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

Fixed submission:
n = int(input())
s = input()
dic_1 = {}
dic_2 = {}
ls = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans = 0
for j in range(26):
    dic_1[ls[j]] = 0
    dic_2[ls[j]] = 0
for i in range(1,n-1):
    s1 = s[:i]
    s2 = s[i:]
    tmp = 0
    for j in range(26):
        dic_1[ls[j]] = 0
        dic_2[ls[j]] = 0
    for j in range(len(s1)):
        dic_1[s1[j]] = 1
    for j in range(len(s2)):
        dic_2[s2[j]] = 1
    for j in range(26):
        tmp += dic_1[ls[j]] * dic_2[ls[j]]
    ans = max(ans,tmp)
print(ans)

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

for i in range(1,n-1):
  
  dic_f = {}
  dic_l = {}
  former = s[:i]
  latter = s[i+1:]
  counter = 0
  
  for j in range(len(former)):
    if former[j] not in dic_f.keys():
      dic_f[former[j]] = 1
      
  for j in range(len(latter)):
    if latter[j] not in dic_l.keys():
      dic_l[latter[j]] = 1
      
  for j in dic_f.keys():
    if j in dic_l.keys():
      counter += 1
  ls.append(counter)

print(max(ls))
Problem p03385 (python)

Fixed submission:
s=input()
if s.count("a")==1 and s.count("b")==1 and s.count("c")==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=list(input())
if s.sorted==["a","b","c"]:
    print("Yes")
else:
    print("No")
Problem p03386 (python)

Fixed submission:
[a,b,k] = [int(i) for i in input().split()]

if k > (b-a+1):
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(max(a+k,b-k+1),b+1):
        print(i)

Buggy submission (verdict: Runtime Error):
[a,b,k]=[int(i) for i in input().split()]
s=list(range(a,b+1))
#print(s)
if (2*k)<=(b-a+1):
    for i in range(k):
        print(int(s[i]))
    for i in range(k):
        print(int(s[b-a-(k-i-1)]))
else:
    for i in range(b-a+1):
        print(s[i])
Problem p03425 (python)

Fixed submission:
n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
cnt = 0
for i in range(n):
  p = input()
  if p[0] == "M":
    m += 1
  if p[0] == "A":
    a += 1
  if p[0] == "R":
    r += 1
  if p[0] == "C":
    c += 1
  if p[0] == "H":
    h += 1
if m > 0:
  cnt += 1
if a > 0:
  cnt += 1
if r > 0:
  cnt += 1
if c > 0:
  cnt += 1
if h > 0:
  cnt += 1
  
if cnt < 3:
  print(0)
else:
  print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h)

Buggy submission (verdict: Runtime Error):
n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
cnt = 0
for i in range(s):
  p = input()
  if p[0] == "M":
    m += 1
  if p[0] == "A":
    a += 1
  if p[0] == "R":
    r += 1
  if p[0] == "C":
    c += 1
  if p[0] == "H":
    h += 1
if m > 0:
  cnt += 1
if a > 0:
  cnt += 1
if r > 0:
  cnt += 1
if c > 0:
  cnt += 1
if h > 0:
  cnt += 1
  
if cnt < 3:
  print(0)
else:
  print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*h + a*c*h + r*c*h)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
m = 0
a = 0
r = 0
c = 0
h = 0
cnt = 0
for i in range(s):
  a = input()
  if a[0] == "M":
    m += 1
  if a[0] == "A":
    a += 1
  if a[0] == "R":
    r += 1
  if a[0] == "C":
    c += 1
  if a[0] == "H":
    h += 1
if m > 0:
  cnt += 1
if a > 0:
  cnt += 1
if r > 0:
  cnt += 1
if c > 0:
  cnt += 1
if h > 0:
  cnt += 1
  
if cnt < 3:
  print(0)
else:
  print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*h + a*c*h + r*c*h)
Problem p03502 (python)

Fixed submission:
"""
https://abc080.contest.atcoder.jp/tasks/abc080_b
"""
n=input()
a=0
for i in range(len(n)):
    a=a+int(n[i])
if int(n)%a==0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
"""
https://abc080.contest.atcoder.jp/tasks/abc080_b
"""
n=input()
a=0
for i in range(len(n)):
    a=a+int(n[i])
if n%a==0:
    print("Yes")
else:
    print("No")
Problem p03545 (python)

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

