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

Fixed submission:
# coding: utf-8
import math

num = int(input())
total = 0
max = 0
tall = list(map(int, input().split()))
for i in range(num):
    if max <= tall[i]:
        max = tall[i]
    if max > tall[i]:
        total += max -tall[i]

print(total)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

num = int(input())
total = 0

tall = list(map(int, input().split()))
for i in range(num):
    if i != num-1:
    	num1 = tall[i]
    	num2 = tall[i+1]
    if num1 > num2:
        total += num2 - num1

print(abs(total))
Problem p02754 (python)

Fixed submission:
# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // all_ball
rest = num % all_ball
print(count * blue_num + min(rest, blue_num))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // (all_ball)
rest = n % all_ball
print(count * all_ball + min(rest, blue_num))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(math.floor(num / all_ball))
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue_rest = rest
    print((count * blue_num)a + blue_rest)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(math.floor(num / all_ball))
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue_rest = rest
    print((count * blue_num) + blue_rest)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(math.floor(num / all_ball))
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue = rest
    print((count) * blue_num + blue)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(num / all_ball)
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue = rest
    print((count) * blue_num + blue)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + blue)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + blue)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + blue)
Problem p02594 (python)

Fixed submission:
X = int(input())

if X >= 30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
X = int(input().split())

if X >= 30:
    print("Yes")
else:
    print("No")
Problem p02987 (python)

Fixed submission:
S = input()

if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]) or (S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]) or (S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]):
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
S = input()

if (S[0]==S[1] and S[2]==S[3}) or (S[0]==S[2] and S[1]==S[3]) or (S[0]==S[3] and S[1]==S[2]):
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
S = input()

if S[1]==S[0]:
	count1=count1+1
	if S[2]==S[0] or S[3]==S[0]:
		print('No')
	elif S[3]==S[2]:
		print('Yes')
elif (S[2]==S[0] and S[3]==S[1]) or (S[2]==S[1] and S[3]==S[0]):
	print('Yes')
else:
	print('No')
Problem p03038 (python)

Fixed submission:
#要修正　方針は合っているようだが・・・
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse=True,key = lambda x:x[1])

pt,card,index = 0,BC[0][1],0
while True:
    for i in range(BC[index][0]):
        if pt < N:
            A[pt] = max(A[pt],card)
        else:
            break
        pt += 1

    index += 1
    if index < M:
        card = BC[index][1]
    else:
        break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse=True,key = lambda x:x[1])

pt,card,index = 0,BC[0][1],0
while True:
    for i in range(BC[index][0]):
        A[pt] = max(A[pt],card)
        pt += 1
        if pt >= N-1:
            break
    index += 1
    if index < M:
        card = BC[index][1]
    else:
        break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse=True,key = lambda x:x[1])

pt,card,index = 0,BC[0][1],0
while True:
    for i in range(BC[index][0]):
        A[pt] = max(A[pt],card)
        pt += 1
        if pt >= N-1:
            break
    index += 1
    if index < M:
        card = BC[index][1]
    else:
        break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse=True,key = lambda x:x[1])

pt,card,index = 0,BC[0][1],0
while A[pt] < card:
    for i in range(BC[index][0]):
        if A[pt] < card:
            A[pt] = card
        pt += 1
        if pt >= N:
            break
    index += 1
    if index < M:
        card = BC[index][1]
    else:
        break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse=True,key = lambda x:x[1])

pt,card,index = 0,BC[0][1],0
while A[pt] < card:
    for i in range(BC[index][0]):
        if A[pt] < card:
            A[pt] = card
        pt += 1
    index += 1
    if index < M:
        card = BC[index][1]
    else:
        break
    if pt >= N:
        break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse=True,key = lambda x:x[1])

pt,card,index = 0,BC[0][1],0
while A[pt] < card:
    for i in range(BC[index][0]):
        if A[pt] < card:
            A[pt] = card
        pt += 1
    index += 1
    if index < M:
        card = BC[index][1]
    else:
        break

print(sum(A))
Problem p02571 (python)

