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

Fixed submission:
from itertools import combinations
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
n,m = map(int,input().split())
abc = [list(map(int,input().split())) for i in range(m)]
abc = [[abc[i][0]-1,abc[i][1]-1,abc[i][2]] for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b,c in abc:
  graph[a].append((b,c))
  graph[b].append((a,c))
v1,v2,edge = zip(*abc)
csr = csr_matrix((edge,(v1,v2)),shape = (n,n))
dist = floyd_warshall(csr, directed = False)
ans = 0
for i,j in combinations(range(n),2):
  fs1,fs2 = zip(*graph[i])
  if j in fs1:
    x = fs1.index(j)
    if fs2[x] > dist[i][j]:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
abc = [list(map(int,input().split())) for i in range(m)]
abc = [[abc[i][0]-1,abc[i][1]-1,abc[i][2]] for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b,c in abc:
  graph[a].append((b,c))
  graph[b].append((a,c))
v1,v2,edge = zip(*abc)
csr = csr_matrix((edge,(v1,v2)),shape = (n,n))
dist = floyd_warshall(csr, directed = False)
ans = 0
for i,j in combinations(range(n),2):
  fs1,fs2 = zip(*graph[i])
  if j in fs1:
    x = fs1.index(j)
    if fs2[x] > dist[i][j]:
      ans += 1
print(ans)
Problem p03844 (python)

Fixed submission:
a,op,b=input().split()
if op=="+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

Buggy submission (verdict: Runtime Error):
a,op,b=map(input().split())
if op=="+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

Buggy submission (verdict: Runtime Error):
a,op,b=map(int,input().split())
if op=="+":
  print(a+b)
else:
  print(a-b)
Problem p03862 (python)

Fixed submission:
N,x=map(int, input().split(' '))
a = list(map(int, input().split(' ')))
wa = [a[0]]+[a[i]+a[i+1] for i in range(N-1)]+[a[-1]]
ans = 0

for i in range(N):
    if wa[i] <= x:
        continue
    if wa[i] > x:
        dif = wa[i]-x
        ans += dif
        a[i] -= dif
        wa[i] -= dif
        wa[i+1] -= dif
        continue

if wa[-1] > x:
    ans += wa[-1]-x
    a[-1] = wa[-1]-x
    wa[-1] -= wa[-1]-x

print(ans)

Buggy submission (verdict: Runtime Error):
N,x=map(int, input().split(' '))
a = list(map(int, input().split(' ')))
wa = [a[0]]+[a[i]+a[i+1] for i in range(N-1)]+[a[-1]]
ans = 0

for i in range(N):
    print(i, a,wa,ans)
    if wa[i] <= x:
        continue
    if a[i] >= x:
        ans += wa[i]-x
        a[i] -= wa[i]-x
        wa[i] -= wa[i]-x
        wa[i+1] -= wa[i+1]-x
        continue
    if a[i] < x:
        ans += wa[i]-x
        a[i] = 0
        a[i] = x
        wa[i] = x

print(ans)
Problem p03937 (python)

Fixed submission:
h,w=map(int,input().split())
bd = [list("."+input()+".") for i in range(h)]
bd.insert(0,["."]*(w+2))
bd.append(["."]*(w+2))
stack=[(1,1)]
while(stack):
  i,j=stack.pop()
  if i == h and j == w:
    bd[i][j]="."
    break
  if bd[i+1][j] == bd[i][j+1]:
    print("Impossible")
    exit()
  if bd[i-1][j] == "#" or bd[i][j-1] == "#":
    print("Impossible")
    exit()
  if bd[i+1][j] == "#":
    stack.append((i+1,j))
  if bd[i][j+1] == "#":
    stack.append((i,j+1))
  bd[i][j] = "."
if bd == [["." for i in range(w+2)] for j in range(h+2)]:
  print("Possible")
else:
  print("Impossible")

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
bd = [[.]+list(input().split())+[.] for i in range(h)]
bd.insert(0,[.]*(w+1))
bd.append([.]*(w+1))
for i in range(h):
  for j in range(w):
    if bd[i][j] == "#":
      if i == h and j == w:
        print("Possible")
        break
      if bd[i+1][j] == bd[i+1][j]:
        print("Impossible")
        break
      if bd[i-1][j] == "#" or bd[i][j-1] == "#":
        print("Impossible")
        break
      bd[i][j]="."
Problem p03946 (python)

Fixed submission:
n,t=map(int,input().split())
a=list(map(int,input().split()))
lmin=[a[0]]
rmax=[a[-1]]
for i in range(1,n):
  if a[i]<=lmin[-1]:
    lmin.append(a[i])
  else:
    lmin.append(lmin[-1])
  if a[-i-1]>=rmax[-1]:
    rmax.append(a[-i-1])
  else:
    rmax.append(rmax[-1])
mxls=[rmax[-i-2]-lmin[i] for i in range(n-1)]
mxls.append(-10**18)
ans=0
mx=max(mxls)
for i in range(n-1):
  if mxls[i]==mx and mxls[i]!=mxls[i+1]:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
a=list(map(int,input().split()))
b=[[a[i],i] for i in range(n)]
b.sort(reverse=True)
lmin=[a[0]]
rmax=[max(a[1:])]
mxls=[rmax[0]-lmin[0]]
mx=0
mn=n-1
for i in range(1,n):
  if a[i]<=b[mn]:
    mn-=1
  if a[i]>=b[mx]:
    mx+=1
  lmin.append(b[mn])
  rmax.append(b[mx])
  mxls.append(b[mx]-b[mn])
print(mxls.count(max(mxls)))
Problem p03952 (python)

Fixed submission:
n,x=map(int,input().split())
if n==2:
  if x==2:
    print("Yes",1,2,3,sep="\n")
    exit()
  else:
    print("No")
    exit()
if x==1 or x==n*2-1:
  print("No")
  exit()
ans=[i for i in range(1,2*n)]
for i in range(len(ans)):
  ans[i]=(ans[i]-(n-x+1))%(2*n-1)+1
print("Yes",*ans,sep="\n")

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
if n==2:
  if x==2:
    print("Yes",1,2,3,sep="\n")
    exit()
  else:
    print("No")
    exit()
if x==1 or x==n*2-1:
  print("No")
  exit()
ans=[i for i in range(1,2n)]
for i in range(len(ans)):
  ans[i]=(ans[i]-(n-x+1))%(2*n-1)+1
print("Yes",ans,sep="\n")
Problem p03957 (python)

Fixed submission:
s=input()
n=len(s)
t = 1000
u = 1000
for i in range(n):
  if s[i] == "C":
    t = i
    break
for i in range(n-1,-1,-1):
  if s[i] == "F":
    u = i
    break
if max(t,u) != 1000 and t<u:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
t = 1000
u = 1000
for i in range(n):
  if s[i] == "C":
    t = i
    break
for i in range(n-1,-1,-1):
  if s[i] == "F":
    u = i
    break
if max(t,u) != 1000 and t<u:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
t,u = 1000
for i in range(n):
  if s[i] == "C":
    t = i
    break
for i in range(n-1,-1,-1):
  if s[i] == "F":
    u = i
    break
if max(t,u) != 1000 and t<u:
  print("Yes")
else:
  print("No")
Problem p03962 (python)

Fixed submission:
print(len(set(list(map(int,input().split())))))

Buggy submission (verdict: Runtime Error):
print)(len(set(list(map(int,input().split()))))
Problem p03973 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 2
ans = a[0]-1
for i in range(1,n):
  if a[i] == cnt:
    cnt += 1
  else:
    ans += (a[i]-1)//cnt
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 1
ans = 0
for i in range(n):
  if a[i] = cnt+1:
    cnt += 1
  else:
    ans += (a[i]-1)//cnt
    if cnt == 1:
      cnt += 1
print(ans)
Problem p03993 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  j = a[i]-1
  if a[j] == i+1:
    ans+=1
print(ans//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  j = a[i]
  if a[j] == i:
    ans+=1
print(ans//2)
Problem p03994 (python)

Fixed submission:
a=input()
n=len(a)
m=int(input())
ans=""
for i in range(n-1):
  if a[i]=="a":
    ans += "a"
    continue
  x=ord(a[i])-97
  if m>=26-x:
    ans += "a"
    m -= 26-x
  else:
    ans += a[i]
ans += chr((ord(a[n-1])-97+m)%26+97)
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
n=int(input())
ans=""
for i in range(n-1):
  x=ord(a[i])-97
  if n>=123-x:
    ans += "a"
    n -= 123-x
  else:
    ans += a[i]
ans += chr((ord(a[i])-97+n)%26+97)
print(ans)
Problem p03997 (python)

Fixed submission:
a= int(input())
b= int(input())
h=int(input())
print((a+b)*h//2)

Buggy submission (verdict: Runtime Error):
a,b,h=map(int,input().split())
print((a+b)*h//2)
Problem p03998 (python)

Fixed submission:
from collections import deque
A=deque(list(input()+"A"))
B=deque(list(input()+"B"))
C=deque(list(input()+"C"))
x=A.popleft()
while(True):
  if x == "a":
    x = A.popleft()
  elif x == "b":
    x = B.popleft()
  elif x == "c":
    x = C.popleft()
  else:
    break
print(x)

Buggy submission (verdict: Runtime Error):
from collections import deque
A=deque(list(input()+"A"))
B=deque(list(input()+"B"))
C=deque(list(input()+"C"))
x=A.pop()
while(True):
  if x == "a":
    x = A.pop()
  elif x == "b":
    x = B.pop()
  elif x == "c:
    x = C.pop()
  elif x == "A":
    x = a
    break
  elif x == "B":
    x = b
    break
  elif x == "C":
    x = c
    break
print(x)
Problem p04014 (python)

Fixed submission:
n = int(input())
s = int(input())
x = int(n**0.5)+1
def dsum(x,t):
  ret = 0
  while x>0:
    ret += x%t
    x //= t
  return ret
for i in range(2,x+1):
  if dsum(n,i) == s:
    print(i)
    exit()
for i in range(x,0,-1):
  if (n-(s-i))%i == 0:
    digit = (n-(s-i))//i
    if 0 < i < digit and 0 <= s-i < digit:
      print((n-(s-i))//i)
      exit()
if n == s:
  print(n+1)
  exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n,s=int(input())
if n*2<=s+1:
  print(s-n+1)
else:
  print(-1)
Problem p04020 (python)

Fixed submission:
n=int(input())
a = [int(input()) for i in range(n)]
a.append(0)
ans = 0
tmp = 0
for i in range(n+1):
  if a[i]!=0:
    tmp += a[i]
  else:
    ans += tmp//2
    tmp = 0
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = [int(input()) for i in range(n)]
a.append(0)
ans = 0
for i in range(n+1):
  if a[i]!=0:
    tmp += a[i]
  else:
    ans += tmp//2
    tmp = 0
print(ans)
Problem p04032 (python)

Fixed submission:
s=input()
if len(s)==2:
  if s[0]==s[1]:
    print(1,2)
  else:
    print(-1,-1)
else:
  for i in range(len(s)-2):
    if len(set((s[i],s[i+1],s[i+2])))!=3:
      print(i+1,i+3)
      break
  else:
    print("-1 -1")

Buggy submission (verdict: Runtime Error):
s=input()
for i in range(len(s)-2):
  if len(set(s[i],s[i+1],s[i+2]))!=3:
    print(i+1,i+3)
    break
else:
  print("-1 -1")
Problem p04034 (python)

Fixed submission:
N, M = map(int, input().split(' '))
X = []
for i in range(M):
    X.append(list(map(int, input().split(' '))))

num_b = [1 for i in range(N+1)]
num_b[0] = 0
psb = [0]*(N+1)
psb[1] = 1
for i in range(M):
    num_b[X[i][0]] -= 1
    num_b[X[i][1]] += 1
    if psb[X[i][0]] == 1:
        psb[X[i][1]] = 1 
    if num_b[X[i][0]] == 0:
        psb[X[i][0]] = 0

print(psb.count(1))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split(' '))
X = []
for i in range(N):
    X.append(list(map(int, input().split(' '))))

num_b = [i+1 for i in range(N)]
psb = [0]*N
psb[0] = 1

for i in X:
    num_b[i[0]] -= 1
    num_b[i[1]] += 1
    if num_b[i[0]] == 0:
        psb[i[0]] = 0
    if psb[i[0]] == 1:
        psb[i[1]] == 1 

print(psb.count(1))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split(' '))
X = []
for i in range(N):
    X.append(list(map(int, input().split(' '))))

num_b = [i+1 for i in range(N)]
psb = [0]*N
psb[0] = 1

for i in X:
    num_b[[i][0]] -= 1
    num_b[[i][1]] += 1
    if num_b[[i][0]] == 0:
        psb[[i][0]] = 0
    if psb[[i][0]] == 1:
        psb[[i][1]] == 1 

print(psb.count(1))
Problem p02630 (python)

Fixed submission:
n = int(input())
m = {}
tot = 0
for a in map(int,input().split()):
  tot += a
  if a not in m:
    m[a]=0
  m[a] += 1
q = int(input())
for step in range(q):
  b,c = map(int,input().split())
  if c not in m:
    m[c] = 0
  if b in m:
    m[c] += m[b]
    tot += m[b]*(c-b)
    m[b] = 0
  print(tot)

Buggy submission (verdict: Runtime Error):
n = int(input())
m = {}
tot = 0
for a in map(int,input().split()):
  tot += m
  if a not in m:
    m[a]=0
  m[a] += 1
q = int(input())
for step in range(q):
  b,c = map(int,input().split())
  if c not in m:
    m[c] = 0
  if b in m:
    m[c] += m[b]
    tot += m[b]*(c-b)
    m[b] = 0
  print(tot)
Problem p03263 (python)

Fixed submission:
h,w = map(int,raw_input().split())
a=[map(int,raw_input().split()) for _ in range(h)]
ret = []
for y in range(h):
    for x in range(w-1):
        if a[y][x]%2==1:
            ret.append((y,x,y,x+1))
            a[y][x+1]+=1
for y in range(h-1):
    if a[y][-1]%2==1:
        ret.append((y,w-1,y+1,w-1))
        a[y+1][-1]+=1
print len(ret)
for seq in ret:
    a,b,c,d = seq
    print a+1,b+1,c+1,d+1

Buggy submission (verdict: Runtime Error):
h,w = map(int,raw_input().split())
a=[map(int,raw_input().split()) for _ in range(h)]
ret = []
for y in range(h):
    for x in range(w-1):
        if a[y][x]%2==1:
            ret.append((y,x,y,x+1))
            a[y][x+1]+=1
for y in range(h-1):
    if a[y][-1]==1:
        ret.append((y,w-1,y+1,w-1))
        a[y+1][-1]+=1
print len(seq)
for seq in ret:
    a,b,c,d = seq
    print a+1,b+1,c+1,d+1
Problem p03281 (python)

Fixed submission:
n=input()
print sum(1 for k in range(1,n+1,2) if sum(1 for v in range(1,k+1) if k%v==0)==8)

Buggy submission (verdict: Runtime Error):
n=input()
print len(0 for k in range(1,n+1,2) if sum(1 for v in range(1,k+1) if k%v==0)==8)
Problem p03283 (python)

Fixed submission:
n,m,q=map(int,raw_input().split())
lrs=[map(int,raw_input().split()) for _ in range(m)]
a=[[0 for j in range(n)] for i in range(n)]
for l,r in lrs:a[l-1][r-1]+=1
cnt=[[0 for j in range(n)] for i in range(n)]
for y in range(n):
 v = 0
 for x in range(y,-1,-1):
  v+=a[x][y]
  cnt[x][y]=cnt[x][y-1]+v
for _ in range(q):
 l,r=map(int,raw_input().split())
 print cnt[l-1][r-1]

Buggy submission (verdict: Runtime Error):
n,m,q=map(int,raw_input().split())
lrs=[map(int,raw_input().split()) for _ in range(m)]
a=[[0 for j in range(n)] for i in range(n)]
for l,r in lrs:a[l-1][r-1]+=1
cnt=[[0 for j in range(n)] for i in range(n)]
for y in range(n):
 v = 0
 for x in range(y+1):
  v+=a[x][y]
  cnt[x][y]=cnt[x][y-1]+v
for _ in range(q):
 l,r=map(int,raw_input().split())
 print cnt[l][r]
Problem p03287 (python)

Fixed submission:
n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
b=[0]
for v in a:b.append((b[-1]+v)%m)
ret = 0
z = {}
for c in b:
 if c not in z:z[c]=1
 else:
  ret+=z[c]
  z[c]+=1
print ret

Buggy submission (verdict: Runtime Error):
n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
b=[0]
for v in a:b.append((b[-1]+v)%m)
ret = 0
z = {}
for c in v:
 if c not in z:z[c]=1
 else:
  ret+=z[c]
  z[c]+=1
print ret
Problem p03288 (python)

Fixed submission:
R=input()
if R<1200:print "ABC"
elif R<2800:print "ARC"
else:print "AGC"

Buggy submission (verdict: Runtime Error):
R=input()
if R<1200:print "ABC"
elif E<2800:print "ARC"
else:print "AGC"
Problem p03289 (python)

Fixed submission:
s=raw_input()
if s[0]=="A" and len(s)>=3 and s.count("C")==1 and s[-1]!="C" and s[1]!="C" and all(x not in s[1:] for x  in"ABDEFGHIJKLMNOPQRSTUVWXYZ"):print "AC"
else:print "WA"

Buggy submission (verdict: Runtime Error):
s=input()
if s[0]=="A" and s.count("C")==1 and s[-1]!="C" and s[1]!="C" and all(x not in s for x  in"ABDEFGHIJKLMNOPQRSTUVWXYZ"):print "AC"
else:print "WA"
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split())
if b == 1:
  print(0)
  exit()
for i in range(1,21):
  if (a-1)*i+1 >= b:
    print(i)
    exit()
print(0)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input.split())
ans = int((b-1)/(a-1))+1
print(ans)
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
maxl = [0]*n

for i in range(n-2,-1,-1):
  if h[i] >= h[i+1]:
    maxl[i] = maxl[i+1]+1
  else:
    maxl[i] = 0
  
tmp_max = max(maxl)
print(tmp_max)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
tmp_max = 0
for i in range(0,n-1):
  tmp = 0
  for j in range(i, n-1):
    if h[j+1] <= h[j]:
      tmp += 1
  if tmp > tmp_max:
    tmp_max = tmp
print(tmp)
Problem p02927 (python)

Fixed submission:
m, d = map(int, input().split())
ans = 0

for mon in range(1,m+1):
  for day in range(1, d+1):
    d1 = day%10
    d10 = int(day/10)
    if d1 >= 2 and d10 >= 2:
      if d1*d10 == mon:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
m, d = map(int, input().split())
ans = 0

for mon in m:
  for day in d:
    d1 = day%10
    d10 = int(day/10)
    if d1 >= 2 and d10 >= 2:
      if d1*d10 == mon:
        ans+=1
print(ans)
Problem p02971 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
max_a = max(a)
if a.count(max(a)) == 1:
  sec_max = sorted(a)[-2]
else:
  sec_max = max_a

for i in range(n):
  if a[i] == max_a:
    print(sec_max)
  else:
    print(max_a)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
max_list = a.index(max(a))
max_a = max(a)
if len(max_list) == 1:
  sec_max = sorted(a)[1]
else:
  sec_max = max_a

for i in range(n):
  if i in max_list:
    print(sec_max)
  else:
    print(max_a)
Problem p02981 (python)

Fixed submission:
n, b, c = map(int, input().split())
print(min(n*b, c))

Buggy submission (verdict: Runtime Error):
a, b, c = int(input().split())
print(min(a*b,c))
Problem p02982 (python)

Fixed submission:
import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = list(map(int, input().split()))
result = 0
for i in range(0,n-1):
  for j in range(i+1,n):
    diff = list(map(lambda x,y: pow(x-y,2), x[i], x[j]))
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)

Buggy submission (verdict: Runtime Error):
import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = map(int, input().split())
 
result = 0
for i in range(n):
  for j in range(1,n):
    diff = map(lambda x: x*x, x[i]-x[j])
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)
Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())
if r-l >=2019:
  print("0")
  exit()
