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

Fixed submission:
s = input()
print(700+100*sum([1 for x in s if x=='o']))

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
import sys
input = sys.stdin.readline

n,c = map(int,input().split())
x1,v1 = [0],[0]
x2,v2 = [],[]
for _ in range(n):
  a,b = map(int, input().split())
  x1.append(a)
  x2 = [c-a] + x2
  v1.append(b)
  v2 = [b] + v2
x2 = [0] + x2
v2 = [0] + v2

v1, v2 = list(accumulate(v1)), list(accumulate(v2))

f1 = [v1[i] - x1[i] for i in range(n+1)]
f2 = [v2[i] - x2[i] for i in range(n+1)]
g1,x1_ = f1[0],x1[0]
g2,x2_ = f2[0],x2[0]
val = max(v1[n]-x1[n] + g2 - min(x1[n],x2_), v2[n]-x2[n] + g1 - min(x2[n],x1_))
for i in range(1,n+1):
  if g1<f1[i]:
	  g1,x1_ = f1[i], x1[i]
  if g2<f2[i]:
	  g2,x2_ = f2[i], x2[i]
  val = max(val, v1[n-i]-x1[n-i] + g2 - min(x1[n-i],x2_), v2[n-i]-x2[n-i] + g1 - min(x2[n-i],x1_))

print(val)
Problem p03544 (python)

Fixed submission:
n = int(input())
a= [0]*87
a[0]=2
a[1]=1
for i in range(2,87):
    a[i]=a[i-1]+a[i-2]

print(a[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
a= [0]*86
a[0]=1
a[1]=2
for i in range(2,87):
  a[i]=a[i-1]+a[i-2]
print(a[n-1])
Problem p03557 (python)

Fixed submission:
import collections
n=int(input())
a=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
b=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
c=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
la=len(a)
lb=len(b)
lc=len(c)
bc=[0]*lb
j=0
tmp=sum(i[1] for i in c)
for i,x in enumerate(b):
  while j<lc and x[0]>=c[j][0]:
    tmp-=c[j][1]
    j+=1
  bc[i]=tmp

abc=[0]*la
j=0
tmp=sum(i[1]*j for i,j in zip(b,bc))
for i,x in enumerate(a):
  while j<lb and x[0]>=b[j][0]:
    tmp-=b[j][1]*bc[j]
    j+=1
  abc[i]=tmp
ans=sum(i[1]*j for i,j in zip(a,abc))
#print(a,b,c,bc,abc,sep="\n")
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
a=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
b=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
c=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])

bc=[0]*len(b)
j=0
tmp=sum(i[1] for i in c)
for i,x in enumerate(b):
  while j<n and x[0]>=c[j][0]:
    tmp-=c[j][1]
    j+=1
  bc[i]=tmp

abc=[0]*len(a)
j=0
tmp=sum(i[1]*j for i,j in zip(b,bc))

for i,x in enumerate(a):
  while j<n and x[0]>=b[j][0]:
    tmp-=b[j][1]*bc[j]
    j+=1
  abc[i]=tmp
ans=sum(i[1]*j for i,j in zip(a,abc))
#print(a,b,c,bc,abc,sep="\n")
print(ans)
Problem p03639 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a1=0
a2=0
a3=0
for i in a:
  if i%4==0:
    a1+=1
  elif i%4==2:
    a2+=1
  else:
    a3+=1
    
if a3==0:
  print("Yes")
else:
  if a2==0:
    if a1>=a3-1:
      print("Yes")
    else:
      print("No")
  else:
    if a1>=a3:
      print("Yes")
    else:
      print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a1=0
a2=0
a3=0
for i in a:
  if a%4==0:
    a1+=1
  elif a%4==2:
    a2+=1
  else:
    a3+=1
    
if a3==0:
  print("Yes")
else:
  if a2==0:
    if a1>=a3-1:
      print("Yes")
    else:
      print("No")
  else:
    if a1>=a3:
      print("Yes")
    else:
      print("No")
Problem p04043 (python)

Fixed submission:
a,b,c = map(int, input().split())
if a*b*c==5*5*7:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n,l = map(int, input().split())
string = [input() for i in range(n)]
string.sort()
print("".join(string))
Problem p04045 (python)

