Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    # n=max(-(-a//A),-(-t//T))
    n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)


Fixed submission:
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(-(-a//A),-(-t//T))
    # n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)

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

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)


Fixed submission:
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(-(-a//A),-(-t//T))
    # n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    Te,Ae=T,A
    if t>T or a>A:
        T,A=T*math.ceil((t+a)/(T+A)),A*math.ceil((t+a)/(T+A))
        while t>T or a>A:
            T+=Te
            A+=Ae
    t,a=T,A

print(t+a)


Fixed submission:
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(-(-a//A),-(-t//T))
    # n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    Te,Ae=T,A
    if t>T or a>A:
        T,A=T*math.ceil((t+a)/(T+A)),A*math.ceil((t+a)/(T+A))
        while t>T or a>A:
            T+=Te
            A+=Ae
    t,a=T,A

print(t+a)


Fixed submission:
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(-(-a//A),-(-t//T))
    # n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    Te,Ae=T,A
    while t>T or a>A:
        T+=Te
        A+=Ae
    t,a=T,A

print(t+a)


Fixed submission:
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(-(-a//A),-(-t//T))
    # n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    Te,Ae=T,A
    while t>T or a>A:
        T+=Te
        A+=Ae
    t,a=T,A

print(t+a)


Fixed submission:
import fractions

N=int(input())
t,a=1,1
for i in range(N):
    T,A=map(int,input().split())
    n=max(-(-a//A),-(-t//T))
    # n=max(fractions.ceil(a/A),fractions.ceil(t/T))
    t,a=n*T,n*A

print(t+a)
Buggy python submission (verdict: Runtime Error):
S1=input()
S2='CODEFESTIVAL2016'

ans=0
for i in len(S1):
    if S1[i]!=S2[i]:
        ans+=1

print(ans)

Fixed submission:
S1=input()
S2='CODEFESTIVAL2016'

ans=0
for i in range(len(S1)):
    if S1[i]!=S2[i]:
        ans+=1

print(ans)

Buggy python submission (verdict: Runtime Error):
S1=input()
S2='CODEFESTIVAL2016'

ans=0
for i in len(S):
    if S1[i]!=S2[i]:
        ans+=1

print(ans)

Fixed submission:
S1=input()
S2='CODEFESTIVAL2016'

ans=0
for i in range(len(S1)):
    if S1[i]!=S2[i]:
        ans+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
SA=input()
SB=input()
SC=input()

A_rest=len(SA)
B_rest=len(SA)
C_rest=len(SA)
next='a'

while(1):
    if next=='a':
        A_rest-=1
       	if A_rest<0:
           	break
        next=SA[len(SA)-A_rest]
    elif next=='b':
        B_rest-=1
       	if B_rest<0:
           	break
        next=SB[len(SB)-B_rest]
    else:
        C_rest-=1
       	if C_rest<0:
           	break
        next=SC[len(SC)-C_rest]

if A_rest<0:
    print('A')
elif B_rest<0:
    print('B')
else:
    print('C')

Fixed submission:
SA=input()
SB=input()
SC=input()

A_rest=len(SA)
B_rest=len(SB)
C_rest=len(SC)
next='a'

while(1):
    if next=='a':
       	if A_rest==0:
            print('A')
            exit()
        next=SA[len(SA)-A_rest]
        A_rest-=1
    elif next=='b':
       	if B_rest==0:
            print('B')
            exit()
        next=SB[len(SB)-B_rest]
        B_rest-=1
    else:
       	if C_rest==0:
            print('C')
            exit()
        next=SC[len(SC)-C_rest]
        C_rest-=1
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from collections import deque

N, M = map(int, input().split())

chg = 10**6
G = defaultdict(set)
for _ in range(M):
    p, q, c = map(int, input().split())
    # 無向グラフ
    G[p].add(p+chg*c)
    G[p+chg*c].add(p)
    G[q].add(q+chg*c)
    G[q+chg*c].add(q)
    G[p+chg*c].add(q+chg*c)
    G[q+chg*c].add(p+chg*c)


dist = defaultdict(lambda: 10**11)
dist[1] = 0

que = deque([1])

while que:
    ci = que.popleft()

    for ni in G[ci]:
        if dist[ni] == 10**11:
            if ci >= chg and ni >= chg:
                dist[ni] = dist[ci]
                que.appendleft(ni)
            else:
                dist[ni] = dist[ci]+1
                que.append(ni)


if dist[N] < 10**11:
    print(dist[N]//2)
else:
    print(-1)


Fixed submission:
from collections import defaultdict
from collections import deque

N, M = map(int, input().split())

chg = 10**6
G = defaultdict(set)
for _ in range(M):
    p, q, c = map(int, input().split())
    # 無向グラフ
    G[p].add(p+chg*c)
    G[p+chg*c].add(p)
    G[q].add(q+chg*c)
    G[q+chg*c].add(q)
    G[p+chg*c].add(q+chg*c)
    G[q+chg*c].add(p+chg*c)


dist = defaultdict(lambda: 10**11)
dist[1] = 0

que = deque([1])

while que:
    ci = que.popleft()

    for ni in G[ci]:
        if dist[ni] == 10**11:
            if ci >= chg and ni >= chg:
                dist[ni] = dist[ci]
                que.appendleft(ni)
            else:
                dist[ni] = dist[ci]+1
                que.append(ni)


if dist[N] < 10**11:
    print(dist[N]//2)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
w=sorted(input())
if len(w)%2==1:
    print('No')
else:
    while len(w)>=2:
        if w.pop(0)!=w.pop(0):
            print('No')
            exit()
	print('Yes')

Fixed submission:
w=sorted(input())
if len(w)%2==1:
    print('No')
else:
    while len(w)>=2:
        if w.pop(0)!=w.pop(0):
            print('No')
            exit()
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())
x = [int(i) for i in input().split()]

X = max(A, max(x))

dp = [[[0 for _ in range(N*X+1)] for _ in range(N+1)] for _ in range(N+1)]

for j in range(N+1):
    for k in range(N+1):
        for s in range(N*X+1):
            if j == 0 and k == 0 and s == 0:
                dp[j][k][s] = 1
            elif j >= 1 and s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s >= x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]]
            else:
                dp[j][k][s] = 0

ans = 0
for k in range(1, N+1):
    ans += dp[N][k][k*A]

print(ans)


Fixed submission:
N, A = map(int, input().split())
x = [int(i) for i in input().split()]

X = max(A, max(x))

dp = [[[0 for _ in range(N*X+1)] for _ in range(N+1)] for _ in range(N+1)]

for j in range(N+1):
    for k in range(N+1):
        for s in range(N*X+1):
            if j == 0 and k == 0 and s == 0:
                dp[j][k][s] = 1
            elif j >= 1 and s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s >= x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]]
            else:
                dp[j][k][s] = 0

ans = 0
for k in range(1, N+1):
    ans += dp[N][k][k*A]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

O = sorted(A)[::2]
E = sorted(A)[1::2]

ans = 0
for i in range(N):
    if i % 2 == 0 and A[i] not in O:
        ans += 1
    elif i % 2 == 1 and A[i] not in E:
        ans += 1
print(ans//2)


Fixed submission:
import bisect
N = int(input())
A = [int(input()) for _ in range(N)]

eo = [0]*2

As = sorted(A)
for i in range(N):
    if i % 2 != bisect.bisect_left(As, A[i]) % 2:
        eo[i % 2] += 1

print(max(eo))
Buggy python submission (verdict: Runtime Error):
s = input()
if s[-2] == s[-1]:
    print(len(s)-1, len(s))
    exit()

for i in range(s-2):
    if s[i] == s[i+1] or s[i] == s[i+2]:
        print(i+1, i+3)
        exit()
print(-1 - 1)


Fixed submission:
s = input()

if len(s) == 2 and s[0] == s[1]:
    print(1, 2)
    exit()

for i in range(len(s)-2):
    if len(set(s[i:i+3])) != 3:
        print(i+1, i+3)
        exit()
print(-1, -1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))


sum = 0
D = set(range(N))
E = set()
for i in D:
    E.add(i)
    tmp = 0
    for j in D - E:
        tmp += A[j]
    sum += A[i] * tmp

print(sum % (10**9+7))

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


S = []
sum = 0
for i in range(N):
    sum += A[i]
    S.append(sum)

ans = 0
for i in range(N):
    ans += A[i] * (S[N-1] - S[i])

print(int(ans % (10**9 + 7)))

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



sum = 0
D = set(range(N))
E = set()
for i in D:
    E.add(i)
    for j in D - E:
        sum += A[i] * A[j]

print(sum % (10**9+7))

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


S = []
sum = 0
for i in range(N):
    sum += A[i]
    S.append(sum)

ans = 0
for i in range(N):
    ans += A[i] * (S[N-1] - S[i])

print(int(ans % (10**9 + 7)))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())
p = list(map(int, input().split()))

product = 1
for i in range(N):
    product = product * p[i]

if product > 10 ** 18:
    print(-1)
    sys.exit()
print(product)

Fixed submission:
import sys

N = int(input())
p = list(map(int, input().split()))


for i in range(N):
    if p[i] == 0:
        print(0)
        sys.exit()

product = 1
for i in range(N):
    product = product * p[i]
    if product > 10 ** 18:
        print(-1)
        sys.exit()
        break

print(product)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
S.append(input())


for i in range(N-1):
    get = input()
    if S.count(get) == 0:
        S.append(get)

print(len(S))

Fixed submission:
N = int(input())
S = set()

for i in range(N):
    S.add(input())

print(len(S))
Buggy python submission (verdict: Runtime Error):
import math
import itertools
import sys
n = int(input())
a = list(map(int, input().split()))
ans = 0
all = 0
for i in a:
    all += i
for i in a:
    all -= i
    ans += i*all
    if(ans > 10**9+7):
        ans %= 10**9+7
print(ans)


Fixed submission:
import math
import itertools
import sys
n = int(input())
a = list(map(int, input().split()))
ans = 0
all = 0
for i in a:
    all += i
for i in a:
    all -= i
    ans += i*all
    if(ans > 10**9+7):
        ans %= 10**9+7
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import math
import itertools
import random
n=int(input())
lis=[0]*(10**9)
for a in range(1,int((math.sqrt(n)/2)+100)):
    for b in range(1,int((math.sqrt(n)/2)+100)):
        for c in range(1,int((math.sqrt(n)/2)+100)):
            lis[int(a**2+b**2+c**2+a*b+b*c+c*a)]+=1
for i in range(1,n+1):
    print(lis[i])

Fixed submission:
import sys
import math
import itertools
import random
n=int(input())
lis=[0]*(10**8)
for a in range(1,int((math.sqrt(n)/2)+100)):
    for b in range(1,int((math.sqrt(n)/2)+100)):
        for c in range(1,int((math.sqrt(n)/2)+100)):
            lis[int(a**2+b**2+c**2+a*b+b*c+c*a)]+=1
for i in range(1,n+1):
    print(lis[i])

Buggy python submission (verdict: Runtime Error):
import sys
import math
import itertools
import random
n=int(input())
lis=[0]*(10**5)
for a in range(1,int((math.sqrt(n)/2)+100)):
    for b in range(1,int((math.sqrt(n)/2)+100)):
        for c in range(1,int((math.sqrt(n)/2)+100)):
            lis[int(a**2+b**2+c**2+a*b+b*c+c*a)]+=1
for i in range(1,n+1):
    print(lis[i])

Fixed submission:
import sys
import math
import itertools
import random
n=int(input())
lis=[0]*(10**8)
for a in range(1,int((math.sqrt(n)/2)+100)):
    for b in range(1,int((math.sqrt(n)/2)+100)):
        for c in range(1,int((math.sqrt(n)/2)+100)):
            lis[int(a**2+b**2+c**2+a*b+b*c+c*a)]+=1
for i in range(1,n+1):
    print(lis[i])

Buggy python submission (verdict: Runtime Error):
import sys
import math
import itertools
import random
n=int(input())
lis=[0]*(10**5)
for a in range(1,int((math.sqrt(n)/2)+100)):
    for b in range(1,int((math.sqrt(n)/2)+100)):
        for c in range(1,int((math.sqrt(n)/2)+100)):
            lis[int(a**2+b**2+c**2+a*b+b*c+c*a)]+=1
for i in range(n):
    print(lis[i])

Fixed submission:
import sys
import math
import itertools
import random
n=int(input())
lis=[0]*(10**8)
for a in range(1,int((math.sqrt(n)/2)+100)):
    for b in range(1,int((math.sqrt(n)/2)+100)):
        for c in range(1,int((math.sqrt(n)/2)+100)):
            lis[int(a**2+b**2+c**2+a*b+b*c+c*a)]+=1
for i in range(1,n+1):
    print(lis[i])
Buggy python submission (verdict: Runtime Error):
import sys

import math
import itertools

n,m,k=map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
time = 0
max=len(a)+len(b)
for i in range(max):
    if (len(a) == 0):
        if (time + b[0] <= k):
            time += b[0]
            ans += 1
            b.pop(0)
    elif (len(b) == 0):
        if (time + a[0] <= k):
            time += a[0]
            ans += 1
            a.pop(0)
    else:
        tmp = 0
        isA=True
        if (a[0] < b[0]):
            tmp = a[0]
            isA=True
        else:
            tmp = b[0]
            isA = False
        if (time + tmp <= k):
            time += tmp
            ans += 1
            if (isA):
                a.pop(0)
            else:
                b.pop(0)
print(ans)
        

Fixed submission:
import sys

import math
import itertools

a=int(input())
print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
import sys
import math
import itertools
h1, m1, h2, m2, k = map(int, input().split())
print(max((h2-h1)*60 + (m2-m1)-k),0)

Fixed submission:
import sys
import math
import itertools
h1, m1, h2, m2, k = map(int, input().split())
print(max((h2-h1)*60 + (m2-m1)-k,0))
Buggy python submission (verdict: Runtime Error):
import sys
import math
import itertools
s = input()
ans=''
for i in range(len(s)):
    if (s[i] == '?'):
        if (i!=len(s)-1 and s[i + 1] == 'D' or s[i+1]=='?'):
            ans += 'P'
        else:
            ans+='D'
    else:
        ans += s[i]
print(ans)
            

Fixed submission:
import sys
import math
import itertools
s = input()
ans=''
for i in range(len(s)):
    if(s[i]=='?'):
        ans+='D'
    else:
        ans += s[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import math

n, m = map(int, input().split())
h = list(map(int, input().split()))
ma = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    ma[a - 1] = max(h[a - 1],max(ma[a-1],h[b - 1]))
    ma[b - 1] = max(h[b - 1],max(ma[b-1] ,h[a - 1]))
cnt = 0
for i in range(n):
    if h[i] >= ma[i]:
        cnt += 1
print(cnt)


Fixed submission:
import sys
import math
s=input()
if (s == 'ABC'):
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
import sys
import math
import itertools

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [True] * n
lis = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    lis[a - 1] = max(lis[a - 1], h[b - 1])
    lis[b - 1] = max(lis[b - 1], h[a - 1])
ans = 0
if lis[i] < h [i]:
    ans += 1
print(ans)


Fixed submission:
import sys
import math

n, m = map(int, input().split())
h = list(map(int, input().split()))
ma = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    ma[a - 1] = max(ma[a-1],h[b - 1])
    ma[b - 1] = max(ma[b-1] ,h[a - 1])
cnt = 0
for i in range(n):
    if h[i] > ma[i]:
        cnt += 1
print(cnt)

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

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [True] * n
lis = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    lis[a - 1] = max(lis[a - 1], h[b - 1])
    lis[b - 1] = max(lis[b - 1], h[a - 1])
ans = 0
if lis[i] > h [i]:
    ans += 1
print(ans)


Fixed submission:
import sys
import math

n, m = map(int, input().split())
h = list(map(int, input().split()))
ma = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    ma[a - 1] = max(ma[a-1],h[b - 1])
    ma[b - 1] = max(ma[b-1] ,h[a - 1])
cnt = 0
for i in range(n):
    if h[i] > ma[i]:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
for i in range(n):
    li.append(input())
li.sort()
tmp = list(sorted(set(li), key=li.index))
oplist = [[0 for i in range(2)] for j in range(len(tmp))]
for i in range(len(tmp)):
    oplist[i][1] = tmp[i]
cnt = 0
for i in range(len(oplist)):
    if cnt < li.count(oplist[i][1]):
        cnt = li.count(oplist[i][1])
    oplist[i][0] = li.count(oplist[i][1])
for i in range(len(tmp)):
    if oplist[i][0] == cnt:
        print(oplist[i][1])



Fixed submission:
import math
import sys
n = int(input())
li=[input()]
for i in range(n-1):
    li.append(input())
li.sort()
cnt = 0
tmp = 1
li.append('')
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if(cnt<tmp):
            cnt=tmp
        tmp = 1
tmp=1
for i in range(n):
    if (li[i] == li[i + 1]):
        tmp += 1
    else:
        if (cnt == tmp):
                print(li[i])
        tmp = 1
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import itertools
n = int(input())
ans = 0
for i in range(1, n + 1):
    ans+=i
print(ans-n)

Fixed submission:
import sys
import math
import itertools
n = int(input())
if(n%2==0):
    print((n + 1) * (n // 2) - n)
else:
    print((n + 1) * ((n-1) // 2) +(n+1)//2- n)
Buggy python submission (verdict: Runtime Error):
import math
def String_Sort(str):
    tmp = sorted(str)
    ans = ""
    for i in tmp:
        ans += i
    return ans

def sol(n):
    return math.factorial(n) / 2

# main
li = []
n = int(input())
ans = 0
for i in range(n):
    li.append(String_Sort(input()))
li.sort()
# temporary
str = li[0]
num = 0
for i in li:
    if (i == str):
        num += 1
        continue
    else:
        if num>1:
            ans += sol(num)
        num = 1
        str = i
if (num > 1):
    ans+=sol(num)
print(int(ans))


Fixed submission:
import math
def String_Sort(str):
    tmp = sorted(str)
    ans = ""
    for i in tmp:
        ans += i
    return ans

def sol(n):
    return (n*(n-1))//2

# main
li = []
n = int(input())
ans = 0
for i in range(n):
    li.append(String_Sort(input()))
li.sort()
# temporary
str = li[0]
num = 0
for i in li:
    if (i == str):
        num += 1
        continue
    else:
        if num>1:
            ans += sol(num)
        num = 1
        str = i
if (num > 1):
    ans+=sol(num)
print(ans)
Buggy python submission (verdict: Runtime Error):
int a=int(input())
int b=int(input())
if abs(a-b)%2==0:
  print(abs(a-b)/2)
else:
  print('IMPOSSIBLE')

Fixed submission:
a,b=map(int,input().split())
if  (a+b)%2==0:
    print((a+b)//2)
         
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
import sys
import math

s=input()
k = int(input())
cnt=0
for i in range(len(s)):
    if s[i] != '1':
        print(s[i])
        sys.exit()
if (cnt == 0):
    print('1')


Fixed submission:
import sys
import math

a, b= map(int, input().split())
print(a*b-a-b+1)
Buggy python submission (verdict: Runtime Error):
import sys
import math

s=input()
k = int(input())
cnt = False
ans=0
for i in range(0,k+1):
    if s[i] != '1':
        ans = s[i]
        cnt = True
        break
    cnt+=1
if (not cnt):
    print(1)
else:
    print(ans)


Fixed submission:
import sys
import math

s=input()
k = int(input())
cnt = False
ans=0
for i in range(0,k):
    if s[i] != '1':
        ans = s[i]
        cnt = True
        break
if (not cnt):
    print(1)
else:
    print(ans)

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

s=input()
k = int(input())
cnt = False
ans=0
for i in range(len(s),k):
    if s[i] != '1':
        ans = s[i]
        cnt = True
        break
    cnt+=1
if (not cnt):
    print(1)
else:
    print(ans)


Fixed submission:
import sys
import math

s=input()
k = int(input())
cnt = False
ans=0
for i in range(0,k):
    if s[i] != '1':
        ans = s[i]
        cnt = True
        break
if (not cnt):
    print(1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
x = int(input())
if (x == 1000):
    print(1000)
    sys.exit()
list = []
list.append(1)
for i in range(30):
    tmp = (i+2)**2
    while (tmp <= 1000):
        list.append(tmp)
        tmp = tmp*(i+2)
list.sort()
tmp = list[0]
for i in list:
    if (i > x):
        print(tmp)
        sys.exit()
    tmp = i


Fixed submission:
import sys
import math
a, b, c, d = map(int, input().split())
if (max(a, c) - min(a, c) <= d or (max(a, b) - min(a, b) <= d and max(c, b) - min(c, b) <= d)):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    while a != b:
        if (a != 1 and b != 1):
            if a < b:
                b = b % a
            elif a > b:
                a = a % b
            else:
                break
    if (a == 1 or b == 1):
        return 1
    else:
        return a

def lcm(a, b):
    return (a * b) // gcd(a, b)


n = int(input())
ans = 1
for i in range(n):
    tmp = int(input())
    ans = lcm(ans, tmp)
print(ans)


Fixed submission:
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b,a%b)

def lcm(a, b):
    return (a * b) // gcd(a, b)


n = int(input())
ans = 1
for i in range(n):
    tmp = int(input())
    ans = lcm(ans, tmp)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
def lcm(a, b):
    return (a*b)//math.gcd(a,b)
n = int(input())
ans = 1
for i in range(n):
    tmp = int(input())
    ans=lcm(ans,tmp)
print(ans)

Fixed submission:
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b,a%b)

def lcm(a, b):
    return (a * b) // gcd(a, b)


n = int(input())
ans = 1
for i in range(n):
    tmp = int(input())
    ans = lcm(ans, tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import itertools
import sys

n=int(input())
all=1
for i in range(1,n+1):
    all*=i
print(all%(10**9+7))

Fixed submission:
import sys
import math
import itertools
MOD=10**9+7
n = int(input())
ans=1
for i in range(1, n + 1):
    ans =ans%MOD*i
print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
b = []
for i in range(n):
    t, m = map(int, input().split())
    a.append(t)
    b.append(m)
ans = 0
for i in range(n):
    while (ans + a[-1 - i]) % b[-1 - i] != 0:
        ans += 1
print(ans)


Fixed submission:
n = int(input())
a = []
b = []
for i in range(n):
    t, m = map(int, input().split())
    a.append(t)
    b.append(m)
ans = 0
for i in range(n):
    if((ans + a[-1 - i]) % b[-1 - i]!=0):
        ans += b[-1 - i] - (ans + a[-1 - i]) % b[-1 - i]
print(ans)