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

Fixed submission:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, x = LI()
    a = LI()

    # 隣り合う2つの和
    s = [a[i] + a[i+1] for i in range(N - 1)]
    # 隣り合う2つの和をx以下にしたもの
    s_after = [min(i, x) for i in s]

    # 隣り合う2つの和をx以下にしたものから元の数列を復元
    a_after = [0] * N
    a_after[0] = min(a[0], s_after[0])
    for i in range(N - 1):
        a_after[i+1] = min(s_after[i] - a_after[i], a[i+1])

    ans = sum(a) - sum(a_after)
    print(ans)

if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, x = LI()
    a = LI()

    s = [max(a[i] + a[i+1] - x, 0) for i in range(N - 1)]
    
    ans = sum([ss[i] for i in range(len(s)) if i % 2 == 0])
    print(ans)

if __name__ == '__main__':
    resolve()
Problem p02608 (python)

Fixed submission:
def resolve():
    n=int(input())
    a=[0]*(60000)
    nn=int(n**0.5)
    for x in range(1,nn):
        for y in range(1, nn):
            for z in range(1, nn):
                a[x**2+y**2+z**2+x*y+y*z+z*x]+=1
    for i in range(n):
        print(a[i+1])
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n=int(input())
    a=[0]*(10001)
    nn=int(n**0.5)
    for x in range(1,nn):
        for y in range(1, nn):
            for z in range(1, nn):
                a[x**2+y**2+z**2+x*y+y*z+z*x]+=1
    for i in range(n):
        print(a[i+1])
resolve()
Problem p02683 (python)

Fixed submission:
def resolve():

    n, m,x = map(int, input().split())
    c=[]
    a=[]
    ans=10**13
    nedan=0
    rikai=[0]*m
    for i in range(n):
        A = list(map(int, input().split()))
        c.append(A[0])
        a.append(A[1:])
        for j in range(m):
            rikai[j]+=a[i][j]

    if min(rikai)>=x:
        for Bin in range(1,2**n):
            rikai = [0] * m
            nedan = 0
            for hon in range(n):
                if (Bin>>hon) & 1:
                    for aru in range(m):
                        rikai[aru]+=a[hon][aru]
                    nedan+=c[hon]
            if min(rikai)>=x:
                ans=min(ans,nedan)
        print(ans)

    else:
        print(-1)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():

    n, m,x = map(int, input().split())
    c=[]
    a=[]
    ans=10**13
    nedan=0
    rikai=[0]*m
    for i in range(n):
        A = list(map(int, input().split()))
        c.append(A[0])
        a.append(A[1:])
        for j in range(m):
            rikai[j]+=a[i][j]
    if min(rikai)>=x:
        for Bin in range(2**n):
            N = [str(x) for x in list(str(bin(Bin+2**13)))]
            N.pop(0)
            N.pop(0)
            for hon in range(n):
                if N[hon + 1] == 1:
                    for aru in range(m):
                        rikai[aru]+=a[hon][aru]
                    nedan+=c[hon]
            if min(rikai)>=x:
                ans=min(ans,nedan)
            rikai=[]
            nedan=0
        print(ans)

    else:
        print(-1)
resolve()
Problem p03059 (python)

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

Buggy submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j,if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))

Buggy submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
for i in range(n)
t[i]=v[i]-c[i]
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)

Buggy submission (verdict: Runtime Error):
import numpy as np
n=input()
v=np.array(map(int, input().split()))
c=np.array(map(int, input().split()))
t=v-c
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)
Problem p03060 (python)

Fixed submission:
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))

Buggy submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=[i-j,if i-j>0 else 0 for i,j in zip(v,c)]
print(sum(t))

Buggy submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
for i in range(n)
t[i]=v[i]-c[i]
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)

Buggy submission (verdict: Runtime Error):
n=input()
v=list(map(int, input().split()))
c=list(map(int, input().split()))
t=v-c
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)

Buggy submission (verdict: Runtime Error):
import nmpy as np
n=input()
v=np.array(map(int, input().split()))
c=np.array(map(int, input().split()))
t=v-c
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)

Buggy submission (verdict: Runtime Error):
import nmpy as np
n=input()
v=np.array(map(int, input().split()))
c=np.array(map(int, input().split()))
t=v-c
a=0
for i in range(n)
if t[i]>0 :
a+=t[i]
print(a)
Problem p03071 (python)

