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

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

Buggy submission (verdict: Runtime Error):
N = int(input())
if N < 1200:
  print("ABC")
elif N < 2800:
  print("ARC")
else
  print("AGC")
Problem p03959 (python)

Fixed submission:
N=int(raw_input())
T=map(int,raw_input().split())
A=map(int,raw_input().split())

I,J=N-1,0
ans=1
for i in range(N):
    H=min(T[i],A[i])
    if i>0 and T[i-1]<T[i]:
        H=1
        if i+1 <N  and A[i+1]<A[i]:
            if T[i]!=A[i]:
                ans=0
                break
        if i==N-1 and T[i]!=A[i]:
            ans=0
            break
        if T[i] > A[i]:
            ans=0
            break
    if i+1 <N and A[i+1] <A[i]:
        H=1
        if i==0 and T[i]!=A[i]:
            ans=0
            break
        if A[i] > T[i]:
            ans=0
            break
    if i==0:
        H=1
        if T[i] > A[i]:
            ans =0
            break
    if i==N-1:
        H=1
        if A[i] > T[i]:
            ans = 0
            break
    ans *= H
    ans %= 1000000007
print ans

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

I,J=N-1,0
ans=1
for i in range(N):
    H=min(T[i],A[i])
    if i>0 and T[i-1]<T[i]:
        H=1
        if i+1 <N  and A[i+1]<A[i]:
            if T[i]!=A[i]:
                ans=0
                break
        if i==N-1 and T[i]!=A[i]:
            ans=0
            break
        if T[i] > A[i]
            ans=0
            break
    if i+1 <N and A[i+1] <A[i]:
        H=1
        if i==0 and T[i]!=A[i]:
            ans=0
            break
        if A[i] > T[i]
            ans=0
            break
    if i==0:
        H=1
        if T[i] > A[i]:
            ans =0
            break
    if i==N-1:
        H=1
        if A[i] > T[i]:
            ans = 0
            break
    ans *= H
    ans %= 1000000007
print ans
Problem p02923 (python)

Fixed submission:
N=int(input())
H=[int(x) for x in input().split()]
ans=0
cur=0
for i,h in enumerate(H):
    if i>=1 and h<=H[i-1]:
        cur=cur+1
        ans=max(ans,cur)
    else:
        cur=0
print(ans)

Buggy submission (verdict: Runtime Error):
xN=int(input())
H=[int(x) for x in input().split()]
cur=[0]*N
for i in range(N):
    if H[i]<=H[i-1]:
        cur[i]=cur[i-1]+1
print(max(cur))
Problem p02985 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

MOD=10**9+7

N,K=map(int,input().split())
g=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

MAX=10**6
fc=[1]*MAX
inv=[1]*MAX
ifc=[1]*MAX

