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

Fixed submission:



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

# counter
from collections import Counter
cntr = Counter(lst)

# combination
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

total = 0
# countSameNames
for value in cntr.values():
    if value > 1:
        total += combinations_count( value, 2 )


for l in lst:
    print(total - (cntr[l]-1))

Buggy submission (verdict: Runtime Error):
import collections
import copy
import math
from scipy.special import comb
from functools import lru_cache


n = int(input())
nums = [ int(s) for s in input().split() ]


@lru_cache(maxsize=1000)
def comb_count2(val):
    return comb(val, 2, exact=True)

for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += comb_count2(val)
    
    print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import copy
import math
from scipy.special import comb

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
nums = [ int(s) for s in input().split() ]


for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += comb(val, 2, exact=True)
    
    print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import copy
import math
import scipy.misc import comb

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
nums = [ int(s) for s in input().split() ]


for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += comb(val, 2, exact=True)
    
    print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import copy
import math
import scipy.special import comb

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
nums = [ int(s) for s in input().split() ]


for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += comb(val, 2, exact=True)
    
    print(ans)
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
ary = list(map(int, input().split()))


# ruisekiwa
ruiseki = [0] * (n+1)

for i, x in enumerate(ary):
    ruiseki[i+1] = ruiseki[i] + x

kmax = 0
for i in range(n+1-k):
    ksum = ruiseki[i+k] - ruiseki[i]
    kmax = max(kmax, ksum)

print((kmax+k) / 2)

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


dices = list(map(int, input().split()))

# 制約より
MAX_DICE = 1000*K

# 0-K番目を初期としてK個の値が最大になる範囲を探す
pos = 0
maxpos = pos
maxvalue = sum(dices[maxpos:maxpos+K])

for pos in range(1, N-K+1):
    if sum(dices[pos:pos+K]) > maxvalue):
        maxpos = pos
        maxvalue = sum(dices[pos:pos+K])

        # 上限
        if maxvalue == MAX_DICE:
            break

# 期待値を合計する
ans = 0
for dice in dices[maxpos:maxpos+K]:
    ans += (dice+1)/2


print(ans)
Problem p03067 (python)

Fixed submission:
x = input().split()
A = int(x[0])
B = int(x[1])
C = int(x[2])

if A < B:
    if C in range(A, B):
        print("Yes")
    else:
        print("No")
else:
    if C in range(B, A):
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(str(input()))
K = int(input())

SK = str(S[K])
for i in range(0,N):
    if S[i] == SK:
        pass
    else:
        S[i] = '*'
print(S, end="")
Problem p03068 (python)

Fixed submission:
N = int(input())
S = list(str(input()))
K = int(input())

SK = str(S[K-1])
for i in range(0,N):
    if S[i] == SK:
        pass
    else:
        S[i] = '*'
for j in S:
  print(j, end ="")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(str(input()))
K = int(input())

SK = str(S[K])
for i in range(0,N):
    if S[i] == SK:
        pass
    else:
        S[i] = '*'
print(S, end="")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(str(input()))
K = int(input())

SK = str(S[K])
for i in range(0,N):
    if S[i] == SK:
        pass
    else:
        S[i] = '*'
print(*S)
Problem p03071 (python)

Fixed submission:
a = input().split()
b = int(a[0])
c = int(a[1])
if b > c:
	first = b
	b = b-1
else:
	first = c
	c = c-1
if b > c:
	second = b
else:
	second = c
answer = first + second
print(str(answer))

Buggy submission (verdict: Runtime Error):
a = input().split()
b = int(d[0])
c = int(d[1])
if b > c:
	first = b
    b = b - 1
else:
	first = c
	c = c - 1
if b > c:
	second = b
else:
	second = c
answer = first + second
print(str(answer))
Problem p02630 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC=[list(map(int,input().split())) for _ in range(Q)]

cnt=[0]*(10**5+1)
for a in A:
  cnt[a]+=1
