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

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

n,q = map(int,input().split())
ab = [list(map(int,input().split()))for i in range(n-1)]
px = [list(map(int,input().split()))for i in range(q)]

def dfs(m):
    for i in range(len(adj[m])):
        if depth[adj[m][i]] == float('inf'):
            depth[adj[m][i]] = depth[m] + 1
            point[adj[m][i]] += point[m]
            dfs(adj[m][i])


point = [0]*(n+1)
depth = [float('inf')]*(n+1)
adj = [[]for _ in range(n+1)]

for i in range(n-1):
    adj[ab[i][0]].append(ab[i][1])
    adj[ab[i][1]].append(ab[i][0])

for i in range(q):
    point[px[i][0]] += px[i][1]

depth[1] = 1
dfs(1)

for i in range(1,n+1):
    print(point[i],end = ' ')










'''
n,q = map(int,input().split())
ab = [list(map(int,input().split()))for i in range(n-1)]
px = [list(map(int,input().split()))for i in range(q)]

def dfs(m):
    if m in vdic:
        for i in range(len(vdic[m])):
            point[vdic[m][i]] += point[m]
            dfs(vdic[m][i])

point = [0]*(n+1)

vdic = {}
for i in range(n-1):
    if ab[i][0] not in vdic:
        vdic[ab[i][0]] = []
    vdic[ab[i][0]].append(ab[i][1])

for i in range(q):
    point[px[i][0]] += px[i][1]

dfs(1)

for i in range(1,len(point)):
    print(point[i],end = ' ')

'''

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

n,q = map(int,input().split())
ab = [list(map(int,input().split()))for i in range(n-1)]
px = [list(map(int,input().split()))for i in range(q)]

def dfs(m):
    if m in vdic:
        for i in range(len(vdic[m])):
            point[vdic[m][i]] += point[m]
            dfs(vdic[m][i])

point = [0]*(n+1)

vdic = {}
for i in range(n-1):
    if ab[i][0] not in vdic:
        vdic[ab[i][0]] = []
    vdic[ab[i][0]].append(ab[i][1])

for i in range(q):
    point[px[i][0]] += px[i][1]
'''
for v in vdic:
    for c in vdic[v]:
        point[c] += point[v]
'''
dfs(1)

for i in range(1,len(point)):
    print(point[i],end = ' ')
Problem p02947 (python)

Fixed submission:
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
n = int(input())
ans = 0
sum = 0
ansdic = {}
for i in range(n):
  s = input()
  slist = [i for i in s]
  slist.sort()
  smoji = ','.join(slist)
  if smoji in ansdic:
    ansdic[smoji] += 1
  else:
    ansdic[smoji] = 1
for i in ansdic:
  if ansdic[i] > 1:
    sum += cmb(ansdic[i],2)
print(sum)

Buggy submission (verdict: Runtime Error):
memo = {2:1}
def cmb2(n):
  if n in memo:
    return memo[n]
  memo[n] = cmb2(n-1) + n - 1
  return memo[n]
n = int(input())
ans = 0
sum = 0
ansdic = {}
for i in range(n):
  s = input()
  slist = [i for i in s]
  slist.sort()
  smoji = ','.join(slist)
  if smoji in ansdic:
    ansdic[smoji] += 1
  else:
    ansdic[smoji] = 1
for i in ansdic:
  if ansdic[i] > 1:
    sum += cmb2(ansdic[i])
print(sum)

Buggy submission (verdict: Runtime Error):
from math import factorial
def cmb(n,r):
  a = factorial(n) / factorial(r) / factorial(n - r)
  return a
n = int(input())
slist = []
cnt = 0
for i in range(n):
  s = input()
  s = sorted(s)
  
  s = ''.join(s)
  slist.append(s)
sset = set(slist)
stup = tuple(sset)
for i in range(len(sset)):
  if slist.count(stup[i]) >= 2:
    cnt += cmb(slist.count(stup[i]),2)
print(int(cnt))
Problem p02995 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
all_val = b-a+1
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
if a%c == 0:
  c_val = b//c-a//c+1
else:
  c_val = b//c-a//c