for i in range(2,MAX):
    fc[i]=i*fc[i-1]%MOD
    inv[i]=MOD-(MOD//i)*inv[MOD%i]%MOD
    ifc[i]=inv[i]*ifc[i-1]%MOD

def comb(n,k):
    if n<0 or k<0 or n-k<0:
        return 0
    return fc[n]*ifc[n-k]%MOD*ifc[k]%MOD

def dfs(cur,par):
    ret=1
    ch=len(g[cur])
    if par!=-1:
        ch-=1
    
    if par==-1:
        ret=comb(K-1,ch)*fc[ch]%MOD
    else:
        ret=comb(K-2,ch)*fc[ch]%MOD
        
        
    for dst in g[cur]:
        if dst==par:
            continue
        ret=ret*dfs(dst,cur)%MOD
    return ret

ans=K*dfs(0,-1)%MOD
print(ans)

Buggy submission (verdict: Runtime Error):
sys.setrecursionlimit(10**7)

MOD=10**9+7

N,K=map(int,input().split())
g=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

MAX=10**6
fc=[1]*MAX
inv=[1]*MAX
ifc=[1]*MAX

for i in range(2,MAX):
    fc[i]=i*fc[i-1]%MOD
    inv[i]=MOD-(MOD//i)*inv[MOD%i]%MOD
    ifc[i]=inv[i]*ifc[i-1]%MOD

def comb(n,k):
    if n<0 or k<0 or n-k<0:
        return 0
    return fc[n]*ifc[n-k]%MOD*ifc[k]%MOD

def dfs(cur,par):
    ret=1
    ch=len(g[cur])
    if par!=-1:
        ch-=1
    
    if par==-1:
        ret=comb(K-1,ch)*fc[ch]%MOD
    else:
        ret=comb(K-2,ch)*fc[ch]%MOD
        
        
    for dst in g[cur]:
        if dst==par:
            continue
        ret=ret*dfs(dst,cur)%MOD
    return ret

ans=K*dfs(0,-1)%MOD
print(ans)

Buggy submission (verdict: Runtime Error):
MOD=10**9+7

N,K=map(int,input().split())
g=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

MAX=10**6
fc=[1]*MAX
ifc=[1]*MAX
inv=[1]*MAX

for i in range(2,MAX):
    fc[i]=i*fc[i-1]%MOD
    inv[i]=MOD-(MOD//i)*inv[MOD%i]%MOD
    ifc[i]=inv[i]*ifc[i-1]%MOD

def comb(n,k):
    if n<0 or k<0 or n-k<0:
        return 0
    return fc[n]*ifc[n-k]%MOD*ifc[k]%MOD

def dfs(cur,par):
    ret=1
    ch=len(g[cur])
    if par!=-1:
        ch-=1
    
    if par==-1:
        ret=comb(K-1,ch)*fc[ch]%MOD
    else:
        ret=comb(K-2,ch)*fc[ch]%MOD
        
        
    for dst in g[cur]:
        if dst==par:
            continue
        ret=ret*dfs(dst,cur)%MOD
    return ret

ans=K*dfs(0,-1)%MOD
print(ans)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N=int(readline())
m=map(int,read().split())
UVW=zip(m,m,m)

graph =[[] for i in range(N+1)]
for u,v,w in UVW:
    graph[u].append((v,w))
    graph[v].append((u,w))
color=[0]*(N+1)

def dfs(cur,par,dist):
    color[cur]=dist
    for dst,w in graph[cur]:
        if (dst==par):
            continue
        dfs(dst,cur,dist^(w&1))
dfs(1,-1,0)
print('\n'.join(map(str,color[1:])))

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N=int(readline())
m=map(int,read().split())
UVW=zip(m,m,m)

graph =[[] for i in range(N+1)]
for u,v,w in UVW:
    graph[u].append((v,w))
    graph[v].append((u,w))
color=[0]*(N+1)

def dfs(cur,par,dist):
    color[cur]=dist
    for dst,w in graph[cur]:
        if (dst==par):
            continue
        dfs(dst,cur,dist^(w&1))
dfs(1,-1,0)
print('\n'.join(map(str,color[1:])))
Problem p02609 (python)

Fixed submission:
n = int(input())
# for i in range(n):
#     print('0', end='')
# print(flush=True)
s = input()
x = int(s, base=2)
popcount = s.count('1')
y_zero = x % (popcount + 1)
if popcount > 1:
    y_one = x % (popcount - 1)
dp = [-1] * n
dp[0] = 0


def calc(y):
    if dp[y] != -1:
        return dp[y]
    dp[y] = 1 + calc(y % bin(y).count('1'))
    return dp[y]


ans = [0] * n
rem_zero = 1
if popcount > 1:
    rem_one = popcount - 2
for i in range(n):
    if s[n - 1 - i] == '0':
        ans[n - 1 - i] = 1 + calc((y_zero + rem_zero) % (popcount + 1))
    elif popcount > 1:
        ans[n - 1 - i] = 1 + calc((y_one + rem_one) % (popcount - 1))
    else:
        ans[n - 1 - i] = 0
    rem_zero = rem_zero * 2 % (popcount + 1)
    if popcount > 1:
        rem_one = rem_one * 2 % (popcount - 1)
for i in range(n):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
# for i in range(n):
#     print('0', end='')
# print(flush=True)
x_str = input()
x = int(x_str, base=2)
popcount = x_str.count('1')
y_zero = x % (popcount + 1)
y_one = x % (popcount - 1)
dp = [-1] * n
dp[0] = 0


def calc(y):
    if dp[y] != -1:
        return dp[y]
    dp[y] = 1 + calc(y % bin(y).count('1'))
    return dp[y]


ans = [0] * n
rem_zero = 1
rem_one = popcount - 2
for i in range(n):
    if x_str[n - 1 - i] == '0':
        ans[n - 1 - i] = 1 + calc((y_zero + rem_zero) % (popcount + 1))
    else:
        ans[n - 1 - i] = 1 + calc((y_one + rem_one) % (popcount - 1))
    rem_zero = rem_zero * 2 % (popcount + 1)
    rem_one = rem_one * 2 % (popcount - 1)
for i in range(n):
    print(ans[i])
Problem p02548 (python)

Fixed submission:
N = int(input())
ans=0
for i in range(1,10**6+1):
    for j in range(1,1000001):
        if i*j>N-1:
            break
        else:
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
import sympy
ans=0
for i in range(1,N):
    ans+=sympy.divisor_count(i)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
import sympy
ans=0
for i in range(1,N):
    ans+=sympy.divisor_count(i)
print(ans)
Problem p02602 (python)

Fixed submission:
#C
N, K = map(int, input().split())
A = list(map(int, input().split()))
p=[]
for i in range(N-K):
    if A[i+K]>A[i]:
        p.append(1)
    else:
        p.append(0)

for j in range(len(p)):
    if p[j]==1:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
#C
N, K = map(int, input().split())
A = list(map(int, input().split()))
p=[]
import numpy as np
for i in range(N-K+1):
    if i==0:
        ans=np.prod(A[i:i+K])
    else:
        ans=ans*A[i+K-1]/A[i-1]
    p.append(ans)

for j in range(len(p)-1):
    if p[j]<p[j+1]:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
#C
N, K = map(int, input().split())
A = list(map(int, input().split()))
p=[]
import numpy as np
for i in range(N-K+1):
    if i==0:
        ans=np.prod(A[i:i+K])
    else:
        ans=ans*A[i+K-1]/A[i-1]
    p.append(int(ans))
for j in range(len(p)-1):
    if p[j]<p[j+1]:
        print('Yes')
    else:
        print('No')
Problem p02608 (python)

Fixed submission:
N = int(input())
A = [0] * (10**4+1)
import math
import numpy
tmp=0
for i in range(1,int(math.sqrt(N))):
    for j in range(1,int(math.sqrt(N))):
        for k in range(1,int(math.sqrt(N))):
            tmp=(i+j+k)**2-(i*j+j*k+i*k)
            if tmp<=10**4:
                A[tmp]+=1
for p in A[1:N+1]:
    print(p)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0] * (10**4)
import math
import numpy
tmp=0
for i in range(1,int(math.sqrt(N))):
    for j in range(1,int(math.sqrt(N))):
        for k in range(1,int(math.sqrt(N))):
            tmp=(i+j+k)**2-(i*j+j*k+i*k)
            if tmp<=10**4:
                A[tmp]+=1
for p in A[1:N+1]:
    print(p)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0] * (10**4)
import math
import numpy
tmp=0
for i in range(1,int(math.sqrt(N))):
    for j in range(1,int(math.sqrt(N))):
        for k in range(1,int(math.sqrt(N))):
            tmp=(i+j+k)**2-(i*j+j*k+i*k)
            A[tmp]+=1
for p in A[1:N+1]:
    print(p)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0] * (10**4)