Fixed submission:
a,b=map(int, input().split())
print(max(2*a-1,2*b-1,a+b))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  if a[i] <= a[i+1]:
    b=i+2
  else:
    print(b)
    exit()
Problem p03086 (python)

Fixed submission:
s=input()
a=0
b=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=max(a,b)
    a=0
print(max(a,b))

Buggy submission (verdict: Runtime Error):
s=input()
a,b=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=max(a,b)
    a=0
print(max(a,b))

Buggy submission (verdict: Runtime Error):
s=input()
a=0
for i in s:
  if i in "ATGC" :
    a+=1
  else:
    b=a
    a=0
print(max(a,b))

Buggy submission (verdict: Runtime Error):
s=input()
a=0
for i in s:
  if i in ATGC:
    a+=1
  else:
    b=a
    a=0
print(max(a,b))

Buggy submission (verdict: Runtime Error):
s=list(map(str,input().split()))
a=0
for i in s:
  if i in ATGC:
    a+=1
  else:
    b=a
    a=0
print(max(a,b))
Problem p03087 (python)

Fixed submission:
n, q = map(int, input().split())
s=input()
d=[0]*n
c=0
for i in range(n-1):
  if s[i:i+2]=="AC":
    c+=1
  d[i+1]=c
for i in range(q):
  l,r= map(int, input().split())
  print(d[r-1]-d[l-1])

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s=input()
for i in range(n):
  l[i],r[i] = map(int, input().split())
  t[i]=s[l[i]:r[i]+1].count("AC")
  print(t(i))

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s=input()
for i in range(n):
  l[i],r[i] = map(int, input().split())
  t[i]=s[l[i]:r[i+1]].count("AC")
  print(t(i))
Problem p03106 (python)

Fixed submission:
a,b,k= map(int, input().split())
i=min(a,b)
j=0
while j!=k :
    if a%i==0 and b%i==0:
      j+=1
      if j==k:
        print(i)
        exit()
    i-=1

Buggy submission (verdict: Runtime Error):
a,b,k= map(int, input().split())
n=min(a,b)
m=[]
i=1
j=1
while n//2<m:
  if j=k:
    print(i)
    exit()
  else:
    i+=1
    if a%i==0 and b%i==0:
      j+=1
Problem p02573 (python)

Fixed submission:

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

par = [i for i in range(N)]

def find(x):
  if par[x] == x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]
    

def unite(x, y):
  x = find(x)
  y = find(y)
  if x > y:
    par[x] = y
    find(x)
  else:
    par[y] = x
    find(y)
if M > 0:  
  for i in range(M):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)
  
  ans = [0] * N
  Max = 0
  for i in range(N):
    find(i)
  for i in par:
    ans[i] += 1
  for i in ans:
    if i > Max:
      Max = i
  
  print(Max)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
import sys,os
import math
from fractions import Fraction 
from collections import defaultdict
from random import randint

# sys.stderr=open('err.txt','w')
# sys.stdout=open('output.txt','w')
# sys.stdin=open('input.txt','r')

def linput():
    return list(minput())

def minput():
    return map(int, sys.stdin.readline().strip().split())

###############################################################

def make_set(a,parent):
    parent[a]=a

def find_set(a,parent):
    if parent[a]==a:
        return a
    parent[a]=find_set(parent[a])
    return parent[a]

def union_set(a,b,parent):
    x=find_set(a)
    y=find_set(b)
    if x==y:
        return
    else:
        parent[y]=x

n,m=minput()
parent=[0]*n
for i in range(n):
    make_set(i,parent)
ans=0
for i in range(m):
    x,y=minput()
    if x>y:
        x,y=y,x
    x=x-1
    y=y-1
    union_set(x,y,parent)
# print(parent)
di = defaultdict(int)
for i in parent:
    di[i]+=1
# print(di)
for k,v in di.items():
    ans=max(ans,v)
print(ans)
Problem p02603 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
v = 1000
s = 0
for i in range(n - 1):
    if a[i] < a[i + 1]:
        s = v // a[i]
        v += (a[i + 1] - a[i]) * s
print(v)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = 1000
for i in range(n - 1):
    dp = [0] * 1000 * 200
    dp[0] = 0
    c = b
    for j in range(b + 1):
        dp[j + a[i]] = max(dp[j + a[i]], dp[j] + a[i + 1])
    for j in range(b + 1):
        c = max(c, dp[j] + b - j)
    b = c
