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

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

A = []
B = []

for _ in range(M):
    a,b = map(int, input().split())
    if a == 1: A.append(b)
    elif b == N: B.append(a)

B.sort()
for a in A:
    if bisect.bisect_left(B, a) < len(B) and B[bisect.bisect_left(B, a)]==a:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

A = []
B = []

for _ in range(M):
    a,b = map(int, input().split())
    if a == 1: A.append(b)
    elif b == N: B.append(a)

B.sort()
if len(B) > 0 and len(A) > 0:
    for a in A:
        if B[bisect.bisect_left(B, a)]==a:
            print("POSSIBLE")
            exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

A = []
B = []

for _ in range(M):
    a,b = map(int, input().split())
    if a == 1: A.append(b)
    elif b == N: B.append(a)

B.sort()
if len(B) > 0:
    for a in A:
        if B[bisect.bisect_left(B, a)]==a:
            print("POSSIBLE")
            exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

A = []
B = []

for _ in range(M):
    a,b = map(int, input().split())
    if a == 1: A.append(b)
    elif b == N: B.append(a)

B.sort()
for a in A:
    if B[bisect.bisect_left(B, a)]==a:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
Problem p03761 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

N = int(input())
S = []
for _ in range(N):
    s = input()
    S.append(s)

cnt = [10000]*26
for s in S:
    for i in range(26):
        cnt[i] = min(cnt[i], s.count(chr(97+i)))

ans = ""
for i in range(26):
    if cnt[i] < 10000: ans += chr(97+i)*cnt[i]

print(ans)

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef char* String;