import math
import numpy
tmp=0
for i in range(1,int(math.sqrt(N))):
    for j in range(1,int(math.sqrt(N))):
        for k in range(1,int(math.sqrt(N))):
            tmp=(i+j+k)**2-(i*j+j*k+i*k)
            A[tmp]+=1
for p in A[1:N+1]:
    print(p)
Problem p02630 (python)

Fixed submission:
#d
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())
D = [0] * (10**5+1)
ans=sum(A)
for i in A:
    D[i]+=1
for x in range(Q):
    ans+=D[B[x]]*int(C[x]-B[x])
    print(ans)
    D[C[x]]+=D[B[x]]
    D[B[x]]=0

Buggy submission (verdict: Runtime Error):
#d
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())
D = [0] * (10**5)
ans=sum(A)
for i in A:
    D[i]+=1
for x in range(Q):
    ans+=D[B[x]]*int(C[x]-B[x])
    print(ans)
    D[C[x]]+=D[B[x]]
    D[B[x]]=0

Buggy submission (verdict: Runtime Error):
#d
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())
D = [0] * (10**5)
ans=sum(A)
for i in A:
    D[i]+=1
for x in range(Q):
    ans+=D[B[x]]*(C[x]-B[x])
    print(ans)
    D[C[x]]+=D[B[x]]
    D[B[x]]=0