total=sum(A)
for b,c in BC:
  total+=(c-b)*cnt[b]
  cnt[c]+=cnt[b]
  cnt[b]=0
  print(total)

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

cnt=[0]*(10**5)
for a in A:
  cnt[a]+=1
total=sum(A)
for b,c in BC:
  total+=c*cnt[b]
  total-=b*cnt[b]
  cnt[c]+=cnt[b]
  cnt[b]=0
  print(total)
Problem p02797 (python)

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

A=[s]*k
for i in range(len(A),n):
  if s!=10**9:
    A.append(s+1)
  else:
    A.append(1)
print(*A)

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

A=[s]*k
for i in range(len(A),n):
  if s+1!+10**9:
    A.append(s+1)
  else:
    A.append(s-1)
print(*A)
Problem p02803 (python)

Fixed submission:
from collections import deque
h,w=map(int,input().split())
S=[input() for _ in range(h)]

ans=0
dxy=[(0,1),(1,0),(0,-1),(-1,0)]
for y in range(h):
  for x in range(w):
    if S[y][x]=='#': continue
    q=deque([(x,y)])
    dist=[[0]*w for _ in range(h)]
    visited=[[0]*w for _ in range(h)]
    visited[y][x]=1
    while q:
      x,y=q.popleft()
      for dx,dy in dxy:
        nx,ny=x+dx,y+dy
        if not 0<=nx<w: continue
        if not 0<=ny<h: continue
        if visited[ny][nx]: continue
        if S[ny][nx]=='#': continue
        visited[ny][nx]=1
        dist[ny][nx]=dist[y][x]+1
        q.append((nx,ny))
    ans = max(ans, max(max(row) for row in dist))
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
from queue import Queue
h,w=map(int,input().split())
S=[input() for _ in range(h)]

def bfs(q,memo):
  x,y,cnt=q.get()
  if x<0 or x>=w or y<0 or y>=h:
    return
  elif S[y][x]=='#':
    return
  elif memo[y][x]<0:
    memo[y][x]=cnt
    q.put([x-1,y,cnt+1])
    q.put([x+1,y,cnt+1])
    q.put([x,y-1,cnt+1])
    q.put([x,y+1,cnt+1])
    
ans=0
out=[]
def bbfs(x,y,ans):
  q=Queue()
  q.put([x,y,0])

  memo=[[-1]*w for _ in range(h)]
  while not q.empty():
    bfs(q,memo)
  if max(max(memo))>=ans:
    ans=max(max(memo))
    bbfs(x-1,y,ans)
    bbfs(x+1,y,ans)
    bbfs(x,y-1,ans)
    bbfs(x,y+1,ans)
    if ans!=None: out.append(ans)
    
bbfs(0,0,ans)
print(max(out))
Problem p02843 (python)

Fixed submission:
x=input()

if len(x)>=3:
  if int(x[-2:])%5==0:
    if int(x[:-2])-int(x[-2:])//5>=0:
      print(1)
    else:
      print(0)
  elif int(x[-2:])%4==0:
    if int(x[:-2])-int(x[-2:])//4>=0:
      print(1)
    else:
      print(0)
  elif int(x[-2:])%3==0:
    if int(x[:-2])-int(x[-2:])//3>=0:
      print(1)
    else:
      print(0)
  elif int(x[-2:])%2==0:
    if int(x[:-2])-int(x[-2:])//2>=0:
      print(1)
    else:
      print(0)
  elif int(x[-2:])%1==0:
    if int(x[:-2])-int(x[-2:])//1>=0:
      print(1)
    else:
      print(0)
  else:
    print(0)
else:
  print(0)

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

if int(x[-2:])%5==0:
  if int(x[:-2])-int(x[-2:])//5>=0:
    print(1)
  else:
    print(0)
elif int(x[-2:])%4==0:
  if int(x[:-2])-int(x[-2:])//4>=0:
    print(1)
  else:
    print(0)
elif int(x[-2:])%3==0:
  if int(x[:-2])-int(x[-2:])//3>=0:
    print(1)
  else:
    print(0)
