Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

N,P = MI()
S = S()
mod = 0
ans = 0
dic = {0:1}
if P == 2 or P == 5:
    for i in range(N):
        if int(S[i])%P==0:
            ans += i+1
else:
    for i in range(N-1,-1,-1):
        mod = (mod+10**(N-1-i)*int(S[i]))%P
        dic[mod] = dic.get(mod,0)+1
    for i in dic.values():
        ans += int(i*(i-1)/2)
print(ans)


Fixed submission:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 998244353
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

N,P = MI()
S = S()
mod = 0
ans = 0
dic = {0:1}
if P == 2 or P == 5:
    for i in range(N):
        if int(S[i])%P==0:
            ans += i+1
else:
    for i in range(N-1,-1,-1):
        mod = (mod+pow(10,(N-1-i),P)*int(S[i]))%P
        dic[mod] = dic.get(mod,0)+1
    for i in dic.values():
        ans += int(i*(i-1)/2)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = [int(i) for i in input().split()]
d = {}
for i in range(M):
    s,c = [int(i) for i in input().split()]
    if d.get(s,c) != c:
        print(-1)
        break
    else:
        d[s] = c
else:
    if d[1] == 0:
        print(-1)
    else:
        l=[str(d.get(1,1))]
        l=[str(d.get(i,0)) for i in range(2, N+1)]
        print(''.join(l))


Fixed submission:
N,M = [int(i) for i in input().split()]
d = {}
for i in range(M):
    s,c = [int(i) for i in input().split()]
    if d.get(s,c) != c:
        print(-1)
        break
    else:
        d[s] = c
else:
    if N==1:
        print(d.get(1,0))
    elif d.get(1,1) == 0:
        print(-1)
    else:
        l = [str(d.get(1,1))]
        l+=[str(d.get(i,0)) for i in range(2, N+1)]
        print(''.join(l))

Buggy python submission (verdict: Runtime Error):
N,M = [int(i) for i in input().split()]
d = {}
for i in range(M):
    s,c = [int(i) for i in input().split()]
    if d.get(s,c) != c:
        print(-1)
        break
    else:
        d[s] = c
else:
    if d[1] == 0:
        print(-1)
    else:
        l=[str(d.get(i,0)) for i in range(1, N+1)]
        print(''.join(l))


Fixed submission:
N,M = [int(i) for i in input().split()]
d = {}
for i in range(M):
    s,c = [int(i) for i in input().split()]
    if d.get(s,c) != c:
        print(-1)
        break
    else:
        d[s] = c
else:
    if N==1:
        print(d.get(1,0))
    elif d.get(1,1) == 0:
        print(-1)
    else:
        l = [str(d.get(1,1))]
        l+=[str(d.get(i,0)) for i in range(2, N+1)]
        print(''.join(l))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]
 
print(DP[-1])

Fixed submission:
n = int(input())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    dp[i+2] = min(dp[i+1]+abs(v[i+1]-v[i+2]),dp[i]+abs(v[i]-v[i+2]))

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n,K = map(int,input().split())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    for k in range(K):
        if i+1-k>=0:
            dp[i+2] = min(dp[i+2],dp[i+1-k]+abs(v[i+2]-v[i+1-k]))


print(dp[n-1])

Fixed submission:
n = int(input())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    dp[i+2] = min(dp[i+1]+abs(v[i+1]-v[i+2]),dp[i]+abs(v[i]-v[i+2]))

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n,K = map(int,input().split())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    for k in range(K):
        if i+1-k>=0:
            dp[i+2] = min(dp[i+2],dp[i+1-k]+abs(v[i+2]-v[i+1-k]))


print(dp[n-1])


Fixed submission:
n = int(input())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    dp[i+2] = min(dp[i+1]+abs(v[i+1]-v[i+2]),dp[i]+abs(v[i]-v[i+2]))

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+1)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-1):
    dp[i+2] = min(dp[i+1]+abs(v[i+1]-v[i+2]),dp[i]+abs(v[i]-v[i+2]))

print(dp[n-1])