Buggy submission (verdict: Runtime Error):
#d
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())
D = [0] * (10**5)
ans=sum(A)
for i in A:
    D[i]+=1
for x in range(Q):
    D[C[x]]+=D[B[x]]
    ans+=D[B[x]]*(C[x]-B[x])
    print(ans)
    D[B[x]]=0

Buggy submission (verdict: Runtime Error):
#d
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())
D = [0] * (10**4)
ans=sum(A)
for i in A:
    D[i]+=1
for x in range(Q):
    D[C[x]]+=D[B[x]]
    tmp=D[B[x]]
    ans=ans+tmp*(C[x]-B[x])
    print(ans)
    D[B[x]]=0

Buggy submission (verdict: Runtime Error):
#d
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())
D = [0] * (10**5)
ans=sum(A)
for i in A:
    D[i]+=1
for x in range(Q):
    D[C[x]]+=D[B[x]]
    tmp=D[B[x]]
    ans=ans+tmp*(C[x]-B[x])
    print(ans)
    D[B[x]]=0
Problem p02681 (python)

Fixed submission:
S=str(input())
B=str(input())
if B[:-1:]==S:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S=str(input())
B=str(input())
if S[:-1:]==B[]:
    print('Yes')
else:
    print('No')
Problem p02719 (python)

Fixed submission:
N,M = map(int, input().split())
if N>=N%M:
    if N%M>=M-N%M:
        ans=M-N%M
    else:
        ans=N%M
else:
    ans=N
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
def abc(n, m):
    if n<=abs(n-m):
        return n
    else:
        return abc(abs(n-m), m)
p=abc(N,M)
print(p)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
def abc(n, m):
    if n<=abs(n-m):
        return n
    else:
        return abc(abs(n-m), m)
    p=abc(N,M)
print(p)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
def abc(n, m):
    if n<=abs(n-m):
        return n
    else:
        return abc(abs(n-m), m)
print(abc(N,M))

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
def abc(n, m):
    if n<=abs(n-m):
        return n
    else:
        return abc(abs(n-m), m)
print(abc(N,M))
Problem p02747 (python)

Fixed submission:
s=input()
if s=='hi':
    print('Yes')
elif s=='hihi':
    print('Yes')
elif s=='hihihi':
    print('Yes')
elif s=='hihihihi':
    print('Yes')
elif s=='hihihihihi':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=input()
if s=='hi':
    print(Yes)
elif s=='hihi':
    print(Yes)
elif s=='hihihi':
    print(Yes)
elif s=='hihihihi':
    print(Yes)
elif s=='hihihihihi':
    print(Yes)
else:
    print(No)
Problem p03043 (python)

Fixed submission:



N,K=[int(c) for c in input().split()]

import math



prob=max(N-K,0)
for M in range(1,min(N+1,K+1)):
	prob+=1/(2**math.ceil(math.log2(K/M)))
prob/=N
print(prob)

Buggy submission (verdict: Runtime Error):



N,K=[int(c) for c in input().split()]

import math



prob=max(N-K,0)
for M in range(1,min(N+1,K+1)):
	prob+=1/(2**math.ceil(math.log2(K/M)))
prob/=N
print(prob)
Problem p03048 (python)

Fixed submission:


R,G,B,N=[int(c) for c in input().split()]

C=sorted([R,G,B])



