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

Fixed submission:
n=int(input(""))
ain=input("").split(" ")
a={1:0,}
c=[]
for i in range(n):
    c+=[int(ain[i])]
s=sum(c)
for i in range(n):
    if (c[i] in a):
        a[c[i]]+=1
    else:
        a[c[i]]=1
q=int(input(""))
c=[]

for i in range(q):
    c=input("").split(" ")
    bb=int(c[0])
    cc=int(c[1])
    if (bb in a and a[bb]!=0):
        s+=(cc-bb)*a[bb]
        if (cc in a):
            a[cc]+=a[bb]
        else:
            a[cc]=a[bb]
        a[bb]=0
                              
    print(s)

Buggy submission (verdict: Runtime Error):
n=int(input(""))
ain=input("").split(" ")
a={1:0,}
c=[]
for i in range(n):
    c+=[int(ain[i])]
s=sum(c)
for i in range(n):
    if (c[i] in a):
        a[c[i]]+=1
    else:
        a[c[i]]=1
q=int(input(""))
c=[]
listb=[]
listc=[]
for i in range(q):
    c=+[input("").split(" ")]
    listb+=[int(c[i][0])]
    listc+=[int(c[i][1])]
    if (listb[i] in a and a[listb[i]]!=0):
        s+=(listc[i]-listb[i])*a[listb[i]]
        if (listc[i] in a):
            a[listc[i]]+=a[listb[i]]
        else:
            a[listc[i]]=a[listb[i]]
    
    print(s)

Buggy submission (verdict: Runtime Error):
n=int(input(""))
ain=input("").split(" ")
a=[]
for i in range(n):
    a+=[int(ain[i])]
q=int(input(""))
c=[]
listb=[]
listc=[]
for i in range(q):
    c+=[input("").split(" ")]
    listb+=[int(c[i][0])]
    if (listb[i] in a):
        listc+=[int(c[i][1])]
        for k in range(n):
            if (a[k]==listb[i]):
                a[k]=listc[i]
    print(sum(a))
Problem p02631 (python)

Fixed submission:
n=int(input(""))
a=[]
ans=[1]
ain=input("").split(" ")
for i in range(n):
    a+=[int(ain[i])]
s=a[1]
for i in range(n-2):
    s^=a[i+2]
ans[0]=s
for i in range(n-1):
    s=s^a[i]
    s^=a[i+1]
    ans+=[s]
b=[]
for i in range(n):
    b+=[str(ans[i])]
print(" ".join(b))

Buggy submission (verdict: Runtime Error):
n=int(input(""))
a=[]
ans=[1]
ain=input("").split(" ")
for i in range(n):
    a+=[int(ain[i])]
s=a[1]
for i in range(n-2):
    s^=a[i+2]
ans[0]=s
for i in range(n-1):
    s=s^a[i]
    s^=a[i+1]
    ans+=s
print(" ".join(ans))
Problem p02642 (python)

Fixed submission:
n=int(input(""))
aa=input("").split(" ")
lista=[]
for i in range(n):
    lista+=[int(aa[i])]
lista.sort()
listtf=[]
s=0
for i in range(lista[n-1]):
    listtf+=[True]
for i in range(n):
    
    if(listtf[lista[i]-1]):
        if(i<n-1 and lista[i]==lista[i+1]):
            s-=1
        s+=1
        t=1
        while(t*lista[i]<=lista[n-1]):
            listtf[lista[i]*t-1]=False
            t+=1
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input(""))
aa=input("").split(" ")
lista=[]
for i in range(n):
    lista+=[int(aa[i])]
lista.sort()
listtf=[]
s=0
for i in range(lista[n-1]):
    listtf+=[True]
for i in range(n):
    if(listtf[i]):
        if(i<n-1 and lista[i]==lista[i+1]):
            s-=1
        s+=1
        t=1
        while(t*lista[i]<lista[n-1]):
            listtf[lista[i]*t]=False
            t+=1
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input(""))
aa=input("").split(" ")
lista=[]
for i in range(n):
    lista+=[int(aa[i])]
