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

Fixed submission:
b=input()
if b=='A':c='T'
if b=='T':c='A'
if b=='C':c='G'
if b=='G':c='C'
print(c)

Buggy submission (verdict: Runtime Error):
b=input()
if b='A':c='T'
if b='T':c='A'
if b='C':c='G'
if b='G':c='C'
print(c)
Problem p03106 (python)

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

cnt=0

for i in range(100,0,-1):
    if A%i==0 and B%i==0:
        cnt+=1
    if cnt==K:
        print(i)
        break

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

cnt=0

for i in range(101):
    if A%i==B%i==0:
        cnt+=1
    if cnt==K:
        print(i)
        break
Problem p03148 (python)

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

l=[] # 寿司リスト。ただし，「おいしさ」を第1要素にする
m=[] # 寿司タプルをそのまま入れる
s=set()

for i in range(N):
    t,d=map(int,input().split())
    l.append((d,t))
l.sort(reverse=True) 

ans=K**2
t=0 # 既に食べたことのある種類の寿司を更に食べた回数

i=0 # l内を走査する際の添字
j=0 # m内を操作する際の添え字

for _ in range(K): # _番目に食べる寿司について
    while i<N and l[i][1] in s:
        m.append(l[i]) # そのままmに追加する
        i+=1 # lの先頭の要素を削除せず，
    if (i<N and (m and j<len(m)) and l[i][0]>=m[j][0]-(2*K-1-2*t)) or (not m or j>=len(m)):
        ans+=l[i][0]
        s.add(l[i][1])
        i+=1
    else:
        ans+=m[j][0]-(2*K-1-2*t)
        j+=1
        t+=1

print(ans)

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

l=[] # 与えられた寿司のリスト。寿司をタプル(ネタti,おいしさdi)で表す。既に食べた種類の寿司は，そのおいしさdiをdjに移す。食べた寿司はリストから削除する。
dj=[] # 既に食べた種類の寿司の「おいしさ基礎ポイント」を格納するリスト。食べた寿司の「おいしさ基礎ポイント」はリストから削除する。
s=set() # 既に食べた寿司の種類を格納するセット

for i in range(N):
    t,d=map(int,input().split())
    l.append((t,d))
l.sort(key=lambda x:x[1],reverse=True) # l内の寿司をおいしさdiで降順にソート

ans=K**2
j=0 # 既に食べたことのある種類の寿司を更に食べた回数

for i in range(K): # i番目に食べる寿司について
    while l and l[0][0] in s: # lが空でなく，先頭の寿司の種類がsに入っている（先頭の寿司が食べたことのある種類である）場合
        dj.append((l.pop(0))[1]) # 食べたことのない種類の寿司がlの先頭に現れるか，lが空になるまで，先頭の寿司のおいしさをdjに格納する
    if not dj or l[0][1]>=dj[0]-(2*K-1-2*j): # djが空である場合，又は，lの先頭の寿司のおいしさと，djの先頭の「寿司のおいしさ」から「種類ボーナスポイント」の差分を減じたものを比較し，前者が勝る場合
        ans+=l[0][1] # lの先頭の寿司のおいしさに「種類ボーナスポイント」の差分を加えたものを答えに加算
        s.add(l[0][0]) # その寿司の種類をsに追加
        l.pop(0) # その寿司をlから削除
    else: #　後者が勝る場合
        ans+=dj[0]-(2*K-1-2*j) # djの先頭の「寿司のおいしさ」を答えに加算
        dj.pop(0) # その「寿司のおいしさ」をdjから削除
        j+=1

print(ans)
Problem p03244 (python)

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

dE={};dO={}
for i in range(n):
    dX=dE if i%2==0 else dO
    if v[i] in dX:
        dX[v[i]]+=1
    else:
        dX[v[i]]=1

lE=sorted(list(dE.items()),key=lambda x:x[1],reverse=True)
lO=sorted(list(dO.items()),key=lambda x:x[1],reverse=True)

