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

Fixed submission:
from itertools import permutations
n,C=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(n)]
a=[[0]*C for _ in range(3)]
for i in range(n):
	for j in range(n):
		a[(i+j)%3][c[i][j]-1]+=1
ans=10**9
for v in permutations(range(C),3):
	tmp=0
	for i in range(3):
		for j in range(C):
			tmp+=a[i][j]*d[j][v[i]]
	ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
from  itertools import combinations
n,C=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(n)]
a=[[0]*C for _ in range(3)]
for i in range(n):
	for j in range(n):
		a[(i+j)%3][c[i][j]-1]+=1
ans=10**9
for v in combinations(range(C),3):
	tmp=0
	for i in range(3):
		for j in range(30):
			tmp+=a[i][j]*d[j][v[i]]
	ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
from  itertools import combinations
n,C=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(n)]
a=[[0]*C for _ in range(3)]
for i in range(n):
	for j in range(n):
		a[(i+j)%3][c[i][j]-1]+=1
ans=10**9
for v in combinations(range(C),3):
	tmp=0
	for i in range(3):
		for j in range(30):
			tmp+=a[i][j]*c[j][v[i]]
	ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
from  itertools import combinations
n,C=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(n)]
a=[[0]*C for _ in range(3)]
for i in range(n):
	for j in range(n):
		a[(i+j)%3][c[i][j]-1]+=1
ans=10**9
for v in combinations(C,3):
	tmp=0
	for i in range(3):
		for j in range(30):
			tmp+=a[i][j]*c[j][v[i]]
	ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
from  itertools import combinations
n,c=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(c)]
c=[list(map(int,input().split())) for _ in range(n)]
a=[[0]*c for _ in range(3)]
for i in range(n):
	for j in range(n):
		a[(i+j)%3][c[i][j]-1]+=1
ans=10**9
for v in combinations(c,3):
	tmp=0
	for i in range(3):
		for j in range(30):
			tmp+=a[i][j]*c[j][v[i]]
	ans=min(ans,tmp)
print(ans)
Problem p03369 (python)

Fixed submission:
print(700+input().count('o')*100)

Buggy submission (verdict: Runtime Error):
print(700+input.count('o')*100)
Problem p03393 (python)

Fixed submission:
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
a=[]
for i in range(25,-1,-1):
    for j in range(24-(25-i),-1,-1):
        if s[j]<s[i]:
            a.append(s[:j]+s[i])
print(min(a))

Buggy submission (verdict: Runtime Error):
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
for i in range(25):
    if s[i]>s[i+1]:
        k=i-1

a="z"
for i in range(k+2,26):
    if s[k+1]<s[i]:
        a=min(a,s[i])
print(s[:k]+a)

Buggy submission (verdict: Runtime Error):
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
for i in range(25):
    if s[i]>s[i+1]:
        k=i-1

a="z"
for i in range(k+2,26):
    if s[k]<s[i]:
        a=min(a,s[i])
print(s[:k]+a)

Buggy submission (verdict: Runtime Error):
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
for i in range(25):
    if s[i]>s[i+1]:
        k=i-1
        break
a="z"
for i in range(k+2,26):
    if s[k]<s[i]:
        a=min(a,s[i])
print(s[:k]+a)

Buggy submission (verdict: Runtime Error):
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
for i in range(26):
    if s[i]>s[i+1]:
        k=i-1
        break
a="z"
for i in range(k,26):
    if s[k]<s[i]:
        a=min(a,s[i])
print(s[:k]+a)
Problem p03394 (python)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n=int(input())
ans=[0]*n
k=0
i=2
while k<n-1:
    if i%2==0 or i%3==0:
        ans[k]=i
        k+=1
    i+=1
x=sum(ans)
ans[-1]=30000+x//6*6-x
while gcd(ans[-1],x)==1:
    ans[-1]-=6
print(*ans)

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