Fixed submission:
n = int(input())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    dp[i+2] = min(dp[i+1]+abs(v[i+1]-v[i+2]),dp[i]+abs(v[i]-v[i+2]))

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
n,m = map(len,[s,t])

dp = [['' for i in range(m+1)] for j in range(n+1)]

for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1] = dp[i][j] + s[i]
        else:
            dp[i+1][j+1] = dp[i][j]
        dp[i+1][j+1] = dp[i+1][j] if len(dp[i+1][j])>len(dp[i+1][j+1]) else dp[i+1][j+1]
        dp[i+1][j+1] = dp[i][j+1] if len(dp[i][j+1])>len(dp[i+1][j+1]) else dp[i+1][j+1]
print(dp[n][m])

Fixed submission:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

S = list(ST())
T = list(ST())
dp = FILL2(0,len(S)+1,len(T)+1)
for i in range(len(S)+1):
    for j in range(len(T)+1):
        if i+1<=len(S) and j+1<=len(T):
            if S[i]==T[j]:
                dp[i+1][j+1] = dp[i][j] + 1
        if i+1<=len(S):
            dp[i+1][j] = max(dp[i+1][j],dp[i][j])
        if j+1 <= len(T):
            dp[i][j+1] = max(dp[i][j+1],dp[i][j])

l = dp[len(S)][len(T)]
i = len(S)
j = len(T)
ans = ''
while l > 0:
    if S[i-1]==T[j-1]:
        i -= 1
        j -= 1
        l -= 1
        ans = S[i]+ans
    else:
        if dp[i][j-1]==dp[i][j]:
            j -= 1
        else:
            i -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
