Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03739 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:51:53 2018

@author: maezawa
"""

def sign(x):
    return x//abs(x)

def f(n, a0, s):
    cnt = 0
    cum = 0
    for i, ai in enumerate(a):
        cum += ai
        if cum == 0:
            cnt += 1
            cum = (-1)**i*s
        elif sign(cum) == (-1)**i*s:
            continue
        else:
            cnt += abs(cum)+1
            cum = (-1)**i*s
    return cnt

n = int(input())
a = list(map(int, input().split()))

cnt = 0
cnt0 = f(n, a, -1)
cnt1 = f(n, a, 1)
cnt = min([cnt0,cnt1])
print(cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:51:53 2018

@author: maezawa
"""
def f(n, a0, cnt, sa, sign):
    a = a0[:]
    if sign == -1:
        cnt += abs(a[0])+1
        a[0] = -a[0]/abs(a[0])
    for i in range(n-1):
        sa += a[i]
        na = -sa//abs(sa)*(abs(sa)+1)
        if abs(a[i+1]) > abs(na) and a[i+1]*na > 0:
            continue
        else:
            cnt += abs(na-a[i+1])
            a[i+1] = na
    return cnt

n = int(input())
a = list(map(int, input().split()))
sa = 0
cnt = 0

cnt0 = f(n, a, 0, 0, -1)
cnt1 = f(n, a, 0, 0, 1)
cnt = min([cnt0,cnt1])
print(cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:51:53 2018

@author: maezawa
"""
def f(n, a0, cnt, sa, sign):
    a = a0[:]
    if sign == -1:
        a[0] = -a[0]
        cnt += 2*a[0]
    for i in range(n-1):
        sa += a[i]
        na = -sa//abs(sa)*(abs(sa)+1)
        if abs(a[i+1]) > abs(na) and a[i+1]*na > 0:
            continue
        else:
            cnt += abs(na-a[i+1])
            a[i+1] = na
    return cnt

n = int(input())
a = list(map(int, input().split()))
sa = 0
cnt = 0

cnt0 = f(n, a, cnt, sa, -1)

cnt1 = f(n, a, cnt, sa, 1)
cnt = min([cnt0,cnt1])
print(cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:51:53 2018

@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))
sa = 0
cnt = 0
for i in range(0,n-1):
    sa += a[i]
    na = -sa//abs(sa)*(abs(sa)+1)
    if abs(a[i+1]) > abs(na) and a[i+1]*na > 0:
        continue
    else:
        cnt += abs(na-a[i+1])
        a[i+1] = na

print(cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:51:53 2018

@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))
sa = 0
cnt = 0
for i in range(0,n-1):
    sa += a[i]
    na = -sa//abs(sa)*(abs(sa)+1)
    if abs(a[i+1]) > abs(na) and a[i+1]*na > 0:
        continue
    cnt += abs(na-a[i+1])
    a[i+1] = na

print(cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:51:53 2018

@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))
sa = 0
cnt = 0
for i in range(0,n-1):
    sa += a[i]
    na = -sa//abs(sa)*(abs(sa)+1)
    if abs(a[i+1]) > abs(na) and a[i+1]*na >= 0:
        continue
    cnt += abs(na-a[i+1])
    a[i+1] = na

print(cnt)
Problem p03759 (python)

Fixed submission:
a, b, c = list(map(int, input().split()))
if a-b == b-c:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split()))
if a-b = b-c:
  print('YES')
else:
  print('NO')
Problem p03777 (python)

Fixed submission:
a, b = input().split()
if a == 'H':
  print(b)
elif b == 'H':
  print('D')
else:
  print('H')

Buggy submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
if a == 'H':
  print(b)
elif b == 'H':
  print('D')
else:
  print('H')
Problem p03844 (python)

Fixed submission:
a, op, b = input().split()
if op == '+':
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

Buggy submission (verdict: Runtime Error):
a, op, b = input().split()
if op = '+':
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
Problem p03854 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 15 12:43:21 2018
ABC049C
@author: maezawa
"""

s = input()
a = ('dream', 'dreamer', 'erase', 'eraser')

i = len(s)
ans = 'YES'
while True:
    if s[-5:] == a[0] or s[-5:] == a[2]:
        i -= 5
        if i == 0:
            ans = 'YES'
            break
        elif i<5:
            ans = 'NO'
            break
        s = s[:i]
    elif i>=6 and s[-6:] == a[3]:
        i -= 6
        if i == 0:
            ans = 'YES'
            break
        elif i<5:
            ans = 'NO'
            break
        s = s[:i]
    elif i>=7 and s[-7:] == a[1]:
        i -= 7
        if i == 0:
            ans = 'YES'
            break
        elif i<5:
            ans = 'NO'
            break
        s = s[:i]
    else:
        ans = 'NO'
        break
    #print(s)
print(ans)

Buggy submission (verdict: Runtime Error):
i = len(s)
ans = 'YES'
while True:
    if s[-5:] == a[0] or s[-5:] == a[2]:
        i -= 5
        if i == 0:
            ans = 'YES'
            break
        elif i<5:
            ans = 'NO'
            break
        s = s[:i]
    elif i>=6 and s[-6:] == a[3]:
        i -= 6
        if i == 0:
            ans = 'YES'
            break
        elif i<5:
            ans = 'NO'
            break
        s = s[:i]
    elif i>=7 and s[-7:] == a[1]:
        i -= 7
        if i == 0:
            ans = 'YES'
            break
        elif i<5:
            ans = 'NO'
            break
        s = s[:i]
    else:
        ans = 'NO'
        break
    #print(s)
print(ans)
Problem p03998 (python)

Fixed submission:
s = [[] for _ in range(3)]
s[0]=list(input())
s[1]=list(input())
s[2]=list(input())
name = 'ABC'
i = 0
while True:
  if len(s[i]) == 0:
    print(name[i])
    break
  c = s[i].pop(0)  
  if c == 'a':
    i = 0
  elif c == 'b':
    i = 1
  else:
    i = 2

Buggy submission (verdict: Runtime Error):
s=[]
s.append[list(input())]
s.append[list(input())]
s.append[list(input())]
name = 'ABC'
i = 0
while True:
  if len(s[i]) == 0:
    print(name[i])
    break
  c = s[i].pop(0)  
  if c == 'a':
    i = 0
  elif c == 'b':
    i = 1
  else:
    i = 2
Problem p04046 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 23 17:33:45 2019
ABC042D
@author: maezawa
"""

MAX = 5*10**5+1
MOD = 10**9+7

fac = [0] * MAX
finv = [0]*MAX
inv = [0]*MAX

# テーブルを作る前処理
fac[0] = 1
fac[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
for i in range(2,MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

# 二項係数計算
def COM(n, k):
    if (n < k):
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

def HCOM(n,k):
    return COM(n+k-1,k)


#n, r = list(map(int, input().split()))
#ans = COM(n, r)
#print(ans)

h, w, a, b = list(map(int, input().split()))
cnt = 0
for i in range(h-a):
    p0 = HCOM(b, i) * HCOM(w-b,h-i-1)
    cnt = (cnt+p0)%MOD
print(cnt)

Buggy submission (verdict: Runtime Error):
import numpy as np

h, w, a, b = list(map(int, input().split()))

nmod = 10**9+7
board = np.zeros((h+1, w+1), dtype=int)
board[1,1] = 1

for x in range(1, h+1):
    for y in range(1, w+1):
        if x >= h-a+1 and y <= b:
            continue
        board[x,y] += board[x-1,y] + board[x,y-1]
        if board[x,y] >= nmod:
            board[x,y] = board[x,y] % nmod
print(board[h,w])
Problem p02887 (python)

Fixed submission:
N = int(input())
S = input()
ans = 1
for i in range(N):
  if i <= len(S)-2:
    if S[i] !=S[i+1]:
      ans = ans + 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
for w in 'abcdefghijklmnopqrstuvwxyz':
  if S.find(w) != -1:
    while S.count(w) != 1:
   		 if S[S.find(w) + 1] == w:
    	 	 S.replace(w + w,w)
print(len(S))
Problem p02898 (python)

Fixed submission:
N,K = map(int,input().split())
li = list(map(int,input().split()))
ans = 0
for i in li:
  if i >= K:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input())
li = [int(input()) for i in range(N)]
ans = 0
for i in li:
  if i >= K:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = int(input())
li = [int(input()) for i in range(N)]
ans = 0
for i in li:
  if i >= K:
    ans += 1
print(ans)
Problem p02899 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N = int(input())
li = list(map(int,input().split()))
ans = [0] * N
for i in range(N):
    ans[li[i]-1] = i+1
for j in range(N):
    print(ans[j],end = ' ')

Buggy submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split()))
ans = []
for i in range(N):
  ans.append(li.find(i+1) + 1)
for i in range(N):
  print(ans[i],end=' ')
Problem p03338 (python)

Fixed submission:
import collections

N = int(input())
S = input()
A = ''
B = S
ans = 0
for i in range(N):
  A += B[0]
  B = B[1:]
  C = collections.Counter(A)
  D = 0
  for w in C:
    if w in B:
      D += 1
  if D > ans:
    ans = D
print(ans)

Buggy submission (verdict: Runtime Error):

    import collections

N = int(input())
S = input()
A = ''
B = S
ans = 0
for i in range(N):
  A += B[0]
  B = B[1:]
  C = collections.Counter(A)
  D = 0
  for w in C:
    if w in B:
      D += 1
  if D > ans:
    ans = D
print(ans)
Problem p03435 (python)

Fixed submission:
import numpy as np

c = [list(map(int,input().split())) for i in range(3)]

A = np.array([
    [1,0,0,1,0,0],
    [1,0,0,0,1,0],
    [1,0,0,0,0,1],
    [0,1,0,1,0,0],
    [0,1,0,0,1,0],
    [0,1,0,0,0,1],
    [0,0,1,1,0,0],
    [0,0,1,0,1,0],
    [0,0,1,0,0,1]])

B = np.array([
    [1,0,0,1,0,0,c[0][0]],
    [1,0,0,0,1,0,c[0][1]],
    [1,0,0,0,0,1,c[0][2]],
    [0,1,0,1,0,0,c[1][0]],
    [0,1,0,0,1,0,c[1][1]],
    [0,1,0,0,0,1,c[1][2]],
    [0,0,1,1,0,0,c[2][0]],
    [0,0,1,0,1,0,c[2][1]],
    [0,0,1,0,0,1,c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np

c = [list(map(int,input().split())) for i in range(3)]

A = np.array([
    [1,0,0,1,0,0],
    [1,0,0,0,1,0],
    [1,0,0,0,0,1],
    [0,1,0,1,0,0],
    [0,1,0,0,1,0],
    [0,1,0,0,0,1],
    [0,0,1,1,0,0],
    [0,0,1,0,1,0],
    [0,0,1,0,0,1]])

B = np.array([
    [1,0,0,1,0,0,c[0][0]],
    [1,0,0,0,1,0,c[0][1]],
    [1,0,0,0,0,1,c[0][2]],
    [0,1,0,1,0,0,c[1][0]],
    [0,1,0,0,1,0,c[1][1]],
    [0,1,0,0,0,1,c[1][2]],
    [0,0,1,1,0,0,c[2][0]],
    [0,0,1,0,1,0,c[2][1]],
    [0,0,1,0,0,1,c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np

c = [list(map(int,input().split())) for i in range(3)]

A = np.array([
    [1,0,0,1,0,0],
    [1,0,0,0,1,0],
    [1,0,0,0,0,1],
    [0,1,0,1,0,0],
    [0,1,0,0,1,0],
    [0,1,0,0,0,1],
    [0,0,1,1,0,0],
    [0,0,1,0,1,0],
    [0,0,1,0,0,1]])

B = np.array([
    [1,0,0,1,0,0,c[0][0]],
    [1,0,0,0,1,0,c[0][1]],
    [1,0,0,0,0,1,c[0][2]],
    [0,1,0,1,0,0,c[1][0]],
    [0,1,0,0,1,0,c[1][1]],
    [0,1,0,0,0,1,c[1][2]],
    [0,0,1,1,0,0,c[2][0]],
    [0,0,1,0,1,0,c[2][1]],
    [0,0,1,0,0,1,c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print('Yes')
else:
    print('No')
Problem p03495 (python)

Fixed submission:
import sys
import collections
input = sys.stdin.readline

N,K = map(int,input().split())
a = list(map(int,input().split()))
c = collections.Counter(a)
d = len(c)
ans = 0
c_sorted = sorted(c.items(),key = lambda x:x[1])
for i in c_sorted:
    if K >= d:
        break
    ans += i[1]
    d -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
b = set(a)
c = [a.count(i) for i in b]
d = len(b)
ans = 0
for i in c:
  if K >= d:
    break
  ans += i
  d -= 1
  print(c[i])
print(ans)
Problem p03625 (python)

Fixed submission:
N = int(input())
li = list(map(int,input().split()))
li.sort()
a = 0
b = 0
while len(li) >= 2:
  if li[-1] == li[-2] and a == 0:
    a = li[-1]
    del li[-1]
    del li[-1]
  elif li[-1] != li[-2]:
    del li[-1]
  elif li[-1] == li[-2] and a != 0:
    b = li[-1]
    break
print(a * b)

Buggy submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split()))
li.sort()
a = 0
b = 0
while len(li) >= 1:
  if li[-1] == li[-2] and a == 0:
    a = li[-1]
    del li[-1]
  elif li[-1] != li[-2] or  a != 0 and a == li[-1]:
    del li[-1]
  elif li[-1] == li[-2] and a != 0:
    b = li[-1]
    break
print(a * b)

Buggy submission (verdict: Runtime Error):
N = int(input())
li = list(map(int,input().split()))
li.sort()
a = 0
b = 0
for i in range(N):
  if li[-1] == li[-2] and a == 0:
    a = li[-1]
    del li[-1]
  elif li[-1] != li[-2] or  a != 0 and a == li[-1]:
    del li[-1]
  elif li[-1] == li[-2] and a != 0:
    b = li[-1]
    break
print(a * b)
Problem p03645 (python)

Fixed submission:
N,M = map(int,input().split())
li = []
numb = []
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        li.append(b)
    elif b == N:
        numb.append(a)
ans = set(li) & set(numb)
if len(ans) >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
li = []
numb = []
ans = ''
for i in range(M):
  a,b = map(int,input().split())
  if a == 1:
    li.append(b)
  elif b == N:
    numb.append(a)
for i in range(M):
  if li[i] in numb:
    ans = 'POSSIBLE'
    break
if ans == '':
  print('IMPOSSIBLE')
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
li = []
numb = []
ans = ''
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        li.append(b)
    elif b == N:
        numb.append(a)
for i in range(M):
  if li[i] in numb:
    ans = 'POSSIBLE'
    break
if ans == '':
  print('IMPOSSIBLE')
else:
  print(ans)
Problem p03761 (python)

Fixed submission:
N = int(input())
li = []
moji = []
ans = ''
for i in range(N):
  li.append(input())
for w in li[0]:
  countw = 1
  for j in range(1,N):
    for k in range(len(li[j])):
      if li[j][k] == w:
        countw += 1
        li[j] = li[j].replace(w, '', 1)
        break
  if countw == N:
    moji.append(w)
moji.sort()
for i in range(len(moji)):
  ans += moji[i]
print(ans)

Buggy submission (verdict: Runtime Error):
li = []
moji = []
ans = ''
for i in range(N):
  li.append(input())
for w in li[0]:
  countw = 1
  for j in range(1,N):
    for k in range(len(li[j])):
      if li[j][k] == w:
        countw += 1
        li[j].replace(w, '', 1)
        break
  if countw == N:
    moji.append(w)
moji.sort()
for i in range(len(moji)):
  ans += moji[i]
print(ans)
Problem p03815 (python)

Fixed submission:
N = int(input())
ans = (N // 11) * 2
if N%11 == 0:
    ans = ans
elif N%11 != 0 and N%11 <= 6:
    ans += 1
else:
    ans += 2
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = (N // 11) * 2
if N%11 == 0:
    ans = ans
elif N%0 != 0 and N%11 <= 6:
    ans += 1
else:
    ans += 2
print(ans)
Problem p03353 (python)

Fixed submission:
s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i+1, min(i+6, len(s)+1)):
        sub.append(s[i:j])
sub = sorted(list(set(sub)))
print(sub[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        sub.append(s[i:j])
sub = sorted(list(set(sub)))
print(sub[k-1])
Problem p03379 (python)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
x = sorted(X)
m1 = x[N//2]
m2 = x[N//2-1]
for i in X:
    print(m1 if i < m1 else m2)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
x = sorted(X)
m1 = x[N//2]
m2 = x[N//2-1]
for i in X:
    print(m1 if i < m else m2)
Problem p03391 (python)

Fixed submission:
n = int(input())
a, b, c = [], [], []
for i in range(n):
    ab = list(map(int, input().split()))
    a.append(ab[0])
    b.append(ab[1])
    if(ab[0] > ab[1]):
        c.append(ab[1])
if(len(c) == 0):
    print(0)
else:
    print(sum(a) - min(c))

Buggy submission (verdict: Runtime Error):
n = int(input())
a, b, c = [], [], []
for i in range(n):
    ab = list(map(int, input().split()))
    a.append(ab[0])
    b.append(ab[1])
    if(ab[0] > ab[1]):
        c.append(ab[1])
if(len(c) == 0):
    print(0)
else:
    sort.c()
    print(sum(a) - c[0])
Problem p03393 (python)

Fixed submission:
s = input()
if(len(s) != 26):
    for c in range(ord('a'), ord('z')+1):
        c = chr(c)
        if(not c in s):
            print(s+c)
            exit()
s = list(s)
t = []
while(s):
    for c in t:
        if(c > s[-1]):
            print(''.join(s[:-1]) + c)
            exit()
    t.append(s.pop())
print(-1)

Buggy submission (verdict: Runtime Error):
s = input()
if(len(s) == 0):
    print('a')
if(len(s) != 26):
    for c in range(ord('a'), ord('z')+1):
        c = chr(c)
        if(not c in s):
            print(s+c)
            exit()
s = list(s)
t = []
while(True):
    for c in t:
        if(c > s[-1]):
            print(''.join(s[:-1]) + c)
            exit()
    t.append(s.pop())

Buggy submission (verdict: Runtime Error):
s = input()
if(len(s) != 26):
    for c in range(ord('a'), ord('z')+1):
        c = chr(c)
        if(not c in s):
            print(s+c)
            exit()
s = list(s)
t = []
while(True):
    for c in t:
        if(c > s[-1]):
            print(''.join(s[:-1]) + c)
            exit()
    t.append(s.pop())
Problem p03457 (python)

Fixed submission:
n = int(input())
t = [[0, 0, 0]]
for i in range(n):
    t.append(list(map(int, input().split())))
for i in range(0, n):
    time = t[i+1][0] - t[i][0]
    move = t[i+1][1] + t[i+1][2] - (t[i][1] + t[i][2])
    if(move > time or move%2 != time%2):
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
t = [[0, 0, 0]]
for i in range(n):
    t.append(list(map(int, input().split())))
for i in range(0, n+1):
    time = t[i+1][0] - t[i][0]
    move = t[i+1][1] + t[i+1][2] - (t[i][1] + t[i][2])
    if(move > time or move%2 != time%2):
        print("No")
        exit()
print("Yes")
Problem p03544 (python)

Fixed submission:
n = int(input())
l = [2, 1]
for i in range(2, n+1):
    l.append(l[i-2]+l[i-1])
print(l[n])

Buggy submission (verdict: Runtime Error):
n = int(input())-1
a, b = 2, 1
if(n==0):
    print(2)
elif(n==1):
    print(1)
while(n):
    c = a + b
    a = b
    b = c
    n -= 1
print(c)
Problem p03712 (python)

Fixed submission:
h, w = map(int, input().split())
s = []
s.append('#'*(w+2))
for i in range(h):
    s.append('#'+input()+'#')
s.append('#'*(w+2))
for i in range(h+2):
    print(s[i])

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
print('#'*w)
for i in range(w):
    print('#'+input()+'#')
print('#'*w)
Problem p02814 (python)

Fixed submission:
import fractions
import math

n,m = map(int,input().split())
A=list(map(int,input().split()))

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

def chk(i):
    cnt=0
    while True:
        if i%2==0:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        exit()

l = 1
for i in A:
    l = l * i//2 // fractions.gcd(l, i//2)
 
print((m // l + 1) // 2)

"""
num=A[0]//2
flag2=0
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            flag2=1
            break
    if flag2==1:
        print(0)
    else:
        print(math.ceil(m//num/2))
"""

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

n,m = map(int,input().split())
A=list(map(int,input().split()))

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

def chk(i):
    cnt=0
    while True:
        if i%2==0:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        flag=1

num=A[0]//2
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            num=0
            break
    print(math.ceil(m//num/2))

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

n,m = map(int,input().split())
A=list(map(int,input().split()))

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

def chk(i):
    cnt=0
    while True:
        if i%2==1:
            i/=2
            cnt+=1
        else:
            break
    return cnt

flag=0
number=chk(A[0])
for i in A:
    if chk(i)!=number:
        print(0)
        flag=1

num=A[0]//2
if flag==0:
    for i in range(1,len(A)):
        num=lcm(num,A[i]//2)
        if num>m:
            num=0
            break
print(math.ceil(m//num/2))
Problem p03006 (python)

Fixed submission:
import collections

n=int(input())

if n==1:
    a,b=(map(int, input().split()))
    print(1)
else:

    arr=[]
    for i in range(n):
        a,b=(map(int, input().split()))
        arr.append([a,b])
    arr=sorted(arr, key=lambda x: x[1], reverse=True)
    arr=sorted(arr, key=lambda x: x[0])
    
    tmparr=[]
    for num in range(len(arr)-1):
        #print(num)
        #tmparr=[]
        #for nn,i in enumerate(arr):
        for nn,i in enumerate(arr[num+1:]):
            #if nn==num:
            #    continue
            #g=gcd(arr[num][0]-i[0],arr[num][1]-i[1])
            tmparr.append(((arr[num][0]-i[0]),(arr[num][1]-i[1])))
            #print(tmparr)
        #print(tmparr)
    #print(set(tmparr))
    c = collections.Counter(tmparr)
    print(n-c.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
import collections
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


n=int(input())

arr=[]
for i in range(n):
    a,b=(map(int, input().split()))
    arr.append([a,b])
arr=sorted(arr, key=lambda x: x[1], reverse=True)
arr=sorted(arr, key=lambda x: x[0])

tmparr=[]
for num in range(len(arr)-1):
    #print(num)
    #tmparr=[]
    #for nn,i in enumerate(arr):
    for nn,i in enumerate(arr[num+1:]):
        #if nn==num:
        #    continue
        g=gcd(arr[num][0]-i[0],arr[num][1]-i[1])
        tmparr.append(((arr[num][0]-i[0]),(arr[num][1]-i[1])))
        #print(tmparr)
    #print(tmparr)
#print(set(tmparr))
c = collections.Counter(tmparr)
print(n-c.most_common()[0][1])
Problem p03076 (python)

Fixed submission:
import math
arr=[]
for _ in range(5):
    arr.append(int(input()))

targetnum=999
minnum=10
for num,i in enumerate(arr):
    if int(str(i)[-1])<minnum and int(str(i)[-1])>0:
        minnum=int(str(i)[-1])
        targetnum=num

result=0
for num,i in enumerate(arr):
    if num==targetnum:
        result+=i
        #print("aa")
    else:
        result+=math.ceil(i/10)*10


print(result)

Buggy submission (verdict: Runtime Error):
import math
arr=[]
for _ in range(5):
    arr.append(int(input()))

minnum=10
for num,i in enumerate(arr):
    if int(str(i)[-1])<minnum and int(str(i)[-1])>0:
        minnum=int(str(i)[-1])
        targetnum=num

result=0
for num,i in enumerate(arr):
    if num==targetnum:
        result+=i
        #print("aa")
    else:
        result+=math.ceil(i/10)*10


print(result)