s=0
lista.sort()
listde=set()
for i in range(n-1):
    if(lista[i]==lista[i+1]):
        listde.add(lista[i])
t=0
for i in range(n):
    t=0
    for k in listde:
        if (lista[i]%k==0):
            t=1
            break
    if (t==0):
        s+=1
        listde.ad(lista[i])
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input(""))
aa=input("").split(" ")
lista=[]
for i in range(n):
    lista+=[int(aa[i])]
s=0
lista.sort()
for i in range(n-1):
    for k in range(i+1):
        if(lista[i+1]%lista[k]==0):
            break
        else:
            if(k==i):
                s+=1
if(lista[0]!=lista[1]):
    s+=1
print(s)
                
        
        
        
    
5
Problem p02660 (python)

Fixed submission:
def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a





n=int(input(""))
s=0
if(n!=1):
    

    

    t=0
    lista=prime(n)
    #print(lista)
    
    c=lista[0]
    for i in lista:
        if (c==i):
            t+=1
        else:
            k=1
            while(t>=k):
                t-=k
                s+=1
                k+=1
            t=1
            c=i


    k=1
    while(t>=k):
        t-=k
        s+=1
        k+=1
        


            
        
        
    
    


print(s)

Buggy submission (verdict: Runtime Error):
def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a





n=int(input(""))

if(n!=1):
    

    s=0

    t=0
    lista=prime(n)
    aa=len(lista)
    c=lista[0]
    for i in lista:
        if (c==i):
            t+=1
        else:
            k=1
            while(t>=k):
                t-=k
                s+=1
                k+=1
            t=1
            c=i

    if(t!=1):
        k=1
        while(t>=k):
            t-=k
            s+=1
            k+=1
        


            
        
        
    
    
if(n==1):
    s==0

print(s)

Buggy submission (verdict: Runtime Error):
def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a








n=int(input(""))

s=0

t=0
lista=prime(n)
aa=len(lista)
c=lista[0]
for i in lista:
    if (c==i):
        t+=1
    else:
        k=1
        while(t>=k):
            t-=k
            s+=1
            k+=1
        t=1
        c=i

if(t!=1):
    k=1
    while(t>=k):
        t-=k
        s+=1
        k+=1
    


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

    print(s)

Buggy submission (verdict: Runtime Error):
def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a








n=int(input(""))
if(n==1):
    print(0)
s=0

t=0
lista=prime(n)
aa=len(lista)
c=lista[0]
for i in lista:
    if (c==i):
        t+=1
    else:
        k=1
        while(t>=k):
            t-=k
            s+=1
            k+=1
        t=1
        c=i

if(t!=1):
    k=1
    while(t>=k):
        t-=k
        s+=1
        k+=1
    


        
    
    
    
    
    

print(s)
Problem p02677 (python)

Fixed submission:
import math
inlist=input("").split(" ")
a=int(inlist[0])
b=int(inlist[1])
h=int(inlist[2])
m=int(inlist[3])
sita1=h*30+0.5*m
sita2=m*6
sita=sita1-sita2
d=a**2+b**2-2*a*b*math.cos(math.radians(sita))
e=math.sqrt(d)
print(e)

Buggy submission (verdict: Runtime Error):
import math
inlist=input("").split(" ")
a=int(inlist[0])
b=int(inlist[1])
h=int(inlist[2])
m=int(inlist[3])
sita1=h*30+0.5*m
sita2=h*6
sita=sita1-sita2
d=a**2+b**2-2*a*b*math.cos(math.radius(sita))
e=int(math.sqrt(d))
print(e)
Problem p02719 (python)

Fixed submission:
l=input("").split(" ")
n=int(l[0])
k=int(l[1])
s=n%k
ss=k-s
if(s<ss):
    print(s)
else:
    print(ss)

Buggy submission (verdict: Runtime Error):
n=int(input(""))
k=int(input(""))
s=n%k
ss=k-s
if(s<ss):
    print(s)
else:
    print(ss)
Problem p02760 (python)