elif int(x[-2:])%2==0:
  if int(x[:-2])-int(x[-2:])//2>=0:
    print(1)
  else:
    print(0)
elif int(x[-2:])%1==0:
  if int(x[:-2])-int(x[-2:])//1>=0:
    print(1)
  else:
    print(0)
else:
  print(0)
Problem p02845 (python)

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

mod=10**9+7
ans=1
cs=[0]*3
for a in A:
  c=cs.count(a)
  if c==0:
    print(0)
    exit()
  ans=(ans*c)%mod
  i=cs.index(a)
  cs[i]+=1
print(ans)

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

mod=10**9+7
ans=1
cs=[0]*3
for a in A:
  c=cs.count(a)
  ans=(ans*c)%mod
  i=cs.index(a)
  cs[i]+=1
print(ans)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
n=int(input())
AB=[list(map(int,input().split())) for _ in range(n-1)]

path=[[] for _ in range(n)]
for i,(a,b) in enumerate(AB):
  a,b=a-1,b-1
  path[a].append((b,i))
  path[b].append((a,i))
  
visited=[0]*n
ans=[None]*(n-1)
  
def dfs(v,c=-1):
  nc=1
  for to,i in path[v]:
    if visited[to]: continue
    visited[v]=1
    if nc==c: nc+=1
    ans[i]=nc
    dfs(to,nc)
    nc+=1
dfs(0)
print(max(ans))
print(*ans,sep='\n')

Buggy submission (verdict: Runtime Error):
n=int(input())
AB=[list(map(int,input().split())) for _ in range(n-1)]

path=[[] for _ in range(n)]
for i,(a,b) in enumerate(AB):
  a,b=a-1,b-1
  path[a].append((b,i))
  path[b].append((a,i))
  
visited=[0]*n
ans=[None]*(n-1)
  
def dfs(v,c=-1):
  nc=1
  for to,i in path[v]:
    if visited[to]: continue
    visited[v]=1
    if nc==c: nc+=1
    ans[i]=nc
    dfs(to,nc)
    nc+=1
dfs(0)
print(max(ans))
print(*ans,sep='\n')
Problem p02899 (python)

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

ans=[]
for i,a in enumerate(A):
  ans.append([i+1,a])
ans.sort(key=lambda x:x[1])
for a in ans:
  print(a[0],end=' ')

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

ans=[]
for i,a in enumerate(A):
  ans.append([i+1,a])
ans.sort(key=lambda x:x[a])
for a in ans:
  print(a[0],end=' ')
Problem p02909 (python)

Fixed submission:
S=input()

if S=='Sunny':
  print('Cloudy')
elif S=='Cloudy':
  print('Rainy')
elif S=='Rainy':
  print('Sunny')

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

if S=='Sunny':
  print('Cloudy')
elif S=='Cloudy':
  ptint('Rainy')
elif S=='Rainy':
  print('Sunny')
Problem p02921 (python)

Fixed submission:
S=input()
T=input()

ans=0
for i in range(3):
  if S[i]==T[i]:
    ans+=1
print(ans)

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