String string_input(void){
    int i,len;
    char buf[100];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    
    len=strlen(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    String* S;
    NEW(S,N);
    for(int i=0;i<N;i++){
        S[i]=string_input();
    }

    int* ans;
    NEW(ans,26);
    for(int i=0;i<26;i++) ans[i]=50;

    int* tmp;
    NEW(tmp,26);
    for(int i=0;i<N;i++){
        for(int j=0;j<26;j++) tmp[j]=0;

        for(int j=0;j<strlen(S[i]);j++){
            tmp[S[i][j]-'a']++;
        }

        for(int j=0;j<26;j++) ans[j]=MIN(ans[j],tmp[j]);
    }

    for(int i=0;i<26;i++){
        char c='a'+i;
        for(int j=1;j<=ans[i];j++) printf("%c",c);
    }
    printf("\n");

    return 0;
}
Problem p02928 (python)

Fixed submission:
#######################################
prime = 10**9+7

def sowa(num):
  return int((1+num)*num//2)
#######################################
n,k = map(int, input().split())
a = list(map(int, input().split()))

tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = (sum(tento1) *k %prime) + (sum(tento2) *(sowa(k-1) %prime) %prime)
print(int(ret%prime))

Buggy submission (verdict: Runtime Error):
#######################################
prime = 10**9+7

def sowa(num):
  return int((1+num)*num/2)
#######################################
n,k = map(int, input().split())
a = list(map(int, input().split()))

tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = (sum(tento1) *k %prime) + (sum(tento2) *(sowa(k-1) %prime) %prime)
print(int(ret%prime)))
Problem p02975 (python)

Fixed submission:
def xor(n1, n2):
  if n2=="0":
    return n1
  elif n2=="1":
    if n1=="1":
      return "0"
    else:
      return "1"
      
def bitxor(n1, n2):
 
  bn1 = bin(n1)[2:]
  bn2 = bin(n2)[2:]
  if n1<n2:
    bn1 = bn1.zfill(len(bn2))
  else:
    bn2 = bn2.zfill(len(bn1))
    
  n3 = [xor(b1,b2) for b1,b2 in zip(bn1, bn2)]
  n3 = "".join(n3)
  return int(n3, 2)
 
 
n = int(input())
a = [int(x) for x in input().split()]
a_unique = list(set(a))
la = len(a)
lau = len(a_unique)

if a_unique==[0]:
  print("Yes")

elif la%3==0 and (0 in a_unique):
  u0 = a.count(0)
  if u0*3!=la:
    print("No")
  else:
    a_unique.remove(0)
    tmp = [(a.count(ai)%2==0) for ai in a_unique]
    if len(tmp)==sum(tmp):
      print("Yes")
    else:
      print("No")

elif la%3==0 and lau==2 and (0 in a_unique):
  u0 = a.count(0)
  if a_unique[0]==0:
    num = a_unique[1]
  else:
    num = a_unique[0]
  u1 = a.count(num)
  if u0*2==u1:
    print("Yes")
elif la%3!=0 or lau!=3:
  print("No")
else:
  u0 = a.count(a_unique[0])
  u1 = a.count(a_unique[1])
  u2 = a.count(a_unique[2])
 
  if (a_unique[2]== bitxor(a_unique[0], a_unique[1])) and (u0==u1 and u1==u2):
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
def xor(n1, n2):
  if n2=="0":
    return n1
  elif n2=="1":
    if n1=="1":
      return "0"
    else:
      return "1"
      
def bitxor(n1, n2):

  bn1 = bin(n1)[2:]
  bn2 = bin(n2)[2:]
  if n1<n2:
    bn1 = bn1.zfill(len(bn2))
  else:
    bn2 = bn2.zfill(len(bn1))
    
  n3 = [xor(b1,b2) for b1,b2 in zip(bn1, bn2)]
  n3 = "".join(n3)
  return int(n3, 2)


n = int(input())
a = [int(x) for x in input().split()]
a_unique = list(set(a))
l = len(a)

u0 = a.count(a_unique[0])
u1 = a.count(a_unique[1])
u2 = a.count(a_unique[2])

if l%3==0 and (a_unique[2]== bitxor(a_unique[0], a_unique[1])) and (u0==u1 and u1==u2):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def xor(n1, n2):
  if n2=="0":
    return n1
  elif n2=="1":
    if n1=="1":
      return "0"
    else:
      return "1"
      
def bitxor(n1, n2):

  bn1 = bin(n1)[2:]
  bn2 = bin(n2)[2:]
  if n1<n2:
    bn1 = bn1.zfill(len(bn2))
  else:
    bn2 = bn2.zfill(len(bn1))
    
  n3 = [xor(b1,b2) for b1,b2 in zip(bn1, bn2)]
  n3 = "".join(n3)
  return int(n3, 2)


n = int(input())
a = [int(x) for x in input().split()]
a_unique = list(set(a))
l = len(a)

u0 = a.count(a_unique[0])
u1 = a.count(a_unique[1])
u2 = a.count(a_unique[2])

if l==3 and (a[2]== bitxor(a[0], a[1])) and (u0==u1 and u1==u2):
  print("Yes")
else:
  print("No")
Problem p03087 (python)

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

counts = [1 if s[i:i+2]=="AC" else 0 for i in range(n)]

cum_counts=[0]*n
for i in range(1,n):
  cum_counts[i]=cum_counts[i-1]+counts[i-1]

#print(counts)
#print(cum_counts)

for i in range(q):
  l,r = map(int, input().split())
  print(cum_counts[r-1] - cum_counts[l-1])

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

counts = [1 if s[i]=="A" and s[i+1]=="C" else 0 for i in range(n)]
cum_counts = [sum(counts[:i]) for i in range(n)]

for i in range(q):
  l,r = map(int, input().split())
  print(cum_counts[r-1] - cum_counts[l-1])
Problem p02858 (python)

Fixed submission:
mod=10**9+7
from fractions import gcd
h,w,t=map(int,input().split())
gh,gw=gcd(h,t),gcd(w,t)
h1,w1=h//gh,w//gw
print(
		pow(
			pow(2,w1,mod)+
			pow(2,h1,mod)+
			(mod-1)+
			pow(2,gcd(h1,w1),mod)+mod-2
			,gh*gw,mod)
		)

Buggy submission (verdict: Runtime Error):
#!/bin/python3
mod=10**9+7
from math import gcd
h,w,t=map(int,input().split())
gh,gw=gcd(h,t),gcd(w,t)
h1,w1=h//gh,w//gw
print(
		pow(
			pow(2,w1,mod)+
			pow(2,h1,mod)+
			(mod-1)+
			pow(2,gcd(h1,w1),mod)+mod-2
			,gh*gw,mod)
		)
Problem p02936 (python)

Fixed submission:
N,Q = map(int,input().split())
Ki_Oya=dict()
for i in range(N-1):
  A,B = map(int,input().split())
  Ki_Oya[B-1]=A-1
Counter_list=[0]*N
for i in range(Q):
  P,X=map(int,input().split())
  Counter_list[P-1] += X
print(Counter_list[0],end=" ")
for i in range(1,len(Counter_list)):
  Counter_list[i] += Counter_list[Ki_Oya[i]]
  print(Counter_list[i],end=" ")
print("")

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
Ki_Oya=dict()
Ki_Dict=dict()
Ki_Count=dict()
for i in range(N-1):
  A,B = input().split()
  if A not in Ki_Dict:
    Ki_Dict[A]=set(A)
    Ki_Count[A]=0
    Ki_Oya[A]=set(A)
  if B not in Ki_Dict:
    Ki_Dict[B]=set(B)
    Ki_Count[B]=0
    Ki_Oya[B]=set(B)|Ki_Oya[A]
  Ki_Dict[A]|set(B)
  if A in Ki_Oya:
    for j in list(Ki_Oya[A]):
      Ki_Dict[j]|set(B)

for i in range(Q):
  P,X = input().split()
  X = int(X)
  for i in list(Ki_Dict[P]):
    Ki_Count[i] += X
Ki_List = list(Ki_Dict.keys())
ans=[]
for i in Ki_List:
  ans.append(str(Ki_Count[i]))
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
Ki_Oya=dict()
Ki_Dict=dict()
Ki_Count=dict()
for i in range(N-1):
  A,B = input().split()
  if A not in Ki_Dict:
    Ki_Dict[A]=set(A)
    Ki_Count[A]=0
    Ki_Oya[A]=set(A)
  if B not in Ki_Dict:
    Ki_Dict[B]=set(B)
    Ki_Count[B]=0
    Ki_Oya[B]=Ki_Oya[A]
  
  Ki_Dict[A].add(B)
  if A in Ki_Oya:
    for j in list(Ki_Oya[A]):
      Ki_Dict[j].add(B)

for i in range(Q):
  P,X = input().split()
  X = int(X)
  for i in list(Ki_Dict[P]):
    Ki_Count[i] += X
Ki_List = list(Ki_Dict.keys())
ans=[]
for i in Ki_List:
  ans.append(str(Ki_Count[i]))
print(" ".join(ans))
Problem p02811 (python)

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

if (X <= 500*K):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
K = input()
X = input()

if (X <= 500*K):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):