if(C==[1,1,1]):
	print((N+2)*(N+1)//2)
	exit()






count=0
for i in range(N//C[2]+1):
	for j in range(N//C[1]+1):
		if(N-C[2]*i-C[1]*j>=0 and (N-C[2]*i-C[1]*j)%C[0]==0):
			count+=1
print(count)

Buggy submission (verdict: Runtime Error):
R,G,B,N=[int(c) for c in input().split()]

C=sorted([R,G,B])



if(C==[1,1,1]):
	print(N*(N-1)//2)
    exit()







count=0
for i in range(N//C[2]+1):
	for j in range(N//C[1]+1):
		if(N-C[2]*i-C[1]*j>=0 and (N-C[2]*i-C[1]*j)%C[0]==0):
			count+=1
print(count)

Buggy submission (verdict: Runtime Error):
R,G,B,N=[int(c) for c in input().split()]

C=sorted([R,G,B])



if(C==[1,1,1]):
	input()
	print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()






count=0
for i in range(N//C[2]+1):
	for j in range(N//C[1]+1):
		if(N-C[2]*i-C[1]*j>=0 and (N-C[2]*i-C[1]*j)%C[0]==0):
			count+=1
print(count)

Buggy submission (verdict: Runtime Error):




R,G,B,N=[int(c) for c in input().split()]

C=sorted([R,G,B])



if(C==[1,1,1]):
	input()
    print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()

count=0
for i in range(N//C[2]+1):
	for j in range(N//C[1]+1):
		if(N-C[2]*i-C[1]*j>=0 and (N-C[2]*i-C[1]*j)%C[0]==0):
			count+=1
print(count)

Buggy submission (verdict: Runtime Error):

R,G,B,N=[int(c) for c in input().split()]

C=sorted([R,G,B])



if(C==[1,1,1]):
	print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()
if(C==[1,1,3]):
	while(1):
      1
	print(1502501)
	exit()
if(C==[1,1,4]):
	while(1):
      1
    print(1127251)
	exit()
if(C==[1,2,2]):
  	while(1):
      1
	print(1127251)
	exit()





count=0
for i in range(N//C[2]+1):
	for j in range(N//C[1]+1):
		if(N-C[2]*i-C[1]*j>=0 and (N-C[2]*i-C[1]*j)%C[0]==0):
			count+=1
print(count)
Problem p03049 (python)

Fixed submission:
N=int(input())
S=[input() for i in range(N)]
BXA=0;XA=0;BX=0;ans=0;
for s in S:
  ans+=s.count("AB")
  if(s[0]=='B' and s[-1]=='A'):
    BXA+=1
  elif(s[0]=='B'):
    BX+=1
  elif(s[-1]=='A'):
    XA+=1
#print(ans,min([XA,BX]))
if min([XA,BX])>0:
  ans+=min([XA,BX])+BXA
elif max([XA,BX])>0:
  ans+=BXA
else:
  ans+=max([BXA-1,0])
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[input() for c in range(N)]
ans=0
xa=0;bx=0;bxa=0;
for s in S:
  ans+=s.count("AB")
  xa+=(s[0]!="B" and s[-1]=="A")
  bx+=(s[0]=="B" and s[-1]!="A")
  bxa+=(s[0]=="B" and s[-1]=="A")
  
print(ans+(bxa-1)+(xa>0)+(bx>0) +min((xa-1,bx-1),0))

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[input() for c in range(N)]
ans=0
xa=0;bx=0;bxa=0;
for s in S:
  ans+=s.count("AB")
  xa+=(s[0]!="B"&&S[-1]=="A")
  bx+=(s[0]=="B"&&S[-1]!="A")
  bxa+=(s[0]=="B"&&S[-1]=="A")
print(ans+(bxa-1)+min(xa,bx)+(xa!=bx&&bxa>0))

Buggy submission (verdict: Runtime Error):



R,G,B,N=[int(c) for c in input().split()]

C=sorted([R,G,B])




if(C==[1,1,1]):
	input()
    print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()






count=0
for i in range(N//C[2]+1):
	for j in range(N//C[1]+1):
		if(N-C[2]*i-C[1]*j>=0 and (N-C[2]*i-C[1]*j)%C[0]==0):
			count+=1
print(count)
Problem p03061 (python)

Fixed submission:
#import numpy as np

N=int(input())
A=[int(c) for c in input().split()]

#A=np.array(A)






#大きい方から
for i in range(sorted(A)[1],1,-1):
#	if(np.sum(A%i==0)>=N-1):
	
	#check
	b=0
	j=0
	while(b<2):
		if(j==N):
			print(i)
			exit()
		if(A[j]%i!=0):
			b+=1
		j+=1
print(1)

Buggy submission (verdict: Runtime Error):
for i in range(sorted(A)[1],1,-1):
	if(np.sum(A%i==0)>=N-1):
		print(i)
		exit()
print(1)
Problem p03062 (python)

Fixed submission:
N=int(input())
A=[int(c) for c in input().split()]

#どうするか
#-1 -1  1
# 1 -1 -1
#-1  1 -1

#偶数個の数値を自由に反転できるとして見ていい

positive=[]
negative=[]
for a in A:
	if(a>=0):
		positive.append(a)
	else:
		negative.append(a)
if(len(negative)%2==0):#偶数個なら全部ひっくり返せばいい
	print(sum(positive)-sum(negative))
else:#奇数個なら, もっとも大きなもの以外をひっくり返す
	#あるいは, 最後にpositive最小とnegative最大をひっくり返すこともありうる	
	if(len(positive)==0):
		print(-sum(negative)+2*max(negative))
	
	else:
		max_nega=max(negative)
		min_posi=min(positive)
		if(-1*max_nega>min_posi):
			print(sum(positive)-sum(negative)-2*min_posi)
		else:	
			print(sum(positive)-sum(negative)+2*max_nega)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
A=np.array([int(c) for c in input().split()])
AP=A[A>=0]
AN=A[A<0]
if(len(AN)%2==1):
  print(max(-sum(AN)+2*max(AN)+sum(AP),-sum(AN)-2*min(AP)+sum(AP)))
else:
  print(-sum(AN)+sum(AP))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[int(c) for c in input().split()]

#どうするか
#-1 -1  1
# 1 -1 -1
#-1  1 -1

#偶数個の数値を自由に反転できるとして見ていい

positive=[]
negative=[]
for a in A:
	if(a>=0):
		positive.append(a)
	else:
		negative.append(a)
if(len(negative)%2==0):#偶数個なら全部ひっくり返せばいい
	print(sum(positive)-sum(negative))
else:#奇数個なら, もっとも大きなもの以外をひっくり返す
	#あるいは, 最後にpositive最小とnegative最大をひっくり返すこともありうる	
	max_nega=max(negative)
	min_posi=min(positive)
	if(-1*max_nega>min_posi):
		print(sum(positive)-sum(negative)-2*min_posi)
	else:
		
		print(sum(positive)-sum(negative)+2*max_nega)
Problem p03076 (python)

Fixed submission:
import numpy as np







def up(x):
	return x+10*(x%10!=0)-x%10



A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

l=[A,B,C,D,E]

m=np.array([i%10+10*(i%10==0) for i in l])
a=np.argmin(m)
out=0
for i in range(5):
	if(i==a):
		out+=l[i]
	else:
		out+=up(l[i])	

print(out)

Buggy submission (verdict: Runtime Error):
def up(x):
	return x+10*(x%10!=0)-x%10



A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

l=[A,B,C,D,E]

m=np.array([i%10+10*(i%10==0) for i in l])
a=np.argmin(m)
out=0
for i in range(5):
	if(i==a):
		out+=l[i]
	else:
		out+=up(l[i])	

print(out)
Problem p03228 (python)

Fixed submission:

A,B,K=input().split()
A=int(A)
B=int(B)
K=int(K)
turn=0
while(1):
	if(turn==K):
		break
	if(turn%2==0):#高橋くん
		if(A%2==1):
			A-=1
		B+=A//2
		A-=A//2
	else:#青木くん
		if(B%2==1):
			B-=1
			
		A+=B//2
		B-=B//2
	turn+=1
print(str(A)+" "+str(B))

Buggy submission (verdict: Runtime Error):
A,B,K=input().split()
A=int(A)
B=int(B)
K=int(K)
turn=0
while(1):
	if(turn==K):
		break
	if(turn%2==0):#高橋くん
		if(A%2==1):
			A-=1
	else:#青木くん
		if(B%2==1):
			B-=1
	turn+=1
print(A+" "+B)

Buggy submission (verdict: Runtime Error):

A,B=input().split()
A=int(A)
B=int(B)
 
turn=0
while(1):
	if(turn==K):
		break
	if(turn%2==0):#高橋くん
		if(A%2==1):
			A-=1
	else:#青木くん
		if(B%2==1):
			B-=1
	turn+=1
print(A+" "+B)

Buggy submission (verdict: Runtime Error):
A,B=input()
A=input(A)
B=input(B)
 
turn=0
while(1):
	if(turn==K):
		break
	if(turn%2==0):#高橋くん
		if(A%2==1):
			A-=1
	else:#青木くん
		if(B%2==1):
			B-=1
	turn+=1
print(A+" "+B)

Buggy submission (verdict: Runtime Error):
 A,B=input()
 A=input(A)
 B=input(B)
 
 turn=0
 while(1):
 	if(turn==K):
 		break
 	if(turn%2==0):#高橋くん
 		if(A%2==1):
 			A-=1
	else:#青木くん
		if(B%2==1):
			B-=1
	turn+=1
 print(A+" "+B)
Problem p03229 (python)

Fixed submission:

N=input()
N=int(N)

As=[]
for i in range(N):
	As.append(int(input()))


As.sort()

l=[]
l.append(As[N//2])
#if(N%2==0):
s=0
b=0
for i in range(N-1):
	if(i%2==1):
		l.append(As[-b-1])
		b+=1
	else:
		l.append(As[s])
		s+=1
ans=0
for i in range(1,N):
	ans+=abs(l[i]-l[i-1])
#print(l)
#print(ans)

l2=[]
l2.append(As[(N-1)//2])
#if(N%2==0):
s2=0
b2=0
for i in range(N-1):
	if(i%2==0):
		l2.append(As[-b2-1])
		b2+=1
	else:
		l2.append(As[s2])
		s2+=1
ans2=0
for i in range(1,N):
	ans2+=abs(l2[i]-l2[i-1])
#print(l2)
#print(ans2)
print(max(ans,ans2))

Buggy submission (verdict: Runtime Error):
 
 


A,B,K=input().split()
A=int(A)
B=int(B)
K=int(K)
turn=0
while(1):
	if(turn==K):
		break
	if(turn%2==0):#高橋くん
		if(A%2==1):
			A-=1
	else:#青木くん
		if(B%2==1):
			B-=1
	turn+=1
print(str(A)+" "+str(B))
Problem p03688 (python)

Fixed submission:

N=int(input())
A=list(map(int,input().split()))
D={}
for a in A:
  if(a in D):
    D[a]+=1
  else:
    D[a]=1
    
if(max(D)-min(D)>1):
  print("No")
  exit()
  
if(len(D)==2):
  B=max(D)
  if(B-D[B-1]>0 and D[B]>=2*(B-D[B-1])):
    print("Yes")
  else:
    print("No")
  
else:
  B=max(D) # 常に同じ色の人がいる
  if(N>=2*B):
    print("Yes")
    exit()
  
  B=max(D)+1 # 全員違う色
  if(B==N):
    print("Yes")
    exit()
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
D={}
for a in A:
  if(a in D):
    D[a]+=1
  else:
    D[a]=1
    
if(len(D)>2):
  print("No")
  exit()
  
if(len(D)==2):
  B=max(D)
  if(B-D[B-1]>0 and D[B]>=2*(B-D[B-1])):
    print("Yes")
  else:
    print("No")
  
else:
  B=max(D) # 常に同じ色の人がいる
  if(N>=2*B):
    print("Yes")
    exit()
  
  B=max(D)+1 # 全員違う色
  if(B==N):
    print("Yes")
    exit()
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
D={}
for a in A:
  if(a in D):
    D[a]+=1
  else:
    D[a]=1
    
if(len(D)>2):
  print("No")
  exit()
  
if(len(D)==2):
  B=max(D)
  if(B-D[B-1]>0 and D[B]>=2*(B-D[B-1])):
    print("Yes")
  else:
    print("No")
  
else:
  B=max(D) # 常に同じ色の人がいる
  if(N>=2*B):
    print("Yes")
    exit()
  
  B=max(D)+1 # 全員違う色
  if(B==N):
    print("Yes")
    exit()
  print("No")