Dataset Viewer
Auto-converted to Parquet Duplicate
input
stringlengths
50
4.04k
output
stringlengths
1
2.88k
# -*- coding: utf-8 -*- def main(): _, K = map(int, input().split(' ')) S = input() # Buggy code: # S[K - 1] = S[K - 1].lower() # # print(S) <FILL_ME> if __name__ == '__main__': main()
print(S[:K - 1] + S[K - 1].lower() + S[K:])
def run_solution(): import sys stdin = sys.stdin read_int = lambda : list(map(int,stdin.readline().split())) read_str = lambda : stdin.readline().rstrip() A,B,C,D = read_int() Max = max(A,B,C,D) # Buggy code: # Alice = [True if i >= A and i <= B else False for i in range(Max)] # Bob =...
Alice = [True if i >= A and i < B else False for i in range(Max)] Bob = [True if i >= C and i < D else False for i in range(Max)] Overlap = [True if Alice[i] and Bob[i] else False for i in range(Max)] sec = 0 for o in Overlap: if o: sec += 1 print(sec)
def handle(): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 # Buggy code: # for i in range(N, 0, -1): # ans += min(A[i], B[i - 1]) # B[i - 1] -= min(A[i],B[i - 1]) # ans += min(A[i - 1],B[i - 1]) # B[i - 1] -= min(A[i...
for i in range(N): ans += min(A[i], B[i]) B[i] -= min(A[i], B[i]) ans += min(A[i + 1], B[i]) A[i + 1] -= min(A[i + 1], B[i])
def execute(): A, B, C, K = map(int, input().split()) if A >= K: # Buggy code: # print(A) <FILL_ME> else: if (A + B) >= K: print(A) else: if (A + B + C) >= K: print(A - (K - (A + B))) else: print(A - C)
print(K)
def run(): a, b = map(int,input().split()) # Buggy code: # if b == 0: <FILL_ME> print("0") exit() count = 1 dx = a-1 while a < b: a += dx count += 1 print(count)
if b == 1:
def process_data(): # Buggy code: # import numpy as np # N = int(input()) # s = list(list(input())for i in range(N)) # count = 1 # ans = 0 # s.sort() # for i in range(N): # s[i].sort() <FILL_ME> for i in range(0,N-1): if s[i] == s[i+1]: ans += count ...
N = int(input()) s = list(list(input())for i in range(N)) count = 1 ans = 0 for i in range(N): s[i].sort() s.sort()
def operation(): n,m = map(int,input().split()) a = [list(map(int,input().split())) for i in range(n)] # Buggy code: # b = [list(map(int,input().split())) for i in range(n)] <FILL_ME> ans = [] for i in a: count = 10**10 check = 0 for j in range(m): if count > abs(i[0]-b[j...
b = [list(map(int,input().split())) for i in range(m)]
def parse_and_solve(): S = list(input()) temp = 0 ans = 0 letter = ["A", "T", "C", "G"] for i, val in enumerate(S): if val in letter: temp += 1 else: if ans < temp: ans = temp temp = 0 # Buggy code: # print(ans) # <FILL_ME>
if ans < temp: ans = temp print(ans)
def main(): x, n = map(int, input().split()) p = list(map(int, input().split())) p.sort() if len(p) == 0: print(x) return diff_min = 1000 min_n = 1000 # Buggy code: # for _ in range(1, 101): # diff = abs(_ - x) # if diff < diff_min: # if _ < p[0...
for _ in range(0, 102): diff = abs(_ - x) if diff < diff_min: if _ not in p:
def task(): K = int(input().rstrip()) n = 1 if K%7==0: L = 9 * K / 7 else: L = 9 * K R = 10 ** n s = set() # Buggy code: # if K ==7: <FILL_ME> print(1) else: while R!=1: R = (10 * R) % L n += 1 if R in s: ...
if K == 1 or K == 7:
def evaluate(): N, K = map(int,input().split()) A= list((map(int, input().split()))) an = (K*(K+1))//2 a = ((K-1)*K)//2 au =0 al = 0 for i in range(N): # Buggy code: # for j in range(N): # au += 1 if A[i]<A[j] and i>j else 0 # al += 1 if A[i]<A[j] and i<j els...
for j in range(N): au += 1 if A[i]<A[j] and i>j else 0 al += 1 if A[i]<A[j] and i<j else 0
def main(): n = int(input()) h = list(map(int,input().split())) cost = [100000] * n cost[0] = 0 cost[1] = abs(h[0]-h[1]) for i in range(2,n): sgl = cost[i-1] + abs(h[i]-h[i-1]) dbl = cost[i-2] + abs(h[i]-h[i-2]) cost[i] = min(sgl,dbl) # Buggy code: # print(cost[n]) <F...
print(cost[-1])
def process_input(): num_str = list(str(input())) num = [] for i in range(4): num.append(int(num_str[i])) if num[0] + num[1] + num[2] + num[3] == 7: print(num[0], "+", num[1], "+", num[2], "+", num[3], "=7", sep="") elif num[0] - num[1] + num[2] + num[3] == 7: print(num[0], ...
print(num[0] ,"-", num[1], "-" ,num[2] ,"-", num[3],"=7", sep="") elif num[0] + num[1] - num[2] - num[3] == 7: print(num[0], "+" ,num[1] ,"-" ,num[2], "-" ,num[3], "=7", sep="")
def task(): INF = 10 ** 20 N = int(input()) coin_list = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)] # Buggy code: # dp = [INF]*(W+1) # dp[0] = 0 # # for coin in coin_list: # for i in range(coin,W+1): # dp[i] = min(dp[i], dp[i-coin]+1) # # print(dp[W...
dp = [INF]*(N+1) dp[0] = 0 for coin in coin_list: for i in range(coin,N+1): dp[i] = min(dp[i], dp[i-coin]+1) print(dp[N])
def transform(): import math n = int(input()) # Buggy code: # a = [0]*10001 <FILL_ME> b = math.ceil(math.sqrt(n)) + 1 for i in range(1,b): for j in range(1,b): for k in range(1,b): ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2 a[ans] += 1...
a = [0]*100001
def process_data(): MOD = 1000000007 l = input().split() s = int(l[0]) # Buggy code: # c = int(l[1]) # # if(s > 2*c): # ans = s // 2 # else: # ans = s + (c - 2*s) // 4 <FILL_ME> print(ans)
c = int(l[1]) // 2 if(s > c): ans = c else: ans = s + (c-s) // 2
def check(): import math N,M = map(int,input().split()) List = list(map(int,input().split())) a = 0 b = 0 for i in range(0,N): a = a + List[i] for j in range(0,N): # Buggy code: # if List[j] > math.floor(a/(4*M)): <FILL_ME> b = b+1 if b < M: print('No...
if List[j] >= math.ceil(a/(4*M)):
def procedure(): mod=10**9+7 N,K=map(int,input().split()) term1=N-K+1 term2=1 for i in range(1,K+1): #print((term1,term2)) print((term1*term2)%mod) # Buggy code: # term1 = ((term1*(N-K+1-i))//(i+1))%mod # term2 = ((term2*(K-i))//i)%mod <FILL_ME>
#term1 = ((term1*(N-K+1-i))//(i+1))%mod #term2 = ((term2*(K-i))//i)%mod term1 = (term1*(N-K+1-i))//(i+1) term2 = (term2*(K-i))//i
def main(): s = input() K = int(input()) ind = [] for i in range(len(s)): for j in range(i+1, min(len(s)+1, i+6)): ind.append(s[i:j]) # Buggy code: # ind = sorted(list(ind)) <FILL_ME> print(ind[K-1]) if __name__ == "__main__": main()
ind = sorted(list(set(list(ind)))) # print(ind)
def check(): N = int(input()) P = [int(input()) for _ in range(N)] index = [-1] * N for i, p in enumerate(P): index[p-1] = i res = 1 # Buggy code: # for i in range(N-1): # if index[i] < index[i+1]: # res += 1 # else: # res = 1 <FILL_ME> ans = N...
tmp = 1 for i in range(N-1): if index[i] < index[i+1]: tmp += 1 res = max(res, tmp) else: tmp = 1
def get_result(): N, K, *A = map(int, open(0).read().split()) A = [0] + A visited = [-1] * (N + 1) pre = 0 cycle = 0 cur = 1 for i in range(N): visited[cur] = i cur = A[cur] if visited[cur] >= 0: pre = visited[cur] cycle = i + 1 - visited[c...
for _ in range(min(K, pre + ((K - pre) % cycle))):
def find_answer(): import math N, D = map(int, input().split()) X = [] ans = 0 for i in range(N): x = list(map(int, input().split())) X.append(x) for j in range(i): l = 0 for k in range(D): l += (X[j][k] - x[k]) ** 2 # Buggy code: # if math.sqrt(l) ** 2 == l: ...
if int(math.sqrt(l)) ** 2 == l:
def parse_and_solve(): N = int(input()) ans = "" al = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] while(True): # Buggy code: # if N < 26: # ans = al[N-1] + ans # break # tmp = N%26 # ans = al[tmp-1] + ans # ...
if N <= 26: ans = al[N-1] + ans break tmp = N%26 ans = al[tmp-1] + ans N = N//26 if tmp == 0: N -= 1
def func(): #y,m,d=map(int,input().split()) #a,b=map(int,input().split()) #n=int(input()) #a=int(input()) #b=int(input()) #s=list(input()) #recipe=[list(input().split())for _ in range(n)] #m=int(input()) #have=[list(input().split())for _ in range(m)] #s=[list(input())for _ in ran...
a=list(map(int,input().split()))
def driver(): import itertools N, M, Q = map(int, input().split()) P = [[int(x) for x in input().split()] for _ in range(Q)] li = [x for x in range(1, M+1)] # Buggy code: # Com = itertools.combinations(li, N) <FILL_ME> ans=0 for com in Com: reg=0 for a,b,c,d in P: ...
Com = itertools.combinations_with_replacement(li, N)
def check(): N=int(input()) A=list(map(int,input().split())) A.sort(reverse=True) s=0 t=0 prev=-1 c=0 for a in A: if prev==a: c+=1 else: prev=a c=1 if c==2: if s==0: s=a elif t==0: ...
break if c==4 and t==0: t=a break
def do_work(): from collections import deque H,W = map(int, input().split()) Ch, Cw = map(int, input().split()) Dh, Dw = map(int, input().split()) S = [input() for _ in range(H)] used = [[-1]*W for _ in range(H)] Ch -= 1 Cw -= 1 Dh -= 1 Dw -= 1 q = deque() flag = True ...
if S[k][l] == "#" or S[i][j] == "#":
def attempt(): import sys (n, m, l) = sys.stdin.readline().rstrip('\r\n').split(' ') n = int(n) m = int(m) l = int(l) a = [] b = [] c = [] for ii in range(n): a.append([int(x) for x in input().rstrip('\r\n').split(' ')]) for ii in range(m): b.append([int(x) for x i...
c[ii][jj] = str(c[ii][jj]) print(' '.join(c[ii]))
def evaluate(): x,a,b = map(int, input().split()) if a >= b: print("delicious") # Buggy code: # elif x + a < b: <FILL_ME> print("safe") else: print("dangerous")
elif b - a <= x:
def find_answer(): n=int(input()) a=list(map(int,input().split())) a1=[] for i in range(n-1,-1,-2): a1.append(a[i]) a2=[] for i in range(n-2,-1,-2): a2.append(a[i]) # Buggy code: # a2.reverse <FILL_ME> a1+=a2 print(*a1)
a2.reverse()
#!/usr/bin/env python """AtCoder Beginner Contest 170: C - Forbidden List https://atcoder.jp/contests/abc170/tasks/abc170_c """ def main(): X, N = list(map(int, input().split())) Ps = list(map(int, input().split())) ans = X min_diff = float('inf') # Buggy code: # for d in range(1, 101): # 1-100 ...
for d in range(102): if d in Ps: continue v = abs(X - d) # print('d({}), v({})'.format(d, v)) if v < min_diff: min_diff = v
def run(): n = int(input()) s = input() t = input() for i in range(n): cnt = 0 for j in range(i, n): if s[j] != t[j-i]: break cnt += 1 if cnt == n-i: ans = n+i break # Buggy code: # <FILL_ME> print(ans)
if cnt == 0: ans = 2*n
def evaluate(): # Buggy code: # S = input() # Q = int(input()) # # S_list = list(S) # # r = 1 # a = [] # b = [] # # for i in range(Q): # q = input().split() # if q[0] == '1': # r *= -1 # continue # elif len(q) == 3: # if q[1] == ...
from collections import deque S = input() Q = int(input()) S_list = list(S) r = 1 a = [] b = [] d = deque(a) for i in range(Q): q = input().split() if q[0] == '1': r *= -1 continue elif len(q) == 3: if q[1] == '1': ...
def solve(): x = input() i = 0 ans = 0 for xi in x: if xi == 'A' or xi == 'T' or xi == 'G' or xi == 'C': i = i + 1 else: if ans < i: ans = i i = 0 # Buggy code: # <FILL_ME> print(ans)
if ans < i: ans = i
from math import gcd from datetime import date, timedelta from heapq import* import math from collections import defaultdict, Counter, deque import sys from bisect import * import itertools import copy sys.setrecursionlimit(10 ** 7) MOD = 10 ** 9 + 7 def main(): a, b, x = map(int, input().split()) # Buggy code: #...
if(a % x == 0):
def include3(n): cond = 0 while True: if n%10==3: cond = 1 return cond elif n>9: # Buggy code: # n /= 10 <FILL_ME> else: return cond n = int(input()) for i in range(1,n+1): if i%3==0 or include3(i)==1: print(' ',end='') print(i,end='') print()
n //= 10
def solution(): import numpy as np s=np.array(list(input())) t=np.array(list(input())) ans = len(t) # Buggy code: # for i in range(len(s)-len(t)): <FILL_ME> tmp = sum(s[i:i+len(t)] == t) if ans > len(t) - tmp: ans = len(t) - tmp print(ans)
for i in range(len(s)-len(t)+1):
def driver(): hi, wd = map(int, input().split()) # いずれかが1の場合 if hi==1 or wd ==1: # Buggy code: # print(0) <FILL_ME> exit() # heightまたはwidthが偶数だった場合 if hi%2 == 0 or wd%2 == 0: print(hi*wd//2) else: print(hi*wd//2 + 1)
print(1)
def task(): import itertools N = int(input()) P_ar = list(map(int,input().split())) Q_ar = list(map(int,input().split())) List = list(map(list,list(itertools.permutations(range(N))))) for i in range(N): P_ar[i]-=1 Q_ar[i]-=1 a=-1 b=-1 for i in range(len(List)): ...
print(abs(a-b))
def solve(): # -*- coding: utf-8 -*- n,c,k = map(int, input().split()) k *= 2 t = [] for _ in range(n): t.append(int(input())*2) t.sort() # print(t) res = 0 s = [] for x in t: if len(s)==0: s.append(x) else: # print(x,s,x-s[0]) # Bu...
if x-s[0]>k: while len(s)>0 and x-s[0]>k: res += 1 s = s[c:] s.append(x)
def task(): # Buggy code: # vn,m,q=map(int,input().split()) <FILL_ME> lis=[] for i in range(q): a,b,c,d=map(int,input().split()) lis.append((a,b,c,d)) from itertools import combinations_with_replacement co=list(combinations_with_replacement(range(1,m+1),n)) ans=0 for statu...
n,m,q=map(int,input().split())
def check(): n = int(input()) # Buggy code: # maxv = 10**18 <FILL_ME> minv = 10**18 for i in range(n): r= int(input()) maxv = max(maxv, r - minv) minv = min(minv, r) print(maxv)
maxv = -10**18
def process_data(): N, M = map(int, input().split()) L = [] R = [] l = 0 r = 10 ** 6 for i in range(M): a,b = map(int, input().split()) L.append(a) R.append(b) for i in range(M): if l < L[i]: l = L[i] if r > R[i]: r = R[i] ...
if ans > 0: print(ans) else: print("0")
def check(): N=int(input()) A=list(map(int,input().split())) B=[] for i in range (N): if A[i]%2==0: B.append(A[i]) x=len(B) hantei=0 for i in range(x): if B[i]%3==0: hantei=hantei+1 elif B[i]%5==0: hantei=hantei+1 else: ...
if hantei>=x:
def process(): a,b,c,d=map(int,input().split()) ans=0 # Buggy code: # if d-a>0: # d=d-a # ans+=a # if d-b>0: # d-=b # if d-c==0: # ans-=c # else: # ans=ans-d # else: # ans=a-d <FILL_ME> print(ans)
if d-a>=0: d=d-a ans+=a if d-b>0: d-=b if d-c==0: ans-=c else: ans=ans-d else: ans+=d
def execute(): x=int(input()) days=[] for i in range(x): days.append(list(map(int,input().split()))) # Buggy code: # print(days) <FILL_ME> dp=[0]*3 dp=days[0] for cur in range(1,x): m=[0]*3 for i in range(3): for j in range(3): if i!=j: ...
#print(days)
def resolve(): X, K, D = list(map(int, input().split())) # Buggy code: # k = min(X // D, K) # ans = min(abs(X - D*k),abs(X + D*k)) # l = K-k # if l % 2 == 1: # ans = min(abs(ans-D), abs(ans+D)) # print(ans) <FILL_ME> resolve()
k = min(abs(X) // D, K) x = min(abs(X - D*k),abs(X + D*k)) l = K-k if l % 2 == 1: x = min(abs(x-D), abs(x+D)) print(x)
def solve(): # Buggy code: # S = list(input()) # N = len(S) # K = int(input()) # T = S.copy() # S += S # ans = 0 # cnt = 0 # # if N == 1: # print(K//2) # exit() # <FILL_ME> for i in range(1, N): if S[i - 1] == S[i]: cnt += 1 S[i] = "-...
from collections import defaultdict S = list(input()) N = len(S) K = int(input()) T = S.copy() S += S ans = 0 cnt = 0 f = defaultdict(int) for t in T: f[t] += 1 if len(f) == 1: print(N * K // 2) exit()
def logic(): n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) # Buggy code: # e = 0 # d = sum(b) # # for i in range(n-1): # if a[i]+1 == a[i+1]: # e += c[i-1] # else: # e = e <FI...
e=0 d = sum(b) for i in range(n-1): if a[i]+1 == a[i+1]: e += c[a[i]-1] else: e += 0
def compute(): import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.rea...
dp[y][0] = dp[y-1][0] + (int(m[y][0]=="#") if m[y-1][0]=="." else 0) for x in range(1, w): dp[y][x] = min( dp[y][x-1] + (int(m[y][x]=="#") if m[y][x-1]=="." else 0), dp[y-1][x] + (int(m[y][x]=="#") if m[y-1][x]=="." else 0)
def find_answer(): cnt = 0 W = input() while True: li = input().split() if li[0] == "END_OF_TEXT": break for w in li: # Buggy code: # if w.lower == W: <FILL_ME> cnt += 1 print(cnt)
if w.lower() == W:
def check(): n = int(input()) inab = 0 topb = 0 taila = 0 topb_taila = 0 for _ in range(n): s = str(input()) if (s[0] == "B")&(s[-1] == "A"): topb_taila += 1 else: if (s[0] == "B"): topb += 1 if (s[-1] == "A"): ...
if topb==0: ans+=0 else: ans += topb-1 else: ans += topb else: ans += min(topb,taila) print(ans)
def work(): W, H, x, y = [int(i) for i in input().split()] counter = 0 if x == W/2: # Buggy code: # counter+=1 # # if y == H/2: # counter+=1 <FILL_ME> if counter == 0: print(W*H/2, 0) else: print(W*H/2, 1)
if y == H/2: counter+=1
def process_data(): i,o,t,j,l,s,z=map(int,input().split()) ans=0 ans+=o if j==1 and l==1 and i==1: ans+=3 # Buggy code: # elif j<2 or l<2 or i<2: <FILL_ME> ans+=0 elif j%2==1 and l%2==1 and i%2==1: ans+=j+i+l elif j%2==1 and l%2==1 and i%2==0: ans+=j+i+l-1 ...
elif j<2 and l<2 and i<2:
def execute(): import sys N = int(input()) array = list(map(int,input().split())) if not ( 2 <= N <= 10**5 ): sys.exit() if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit() if 0 in array: print(0); sys.exit() sum = array[0] for I in range(1,len(array)): sum *= array[...
if sum > 10**18: print(-1);sys.exit()
import queue def main(): n, m = map(int, input().split()) G = [[] for _ in range(n+1)] par = [None]*(n+1) # Buggy code: # f = [True]*(n+1) # for _ in range(n-1+m): # a, b = map(int, input().split()) # G[a].append(b) # f[b] = False # p = -1 # for i in range(1, n+1): # ...
cnt = [0]*(n+1) for _ in range(n-1+m): a, b = map(int, input().split()) G[a].append(b) cnt[b] += 1 p = -1 for i in range(1, n+1): if cnt[i] == 0: p = i break par[p] = 0 q = queue.Queue() q.put(p) t = [0]*(n+1) while not q.empty(...
def process_input(): n = int(input()) a = list(map(int,input().split())) ans = [1 for i in range(n+1)]; ans[0] = 0 for i in range(n,0,-1): s = 0 # Buggy code: # for j in range(i*2,n+1,i): s += ans[j] <FILL_ME> if (s - a[i-1])%2 == 0: pass else: ans[i] = 0 print(sum(...
for j in range(i,n+1,i): s += ans[j]
from itertools import permutations def main(): n, m = map(int, input().split()) graph = [[] for _ in range(n)] for _ in range(m): a, b = map(lambda x: int(x) - 1, input().split()) graph[a].append(b) graph[b].append(a) answer = 0 for p in permutations([i for i in range(n)]):...
if p[0] != 0:
def main(): l=[int(x) for x in input().split()] N=l[0] K=l[1] ans = [] while True: ans.append(int(N) % int(K)) N = int(N) / int(K) # Buggy code: # if N < K: <FILL_ME> ans.append(int(N)) break print(len(ans))
if int(N) == 0: break elif N < K:
def task(): K = int(input()) A = list(map(int,input().split())) if A[-1] != 2: print(-1) exit(0) minval = 2 maxval = 3 for i in range(K-1,-1,-1): # Buggy code: # if maxval < A[i] or (minval > A[i] and (((minval % A[i]) + minval) < A[i])): <FILL_ME> print(-1) exit(0) ...
if maxval < A[i] or (minval > A[i] and ((maxval - (maxval % A[i]) < minval))):
def execute(): N,K=map(int,input().split()) # Buggy code: # ans=0 # for i in range(1,N+1): # x=0 # # while True: # # if K < i*(2**x): # ans+= (1/N)*((1/2)**x) # break # # x+=1 # <FILL_ME> print(ans)
ans=0.0 for i in range(1,N+1): x=0 while True: if K <= i*(2**x): ans+= (1/N)*((1/2**x)) break x+=1
def answer(): n,h=map(int,input().split()) x=[0]*n y=0 for i in range(n): a,b=map(int,input().split()) y=max(y,a) x[i]=b cnt=0 x.sort(reverse=1) for i in x: if i>y: cnt+=1 h-=i if h<=0: # Buggy code: # break <FILL_ME...
print(cnt) exit()
def work(): a = [] a = input().split() A = int(a[0]) B = int(a[1]) C = int(a[2]) # Buggy code: # if A - B > C : # ans = 0 # if A - B < C : <FILL_ME> ans = C - (A - B) print(ans)
if (A - B) >= C : ans = 0 if (A - B) < C :
def solve(): # -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. Author : Takeshi Saga """ import itertools import numpy as np tmp = input() # Buggy code: # N,K = tmp.split() # que = input() # try: # N = int(N) # except: # p...
#tmp = "5 3" N,K = tmp.split() que = input() #que = "50 100 80 120 80" try: N = int(N) except: pass try: K = int(K) except: pass que = [int(x) for x in que.split()] #print(que) """ tmp = [] for x in que: for xx in range(K): ...
def driver(): A,B,M=map(int,input().split()) vecA=list(map(int,input().split())) vecB=list(map(int,input().split())) matX=[input().split() for k in range(M)] price = 10**6 for i in range(0,M): pricecom = int(vecA[int(matX[i][0]) -1]) + int(vecB[int(matX[i][1]) -1]) - int(matX[i][2]) ...
price2=int(min(vecA)) + int(min(vecB)) if price2<=price: price=price2
def func(): n = int(input()) cost = [] i = 2 # Buggy code: # while i < n**0.5: # if n % i == 0: # cost.append(i+n/i-2) # i += 1 # if len(cost) == 0: # cost.append(n-1) # print(int(min(cost))) # <FILL_ME>
while i <= n**0.5: if n % i == 0: cost.append(i+n/i-2) i += 1 if len(cost) == 0: cost.append(n-1) print(int(min(cost)))
def logic(): Q,H,S,D = map(int,input().split()) N = int(input()) Q_l = [8*Q,0.25,Q] H_l = [4*H,0.5,H] S_l = [2*S,1,S] D_l = [D,2,D] L = [Q_l,H_l,S_l,D_l] L.sort() cost = 0 for e in L: # Buggy code: # num = N // e[1] # N -= (N // e[1]) * e[1] # cost += num ...
num = int(N // e[1]) N -= (num) * e[1] cost += num * e[2] print(cost)
def run(): S = list(input().rstrip()) if S[0] == 'A': S[0] = 'a' cnt = 0 flag = True # Buggy code: # for i, s in enumerate(S[2:-2]): <FILL_ME> if s == 'C': cnt += 1 if flag: S[2+i] = 'c' flag = False if cnt == 1 and ''.join(S).islower(): print(...
for i, s in enumerate(S[2:-1]):
def task(): import collections N, M = map(int, input().split()) G = [[] for i in range(N)] # Buggy code: # for i in range(N): # a, b = map(int, input().split()) # G[b-1].append(a-1) # G[a-1].append(b-1) # # queue = collections.deque([0]) # visited = [0]*N # visited...
for i in range(M): a, b = map(int, input().split()) G[b-1].append(a-1) G[a-1].append(b-1) queue = collections.deque([0]) visited = [0]*N visited[0] = 1 while queue: x = queue.popleft() for i in G[x]: if visited[i] == 0: visited[i] ...
def attempt(): s = int(input()) a =[s] # Buggy code: # for i in range(1,101): <FILL_ME> if a[i-1] % 2 == 0: if (a[i-1]//2) in a: print(len(a)+1) break else: a.append(a[i-1]//2) elif a[i-1] % 2 == 1: if (a[i-1...
i = 0 while True: i += 1
def procedure(): from collections import Counter N = int(input()) A = list(map(int, input().split())) #cnt = 0 #for i in range(N): # for j in range(i, N): # if j - i == A[i] + A[j]: # cnt += 1 Ap = [A[i]+i for i in range(len(A))] Am = [i-A[i] for i in range(len(A))] ...
print(cnt)
def run(): K = int(input()) A = list(map(int, input().split())) if A[-1] != 2: print(-1) exit() else: m, M = 2, 3 for i in range(K-2, -1, -1): if A[i] > M: print(-1) exit() else: if m % A[i] != 0: ...
if m > M: print(-1) exit() else: print(m, M)
def parse_and_solve(): import sys n = input() lengths = list(map(int,input().split(" "))) lengths = sorted(lengths) # Buggy code: # max = length.pop(-1) # if max < sum(length) : <FILL_ME> print("Yes") else : print("No")
max = lengths.pop(-1) if max < sum(lengths) :
def transform(): n=int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a_sum=sum(a) b_sum=sum(b) c = a[:] if a_sum< b_sum: print(-1) else: sub_ab=[0 for i in range(n)] for i in range(n): sub_ab[i]=c[i]-b[i] ...
print(m+minus_number)
def calculate(): import numpy as np N, M = list(map(int, input().split())) A = list(map(int, input().split())) total_vote = np.sum(A) threshold = total_vote/(4*M) A.sort(reverse = True) # Buggy code: # if A[M] > threshold: <FILL_ME> print('Yes') else: print('No')
if A[M-1] >= threshold:
def process(): S=list(input()) count=0 for s in S: if s=='+': # Buggy code: # count=+1 # if s=='-': # count=-1 <FILL_ME> print(count)
count=count+1 if s=='-': count=count-1
def handle(): n = int(input()) h = list(map(int, input().split())) h_max = h[0] for i in range(1, n): if h[i-1] > h_max: # Buggy code: # h_max == h[i-1] <FILL_ME> if h[i] < h_max -1: print("No") exit(0) print("Yes")
h_max = h[i-1]
def solve(): N = int(input()) a = list(map(int, input().split())) colors = set() free_num = 0 for rate in a: if rate < 400: colors.add("grey") elif rate < 800: colors.add("brown") elif rate < 1200: colors.add("green") elif rate < 1...
if len(colors) > 0: print(len(colors), free_num + len(colors)) else: print(1, free_num)
def program(): K = int(input()) if K % 2 == 0: print(-1) else: mod = K # Buggy code: # t = 7 # for _ in range(K+1): # t *= 10 # t += 7 # if t % mod == 0: # print(_+2) <FILL_ME> exit(0) else: ...
t = 0 for _ in range(K+1): t *= 10 t += 7 if t % mod == 0: print(_+1)
def process_data(): a, b, k = map(int, input().split()) cnt = 0 # Buggy code: # for i in range(1, 100): <FILL_ME> if a % i != 0: continue if b % i != 0: continue cnt += 1 if cnt == k: print(i) break
for i in range(101): i = 101 - i
def program(): import statistics N = int(input()) L = list(map(int,input().split( ))) f1 = [li-j for li,j in zip(L,range(1+N+1))] b = statistics.median(f1) if N%2 != 0: ans = sum([abs(li-j-b) for li,j in zip(L,range(1+N+1))]) else: # Buggy code: # b1 = f1[int(b/2-0.5)] # b2 = ...
b1 = int(b+0.5) b2 = int(b-0.5)
def process_data(): s = list(input().rstrip()) r=0 bm=0 while r<len(s)-1: if s[r]=="B" and s[r+1]=="W": # Buggy code: # break # bm+=1 # r+=1 # ans=0 # for i in range(r, len(s)): <FILL_ME> if s[i]=="W": ans+=bm if s[i]=="B": ...
bm+=1 break elif s[r]=="B": bm+=1 r+=1 ans=0 for i in range(r+1, len(s)):
def answer(): N = 10**6 mod = 10**9 + 7 fact = [1] for i in range(1, N+1): fact.append(fact[-1]*i%mod) n, m = map(int, input().split()) # Buggy code: # ans = 0 # if n - m > 1 or m - n > 1: # ans = 0 # elif n - m == 0: # ans = 2 * fact[n] * fact[m] # else: # ...
if n - m > 1 or m - n > 1: ans = 0 elif n - m == 0: ans = 2 * fact[n] * fact[m] % mod else: ans = fact[n] * fact[m] % mod
def find_answer(): N, M = map(int, input().split()) A = list(map(int, input().split())) check = ((1 / (4 * M)) * sum(A)) x = 0 for item in A: if item < check: x += 1 ans = N - x # Buggy code: # if ans > M : <FILL_ME> print('Yes') else: print('No')
if ans >= M :
def solve(): # Buggy code: # N=int(input("N:")) # a,b=map(int,input().split()) <FILL_ME> Num=0 Num_sum=0 for number in range(1,N+1): for num in str(number): num=int(num) Num+=num if Num>=a and Num<=b: Num_sum+=number Num=0 print(Num_s...
N,a,b=map(int,input().split())
def parse_and_solve(): N = int(input()) a=0;b=0;c=0 L = list(map(int,input().split())) for i in range(N): if L[i]%4 == 0: c += 1 elif L[i]%2 == 0: b += 1 else: a += 1 t = a+b+c # Buggy code: # print(a,b,c) <FILL_ME> ans = "No" if a == 0: a...
#print(a,b,c)
import sys input=sys.stdin.readline from collections import deque sys.setrecursionlimit(10**6) def main(): n,m=map(int,input().split()) graph=[[] for _ in range(n)] seen=[False]*n for _ in range(m): a,b=map(int,input().split()) graph[a-1].append(b-1) graph[b-1].append(a-1) ...
seen[0]=True while len(q): now=q.popleft() for i in graph[now]: if seen[i]: continue seen[i]=True
def work(): import sys n = int(input()) for i in range(3, n + 1): x = i if x % 3 == 0 or x % 10 == 3: sys.stdout.write(' ') sys.stdout.write(str(i)) else: while x != 0: x = int(x / 10) if x % 10 == 3: sys.stdout.write(' ') sys.stdout.write(str(...
break print()
def perform(): mod = 10 ** 9 + 7 n, k = map(int, input().split()) edge = [[] for _ in range(n)] parent = [0] * n permutation_k2 = [1] * n for i in range(n-1): a, b = map(int, input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) permutation_k2[i+1] = permutation_k...
if n == 1: print(k) else: print(count)
def transform(): # Buggy code: # A=int(input()) # B=int(input()) # C=int(input()) # D=int(input()) # # if A>B: # if C>D: # print(B+D) # else: # print(B+C) # else: # if C>D: # print(B+D) # else: # print(B+C) <FILL_ME>
A=int(input()) B=int(input()) C=int(input()) D=int(input()) if A>B: if C>D: print(B+D) else: print(B+C) else: if C>D: print(A+D) else: print(A+C)
def handle(): i,j=map(int,input().split()) listA=[] # Buggy code: # for i in range(i): # listA.append(list(map(int,input().split()))) # listA[n].append(sum(listA[n])) # listA.append([]) # for n in range(j+1): # number =0 # for m in range(i): # number+=list...
for n in range(i): listA.append(list(map(int,input().split()))) listA[n].append(sum(listA[n])) listA.append([]) for n in range(j+1): number=0 for m in range(i): number+=listA[m][n] listA[i].append(number) for n in range(i+1): print(' '.join(map...
def handle(): N=int(input()) S=input() K=int(input()) Slist =list(S) for i in range(N): # Buggy code: # if Slist[K] == Slist[i]: <FILL_ME> continue else: Slist[i]="*" S = ''.join(Slist) print(S)
if Slist[K-1] == Slist[i]:
def do_work(): s = input() k = int(input()) answer = 1 if len(s) == 1: answer = s else : # Buggy code: # for i in range(len(s)): <FILL_ME> if s[i] != "1": answer = s[i] break print(answer)
for i in range(k):
def logic(): number=list(map(int,input().split())) n,m=number[0],number[1] height=list(map(int,input().split())) load=[[] for i in range(n+1)] for i in range(m): tmp=list(map(int,input().split())) if tmp[1] not in load[tmp[0]]: load[tmp[0]].append(tmp[1]) if tmp[0...
if load[i]==[]: answer+=1 while load[i] != []: if height[i-1]<=height[load[i][-1]-1]:
def process_data(): data1 = input() data2 = input() count = 3 -1 sw = 0 i = 0 j = len(data2)-1 while i <= count: if data1[i] == data2[j]: sw += 1 i += 1 j -= 1 if sw == 3: # Buggy code: # print("Yes") # else: # print("No") <FILL_ME...
print("YES") else: print("NO")
def task(): N = int(input()) S = list() if N==0: print(0) exit() elif N>0: while N>0: S.append(N%2) N//=2 # Buggy code: # S.append(0) # for i in range(len(S)-1): # if i%2==1 and S[i]==1: # S[i+1] += 1 # if S[i]==2: # S[i]=...
S.append(0) S.append(0) for i in range(len(S)-1): if i%2==1 and S[i]==1: S[i+1] += 1 if S[i]==2: S[i]=0 S[i+1]+=1 else: N *= -1 while N>0: S.append(N%2) N//=2 S.append(0) S.append(0) for i in range(len(S)-1...
def answer(): S,K=input(),input() if len(S) >= int(K): # Buggy code: # if S[int(K)-1] == '1': <FILL_ME> print('1') exit() for s in S: if s != '1': print(s) exit() print('1')
if set(S[:int(K)]) == set(['1']):
def solution(): import math D, G = list(map(int, input().split())) pc = [list(map(int, input().split())) for _ in range(D)] digit = '0'+str(D)+'b' minimam = float("inf") for i in range(2**D): pattern = list(str(format(i, digit))) point = 0 count = 0 tmp = -1 ...
# count += countTmp if countTmp < pc[tmp][0]: count += countTmp else: continue
def q2(): N, M = (int(i) for i in input().split()) A = [int(i) for i in input().split()] sum_A = sum(A) # Buggy code: # if N > sum_A: # ans = N - sum_A # else: # ans = 0 <FILL_ME> print(ans) if __name__ == '__main__': q2()
if N >= sum_A: ans = N - sum_A else: ans = -1
def transform(): X,K,D = map(int, input().split()) if X == 0: if K % 2 == 0: print(0) else: print(D) exit(0) if X < 0: xminus = True X = (-1) * X else: xminus = False if abs(X) > K*D: ans = X - K*D else: wk = X // D K -= wk ...
print(ans)
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
3