n=int(input())
ans=[0]*n
k=0
i=2
while k<n-1:
    if i%2==0 or i%3==0:
        ans[k]=i
        k+=1
    i+=1
x=sum(ans)
ans[-1]=30000+x//6*6-x
if ans[-1]
while gcd(ans[-1],x)==1:
    ans[-1]-=6
print(*ans)
Problem p03408 (python)

Fixed submission:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cnt=[0]*(len(s)+1)
for i in range(len(s)):
    cnt[i]=s.count(s[i])-t.count(s[i])
print(max(cnt))

Buggy submission (verdict: Runtime Error):
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cnt=[0]*(len(s)+1)
for i in range(len(s)):
    cnt[i]=s.count(s[i])-t.count(t[i])
print(max(cnt))
Problem p03438 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c,d=0,0
for i in range(n):
    if a[i]>b[i]:
        c+=a[i]-b[i]
    else:
        d+=(b[i]-a[i])//2
if d>=c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
k=0
for i in range(n):
    if a[i]<b[i]:
        p=b[i]-a[i]
        a[i]+=(p+1)//2*2
        while p>0 and k<n:
            if a[k]-b[k]>p:
                b[k]+=p
                p=0
            elif a[k]-b[k]>0:
                b[k]=a[k]
                p-=a[k]-b[k]
            k+=1
            # print(a,b,k,p,i)

# print(a,b)
if a==b and p==0:
    print("Yes")
else:
    print("No")
Problem p03450 (python)

Fixed submission:
# 解説みたよ
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, m = map(int, input().split())
es = [[] for i in range(n)]
l, r, d = [0] * m, [0] * m, [0] * m
for i in range(m):
    l[i], r[i], d[i] = map(int, input().split())
    l[i] -= 1
    r[i] -= 1
    es[l[i]].append((r[i], d[i]))
    es[r[i]].append((l[i], -d[i]))
INF = 1000000000000
value = [INF] * n


def dfs(v):
    for i, di in es[v]:
        if value[i] == INF:
            value[i] = value[v] + di
            dfs(i)


for i in range(n):
    if value[i] == INF:
        value[i] = 0
        dfs(i)

for i, j, k in zip(l, r, d):
    if value[j] - value[i] != k:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
# 解説みたよ
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
d = defaultdict(int)
n, m = map(int, input().split())
es = [[] for i in range(n)]
l, r, d = [0] * m, [0] * m, [0] * m
for i in range(m):
    l[i], r[i], d[i] = map(int, input().split())
    l[i] -= 1
    r[i] -= 1
    es[l[i]].append((r[i], d[i]))
    es[r[i]].append((l[i], -d[i]))
INF = 1000000000000
value = [INF] * n


def dfs(v):
    for i, d in es[v]:
        if value[i] == INF:
            value[i] = value[v] + d
            dfs(i)


for i in range(n):
    if value[i] == INF:
        value[i] = 0
        dfs(i)

for i, j, k in zip(l, r, d):
    if value[j] - value[i] != k:
        print("No")
        exit()
print("Yes")
Problem p03456 (python)

Fixed submission:
a,b=input().split()
x=int(a+b)
for i in range(1000):
  if i**2==x:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
a,b=input().split
x=int(a+b)
for i in range(1000):
  if i**2==x:
    print("Yes")
    exit()
print("No")
Problem p03494 (python)

Fixed submission:
import fractions as f
n=int(input())
c=list(map(int, input().split()))
for i in range(1,n):
    c[i]=f.gcd(c[i-1],c[i])
ans=0
while True:
    if c[n-1]/2==c[n-1]//2:
        ans+=1
        c[n-1]/=2
    else:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
c=list(map(int, input().split()))
print(np.gcd.reduce(c))