Fixed submission:
a1=input("").split(" ")
a2=input("").split(" ")
a3=input("").split(" ")
lista=[]
listmp=[]
for k in range(3):
    listmp+=[int(a1[k])]
lista+=[listmp]
listmp=[]
for k in range(3):
    listmp+=[int(a2[k])]
lista+=[listmp]
listmp=[]
for k in range(3):
    listmp+=[int(a3[k])]
lista+=[listmp]
n=int(input(""))
listn=[]
for i in range(n):
    t=int(input(""))
    listn+=[t]
for i in range(3):
    for k in range(3):
        if(lista[i][k] in listn):
            lista[i][k]=0
p=0
for i in range(3):
    s=0
    for k in range(3):
        s+=lista[i][k]

    if(s==0):
            p=1
for i in range(3):
    s=0
    for k in range(3):
        s+=lista[k][i]

    if(s==0):
            p=1
s=0
for i in range(3):
    s+=lista[i][i]
if(s==0):
    p=1
s=0
for i in range(3):
    s+=lista[i][2-i]
if(s==0):
    p=1
if(p==1):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a1=input("").split(" ")
a2=input("").split(" ")
a3=input("").split(" ")
lista=[]
listmp=[]
for k in range(3):
    listmp+=[int(a1[i])]
lista+=[listmp]
listmp=[]
for k in range(3):
    listmp+=[int(a2[i])]
lista+=[listmp]
listmp=[]
for k in range(3):
    listmp+=[int(a3[i])]
lista+=[listmp]
n=int(input(""))
listn=[]
for i in range(n):
    t=int(input(""))
    listn+=[t]
for i in range(3):
    for k in range(3):
        if(lista[i][k] in listn):
            lista[i][k]=0
p=0
for i in range(3):
    s=0
    for k in range(3):
        s+=lista[i][k]

        if(s==0):
            p=1
for i in range(3):
    s=0
    for k in range(3):
        s+=lista[k][i]

        if(s==0):
            p=1
s=0
for i in range(3):
    s+=lista[i][i]
if(s==0):
    p=1
s=0
for i in range(3):
    s+=lista[i][2-i]
if(s==0):
    p=1
if(p==1):
    print("Yes")
else:
    print("No")
Problem p02772 (python)

Fixed submission:
n=int(input(""))
aa=input("").split(" ")
s=0
a=[]
for i in aa:
    a+=[int(i)]
for i in a:
    if(i%2==0):
        if(i%3!=0 and i%5!=0):
            s=1
if(s==0):
    print("APPROVED")
else:
    print("DENIED")

Buggy submission (verdict: Runtime Error):
n=int(input(""))
a=input("").split(" ")

for i in a:
    if(i%2==0):
        if(i%3!=0 and i%5!=0):
            print("DENIED")
            break
else:
    print("APPROVED")
Problem p02639 (python)

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

for i in range(5):
    if A[i] == 0:
        print(i + 1)
        break

Buggy submission (verdict: Runtime Error):
A = map(int, input().split())
for i in range(5):
	if (A[i] == 0):
		print(i+1)
        break

Buggy submission (verdict: Runtime Error):
import java.io.*;
import java.util.*;

public class five {
	static class InputReader {
		BufferedReader reader;
		StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens())
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			return tokenizer.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public void close() throws IOException {
			reader.close();
		}
	}

	public static void main(String[] args) throws IOException {
		InputReader f = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

		for (int i = 1; i <= 5; i++) {
			if (f.nextInt() == 0) {
				System.out.println(i);
				break;
			}
		}
		
		f.close();
		out.close();
	}
}
Problem p02657 (python)

Fixed submission:
A, B = map(int, input().split())
print(A * B)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())
print(A * B)
Problem p02700 (python)

Fixed submission:
A, B, C, D = [int(s) for s in input().split()]
turn = 0
while A > 0 and C > 0:
  if turn == 0:
    C -= B
    turn = 1
  else:
    A -= D
    turn = 0
if A > 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A, B, C, D = [int(s) for s in input().split()]
turn = 0
while A > 0 and C > 0:
  if turn == 0:
    C -= B
    turn = 1
  else:
    A -= D
  	turn = 0