if a%d == 0:
  d_val = b//d-a//d+1
else:
  d_val = b//d-a//d
if a%lcm(c,d) == 0:
  lcm_val = b//lcm(d,c)-a//lcm(d,c)+1
else:
  lcm_val = b//lcm(d,c)-a//lcm(d,c)
print(all_val-c_val-d_val+lcm_val)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
all_val = b-a+1
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
if a%c == 0:
  c_val = b//c-a//c+1
else:
  c_val = b//c-a//c
if a%d == 0:
  d_val = b//d-a//d+1
else:
  d_val = b//d-a//d
if a%lcm(c,d) == 0:
  lcm_val = b//lcm(d,c)-a//lcm(d,c)+1
else:
  lcm_val = b//lcm(d,c)-a//lcm(d,c)
print(all_val-c_val-d_val+lcm_val)
Problem p03043 (python)

Fixed submission:
import math
n,k = map(int,input().split())
sumlist = []
for i in range(1,n+1):
  point = i
  if point <= k-1:
    s = math.log(k/i,2)
    if s == int(s):
      sumlist.append((1/2)**(int(s)))
    else:
      sumlist.append((1/2)**(int(s)+1))
  else:sumlist.append(1)
print(round(sum(sumlist)/n,10)-10**(-10))

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
sumlist = []
for i in range(1,n+1):
  point = i
  if point <= k-1:
    s = math.log2(k/i)
    if s == int(s):
      sumlist.append((1/2)**(int(s)))
    else:
      sumlist.append((1/2)**(int(s)+1))
  else:sumlist.append(1)
print(round(sum(sumlist)/n,10)-10**(-10))

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
sum = 0
for i in range(1,n+1):
  point = i
  if point <= k-1:
    s = math.log2(k/i)
    if s == int(s):
      sum += (1/2)**(int(s))
    else:
      sum += (1/2)**(int(s)+1)
  else:sum += 1
print(round(sum/n,10)-10**(-10))

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
sum = 0
for i in range(1,n+1):
  point = i
  if point <= k-1:
    s = math.log2(k/i)
    if s == int(s):
      sum += (1/2)**(int(s))
    else:
      sum += (1/2)**(int(s)+1)
  else:sum += 1
print(round(sum/n,10))
Problem p03061 (python)

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

from fractions import gcd
left = [a[0]]
right = [0]*n
right[-1] = a[-1]

for i in range(1,n):
    left.append(gcd(left[-1], a[i]))

for i in range(n-2,-1,-1):
    right[i] = gcd(a[i], right[i+1])

ans = 0
for i in range(n):
    if i == 0:
        ans = max(ans,right[i+1])
    elif i == n-1:
        ans = max(ans, left[i-1])
    else:
        ans = max(ans, gcd(left[i-1],right[i+1]))

print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
alist = list(map(int,input().split()))
aalist = alist[:]
mx = 0
for i in range(n):
    alist.pop(i)
    for j in range(1,n-1):
            alist[j] = math.gcd(alist[j], alist[j-1])
    mx = max(mx,alist[n-2])
    alist = aalist[:]
print(mx)
Problem p03087 (python)

Fixed submission:
n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split()))for i in range(q)]

a = [0]*n
p = 0
for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        p += 1
    a[i] = p
ans = []
for i in range(q):
    ans.append(a[lr[i][1]-1]-a[lr[i][0]-1])
for i in range(q):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = input()
anslist = []
anslist2 = [0]*q
for i in range(n):
  if s[i] == 'A' and s[i+1] == 'C':
    anslist.append([i+1,i+2])
for i in range(q):
  l,r = map(int,input().split())
  cnt = 0
  for j in range(len(anslist)):
    if l <= anslist[j][0] and anslist[j][1] <= r:
      cnt += 1
  anslist2[i] = cnt
for i in range(q):
  print(anslist2[i])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for i in range(q)]
anslist = []
for i in range(n):
  if s[i] == 'A' and s[i+1] == 'C':
    anslist.append([i,i+1])
