Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
num = int(input())

count = 0
flag = False
for i in range(num):
    a,b = read().split()
    if a == b:
        count += 1
        if count >= 3:
            print("Yes")
            flag = True
            break
    else:
        count = 0
if flag:
    print("No")

Fixed submission:
num = int(input())

count = 0
flag = False
for i in range(num):
    a,b = input().split()
    if a == b:
        count += 1
        if count >= 3:
            print("Yes")
            flag = True
            break
    else:
        count = 0
if not flag:
    print("No")

Buggy python submission (verdict: Runtime Error):
num = int(input())

count = 0
for i in range(num):
    a,b = read().split()
    if a == b:
        count += 1
        if count >= 3:
            print(Yes)
            return()
    else:
        count = 0
print("No")

Fixed submission:
num = int(input())

count = 0
flag = False
for i in range(num):
    a,b = input().split()
    if a == b:
        count += 1
        if count >= 3:
            print("Yes")
            flag = True
            break
    else:
        count = 0
if not flag:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
a = int(sys.stdin)
if a >= 30:
	print("Yes")
else:
	print("No")

Fixed submission:
import sys
for l in sys.stdin:
	if int(l) >= 30:
		print("Yes")
	else:
		print("No")

Buggy python submission (verdict: Runtime Error):
if input() >= 30:
  print("Yes")
else:
  print("Yes")

Fixed submission:
import sys
for l in sys.stdin:
	if int(l) >= 30:
		print("Yes")
	else:
		print("No")
Buggy python submission (verdict: Runtime Error):
import sys
 
if __name__ == '__main__':
  args = sys.argv
  ret="No"
  
  if (args[1] == args[2] or args[2] == args[3] or args[1] == args[3]):
    ret="Yes"
    
  print(ret)


Fixed submission:
import sys
 
if __name__ == '__main__':
  args = input().split()
  ret="No"
  if ((args[0] == args[1] or args[0] == args[2] or args[1] == args[2]) and (args[0] != args[1] or args[1] != args[2])):
    ret="Yes"
    
  print(ret)

Buggy python submission (verdict: Runtime Error):
import sys
 
if __name__ == '__main__':
  args = sys.argv
  ret="No"
  
  if (args[1] == args[2] | args[2] == args[3] | args[1] == args[3]):
    ret="Yes"
    
  print(ret)

Fixed submission:
import sys
 
if __name__ == '__main__':
  args = input().split()
  ret="No"
  if ((args[0] == args[1] or args[0] == args[2] or args[1] == args[2]) and (args[0] != args[1] or args[1] != args[2])):
    ret="Yes"
    
  print(ret)

Buggy python submission (verdict: Runtime Error):
import sys

if __name__ == '__main__':
  args = sys.argv
  ret="No"
  
  if (args[1] == args[2] || args[2] == args[3] || args[1] == args[3]):
    ret="Yes"
    
  print(ret)

Fixed submission:
import sys
 
if __name__ == '__main__':
  args = input().split()
  ret="No"
  if ((args[0] == args[1] or args[0] == args[2] or args[1] == args[2]) and (args[0] != args[1] or args[1] != args[2])):
    ret="Yes"
    
  print(ret)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

pat = 0
for a in range(A):
	for b in range(B):
    	for c in range(C):
          if a*500+B*100+c*50 == X:
            pat += 1
print(pat)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

pat = 0
for a in range(A+1):
	for b in range(B+1):
		for c in range(C+1):
			if a*500+b*100+c*50 == X:
				pat += 1
print(pat)
Buggy python submission (verdict: Runtime Error):
N = int(input())

for i in range(N):
	d = int(input())

dset = set(d)
print(len(dset))

Fixed submission:
N = int(input())

d=[]
for i in range(N):
	d.append(int(input()))

dset = set(d)
print(len(dset))
Buggy python submission (verdict: Runtime Error):
N,A,B = list(map(int,input().split()))

cnt = 0
for n range(1,N):
    val = 0
    tmp = N
    while tmp // N > 0:
        val = tmp % 10
        tmp = tmp // 10
    
    if val >= A and val <= B:
        cnt += 1
print(cnt)

Fixed submission:
N,A,B = list(map(int,input().split()))

cnt = 0
for n in range(1,N+1):
    val = n % 10
    tmp = n
    while tmp // 10 > 0:
        
        tmp = tmp // 10
        val += tmp % 10
    if val >= A and val <= B:
        cnt += n
print(cnt)

Buggy python submission (verdict: Runtime Error):
from math import log10