to = [[] for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    to[x-1]+=[y-1]

dp = [-1 for i in range(N)] #node[i]からの最長経路長を記す -1で未決定を示す

def memo(i):
    if dp[i] != -1:
        return dp[i]
    a=0
    for j in to[i]:
        a=max(a, memo(j)+1)
    dp[i] = a
    return a
    
lp = 0
for i in range(N):
    lp = max(lp,memo(i))
print(lp)

Fixed submission:
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = sys.stdin.readline

N,M = map(int,input().split())
to = [[] for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    to[x-1]+=[y-1]

dp = [-1 for i in range(N)] #node[i]からの最長経路長を記す -1で未決定を示す

def memo(i):
    if dp[i] != -1:
        return dp[i]
    a=0
    for j in to[i]:
        a=max(a, memo(j)+1)
    dp[i] = a
    return a

lp = 0
for i in range(N):
    lp = max(lp,memo(i))
print(lp)
Buggy python submission (verdict: Runtime Error):
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

a,b = MI()
print(int((a+b+1)/2)


Fixed submission:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

a,b = MI()
print(int((a+b+1)/2))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

t = 1
for _ in range(k):
    t = a[t-1]

print(t)

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

pos = 0
visit = [0]*n
move = []
roop = []
while visit[pos] != 2:
    if visit[pos] == 0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = a[pos] - 1
if len(move) > k:
    print(move[k]+1)
else:
    print(roop[(k-(len(move)-len(roop))) % len(roop)]+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = 2019
cnt = [0] * N
S = input()
ans = 0
for s in S:
    s = int(s)
    new = [0] * N
    for n in range(N):
        idx = (10 * n + s) % N
        new[idx] += cnt[n]
    cnt = new
    cnt[s] += 1
    ans += cnt[0]

print(ans)


Fixed submission:
N = 2019
cnt = [0] * N
S = input()
ans = 0
for s in S:
    s = int(s)
    new = [0] * N
    for n in range(N):
        idx = (10 * n + s) % N
        new[idx] += cnt[n]
    cnt = new
    cnt[s] += 1
    ans += cnt[0]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
k = int(input())

res = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        t = gcd(a, b)
        for c in range(1, k+1):
            res += gcd(t, c)

print(res)


Fixed submission:
import math
k = int(input())
res = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        t = math.gcd(a, b)
        for c in range(1, k+1):
            res += math.gcd(t, c)
print(res)
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
ans = a * b // math.gcd(a, b)
print(ans)


Fixed submission:
import fractions
a, b = map(int, input().split())
ans = a * b // fractions.gcd(a, b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    a = list(input())
    a.sort()
    s.append(''.join(a))

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        if s[i] == s[j]:
            ans += 1

print(ans)


Fixed submission:
n = int(input())
s = [input() for _ in range(n)]

for i in range(n):
    s[i] = ''.join(sorted(s[i]))
# print(s)
t = {}
for i in range(n):
    if s[i] in t:
        t[s[i]] += 1
    else:
        t[s[i]] = 1
# print(t)
print(sum(t[k]*(t[k]-1)//2 for k in t))

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

for i in range(n):
    a = list(s[i])
    a.sort()
    s[i] = ''.join(a)

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        if s[i] == s[j]:
            ans += 1

print(ans)


Fixed submission:
n = int(input())
s = [input() for _ in range(n)]

for i in range(n):
    s[i] = ''.join(sorted(s[i]))
# print(s)
t = {}
for i in range(n):
    if s[i] in t:
        t[s[i]] += 1
    else:
        t[s[i]] = 1
# print(t)
print(sum(t[k]*(t[k]-1)//2 for k in t))
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

res = []
for i in range(1, min(a, b)):
    if a % i == 0 and b % i == 0:
        res.append(i)

res.sort(reverse=True)
print(res[k-1])


Fixed submission:
a, b, k = map(int, input().split())

res = []
for i in range(1, 101):
    if a % i == 0 and b % i == 0:
        res.append(i)

res.sort(reverse=True)
print(res[k-1])
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = n; i <= 999; i++) {
    string str = to_string(i);
    set<char> st;
    for (int i = 0; i < str.size(); i++) {
      st.insert(str[i]);
    }
    if (st.size() == 1) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Fixed submission:
n = int(input())
for i in range(n, 1000):
    if len(set(str(i))) == 1:
        print(i)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
n = int(input())
count = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      count += gcd(i+1, j+1, k+1)
print(count)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
n = int(input())
count = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      count += gcd(i+1, j+1, k+1)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n, x, y = map(int, input().split())
lst = []
for i in range(1, n+1):
  for j in range(i, n+1):
    tmp = min(abs(i-j), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(x-j))
    lst.append(tmp)
lst = collections.Counter(lst)
for i in range(1, n):
  print(lst[i])

Fixed submission:
import collections
n, x, y = map(int, input().split())
lst = []
for i in range(1, n+1):
  for j in range(i, n+1):
    tmp = min(abs(i-j), abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(x-j))
    lst.append(tmp)
lst = collections.Counter(lst)
for i in range(1, n):
  print(lst[i])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
b = True
for _ in range(q):
  query = input()
  if query == "1":
    b = not(b)
  else:
    t, f, c = query.split()
    if int(f) + b == 2:
      s = c + s
    else:
      s = s + c
print(s if b else s[::-1])

Fixed submission:
s = input()
q = int(input())
b = True
left = []
right = []
for _ in range(q):
  query = input()
  if query == "1":
    b = not(b)
  else:
    t, f, c = query.split()
    if int(f) + b == 2:
      left.append(c)
    else:
      right.append(c)
s = "".join(left)[::-1] + s + "".join(right)
print(s if b else s[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for _ in range(q):
  query = input()
  if query == "1":
    s = s[::-1]
  else:
    t, f, c = query.split()
    if f == "1":
      s = c + s
    else:
      s = s + c
print(s)

Fixed submission:
s = input()
q = int(input())
b = True
left = []
right = []
for _ in range(q):
  query = input()
  if query == "1":
    b = not(b)
  else:
    t, f, c = query.split()
    if int(f) + b == 2:
      left.append(c)
    else:
      right.append(c)
s = "".join(left)[::-1] + s + "".join(right)
print(s if b else s[::-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())) 

result = 1
if 0 in A:
    result = 0
else:
    for i in A:
    result *= i
    if result > 10**18:
        result = -1
        break

print(result)


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

result = 1
A.sort()
for i in A:
    result *= i
    if result > 10**18:
        result = -1
        break

print(result)

Buggy python submission (verdict: Runtime Error):
result = 1
if 0 in A:
    result = 0
else:
    for i in A:
        result *= i
        if result > 10**18:
            result = -1
            break

print(result)

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

result = 1
A.sort()
for i in A:
    result *= i
    if result > 10**18:
        result = -1
        break

print(result)
Buggy python submission (verdict: Runtime Error):
K = int(input())
S = input()

length = len(s)
if K >= length:
    print(S)
else:
    print(S[:K] + '...')


Fixed submission:
K = int(input())
S = input()

if K >= len(S):
    print(S)
else:
    print(S[:K] + '...')

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

length = len(s)
if K <= length:
    print(S)
else:
    print(S[:K] + '...')


Fixed submission:
K = int(input())
S = input()

if K >= len(S):
    print(S)
else:
    print(S[:K] + '...')
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())

if A => K:
    print(K)
elif A + B => K:
    print(A)
else:
    print(A+(K-C)*(-1))



Fixed submission:
A, B, C, K = map(int, input().split())

if A >= K:
    print(K)
elif A + B >= K:
    print(A)
else:
    print(A+(K-B-A)*(-1))
Buggy python submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = sorted(map(int, input().split()))

if h <= a[-2] + a[-1]:
    print('Yes')
else:
    print('No')

Fixed submission:
h, n = map(int, input().split())
a = [int(x) for x in input().split()]

if h <= sum(a):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
if h <= a[-2] + a[-1]:
    print('Yes')
else:
    print('No')

Fixed submission:
h, n = map(int, input().split())
a = [int(x) for x in input().split()]

if h <= sum(a):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
def sieve(n, s):
    num = [True]*n
    num[0] = num[1] = False
    for i in range(2,int(n**0.5)+1):
        if num[i]:
            for j in range(i**2, n, i):
                num[j] = False
    return [i for i in range(2,n) if num[i] and i > s]
print(sieve(int(N*1.2), N)[0])

Fixed submission:
S, T = input().split()
print(T + S)

Buggy python submission (verdict: Runtime Error):
N = int(input())
def sieve(n, s):
    num = [True]*n
    num[0] = num[1] = False
    for i in range(2,int(n**0.5)+1):
        if num[i]:
            for j in range(i**2, n, i):
                num[j] = False
    return [i for i in range(2,n) if num[i] and i > s]
print(sieve(N*2, N)[0])

Fixed submission:
S, T = input().split()
print(T + S)
Buggy python submission (verdict: Time Limit Exceeded):
info = [int(i) for i in  input().split()]
t, a, k = info
for i in range(k):
    if t > 0:
        t -= 1
    elif a > 0:
        a -= 1
    else:
        break
print(t, a)

Fixed submission:
info = [int(i) for i in  input().split()]
t, a, k = info
if t <= k:
    a = a - (k - t)
    t = 0
    if a <= 0:
        a = 0
else:
    t = t - k
print(t, a)

Buggy python submission (verdict: Time Limit Exceeded):
info = [int(i) for i in  input().split()]
t, a, k = info
for i in range(k):
    if t > 0:
        t -= 1
    elif a > 0:
        a -= 1
    else:
        break
print(t, a)

Fixed submission:
info = [int(i) for i in  input().split()]
t, a, k = info
if t <= k:
    a = a - (k - t)
    t = 0
    if a <= 0:
        a = 0
else:
    t = t - k
print(t, a)
Buggy python submission (verdict: Runtime Error):
X = int(input())
A, B, C = map(int, input().split())

price = 0
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            price = i * 500 + j * 100 + k * 50
            if price == X:
                count += 1
            price = 0

print(count)


Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
 
count = 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:
                count += 1
 
print(count)

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

X = int(input())
A, B, C = map(int, input().split())

price = 0
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            price = i * 500 + j * 100 + k * 50
            if price == X:
                count += 1
            price = 0

print(count)



Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
 
count = 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:
                count += 1
 
print(count)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split(','))

if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')

Fixed submission:

a, b = map(int, input().split(' '))

if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')