if a + b + c + d  == 7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a + b + c - d == 7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a + b - c + d == 7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a - b + c + d == 7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a + b - c - d == 7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif a - b + c - d == 7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a - b - c + d == 7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a - b - c - d == 7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")

Buggy submission (verdict: Runtime Error):
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

if a + b + c + d  == 7:
  print(str(a)+"+"+str(b)+"+"str(c)+"+"str(d)+"=7")
elif a + b + c - d == 7:
  print(str(a)+"+"+str(b)+"+"str(c)+"-"str(d)+"=7")
elif a + b - c + d == 7:
  print(str(a)+"+"+str(b)+"-"str(c)+"+"str(d)+"=7")
elif a - b + c + d == 7:
  print(str(a)+"-"+str(b)+"+"str(c)+"+"str(d)+"=7")
elif a + b - c - d == 7:
  print(str(a)+"+"+str(b)+"-"str(c)+"-"str(d)+"=7")
elif a - b + c - d == 7:
  print(str(a)+"-"+str(b)+"+"str(c)+"-"str(d)+"=7")
elif a - b - c - d == 7:
  print(str(a)+"+"+str(b)+"+"str(c)+"+"str(d)+"=7")
Problem p03555 (python)

Fixed submission:
a=input()
b=input()
if (a+b)==(a+b)[::-1]:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
"""
https://abc077.contest.atcoder.jp/tasks/abc077_b
"""
n=int(input())
i=1
while (i**2)<=n:
    i=i+1
print((i-1)**2)
Problem p03633 (python)

Fixed submission:
import math
n = int(input())
t = []
for i in range(n):
    t.append(int(input()))
if n == 1:
    print(t[0])
else:
    tmp = t[0]
    for i in range(1,n):
        div = math.gcd(tmp,t[i])
        tmp = (t[i] * tmp)//div
    print(tmp)

Buggy submission (verdict: Runtime Error):
import fractions as frac
n = int(input())
t = []
for i in range(n):
  t.append(int(input()))
tmp = t[0]
for i in range(1,n):
  if tmp % t[i] != 0:
    tmp = int(tmp * t[i] /frac.gcd(tmp,t[i]))
print(tmp)
Problem p03680 (python)

Fixed submission:
n = int(input())
a = {}
for i in range(n):
  a[i+1] = int(input())

p = 1
ok = 0

for i in range(n):
  p = a[p]
  if p == 2:
    ok = 1
    break

if ok == 1:
  print(i+1)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
"""
https://abc065.contest.atcoder.jp/tasks/abc065_b
"""
n=int(input())
a="S"
for i in range(n):
    a=a+input()
#print(a)
t=1
c=0
for i in range(n):
    t=int(a[t])
    c=c+1
    if t==2:
        print(c)
        break
if t!=2:
    print(-1)
Problem p03720 (python)

Fixed submission:
[n,m] = [int(i) for i in input().split()]
ab = []
dic = {}
for i in range(m):
  ab.append([int(j) for j in input().split()])

for i in range(m):
  if ab[i][0] in dic.keys():
    dic[ab[i][0]] += 1
  else:
    dic[ab[i][0]] = 1
    
  if  ab[i][1] in dic.keys():
    dic[ab[i][1]] += 1
  else:
    dic[ab[i][1]] = 1
    
for i in range(n):
  if i+1 in dic.keys():
    print(dic[i+1])
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
[n,m] = [int(i) for i in input().split()]
ab = []
dic = {}
for i in range(m):
  ab.append([int(j) for j in input().split()])

for i in range(m):
  if ab[i][0] in dic.keys():
    dic[ab[i][0]] += 1
  else:
    dic[ab[i][0]] = 1
    
  if  ab[i][1] in dic.keys():
    dic[ab[i][1]] += 1
  else:
    dic[ab[i][1]] = 1
    
for i in range(n):
  print(dic[i+1])

Buggy submission (verdict: Runtime Error):
[n,m] = [int(i) for i in input().split()]
ab = []
dic = {}
for i in range(m):
  ab.append([int(j) for j in input().split()])

for i in range(m):
  if ab[i][0] in dic.keys():
	dic[ab[i][0]] += 1
  else:
    dic[ab[i][0]] = 1
    
  if  ab[i][1] in dic.keys():
	dic[ab[i][1]] += 1
  else:
    dic[ab[i][1]] = 1
    