for i in range(q):
  cnt = 0
  for j in range(len(anslist)):
    if lr[i][0]-1 <= anslist[j][0] and anslist[j][1] <= lr[i][1]-1:
      cnt += 1
  print(cnt)
Problem p03161 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [10**9]*n
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i-j >= 0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
imort sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [10**10]*n
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if i-j >= 0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[n-1])
Problem p03379 (python)

Fixed submission:
n = int(input())

xx = list(map(int,input().split()))
x = sorted(xx)

left = x[n//2-1]
right = x[n//2]
mid = (left+right)/2

for i in range(n):
    if xx[i] >= mid:
        print(left)
    else:print(right)

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

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

from statistics import median

for i in range(n):
    print(median(x[:i]+x[i+1:]))
Problem p03625 (python)

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

adic = {}
for i in range(n):
    if a[i] not in adic:
        adic[a[i]] = 0
    adic[a[i]] += 1

alist = sorted(adic.items(),reverse = True)
before = 0
after = 0

for i in range(len(alist)):
    if before == 0:
        if alist[i][1] >= 4:
            before = alist[i][0]
            after = alist[i][0]
            break
        elif alist[i][1] >= 2:
            before = alist[i][0]
    else:
        if alist[i][1] >= 2:
            after = alist[i][0]
            break
print(before * after)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
cnts = [0]*(a[-1]+1)
cnt2 = []
cnt4 = []
for i in range(len(a)):
    cnts[a[i]] += 1
    if cnts[a[i]] == 2:
        cnt2.append(a[i])
    if cnts[a[i]] == 4:
        cnt2.remove(a[i])
        cnt4.append(a[i])
ans = 0
if len(cnt2) <= 1 and not(cnt4):
    print(0)
else:
    if len(cnt2) >= 2:
        ans = max(ans, cnt2[-1]*cnt2[-2])
    if cnt4:
        ans = max(ans, cnt4[-1]**2)
    
    print(ans)
Problem p03761 (python)

Fixed submission:
n = int(input())
slist = [input()for i in range(n)]

alp = {chr(i):float('inf') for i in range(97,97+26)}

for i in range(len(slist)):
    sdic = {chr(i):0 for i in range(97,97+26)}
    for j in range(len(slist[i])):
        sdic[slist[i][j]] += 1
    
    for k in alp:
        alp[k] = min(alp[k],sdic[k])

alplist = sorted(list(alp.items()))
ans = ''
for i in range(26):
    ans += alplist[i][0]*alplist[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
slist = []
for i in range(n):
    s = sorted(list(input()))
    slist.append(s)

common = [s for s in slist[0]]

for i in range(1,n):
    poplist = []
    for j in range(len(common)):
        if common[j] in slist[i]:
            slist[i].remove(common[j])
        else:
            poplist.append(j)
    for j in range(len(poplist)):
        common.pop(poplist[j])
    #print(common)
common.sort()
print(''.join(common))

Buggy submission (verdict: Runtime Error):
n = int(input())
slist = []
for i in range(n):
    s = sorted(list(input()))
    slist.append(s)

common = [s for s in slist[0]]

for i in range(1,n):
    poplist = []
    for j in range(len(common)):
        if common[j] in slist[i]:
            slist[i].remove(common[j])
        else:
            poplist.append(j)
    for j in range(len(poplist)):
        common.pop(poplist[j])
    #print(common)

print(''.join(common))
Problem p03846 (python)

Fixed submission:
n = int(input())
cnts = [0]*n
alist = list(map(int,input().split()))
mod = 10**9+7

for i in range(n):
    cnts[alist[i]] += 1

p = n%2
if p == 1:
    cnts[0] += 1

for i in range(n):
    if p != (i%2):
        if cnts[i] != 2:
            print(0)
            exit()
    else:
        if cnts[i] != 0:
            print(0)
            exit()
print(pow(2,(n//2))%mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int,input().split()))
dic = {}
mod = 10**9+7
for i in range(n):
    if alist[i] not in dic:
        dic[alist[i]] = 0
    dic[alist[i]] += 1
k = 0
while n-k-1 >= 2:
    p = n-k-1
    if p == 0:
        if dic[p] != 1:
            print(0)
            exit()
    else:
        if dic[p] != 2:
            print(0)
            exit()
    k += 2
else:
    print(2**(n//2)%mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int,input().split()))
dic = {}
for i in range(n):
    if alist[i] not in dic:
        dic[alist[i]] = 0
    dic[alist[i]] += 1
k = 0
while n-k-1 >= 2:
    p = n-k-1
    if p == 0:
        if dic[p] != 1:
            print(0)
            exit()
    else:
        if dic[p] != 2:
            print(0)
            exit()
    k += 2
else:
    print(2**(n//2))

Buggy submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int,input().split()))
dic = {}
for i in range(n):
    if alist[i] not in dic:
        dic[alist[i]] = 0
    dic[alist[i]] += 1

k = -2
while n-1-k >= 2:
    k += 2
    if n-1-k != 0:
        if dic[n-1-k] != 2:
            print(0)
            exit()
    else:
        if dic[0] != 1:
            print(0)
            exit()

p = n//2
print(2**p)
Problem p02952 (python)

Fixed submission:
N=int(input())
c=0
for i in range(1, N+1):
    if (len(str(i))%2 == 1):
        c += 1
print(c)

Buggy submission (verdict: Runtime Error):
#another way:
def count_digits(n):
    d=0
    while(n>0):
        d += 1
        n = n//10
    return d
c=0
for i in range(1,N+1):
    if (count_digits(i)%2==1):
        c += 1
print(c)
Problem p02583 (python)

Fixed submission:
N = int(input())
L_list = list(map(int,input().split()))


counter = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            a = L_list[i]
            b = L_list[j]
            c = L_list[k]
            if a==b or b==c or c==a or a+b<=c or b+c<=a or c+a<=b:
                continue
            counter += 1


print(counter)

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


conter = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if a==b or b==c or c==a or a+b<=c or b+c<=a or c+a<=b:
                continue
            counter += 1


print(counter)
Problem p02584 (python)

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

y = abs(X)//D

if K<=y:
    print(abs(abs(X)-K*D))

else  :
    a = (abs(X)-y*D)
    b = (abs(X)-(y+1)*D)
    
    C = abs(a)
    D = abs(b)
    
    if (K-y)%2==0:
        print(C)
    else:
        print(D)


#print(y+1)
#print(1000000000000000)

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

y = abs(X)//D

if K<=y:
    print(abs(abs(X)-K*D))

else  :
    a = (X-y*D)
    b = (X-(y+1)*D)
    
    C = abs(a)
    D = abs(b)
    
    if (K-y)%2==0:
        print(C)
    else:
        print(D)


#print(y+1)
#print(1000000000000000)
Problem p02630 (python)

Fixed submission:
N = int(input())


A = list(map(int,input().split()))
ok = [0]*pow(10,6)
Q = int(input())

li = [list(map(int,input().split())) for i in range(Q)]

for i in range(N):
    ok[A[i]]+=1
memo1=0
memo2=0

S = sum(A)
for i in range(Q):

    S+=ok[li[i][0]]*(li[i][1]-li[i][0])
    print(S)
    a = ok[li[i][0]]
    ok[li[i][1]]+=a
    ok[li[i][0]]=0

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


A = list(map(int,input().split()))
ok = [0]*pow(10,5)
Q = int(input())

li = [list(map(int,input().split())) for i in range(Q)]

f):
    ok[A[i]]+=1
memo1=0
memo2=0

S = sum(A)
for i in range(Q):

    S+=ok[li[i][0]]*(li[i][1]-li[i][0])
    print(S)
    a = ok[li[i][0]]
    ok[li[i][1]]+=a
    ok[li[i][0]]=0
    
    if max(ok)==N:
        memo1=i
        memo2=ok.index(N)
        break



for i in range(memo1+1,Q):
    if li[i][0]==memo2:
        print(N*li[i][1])
        memo2=li[i][1]
    else:
        print(memo2*N)

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

A = list(map(int,input().split()))
ok = [0]*pow(10,5)
Q = int(input())

li = [list(map(int,input().split())) for i in range(Q)]

for i in range(N):
    ok[A[i]]+=1
memo=0

S = sum(A)
for i in range(Q):
    print(S + ok[li[i][0]]*(li[i][1]-li[i][0]))
    a = ok[li[i][0]]
    ok[li[i][1]]+=a
    ok[li[i][0]]=0
Problem p02683 (python)

Fixed submission:
N,M,X = map(int,input().split())
li = []
import numpy as np
C = []

for _ in range(N):
    c,*a = map(int,input().split())
    li.append(np.array(a))
    C.append(c)

counter = []

for i in range(1<<N):
    skill_li = np.zeros(M).astype(int)
    sum_price = 0
    for k in range(N):
        if (i>>k) & 1:
            skill_li += li[k]
            sum_price += C[k]
    if all(skill_li>=X):
        counter.append(sum_price)

if len(counter)==0:
    print(-1)
else:
    print(min(counter))

Buggy submission (verdict: Runtime Error):
N,M,X = map(int,input().split())
li = []
import numpy as np
C = []

for _ in range(N):
    c,*a = map(int,input().split())
    li.append(np.array(a))
    C.append(c)

counter = []

for i in range(1<<N):
    skill_li = np.zeros(M).astype(int)
    sum_price = 0
    for k in range(N):
        if (i>>k) & 1:
            skill_li += li[k]
            sum_price += C[k]
    if all(skill_li>=X):
        counter.append(sum_price)

if len(counter)==0:
    print(-1)
else:
    print(min(counter))

Buggy submission (verdict: Runtime Error):
N,M,X = map(int,input().split())
li = []
import numpy as np
C = []

for _ in range(M):
    c,*a = map(int,input().split())
    li.append(np.array(a))
    C.append(c)

counter = []

for i in range(1<<N):
    skill_li = np.zeros(M)
    sum_price = 0
    for k in range(N):
        if (i>>k) & 1:
            skill_li += li[k]
            sum_price += C[k]
    if all(skill_li>=X):
        counter.append(sum_price)
if len(counter)==0:
    print(-1)
else:
    print(min(counter))

Buggy submission (verdict: Runtime Error):
N,M,X = map(int,input().split())
li = []
import numpy as np
C = []

for _ in range(M):
    c,*a = map(int,input().split())
    li.append(np.array(a))
    C.append(c)

counter = []

for i in range(1<<N):
    skill_li = np.zeros(M)
    sum_price = 0
    for k in range(N):
        if (i>>k) & 1:
            skill_li += li[k]
            sum_price += C[k]
    if all(skill_li>=X):
        counter.append(sum_price)
if len(counter)==0:
    print(-1)
else:
    print(min(counter))
Problem p02705 (python)

Fixed submission:
print(int(input())*6.3)

Buggy submission (verdict: Runtime Error):
 print(int(input())*6.3)

Buggy submission (verdict: Runtime Error):
import math
print(2*math.pi*R)

Buggy submission (verdict: Runtime Error):
print(2*pi)
Problem p02706 (python)

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
for i in range(M):
    counter += A[i]
    
if N - counter>=0:
    print(N-counter)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
for i in range(M):
    counter += A[i]
    
if N - conter>=0:
    print(N-counter)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
for i in range(M):
    counter += A[i]
    
if N - conter>=0:
    print(N-counter)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
for i in range(M):
    counter += A[i]
    
if N - conter>=0:
    print(N-counter)
else:
    priont("-1")

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

for i in range(M):
    counter += A[i]
    
print(N-counter)
Problem p02747 (python)

Fixed submission:
S = input()
l = len(S)


judge=True
if l%2==0:
    for i in range(l//2):
        if not S[2*i:2*(i+1)]=="hi":
            judge=False
    if judge:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A,B,M = map(int,input().split())
A_li = list(map(int,input().split()))
B_li = list(map(int,input().split()))

inf = float("inf")
posibility = inf

for m in range(M):
    x,y,c=map(int,input().split())
    tmp_posibility=A_li[x-1]+B_li[y-1]-c
    posibility=min(posibility,tmp_posibility)
 

no_c = min(A_li)+min(B_li)
decition = min(posibility,no_c)

print(decition)
Problem p02755 (python)

Fixed submission:
A,B = map(int,input().split())
import math
A_se = set()
B_se = set()

for i in range(math.ceil(A/0.08),math.ceil((A+1)/0.08)):
    A_se.add(i)

for i in range(math.ceil(B/0.1),math.ceil((B+1)/0.1)):
    B_se.add(i)

C = A_se & B_se
if len(C)==0:
    print(-1)
else:
    print(min(C))

Buggy submission (verdict: Runtime Error):
import math
A_se = set()
B_se = set()

for i in range(math.ceil(A/0.08),math.ceil((A+1)/0.08)):
    A_se.add(i)

for i in range(math.ceil(B/0.1),math.ceil((B+1)/0.1)):
    B_se.add(i)

C = A_se & B_se
if len(C)==0:
    print(-1)
else:
    print(min(C))
Problem p02756 (python)

Fixed submission:
S = input()
Q = int(input())
flag = True
from collections import deque
que=deque(S)

for i in range(Q):
    a = input().split()
    if a[0]=="1":
        flag = not flag

    else:
        f = a[1]
        c = a[2]
        if f=="1":
            if flag:
                que.appendleft(c)
            else:
                que.append(c)
        else:
            if flag:
                que.append(c)
            else:
                que.appendleft(c)

if not flag:
    que.reverse()

print("".join(que))

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
counter =0

for q in range(Q):
    inpu_ = input()
    if len(inpu_)==1:
        counter += 1
    else:
        a,f,c = map(str,inpu_.split())
        if f=="1":
            if counter%2 == 1:
                S = S+c
            else:
                S = c+S

        else:
            if counter%2==1:
                S = c+S
            else: 
                S = S+c

if counter%2==1:
    S.reverse()
print(S)
Problem p02761 (python)

Fixed submission:
N,M = map(int,input().split())


li = ["#"]*N
A = "#"
if N==1:
    for i in range(M):
        s,c = map(int,input().split())
        if not c==A and not A=="#":
            print(-1)
            exit()
        else:
            A=c
  
    if A == "#":
        print(0)
    else:
        print(int(A))
    exit()
    

for i in range(M):
    s,c = map(int,input().split())
    if s==1 and c==0:
        print(-1)
        break

    if not li[s-1]=="#" and not li[s-1]==c:
        print(-1)
        break
    if li[s-1]=="#":
        li[s-1]=c
    
else:
    if li[0]=="#":
        li[0]=1
        
    num="".join(map(str,li))
    num_new=num.replace("#","0")
    print(num_new)

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


li = ["#"]*N
A = "#"
if N==1:
    s,c = map(int,input().split())
    if not c==A and not c=="#":
        print(-1)
        break
    else:
        A=c
else:   
    if A == "#":
        print(0)
    else:
        print(int(A))
    

for i in range(M):
    s,c = map(int,input().split())
    if s==1 and c==0:
        print(-1)
        break

    if not li[s-1]=="#" and not li[s-1]==c:
        print(-1)
        break
    if li[s-1]=="#":
        li[s-1]=c
    
else:
    if li[0]=="#":
        li[0]=1
        
    num="".join(map(str,li))
    num_new=num.replace("#","0")
    print(num_new)

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

memo = [0]*N

for i in range(M):
    s,c = map(int,input().split())
    if memo[s-1]==0:
        memo[s-1]=c
    elif s==1 and c==0:
        print(-1)
            break
    else:
        if not memo[s-1]==c:
            print(-1)
            break


else:
    if memo[0]==0:
        memo[0]=1
    
    counter = 0
    for iterration,k in enumerate(memo):
        counter += k*(10**(len(memo)-iterration-1))
    print(counter)

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

memo = [0]*N

for i in range(M):
    s,c = map(int,input().split())
    if memo[s-1]==0:
        memo[s-1]=c
    else:
        if not memo[s-1]==c:
            print(-1)
            break

else:
    if memo[0]==0:
        memo[0]=1
    
    counter = 0
    for iterration,k in enumerate(memo):
        counter += k*(10**(len(memo)-iterration-1))
    print(counter)