la = l % 2019
ra = r % 2019
diff = ra - la
if diff <= 0:
  print("0")
  exit()
ans = 2019
for i in range(la, ra):
  for j in range(i+1, ra+1):
    mul = (i*j) % 2019
    if mul <= ans:
      ans = mul
print(int(ans))

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())
la = l % 2019
ra = r % 2019
diff = ra - la
if diff <= 0:
  diff+=2019
ans = None
for i in range(la, la+diff):
  for j in range(i+1, la+diff+1):
    mul = (i*j) % 2019
    if mul < ans:
      ans = mul
print(ans)
Problem p03029 (python)

Fixed submission:
A, P = map(int, input().split())
P += A*3
pi = int(P/2)
print (pi)

Buggy submission (verdict: Runtime Error):

N = int(input())
S=[0]*N
P=[0]*N 
for i in range(N):
    S[i], P[i] = input().split()
    P[i] = int(P[i])

S_mid = sorted(S, key=lambda idx: P[idx] )
fin = sorted(range(N), key=lambda idx: S_mid[idx])
for i in fin:
    print (i)

Buggy submission (verdict: Runtime Error):
A, P = input().split()
P += A*3
pi = int(P/3)
print (pi)

Buggy submission (verdict: Runtime Error):
A, P = raw_input().split()
P += A*3
pi = int(P/3)
print (pi)