for i in range(n):
  print(dic[i+1])

Buggy submission (verdict: Runtime Error):
[n,m] = [int(i) for i in input().split()]
ab = []
dic = {}
for i in range(m):
  ab.append([int(j) for j in input().split()])

for i in range(m):
  if ab[i][0] in dic.keys():
	  dic[ab[i][0]] += 1
  else:
    dic[ab[i][0]] = 1
    
  if  ab[i][1] in dic.keys():
	  dic[ab[i][1]] += 1
  else:
    dic[ab[i][1]] = 1
    
for i in range(n):
  print(dic[i+1])

Buggy submission (verdict: Runtime Error):
[n,m] = [int(i) for i in input().split()]
ab = []
dic = {}
for i in range(m):
  ab.append([int(j) for j in input().split()])
 
for i in range(m):
  if ab[i][0] in dic.keys():
	  dic[ab[i][0]] += 1
  else:
    dic[ab[i][0]] = 1
    
  if  ab[i][1] in dic.keys():
	  dic[ab[i][1]] += 1
  else:
    dic[ab[i][1]] = 1
    
for i in range(n):
  print(dic[i+1])

Buggy submission (verdict: Runtime Error):
[n,m] = [int(i) for i in input().split()]
ab = []
dic = {}
for i in range(m):
  ab.append([int(i) for i in input().split()])

for i in range(m):
  if ab[i][0] in dic.keys():
	  dic[ab[i][0]] += 1
  else:
    dic[ab[i][0]] = 1
    
  if  ab[i][1] in dic.keys():
	  dic[ab[i][1]] += 1
  else:
    dic[ab[i][1]] = 1
    
for i in range(n):
  print(dic[i+1])
Problem p03818 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

import collections

n = int(input())
a = [int(i) for i in input().split()]

dic = collections.defaultdict(int)
for i in range(n):
    dic[a[i]] += 1

ls = collections.deque()
for i in dic.keys():
    if dic[i] > 1:
        ls.append(i)

ans = n
if len(ls) > 0:
#n/2回ループ
    for i in range(n//2):
        if len(ls) == 1 and dic[ls[0]] == 2:
            ans -= 2
            dic[ls[0]] -= 1
            break
        else:
            if len(ls) == 1:
                dic[ls[0]] -= 2
            else:
                dic[ls[0]] -= 1
                dic[ls[-1]] -= 1
            ans -= 2

        if len(ls) > 1:
            if dic[ls[-1]] <= 1:
                ls.pop()
        if dic[ls[0]] <= 1:
            ls.popleft()

        if len(ls) == 0:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]

import collections

n = int(input())
a = [int(i) for i in input().split()]

dic = collections.defaultdict(int)
for i in range(n):
    dic[a[i]] += 1

ls = collections.deque()
for i in dic.keys():
    if dic[i] > 1:
        ls.append(i)