Buggy submission (verdict: Runtime Error):
import numpy as np
c=list(map(int, input().split()))
print(np.gcd.reduce(c))
Problem p03495 (python)

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

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=set(a)
print(max(0,len(a)-k)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=set(map(int,input().split()))
print(max(0,len(a)-k)
Problem p03523 (python)

Fixed submission:
s=input()
x="KIHBR"
no=[0]
for i in x:
    if not(i in s[no[-1]:]):
        print("NO")
        exit()
    else:
        no.append(s[no[-1]:].index(i)+no[-1])
no.append(len(s))
if no[1]>=2 or no[1]==1 and s[0]!="A" or no[2]-no[1]>=2 or no[3]-no[2]>=2 or no[4]-no[3]>=3 or no[4]-no[3]==2 and s[no[3]+1]!="A" or no[5]-no[4]>=3 or no[5]-no[4]==2 and s[no[4]+1]!="A" or no[6]-no[5]>=3 or no[6]-no[5]==2 and s[no[5]+1]!="A":
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
s=list(input())
a="AKIHABARA"
n=len(a)
m=len(s)
j=0
for i in range(n):
  if s[j]==a[i]:
    j+=1
  elif a[i]!='A':
    print('NO')
if m==j:
  print('YES')
else:
  print('NO')
Problem p03607 (python)

Fixed submission:
n=int(input())
a=sorted([int(input()) for _ in range(n)])
ans=0
k=1
for i in range(1,n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
ans+=k%2
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=sorted[int(input()) for _ in range(n)]
ans=0
k=1
for i in range(1,n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
if a[n-2]==a[n-1]:
  ans+=k%2
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=sorted[int(input()) for _ in range(n)]
ans=0
k=1
for i in range(n):
  if a[i]==a[i-1]:
    k+=1
  else:
    ans+=k%2
    k=1
if a[n-2]==a[n-1]:
  ans+=k%2
print(ans)

Buggy submission (verdict: Runtime Error):
print(len({int(input()) for i in int(input())}))

Buggy submission (verdict: Runtime Error):
print({int(input()) for i in int(input())})
Problem p03608 (python)

Fixed submission:
INF = 10**10
n,m,R = map(int,input().split())
r=list(map(int,input().split()))
for i in range(R):
    r[i]-=1
d = [[INF]*n for i in range(n)] 
# 入力
for i in range(m):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    d[a][b] = c
    d[b][a] = c # 無向グラフ
for i in range(n):
    d[i][i] = 0

def FW():
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
FW()
from itertools import permutations, combinations
ans=INF
for v in permutations(r):
    tmp=0
    for i in range(R-1):
        tmp+=d[v[i]][v[i+1]]
    ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
INF = 10**10
n,m,R = map(int,input().split())
r=list(map(int,input().split()))
d = [[INF]*n for i in range(n)] 
# 入力
for i in range(m):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    d[a][b] = c
    d[b][a] = c # 無向グラフ
for i in range(n):
    d[i][i] = 0

def FW():
    for i in range(n):
        for j in range(n):
            for k in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
FW()

from itertools import permutations, combinations

ans=10**10
for v in permutations(r):
    tmp=0
    for i in range(R-1):
        tmp+=d[v[i]][v[i+1]]
    ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
INF = 10**10
n,m,R = map(int,input().split())
r=list(map(int,input().split()))
d = [[INF]*n for i in range(n)] 
# 入力
for i in range(m):
    a,b,c = map(int,input().split())
    a,b = a-1, b-1
    d[a][b] = c
    d[b][a] = c # 無向グラフ
for i in range(n):
    d[i][i] = 0

def FW():
    for i in range(n):
        for j in range(n):
            for k in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
FW()

from itertools import permutations, combinations

ans=10**10
for v in permutations(r):
    tmp=0
    for i in range(R-1):
        tmp+=d[v[i]][v[i+1]]
    ans=min(ans,tmp)
print(ans)
Problem p03626 (python)

Fixed submission:
n = int(input())
s = input() + "@"
t = input() + "@"
mod = 10 ** 9 + 7

# 情報を1次元にして処理しやすくするぜ
# 縦で一致 True 横で一致 False
b = []
for i in range(n):
    if s[i] == s[i + 1]:
        continue
    b.append(s[i] == t[i])

# 処理するぜ
if b[0]:
    ans = 3
else:
    ans = 6

for i in range(1, len(b)):
    if b[i]:
        if b[i - 1]:
            ans *= 2
    else:
        if b[i - 1]:
            ans *= 2
        else:
            ans *= 3

print(ans % mod)

Buggy submission (verdict: Runtime Error):
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=1
cnt=0
i=0
while i<n-1 and cnt<2:
    if a[i]==a[i+1]:
        ans*=a[i]
        i+=2
        cnt+=1
    else:
        i+=1
if cnt==2:
    print(ans)
else:
    print(0)
Problem p03633 (python)

Fixed submission:
import fractions as f
n=int(input())
ans=int(input())
for i in range(n-1):
   x=int(input())
   ans=x*ans//f.gcd(ans,x)
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions as f
n=int(input())
ans=int(input())
for i in range(n-1):
   ans=f.lcm(ans,int(input()))
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions as f
n=int(input())
ans=int(input())
for i in range(n):
   ans=f.lcm(ans,int(input()))
print(ans)
Problem p03635 (python)

Fixed submission:
m,n=map(int,input().split())
print((n-1)*(m-1))

Buggy submission (verdict: Runtime Error):
m,n=(int,input().split())
print((n-1)*(m-1))
Problem p03644 (python)

Fixed submission:
a=[2**i for i in range(8)]
import bisect
n=int(input())
s=bisect.bisect_left(a,n)
if n==a[s]:
    print(n)
    exit()
print(a[s-1])

Buggy submission (verdict: Runtime Error):
a=[2**i for i in range(7)]
import bisect
n=int(input())
s=bisect.bisect_left(a,n)
if n==a[s]:
    print(n)
    exit()
print(a[s-1])
Problem p03658 (python)

Fixed submission:
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
print(sum(l[:k]))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
print(sum(l[:k])
Problem p03681 (python)

Fixed submission:
def lam(x,mo):
	ans=1
	for i in range(1,x+1):
		ans*=i
		ans%=mo
	return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print(0)
	exit()
if n+1==m:
	print(lam(n,mod)*lam(m,mod)%mod)
else:
	print(2*(lam(n,mod)**2)%mod)

Buggy submission (verdict: Runtime Error):
def lam(x,mod):
  ans=1
  for i in range(1,x+1):
    ans*=i
    ans%=mod
  return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
  print(0)
  exit()
if n+1==m:
  print(lam(n,mod)*lam(m,mod)%mod)
else:
  print(2*(lam(n,mod)**2)

Buggy submission (verdict: Runtime Error):
def lam(x,mod):
	ans=1
	for i in range(1,x+1):
		ans*=i
        ans%=mod
	return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print(0)
	exit()
if n+1==m:
	print(lam(n,mod)*lam(m,mod)%mod)
else:
	print(2*(lam(n,mod)**2)

Buggy submission (verdict: Runtime Error):
def lam(x,mod):
	ans=1
	for i in range(1,x+1):
		ans*=i
        ans%=mod
	return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print(0)
	exit()
if n+1==m:
	print(lam(n,mod)*lam(m,mod)%mod)
else:
	print(2*(lam(n,mod)**2)%mod)

Buggy submission (verdict: Runtime Error):
def lam(x,mod):
	ans=1
	for i in range(1,x+1):
		ans*=i
        ans%=mod
	return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print(0)
	exit()
if n+1==m:
	print(lam(n,mod)*lam(m,mod)%mod)
else:
	print(2*lam(n,mod)**2%mod)

Buggy submission (verdict: Runtime Error):
def lam(x,mod):
	ans=1
	for i in range(1,x+1):
		ans*=i
        ans%=mod
	return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print(0)
	exit()
if n+1==m:
	print(lam(n,mod)*lam(m,mod)%mod)
else:
	print(2*lam(n,mod)**2%mod)

Buggy submission (verdict: Runtime Error):
def lam(x):
	ans=1
	for i in range(1,x+1):
		ans*=i
        ans%=mod
	return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print(0)
	exit()
if n+1==m:
	print(lam(n)*lam(m)%mod)
else:
	print(2*lam(n)**2%mod)
Problem p03698 (python)

Fixed submission:
s=input()
x={1}
for i in s:
  if i in x:
    print('no')
    exit()
  else:
    x.add(i)
print('yes')

Buggy submission (verdict: Runtime Error):
s=input()
x={}
for i in s:
  if i in x:
    print('no')
    exit()
  else:
    x.add(i)
print('yes')
Problem p03737 (python)

Fixed submission:
s1,s2,s3=input().split()
print(str.upper(s1[0]+s2[0]+s3[0]))

Buggy submission (verdict: Runtime Error):
s1,s2,s3=map(input().split())
print(s1[0]+s2[0]+s3[0])

Buggy submission (verdict: Runtime Error):
s1,s2,s3=map(int,input().split())
print(s1[0]+s2[0]+s3[0])
Problem p03739 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cost = (a[0] == 0)
c = a[0] + (a[0] == 0)
for i in a[1:]:
	if c > 0:
		if c + i >= 0:
			cost += c + i + 1
			c = -1
		else:
			c += i
	else:
		if c + i <= 0:
			cost += 1 - c - i
			c = 1
		else:
			c += i
tmp = cost
cost = 0
if a[0] >= 0:
	cost = a[0] + 1
	c = -1
else:
	cost = -a[0] + 1
	c = 1
for i in a[1:]:
	if c > 0:
		if c + i >= 0:
			cost += c + i + 1
			c = -1
		else:
			c += i
	else:
		if c + i <= 0:
			cost += 1 - c - i
			c = 1
		else:
			c += i
print(int(min(tmp, cost)))

Buggy submission (verdict: Runtime Error):
def f():
  for i in a[1:]:
    if c > 0:
      if c + i >= 0:
        cost += c + i + 1
        c = -1
      else:
        c += i
    else:
      if c + i <= 0:
        cost += 1 - c - i
        c = 1
      else:
        c += i


n = int(input())
a = list(map(int, input().split()))
cost = (a[0] == 0)
c = a[0] + (a[0] == 0)
f()
tmp = cost
cost = 0
if a[0] >= 0:
  cost = a[0] + 1
  c = -1
else:
  cost = -a[0] + 1
  c = 1
f()
print(min(cost, tmp))
Problem p03761 (python)

Fixed submission:
n=int(input())
s=[input() for i in range(n)]
dic={}
for i in range(n):
  for j in s[i]:
    if not(j in dic):
      dic[j]=[0 for i in range(n)]
    dic[j][i]+=1
ans=[]
for i in dic.keys():
  ans.append(i*min(dic[i]))
ans.sort()
print(*ans,sep='')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[input() for i in range(n)]
dic={}
for i in range(n):
  for j in s[i]:
    if not(j in dic[s[i]]):
      dic[j]=[0 for i in range(n)]
    dic[j][i]+=1
ans=[]
for i in dic.keys():
  ans.append(i*min(dic[i]))
ans.sort()
print(ans,sep='')
Problem p03796 (python)

Fixed submission:
n=int(input())
mod=10**9+7
ans=1
for i in range(1,n+1):
  ans=ans*i%mod
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
mod=10**9+7
for i in range(1,n+1):
  ans=ans*i%mod
print(ans)
Problem p03998 (python)

Fixed submission:
d={}
d['a']=list(input())
d['b']=list(input())
d['c']=list(input())
now='a'
while True:
  if len(d[now])>0:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()

Buggy submission (verdict: Runtime Error):
d={}
d['a']=list(input())
d['b']=list(input())
d['c']=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()

Buggy submission (verdict: Runtime Error):
d={}
d[a]=list(input())
d[b]=list(input())
d[c]=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(now.upper())
    exit()

Buggy submission (verdict: Runtime Error):
d={}
d[a]=list(input())
d[b]=list(input())
d[c]=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(upper(now))
    exit()

Buggy submission (verdict: Runtime Error):
d={}
d[a]=list(input())
d[b]=list(input())
d[c]=list(input())
now='a'
while True:
  if d[now]>1:
    now=d[now].pop(0)
  else:
    print(upper(now))
Problem p04013 (python)

Fixed submission:
n,a=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
    x[i]-=a
# dp[i][j] = i番目までで(j-2500)を何個作れるか
dp=[[0]*5001 for i in range(n)]
dp[0][x[0]+2500]=1
for i in range(1,n):
    dp[i][x[i]+2500]=1
    for j in range(5000):
        for k in range(2):
            if 0<=j-k*x[i]<=5000:
                dp[i][j]+=dp[i-1][j-k*x[i]]
print(dp[n-1][2500])

Buggy submission (verdict: Runtime Error):
n,a=map(int,input().split())
x=list(map(int,input().split()))
# dp[j][k][s]=(x1,...,xjからk枚選んでx[i]の合計をsにするような選び方の総数)
dp=[[[0]*2500 for i in range(51)] for j in range(51)]
dp[0][0][0]=1
for i in range(n):
    for j in range(n+1):
        for k in range(2500):
            if k<x[i]:
                dp[i+1][j][k]=dp[i][j][k]
            else:
                dp[i+1][j][k]=dp[i][j][k]+dp[i][j-1][k-x[i]]
ans=0
for i in range(1,n+1):
    ans+=dp[n][i][i*a]
print(ans)
Problem p02844 (python)

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

ans = 0
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            p1 = s.find(str(i))
            if p1 == -1:
                continue
            p2 = s.find(str(j),p1+1)
            if p2 == -1:
                continue
            if s.find(str(k),p2+1) != -1:
                ans += 1

print(ans)

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

ans = 0
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            p1 = s.find(str(i))
            if p1 == -1:
                continue
            p2 = s.find(str(j),start=p1+1)
            if p2 = -1:
                continue
            if s.find(str(k),start=p2+1) != -1:
                ans += 1

print(ans)
Problem p02911 (python)

Fixed submission:
n,k,q = map(int,input().split())
l = [0 for x in range(n)]
for _ in range(q):
    l[int(input())-1] += 1

ans = []
for i in l:
    if k- q + i > 0:
        ans.append("Yes")
    else:
        ans.append("No")
print("\n".join(ans))

Buggy submission (verdict: Runtime Error):
n,k,q = map(int,input().split())
l = [0 for x in range(n)]
for _ in range(q):
    l[int(input())] += 1

ans = []
for i in l:
    if k- q + i > 0:
        ans.append("Yes")
    else:
        ans.append("No")
print("\n".join(ans))
Problem p02936 (python)

Fixed submission:
n,q = map(int,input().split())
r = [[] for i in range(n+1)]
v = [0 for i in range(n+1)]

for i in range(n-1):
    a,b = map(int,input().split())
    r[a].append(b)

for i in range(q):
    p,x = map(int,input().split())
    v[p] += x


for i in range(1,n+1):

    for y in r[i]:
        v[y] += v[i]

print(" ".join(map(str,v[1:])))

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
r = [[] for i in range(n)]
v = [0 for i in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    r[a-1].append(b-1)

for i in range(q):
    p,x = map(int,input().split())
    v[p-1] += x


bfs = [0]
visit = [False in range(n)]
while len(bfs) != 0:
    tmp = []
    for i in bfs:
        for y in r[i]:
            if not visit[y]:
                v[y] += v[i]
                tmp.append(y)
        visit[i] = True
    bfs = tmp

#print(" ".join(map(str,v)))
print(*v)