K = input()
X = input()

if (X <= 500*K):
    print("Yes")
else:
    print("No")
Problem p02952 (python)

Fixed submission:
def main():
    n = int(input())

    c = 0
    for i in range(n + 1)[1:]:
        if len(str(i)) % 2 == 1:
            c += 1

    print(c)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def fn(i):
    return (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999)


def main():
    n = int(input())

    x = list(range(n + 1)[1:])
    x = filter(fn, x)

    print(len(x))


if __name__ == '__main__':
    main()

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

    x = list(range(n + 1)[1:])
    x = filter(lambda i: (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999), x)

    print(len(x))


if __name__ == '__main__':
    main()
Problem p03086 (python)

Fixed submission:
def main():
    s = input()
    max_len = 0
    length = 0

    s = list(s)
    s.append('')

    for i in s:
        if i in ['A', 'C', 'G', 'T']:
            length += 1
        else:
            if length > max_len:
                max_len = length
                length = 0

    print(max_len)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    max_len = 0
    length = 0

    for i in list(s).append(''):
        if i in ['A', 'C', 'G', 'T']:
            length += 1
        else:
            if length > max_len:
                max_len = length
                length = 0


if __name__ == '__main__':
    main()
Problem p03371 (python)

Fixed submission:
import sys


def main():
    a, b, c, x, y = map(int, input().split())

    min_price = None

    for i in range(max(x, y) + 1):
        nc = i * 2
        na = x - i
        if na < 0:
            na = 0
        nb = y - i
        if nb < 0:
            nb = 0

        price = na * a + nb * b + nc * c
        if min_price is None or price < min_price:
            min_price = price

    print(min_price)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys


def main():
    a, b, c, x, y = map(int, input())

    min_price = None

    for i in range(max(x, y) + 1):
        nc = i * 2
        na = x - i
        if na < 0:
            na = 0
        nb = y - i
        if nb < 0:
            nb = 0

        price = na * a + nb * b + nc * c
        if min_price is None or price < min_price:
            min_price = price

    print(min_price)


if __name__ == '__main__':
    main()
Problem p02885 (python)

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

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(A-2B)
Problem p02899 (python)

Fixed submission:
N = int(input())
d = []

A = list(map(int, input().split()))
k = []
ANS = []
for i in range(1, N+1):
  k.append(i)

d = list(zip(k, A))
d.sort(key=lambda x:x[1])

for b in range(N):
  print(d[b][0], end=" \n"[b + 1 == N])

Buggy submission (verdict: Runtime Error):
N = int(input())
dic = {}
dic2 = {}
A = list(map(int, input().split()))
k = []
ANS = []
for i in range(1, N+1):
  k.append(i)

dic = dict(zip(k, A))
dic2 = dict(sorted(dic.items(), key=lambda x:x[1]))

for key in dic2:
  ANS.append(key)

