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

Fixed submission:
n,a,b=map(int,input().split())
c=n//(a+b)
d=0
if a==0:
	print(0)
else:
	if n>=(a+b):
		if n-c*(a+b)<=a:
			d=a*c+n-c*(a+b)
			print(d)
		else:
			d=a*(c+1)
			print(d)
	else:
		if n>=a:
			print(a)
		else:
			print(n)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
c=0
d=0
if a==0:
	print(0)
else:
	if n>=(a+b):
		c=n//(a+b)
		d=a*c+n-c*(a+b)
		print(d)
	else:
		if n>=a:
			c=n//a
			ptint(a*c)
		else:
			print(n)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
c=0
d=0
if a==0:
	print(0)
else:
	if n>=(a+b):
		c=n//(a+b)
		d=a*c+n-c*(a+b)
		print(d)
	else:
		if n>=a:
			c=n//a
			ptint(a*c)
		else:
			print(a)
Problem p02773 (python)

Fixed submission:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
#s = {s():0 for _ in range(n)}

a = {}
for i in range(n):
	s = input()
	try:
		a[s] += 1
	except KeyError:
		a[s] = 1
b = sorted(a.items(),key = lambda x:x[0])

memo = max([i[1] for i in a.items()])
for i in b:
	"""print(i,"i")
	print(i[0],"i[0]")
	print(i[1],"i[1]")
	print(max(b)[0],"max(b)[0]")"""
	if i[1] == memo:
		print(i[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[str() for i in range(n)]
b=[]
for j in range(n):
  for k in range(n):
    if a[j]==a[k]:
      b=a[j]
b.sort()
print(b)
Problem p02779 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
for j in range(n-1):
	if a[j]<a[j+1]:
		pass
	else:
		print('NO')
		exit()
print('YES')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int() for i in input().split()]
b=0
for j in range(n):
  for k in range(n):
    if a[j]==a[k] and j!=k:
      b+=1
　　break
if b==0:
  print('YES')
else:
  print('NO')
Problem p02847 (python)

Fixed submission:
a=input()
if a=="SUN":
  print(7)
elif a=="MON":
  print(6)
elif a=="TUE":
  print(5)
elif a=="WED":
  print(4)
elif a=="THU":
  print(3)
elif a=="FRI":
  print(2)
elif a=="SAT":
  print(1)

Buggy submission (verdict: Runtime Error):
a=input()
if a==SUN:
  print(7)
elif a==MON:
  print(6)
elif a==TUE:
  print(5)
elif a==WED:
  print(4)
elif a==THU:
  print(3)
elif a==FRI:
  print(2)
elif a==SAT:
  print(1)
Problem p02860 (python)

Fixed submission:
N=int(input())
if N%2==1:
  print("No")
  #偶数なら不適
else:
  s=input()
  b=N//2
  t=0
  for i in range (0,b):
    if s[i]==s[i+b]:
      t=t
    else:
      t=t+1
  if t==0:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2==1:
  print(No)
  #偶数なら不適
else:
  s=input()
  b=N//2
  s=0
  for i in range (0,b):
    if s[i]==s[i+b]:
      s=s
    else:
      s=s+1
  if s==0:
    print(Yes)
  else:
    print(No)
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split()) 
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(a**(1/2))
m=a
for i in range (2,b+1):
  if a%i==0:
    m=i
c=a/m
print(int(m+c-2))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=0
for i in range (2,10):
  if N%i==0:
    if N/i<=9:
      a=a+1
if (a==0 and N>1):
  print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N=int(input())
a=0
for i in range (2,10):
  if N%i==0:
    if N/i<=9:
      a=a+1
if (a==0 and N>1):
  print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N=int(input())
a=0
for i in range (2,10):
  if N%i==0:
    if N/i<=9:
      a=a+1
if (a==0 and N>1):
  print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N=int(input())
a=0
for i in range (2,10):
  if N%i==0:
    if N/i<=9:
      a=a+1
if (a==0 and N>1):
  print("no")
else:
    print("yes")