Fixed submission:
s = input()
t = input()

a = []
for i in range(len(s)-len(t)+1):
  count = 0
  for j in range(len(t)):
    if t[j] != s[j+i]:
      count += 1
  a.append(count)
  
print(min(a))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

a = []
for i in range(len(s)-len(t)):
  count = 0
  for j in range(len(t)):
    if t[j] != s[j+i]:
      count += 1
  a.append(count)
  
print(min(a))
Problem p02629 (python)

Fixed submission:
n = int(input())

def name(n):
  if (n == 0):
    return "";
  n-=1
  return name(n//26) + chr(ord("a")+ n%26)
  
print(name(n))

Buggy submission (verdict: Runtime Error):
memo = {
        1:"a", 2:"b", 3:"c",4:"d", 5:"e",
        6:"f", 7:"g", 8:"h", 9:"i",10:"j",
       11:"k",12:"l",13:"m",14:"n",15:"o",
       16:"p",17:"q",18:"r",19:"s",20:"t",
       21:"u",22:"v",23:"w",24:"x",25:"y",26:"z"
        }

n = int(input())

def name(n):
    if n <= 26:
        return memo[n]
    
    memo[n] = name(n//26) + name(n%26)

    return memo[n]
  
print(name(n))
Problem p02847 (python)

Fixed submission:
d = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}

s = input()
print(d[s])

Buggy submission (verdict: Runtime Error):
d = {"SUN":7,"MON":6,"TUE":5,"WEN":4,"THU":3,"FRI":2,"SAT":1}

s = input()
print(d[s])

Buggy submission (verdict: Runtime Error):
d = {"SUN":7,"MON":6,"TUE":5,"WEN":4,"THU":3,"FRI":2,"STR":1}

s = input()
print(d[s])
Problem p03307 (python)

Fixed submission:
a = int(input())

if a%2 == 0 :
    print(a)
else :
    print(a*2)

Buggy submission (verdict: Runtime Error):
a = int(input())

if a%n == 2 :
    print(a)
else :
    print(a*2)
Problem p03774 (python)

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

ab = [list(map(int,input().split()))for _ in range(n)]
cd = [list(map(int,input().split()))for _ in range(m)] 

for a, b in ab:
  distance = [abs(a-c) + abs(b-d) for c,d in cd]
  print(distance.index(min(distance))+1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split()) 
ab = []
for i in range(n):
  a, b = map(int, input().split()) 
  ab.append([a,b])

cd = []  
for i in range(n):
  c, d = map(int, input().split()) 
  cd.append([c,d])

for a, b in ab:
  distance = [abs(a-c) + abs(b-d) for c,d in cd]
  print(distance.index(min(distance))+1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split()) 
ab = []
for i in range(n):
  a, b = map(int, input().split()) 
  ab.append([a,b])

cd = []  
for i in range(n):
  c, d = map(int, input().split()) 
  cd.append([c,d])

distance = []
for a, b in ab:
  for c, d in cd:
    distance.append(abs(a-c)+abs(b-d))
  print(distance.index(min(distance))+1)
  distance.clear()

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split()) 
ab = []
for i in range(n):
  a, b = map(int, input().split()) 
  ab.append([a,b])

cd = []  
for i in range(n):
  c, d = map(int, input().split()) 
  cd.append([c,d])

d = {}
for i in range(len(ab)):
  for j in range(len(cd)):
    d[j+1] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
  print(min(d, key=d.get))
Problem p02571 (python)

Fixed submission:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
s = input()
t = input()
min_count = 1000
for i in range(len(s) - len(t) + 1):
    count = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            count += 1
    min_count = min(count, min_count)
    if min_count == 0:
        break
print(min_count)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding: utf-8 -*-
s = input()
t = input()
min_count = 1000
for i in range(len(s) - len(t) + ):
    count = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            count += 1
    min_count = min(count, min_count)
    if min_count == 0:
        break
print(min_count)
Problem p02753 (python)

Fixed submission:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = input()
if n == "AAA" or n == "BBB":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = input()
if n == "aaa" or  == "bbb":
    print("No")