ans = n
#n/2回ループ
for i in range(n//2):
    if len(ls) == 1 and dic[ls[0]] == 2:
        ans -= 2
        dic[ls[0]] -= 1
        break
    else:
        if len(ls) == 1:
            dic[ls[0]] -= 2
        else:
            dic[ls[0]] -= 1
            dic[ls[-1]] -= 1
        ans -= 2

    if len(ls) > 1:
        if dic[ls[-1]] <= 1:
            ls.pop()
    if dic[ls[0]] <= 1:
        ls.popleft()

    if len(ls) == 0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
a = [int(i) for i in input().split()]

dic = collections.defaultdict(int)
for i in range(n):
    dic[a[i]] += 1

ls = collections.deque()
for i in dic.keys():
    if dic[i] > 1:
        ls.append(i)

ans = n

for i in range(n//2):
    if max(dic.values()) == 1:
        break

    if len(ls) == 1 and dic[ls[0]] == 2:
        ans -= 2
        dic[ls[0]] -= 1
        break
    else:
        dic[ls[0]] -= 1
        dic[ls[-1]] -= 1
        ans -= 2

    if dic[ls[0]] <= 1:
        ls.popleft()
    if dic[ls[-1]] <= 1:
        ls.pop()

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
a = [int(i) for i in input().split()]

dic = collections.defaultdict(int)
for i in range(n):
    dic[a[i]] += 1

ls = collections.deque()
for i in dic.keys():
    if dic[i] > 1:
        ls.append(i)

ans = n

while max(dic.values()) > 1:
    #print(dic)
    if len(ls) == 1 and dic[ls[0]] == 2:
        ans -= 2
        dic[ls[0]] -= 1
        break
    else:
        dic[ls[0]] -= 1
        dic[ls[-1]] -= 1
        ans -= 2
    if len(ls) >= 1:
        if dic[ls[0]] <= 1:
            ls.popleft()
        if dic[ls[-1]] <= 1:
            ls.pop()
print(ans)
Problem p03853 (python)

Fixed submission:
[h,w] = [int(i) for i in input().split()]
s=[]
for i in range(h):
  s.append(input())

for i in range(h):
  print(s[i])
  print(s[i])

Buggy submission (verdict: Runtime Error):
[h,w] = [int(i) for i in input().split()]
s=[]
for i in range(h):
  s=input()

for i in range(h):
  print(s[i])
  print(s[i])
Problem p03962 (python)

Fixed submission:
t=[int(i) for i in input().split()]
t.sort()
#print(t)
a=1
for j in range(1,len(t)):
    if t[j-1]<t[j]:
        a=a+1
print(a)

Buggy submission (verdict: Runtime Error):
[n,k]=[int(i) for i in input().split()]
a=k
if n==1:
    print(k)
else:
    for i in range(n-1):
        a=a*(k-1)
    print(a)
Problem p04043 (python)

Fixed submission:
s=[int(i) for i in input().split()]
#print(s,len(s))
if len(s)==3 and s.count(5)==2 and s.count(7)==1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
s=[int(i) for i in input.split()]
if len(s)==3 and s.count("5")==2 and s.count("7")==1:
    print("YES")
else:
    print("NO")
Problem p04047 (python)

Fixed submission:
n = int(input())
l = [int(i) for i in input().split()]
a = 0
l.sort()
for i in range(len(l)):
    if i % 2 == 0:
        a = a + l[i]
print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(i) for i in input().split()]
a = 0
for i in len(l):
    if i % 2 == 0:
        a = a + l[i]
print(a)
Problem p02732 (python)

Fixed submission:
def main():
    import math
    import collections
    N = int(input())
    A = list(map(int, input().split()))
    tt = 0
    #ans = list()
    ann = 0

    def comb(m, n):
        #return math.factorial(m) // (math.factorial(n) * math.factorial(m - n))
        return ((m - 1 + 1) / 1) * (m - 2 + 1) / 2

    '''
    def A_count(n):
        if n in memo:
            return memo[n]
        h = A.count(i)
        memo[n] = A.count(i)
        return h
    '''

    C = collections.Counter(A)
    for i in C.values():
        if i>=2:
            tt = tt + comb(i, 2)

    for i in A:
        f = C[i] #A_count(A[i])
        if f>=3:
            ann = (tt - comb(f, 2) + comb(f-1, 2))
        elif f==2:
            ann = tt - comb(f, 2)
        else:
            ann = tt
        print(int(ann))

    #for i in ans:
    #    print(i)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import math
    import collections
    N = int(input())
    A = list(map(int, input().split()))
    tt = 0
    #ans = list()
    ann = 0

    def comb(m, n):
        return math.factorial(m) // (math.factorial(n) * math.factorial(m - n))
    '''
    def A_count(n):
        if n in memo:
            return memo[n]
        h = A.count(i)
        memo[n] = A.count(i)
        return h
    '''

    C = collections.Counter(A)
    for i in C.values():
        f = i
        if f>=2:
            tt = tt + comb(f, 2)

    for i in A:
        f = C[A[i]] #A_count(A[i])
        if f>=3:
            ann = (tt - comb(f, 2) + comb(f-1, 2))
        elif f==2:
            ann = tt - comb(f, 2)
        else:
            ann = tt
        print(ann)

    #for i in ans:
    #    print(i)


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

Fixed submission:
L, R = list(map(int, input().split()))
ans = 2020
if abs(L-R)>=2020:
    print(0)
else:
    for i in range(L, R):
        for j in range(L, R+1):
            if i==j:
                continue
            else:
                ans = min(ans, (i*j)%2019)
    print(ans)

Buggy submission (verdict: Runtime Error):
L, R = list(map(int, input().split()))
ans = 2020
if abs(L-R)>==4038:
    print(0)
else:
    for i in range(L, R):
        for j in range(L, R+1):
            if i==j:
                continue
            else:
                ans = min(ans, (i*j)%2019)

print(ans)
Problem p02995 (python)

Fixed submission:
import fractions
#なぜかWA
"""
A,B,C,D = list(map(int, input().split()))
cc = int(B/C) - int((A-1)/C)
dd = int(B/D) - int((A-1)/D)
cd = int(C*D / fractions.gcd(C,D))
ee = int(B/cd) - int((A-1)/cd)
U = B-A+1
print(U - (cc + dd - ee))
"""
#解説読んだ
#なんで通らなくぁｗせｄｒｆｔｇｙふじこｌｐ
#?????????????????
A,B,C,D = list(map(int, input().split()))
def y(n, c, d):
    cd = c // fractions.gcd(c,d) * d
    cc = n//c
    dd = n//d
    ee = n//cd
    return n - cc - dd + ee

print(y(B, C, D) - y(A-1, C, D))

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D = list(map(int, input().split()))
cc = int(B/C) - int((A-1)/C)
dd = int(B/D) - int((A-1)/D)
cd = C*D / math.gcd(C,D)
ee = int(B/(cd)) - int((A-1)/(cd))
U = B-A+1
print(U - (cc + dd - ee))
Problem p03612 (python)

Fixed submission:
#解説見た
n = int(input())
p = list(map(int, input().split()))
p.append(0)
ans = 0
for i in range(n):
    if p[i] == (i+1):
        p[i],p[i+1] = p[i+1], p[i]
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
#解説見た
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
    if p[i] == (i+1):
        p[i],p[i+1] = p[i+1], p[i]
        ans += 1

print(ans)
Problem p02718 (python)

Fixed submission:
from sys import stdin
 
input = stdin.readline
 
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
vote = sum(a) / 4 / m
 
a.sort()
a.reverse()
 
print("Yes" if a[m - 1] >= vote else "No")

Buggy submission (verdict: Runtime Error):
from sys import stdin

input = stdin.readline

n, k = map(int, input().split())
a = [int(x) for x in input().split()]
vote = sum(a) / 4 / m

a.sort()
a.reverse()

print("Yes" if a[m - 1] >= vote else "No")
Problem p02614 (python)

Fixed submission:
H, W, K = map(int, input().split())
G = [list(input()) for _ in range(H)]
ans = 0
for rows in range(2**H):
    for cols in range(2**W):
        black = 0
        for i in range(H):
            if rows >> i & 1:
                continue
            for j in range(W):
                if cols >> j & 1:
                    continue
                if G[i][j] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
H, W, K = map(int, input().split())
G = [list(input()) for _ in range(H)]
for rows in range(2**H):
    for cols in range(2**W):
        black = 0
        for i in range(H):
            if rows >> i & 1:
                continue
            for j in range(W):
                if cols >> j & 1:
                    continue
                if G[i][j] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)