print(int((n-1)*n//2))
Problem p02972 (python)

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

ans=set()
for i in range(n-1,-1,-1):
  for j in range(i+1,n+1,i+1):
    if j in ans:
      A[i]+=1
  if A[i]%2:
    ans.add(i+1)
print(len(ans))
print(*ans)

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

ans=[]
balls=[0]*n
for i in range(n-1,-1,-1):
  if A[i]!=0:
    total=0
    for j in range(n-1,i,A[i]):
      total+=A[j]
    if total%2!=A[i]:
      if totaL+1!=A[i]:
        print(-1)
        exit()
      balls[i]+=1
      ans.append(i+1)
print(sum(balls))
print(*ans,sep=' ')
Problem p02988 (python)

Fixed submission:
N = [int(i) for i in input().split()][0]
P = [int(i) for i in input().split()]

count=0
for i in range(0,N-2):
  tmp = [P[i],P[i+1],P[i+2]]
  tmp.sort()
  if P[i+1]==tmp[1]:
    count+=1
  elif tmp[0]==tmp[1] or tmp[0]==tmp[2]:
    count+=1

print(count)

Buggy submission (verdict: Runtime Error):
N = [int(i) for i in input().split()][0]
P = [i for i in input().split()]

count=0
for i in range(0,N-2):
  tmp = [P[i],P[i+1],P[i+2]]
  tmp.sort()
  if P[i+1]==tmp[1]:
    count+=1
  if tmp[0]==tmp[1] or tmp[1]=tmp[2] or tmp[0]==tmp[2]:
    count+=1

print(count)
Problem p03029 (python)

Fixed submission:
A,P = [int(i) for i in input().split()]

print((A*3+P)//2)

Buggy submission (verdict: Runtime Error):
N = [int(i) for i in input().split()][0]

ls = []
for i in range(N):
  a,b = [i for i in input().split()]
  tmp = [str(a),int(b)]
  ls.append(tmp)

new_ls = sorted(ls, key=lambda x:x[1], reverse=True)
new_ls = sorted(new_ls, key=lambda x:x[0])

for next,l in enumerate(new_ls):
  for i,tmp in enumerate(ls):
    if l[0]==tmp[0] and l[1]==tmp[1]:
      print(i+1)
      continue

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

N = [int(i) for i in input().split()][0]

ls = []
for i in range(N):
  a,b = [i for i in input().split()]
  tmp = [str(a),int(b)]
  ls.append(tmp)

new_ls = sorted(ls, key=lambda x:x[1], reverse=True)
new_ls = sorted(new_ls, key=lambda x:x[0])

for next,l in enumerate(new_ls):
  for i,tmp in enumerate(ls):
    if l[0]==tmp[0] and l[1]==tmp[1]:
      print(i+1)
      continue
Problem p03074 (python)

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

T='0'+S+'0'
ans,cnt=0,0
for i,(a,b) in enumerate(zip(S,S[1:])):
  if a=='0' and b=='1':
    cnt+=1
  elif cnt==k and a=='1' and b=='0':
    ans=max(ans,i+1)
    break
else:
  print(n)
  exit()
  
S,cnt=S[::-1],0
for i,(a,b) in enumerate(zip(S,S[1:])):
  if a=='0' and b=='1':
    cnt+=1
  elif cnt==k and a=='1' and b=='0':
    ans=max(ans,i+1)
    break
else:
  print(n)
  exit()
  
x,y=[],[]
for i,(a,b) in enumerate(zip(T,T[1:])):
  if a==b: continue
  if a=='0':
    x.append(i)
  else:
    y.append(i)
for a,b in zip(x,y[k:]):
  ans=max(ans,b-a)
print(ans)

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

T='0'+S+'0'

ans,cnt=0,0
for i,(a,b) in enumerate(zip(S,S[1:])):
  if a=='0' and b=='1':
    cnt+=1
  elif cnt==k and a=='1' and b=='0':
    ans=max(ans,i+1)
    break
else:
  print(n)
  exit()
  
S,cnt=[::-1],0
for i,(a,b) in enumerate(zip(S,S[1:])):
  if a=='0' and b=='1':
    cnt+=1
  elif cnt==k and a=='1' and b=='0':
    ans=max(ans,i+1)
    break
else:
  print(n)
  exit()
  
x,y=[],[]
for i,(a,b) in enumerate(zip(T,T[1:])):
  if a==b: continue
  if a=='0':
    x.append(i)
  else:
    y.append(i)
for a,b in zip(x,y[k:]):
  ans=max(ans,b-a)
print(ans)
Problem p03162 (python)

Fixed submission:
n=int(input())
ABC=[list(map(int,input().split())) for _ in range(n)]

x,y,z=0,0,0
for a,b,c in ABC:
  x,y,z=max(y,z)+a,max(x,z)+b,max(x,y)+c
print(max(x,y,z))

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
ABC=[list(map(int,input().split())) for _ in range(n)]

dp=np.zeros((n,3),int)
for i in range(3):
  dp[0][i]=ABC[0][i]
for i in range(n-1):
  for j in range(3):
    dp[i+1][j]=max(dp[i][(j+1)%3]+ABC[i+1][j], dp[i][(j+2)%3]+ABC[i+1][j])
print(max(dp[-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
ABC=[list(map(int,input().split())) for _ in range(n)]

dp=np.zeros((n,3),int)
for i in range(n):
  for j in range(3):
    dp[i][j]=max(dp[i-1][(j+1)%3]+ABC[i][j], dp[i-1][(j+2)%3]+ABC[i][j])
print(max(dp[-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
ABC=[list(map(int,input().split())) for _ in range(n)]

dp=np.zeros((n,3),int)
for i in range(n):
  for j in range(3):
    dp[i][j]=max(dp[i-1][(j+1)%3]+ABC[i][j], dp[i-1][(j+2)%3]+ABC[i][j])
print(max(dp[-1]))
Problem p03164 (python)

Fixed submission:
import numpy as np
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for _ in range(N)]

dp=np.full(10**5+10,10**18,int)
dp[0]=0
for w,v in WV:
  np.minimum(dp[v:], dp[:-v].copy()+w, out=dp[v:])
print(np.where(dp<=W)[0][-1])

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

dp=[-1]*(W+1)
dp[0]=0
for i in range(N):
  w,v=WV[i]
  for j in range(W-w,-1,-1):
    if dp[j]!=-1:
      dp[j+w]=max(dp[j+w],dp[j]+v)
print(max(dp))
Problem p03244 (python)

Fixed submission:
from collections import Counter
n=int(input())
V=list(map(int,input().split()))

E=Counter(V[::2]).most_common() + [(0, 0)]
O=Counter(V[1::2]).most_common() + [(0, 0)]
if E[0][0]!=O[0][0]:
  print(n-E[0][1]-O[0][1])
else:
  print(n-max(E[1][1]+O[0][1],E[0][1]+O[1][1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
V=list(map(int,input().split()))
E=Counter(V[::2]).most_common()
O=Counter(V[1::2]).most_common()

E1=E[0][1]
O1=O[0][1]
if E[0][0]==O[0][0]:
  print(n//2)
elif E1==O1==n//2:
  print(0)
else:
  E2=E[1][1] if len(E)>1 else 0
  O2=O[1][1] if len(O)>1 else 0
  if E2!=0 and O2!=0:
    print(min(n//2-E2+n//2-O1,n//2-E1+n//2-O2))
  else:
    print(min(n//2-E2+n//2-O1,n//2-E1+n//2-O2))
Problem p03251 (python)

Fixed submission:
n,m,x,y=map(int,input().split())
xs=input().split()
ys=input().split()
xs=[int(i) for i in xs]
ys=[int(i) for i in ys]

xs.sort()
ys.sort()
flag=0
if xs[-1]<y:
  z=xs[-1]+1
  if z==x or z==y:
    pass
  elif ys[0]>=z:
      print('No War')
      flag=1
if flag==0:
  print('War')

Buggy submission (verdict: Runtime Error):
n,m,x,y=map(int,input().split())
xs=input().split()
ys=input().split()
xs=[int(i) for i in xs]
ys=[int(i) for i in ys]

xs.sort()
ys.sort()
flag=0
if xs[-1]<y:
  threshold=xs[-1]+1
if ys[0]>threshold:
    print('No War')
    flag=1
if flag==0:
  print('War')
Problem p03328 (python)

Fixed submission:
a,b=map(int,input().split())

print(int((b-a)*(b-a+1)/2-b))

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

tmp=0
for i in range(1,a):
  if tmp<a:
    tmp+=i
  else:
    break
print(tmp+i-b)
Problem p03436 (python)

Fixed submission:
from queue import Queue
h,w=map(int,input().split())
S=[list(input()) for _ in range(h)]

memo=[[-1]*w for _ in range(h)]
def bfs(q):
  x,y,cnt=q.get()
  if x<0 or x>=w or y<0 or y>=h:
    return
  elif S[y][x]=='#':
    return
  elif memo[y][x]<0:
    memo[y][x]=cnt
    q.put([x-1,y,cnt+1])
    q.put([x+1,y,cnt+1])
    q.put([x,y-1,cnt+1])
    q.put([x,y+1,cnt+1])

q=Queue()
q.put([0,0,0])
while not q.empty():
  bfs(q)
if memo[h-1][w-1]==-1:
  print(-1)
  exit()
cnt=0
for i in range(h):
  cnt+=S[i].count('.')
print(cnt-memo[h-1][w-1]-1)

Buggy submission (verdict: Runtime Error):
from queue import Queue
h,w=map(int,input().split())
S=[list(input()) for _ in range(h)]

memo=[[-1]*w for _ in range(h)]
def bfs(q):
  x,y,cnt=q.get()
  if x<0 or x>=w or y<0 or y>=h:
    return
  elif S[y][x]=='#':
    return
  elif memo[y][x]<0:
    memo[y][x]=cnt
    q.put([x-1,y,cnt+1])
    q.put([x+1,y,cnt+1])
    q.put([x,y-1,cnt+1])
    q.put([x,y+1,cnt+1])

q=Queue()
q.put([0,0,0])
while not q.empty():
  bfs(q)
if memo[y-1][x-1]==-1:
  print(-1)
  exit()
cnt=0
for i in range(h):
  cnt+=S[i].count('.')
print(cnt-memo[h-1][w-1]-1)
Problem p03447 (python)

Fixed submission:
inputs=[int(input()) for _ in range(3)]

val=inputs[0]-inputs[1]

syo=val//inputs[2]
print(val-(inputs[2]*syo))

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())

total,out=0,0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a*500+b*100+c*50 == 0:
        out+=1
        
print(out)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())

c=a*b
if c%2 == 0:
	print('Even')
else:
	print('Odd')

Buggy submission (verdict: Runtime Error):
tmp=input()
tmp=tmp.split('')
a,b=tmp[0],tmp[1]
c=a*b
if c%2 == 0:
	print('Even')
else:
	print('odd')
Problem p03475 (python)

Fixed submission:
n=int(input())
CSF=[list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
  ans=0
  for c,s,f in CSF[i:]:
    if ans<s:
      ans=s
    elif ans%f!=0:
      ans+=f-ans%f
    ans+=c
  print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
CSF=[list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
  ans=0
  for c,s,f in CSF[i:]:
    if ans<s:
      ans=s
    else:
      ans+=f-t%f
    ans+=c
  print(ans)
Problem p03493 (python)

Fixed submission:
s=input()
a,b,c=s[0],s[1],s[2]

print(int(a)+int(b)+int(c))

Buggy submission (verdict: Runtime Error):
N=int(input())
tmp=input()
tmp=tmp.split(' ')
a=[]
for i in range(N):
  a.append(int(tmp[i]))
  
if all(x % 2 == 0 for x in a) == False:
  print(0)
else:
  count=0
  while all(x % 2 == 0 for x in a) == True:
    a=[x/2 for x in a]
    count+=1
    
  print(count)

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

print(a+b+c)
Problem p03612 (python)

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

ans=0
for i in range(n-1):
  if P[i]==i+1:
    P[i],P[i+1]=P[i+1],P[i]
    ans+=1
if P[-1]==n:
  ans+=1
print(ans)

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

ans=0
if P[0]==1:
  P[0]=P[1]
  P[1]=1
  ans+=1
for i in range(1,n):
  if P[i]==i+1:
    if P[i+1]!=i+2:
      P[i]=P[i+1]
      P[i+1]=i+1
    else:
      P[i]=P[i-1]
      P[i-1]=i+1
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
P=list(map(int,input().split()))
ans=0
if P[0]==1:
  P[0]=P[1]
  P[1]=1
  ans+=1
while True:
  flag=True
  for i in range(1,n):
    if P[i]==i+1:
      if P[i+1]!=i+2:
        P[i]=P[i+1]
        P[i+1]=i+1
      else:
        P[i]=P[i-1]
        P[i-1]=i+1
      ans+=1
      flag=False
  if flag==True:
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
P=list(map(int,input().split()))
ans=0
if P[0]==1:
  P[0]=P[1]
  P[1]=1
  ans+=1
while True:
  flag=True
  for i in range(1,n):
    if P[i]==i+1:
      P[i]=P[i+1]
      P[i+1]=i+1
      ans+=1
      flag=False
  if flag==True:
    break
print(ans)
Problem p03626 (python)

Fixed submission:
n=int(input())
S1=input()
S2=input()

mod=1000000007
if n==1:
  ans=3
else:
  if S1[0]==S2[0]:
    ans,i=3,1
  else:
    ans,i=6,2
  while i<n:
    if S1[i]==S2[i]:
      ans *= 2%mod if S1[i-1]==S2[i-1] else 1%mod
      i+=1
    else:
      ans *= 2%mod if S1[i-1]==S2[i-1] else 3%mod
      i+=2
print(ans%(mod))

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

mod=1000000007
if n==1:
  print(3)
else:
  if S1[0]==S2[0]:
    ans,i=3,1
  else:
    ans,i=6,2
  while i<n:
    if S1[i]==S2[i]:
      ans *= 2%mod if S1[i-1]==S2[i-1] else 1%mod
      i+=1
    else:
      ans *= 2%mod if S1[i-1]==S2[i-1] else 3%mod
      i+=2
print(ans%(mod))

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

if n==1:
  print(3)
else:
  if S1[0]==S2[0]:
    ans,i=3,1
  else:
    ans,i=6,2
  while i<n:
    if S1[i]==S2[i]:
      ans *= 2 if S1[i-1]==S2[i-1] else 1
      i+=1
    else:
      ans *= 2 if S1[i-1]==S2[i-1] else 3
      i+=2
print(ans%(1000000007))
Problem p03696 (python)

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

l,cnt1=0,0
for s in S:
  if s=='(':
    cnt1+=1
  else:
    cnt1-=1
    l=min(l,cnt1)
r,cnt2=0,0
for s in S[::-1]:
  if s==')':
    cnt2+=1
  else:
    cnt2-=1
    r=min(r,cnt2)
print('('*-l+ S + ')'*-r)

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

i,cnt1=0,0
ins=[0]*(n+1)
while i<len(S):
  if S[i]=='(':
    cnt1+=1
    i+=1
  else:
    j,cnt2=0,0
    while i<len(S):
      if S[i]=='(':
        break
      else:
        cnt2+=1
      i+=1
      
    tmp=''
    if cnt2>cnt1:
      for _ in range(cnt2-cnt1):
        tmp+='('
      ins[i-(cnt1+cnt2)]=tmp
    elif cnt1>cnt2:
      for _ in range(cnt1-cnt2):
        tmp+=')'
      ins[i]=tmp
    cnt1,cnt2=0,0

if cnt1>0 and cnt2==0:
  tmp=''
  for _ in range(cnt1):
    tmp+=')'
  ins[-1]=tmp
for i,s in enumerate(ins):
  if s!=0:
    if i==0:
      S.insert(i,s)
    else:
      S.insert(i+1,s)
print(*S,sep='')
Problem p03828 (python)

Fixed submission:
import math
n=int(input())

mod=10**9+7
m=math.factorial(n)
ans=1
for i in range(2,n+1):
  tmp=1
  while m%i==0:
    m=m//i
    tmp+=1
  ans*=tmp
print(ans%mod)

Buggy submission (verdict: Runtime Error):
import math

n=int(input())
n=math.factorial(n)

divisors = []
for i in range(1, int(n**0.5)+1):
  if n % i == 0:
      divisors.append(i)
      if i != n // i:
          divisors.append(n//i)
print(len(divisors)%(10**9+7))