print(b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = 1000
for i in range(n - 1):
    dp = [0] * 100000
    dp[0] = 0
    c = b
    for j in range(b + 1):
        dp[j + a[i]] = max(dp[j + a[i]], dp[j] + a[i + 1])
    for j in range(b + 1):
        c = max(c, dp[j] + b - j)
    b = c
print(b)
Problem p02660 (python)

Fixed submission:
def factorint(n):
    d = dict()
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            c = 0
            while n % i == 0:
                c += 1
                n /= i
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n = int(input())
c = 0
for i, j in factorint(n).items():
    for k in range(j):
        if n % i ** (k + 1) == 0:
            n = n / i ** (k + 1)
            c += 1
        else:
            break
print(c)

Buggy submission (verdict: Runtime Error):
import sympy
n = int(input())
c = 0
for i, j in sympy.factorint(n).items():
    for k in range(j):
        if n % i ** (k + 1) == 0:
            n = n / i ** (k + 1)
            c = c + 1
        else:
            break
print(c)
Problem p02700 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
print('Yes' if (a - 1) // d >= (c - 1) // b else 'No')

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
while a * c:
    c -= b
    a -= d
print('Yes' if a else 'No')
Problem p02741 (python)

Fixed submission:
a = int(input())
k = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(k[a-1])

Buggy submission (verdict: Runtime Error):
a = int(input())
k = [5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(k[a-1])
Problem p02582 (python)

Fixed submission:
weather = input()
rainyDay = weather.count('R')
if rainyDay < 2:
    print(rainyDay)
else:
    if weather[1] == 'R':
        print(rainyDay)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
temp = input()
return print(temp.count('R'))
Problem p02658 (python)

Fixed submission:
res = 1

A = int(input())
N = sorted([int(x) for x in input().split()])

for x in N:
    res *= x
    if res > pow(10, 18):
        res = -1
        break

print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
    A = sorted([int(i) for i in input().split()])
    res=1
    for x in A:
        res = res*x
        if res > 10 ** 18:
            res = -1
            break
    print(res)
Problem p03071 (python)

Fixed submission:
A,B = map(int,input().split())
if  A > B:
    print(2*A-1)
elif A == B:
    print(2*A)
else:
    print(2*B-1)

Buggy submission (verdict: Runtime Error):
N , K = map(int,input().split())
S = str(input())
T =[] #０と１の個数を並べていったリスト
m = 1
for i in range(N-1):
    if S[i] == S[i + 1]:
        m = m + 1
    else:
        T.append(m)
        m = 1
T.append(m)
n = len(T)

left_1 = []
left_0 = []
if S[0] == str(1):
    if K >= (len(T) // 2):
        ans = N
    else:
        if len(T) % 2 == 0:
            i = 0
            while 2*i + 2*K + 1 <= n:
                left_1.append(sum(T[2*i:2*i+2*K+2]))
            left_1.append(sum(T[n - 2*K :n]))
            ans = max(left_1)
        else:
            i = 0
            while 2*i + 2*K + 1 <= n:
                left_1.append(sum(T[2*i:2*i+2*K+2]))
            ans = max(left_1)

else: # if S[0] == 0:
    if n % 2 == 0: 
        if K >= (len(T) / 2):
            ans = N
        else:
            left_0.append(sum(T[0:2*K]))
            i = 0
            while 2*i + 2*K + 2 <= n:
                left_1.append(sum(T[2*i + 1:2*i + 2*K + 3]))
            ans = max(left_0)
    
    else:
        if K >= (len(T)//2 + 1):
            ans = N
        else:
            left_0.append(sum(T[0:2*K]))
            left_0.append(sum(T[n-2*K:n]))
            while 2*i + 2*K + 2 <= n:
                left_1.append(sum(T[2*i + 1:2*i + 2*K + 3]))
            ans = max(left_0)

print (ans)
Problem p03076 (python)

Fixed submission:
a = []
for i in range(5):
    a.append(int(input()))
b =[]
c = []
for i in range(5):
    b.append(int(a[i]))
for i in range(5):
    while b[i] > 10:
        b[i] = b[i] - 10
if min(b) == 10:
    ans = sum(a)
else:
    for i in range(5):
    	c.append(int(a[i]) +10 -int(b[i]))
    d = sum(c)
    mini = min(b)
    ans = d - 10 + mini
print(ans)

Buggy submission (verdict: Runtime Error):
a = []
for _ in range(5):
  a.append(int(input()))
b =[]
c = []
for i in range(5):
  b[i] = a[i]
for i in range(5):
  while b[i] > 10:
  	b[i] = b[i] - 10
  if min(b[i]) = 10:
    return sum(a)
  else:
    for i in range(5):
    	if b[i] = 10:
          c[i] = a[i]
        else:
          c[i] = a[i] +10 -b[i]
        d = sum(c)
        mini = min(b)
        ans = d - 10 + mini
        return ans
Problem p02642 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
key=max(A)+1 #最大値もrange(a,key,a)で計算させるため
B=[0]*key #0~Aの最大値までのlistを作成
for a in A:
    for b in range(a,key,a):
        B[b]+=1 #aの倍数を全てにBリストで1を足す
ans=0
for a in A:
    if B[a]==1: #自身しか倍数にならなかった物
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
key=max(A)+1 #最大値もrange(a,key,a)で計算させるため
B=[0]*key #0~Aの最大値までのlistを作成
for a in A:
    for b in range(a,key,a):
    B[b]+=1 #aの倍数を全てにBリストで1を足す
ans=0
for a in A:
    if B[a]==1: #自身しか倍数にならなかった物
    ans+=1
print(ans)
Problem p02705 (python)

Fixed submission:
R=int(input())
import math
print(2*math.pi*R)

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

import collections
c=collections.Counter(A)

for i in range(N):
    print(c[i+1])
Problem p02640 (python)

Fixed submission:
X, Y = map(int, input().split())

for i in range(X+1):
    if (2*i + 4*(X - i)) == Y:
        print("Yes")
        break
else:
    print("No")

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

for i in range(X+1):
    if 2*i +4(X - i) == Y:
        print("Yes")
    else:
        print("No")
Problem p02717 (python)

Fixed submission:
a, b, c = map(int, input().split())
#n=int(input())
#list_ = [input() for i in range(n)]
temp = a
a = b
b = temp
temp = a
a = c
c = temp

print(a,b,c)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a_list =  list(map(int, input().split()))
a_list.sort(reverse = True)
a_total = sum(a_list)
count = 0
for voted in a_list[:M]:
  if voted < (1/(4*M))*a_total:
    print("No")
    break
else:
  print("Yes")
Problem p02718 (python)

Fixed submission:
N, M = map(int, input().split())
a_list =  list(map(int, input().split()))
a_list.sort(reverse = True)
a_total = sum(a_list)
count = 0
for voted in a_list[:M]:
  if voted < (1/(4*M))*a_total:
    print("No")
    break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a_list =  list(map(int, input().split()))
a_total = sum(a_list)
ld = sorted(a_list, reverse = True)
for i in ld[:M]:
    if i < (1/(4*M))*a_total:
    	print("No")
        break
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a_list =  list(map(int, input().split()))
a_total = sum(a_list)
ld = sorted(a_list, reverse = True)
for i inld[:M]:
    i < (1/(4*M))*a_total:
        print("No")
else:
    print("Yes")
Problem p02927 (python)

Fixed submission:
# -*- coding: utf-8 -*-

# スペース区切りの整数の入力
m, d = map(int, input().split())
ans =0

for month in range(1, m+1):
    for i in range(22, d+1):
        d_list = list(str(i))
        d1   = int(d_list[1])
        d10 = int(d_list[0])
        if d1 < 2 or d10 < 2:
            continue
        if month == (d1 * d10):
            ans +=1

print(ans)

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

tentosu_f = 0
tentosu_l = 0

for i in range(len(A)):
    for j in range(i+1, len(A)):
        if A[i] > A[j]:
            tentosu_f += 1
          
for i in range(len(A)):
    for j in range(len(A)):
        if A[i] > A[j]:
            tentosu_l += 1
            
ans = int(tentosu_f * k) + int(k*(k-1) / 2 * tentosu_l)
print(ans%(10**9+7))
Problem p02928 (python)

Fixed submission:
mod = (10 ** 9) + 7
N, K = map(int, input().split())
A = list(map(int, input().split()))

ten_f = 0
ten_l = 0

for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            ten_f += 1

for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            ten_l += 1

ans = (ten_f * (K)) + ((K * ((K - 1)) // 2) * ten_l)
print(ans % mod)

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

tentosu_f = 0
tentosu_l = 0

for i in range(len(n)):
    for j in range(i+1, len(n)):
        if A[i] > A[j]:
            tentosu_f += 1

for i in range(n):
    for j range(n):
        if A[i] > A[j]:
            tentosu_l += 1
            
ans = ((tentosu_f * k) + ((k* (k-1)) / 2) * tentosu_l) % (10**9 + 7)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = input().split()
B = A*k
tentosu = 0

for i in range(len(B)):
    for j in range(len(B)):
        if j <i:
            continue
        if B[i] > B[j]:
            tentosu += 1
            
ans = tentosu % (10**9 + 7)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = input().split()
B = A*k
tentosu = 0

for i in range(len(B)):
    for j in range(len(B)):
        if j <i:
            continue
        if B[i] > B[j]:
            print(i," ", j)
            tentosu += 1
print(tentosu)
Problem p02555 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

target = readInt()
nums = [i for i in range(3,target+1)]

dp = [0] * (1+target)
for num in nums:
    if num <= target:
        dp[num] = 1
for i in range(target+1):
    for num in nums:
        if i - num > 0:
            dp[i] += dp[i-num]
print(dp[-1]%mod)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

target = readInt()
nums = [i for i in range(3,target+1)]

dp = [0] * (1+target)
for num in nums:
    if num <= target:
        dp[num] = 1
for i in range(target+1):
    for num in nums:
        if i - num > 0:
            dp[i] += dp[i-num]
print(dp[-1]%mod
Problem p02621 (python)

Fixed submission:
a = int(input())
ans = a + (a ** 2) + (a ** 3)
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
ans = a + (a ** 2) + (a ** 3)
print(ans)
Problem p02687 (python)

Fixed submission:
S = input()
if S == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):

if S == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
S = input()
if S == "ABC":
  print "ARC"
else:
  print "ABC"

Buggy submission (verdict: Runtime Error):
if S == "ABC":
  return "ARC"
else:
  return "ABC"
Problem p03106 (python)

Fixed submission:
a, b, k = [int(x) for x in input().split()]
al = set()
bl = set()
for i in range(1, a+1):
    if a%i == 0:
        al.add(i)
for i in range(1, b+1):
    if b%i == 0:
        bl.add(i)
kk = list(al & bl)
kk.sort(reverse=True)
print(kk[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = [int(x) for x in input().split()]
al = set()
for i in range(1, a):
    if a%i == 0:
        al.add(i)
bl = set()
for i in range(1, b):
    if b%i == 0:
        bl.add(i)
kk = list(al | bl)
print(kk[k-1])
Problem p03151 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
if sum(A) < sum(B):
    print(-1)
else:
    num, fix = 0, 0
    for i in range(N):
        if A[i] - B[i] <  0:
            num += 1
            fix += B[i] - A[i]
    if num != 0:
        ret = []
        for i in range(N):
            if A[i] - B[i] > 0:
                ret.append(A[i] - B[i])
        ret.sort(reverse=True)
        su = 0
        for i in range(len(ret)):
            su += ret[i]
            num += 1
            if su >= fix:
                break
    print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = input().split()
A = []
for i in range(N):
    A.append(int(a[i]))
b = input().split()
B = []
for i in range(N):
    B.append(int(b[i]))
if sum(A) < sum(B):
    print(-1)
else:
    num = 0
    fix = 0
    for i in range(N):
        if A[i] - B[i] <  0:
            num += 1
            fix += B[i] - A[i]
if num == 0:
    print(0)
else:
    ret = []
    for i in range(N):
        if A[i] - B[i] > 0:
            ret.append(A[i] - B[i])
        else:
            ret.append(0)
    ret.sort(reverse=True)
    su = 0
    for i in range(N):
        su += ret[i]
        num += 1
        if su >= fix:
            break
    print(num)
Problem p02555 (python)

Fixed submission:

def solve(S):
    dp = [0]*(2000+1)
    dp[0] = 1
    dp[3] = 1
    MOD = 10**9+7
    for n in range(4, S+1):
        answer = 0
        for c in range(3, n+1):
            #print(n, "c=%d"%c, dp[c])
            answer = (answer + dp[n-c]) % MOD
        dp[n] = answer % MOD
        #print(n, dp[n])
    return dp[S]
#solve(7)
print(solve(int(input())))

Buggy submission (verdict: Runtime Error):

def solve(S):
    dp = [0]*(S+1)
    dp[0] = 1
    dp[3] = 1
    MOD = 10**9+7
    for n in range(4, S+1):
        answer = 0
        for c in range(3, n+1):
            #print(n, "c=%d"%c, dp[c])
            answer = (answer + dp[n-c]) % MOD
        dp[n] = answer % MOD
        #print(n, dp[n])
    return dp[S]
#solve(7)
print(solve(int(input())))