Problem p02642 (python)

Fixed submission:
N = int(input())
*A, = map(int, input().split())
m = max(A)
cnt = [0] * (m + 1)
for elem in A:
    cnt[elem] += 1
# print(cnt)

unique = []
for i in range(m + 1):
    if cnt[i] == 1:
        unique.append(i)
# print(unique)
# unique = list(set(A))

cnt = [0] * (m + 1)
A = list(set(A))
for elem in A:
    for mul in range(elem * 2, m + 1, elem):
        cnt[mul] = 1
ans = 0

for elem in unique:
    if cnt[elem] == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
*A, = map(int, input().split())
A = list(set(A))
A.sort()
if len(A) == 1:
    print(0)
    exit()
ans = 0
for i in reversed(range(N)):
    b = True
    for j in reversed(range(i)):
        if A[i] % A[j] == 0:
            b = False
    if b:
        ans += 1
print(ans)
Problem p02658 (python)

Fixed submission:
N = int(input())
*A, = map(int, input().split())
if 0 in A:
    print(0)
    exit()
ans = A[0]
for i in range(1, N):
    ans *= A[i]
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
*A, = map(int, input().split())
ans = 1
for a in range(A):
    ans *= a
    if ans >= 10 ** 18:
        print(-1)
        exit()
print(ans)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
journey = [1]
dup = {}
for i in range(N+100000):
    journey.append(A[journey[-1] - 1])

end_idx, start_idx = 0, 0
dup = {}
for i, j in enumerate(journey):
    if j in dup:
        end_idx = i
        break
    else:
        dup[j] = 0