Buggy submission (verdict: Runtime Error):
A, P = input()
P += A*3
pi = int(P/3)
print (pi)
Problem p03030 (python)

Fixed submission:
N = int(input())
sp=[[0]*3 for i in range(N)]
for i in range(N):
    sp[i][0], sp[i][1] = input().split()
    sp[i][1] = int(sp[i][1])
    sp[i][2] = i+1

sp = sorted(sp, key=lambda x:x[1], reverse=True)
sp = sorted(sp, key=lambda x:x[0])
for i in sp:
    print (i[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
sp=[[0]*3 for i in range(N)]
for i in range(N):
    sp[i][0], sp[i][1] = input.split()
    sp[i][1] = int(sp[i][1])
    sp[i][2] = i

sp = sorted(sp, key=lambda x:x[1])
sp = sorted(sp, key=lambda x:x[0])
for i in sp:
    print (i[2])

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

S_mid = sorted(S, key=lambda x:P[x])
S_fin = sorted(range(len(S_mid)), key=lambda idx:S_mid[idx])
# fin = sorted(range(N), key=lambda idx: S_mid[idx])
for i in fin:
    print (i)

Buggy submission (verdict: Runtime Error):

N = int(input())
S=[0]*N
P=[0]*N 
for i in range(N):
    S[i], P[i] = input().split()
    P[i] = int(P[i])

S_mid = sorted(S, key=lambda idx: P[idx] )
fin = sorted(range(N), key=lambda idx: S_mid[idx])
for i in fin:
print (i)
Problem p03378 (python)

Fixed submission:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
for i,j in enumerate(a):
  if j > x:
    cnt = i
    break
print(min(cnt, m-cnt))

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
print(min(sum(a[:a.index(x)+1]), sum(a[a.index(x)+1:])))
Problem p03645 (python)

Fixed submission:
N, M = map(int, input().split())
a = []
b = []
ikeru = [0]*(N+1)
for i in range(M):
    a_tmp, b_tmp = map(int, input().split())
    a.append(a_tmp)
    b.append(b_tmp)

for i in range(M):
    if a[i] == 1:
        ikeru[b[i]] = 1
ikeru_2 = [0]*(N+1)
for i in range(M):
    if ikeru[a[i]] == 1:
        ikeru_2[b[i]] = 1
if ikeru_2[N] == 1 or ikeru[N] == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
a = []
b = []
ikeru = [0]*(N+1)
for i in range(M):
    a_tmp, b_tmp = map(int, raw_input().split())
    a.append(a_tmp)
    b.append(b_tmp)

for i in range(M):
    if a[i] == 1:
        ikeru[b[i]] = 1
ikeru_2 = [0]*(N+1)
for i in range(M):
    if ikeru[a[i]] == 1:
        ikeru_2[b[i]] = 1
if ikeru_2[N] == 1 or ikeru[N] == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
a = []
b = []
ikeru = [0]*(N+1)
for i in range(M):
    a_tmp, b_tmp = map(int, raw_input().split())
    a.append(a_tmp)
    b.append(b_tmp)

for i in range(M):
    if a[i] == 1:
        ikeru[b[i]] = 1
ikeru_2 = [0]*(N+1)
for i in range(M):
    if ikeru[a[i]] == 1:
        ikeru_2[b[i]] = 1
if ikeru_2[N] == 1 || ikeru[N] == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, raw_input().split())
a = []
b = []
ikeru = [0]*(N+1)
for i in range(M):
    a_tmp, b_tmp = map(int, raw_input().split())
    a.append(a_tmp)
    b.append(b_tmp)

for i in range(M):
    if a[i] == 1:
        ikeru[b[i]] = 1
ikeru_2 = [0]*(N+1)
for i in range(M):
    if ikeru[a[i]] == 1:
        ikeru_2[b[i]] = 1
if ikeru_2[N] == 1 || ikeru[N] == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, raw_input().split())
a = []
b = []
ikeru = [0]*(N+1)
for i in range(M):
    a_tmp, b_tmp = map(int, raw_input().split())
    a.append(a_tmp)
    b.append(b_tmp)