else:
    print("Yes")
Problem p03038 (python)

Fixed submission:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
b_c_hash = {}
c_list = []
for i in range(0,m):
    b, c = map(int, input().split())
    if c in b_c_hash:
        b_c_hash[c] += b
    else:
        b_c_hash[c] = b
        c_list.append(c)
c_list.sort(reverse=True)
k = 0
flag = 0
for c in c_list:
    for i in range(0, b_c_hash[c]):
        if k == n:
            flag = 1
            break
        if a[k] < c:
            a[k] = c
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break
print(sum(a))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
b_c_hash = {}
c_list = []
for i in range(0,m):
    b, c = map(int, input().split())
    if c in b_c_hash:
        b_c_hash[c] += b
    else:
        b_c_hash[c] = b
        c_list.append(c)
c_list.sort(reverse=True)
k = 0
flag = 0
for c in c_list:
    for i in range(0, b_c_hash[c]):
        if a[k] < c:
            a[k] = c
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break
print(sum(a))
Problem p02707 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
for j in cnt:
    print(j)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a = a.sort()
for i in range(1,n+1):
    print(a.count(i))
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if max(a,b,c,d,e) - min(a,b,c,d,e) > k:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if max(a,b,c,d,e) - min(a,b,c,d,e) > k:
    print(":(")