print(a)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=0
for i in range (2,9):
  if N%i==0:
    if N/i<=9:
      a=a+1
if a==0 and N>1:
  print("no")
else:
    print("yes")
Problem p02989 (python)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
ans = arr[n//2] - arr[n//2-1]
print(ans)

Buggy submission (verdict: Runtime Error):
14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1
Problem p02572 (python)

Fixed submission:
num = int(input())
ar = list(map(int,input().split()))
mod = 10**9 + 7
somee = sum(ar)
ans = 0
for i in range(num):
    ans+=(somee-ar[i])*ar[i]
print((ans//2)%mod)

Buggy submission (verdict: Runtime Error):
num = int(input())
ar = list(map(int,input().split()))
mod = 10**9 + 7
somee = sum(arr)
ans = 0
for i in range(num):
    ans+=(somee-ar[i])*ar[i]
print((ans//2)%mod)
Problem p02594 (python)

Fixed submission:
x=int(input())
if x >=30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
X=input()
if X >=30:
    print("Yes")
else:
    print("No")
Problem p02676 (python)

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

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

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if (len(S) > K):
    print(S[:K]+"...")
else:
    print(S)
Problem p02570 (python)

Fixed submission:
d,t,s=map(int,input().split())
if s == 0:
    print("No")
elif d/s <= t :
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
d,t,s=map(int,input()).split())
if s == 0:
    print("No")
elif d/s => t :
    print("Yes")
else:
    print("No")
Problem p02933 (python)

Fixed submission:
a=int(input())
s=str(input())
if a>=3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
a=int(input())
s=str(input())
if a=>3200:
  print(s)
else:
  print("red")
Problem p02935 (python)

Fixed submission:
N = int(input())
List = [] * N
List = input().split(" ")
for i in range(N):
    List[i] = float(List[i]) 
List.sort()
for i in range(N-1):
    List[i+1] = ( List[i] + List[i+1] ) / 2
print(List[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
List = [] * N
List = input().split(" ")
List.sort()
for i in range(N-1):
    List[i+1] = (int(List[i]) + int(List[i+1]) / 2
print(List[N])

Buggy submission (verdict: Runtime Error):
N = int(input())
List = [] * N
List = input().split(" ")
List.sort()
for i in range(N-1):
    List[i+1] = (int(List[i]) + int(List[i+1]) / 2
print(List[N])
Problem p02572 (python)

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

DIV = 10**9+7
ans = 0
Asum = sum(A)
Asum_sq = Asum**2

for i in range(N):
	ans += A[i]**2

res = (Asum_sq-ans)//2
print(res%DIV)

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

N = int(input())
A = numpy.array(list(map(int, input().split())))

ans = 0

for i in range(N):
	ans = (ans +  A[i] * numpy.sum(A[i+1:N])) % (10**9+7)

print(ans)
Problem p02693 (python)

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

for i in range(A,B+1):
    if i % K ==0:
        print("OK")
        break
    if i == B:
        print("NG")
    else:
        i = i + 1

Buggy submission (verdict: Runtime Error):
A, B, N = map(int,input().split())
ans = []

if N >= 100000:
    for i in range(N-200,N+1): 
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
else:
    for i in range(N//2,N+1):
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
print(max(ans))

Buggy submission (verdict: Runtime Error):
A, B, N = map(int,input().split())
ans = []
for i in range(N//2,N+1):
    k = (A*i)//B - A*(i//B)
    ans.append(k)
    i = i + 1
    
print(max(ans))
Problem p02753 (python)

Fixed submission:
S =list(input())
if S[0] =="B" and S[1]=="B" and S[2]=="B":
    print("No")
elif S[0] =="A" and S[1]=="A" and S[2]=="A":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
rest = N-A-B
if A ==0:
    print(0)
elif N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<=A+B:
    print(A)
elif A>=N:
    print(N)

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
rest = N-A-B
if A ==0:
    print(0)
elif N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<=A+B:
    print(A)
Problem p02829 (python)

Fixed submission:
a=0
for i in range(2):
  a=a+int(input())
print(int(6-a))

Buggy submission (verdict: Runtime Error):
l=0
for i range (2):
  l=l+int(input())
print(6-l)

Buggy submission (verdict: Runtime Error):
l=0
l=l+int(input)
l=l+int(input)
print(6-l)

Buggy submission (verdict: Runtime Error):
l=0
for i in range(2):
    l=l+int(input)
print(6-l)
Problem p02970 (python)

Fixed submission:
l=list(map(int,input().rstrip().split()))
a=l[0]
b=l[1]
c=(2*b)+1
u=int(a/c)
if(a%c==0):
  print(u)
else:
  print(u+1)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().rstrip().split()))
a=l[0]
b=l[1]
c=(2*b)+1
u=int(a/c)
if(a%c==0):
  print(u)
else():
  print(u+1)
Problem p02571 (python)

Fixed submission:
s = input()
t = input()
ratio = []
cnt = 0
if len(s) == len(t):
    for i in range(len(t)):
        if s[i] == t[i]:
            cnt += 1
    ratio.append(cnt)
else:
    for k in range(len(s) - len(t)):
        for i in range(len(t)):
            if s[i + k] == t[i]:
                cnt += 1
        ratio.append(cnt)
        cnt = 0
res = len(t) - max(ratio)
print(res)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ratio = []
cnt = 0

for k in range(len(s) - len(t)):
    for i in range(len(t)):
        if s[i + k] == t[i]:
            cnt += 1
    ratio.append(cnt)
    cnt = 0
res = len(t) - max(ratio)
print(res)
Problem p02676 (python)

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

Buggy submission (verdict: Runtime Error):
    K = int(input())
    S = input()
    print(S[:K]+'...')
Problem p02785 (python)

Fixed submission:
N,K = map(int,input().split())
enemys = list(map(int,input().split()))
enemys = sorted(enemys,reverse = True)
if K >= N:
  print(0)
elif K == 0:
  print(sum(enemys))
else:  
  enemys = enemys[K:]
  print(sum(enemys))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
enemys = list(map(int,input().split()))
enemys = sorted(enemys,reversed = True)
if K >= len(enemys):
  print(0)
else:
  enemys = enemys[K+1:]
  print(sum(enemys))
Problem p02754 (python)

Fixed submission:
# coding: utf-8
# Your code here!
n,a,b = map(int,input().split())
c = a+b

count = int(n/c)*a+min(n%c,a)

print(count)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n,a,b = map(int,input().split())
c = a+b

count = int(n/c)*a+min(n%c,a)

print(count)# coding: utf-8
# Your code here!
n,a,b = map(int,input().split())
c = a+b

count = int(n/c)*a+min(n%c,a)

print(count)
Problem p02571 (python)

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

counters = []
for i in range(len(s) - len(t) + 1):
  part_of_s = s[i: i + len(t)]
  counter = 0
  for sss, ttt in zip(part_of_s, t):
    if sss != ttt:
      counter += 1
  counters.append(counter)
print(min(counters))

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

counters = []
for i in range(len(s) - len(t)):
  part_of_s = s[i: i + len(t)]
  counter = 0
  for sss, ttt in zip(part_of_s, t):
    if sss != ttt:
      counter += 1
  counters.append(counter)
print(min(counters))
Problem p02847 (python)

Fixed submission:
s = input()
 
if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)
elif s == 'SAT':
  print(1)

Buggy submission (verdict: Runtime Error):
 input()
 
if s == 'SUN':
  print(0)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)
elif s == 'SAT':
  print(1)
else:
  pass
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()

s_length = len(s)

if s[: s_length // 2] == s[s_length // 2:]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = int(input())

s_length = len(s)

if s[: s_length // 2] == s[s_length // 2]:
  print('Yes')
else:
  print('No')
Problem p02989 (python)

Fixed submission:
n = int(input())

ds = list(map(int, input().split()))
ds.sort()

max_abc = ds[int(n/2 - 1)]
min_arc = ds[int(n/2)]

print(min_arc - max_abc)

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

ds = list(map(int, input().split()))
ds.sort()

max_abc = ds[n/2 - 1]
min_arc = ds[n_2]

print(max_abc - min_arc)
Problem p03011 (python)

Fixed submission:
p, q, r = map(int, input().split())

print(p + q + r - max(p, q, r))

Buggy submission (verdict: Runtime Error):
import sys
n, m = map(int, input().split())

if m > 0:
  As = set(map(int, sys.stdin))
else:
  As = set()

nums = [0] * (n + 1)
nums[0] = 1
if 1 in As:
  pass
else:
  nums[1] = 1
  
for i in range(2, n + 1):
  if i in As:
    continue
  else:
    nums[i] = (nums[i-1] + nums[i-2]) % 1000000007
    
print(nums[-1])

Buggy submission (verdict: Runtime Error):
p, q, r = map(int, input().split())

print(p + q + r - map(p, q, r))
Problem p03012 (python)

Fixed submission:
n = int(input())

nums = list(map(int, input().split()))
sums = [nums[0]]
for i in range(1, n):
  sums.append(sums[i-1] + nums[i])
  
min_diff = 100
index = 0
for sum in sums:
  if abs(sum - (sums[-1] - sum)) < min_diff:
    min_diff = abs(sum - (sums[-1] - sum))
    
print(min_diff)

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

nums = list(map(int, input().split()))
sums = [nums[0]]
for i in range(1, n):
  sums.append(sums[i-1] + nums[i])
  
min_diff = 100
index = 0
for sum in sums:
  if sum - (sum[-1] - sum) < min_diff:
    min_diff = sum - (sum[-1] - sum)
    
print(min_diff)
Problem p03038 (python)

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

As = list(map(int, input().split()))
As.sort()

BCs = []
for _ in range(M):
  b, c = tuple(map(int, input().split()))
  BCs.append((b, c))
BCs.sort(key=lambda x: x[1], reverse=True)
  
num = 0
i = 0
for b, c in BCs:
  for j in range(b):
    a = As[i]
    
    if a >= c:
      break
    else:
      num += c
      i += 1
      
    if i == len(As):
      break
      
  if a >= c or i == len(As):
    break
num += sum(As[i: ])
    
print(num)

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

As = list(map(int, input().split()))
As.sort()

BCs = []
for _ in range(M):
  b, c = tuple(map(int, input().split()))
  BCs.append((b, c))
BCs.sort(key=lambda x: x[1], reverse=True)
  
num = 0
i = 0
for b, c in BCs:
  for j in range(b):
    a = As[i]
    if a >= c or i == len(As):
      break
    else:
      num += c
      i += 1
  if a >= c or i == len(As):
    break
num += sum(As[i: ])
    
print(num)

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

As = list(map(int, input().split()))
As.sort()

BCs = []
for _ in range(M):
  b, c = tuple(map(int, input().split()))
  BCs.append((b, c))
BCs.sort(key=lambda x: x[1], reverse=True)
  
num = 0
i = 0
for b, c in BCs:
  for j in range(b):
    a = As[i]
    if a < c:
      num += c
      i += 1
    else:
      break
  if a >= c or i == len(As):
    break
num += sum(As[i: ])
    
print(num)

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

As = [int(x) for x in input().split(' ')]
As.sort()

Bs = []
Cs = []
for _ in range(M):
  b, c = [int(x) for x in input().split(' ')]
  Cs += [c for _ in range(b)]
if len(Cs) > N:
  Cs = Cs.sort(reverse=True)[: N+1]
else:
  Cs.sort()
  
num = 0
for i in range(len(Cs)):
  a = As[i]
  c = Cs[i]
  if a < c:
    num += c
  else:
    break
num += sum(As[i+1: ])
    
print(num)

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

As = [int(x) for x in input().split(' ')]
As.sort()

Bs = []
Cs = []
for _ in range(M):
  b, c = [int(x) for x in input().split(' ')]
  Cs += [c for _ in range(b)]
if len(Cs) > N:
  Cs = Cs.sort(reverse=True)[: N+1]
else:
  Cs.sort()
  
num = 0
for i in range(len(Cs)):
  a = As[i]
  c = Cs[i]
  if a < c:
    num += c
  else:
    break
num += sum(As[i+1: ])
    
print(num)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = [int(x) for x in input().split(' ')]

As = [int(x) for x in input().split(' ')]
As.sort()

Bs = []
Cs = []
for _ in range(M):
  b, c = [int(x) for x in input().split(' ')]
  Cs += [c for _ in range(b)]
if len(Cs) > N:
  Cs = Cs.sort(reverse=True)[: N+1]
else:
  Cs.sort()
  
num = 0
for i in range(len(Cs)):
  a = As[i]
  c = Cs[i]
  if a < c:
    num += c
  else:
    break
num += sum(As[i+1: ])
    
print(num)

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split(' ')]

as = [int(x) for x in input().split(' ')]
as.sort()

for _ in range(M):
  b, c = [int(x) for x in input().split(' ')]
  for i in range(b):
    if a[i] <= c:
      a[i] = c
    else:
      break
  as.sort()
  
print(sum(as))
Problem p02880 (python)

Fixed submission:
n=int(input())
z="No"
for i in range(1,10):
    if n%i==0 and n/i<=9:
        z="Yes"
print(z)

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i,j;
    cin>>n;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                cout<<"Yes";
            }
            
        }
    }
    cout<<"No";
    return 0;
}
Problem p02676 (python)

Fixed submission:
k = int(input())
n = input()
 
if len(n)<=k:
  print(n)
else:
  print(n[:k] + '...')

Buggy submission (verdict: Runtime Error):
k = int(input())
n = input()

if len(n)<=k:
  print(n)
  else:
    print(n[:k] + '...')
Problem p02571 (python)

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

count = []

for i in range(len(s)-len(t)+1):
    c=0
    for j in range(i,i+len(t)):
        if s[j] == t[j-i]:
            c+=1
    count.append(c)

# print(count)
print(len(t)-max(count))

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

count = []

for i in range(len(s)-len(t)):
    c=0
    for j in range(i,i+len(t)):
        if s[j] == t[j-i]:
            c+=1
    
    count.append(c)

print(len(t)-max(count))

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

count = []

for i in range(len(s)-len(t)):
    c=0
    for j in range(i,i+len(t)):
        if s[j] == t[j]:
            c+=1
    
    count.append(c)

print(len(t)-max(count))
Problem p02754 (python)

Fixed submission:
n, b, r = map(int, input().split())
div = n//(b+r)
base = b*div
zan = n%(b+r)
ama = min(zan, b)
print(base+ama)

Buggy submission (verdict: Runtime Error):
n, b, r = map(int, input().split())
bl = ["b"]*b
rl = ["r"]*r
br = bl + rl
ball = []
sav = n
while n>0:
  ball += br
  n -= (b+r)
print(ball[:sav].count("b"))
Problem p03077 (python)

Fixed submission:
import math

n = int(input())
t = [0] * 5
for i in range(5):
    t[i] = int(input())
print(math.ceil(n / min(t)) + 4)

Buggy submission (verdict: Runtime Error):
k, n = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
df = [0] * (n - 1)
for i in range(n - 1):
    df[i] = abs(x[i + 1] - x[i])

df = sorted(df, reverse=True)
print(sum(df[k - 1 :]))
Problem p03107 (python)

Fixed submission:
s = input()
zom = min(s.count("1"),s.count("0"))
if len(set(list(s))) == 1:
    zom = 0
print(zom*2)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys

input = sys.stdin.readline
b = deque(map(int, input()))
cnt = 0
i = 0
while len(b) > 1:

    if len(list(set(b))) == 1:
        break
    if b[i] != b[i + 1]:
        b.pop(i)
        b.pop(i)
        cnt += 1
        i = 0
        continue
    i += 1
print(cnt * 2)
Problem p02693 (python)

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

A_bai = int(A/K)
B_bai = int(B/K)

if A_bai != B_bai:
  print("OK")
elif (A%K == 0) or (B%K == 0):
  print("OK")
else:
  print("NG")

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

A_bai = int(A/K)
B_bai = int(B/K)

if A_bai != B_bai:
  print("OK")
else if (A%K == 0) || (B%K == 0):
  print("OK")
else:
  print("NG")
Problem p03291 (python)

Fixed submission:
S = input()
N = len(S)
MOD = 1000000007
dp = [[0]*4 for i in range(N+1)]
for i in range(N, -1, -1):
    for j in range(3, -1, -1):
        if i == N:
            dp[i][j] = 1 if j == 3 else 0
        else:
            dp[i][j] = dp[i+1][j] * (3 if S[i] == '?' else 1)
            if j < 3 and (S[i] == '?' or S[i] == "ABC"[j]):
                dp[i][j] += dp[i+1][j+1]
            dp[i][j] %= MOD
print(dp[0][0])

Buggy submission (verdict: Runtime Error):
while True:
    S = input()
    N = len(S)
    MOD = 1000000007
    dp = [[0]*4 for i in range(N+1)]
    for i in range(N, -1, -1):
        for j in range(3, -1, -1):
            if i == N:
                dp[i][j] = 1 if j == 3 else 0
            else:
                dp[i][j] = dp[i+1][j] * (3 if S[i] == '?' else 1)
                if j < 3 and (S[i] == '?' or S[i] == "ABC"[j]):
                    dp[i][j] += dp[i+1][j+1]
                dp[i][j] %= MOD
    print(dp[0][0])
Problem p02754 (python)

Fixed submission:
N, A, B = list(map(int, input().split()))
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))
#print(A*(N//(A+B)), min(A, N%(A+B)))
print(A*(N//(A+B)) + min(A, N%(A+B)))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = ''
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))

for i in range((N//(A+B))+1):
    S += 'b'*A
    S += 'r'*B
print(S[:N].count('b'))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = ''
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))

for i in range((N//(A+B))+1):
    S += 'b'*A
    S += 'r'*B
print(S[:N].count('b'))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = ''
print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))

for i in range((N//(A+B))+1):
    S += 'b'*A
    S += 'r'*B
print(S[:N].count('b'))
Problem p02860 (python)

Fixed submission:
number = int(input())
word = list(input())
judge = 'Yes'
            
if number%2 == 1:
	judge = 'No'
    
else:
	for i in range(int(number/2)):
		if word[i] != word[int(number/2 + i)]:
			judge = 'No'

print(judge)

Buggy submission (verdict: Runtime Error):
number = input(N)
word = list(input((S))
judge = 'Yes'
            
if N%2 == 1:
    print('No')
elif for i in range(N/2 - 1):
    if word[i] != word[N/2+i]:
        judge = 'No'

print(judge)

Buggy submission (verdict: Runtime Error):
number = input(N)
word = list(input((S))
judge = 'Yes'
            
if N%2 == 1:
    print('No')
elif for i in range(N/2):
    if word[i] != word[2i]:
        judge = 'No'

print(judge)
Problem p02578 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in range(1, n):
  if a[i] < a[i - 1]:
    ans += a[i - 1] - a[i]
    a[i] += (a[i - 1] - a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
ans = 0
for i in range(n):
  x = int(input())
  a.append(x)
for i in range(1, n):
  if a[i] < a[i - 1]:
    ans += a[i - 1] - a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input.split()]
ans = 0
for i in range(1, n):
  if a[i] < a[i - 1]:
    ans += a[i - 1] - a[i]
print(ans)
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r*r)

Buggy submission (verdict: Runtime Error):
listnum = int(input())
string = input()

halfnum = listnum // 2
halfstr = string[0:halfnum]
if string == halfstr + halfstr:
	print('Yes')
else:
	print('No')
Problem p02860 (python)

Fixed submission:
listnum = int(input())
string = input()

halfnum = listnum // 2
halfstr = string[0:halfnum]
if string == halfstr + halfstr:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
listnum = int(input())
string = input()

halfnum = listnum / 2
halfstr = string[0:halfnum]
if string == halfstr + halfstr:
	print('Yes')
else:
	print('No')