cnt = 0
for n range(1,N):
    val = 0
    tmp = N
    while tmp // N > 0:
        val = tmp % 10
        tmp = tmp // 10
    
    if val >= A and val <= B:
        cnt += 1
print(cnt)

Fixed submission:
N,A,B = list(map(int,input().split()))

cnt = 0
for n in range(1,N+1):
    val = n % 10
    tmp = n
    while tmp // 10 > 0:
        
        tmp = tmp // 10
        val += tmp % 10
    if val >= A and val <= B:
        cnt += n
print(cnt)
Buggy python submission (verdict: Runtime Error):
num = int(input())

vals = list(map(int,input().split()))

cnt = 0
while(True)
	for i in range(num):
    	if vals[i] % 2 == 1:
        	print(cnt)
        	break
        else:
    		vals[i] = vals[i] / 2
        cnt += 1

Fixed submission:
num = int(input())
 
vals = list(map(int,input().split()))
 
cnt = 0
flag = True
while(flag):
	for i in range(num):
		if vals[i] % 2 == 1:
			print(cnt)
			flag = False
			break
		else:
			vals[i] = vals[i] / 2
	cnt += 1
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

import numpy as np

def gcd(x: int, y: int):
  while(y!=0):
    tmp = x%y
    x = y
    y = tmp
  #if (y == 0):
  #  return x
  #else:
  #  return gcd(y, x%y)
  return x

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i])
an = 0
MOD = 10**9+7

for x in A:
  #print(g,g//x)
  an += g//x
  an %= MOD

print(an)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

#N = 10000
#A = [i*2+1 for i in range(1,N+1)]

MOD = 10**9+7

sm = 0
for x in A:
  sm += pow(x,MOD-2,MOD)
  sm %= MOD

def gcd(x: int, y: int):
  while(y!=0):
    tmp = x%y
    x = y
    y = tmp
  return x

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i]) #pow(gcd(g, A[i]), MOD-2, MOD)
  #print(g)

an = g * sm % MOD

'''
for x in A:
  #print(g,g//x)
  an += g*pow(x,MOD-2,MOD)
  an %= MOD
  print(g,g//x,an)
'''

print(an)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

import numpy as np

def gcd(x: int, y: int):
  if (y == 0):
    return x
  else:
    return gcd(y, x%y)

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i])
an = 0
MOD = 10**9+7

for x in A:
  #print(g,g//x)
  an += g//x
  an %= MOD

print(an)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

#N = 10000
#A = [i*2+1 for i in range(1,N+1)]

MOD = 10**9+7

sm = 0
for x in A:
  sm += pow(x,MOD-2,MOD)
  sm %= MOD

def gcd(x: int, y: int):
  while(y!=0):
    tmp = x%y
    x = y
    y = tmp
  return x

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i]) #pow(gcd(g, A[i]), MOD-2, MOD)
  #print(g)

an = g * sm % MOD

'''
for x in A:
  #print(g,g//x)
  an += g*pow(x,MOD-2,MOD)
  an %= MOD
  print(g,g//x,an)
'''

print(an)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

import numpy as np

def gcd(x: int, y: int):
  if (y == 0):
    return x
  else:
    return gcd(y, x%y)

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i])
an = 0
MOD = 10**9+7

for x in A:
  //print(g,g//x)
  an += g//x
  an %= MOD

print(an)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

#N = 10000
#A = [i*2+1 for i in range(1,N+1)]

MOD = 10**9+7

sm = 0
for x in A:
  sm += pow(x,MOD-2,MOD)
  sm %= MOD

def gcd(x: int, y: int):
  while(y!=0):
    tmp = x%y
    x = y
    y = tmp
  return x

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i]) #pow(gcd(g, A[i]), MOD-2, MOD)
  #print(g)

an = g * sm % MOD

'''
for x in A:
  #print(g,g//x)
  an += g*pow(x,MOD-2,MOD)
  an %= MOD
  print(g,g//x,an)
'''

print(an)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,m=map(int,input().split())
ans=x
a=[x]
if n==1:
  print(ans)
else:
  for i in range(2,n+1):
    tmp=a[-1]**2%m
    if tmp not in a:
      a.append(tmp)
      ans+=tmp
    else:
      t=a.index(tmp)
      if len(a)-t>=n-i+1:
        ans+=sum(a[t:t+n-i+1])
        break
      else:
        t=a.index(tmp)
        tmp_a=(n-i+1)//(len(a)-t)
        tmp_b=(n-i+1)-(len(a)-t)*tmp_a
        ans+=sum(a[t:])*tmp_a+sum(a[t:t+tmp_b])
        break
  print(ans)

