Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in (a+1):
    for j in (b+1):
        for k in (c+1):
            if i*500 + j*100 + k*50 == x:
                ans += 1
print(ans)

Fixed submission:
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(len(set(map(int, [input for i in range(n)]))))

Fixed submission:
n = int(input())
print(len(set(map(int, [input() for i in range(n)]))))
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input()))
if a > 9 or b > 9:
  print(-1)
else:
  print(a * b)

Fixed submission:
a, b = list(map(int, input().split(" ")))
if a > 9 or b > 9:
  print(-1)
else:
  print(a * b)
Buggy python submission (verdict: Time Limit Exceeded):
a=[]
b=int(input())
c=[]
i=0
while i<b:
    a.append(int(input()))
    i+=1

i=1
while i<=b:
    for x in a:
        c.append(x)
    c[i-1]=0
    c.sort()
    print(c[-1])
    i+=1
    c=[]

Fixed submission:
a=[]
b=int(input())
c=[]
i=0
while i<b:
    a.append(int(input()))
    i+=1
for x in a:
    c.append(x)
c.sort()

i=1

if c[-1]!=c[-2]:
    while i<=b:
        if a[i-1]!=c[-1]:
            print(c[-1])
        else:
            print(c[-2])
        i+=1
else:
    while i<=b:
        print(c[-1])
        i+=1
Buggy python submission (verdict: Time Limit Exceeded):
a=[]
i=1
k=1
l=0
rk=[]
bk=[]
a.append(int(input()))
for x in input().split(" "):
    a.append(int(x))

while k<=100000:
    while i<=a[0]:
        if a[i]>=k:
            rk.append(a[i])
        else:
            bk.append(a[i])
        i+=1
    if len(rk)==len(bk):
        l+=1
    rk=[]
    bk=[]
    i=1
    k+=1
        
print(l)

Fixed submission:
n=0
a=[]
i=1
ii=1
l=0
tasu=0
rk=[]
bk=[]
n=int(input())
for x in input().split(" "):
    a.append(int(x))

a.sort()

print(a[int(len(a)/2)]-a[int(len(a)/2)-1])

Buggy python submission (verdict: Runtime Error):
a=[]
i=1
k=0
l=0
rk=[]
bk=[]
a.append(int(x))
for x in input().split(" "):
    a.append(int(x))

while k<=100000:
    while i<=a[0]:
        if a[i]>=k:
            rk.append(a[i])
        else:
            bk.append(a[i])
        i+=1
    if len(rk)==len(bk):
        l+=1
    rk=[]
    bk=[]
    i=1
    k+=1
        
print(l)


Fixed submission:
n=0
a=[]
i=1
ii=1
l=0
tasu=0
rk=[]
bk=[]
n=int(input())
for x in input().split(" "):
    a.append(int(x))

a.sort()

print(a[int(len(a)/2)]-a[int(len(a)/2)-1])
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N==1:
  print(1)
elif N % 2==0:
  print(1/2)
else:
  print((N-1)/2N)


Fixed submission:
N=int(input())
if N==1:
  print(1)
elif N%2 == 0:
  print(1/2)
else:
  print((N+1)/(2*N))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
A,B=map(int,input().split())
gcd_ab=gcd(A,B)
ans=1
for i in range(2,gcd_ab+1):
  if gcd_ab == 1:
    break
  elif (gcd_ab/i)%1 == 0:
    ans+=1
    while (gcd_ab/i)%1 == 0:
      gcd_ab = gcd_ab/i
print(ans)

Fixed submission:
import fractions
import math
A,B=map(int,input().split())

x=fractions.gcd(A,B)

l=[]
for i in range(2, math.floor(math.sqrt(x))+1):
  count=0
  while x%i==0:
    count+=1
    x/=i
  if count>=1:
    l.append([i,count])
if x>math.floor(math.sqrt(x)):
  l.append([x, 1])