if A > 0:
  print("Yes")
else:
  print("No")
Problem p02639 (python)

Fixed submission:
import numpy as np

X = np.array(input().split())

for i in range(len(X)):
    if (i+1) != int(X[i]):
        print(i+1)
        break;

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

if N == 0:
    print(X)
    exit()

P = input().split()
for i in range(len(P)):
    P[i] = int(P[i])

if X not in P:
    print(X)
    exit()

flag_p = True
flag_n = True

abs_num = 0
abs_num_p = X + 1
abs_num_n = X - 1
while True:

    if abs_num_p in P:
        flag_p = True
    else:
        flag_p = False

    if abs_num_n in P:
        flag_n = True
    else:
        flag_n = False

    if(flag_p == True & flag_n == True):
        abs_num_p += 1
        abs_num_n -= 1
        continue;
    elif(flag_p == True & flag_n == False):
        print(abs_num_n)
        break;
    elif(flag_p == False):
        print(abs_num_p)
        break;
Problem p02630 (python)

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

lst = [0] * (10**5+1)
for A in As:
    lst[A] += 1

val = sum(As)

vals = []
for i in range(Q):
    B, C = map(int,input().split())
    val += (C-B) * lst[B]
    lst[C] += lst[B]
    lst[B] = 0
    vals.append(val)
for val in vals:
    print(val)

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

lst = [0] * (10**5)
for A in As:
    lst[A] += 1

val = sum(As)

vals = []
for i in range(Q):
    B, C = map(int,input().split())
    val += (C-B) * lst[B]
    lst[C] += lst[B]
    lst[B] = 0
    vals.append(val)
for val in vals:
    print(val)

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

lst = [0] * (10**5)
for A in As:
    lst[A] += 1

outs = []

for i in range(0,Q):
    B, C = map(int,input().split())
    lst[C] += lst[B]
    lst[B] = 0
    outs.append(sum([i*j for i,j in enumerate(lst)]))

for out in outs:
    print(out)

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

lst = [0] * (10**5)
for A in As:
    lst[A] += 1

for i in range(0,Q):
    B, C = map(int,input().split())
    lst[C] += lst[B]
    lst[B] = 0
    print(sum([i*j for i,j in enumerate(lst)]))
Problem p02687 (python)

Fixed submission:
s = input()
if s=="ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
s = input()
if S=="ABC":
    print("ARC")
else:
    print("ABC")
Problem p02731 (python)

Fixed submission:
L = (int(input()))
print((L/3)**3)

Buggy submission (verdict: Runtime Error):
L = map(int,input().split())
print((L/3)**3)
Problem p02741 (python)

Fixed submission:
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])

Buggy submission (verdict: Runtime Error):
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())+1])

Buggy submission (verdict: Runtime Error):
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())])
Problem p02761 (python)

Fixed submission:
n,m= map(int,input().split())
inputs = []
for _ in range(m):
    inputs.append(list(map(int,input().split())))

if m == 0:
    if n == 1:
        print(0)
    else:
        print(10**(n-1))
    exit()
elif n == 1:
    if len([i[1] for i in inputs if i[1] != inputs[0][1]]) > 0:
        print(-1)    
    else:
        print(max(0,inputs[0][1]))
    exit()
else:
    out = [-1] * n
    for item in inputs:
        s = item[0]
        c = item[1]
        if out[s-1] != -1 and out[s-1] != c:
            print(-1)
            exit()
        elif s == 1 and c == 0:
            print(-1)
            exit()
        else:
            out[s-1] = c

out[0] = max(out[0],1)
res = 0
for i in range(len(out)):
    if out[i] != -1:
        res += out[i] * 10 ** (n-i-1)
print(res)

Buggy submission (verdict: Runtime Error):
n,m= map(int,input().split())
inputs = []
for _ in range(m):
    inputs.append(list(map(int,input().split())))

if m == 0:
    print(10**(n-1))
    exit()
elif n == 1:
    if len([i[1] for i in inputs if i[1] != inputs[0][1]]) > 1:
        print(-1)
        exit()
    else:
        print(max(0,inputs[0][1]))