for i in range(M):
    if a[i] == 1:
        ikeru[b[i]] = 1
if ikeru[N] == 1:
    print("POSSIBLE")
    sys.exit()
ikeru_2 = [0]*(N+1)
for i in range(M):
    if ikeru[a[i]] == 1:
        ikeru_2[b[i]] = 1
if ikeru_2[N] == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p03963 (python)

Fixed submission:
import sys

n, k = map(int, raw_input().split())
ans = k # first                                                                                                 
if n == 1 and k == 1:
    print ans
    sys.exit()
for i in range(n-1):
    ans *= k-1
print ans

Buggy submission (verdict: Runtime Error):
import sys

n, k = map(int, raw_input().split())
ans = k # first                                                                                                 
if n = 1 and k = 1:
    print ans
    sys.exit()
for i in range(n-1):
    ans *= k-1
print ans

Buggy submission (verdict: Runtime Error):
import sys

n, k = map(int, raw_input().split())
ans = k # first                                                                                                 
if n = 1 and k = 1:
    print ans
    sys.exit()
for i in range(n-1):
    ans *= k-1
Problem p03970 (python)

Fixed submission:
s = raw_input()

c = "CODEFESTIVAL2016"

ans  = 0
for i in range(len(c)):
    if s[i] != c[i]:
        ans += 1
print ans

Buggy submission (verdict: Runtime Error):
s = raw_input()

c = "CODEFESTIVAL2016"

ans  = 0
for i in range(len(c)):
    if s[i] != c[[i]:
                 ans += 1
print ans