for b in range(N):
  print(ANS[b], end=" \n"[b + 1 == N
Problem p02917 (python)

Fixed submission:
n = int(input())
A = [None for i in range(n)]
B = list(map(int, input().split()))
A[0] = B[0]
A[-1] = B[-1]
 
for i in range(1, n-1):
  A[i] = min(B[i-1], B[i])
print(sum(A))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [0]*n
B = list(map(int, input()))

A[0] = B[0]
A[-1] = B[-1]

for i in range(1, n-1):
  A[i] = min(B[i-1], B[i])
  
print(sum(A))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [0]*n
B = list(map(int, input()))

A[0] = B[0]
A[-1] = B[-1]

for i range(1, n-1):
  A[i] = min(B[i-1], B[i])
  
print(sum(A))
Problem p02922 (python)

Fixed submission:
import math

A = list(map(int, input().split()))
a = A[1] - 1
b = A[0] - 1
n = math.floor(a / b)

if n == a / b:
    print(n)
elif n < a / b:
    print(n + 1)
else:
    print(1)

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

if n == B / A:
  print(n)
else:
  print(n+1)
Problem p02934 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S =0
for i in range(N):
  S += 1 / A[i]

ans = 1 / S
print('{:.6g}'.format(ans))

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

for i in range(N):
  S += 1 / A[i]

ans = 1 / S
print('[:.6g]'.format(ans))
Problem p02958 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
cnt = 0
 
for i, j in enumerate(A):
  if i + 1 != j:
    cnt +=1
if cnt <= 2:
  print('YES')
else:
  print('NO')

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

for i, j in enumerate(A)
  if i + 1 != j:
    cnt +=1
if cnt <= 2:
  print('YES')
else:
  print('NO')
Problem p02811 (python)

Fixed submission:
k, x = map(int, input().split())
if x <= k*500:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
K,X=map(int,input().split())
ans=YES
if 500*K<X:
    ans=NO
print(ans)
Problem p02861 (python)

Fixed submission:
from itertools import permutations
from math import factorial


# メインプログラム
def func(N, lst):

    # N! を求める
    N_fact = factorial(N)

    # lst から座標のすべての組合せを求める。
    perm_grid_xy = permutations(lst)

    # すべての組合せを全探索して、総合距離を計算する
    total_dist = total_distance(N, perm_grid_xy)

    # 平均距離 = 総合距離 / N!
    average_dist = total_dist / N_fact

    return average_dist


def total_distance(N, perm_grid_xy):
    
    ret = 0
    
    for grid_xy in perm_grid_xy:
        tmp = sum(
            ((grid_xy[i][0] - grid_xy[i+1][0]) ** 2 
            + (grid_xy[i][1] - grid_xy[i+1][1]) ** 2) ** 0.5 
            for i in range(N-1)
            )
        ret += tmp

    return ret


if __name__ == "__main__":
    N = int(input())
    lst = [tuple(map(int, input().split())) for _ in range(N)]
    print(func(N, lst))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
from math import factorial


# メインプログラム
def func(N, lst):

    # N! を求める
    N_fact = factorial(N)

    # lst から座標のすべての組合せを求める。
    perm_grid_xy = permutations(lst)

    # すべての組合せを全探索して、総合距離を計算する
    total_dist = total_distance(N, perm_grid_xy)

    # 平均距離 = 総合距離 / N!
    average_dist = total_dist / N_fact

    return average_dist


def total_distance(N, perm_grid_xy):

  	ret = 0
    
    for grid_xy in perm_grid_xy:
        for i in range(N-1):
            x0, y0 = grid_xy[i][0], grid_xy[i][1]
            x1, y1 = grid_xy[i+1][0], grid_xy[i+1][1]
            dist = ((x0 - x1)**2 + (y0 - y1)**2) ** 0.5
            ret += dist
            
    return ret


if __name__ == "__main__":
    N = int(input())
    lst = [tuple(map(int, input().split())) for _ in range(N)]
    print(func(N, lst))
Problem p02947 (python)

Fixed submission:
from collections import Counter
from operator import mul
from functools import reduce


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()

cnt_s = Counter(lst_s)

ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += cmb(v, 2)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb
from operator import mul
from functools import reduce


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()

cnt_s = Counter(lst_s)

ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += cmb(v, 2)
print(ans)

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


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()
# print(lst_s)


cnt_s = Counter(lst_s)
# print(cnt_s)

ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += comb(v, 2, exact=True)
print(ans)

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


N = int(input())
lst_s = ["".join(sorted(input())) for _ in range(N)]
lst_s.sort()


cnt_s = Counter(lst_s)


ans = 0
for v in cnt_s.values():
    if v == 1:
        continue
    else:
        ans += comb(v, 2, exact=True)
print(ans)
Problem p02975 (python)

Fixed submission:
from collections import Counter


def main():
    N = int(input())
    lst_a = list(map(int, input().split()))

    cnt_a = Counter(lst_a)

    if len(cnt_a) > 3:
        print("No")
        exit()
    
    if len(cnt_a) == 1:
        print("Yes" if lst_a[0] == 0 else "No")
        exit()
    
    if N % 3:
        print("No")
        exit()
    
    if len(cnt_a) == 2:
        if cnt_a[0] != N//3:
            print("No")
        else:
            print("Yes")
    else:
        if any(v != N//3 for v in cnt_a.values()):
            print("No")
        else:
            x, y, z = list(cnt_a)
            print("Yes" if x ^ y ^ z == 0 else "No")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter


def main():
    N = int(input())
    lst_a = list(map(int, input().split()))

    cnt_a = Counter(lst_a)

    if len(cnt_a) > 3:
        print("No")
        exit()
    
    if len(cnt_a) == 1:
        print("Yes" if lst_a[0] == 0 else "No")
        exit()
    
    if N % 3:
        print("No")
        exit()
    
    if len(cnt_a) == 2:
        if cnt_a[0] != N//3:
            print("No")
        else:
            print("Yes")
    else:
        if any(v != N//3 for v in C.values()):
            print("No")
        else:
            x, y, z = list(cnt_a)
            print("Yes" if x ^ y ^ z == 0 else "No")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter


def main():
    N = int(input())
    lst_a = list(map(int, input().split()))

    cnt_a = Counter(lst_a)

    if len(cnt_a) > 3:
        print("No")
        exit()
    
    if len(cnt_a) == 1:
        print("Yes" if lst_a[0] == 0 else "No")
        exit()
    
    if N % 3:
        print("No")
        exit()
    
    if len(cnt_a) == 2:
        if cnt_a[0] != N//3:
            print("No")
        else:
            print("Yes")
    else:
        if any(v != N//3 for v in C.values()):
            print("No")
        else:
            x, y, z = list(cnt_a)
            print("Yes" if a ^ b ^ c == 0 else "No")


if __name__ == "__main__":
    main()
Problem p03076 (python)

Fixed submission:
lst_str = [input() for _ in range(5)]
lst_int = [int(x) for x in lst_str]

sum_lst = sum(lst_int)

lst_diff = []
for i in lst_str:
    val = int(i[-1])
    if val != 0:
        lst_diff.append(10 - val)

if lst_diff == []:
    lst_diff = [0]
diff = sum(lst_diff) - max(lst_diff)

ans = sum_lst + diff
print(ans)

Buggy submission (verdict: Runtime Error):
lst_str = [input() for _ in range(5)]
lst_int = [int(x) for x in lst_str]

sum_lst = sum(lst_int)

lst_diff = []
for i in lst_str:
    val = int(i[-1])
    if val != 0:
        lst_diff.append(10 - val)

diff = sum(lst_diff) - max(lst_diff)

ans = sum_lst + diff
print(ans)

Buggy submission (verdict: Runtime Error):
lst_str = [input() for _ in range(5)]
lst_int = [int(x) for x in lst_str]

sum_lst = sum(lst_int)

lst_diff = []
for i in lst_str:
    val = 10 - int(i[-1])
    if val != 10:
        lst_diff.append(val)

diff = sum(lst_diff) - max(lst_diff)

ans = sum_lst + diff
print(ans)

Buggy submission (verdict: Runtime Error):
lst_str = [input() for _ in range(5)]
lst_int = [int(x) for x in lst_str]
lst_diff = []

sum_lst = sum(lst_int)
for i in lst_str:
    val = 10 - int(i[-1])#一の位
    if val != 10:
        lst_diff.append(val)
# print(lst_diff)

diff = sum(lst_diff) - max(lst_diff)

ans = sum_lst + diff
print(ans)
Problem p03129 (python)

Fixed submission:
n, k = map(int, input().split())
ans = "NO"
if (n+1)//2 >= k:
    ans = "YES"
print(ans)

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

ans="NO"
if n%2==0:
    if k<=n//2:
        ans="YES"
else:
    if K<=(n+1)//2:
        ans="YES"
print(ans)
Problem p03212 (python)

Fixed submission:
# coding: utf-8
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(s + c)
    return ret

print(dfs("0"))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import itertools
N = input()
ans = 0

for i in range(3, len(N)+1):
    for ptn in itertools.product((3,5,7), repeat=i):
        if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
            continue
        a = int("".join(list(map(str, ptn))))
        if a <= N:
            ans += 1
print(ans)