print(len(l)+1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,K=map(int,input().split())
s=input()
ans=0
l1=deque([])
l2=deque([])
for i in range(N-1):
  if s[i:i+2]=='LR':
    l1.append(i)
  elif s[i:i+2]=='RL':
    l2.append(i)
  elif s[i]=='L' and s[i+1]=='L':
    ans+=1
  elif s[i]=='R' and s[i+1]=='R':
    ans+=1

while K>0 and len(s)-2>ans:
  if l1[0]<l2[-1]:
    n1=l1.popleft()
    n2=l2.pop()
    l1=deque([(n1+n2-n) for n in l1 if n<n2])
    l2=deque([(n1+n2-n) for n in l2])
    ans+=2
    K-=1
if len(s)-2<=ans and K>=1:
  ans=len(s)-1
print(ans)

Fixed submission:
N,K=map(int,input().split())
s=input()
ans=0
l1=[]
l2=[]
for i in range(N-1):
  if s[i:i+2]=='LR':
    l1.append(i)
  elif s[i:i+2]=='RL':
    l2.append(i)
  elif s[i]=='L' and s[i+1]=='L':
    ans+=1
  elif s[i]=='R' and s[i+1]=='R':
    ans+=1

while K>0 and len(s)-2>ans:
  ans+=2
  K-=1
if len(s)-2<=ans and K>=1:
  ans=len(s)-1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
l1=list(map(int,input().split()))
l2=[]
l3=[]
for i in range(N-1):
  if l1[i]<l1[i+1]:
    l2.append(i)
l2.append(N)
for i in range(len(l2)-1):
  if l2[i+1]-l2[i] >= 2:
    l3.append(l2[i+1]-l2[i]-2)
print(max(l3))

Fixed submission:
N=int(input())
l1=list(map(int,input().split()))
l1.append(max(l1)+1)
l2=[-1]
l3=[]
for i in range(N):
  if l1[i]<l1[i+1]:
    l2.append(i)
for i in range(len(l2)-1):
  if l2[i+1]-l2[i] >= 2:
    l3.append(l2[i+1]-l2[i]-1)
print(max(l3) if l3 else 0)

Buggy python submission (verdict: Runtime Error):
N=int(input())
l1=list(map(int,input().split()))
l2=[]
l3=[]
for i in range(N-1):
  if l1[i]<l1[i+1]:
    l2.append(i)
l2.append(N-2)
for i in range(len(l2)-1):
  l3.append(l2[i+1]-l2[i])
print(max(l3))

Fixed submission:
N=int(input())
l1=list(map(int,input().split()))
l1.append(max(l1)+1)
l2=[-1]
l3=[]
for i in range(N):
  if l1[i]<l1[i+1]:
    l2.append(i)
for i in range(len(l2)-1):
  if l2[i+1]-l2[i] >= 2:
    l3.append(l2[i+1]-l2[i]-1)
print(max(l3) if l3 else 0)

Buggy python submission (verdict: Runtime Error):
N=int(input())
l1=list(map(int,input().split()))
l2=[]
l3=[]
for i in range(N-1):
  if l1[i]<l1[i+1]:
    l2.append(i)

for i in range(len(l2)-1):
  l3.append(l2[i+1]-l2[i])
print(max(l3))

Fixed submission:
N=int(input())
l1=list(map(int,input().split()))
l1.append(max(l1)+1)
l2=[-1]
l3=[]
for i in range(N):
  if l1[i]<l1[i+1]:
    l2.append(i)
for i in range(len(l2)-1):
  if l2[i+1]-l2[i] >= 2:
    l3.append(l2[i+1]-l2[i]-1)
print(max(l3) if l3 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=[]
for i in range(N):
  l.append(sorted(input()))
ans=0
for a in range(N):
  for b in range(a+1,N):
    if l[a]==l[b]:
      ans+=1
print(ans)

Fixed submission:
N=int(input())
l=[]
from collections import Counter
for i in range(N):
  l.append(''.join(sorted(input())))
l1=Counter(l).values()
from math import factorial
ans=0
for a in l1:
  if a >= 2:
    ans+=int(factorial(a)/(factorial(a-2)*factorial(2)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [input() for i in range(n)]

from collections import Counter
ans = 0
for i in range(n):
  for j in range((i+1),n):
    if Counter(l[i]) == Counter(l[j]):
      ans += 1
print(ans)

Fixed submission:
N=int(input())
l=[]
from collections import Counter
for i in range(N):
  l.append(''.join(sorted(input())))
l1=Counter(l).values()
from math import factorial
ans=0
for a in l1:
  if a >= 2:
    ans+=int(factorial(a)/(factorial(a-2)*factorial(2)))
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [input() for i in range(n)]

from collections import Counter
ans = 0
for w1,w2 in l:
  if Counter(w1) == Counter(w2):
    ans += 1
print(ans)

Fixed submission:
N=int(input())
l=[]
from collections import Counter
for i in range(N):
  l.append(''.join(sorted(input())))
l1=Counter(l).values()
from math import factorial
ans=0
for a in l1:
  if a >= 2:
    ans+=int(factorial(a)/(factorial(a-2)*factorial(2)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [input() for i in range(n)]

from collections import Counter
ans = 0
for i in range(len(l)):
  for j in range((i+1),len(l)):
    if Counter(l[i]) == Counter(l[j]):
      ans += 1
print(ans)

Fixed submission:
N=int(input())
l=[]
from collections import Counter
for i in range(N):
  l.append(''.join(sorted(input())))
l1=Counter(l).values()
from math import factorial
ans=0
for a in l1:
  if a >= 2:
    ans+=int(factorial(a)/(factorial(a-2)*factorial(2)))
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
res = -A+B+C
if res <= 0:
  res = 0
return res

Fixed submission:
A,B,C = map(int,input().split())
res = -A+B+C
if res <= 0:
  res = 0
print(res)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
return -A+B+C            

Fixed submission:
A,B,C = map(int,input().split())
res = -A+B+C
if res <= 0:
  res = 0
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N == 10**5:
  res = 90909
elif 10**4 <= N < 10**5:
  res = N-9089
elif 10**3 < N < 10**4:
  res = 910
elif 10**2 < N < 10**3:
  res = N-90
elif 1 <= N < 10**2:
  res = N
print(res)


Fixed submission:
N = int(input())
if N == 10**5:
  res = 90909
elif 10**4 <= N < 10**5:
  res = N-9090
elif 10**3 <= N < 10**4:
  res = 909
elif 10**2 <= N < 10**3:
  res = N-90
elif 10 <= N < 10**2:
  res = 9
elif 1 <= N < 10:
  res = N
print(res)

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N = 10**5:
  print(90909)
elif 10**4 <= N < 10**5:
  print(N-9089)
elif 10**3 < N < 10**4:
  print(910)
elif 10**2 < N < 10**3:
  print(N-90)
elif 1 <= N < 10**2:
  print(N)


Fixed submission:
N = int(input())
if N == 10**5:
  res = 90909
elif 10**4 <= N < 10**5:
  res = N-9090
elif 10**3 <= N < 10**4:
  res = 909
elif 10**2 <= N < 10**3:
  res = N-90
elif 10 <= N < 10**2:
  res = 9
elif 1 <= N < 10:
  res = N
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split()))
for n in range(N-2,0,-1):
  if l[n] > l[n+1]:
    l[n] -= 1
  if l[n] > l[n+1]:
    print('No')
    sys.exit()
print('Yes')

Fixed submission:
import sys
N = int(input())
l = list(map(int,input().split()))
for n in range(N-2,0,-1):
  if l[n] > l[n+1]:
    l[n] -= 1
  if l[n] > l[n+1]:
    print('No')
    sys.exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split()))
for n in range(N):
  if l[N-n-1] - l[N-n] > 1:
    print('No')
    break
  elif 0 < l[N-n-1] - l[N-n] <= 1:
    l[N-n-1] -= 1
  else:
print('Yes')

Fixed submission:
import sys
N = int(input())
l = list(map(int,input().split()))
for n in range(N-2,0,-1):
  if l[n] > l[n+1]:
    l[n] -= 1
  if l[n] > l[n+1]:
    print('No')
    sys.exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
N=int(input())
l=list(map(int,input().split()))
l1=sorted(l)
ans=0
for i in range(N):
  if l[i]!=l1[i]:
    ans+=1
if ans==0 or ans==2:
  print('YES')
else:
  print('NO')

Fixed submission:
x,y=map(int,input().split())
if (x+y)%2==0:
  print(int((x+y)/2))
else:
  print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
N,D=map(int,input().split())
print((N//(2D+1))+1)

Fixed submission:
import math
N,D=map(int,input().split())
print(math.ceil(N/(2*D+1)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=[]
for i in range(N):
  l.append(int(input()))
i=l.index(max(l))
if i==0:
  l1=l[1:]
  print(max(l1))
  for a in range(N-1):
    print(max(l))
elif i==N:
  l1=l[:N]
  for a in range(N-1):
    print(max(l))
  print(max(l1))
else:
  l1=l[:i]+l[i+1:]
  for a in range(i):
    print(max(l))
  print(max(l1))
  for a in range(N-i-1):
    print(max(l))

Fixed submission:
N=int(input())
l=[]
for i in range(N):
  l.append(int(input()))
l_max=max(l)
i=l.index(l_max)
if i==0:
  l1=l[1:]
  print(max(l1))
  for a in range(N-1):
    print(l_max)
elif i==N:
  l1=l[:N]
  for a in range(N-1):
    print(l_max)
  print(max(l1))
else:
  l1=l[:i]+l[i+1:]
  for a in range(i):
    print(l_max)
  print(max(l1))
  for a in range(N-i-1):
    print(l_max)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=[]
for i in range(N):
  l.append(int(input()))
for i in range(N):
  if i==0:
    l1=l[1:]
  elif i==N:
    l1=l[:N]
  else:
    l1=l[:i]+l[i+1:]
  print(max(l1))

Fixed submission:
N=int(input())
l=[]
for i in range(N):
  l.append(int(input()))
l_max=max(l)
i=l.index(l_max)
if i==0:
  l1=l[1:]
  print(max(l1))
  for a in range(N-1):
    print(l_max)
elif i==N:
  l1=l[:N]
  for a in range(N-1):
    print(l_max)
  print(max(l1))
else:
  l1=l[:i]+l[i+1:]
  for a in range(i):
    print(l_max)
  print(max(l1))
  for a in range(N-i-1):
    print(l_max)
Buggy python submission (verdict: Runtime Error):
N = int(input())
tree = [[] for i in range(N)]
color = [-1] * N
for i in range(N-1):
  u, v, w = map(int, input().split())
  tree[u-1].append((v-1, w))
  tree[v-1].append((u-1, w))


def dfs(u):
  for v, w in tree[u]:
    if color[v] == -1:
      color[v] = color[u] ^ (w % 2)
      dfs(v)


color[0] = 0
dfs(0)
print('\n'.join(map(str, color)))





Fixed submission:
import sys
sys.setrecursionlimit(100000)

N = int(input())
tree = [[] for i in range(N)]
color = [-1] * N
for i in range(N-1):
  u, v, w = map(int, input().split())
  tree[u-1].append((v-1, w))
  tree[v-1].append((u-1, w))


def dfs(u):
  for v, w in tree[u]:
    if color[v] == -1:
      color[v] = color[u] ^ (w % 2)
      dfs(v)


color[0] = 0
dfs(0)
print('\n'.join(map(str, color)))
Buggy python submission (verdict: Runtime Error):
from collections import deque
import fractions
N=int(input())
s=deque(list(map(int,input().split())))
ans=1
for i in range(N):
  a=s.popleft()
  b=fractions.gcd(s[0],s[1])
  for j in range(2,N-2):
    b=fractions.gcd(b,s[j])
  ans=max(ans,b)
  s.append(a)
print(ans)

Fixed submission:
import fractions
N=int(input())
l1=list(map(int,input().split()))
l2=[0]*(N+1)
l3=[0]*(N+1)
for i in range(N):
  l2[i+1]=fractions.gcd(l2[i],l1[i])
for j in range(N-1,0,-1):
  l3[j-1]=fractions.gcd(l3[j],l1[j])
ans=1
for k in range(N):
  ans=max(ans,fractions.gcd(l2[k],l3[k]))
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
l=list(map(int,input().split()))
l2=sorted([num for num in l if num<0])
l3=sorted([num for num in l if num>=0])
if len(l2)%2==0:
  ans=sum([abs(n) for n in l])

else:
  if abs(l2[-1]) < l3[1]:
    x=l2.pop()
  else:
    x=l3.pop(0)
  ans=sum([abs(n) for n in l2])+sum(l3)-abs(x)
print(ans)

Fixed submission:
N=int(input())
l=list(map(int,input().split()))
l2=sorted([num for num in l if num<0])
l3=sorted([num for num in l if num>=0])
if len(l2)%2==0:
  ans=sum([abs(n) for n in l])

elif l3!=[]:
  if abs(l2[-1]) < l3[0]:
    x=l2.pop()
  else:
    x=l3.pop(0)
  ans=sum([abs(n) for n in l2])+sum(l3)-abs(x)
else:
  x=l2.pop()
  ans=sum([abs(n) for n in l2])-abs(x)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
l1=list(map(int,input().split()))
ans=0
h=0
for i in range(N):
  if h<=l[i]:
    ans+=1
    h=max(h,l[i])
print(ans)

Fixed submission:
N=int(input())
l1=list(map(int,input().split()))
ans=0
h=0
for i in range(N):
  if h<=l1[i]:
    ans+=1
    h=max(h,l1[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
b=int(input())
print('A' if b=='T'
      else 'T' if b=='A'
      else 'G' if b=='C'
      else 'C')

Fixed submission:
b=input()
print('A' if b=='T'
      else 'T' if b=='A'
      else 'G' if b=='C'
      else 'C')
Buggy python submission (verdict: Runtime Error):
l=[c for c in input()]
l1=[-1]
l2=[]
for i,j in enumerate(l):
  if j not in 'ACGT':
    l1.append(i)
for i in range(len(l1)-1):
  l2.append(l1[i+1]-l1[i]-1)
print(max(l2))

Fixed submission:
l=[c for c in input()]
l1=[-1]
l2=[]
for i,j in enumerate(l):
  if j not in 'ACGT':
    l1.append(i)
l1.append(len(l))
for i in range(len(l1)-1):
  l2.append(l1[i+1]-l1[i]-1)
print(max(l2))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import fractions
N = int(input())
t = tuple(map(int,input().split()))

def lcm(x,y):
  return x*y/fractions.gcd(x,y)

m=reduce(lcm, t)-1
ans=0
for i in t:
  ans+=m%i
print(int(ans))

Fixed submission:
N = int(input())
t = tuple(map(int,input().split()))
ans=0
for i in t:
  ans+=i-1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N,M=map(int,input().split())

bridge=[0]*(N-1)
l=[]
for _ in range(M):
  l.append(list(map(int,input().split())))

for sl in l:
  for i in range(sl[0]-1,sl[1]-1):
    bridge[i]+=1
ans=0
# bridge=[4,6,6,4]
while max(bridge)>=1:
  m=bridge.index(max(bridge)) #m=1
  l1=copy.deepcopy(l)
  for sl in l1:
    if(m>=sl[0]-1 and m<sl[1]-1):
      for j in range(sl[0]-1,sl[1]-1):
        bridge[j]-=1
      l.remove(sl)
  ans+=1
print(ans)

Fixed submission:
N,M = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(M)]
l.sort(key= lambda x: x[1])
removed = 0
ans = 0
for i in l:
  s = i[1]
  if removed<i[0]:
    removed = s-1
    ans+=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=list(map(int,input().split()))
max_n=max(l)
min_n=min(l)
res=float('inf')
for j in range(max_n-min_n+N+1):
  ans=0
  for i in range(N):
    ans+=abs(max_n+i-l[i]-j)
  if res > ans:
    res = ans
print(res)

Fixed submission:
N=int(input())
l=list(map(int,input().split()))
for i in range(N):
  l[i] -= i
l.sort()
center_num=l[N//2]
ans=0
for i in range(N):
  ans+=abs(l[i]-center_num)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
class UnionFind():
  def __init__(self, x):
    self.x=x
    self.root=[-1]*(N+1)
    self.rnk=[0]*(N+1)
  
  def Find_root(self, x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.Find_root(self.root[x])
      return self.root[x]
    
  def Unite(self, x, y):
    x = self.Find_root(x)
    y = self.Find_root(y)
    if x==y:
      return
    elif self.rnk[x]>self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x]==self.rnk[y]:
        self.rnk[y]+=1
  
  def isSameGroup(self, x, y):
    return self.Find_root(x)==self.Find_root(y)
  
  def Count(self, x):
    return -self.root[self.Find_root(x)]
N,K,L=map(int,input().split())
u1=UnionFind(N)
u2=UnionFind(N)
for _ in range(K):
  x,y=map(int,input().split())
  u1.Unite(x,y)
for _ in range(L):
  x,y=map(int,input().split())
  u2.Unite(x,y)

l=[1]*N
for i,j in combinations(range(N),2):
  if u1.isSameGroup(i+1,j+1) and u2.isSameGroup(i+1,j+1):
    l[i]+=1
    l[j]+=1
  else:
    continue
l=[str(n) for n in l]
print(' '.join(l))
    

Fixed submission:
from itertools import combinations
from collections import Counter
class UnionFind():
  def __init__(self, x):
    self.x=x
    self.root=[-1]*(N+1)
    self.rnk=[0]*(N+1)
  
  def Find_root(self, x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.Find_root(self.root[x])
      return self.root[x]
    
  def Unite(self, x, y):
    x = self.Find_root(x)
    y = self.Find_root(y)
    if x==y:
      return
    elif self.rnk[x]>self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x]==self.rnk[y]:
        self.rnk[y]+=1
  
  def isSameGroup(self, x, y):
    return self.Find_root(x)==self.Find_root(y)
  
  def Count(self, x):
    return -self.root[self.Find_root(x)]
N,K,L=map(int,input().split())
u1=UnionFind(N)
u2=UnionFind(N)
for _ in range(K):
  x,y=map(int,input().split())
  u1.Unite(x-1,y-1)
for _ in range(L):
  x,y=map(int,input().split())
  u2.Unite(x-1,y-1)
l=[]
for i in range(N):
  l.append((u1.Find_root(i), u2.Find_root(i)))
c = Counter(l)
ans = []
for i in range(N):
  ans.append(c[(u1.Find_root(i), u2.Find_root(i))])
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)
n,k = map(int,input().split())
p = 1000000007

xCy = {}
def cmb(x, y):
    if x < 0 or y < 0: return 0
    if y == 0 or y == x: return 1
    if y == 1: return x
    if (x,y) in xCy: return xCy[(x,y)]
    xCy[(x,y)] = (cmb(x-1,y) + cmb(x-1,y-1))%p
    return xCy[(x,y)]

for i in range(1,k+1):
  print((cmb(k-1,i-1)*cmb(n-k+1,n-k-i+1))%p)

Fixed submission:
from operator import mul
from functools import reduce
n,k = map(int,input().split())
p = 1000000007


def cmb(x,y):
    if x < 0 or y < 0: return 0
    y = min(x-y,y)
    if y == 0: return 1
    over = reduce(mul, range(x, x - y, -1))
    under = reduce(mul, range(1,y + 1))
    return (over // under)%p


for i in range(1,k+1):
  print((cmb(k-1,i-1)*cmb(n-k+1,n-k-i+1))%p)
Buggy python submission (verdict: Time Limit Exceeded):
import math
r,g,b,n = map(int,input().split())

li = [r,g,b]
x = max([r,g,b])
li.remove(x)
y = max(li)
li.remove(y)
z = li[0]
ans = 0
for i in range(math.ceil(n/x)+1):
  for j in range(math.ceil((n-x*i)/y)+1):
    if (n - x*i - y*j)%z == 0 and n - x*i - y*j >= 0:
      ans += 1
print(ans)

Fixed submission:
import math
r,g,b,n = map(int,input().split())
 
ans = 0
for i in range(math.ceil(n/r)+1):
  for j in range(math.ceil((n-r*i)/g)+1):
    if (n - r*i - g*j)%b == 0 and n - r*i - g*j >= 0:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
r,g,b,n = map(int,input().split())
 
ans = 0
for i in range(math.ceil(n/r)+1):
  for j in range(math.ceil((n-r*i)/g)+1):
    if (n - r*i - g*j)%b == 0 and n - r*i - g*j >= 0:
      ans += 1
print(ans)

Fixed submission:
import math
r,g,b,n = map(int,input().split())
 
ans = 0
for i in range(math.ceil(n/r)+1):
  for j in range(math.ceil((n-r*i)/g)+1):
    if (n - r*i - g*j)%b == 0 and n - r*i - g*j >= 0:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
r,g,b,n = map(int,input().split())

ans = 0
for i in range(math.ceil(n/r)+1):
  for j in range(math.ceil(n/g)+1):
    if (n - r*i - g*j)%b == 0 and n - r*i - g*j >= 0:
      ans += 1
print(ans)

Fixed submission:
import math
r,g,b,n = map(int,input().split())
 
ans = 0
for i in range(math.ceil(n/r)+1):
  for j in range(math.ceil((n-r*i)/g)+1):
    if (n - r*i - g*j)%b == 0 and n - r*i - g*j >= 0:
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
list_v = map(int,input().split())
list_c = map(int,input().split())
 
ans = 0
for i in range(n):
  if list_v[i] - list_c[i] > 0:
    ans += list_v[i] - list_c[i]
print(int(ans))

Fixed submission:
a,b,t = map(int,input().split())
ans = ((t - t%a)/a)*b
print(int(ans))

Buggy python submission (verdict: Runtime Error):
a,b,t = map(int,input().split())
ans = math.floor(t/a) * b
print(ans)

Fixed submission:
a,b,t = map(int,input().split())
ans = ((t - t%a)/a)*b
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
list_v = map(int,input().split())
list_c = map(int,input().split())
 
ans = 0
for i in range(n):
  if list_v[i] - list_c[i] > 0:
    ans += list_v[i] - list_c[i]
print(int(ans))

Fixed submission:
n = int(input())
list_v = list(map(int,input().split()))
list_c = list(map(int,input().split()))
 
ans = 0
for i in range(n):
  if list_v[i] - list_c[i] > 0:
    ans += list_v[i] - list_c[i]
print(int(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
list_v = map(int,input().split())
list_c = map(int,input().split())

ans = 0
for i in range(n):
  if list_v[i] - list_c[i] > 0:
    ans += list_v[i] - list_c[i]
return(int(ans))

Fixed submission:
n = int(input())
list_v = list(map(int,input().split()))
list_c = list(map(int,input().split()))
 
ans = 0
for i in range(n):
  if list_v[i] - list_c[i] > 0:
    ans += list_v[i] - list_c[i]
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int,input().split()))

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

ans = [0]*n
for i in range(n):
  litmp = li[:i] + li[i+1:]
  tmp = litmp[0]
  for j in range(1,n-1):
    tmp = gcd(tmp,litmp[j])
  ans[i] = tmp
print(max(ans))

Fixed submission:
n = int(input())
li = list(map(int,input().split()))

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

ans = [0]*n
lileft = [0]*(n+1)
liright = [0]*(n+1)
for i in range(n):
  lileft[i+1] = gcd(lileft[i],li[i])
for i in range(n):
  liright[i+1] = gcd(liright[i],li[n-i-1])
for i in range(n):
  ans[i] = gcd(lileft[i],liright[n-i-1])
print(max(ans))