else:
    out = [-1] * n
    for item in inputs:
        s = item[0]
        c = item[1]
        if out[s-1] != -1 and out[s-1] != c:
            print(-1)
            exit()
        elif s == 1 and c == 0:
            print(-1)
            exit()
        else:
            out[s-1] = c

out[0] = max(out[0],1)
res = 0
for i in range(len(out)):
    if out[i] != -1:
        res += out[i] * 10 ** (n-i-1)
print(res)

Buggy submission (verdict: Runtime Error):
n,m= map(int,input().split())
inputs = []
for _ in range(m):
    inputs.append(list(map(int,input().split())))

if n == 1:
    if len([i[1] for i in inputs if i[1] != inputs[0][1]]) > 1:
        print(-1)
        exit()
    else:
        print(max(0,inputs[0][1]))
else:
    out = [-1] * n
    for item in inputs:
        s = item[0]
        c = item[1]
        if out[s-1] != -1 and out[s-1] != c:
            print(-1)
            exit()
        elif s == 1 and c == 0:
            print(-1)
            exit()
        else:
            out[s-1] = c

out[0] = max(out[0],1)
res = 0
for i in range(len(out)):
    if out[i] != -1:
        res += out[i] * 10 ** (n-i-1)
print(res)

Buggy submission (verdict: Runtime Error):
n,m= map(int,input().split())
inputs = []
for _ in range(m):
    inputs.append(list(map(int,input().split())))

if n == 1:
    if len([i[1] for i in inputs if i[1] != inputs[0][1]]) > 1:
        print(-1)
        exit()
    else:
        print(max(0,inputs[0][1]))
else:
    out = [-1] * n
    for item in inputs:
        s = item[0]
        c = item[1]
        if out[s-1] != -1 and out[s-1] != c:
            print(-1)
            exit()
        else:
            out[s-1] = c

out[0] = max(out[0],1)
res = 0
for i in range(len(out)):
    if out[i] != -1:
        res += out[i] * 10 ** (n-i-1)
print(res)
Problem p02582 (python)

Fixed submission:
s=input()
if s.count("RRR")>0:
  print(3)
elif s.count("RR")>0:
  print(2)
elif s.count("R")>0:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
s=input()
if s.count("RRR")>0:
  print(3)
elif s.cout("RR")>0:
  print(2)
elif s.cout("R")>0:
  print(1)
else:
  print(0)
Problem p02554 (python)

Fixed submission:

mod = 10**9+7
N = int(input())

if N <= 1:
  print(0)
else:
  res = (10**N - 8**N - 2 * (9**N - 8**N)) % mod

  print(int(res))

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

if N <= 1:
  print(0)
else:
  res = (10**N - 8**N - 2 * (9**N - 8**N)) % mod

  print(int(res))
Problem p02732 (python)

Fixed submission:
from copy import deepcopy
dp = {0: 0}

N = int(input())
A = list(map(int, input().split()))

balls = {}
fact = 1
for (i, a) in enumerate(A):
  count = i+1
  dp[count] = count * (count-1) // 2
  if a in balls:
    balls[a] += 1
  else:
    balls[a] = 1

res = 0
for count in balls.values():
  res += dp[count]

for a in A:
  print(res - dp[balls[a]] + dp[balls[a]-1])

Buggy submission (verdict: Runtime Error):
from copy import deepcopy
dp = {}

N = int(input())
A = list(map(int, input().split()))

balls = {}
fact = 1
for (i, a) in enumerate(A):
  count = i+1
  dp[count] = count * (count-1) // 2
  if a in balls:
    balls[a] += 1
  else:
    balls[a] = 1

res = 0
for count in balls.values():
  res += dp[count]

for a in A:
  print(res - dp[balls[a]] + dp[balls[a]-1])
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
data = {}
canMake = True
if M == 0:
  if N == 1:
    print(0)
  if N == 2:
    print(10)
  if N == 3:
    print(100)
  exit()

for _ in range(M):
  s, c = map(int, input().split())
  if s in data:
    if data[s] != c:
      canMake = False
  else:
    data[s] = c