Fixed submission:
n,x,m=map(int,input().split())
ans=x
a=[x]
d={}
d[x]=1
if n==1:
  print(ans)
else:
  for i in range(2,n+1):
    tmp=a[-1]**2%m
    if d.get(tmp,0)==0:
      a.append(tmp)
      d[tmp]=1
      ans+=tmp
    else:
      t=a.index(tmp)
      if len(a)-t>=n-i+1:
        ans+=sum(a[t:t+n-i+1])
        break
      else:
        t=a.index(tmp)
        tmp_a=(n-i+1)//(len(a)-t)
        tmp_b=(n-i+1)-(len(a)-t)*tmp_a
        ans+=sum(a[t:])*tmp_a+sum(a[t:t+tmp_b])
        break
  print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
t=0
a=''
al='abcdefghijklmnopqrstuvwxyz'
b=[27]
c=[1]
for i in range(9):
  c.append(c[-1]*26)
  b.append(c[-1]+c[-1]*26)
c.append(c[-1]*26)
b.sort(reverse=True)
b.append(1)
b.append(1)
c.sort(reverse=True)
c.append(1)
flg=0
i=0
while n>0:
  if flg ==1:
    if n > b[i]:
      tmp=0
      while n >= b[i] and tmp <26:
        n -= c[i]
        tmp+=1
      a+=al[tmp-1]
      i+=1
    elif n!=0:
      a+='a'
      i+=1
  elif n > b[i]:
    flg=1
    tmp=0
    while n >= b[i] and tmp <26:
      n -= c[i]
      tmp+=1
    a+=al[tmp-1]
    i+=1
  else:
    i+=1
print(a)

Fixed submission:
n=int(input())
t=0
a=''
al='abcdefghijklmnopqrstuvwxyz'
b=[1]
c=[1]
for i in range(10):
  c.append(c[-1]*26)
  b.append(sum(c))
b.sort(reverse=True)
b.append(1)
c.sort(reverse=True)
c.append(1)
flg=0
i=0
while n>0:
  if flg ==1:
    if n >= b[i]:
      tmp=0
      while n >= b[i] and tmp <26:
        n -= c[i]
        tmp+=1
      a+=al[tmp-1]
      i+=1
    else:
      a+='a'
      i+=1
  elif n >= b[i]:
    flg=1
    tmp=0
    while n >= b[i] and tmp <26:
      n -= c[i]
      tmp+=1
    a+=al[tmp-1]
    i+=1
  else:
    i+=1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans = 1
for i in range(n):
  ans *= a[i]
if ans > 10**18:
  ans = -1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans = 1
if 0 in a:
  print(0)
else:
  for i in range(n):
    ans *= a[i]
    if ans > 10**18:
      ans = -1
      break
  print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(str,input().split())
b=int(float(b)*100)
a=int(a)*b
a//=100
print(int(a))

Fixed submission:
a,b=map(str,input().split())
b=b[0]+b[2]+b[3]
b=int(b)
a=int(a)*b
a//=100
print(int(a))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().split()]
dict = {}
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    dict.setdefault(a-1,[]).append(b-1)
    dict.setdefault(b-1,[]).append(a-1)
tmp = []
ans = [0]*n
ans2 = [0]
t = 0
while t < n:
  for s in ans2:
    for i in range(1,n):
      if s in dict[i] and ans[i] == 0:
        tmp.append(i)
        ans[i] = s+1
  ans2 = tmp
  t += 1
if ans.count(0) == 1:
  print('Yes')
  for i in range(1,n):
    print(ans[i])
else:
  print('No')

Fixed submission:
N,M=list(map(int,input().split()))
 
g=[[] for i in range(N+1)]
 
for i in range(M):
	a,b=list(map(int,input().split()))
	g[a].append(b)
	g[b].append(a)
 
from collections import deque
 
queue = deque([1])
d = [None] * (N+1)
while queue:
	v = queue.popleft()
	for i in g[v]:
		if d[i] is None:
			d[i] = v
			queue.append(i)
 
print("Yes")
print(*d[2:],sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
g = [[] for _ in range(n)]

for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)
tmp = []
ans = [0]*n
ans2 = [0]
t = 0
while t < n:
  for s in ans2:
    for i in range(1,n):
      if s in g[i] and ans[i] == 0:
        tmp.append(i)
        ans[i] = s+1
  ans2 = tmp
  t += 1
if ans.count(0) == 1:
  print('Yes')
  for i in range(1,n):
    print(ans[i])
else:
  print('No')

Fixed submission:
N,M=list(map(int,input().split()))
 
g=[[] for i in range(N+1)]
 