else:
    print("Yay!"）
Problem p03315 (python)

Fixed submission:
s = input()
print (s.count("+") - s.count("-"))

Buggy submission (verdict: Runtime Error):
s = raw_input()
print (s.count("+") - s.count("-"))
Problem p03834 (python)

Fixed submission:
s = input()
print(s[:5]+' '+s[6:13]+' '+s[14:])

Buggy submission (verdict: Runtime Error):
s = input()
print(s[:5]+' '+s[6:13]+' '+a[14:])

Buggy submission (verdict: Runtime Error):
s = input()
print(s[:5]+' '+s[6:13]+' '+a[14:])
Problem p02622 (python)

Fixed submission:
S = input()
T = input()
aa = 0
for i in range(len(S)):
  if S[i] != T[i]:
    aa += 1
print(aa)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
aa = 0
for i in range(length(S)):
  if S[i] != T[i]:
    aa += 1
print(aa)
Problem p02779 (python)

Fixed submission:
import sys
N = int(input())
cc = list(map(int,input().split()))
dic = set()
for i in cc:
  if i in dic:
    print('NO')
    sys.exit()
  else:
    dic.add(i)
print('YES')

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
cc = list(map(int,input().split()))
dic = set()
for i in cc:
  if i in dic:
    print('NO')
    sys.exit()
  else:
    dic.append(i)
print('YES')
Problem p02880 (python)

Fixed submission:
N = int(input())
judge = 'No'
for i in range(1,10):
  for j in range(1,10):
    if i * j == N:
      judge = 'Yes'
      break
  else:
    continue
  break
print(judge)

Buggy submission (verdict: Runtime Error):
N = int(input())
judge = 'No'
for i in range(1:10):
  for j in range(1:10):
    if i * j == N:
      judge = 'Yes'
      break
    else:
      continue
  break
print(judge)
Problem p02771 (python)

Fixed submission:
a,b,c = map(int, input().split())
count = 0
if a == b:
  count = count + 1
if b == c:
  count = count + 1
if c == a:
  count = count + 1
if count != 1:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if b / a == 1 and c / a == 1:
  print("No")
else:
  print("Yes)
Problem p02831 (python)

Fixed submission:
import fractions
a,b = map(int,input().split())
print(a*b//fractions.gcd(a,b))

Buggy submission (verdict: Runtime Error):
from math import gcd
a,b = map(int,input().split())
print(a*b//gcd(a,b))
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
dum1,dum2 = divmod(n,2)
flag = "ok"
if dum2 != 0:
  print("No")
else:
  for i in range(dum1):
    if s[i] != s[i+dum1]:
      flag = "ng"
      break
  if flag == "ng":
    print("No")
  else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
dum1,dum2 = divmod(n,2)
flag = "ok"
if dum2 != 0:
  print("No")
else:
  for i in range(dum1):
    if s[i] != s[i+3]:
      flag = "ng"
      break
  if flag == "ng":
    print("No")
  else:
    print("Yes")
Problem p03042 (python)

Fixed submission:
s = input()
a = int(s[0:2])
b = int(s[2:4])
if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif (a == 0 or a > 12) and 0 < b <= 12:
    print("YYMM")
elif (b == 0 or b > 12) and 0 < a <= 12:
    print("MMYY")
else:
    print("NA")

Buggy submission (verdict: Runtime Error):
s = input()
a = int(s[0:2])
b = int(s[2:4])
if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif (a > 12 and b > 12) or a == 0 or b == 0:
    print("NA")
elif a > 12:
    print("YYMM")
elif b > 12
    print("MMYY")
Problem p03107 (python)

Fixed submission:
n_list = list(input())
n_len_o = len(n_list)
a = 0
while(1):
  flag = "ng"
  n_len = len(n_list)
  for i in range(a,n_len-1):
    if n_list[i] != n_list[i+1]:
      n_list.pop(i)
      n_list.pop(i)
      if i != 0:
        a = i - 1
      else:
        a = 0
      flag = "ok"
      break
  if flag == "ng":
    break
print(n_len_o-len(n_list))

Buggy submission (verdict: Runtime Error):
n_list = list(input())
n_len_o = len(n_list)
#print(n_list)
a = 0
while(1):
  flag = "ng"
  n_len = len(n_list)
  for i in range(a,n_len-1):
    if n_list[i] != n_list[i+1]:
      n_list.pop(i,i+1)
      if a != 0:
        a = i - 1
      flag = "ok"
      break
  if flag == "ng":
    break
print(n_len_o-len(n_list))

Buggy submission (verdict: Runtime Error):
n_list = list(input())
n_len_o = len(n_list)
#print(n_list)
a = 0
while(1):
  flag = "ng"
  n_len = len(n_list)
  for i in range(a,n_len-1):
    if n_list[i] != n_list[i+1]:
      n_list.pop(i)
      n_list.pop(i)
      a = i - 1
      flag = "ok"
      break
  if flag == "ng":
    break
#print(n_list)
print(n_len_o-len(n_list))
Problem p03307 (python)

Fixed submission:
import fractions
a = int(input())
num = fractions.gcd(2,a)
print(a*2//num)

Buggy submission (verdict: Runtime Error):
import math
a = int(input())
num = math.gcd(2,a)
print(a*2/num)
Problem p02753 (python)

Fixed submission:
s=input()
if s[0]==s[1]==s[2]:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
flag=True
for i in range(10**6):
    if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
        print(i)
        flag=False
        exit()
if flag:
    print(-1)
Problem p02754 (python)

Fixed submission:
n,a,b=map(int,input().split())
if a==0:
    print(0)
elif n%(a+b)<a:
    print((n//(a+b))*a+n%(a+b))
elif a<n%(a+b):
    print((n//(a+b))*a+a)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
if a==0:
    print(0)
elif len("b"*a+"r"*b)==n:
    print(a)
elif len("b"*a+"r"*b)<n:
    print((n-len("b"*a+"r"*b))+a)
Problem p02766 (python)

Fixed submission:
a,b=map(int,input().split())
cnt=0
while a>0:
  a//=b
  cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
cnt=0
while a>0:
  a//=b
  cnt+=1
print(x)
Problem p02819 (python)

Fixed submission:
def prime(n):
    for i in range(2,n):
        if n%i==0:
            False
            return
    return True

n=int(input())

i=0
while True:
    if prime(n+i):
        print(n+i)
        exit()
    else:
        i+=1

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

x=0
for i in range(n):
    if a[i]!=0:
        x+=1
a=sum(a)

print(a//x if a%x==0 else a//x+1)

Buggy submission (verdict: Runtime Error):
import fractions

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

a,b=map(int,input().split())
print(lcm(a,b))
Problem p02831 (python)

Fixed submission:
import fractions

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

a,b=map(int,input().split())
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math

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

a,b=map(int,input().split())
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

a,b=map(int,input().split())
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

a,b=map(int,input().split())
print(lcm(a,b))
Problem p02550 (python)

Fixed submission:
N, X, M = map(int, input().split())
table = [0]*(M+1)

pre = X
table[pre] = 0
seq = [pre]
cnt = 0
while True:
    cnt += 1
    A = pre**2%M
    if not table[A]:
        seq.append(A)
        table[A] = cnt
        pre = A
    else:
        f = table[A]
        s = cnt
        break
    
ans = 0
for i in range(f + (N-f)%(s-f)):
    ans += seq[i]
m = (N-f)//(s-f)
for i in range(f, s):
    ans += seq[i]*m

print(ans)

Buggy submission (verdict: Runtime Error):
N, X, M = map(int, input().split())
table = [0]*(M+1)

pre = X
table[pre] = 1
seq = [pre]
cnt = 0
while True:
    cnt += 1
    A = pre**2%M
    if not table[A]:
        seq.append(A)
        table[A] = cnt
        pre = A
    else:
        fir = table[A]
        sec = cnt
        break
    
ans = 0
for i in range(fir + (N-fir)%(sec-fir)):
    ans += seq[i]
mul = (N-fir)//(sec-fir)
for i in range(fir, sec):
    ans += seq[i]*mul

print(ans)

Buggy submission (verdict: Runtime Error):
N, X, M = map(int, input().split())
table = [0]*M

pre = X%M
table[pre] = 1
seq = [pre]
cnt = 0
while True:
    cnt += 1
    A = pre**2%M
    if not table[A]:
        seq.append(A)
        table[A] = cnt
        pre = A
    else:
        fir = table[A]
        sec = cnt
        break
    
ans = 0
for i in range(fir + (N-fir)%(sec-fir)):
    ans += seq[i]
mul = (N-fir)//(sec-fir)
for i in range(fir, sec):
    ans += seq[i]*mul

print(ans)

Buggy submission (verdict: Runtime Error):
N, X, M = map(int, input().split())
table = [0]*M

table[X] = 1
pre = X
seq = [X]
cnt = 0
while True:
    cnt += 1
    A = pre**2%M
    if not table[A]:
        seq.append(A)
        table[A] = cnt
        pre = A
    else:
        fir = table[A]
        sec = cnt
        break
    
ans = 0
for i in range(fir + (N-fir)%(sec-fir)):
    ans += seq[i]
mul = (N-fir)//(sec-fir)
for i in range(fir, sec):
    ans += seq[i]*mul

print(ans)
Problem p02759 (python)

Fixed submission:
n = int(input())

r = n // 2
a = n % 2
print(r + a)

Buggy submission (verdict: Runtime Error):
import sys

A = list(list(map(int, input().split())) for _ in range(3))
N = int(input())
num = list(int(input()) for _ in range(N))

for i in range(3):
    for j in range(3):
        if A[i][j] in num:
            A[i][j] = -1
            
if A[0][0] == -1 and A[0][1] == -1 and A[0][2] == -1:
    print("Yes")
    sys.exit()
elif A[1][0] == -1 and A[1][1] == -1 and A[1][2] == -1:
    print("Yes")
    sys.exit()
elif A[2][0] == -1 and A[2][1] == -1 and A[2][2] == -1:
    print("Yes")
    sys.exit()
elif A[0][0] == -1 and A[1][0] == -1 and A[2][0] == -1:
    print("Yes")
    sys.exit()
elif A[0][1] == -1 and A[1][1] == -1 and A[2][1] == -1:
    print("Yes")
    sys.exit()
elif A[0][2] == -1 and A[1][2] == -1 and A[2][2] == -1:
    print("Yes")
    sys.exit()
elif A[0][0] == -1 and A[1][1] == -1 and A[1][1] == -1:
    print("Yes")
    sys.exit()
elif A[0][2] == -1 and A[1][1] == -1 and A[2][0] == -1:
    print("Yes")
    sys.exit()
    
print("No")