for i, j in enumerate(journey):
    if j == journey[end_idx]:
        start_idx = i
        break

if K <= start_idx:
    print(journey[K])
    exit()
b = end_idx - start_idx
m = (K - start_idx) % b
print(journey[start_idx + m])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
journey = [1]
dup = {}
for i in range(N+100000):
    journey.append(A[journey[-1] - 1])

end_idx, start_idx = 0, 0
dup = {}
for i, j in enumerate(journey):
    if j in dup:
        end_idx = i
        break
    else:
        dup[j] = 0
for i, j in enumerate(journey):
    if j == journey[end_idx]:
        start_idx = i
        break
        
if K >= start_idx:
    print(journey[K])
    exit()
b = end_idx - start_idx
m = (K - start_idx) % b
print(journey[start_idx + m])
Problem p02700 (python)

Fixed submission:
A, B, C, D = map(int, input().split())
for _ in range(1000):
    C = C - B
    A = A - D
    if C <= 0:
        print("Yes")
        exit()
    if A <= 0:
        print("No")
        exit()

Buggy submission (verdict: Runtime Error):
print(len({input() for _ in range(int(input()))}))
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
qa = sorted(list(map(int, input().split())), reverse=True)
qb = sorted(list(map(int, input().split())), reverse=True)
qc = sorted(list(map(int, input().split())), reverse=True)
chk = []
chk.extend(qa[:X]+qb[:Y]+qc)
chk.sort(reverse=True)
print(sum(chk[:X+Y]))

Buggy submission (verdict: Runtime Error):
from collections import deque
X, Y, A, B, C = map(int, input().split())
qa = deque(sorted(list(map(int, input().split())), reverse=True))
qb = deque(sorted(list(map(int, input().split())), reverse=True))
qc = deque(sorted(list(map(int, input().split())), reverse=True))
ans = 0
for _ in range(X):
    if qa[0] >= qc[0]:
        ans += qa.popleft()
    else:
        ans += qc.popleft()

for _ in range(Y):
    if qb[0] >= qc[0]:
        ans += qb.popleft()
    else:
        ans += qc.popleft()
print(ans)
Problem p02743 (python)

Fixed submission:
import decimal
a, b, c = map(int,input().split())
a = decimal.Decimal(a)
b = decimal.Decimal(b)
c = decimal.Decimal(c)
if a.sqrt() + b.sqrt() < c.sqrt():
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
a, b, c = map(int,input().split())
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
div = 0.5
if a ** div + b ** div < c ** div:
    print('Yes')
else:
    print('No')
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
SC = set(tuple(map(int, input().split())) for _ in range(M))

for i in range(10**N):
    num = str(i)
    if len(num) != N:
        continue
    chk = []
    for s, c in SC:
        if num[s-1] == str(c):
            chk.append(True)
        else:
            chk.append(False)
    if all(chk):
        print(num)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
SC = set([tuple(map(int, input().split())) for _ in range(M)])
chk = {}
for s, c in SC:
    if s in chk:
        print(-1)
        exit()
    else:
        chk[s] == 0
ans = [-1] * N
for s, c in SC:
    if ans[s-1] == -1:
        ans[s-1] = c
if N >= 2:
    if ans[0] == -1 or ans[0] == 0:
        print(-1)
        exit()
kotae = ''
for a in ans:
    if a == -1:
        kotae += '0'
    else:
        kotae += str(a)
print(kotae)
Problem p02765 (python)

Fixed submission:
N, R = map(int, input().split())
if N >= 10:
  print(R)
  exit()
else:
	print(100 * (10 - N) + R)

Buggy submission (verdict: Runtime Error):
N, R = map(int, input().split())
if N >= 10:
  print(R)
  exit()
else:
print(100 * (10 - N) + R)
Problem p02796 (python)

Fixed submission:
N = int(input())
A = []
for i in range(N):
    x, l = map(int, input().split())
    A.append([x+l, x-l])
A.sort()
ans = 1
check1 = A[0]
for i in range(1, N):
    check2 = A[i]
    if check1[0] <= check2[1]:
        ans += 1
        check1 = check2
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(a):
    x, l = map(int, input().split())
    A.append([x+l, x-l])
A.sort()
ans = 1
check1 = A[0]
for i in range(1, N):
    check2 = A[i]
    if check1[0] <= check2[1]:
        ans += 1
        check1 = check2
print(ans)