for i in range(M):
	a,b=list(map(int,input().split()))
	g[a].append(b)
	g[b].append(a)
 
from collections import deque
 
queue = deque([1])
d = [None] * (N+1)
while queue:
	v = queue.popleft()
	for i in g[v]:
		if d[i] is None:
			d[i] = v
			queue.append(i)
 
print("Yes")
print(*d[2:],sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
res = 0
for i,h in enumerate(a):
  for j in range(i+1,n):
    if h + a[j] == j - i:
      res += 1
print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
res = 0
dict = {}
dict[a[0]+1] = 1
for i in range(1,n):
  res += dict.get(i+1-a[i],0)
  dict[a[i]+i+1] = dict.get(a[i]+i+1,0) + 1
print(res)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a,b=map(int,input().split())
ans='NG'
for i in range(a,b+1):
  if i%k==0:
    ans='OK'
print(ans)

Fixed submission:
n = int(input())
a,b = map(int, input().split())
flg = 0
for i in range(10000):
  if n * i >= a and n * i <= b:
    flg = 1
if flg == 1:
  print('OK')
else:
  print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
res = 0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      res += math.gcd(math.gcd(i,j),k)
print(res)


Fixed submission:
import math
n = int(input())
res = 0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      res += math.gcd(math.gcd(i,j),k)
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
top=bool()
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      s.insert(0,q[2])
    else:
      s.append(q[2])
if top:
  print(*list(reversed(s)),sep='')
else:
  print(*s,sep='')


Fixed submission:
s=list(input())
top=bool()
t=[]
u=[]
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      t.append(q[2])
    else:
      u.append(q[2])
s=list(reversed(t))+s+u
if top:
  print(*list(reversed(s)),sep='')
else:
  print(*s,sep='')

Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
top=bool()
t=[]
u=[]
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      s.insert(0,q[2])
    else:
      s.append(q[2])
if top:
  print(*list(reversed(s)),sep='')
else:
  print(*s,sep='')


Fixed submission:
s=list(input())
top=bool()
t=[]
u=[]
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      t.append(q[2])
    else:
      u.append(q[2])
s=list(reversed(t))+s+u
if top:
  print(*list(reversed(s)),sep='')
else:
  print(*s,sep='')

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
top=bool()
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      s=q[2]+s
    else:
      s=s+q[2]
if top:
  print(*list(reversed(list(s))),sep='')
else:
  print(s)


Fixed submission:
s=list(input())
top=bool()
t=[]
u=[]
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      t.append(q[2])
    else:
      u.append(q[2])
s=list(reversed(t))+s+u
if top:
  print(*list(reversed(s)),sep='')
else:
  print(*s,sep='')

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
top=bool()
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      s=q[2]+s
    else:
      s=s+q[2]
if top:
  print(*list(reversed(list(s))),sep='')
else:
  print(s)


Fixed submission:
s=list(input())
top=bool()
t=[]
u=[]
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      t.append(q[2])
    else:
      u.append(q[2])
s=list(reversed(t))+s+u
if top:
  print(*list(reversed(s)),sep='')
else:
  print(*s,sep='')
Buggy python submission (verdict: Runtime Error):
li = list(map(int,input().split()))
error = 0
for i in range(li[0]):
  if i == 1:
  else:
    if li[i]%2 == 0:
      if li[i]%3 == 0 or li[i]%5 ==0:
      else:
        error = 1:
    else:
if error:
  print('DENIED')
else:
  print('APPROVED')

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
error = 0
for i in range(n):
  if li[i]%2 == 0:
    if li[i]%3 == 0 or li[i]%5 == 0:
      pass
    else:
      error = 1
  else:
    pass
if error:
  print('DENIED')
else:
  print('APPROVED')
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int, input().split())
max = 0
arr = list(map(int, input().split()))
for i in range(a - b + 1):
  sum = 0
  for j in range(b):
    sum = sum + arr[i + j]
  if sum > max:
    max = sum
print((max + b) / 2)

Fixed submission:
a,b = map(int, input().split())
max = 0
arr = list(map(int, input().split()))
cumsum = [0] * (a + 1)
for i in range(a):
  cumsum[i+1] = cumsum[i] + arr[i]
for i in range(a - b + 1):
  sum = 0
  sum = cumsum[i + b] - cumsum[i]
  if sum > max:
    max = sum
print((max + b) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int, input().split())
max = 0
arr = list(map(int, input().split()))
for i in range(len(arr)):
  arr[i] = (arr[i] + 1) / 2