keta = N
pad = min(data)
if N != 1 and min(data) == 1 and data[min(data)] == 0:
  canMake = False

if not canMake:
  print(-1)
  exit()

res = 0
for i in range(1, keta+1):
  if i in data:
    res += data[i]*10**(keta-i)
  elif i == 1:
    res += 10**(keta-i)

print(res)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
data = {}
canMake = True
for _ in range(M):
  s, c = map(int, input().split())
  if s in data:
    if data[s] != c:
      canMake = False
  else:
    data[s] = c

keta = max(data)
pad = min(data)
if data[min(data)] == 0:
  canMake = False

if not canMake:
  print(-1)
  exit()

res = 0
for i in range(1, keta+1):
  if i in data:
    res += data[i]*10**(keta-i)
  elif i < pad:
    res += 10**(keta-i)

print(res)
Problem p02801 (python)

Fixed submission:
C = input()
print(chr(ord(C)+1))

Buggy submission (verdict: Runtime Error):
C = input()
print(chr(ord(c)+1))
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
one_length = 0
next_num = '1'
for (i, s) in enumerate(S):
    if s != '1':
        one_length = i
        next_num = s
        break

if one_length < K:
    print(str(next_num))
else:
    print('1')

# 1 or 一つ目の1以外

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

for (i, s) in enumerate(S):
    if s != '1':
        one_length = i
        next_num = s
        break

if one_length < K:
    print(str(next_num))
else:
    print('1')

# 1 or 一つ目の1以外
Problem p03294 (python)

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

def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

def lcm(a, b):
  return a*b//gcd(a,b)

alcm = a[0]
for i in a[1:]:
  alcm = lcm(alcm, i)

res = 0

for i in range(N):
  res += (alcm-1) % a[i]

print(int(res))

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

def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

def lcm(a, b):
  return a*b/gcd(a,b)

alcm = a[0]
for i in a[1:]:
  alcm = lcm(alcm, i) 

res = 0

for i in range(N):
  res += (alcm-1) % a[i]

print(int(res))

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

def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

def lcm(a, b):
  return a*b/gcd(a,b)

alcm = a[0]
for i in a[1:]:
  alcm = lcm(alcm, i) 

res = 0

for i in range(N):
  res += (alcm-1) % a[i]

print(int(res))
Problem p03683 (python)

Fixed submission:
MOD = pow(10, 9)+7
N, M = map(int, raw_input().split())

def myfact(num):
	res = 1
	for i in range(num+1)[1:]:
		res *= i
		if res > MOD:
			res %= MOD
	return res
if abs(N - M) > 1:
	print 0
else:
	if N == M:

		res = ( myfact(N) * myfact(N) * 2 )%MOD
	else:
		res = ( myfact(N) * myfact(M) )%MOD
	print res

Buggy submission (verdict: Runtime Error):
R, C, N = map(int, raw_input().split())

lines = []
for i in range(N):
	x, y, xx, yy = map(int, raw_input().split())
	if (x in [0, R] or y in [0, C]) and (xx in [0, R] or yy in [0, C]):
		if x <= y:
			first = x+y
		else:
			first = (R*2 + C*2)-(x+y)
		if xx <= yy:
			second = xx+yy
		else:
			second = (R*2 + C*2)-(xx+yy)
		new_line = [first, second] if first < second else [second, first]
		j = 0
		for j in range(len(lines)):
			if new_line[0] < lines[j][0]:
				lines.insert(j, new_line)
				break
		else:
			lines.append(new_line)

false_flag = False
scopes = []
scopes.append(lines.pop(0))
while lines and not false_flag:
	while scopes:
		next_scope = lines.pop(0)
		right = scopes[-1][1]
		next_left = next_scope[0]
		next_right = next_scope[1]
		if next_left < right:
			if next_right < right:
				if lines:
					scopes.append(next_scope)
				else:
					break
			else:
				false_flag = True
				break
		else:
			scopes.pop()
	else:
		scopes.append(next_scope)

if false_flag:
	print 'NO'
else:
	print 'YES'