me=lE[0][1];mo=lO[0][1]
ae=lE[0][0];ao=lO[0][0]

se=0 if len(lE)==1 else lE[1][1]
so=0 if len(lO)==1 else lO[1][1]

if ae==ao:
    ans=n-max(me+so,mo+se)
else:
    ans=n-(me+mo)

print(ans)

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

dE={};dO={}
for i in range(n):
    dX=dE if i%2==0 else dO
    if v[i] in dX:
        dX[v[i]]+=1
    else:
        dX[v[i]]=1

lE=sorted(list(dE.items()),key=lambda x:x[1],reverse=True)
lO=sorted(list(dO.items()),key=lambda x:x[1],reverse=True)

me=lE[0][1];mo=lO[0][1]
ae=lE[0][0];ao=lO[0][0]
se=0 if len(lE)==0 else lE[1][1]
so=0 if len(lO)==0 else lO[1][1]

if ae==ao:
    ans=n-max(me+so,mo+se)
else:
    ans=n-(me+mo)

print(ans)
Problem p03262 (python)

Fixed submission:
def GCD(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if y==0:
        return x
    elif x%y==0:
        return y
    else:
        return GCD(y,x%y)

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

ans=0

for xi in x:
    ans=GCD(ans,xi-X)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

ans=0

for xi in x:
    ans=math.gcd(ans,xi-X)

print(ans)
Problem p03339 (python)

Fixed submission:
import numpy as np

N=int(input())
S=input()

W=[0 for i in range(N)] # W[i]=(S[i]より西で西を向いている人の数)
E=[0 for i in range(N)] # E[i]=(S[i]より東で東を向いている人の数)

for i in range(1,N):
    if S[i-1]=='W':
        W[i]=W[i-1]+1
    else:
        W[i]=W[i-1]
for i in reversed(range(N-1)):
    if S[i+1]=='E':
        E[i]=E[i+1]+1
    else:
        E[i]=E[i+1]

print(min([x for x in np.array(W)+np.array(E)]))

Buggy submission (verdict: Runtime Error):
import numpy as np

N=int(input())
S=input()

W=[0 for i in range(N)] # W[i]=(S[i]より西で西を向いている人の数)
E=[0 for i in range(N)] # E[i]=(S[i]より東で東を向いている人の数)

for i in range(1,N):
    if S[i-1]=='W':
        W[i]=W[i-1]+1
    else:
        W[i]=W[i-1]
for i in reversed(range(N-1)):
    if S[i+1]=='E':
        E[i]=E[i+1]+1
    else:
        E[i]=E[i+1]

print(min([x for x in np.array(W)+np.array(E)]))
Problem p03379 (python)

Fixed submission:
import copy

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

Y=sorted(X.copy())

a=Y[N//2-1]
b=Y[N//2]

for i in range(N):
    if X[i]<=a:
        print(b)
    else:
        print(a)

Buggy submission (verdict: Runtime Error):
import copy

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

Y=sorted(X.copy())

a=Y[N//2-1]
b=Y[N//2]

for i in range(N):
    if X[i]<=a:
        print(b)
    else:
        print(a)
Problem p03438 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sorted([a[i]-b[i] for i in range(N)])
k=-sum(c)
# print(c,k)
cp=[ci for ci in c if ci>0]
cn=[ci for ci in c if ci<0]

# 必要な「1増やす回数」
p=sum(cp)+sum([cni%2 for cni in cn])
# 必要な「2減らす回数」
n=sum([(-cni+1)//2 for cni in cn])

f=k>=0 and p<=k and n<=k

print('Yes' if f else 'No')

Buggy submission (verdict: Runtime Error):
_=int(input())
print('Yes' if sum(list(map(int,input().split()))<=sum(list(map(int,input().split()))) else 'No')
Problem p03469 (python)

Fixed submission:
print(input().replace('7','8',1))

Buggy submission (verdict: Runtime Error):
print(replace(input(),'7','8',1))
Problem p03644 (python)

Fixed submission:
N=int(input())
if N<2:
    x=1
elif N<4:
    x=2
elif N<8:
    x=4
elif N<16:
    x=8
elif N<32:
    x=16
elif N<64:
    x=32
else:
    x=64
print(x)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N<2:
    x=1
elif N<4:
    x=2
elif N<8:
    x=4
elif N<16:
    x=8
elif n<32:
    x=16
elif n<64:
    x=32
else:
    x=64
print(x)

Buggy submission (verdict: Runtime Error):
N=int(input())
p=0
while N%==0:
    p+=1
    N//=2
print(2**p)
Problem p03719 (python)

Fixed submission:
A,B,C=map(int,input().split())
print('Yes' if A<=C<=B else 'No')

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
print('Yes' if a<=C<=B else 'No')
Problem p03730 (python)

Fixed submission:
import fractions

A,B,C=map(int,input().split())
f=C%fractions.gcd(A,B)==0
print('YES' if f else 'NO')

Buggy submission (verdict: Runtime Error):
import math
A,B,C=map(int,input().split())
f=C%math.gcd(A,B)==0
print('YES' if f else 'NO')
Problem p03994 (python)

Fixed submission:
s=input()
K=int(input())
ans=''
for c in s:
    if c!='a' and ord('z')+1-ord(c)<=K:
        ans+='a'
        K-=ord('z')+1-ord(c)
    else:
        ans+=c
if K>0:
    ans=ans[:-1]+chr(ord(ans[-1])+K%26)

print(ans)

Buggy submission (verdict: Runtime Error):
a=[ord(c)-ord('a') for c in input()]
K=int(input())

for i in range(len(a)):
    if a[i]>0 and 26-a[i]<=K:
        K-=26-a[i]
        a[i]=0
a[-1]+=K
l=[chr(ord('a')+ai) for ai in a]

print(''.join(l))

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

for i,c in enumerate(s):
    if c!='a' and ord('z')+1-ord(c)<=K:
        K-=ord('z')+1-ord(c)
        s=s[:i]+'a'+s[i+1:]
s=s[:-1]+chr(ord(s[-1])+K)

print(s)

Buggy submission (verdict: Runtime Error):
s=input()
a=[ord(c)-ord('a') for c in s]
K=int(input())

# print(a) #DB

for i in range(len(s)):
    if 26-a[i]>K or a[i]==0:
        continue
    else:
        K-=26-a[i]
        a[i]=0

a[-1]+=K

print(''.join([chr(ord('a')+ai) for ai in a]))

Buggy submission (verdict: Runtime Error):
s=input()
a=[ord(c)-ord('a') for c in s]
K=int(input())

# print(a) #DB

for i in range(len(s)):
    if 26-a[i]>K:
        continue
    else:
        K-=26-a[i]
        a[i]=0

a[-1]+=K

print(''.join([chr(ord('a')+ai) for ai in a]))
Problem p03303 (python)

Fixed submission:
S=input()
w=int(input())
n=len(S)
T=""
for i in range (0,n,w):
  T+=S[i]
print(T)

Buggy submission (verdict: Runtime Error):
S=input()
w=int(input())
n=len(S)
T=""
for i in range (0,n+1,w):
  T+=S[i]
print(T)
Problem p03737 (python)

Fixed submission:
a,b,c=input().split()
s=a[0]+b[0]+c[0]
print(s.upper())

Buggy submission (verdict: Runtime Error):
a,b,c=map(input().split())
s=a[0]+b[0]+c[0]
print(s.upper())
Problem p02772 (python)

Fixed submission:

import numpy as np

N = int(input())
A = [int(x) for x in input().split()]
a = np.array(A)

#mask = a%6==0 or a%10==0 or a%2==1 
mask = np.logical_or.reduce( (a%6==0 , a%10==0, a%2==1) )
if mask.all() : 
    print("APPROVED")
else :
    print("DENIED")

Buggy submission (verdict: Runtime Error):

#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);

  return 0;
}
Problem p03680 (python)

Fixed submission:
#!/usr/bin/env python

import sys
sys.setrecursionlimit(1000000)

N = 1
a = []

def sol(x, cnt) : 
    cnt+=1
    if a[x-1] == 2 :
        return cnt
    if cnt > N :
        return -1

    return sol(a[x-1], cnt)


if __name__ == '__main__' : 
    N = int(input())

    for i in range(N) : 
        a.append(int(input()))

    print( sol(1,0) )

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

N = 1
a = []

def sol(x, cnt) : 

    cnt+=1
    if a[x-1] == 2 :
        return cnt
    if cnt > N :
        return -1

    return sol(a[x-1], cnt)


if __name__ == '__main__' : 
    N = int(input())

    for i in range(N) : 
        a.append(int(input()))

    print( sol(1,0) )
Problem p02658 (python)

Fixed submission:
N = int(input())
a = 1
L = list(map(int, input().split()))
L.sort()
for i in L:
    a *= i
    if (a > 1e18):
        break

print(-1 if a > 1e18 else a)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = 1
L = list(map(int, input().split()))
for i in L:
    a *= i
    if(a > 1e18)break

print(-1 if a > 1e18 else a)
Problem p02969 (python)

Fixed submission:
print(3*(int(input())**2))

Buggy submission (verdict: Runtime Error):
print(3*(int(input()**2)))
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100100)
n=int(input())
route=[[] for i in range(n)]
for i in range(n-1):
	u,v,w=map(int,input().split())
	route[u-1].append((v-1,w))
	route[v-1].append((u-1,w))
ans=[-1]*n
def dfs(p,d):
	ans[p]=d
	for i,j in route[p]:
		if ans[i]<0:dfs(i,(d+j)%2)
dfs(0,0)
for i in range(n):
	print(ans[i])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10100)
n=int(input())
route=[[] for i in range(n)]
for i in range(n-1):
	u,v,w=map(int,input().split())
	route[u-1].append((v-1,w))
	route[v-1].append((u-1,w))
ans=[-1]*n
def dfs(p,d):
	ans[p]=d
	for i,j in route[p]:
		if ans[i]<0:dfs(i,(d+j)%2)
dfs(0,0)
for i in range(n):
	print(ans[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
route=[[] for i in range(n)]
for i in range(n-1):
	u,v,w=map(int,input().split())
	route[u-1].append((v-1,w))
	route[v-1].append((u-1,w))
ans=[-1]*n
def dfs(p,d):
	ans[p]=d
	for i,j in route[p]:
		if ans[i]<0:dfs(i,(d+j)%2)
dfs(0,0)
for i in range(n):
	print(ans[i])
Problem p03069 (python)

Fixed submission:
n=int(input())
s=input()
b=s.count("#")
w=s.count(".")
M=n
noww=0
for i in range(n-1):
    if s[i]==".":
        noww+=1
        if s[i+1]=="#":
            M=min(M,(i-noww+1)+w-noww)

print(min(b,w,M))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
b=s.count("#")
w=s.count(".")
cnt=0
ind=n-s[::-1].index(".")
p=s[:ind].count("#")
print(min(b,w,p))
Problem p03089 (python)

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
l=[]
while len(x):
    index=-1
    for i,a in enumerate(x):
        if a==i+1:
            index=i
    if index == -1:
        print(-1)
        break
    l.append(x.pop(index))
else:
    for i in reversed(l):
        print(i)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
l=[]
while len(x):
    for i,a in enumerate(x):
        if a==i+1:
            index=i
    l.append(x.pop(index))
for i in reversed(l):
    print(i)
Problem p03148 (python)

Fixed submission:
n, k = map(int, input().split())
td = sorted([list(map(int, input().split())) for i in range(n)], reverse=True, key=lambda x: x[1])

type = set()
L = []
Sum = 0
for x in td[:k]:
    Sum += x[1]
    if x[0] not in type:
        type.add(x[0])
    else:
        L.append(x[1])

L = L[::-1]
type_cnt = len(type)
ans = Sum + type_cnt ** 2
for x in td[k:]:
    if len(L)==0:break
    if x[0] not in type:
        type.add(x[0])
        type_cnt += 1
        Sum = Sum - L.pop(0) + x[1]
        ans = max(ans, Sum + type_cnt ** 2)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
td = sorted([list(map(int, input().split())) for i in range(n)], reverse=True, key=lambda x: x[1])

type = set()
L = []
Sum = 0
for x in td[:k]:
    Sum += x[1]
    if x[0] not in type:
        type.add(x[0])
    else:
        L.append(x[1])

L = L[::-1]
type_cnt = len(type)
ans = Sum + type_cnt ** 2
for x in td[k:]:
    if x[0] not in type:
        type.add(x[0])
        type_cnt += 1
        Sum = Sum - L.pop(0) + x[1]
        ans = max(ans, Sum + type_cnt ** 2)
print(ans)
Problem p03206 (python)

Fixed submission:
c='Christmas'
for i in range(25-int(input())):
	c+=' Eve'
print(c)

Buggy submission (verdict: Runtime Error):
l = [1]
p = [1]
N, X = map(int, input().split())
for i in range(N):
    l.append(l[i] * 2 + 3)
    p.append(p[i] * 2 + 1)


def calc(n, x):
    if l[n] <= x:
        return p[n]
    if x == 0 or x == 1:
        return 0
    if x <= l[n] // 2:
        return calc(n - 1, x - 1)
    elif x == l[n] // 2 + 1:
        return p[n - 1] + 1
    else:
        return p[n - 1] + 1 + calc(n - 1, x - (l[n - 1] + 2))


print(calc(N, X))
Problem p03238 (python)

Fixed submission:
if input() == '1':
	print('Hello World')
else:
	print(int(input())+int(input()))

Buggy submission (verdict: Runtime Error):
if input() == '1':
	print('Hello world')
else:
	print(int(input())+int(input())))
Problem p03424 (python)

Fixed submission:
n=int(input())
l=list(map(str,input().split()))
print('Four' if 'Y' in l else 'Three')

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
print('Four' if 'Y' in l else 'Three')
Problem p03457 (python)

Fixed submission:
n=int(input())
p=(0,0)
now=0
for _ in range(n):
    t,x,y=map(int,input().split())
    mov=abs(x-p[0])+abs(y-p[1])
    if t-now<mov or (t-now-mov)%2==1:
        print("No")
        break
    p=(x,y)
    now=t
else:print("Yes")

Buggy submission (verdict: Runtime Error):
n=int(input())
p=(0,0)
now=0
for _ in range(2):
    t,x,y=map(int,input().split())
    mov=abs(x-p[0])+abs(y-p[1])
    if t-now<mov or (t-now-mov)%2==1:
        print("No")
        break
else:print("Yes")
Problem p03565 (python)

Fixed submission:
s=list(input())[::-1]
t=list(input())[::-1]
if len(s)<len(t):print('UNRESTORABLE')
else:
	for i in range(len(s)-len(t)+1):
		for j in range(len(t)):
			if s[i+j] not in ['?',t[j]]:break
		else:
			s[i:i+len(t)]=t
			break
	else:
		print('UNRESTORABLE')
		exit()
	print(''.join(s[::-1]).replace('?','a'))

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())
if len(s)<len(t):print('UNRESTORABLE')
else:
	for i in range(len(s)-len(t)+1):
		for j in range(len(t)):
			if s[i+j] not in ['?',t[j]]:break
		else:
			s[i:i+len(t)]=t
			break
	else:
		print('UNRESTORABLE')
        exit()
print(''.join(s).replace('?','a'))
Problem p03573 (python)

Fixed submission:
a=list(map(int,input().split()))
if a[0] == a[1]:
	print(a[2])
else:
	if a[0] == a[2]:
		print(a[1])
	else:
		print(a[0])

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
if a[0] == a[1]:
	print(a[2])
else:
	if a[0] == a[2]:
		print(a[1])
	else:
		ptint(a[0])
Problem p03575 (python)

Fixed submission:
n,m=map(int,input().split())
g=[list() for _ in range(n+1)]
side=[list(map(int,input().split())) for i in range(m)]
for a,b in side:
	g[a].append(b)
	g[b].append(a)
cnt=0
def dfs(x,s):
	ed[x-1]=1
	for i in g[x]:
		if s!={x,i} and ed[i-1]==0:dfs(i,s)
cnt=0
for i in range(m):
	ed=[0]*n
	dfs(1,set(side[i]))
	if 0 in ed:cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
g=[list() for _ in range(n+1)]
side=[list(map(int,input().split())) for i in range(m)]
for a,b in side:
	g[a].append(b)
	g[b].append(a)
cnt=0
def dfs(r,x,s):
	ed[x-1]=1
	for i in g[x]:
		if i!=r and s!={x,i} and ed[i-1]==0:dfs(x,i,s)
cnt=0
for i in range(m):
	ed=[0]*n
	dfs(0,i+1,set(side[i]))
	if 0 in ed:cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
g=[list() for _ in range(n+1)]
side=[list(map(int,input().split())) for i in range(m)]
for a,b in side:
	g[a].append(b)
	g[b].append(a)
cnt=0
def dfs(r,x,s):
	ed[x-1]=1
	for i in g[x]:
		if i!=r and s!={x,i}:dfs(x,i,s)
cnt=0
for i in side:
	ed=[0]*n
	dfs(0,1,set(i))
	if 0 in ed:cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
g=[list() for _ in range(n+1)]
side=[list(map(int,input().split())) for i in range(m)]
for a,b in side:
	g[a].append(b)
	g[b].append(a)
cnt=0
def dfs(r,x,s):
	ed[x-1]=1
	for i in g[x]:
		if i!=r and s!={x,i}:dfs(x,i,s)
cnt=0
for i in range(m):
	ed=[0]*n
	dfs(0,1,set(side[i]))
	if 0 in ed:cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
g=[list() for _ in range(n+1)]
side=[list(map(int,input().split())) for i in range(m)]
for a,b in side:
	g[a].append(b)
	g[b].append(a)
cnt=0
def dfs(r,x,s):
	ed[x-1]=1
	for i in g[x]:
		if i!=r and s!={x,i}:dfs(x,i,s)
cnt=0
for i in range(m):
	ed=[0]*n
	dfs(0,i+1,set(side[i]))
	if 0 in ed:cnt+=1
print(cnt)
Problem p03599 (python)

Fixed submission:
A,B,C,D,E,F=map(int,input().split())
ans=[100,-1]
e=E/(100+E)
W=[a+b for a in range(0,F+1,100*A) for b in range(0,F+1,100*B) if a!=0 or b!=0]
for w in W:
    for c in range(0,F-w+1,C):
        for d in range(0,F-w-c+1,D):
            s=c+d
            if w+s>F or s/(w+s)>e:break
            elif ans[1]/ans[0]<s/(w+s)<=e:
                ans=[w+s,s]
print(ans[0],ans[1])

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F=map(int,input().split())
ans=(0,0,0)
F+=1
E=100*E/(100+E)
for a in range(0,F,A*100):
	for b in range(0,F-a,B*100):
		for c in range(0,F-a-b,C):
          	if a==0 and b==0:break
			for d in range(0,F-a-b-c,D):
				s=a+b+c+d
				e=100*(c+d)/s
				if ans[2]< e <= E:
					ans=(s,c+d,e)
				elif e>E:break
print(ans[0],ans[1])
Problem p03645 (python)

Fixed submission:
n,m=map(int,input().split())
l=[set(map(int,input().split())) for _ in range(m)]
S=set()
G=set()
for x in l:
	if 1 in x:S.add(max(x))
	elif n in x:G.add(min(x))
S=sorted(S)
G=sorted(G)
i=0
Glen=len(G)
for x in S:
	if i==Glen:break
	elif G[i]<x:
		while i<Glen and G[i]<x:
			i+=1
	if i<Glen and x==G[i]:
		print('POSSIBLE')
		exit()
print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[set(map(int,input().split())) for _ in range(m)]
S=set()
G=set()
for x in l:
	if 1 in x:S.add(max(x))
	elif n in x:G.add(min(x))
S=sorted(S)
G=sorted(G)
i=0
Glen=len(G)
for x in S:
	if i==Glen:break
	elif G[i]<x:
		while i<Glen and G[i]<x:
			i+=1
	if x==G[i]:
		print('POSSIBLE')
		exit()
print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[set(map(int,input().split())) for _ in range(m)]
S=set()
G=set()
for x in l:
	if 1 in x:S=S+x
	elif n in x:G=G+x
print('POSSIBLE' if len(S&G)>0 else 'IMPOSSIBLE')
Problem p03657 (python)

Fixed submission:
a,b=map(int,input().split())
if not (a%3 and b%3 and (a+b)%3):
  print('Possible')
else:
  print('Impossible')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if not (a%3orb%3or(a+b)%3):
  print('Possible')
else:
  print('Impossible')
Problem p03679 (python)

Fixed submission:
a,b,c=map(int,input().split())
print('delicious' if c<=b else 'safe' if c-b<=a else 'dangerous')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print('delicious' if c<b else 'safe' if c-b<a else 'dengerous'))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print('delicious' if b<c else 'safe' if c-b<a else 'dengerous'))
Problem p03699 (python)

Fixed submission:
n=int(input())
s=[int(input()) for i in range(n)]
ten=[]
p=[]
for x in s:
    if x%10==0:ten.append(x)
    else:p.append(x)
ten=sum(ten)
if len(p)==0:print(0)
else:
    p=sorted(p)
    Sum=sum(p)
    print(Sum+ten-p[0] if Sum%10==0 else Sum+ten)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[int(input()) for i in range(n)]
ten=[]
p=[]
for x in s:
    if x%10==0:ten.append(x)
    else:p.append(x)
ten=sum(ten)
if len(p)==0:print(0)
else:
	p=sorted(p)
    Sum=sum(p)
    print(Sum+ten-p[0] if Sum%10==0 else Sum+ten)
Problem p02662 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
MOD = 998244353
INF = 10 ** 15

def main():
    N,S = map(int,input().split())
    A = list(map(int,input().split()))

    dp = [[0]*(1 + S) for _ in range(N + 1)]
    dp[0][0] = pow(2,N,MOD)
    inv2 = pow(2,MOD - 2,MOD)
    for i,a in enumerate(A):
        for j in range(S + 1):
            if j < a:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = (dp[i][j] + dp[i][j - a] * inv2)%MOD
    print(dp[N][S])
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)
MOD = 998244353
INF = 10 ** 15

def main():
    N,S = map(int,input().split())
    A = list(map(int,input().split()))

    dp = [[0]*(1 + S) for _ in range(N + 1)]
    dp[0][0] = pow(2,N,MOD)
    inv2 = pow(2,MOD - 2,MOD)
    for i,a in enumerate(A):
        for j in range(a):
            dp[i + 1][j] = dp[i][j]
        for j in range(a,S + 1):
            dp[i + 1][j] = (dp[i][j] + dp[i][j - a] * inv2)%MOD
    print(dp[N][S])
if __name__ == '__main__':
    main()