for i in range(a - b + 1):
  sum = 0
  for j in range(b):
    sum = sum + arr[i + j]
  if sum > max:
    max = sum
print(max)

Fixed submission:
a,b = map(int, input().split())
max = 0
arr = list(map(int, input().split()))
cumsum = [0] * (a + 1)
for i in range(a):
  cumsum[i+1] = cumsum[i] + arr[i]
for i in range(a - b + 1):
  sum = 0
  sum = cumsum[i + b] - cumsum[i]
  if sum > max:
    max = sum
print((max + b) / 2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=1
c=[0,0,0]
for i in range(n):
  ans*=c.count(a[i])
  c[c.index(a[i])]+=1
print(ans%1000000007)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=1
c=[0,0,0]
for i in range(n):
  if a[i] not in c:
    ans=0
  else:
    ans*=c.count(a[i])
    ans%=1000000007
    c[c.index(a[i])]+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=1
c=[0,0,0]
for i in range(n):
  ans*=c.count(a[i])
  ans%=1000000007
  c[c.index(a[i])]+=1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=1
c=[0,0,0]
for i in range(n):
  if a[i] not in c:
    ans=0
  else:
    ans*=c.count(a[i])
    ans%=1000000007
    c[c.index(a[i])]+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=1
c=[0,0,0]
for i in range(n-1):
  ans*=c.count(a[i])
  ans%=1000000007
  c[c.index(a[i])]+=1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=1
c=[0,0,0]
for i in range(n):
  if a[i] not in c:
    ans=0
  else:
    ans*=c.count(a[i])
    ans%=1000000007
    c[c.index(a[i])]+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
res = 2020202020
for i in range(n):
  res = min(res, abs(sum(a[:i]) - sum(a[i:])))
print(res)

Fixed submission:
import itertools
n = int(input())
a = list(itertools.accumulate(list(map(int, input().split()))))
sum_a = a[-1]
res = 2020202020
for i in range(n):
  res = min(res, abs(sum_a - a[i]*2))
print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
res = 2020202020
for i in range(n):
  res = min(res, abs(a[:i] - a[i:]))
print(res)

Fixed submission:
import itertools
n = int(input())
a = list(itertools.accumulate(list(map(int, input().split()))))
sum_a = a[-1]
res = 2020202020
for i in range(n):
  res = min(res, abs(sum_a - a[i]*2))
print(res)
Buggy python submission (verdict: Runtime Error):
s = input()
if s[0] == '>':
  a = [0]
else:
  a = []
flg = 1
for i in range(1,len(s)):
  if s[i] != s[i-1]:
    a.append(flg)
    flg = 1
  else:
    flg += 1
if s[-1] != s[-2]:
  a.append(flg)
else:
  a.append(flg)
if s[-1] == '<':
  a.append(0)
ans = 0
for i in range(len(a)//2):
  if a[2*i] > a[2*i+1]:
    a[2*i+1] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
  else:
    a[2*i] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
print(ans)

Fixed submission:
s = input()
if s[0] == '>':
  a = [0]
else:
  a = []
flg = 1
for i in range(1,len(s)):
  if s[i] != s[i-1]:
    a.append(flg)
    flg = 1
  else:
    flg += 1
a.append(flg)
if s[-1] == '<':
  a.append(0)
ans = 0
for i in range(len(a)//2):
  if a[2*i] > a[2*i+1]:
    a[2*i+1] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
  else:
    a[2*i] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    b=a[i]+a[j]
    k=j+1
    while a[k]<b:
      k+=1
      if k>=n:
        break
    ans+=k-j-1
print(ans)

Fixed submission:
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(a,a[i]+a[j])-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    b=a[i]+a[j]
    k=j+1
    while a[k]<b:
      k+=1
      if k>=n:
        break
    ans+=k-j-1
print(ans)

Fixed submission:
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(a,a[i]+a[j])-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
for i in range(n):
  for j in range(i+1,n):
    k = j + 1
    while k < n and a[i] < a[j] + a[k]:
      k += 1
      ans += 1
print(ans)

Fixed submission:
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(a,a[i]+a[j])-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in list(itertools.combinations(a,3)):
  if i[0] < i[1] + i[2] and i[1] < i[2] + i[0] and i[2] < i[0] + i[1]:
    ans += 1
print(ans)

Fixed submission:
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(a,a[i]+a[j])-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in list(itertools.combinations(a,3)):
  if i[0] < i[1] + i[2] and i[1] < i[2] + i[0] and i[2] < i[0] + i[1]:
    ans += 1
print(ans)

Fixed submission:
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=bisect.bisect_left(a,a[i]+a[j])-j-1
print(ans)