Fixed submission:
import itertools
import sys
def main():
    n,k = map(int, input().split())
    ds =  list(map(int, input().split()))
    for i in range(n, 10**6):
        s = str(i)
        for d in ds:
            if str(d) in s:
                f = False
                break
            else:
                f = True
        if f:
            print(i)
            sys.exit()
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import itertools
def main():
    n,k = map(int, input().split())
    ds =  map(int, input().split())
    canuse = [i for i in range(10)]
    for d in ds: canuse.remove(d)
    canuse = [str(c) for c in canuse]
    digit = len(str(n))
    x = [int("".join(a)) for a in itertools.product(canuse, repeat=digit) if int("".join(a))>=n]
    print(min(x))
if __name__ == "__main__":
    main()
Problem p02865 (python)

Fixed submission:
N=int(input())
if N%2==0:
    print(N//2-1)
else:
    print((N+1)//2-1)

Buggy submission (verdict: Runtime Error):
= int(input())
if N // 2 == 0:
  ans = N / 2 - 1
else:
  ans = (N - 1) / 2
print(ans)
Problem p02969 (python)

Fixed submission:
# *-* coding=utf-8 *-*


n = int(input())
print(3*n*n)

Buggy submission (verdict: Runtime Error):



n = input()
print(3*n*n)

Buggy submission (verdict: Runtime Error):
# *-* coding=utf-8 *-*


n = input()
print(3*n*n)
Problem p02841 (python)

Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2 == 1:
    print 1
else:
    print 0

Buggy submission (verdict: Runtime Error):
M1,D1 = map(int,input().split())
M2,D2 = map(int,input().split())

if D2 == 1:
    print 1
else:
    print 0

Buggy submission (verdict: Runtime Error):
M1,D1 = map(int,input().split())
M2,D2 = map(int,input().split())

if D2 == 1:
  print 1
else:
  print 0

Buggy submission (verdict: Runtime Error):
M1,D1=map(int,input().split())
M2,D2=map(int,input().split())

if d2==1:
  print 1
else:
  print 0

Buggy submission (verdict: Runtime Error):
M1,D1=map(int,input.split())
M2,D2=map(int,input.split())

if d2==1:
  print 1
else:
  print 0

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
for _ in range(M):
    a, b = map(int, input().split())
if M[1]==1:
  print 1
else:
  print 0
Problem p02841 (python)

Fixed submission:
targetDay = input().split()
nextDay	  = input().split()

if targetDay[0] != nextDay[0]:
	print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
payment = input()
price = float(payment) / 1.08


if (price - int(price)) == 0:
  print(int(price))
else:
  print(':(')
Problem p02866 (python)

Fixed submission:
from collections import Counter
from functools import reduce
n = int(input())
d = (int(s) for s in input().split())
if next(d) != 0:
    print(0)
    quit(0)
c = Counter(d)
if c[0] != 0:
    print(0)
    quit(0)
print(reduce(lambda x, y: x * y, (c[k - 1] ** x if k > 1 else 1 for k, x in c.items()), 1) % 998244353)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from collections import Counter
n = int(input())
d = [int(s) for s in input().split()]
c = Counter(d)
ds = [0] * (max(c.keys()) + 1)
for k, v in c.items():
  ds[k] = v
print(reduce(lambda x, y: x * y, (x ** y for x, y in zip(ds[:-1], ds[1:])), 1) if ds[0] == 1 and d[0] = 0 else 0)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from collections import Counter
n = int(input())
c = Counter(int(s) for s in input().split())
ds = [0] * max(c.keys() + 1)
for k, v in c.items():
  ds[k] = v
print(reduce(lambda x, y: x * y, (x ** y for x, y in zip(ds[:-1], ds[1:])), 1) if ds[0] == 1 else 0)
Problem p03128 (python)

Fixed submission:
import sys

mp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = sorted(input().split(), reverse=True)

    dp = [-10007] * (n + 1)
    dp[0] = 0
    for i in a:
        step = mp[int(i)]
        for j in range(step, n + 1):
            dp[j] = max(dp[j - step] + 1, dp[j])

    i = n
    while i > 0:
        for x in a:
            step = mp[int(x)]
            if i >= step and dp[i - step] == dp[i] - 1:
                sys.stdout.write(x)
                i -= step
                break
    print()

Buggy submission (verdict: Runtime Error):
import sys

mp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = sorted(input().split(), reverse=True)

    dp = [-10007] * (n + 1)
    dp[0] = 0
    for i in a:
        step = mp[int(i)]
        for j in range(step, n + 1):
            dp[j] = max(dp[j - step] + 1, dp[j])

    i = n
    while i > 0:
        for x in a:
            step = mp[int(x)]
            if dp[i - step] == dp[i] - 1:
                sys.stdout.write(x)
                i -= step
                break
    print()

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

mp = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

if __name__ == '__main__':
    n, m = map(int, input().split())
    a = sorted(input().split())
    x = min(a, key=lambda x: mp[int(x)])
    key_x = mp[int(x)]
    quo, rem = divmod(n, key_x)
    buf = deque([x] * quo)

    dp = defaultdict(str)
    dp[0] = ''
    while rem not in dp:
        rem += key_x
        buf.pop()
        for k, v in list(dp.items()):
            for i in a:
                index = mp[int(i)]
                dp[k + index] = max(dp[k + index], i + v)
            del dp[k]

    for c in dp[rem]:
        if c > x:
            sys.stdout.write(c)
        else:
            buf.append(c)
    print(''.join(buf))
Problem p03244 (python)

Fixed submission:
from collections import Counter
from collections import deque

if __name__ == '__main__':
    n = int(input())
    vs0 = []
    vs1 = []
    for i,v in enumerate(map(int, input().split())):
        if i % 2 == 0:
            vs0.append(v)
        else:
            vs1.append(v)
    vs0 = deque(sorted(Counter(vs0).items(), key=lambda t: t[1]))
    vs1 = deque(sorted(Counter(vs1).items(), key=lambda t: t[1]))
    t0 = vs0.pop()
    t1 = vs1.pop()
    if t0[0] != t1[0]:
        vs0 = (t[1] for t in vs0)
        vs1 = (t[1] for t in vs1)
        print(sum(vs0) + sum(vs1))
    else:
        if len(vs1) == 0:
            if len(vs0) == 0:
                print(t1[1])
            else:
                vs0 = (t[1] for t in vs0)
                print(sum(vs0))
        elif len(vs0) == 0:
            vs1 = (t[1] for t in vs1)
            print(sum(vs1))
        else:
            t00 = vs0.pop()
            t11 = vs1.pop()
            a = t00[1] + t1[1]
            b = t11[1] + t0[1]
            vs0 = (t[1] for t in vs0)
            vs1 = (t[1] for t in vs1)
            print(sum(vs0) + sum(vs1) + (a if a < b else b))

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

if __name__ == '__main__':
    n = int(input())
    vs0 = []
    vs1 = []
    for i,v in enumerate(map(int, input().split())):
        if i % 2 == 0:
            vs0.append(v)
        else:
            vs1.append(v)
    vs0 = deque(sorted(Counter(vs0).items(), key=lambda t: t[0]))
    vs1 = deque(sorted(Counter(vs1).items(), key=lambda t: t[0]))
    t0 = vs0.pop()
    t1 = vs1.pop()
    if t0[0] != t1[0]:
        vs0 = (t[1] for t in vs0)
        vs1 = (t[1] for t in vs1)
        print(sum(vs0) + sum(vs1))
    else:
        if len(vs1) == 0:
            if len(vs0) == 0:
                print(t1[1])
            else:
                vs0 = (t[1] for t in vs0)
                print(sum(vs0))
        elif len(vs0) == 0:
            vs1 = (t[1] for t in vs1)
            print(sum(vs1))
        else:
            t00 = vs0.pop()
            t11 = vs1.pop()
            a = t00 + t1
            b = t11 + t0
            print(sum(vs0) + sum(vs1) + (a if a < b else b))
Problem p03370 (python)

Fixed submission:
n,x=map(int,input().split())
m=[int(input()) for _ in range(n)]
print((x - sum(m)) // min(m) + n)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
m=[int(input()) for _ in range(n)]
print((x - sum(m)) // min(m) + m)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input())
m=[int(input()) for _ in range(n)]
print((x - sum(m)) // min(m) + m)
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
l = range(a, b + 1) if b - a + 1 <= k else sorted(set(range(a, a + k)) | set(range(b - k + 1, b + 1)))
for i in l: 
  print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
l = range(a, b + 1) if b - a + 1 <= k else sorted(set(range(a, a + k)) | set(range(b - k + 1, b + 1))):
for i in l: 
  print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
for x in sorted(set(a, b + 1) & (set(range(a, a + k)) | set(range(b - k + 1, b + 1)))):
  print(x)
Problem p03393 (python)

Fixed submission:
from collections import deque
from itertools import dropwhile

alphabet = set('abcdefghijklmnopqrstuvwxyz')

if __name__ == '__main__':
    s = input()
    l = [c for c in alphabet - set(s)]
    if l != []:
        print(s + min(l))
        quit(0)

    deq = deque()
    deq.append(s[-1])
    for i in range(24, -1, -1):
        if s[i] < s[i + 1]:
            small = next(dropwhile(lambda c: c <= s[i], deq))
            print(s[:i] + small)
            quit(0)
        else:
            deq.append(s[i])

    print(-1)

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

alphabet = set('abcdefghijklmnopqrstuvwxyz')

if __name__ == '__main__':
    s = input()
    l = [c for c in alphabet - set(s)]
    if l != []:
        print(s + min(l))
        quit(0)

    deq = deque()
    deq.append(s[-1])
    for i in range(24, -1, -1):
        if s[i] < s[i + 1]:
            small = next(dropwhile(lambda c <= s[i], deq))
            print(s[:i] + small)
            quit(0)
        else:
            deq.append(s[i])

    print(-1)

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

alphabet = set('abcdefghijklmnopqrstuvwxyz')

if __name__ == '__main__':
    s = input()
    l = [c for c in alphabet - set(s)]
    if l != []:
        print(s + min(l))
        quit(0)

    deq = deque()
    deq.append(s[-1])
    for i in range(24, -1, -1):
        if s[i] < s[i + 1]:
            small = dropwhile(lambda c <= s[i], deq)
            print(s[:i] + small)
            quit(0)
        else:
            deq.append(s[i])

    print(-1)
Problem p03408 (python)

Fixed submission:
from collections import defaultdict
dd = defaultdict(int)
n = int(input())
for s in (input() for _ in range(n)):
  dd[s] += 1
m = int(input())
for s in (input() for _ in range(m)):
  dd[s] -= 1
print(max(0, max(dd.values())))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
dd = defaultdict(int)
n = int(input())
for s in (input() for _ in range(n)):
  dd[s] += 1
m = int(input())
for s in (input() for _ in range(m)):
  dd[s] -= 1
print(max(0, dd.values()))
Problem p03415 (python)

Fixed submission:
print(''.join(s[i] for i, s in enumerate(input() for _ in range(3))))

Buggy submission (verdict: Runtime Error):
print(''.join(s[i][i] for i, s in enumerate(input() for _ in range(3))))
Problem p03470 (python)

Fixed submission:
print(len(set(int(input()) for _ in range(int(input())))))

Buggy submission (verdict: Runtime Error):
print(len(set(int(input()) for _ in range(int(input()))))
Problem p03502 (python)

Fixed submission:
def f(x):
  if x <= 0:
    return 0
  return (x%10)+f(x//10)

n = int(input())
fx = f(n)
ans = "Yes" if n % fx == 0 else "No"
print (ans)

Buggy submission (verdict: Runtime Error):
def f(x):
  if x <= 0:
    return 0
  return (x%10)+f(x//10)

n = int(input)
fx = f(n)
ans = "Yes" if n % fx == 0 else "No"
print (ans)
Problem p03534 (python)

Fixed submission:
from collections import Counter
c=sorted(Counter(input()).values(),reverse=True) + [0] * 2
print('YES' if c[2] == c[0] or c[2] + 1 == c[0] else 'NO')

Buggy submission (verdict: Runtime Error):
from collections import Counter
c=sorted(Counter(input()).values())
print('YES' if c[0] == c[2] or c[0] + 1 == c[2] else 'NO')
Problem p03568 (python)

Fixed submission:
from functools import reduce
n=int(input())
print(3**n-reduce(lambda x, y: x * y, (2-int(s)%2 for s in input().split())))

Buggy submission (verdict: Runtime Error):
from functools import reduce
n=int(input())
print(3**n-reduce(lambda x, y: x * y, 2-int(s)%2 for s in input().split()))
Problem p03680 (python)

Fixed submission:
n = int(input())
a = [0] + [int(input()) for _ in range(n)]
i = 1
c = 0
while True:
  if i == 2:
    print(c)
    quit(0)
  if a[i] == i:
    print(-1)
    quit(0)
  c += 1
  tmp = a[i]
  a[i] = i
  i = tmp

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
i = 1
c = 0
while True:
  if i == 2:
    print(c)
    quit(0)
  if a[i] == i:
    print(-1)
    quit(0)
  c += 1
  i, a[i] = a[i], i

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
i = 1
c = 0
while a[i] != i:
  if i == 2:
    print(c)
    quit(0)
  c += 1
  i, a[i] = a[i], i
print(-1)
Problem p03693 (python)

Fixed submission:
a,b,c=map(int,input().split())
print('NO' if (b*10+c)%4 else 'YES')

Buggy submission (verdict: Runtime Error):
print('NO' if int(''.join(map(int,input().split())))%4 else 'YES')

Buggy submission (verdict: Runtime Error):
print('NO' if int(''.join(map(int,input().split())))%4 else 'YES')
Problem p03711 (python)

Fixed submission:
d=[0,1,2,1,0,1,0,1,1,0,1,0,1]
a,b=map(int,input().split())
print('Yes' if d[a]==d[b] else 'No')

Buggy submission (verdict: Runtime Error):
d=[0,1,2,1,0,1,0,1,1,0,1,0,1]
a,b=map(int,input.split())
print('Yes' if d[a]==d[b] else 'No')
Problem p03814 (python)

Fixed submission:
import re
m = re.search(r'A.*Z', input())
print(m.end() - m.start())

Buggy submission (verdict: Runtime Error):
import re
m = re.match(r'A.*Z', input())
print(m.end() - m.start())

Buggy submission (verdict: Runtime Error):
import re
m = re.match(r'A.*Z', input())
print(m.end - m.start)
Problem p03856 (python)

Fixed submission:
from collections import deque

def solve(s):
    stack = deque()
    stack.append(s)
    while len(stack) > 0:
        top = stack.pop()
        if top == '':
            return 'YES'

        if top[:5] == 'dream':
            if top[5:7] == 'er':
                stack.append(top[7:])
            stack.append(top[5:])
        elif top[:5] == 'erase':
            if len(top) > 5 and top[5] == 'r':
                stack.append(top[6:])
            else:
                stack.append(top[5:])
    return 'NO'

print(solve(input()))

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

def solve(s):
    que = deque()
    que.append(s)
    while len(que) > 0:
        top = que.pop()
        if top == '':
            return 'YES'

        if top[:5] == 'dream':
            if top[5:7] == 'er':
                que.append(s[:7])
            que.append(s[:5])
        elif top[:5] == 'erase':
            if top[5] == 'r':
                que.append(top[:6])
            else:
                que.append(top[:5])
    return 'NO'

print(solve(input()))

Buggy submission (verdict: Runtime Error):
s = input()
while s != '':
    if s[:5] == 'dream' or s[:5] == 'erase':
        if s[5] == 'r':
            s = s[6:]
        else:
            s = s[5:]
    else:
        print('NO')
        quit(0)

print('YES')

Buggy submission (verdict: Runtime Error):
s = input()
while s != '':
    if s[:5] == 'dream' or s[:5] == 'erase':
        if s[5] = 'r':
            s = s[6:]
        else:
            s = s[5:]
    else:
        print('NO')
        quit(0)

print('YES')
Problem p03919 (python)

Fixed submission:
h,w=map(int, input().split())
for i in range(h):
  l = input().split()
  if 'snuke' in l:
    t=l.index('snuke')
    print('%s%d' % (chr(t+ord('A')), i+1))
    quit(0)

Buggy submission (verdict: Runtime Error):
h,w=map(int, input().split())
for i in range(h):
  t=input().split().index('snuke')
  if t<0:
    continue
  print('%s%d' % (chr(t+ord('A')), i+1))
  quit(0)

Buggy submission (verdict: Runtime Error):
h,w=map(int, input().split())
for i in range(h):
  t=input().split().find('snuke')
  if t<0:
    continue
  print('%s%d' % (chr(t+ord('A')), i+1))
  quit(0)
Problem p03997 (python)

Fixed submission:
print((int(input())+int(input()))*int(input())//2)

Buggy submission (verdict: Runtime Error):
print((int(input())+(int(input()))*int(input())//2)
Problem p03998 (python)

Fixed submission:
from collections import deque

def solve(top, sa, sb, sc):
  if len(s[top]) == 0:
    return top.upper()
  top = s[top].popleft()
  return solve(top, sa, sb, sc)
  
s = {}
s['a'] = deque(input())
s['b'] = deque(input())
s['c'] = deque(input())

top = s['a'].popleft()
print(solve(top, s['a'], s['b'], s['c']))

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

def solve(top, sa, sb, sc):
  if len(s[top]) == 0:
    return top.upper()
  top = s[top].popleft()
  return solve(top, sa, sb, sc)
  
s = {}
s['a'] = deque(input())
s['b'] = deque(input())
s['c'] = deque(input())

top = s['a'].popleft()
print(solve(top, sa, sb, sc))

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

def solve(top, sa, sb, sc):
  if len(s[top]) == 0:
    return top
  top = s[top].popleft()
  return solve(top, sa, sb, sc)
  
s = {}
s['a'] = deque(input())
s['b'] = deque(input())
s['c'] = deque(input())

top = s['a'].popleft()
print(solve(top, sa, sb, sc))
Problem p04011 (python)

Fixed submission:
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(x*min(n,k)+y*max(0,n-k))

Buggy submission (verdict: Runtime Error):
n=int(inout())
k=int(input())
x=int(input())
y=int(input())
print(x*k+y*max(0,n-k))
Problem p02861 (python)

Fixed submission:
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int, input().split())
d=0
for i,j in zip(x,y):
  for k,l in zip(x,y):
    m1,m2=i-k,j-l
    o=m1**2+m2**2
    d+=o**0.5
print(d/n)

Buggy submission (verdict: Runtime Error):
n=int(input())
x,y=[int(input()) for _ in range(n)],[int(input()) for _ in range(n)]
d=0
for i,j in zip(x,y):
  for k,l in zip(x,y):
    m1,m2=i-k,j-l
    o=m1**2+m2**2
    d+=o**0.5
print(d/n)

Buggy submission (verdict: Runtime Error):
n=int(input())
x,y=[int(input()) for _ in range(int(input()))],[int(input()) for _ in range(int(input()))]
d=0
for i,j in zip(x,y):
  for k,l in zip(x,y):
    m1,m2=i-k,j-l
    o=m1**2+m2**2
    d+=o**0.5
print(d/n)

Buggy submission (verdict: Runtime Error):
n=int(input())
x,y=[int(input()) for _ in range(int(input()))],[int(input()) for _ in range(int(input()))]
d=0
for i,j in zip(x,y):
  for k,l in zip(x,y):
    m=(i-k)**2+(j-l)**2
    d+=m**0.5
print(d/n)

Buggy submission (verdict: Runtime Error):
n=int(input())
x,y=[int(input) for _ in range(int(input()))],[int(input) for _ in range(int(input()))]
d=0
for i,j in zip(x,y):
  for k,l in zip(x,y):
    m=(i-k)**2+(j-l)**2
    d+=m**0.5
print(d/n)
Problem p02888 (python)

Fixed submission:
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ans=0
ans1=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+ans1,n):
      ans1=0
      if l[i]+l[j]>l[-1]:
        ans+=n-j-1
        break
      elif l[i]+l[j]<=l[k] :
        ans+=k-j-1
        ans1+=k-j-1
        break
      
      
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      elif l[i]+l[j]>l[-1]:
        ans+=n-j-1
        break
      if l[i]+l[j]<=l[k] :
        ans+=k-j-1
        ans1+=k-j-1
        break
      
      
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ans=0
ans1=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+ans1,n):
      ans1=0
      elif l[i]+l[j]>l[-1]:
        ans+=n-j-1
        break
      if l[i]+l[j]<=l[k] :
        ans+=k-j-1
        ans1+=k-j-1
        break
      
      
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+ans1,n):
      ans1=0
      elif l[i]+l[j]>l[-1]:
        ans+=n-j-1
        break
      if l[i]+l[j]<=l[k] :
        ans+=k-j-1
        ans1+=k-j-1
        break
      
      
print(ans)