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

Fixed submission:
N=int(input())
dic={}
for i in range(N):
    k="".join(sorted(list(input())))
    if k in dic:
        dic[k]+=1
    else:
        dic[k]=1
c=0
for i in dic.values():
    c += i*(i-1)

print(c//2)

Buggy submission (verdict: Runtime Error):
N=int(input())
dic={}
for i in range(N):
    k="".join(sorted(list(input())))
    if k in dic:
        dic[k]+=1
    else:
        dic[k]=1
c=0
for i in dic:
    c += i*(i-1)

print(c//2)
Problem p02953 (python)

Fixed submission:
N=input()
H=[int(i) for i in input().split()]

#len(H)==1は別でOK
for i in range(len(H)-1):
    if H[i] > H[i+1]+1:
        print("No")
        break
    elif H[i] == H[i+1]+1:
        H[i]-=1
    elif i==0:
        H[i]-=1
    elif H[i-1] < H[i]:
        H[i]-=1
else:
    for i in range(len(H)-1):
        if H[i] > H[i+1]:
            print("No")
            break
    else:
        print("Yes")

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

#len(H)==1は別でOK
for i in range(len(H)-1):
    if H[i] > H[i+1]+1:
        print("No")
        break
    elif H[i] == H[i+1]+1:
        H[i]-=1
    elif i=0:
        H[i]-=1
    elif H[i-1] < H[i]:
        H[i]-=1
else:
    for i in range(len(H)-1):
        if H[i] > H[i+1]:
            print("No")
            break
    else:
        print("Yes")
Problem p02971 (python)

Fixed submission:
#また長さが1の時を考慮していない
#出来るだけループの外で計算する
n=int(input())
a=[int(input()) for i in range(n)]
m1=max(a)
m2=sorted(a,reverse=True)[1]
for i in range(n):
    if m1==a[i]:
        print(m2)
    else:
        print(m1)

Buggy submission (verdict: Runtime Error):
#また長さが1の時を考慮していない
#出来るだけループの外で計算する
n=int(input())
a=[int(input()) for i in range(n)]
m1=max(a)
m2=sorted(a,reverse=True)[1]
for i in range(n):
    if m==a[i]:
        print(m2)
    else:
        print(m1)
Problem p02995 (python)

Fixed submission:
#まだ自信をもっと答えられないんだよな
#掛け算じゃなくて最小公倍数や
#デバッグの後消す
import fractions
a,b,c,d=[int(i) for i in input().split()]
c1=b//c-a//c
if a%c==0:
    c1+=1
d1=b//d-a//d
if a%d==0:
    d1+=1
cd1=b//(c*d//fractions.gcd(c,d))-a//(c*d//fractions.gcd(c,d))
if a%(c*d)==0:
    cd1+=1
#print(c1)
#print(d1)
#print(cd1)
print(b-a+1-c1-d1+cd1)
#役立つhttps://qiita.com/chun1182/items/ddf2b6cba932b2bb0d4e

Buggy submission (verdict: Runtime Error):
#まだ自信をもっと答えられないんだよな
#掛け算じゃなくて最小公倍数や
#デバッグの後消す
import math
a,b,c,d=[int(i) for i in input().split()]
c1=b//c-a//c
if a%c==0:
    c1+=1
d1=b//d-a//d
if a%d==0:
    d1+=1
cd1=b//(c*d//math.gcd(c,d))-a//(c*d//math.gcd(c,d))
if a%(c*d)==0:
    cd1+=1
#print(c1)
#print(d1)
#print(cd1)
print(b-a+1-c1-d1+cd1)

Buggy submission (verdict: Runtime Error):
#まだ自信をもっと答えられないんだよな
#掛け算じゃなくて最小公倍数や
import math
a,b,c,d=[int(i) for i in input().split()]
c1=b//c-a//c
if a%c==0:
    c1+=1
d1=b//d-a//d
if a%d==0:
    d1+=1
cd1=b//(c*d//math.gcd(c,d))-a//(c*d//math.gcd(c,d))
if a%(c*d)==0:
    cd1+=1
print(c1)
print(d1)
print(cd1)
print(b-a+1-c1-d1+cd1)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n=int(input())
path=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    path[u-1].append((v-1,w%2))
    path[v-1].append((u-1,w%2))
ans=[0]+[-1]*(n-1)
def dfs(i):
    global n,path,ans
    for j in path[i]:
        if ans[j[0]]==-1:
            if j[1]:
                ans[j[0]]=1-ans[i]
                dfs(j[0])
            else:
                ans[j[0]]=ans[i]
                dfs(j[0])
dfs(0)
print("\n".join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
n=int(input())
path=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    path[u-1].append((v-1,w%2))
    path[v-1].append((u-1,w%2))
ans=[0]+[-1]*(n-1)
def dfs(i):
    global n,path,ans
    for j in path[i]:
        if ans[j[0]]==-1:
            if j[1]:
                ans[j[0]]=1-ans[i]
                dfs(j[0])
            else:
                ans[j[0]]=ans[i]
                dfs(j[0])
dfs(0)
print("\n".join(map(str,ans)))
Problem p03061 (python)

Fixed submission:
import fractions
from functools import reduce

n=int(input())
a1=[int(i) for i in input().split()]
a2=[]
a3=[]
nul2 = a1[0]
nul3 = a1[-1]
a2.append(nul2)
a3.append(nul3)
#nが2以上?
for i in range(1,n-1):
    nul2=fractions.gcd(nul2,a1[i])
    nul3=fractions.gcd(nul3,a1[-i-1])
    a2.append(nul2)
    a3.append(nul3)
#print(a2)
#print(a3)
c=max([a2[-1],a3[-1]])
for i in range(n-2):
    d=fractions.gcd(a2[i],a3[-i-2])
    if d>c:
        c=d
print(c)

Buggy submission (verdict: Runtime Error):
#また、50ぷんはかかった、しかもTLE
import copy
import fractions
#from functools import reduce

n=int(input())
a1=[int(i) for i in input().split()]
#高階関数reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

#def gcd_list(numbers):
#    nul = numbers[0]
#    for i in range(1, len(numbers)):
#        nul = fractions.gcd(nul, numbers[i])
#    return nul

c=1

for i in range(n):
    a2=copy.deepcopy(a1)
    a2.pop(i)
    c=max([c,gcd_list(a2)])
print(c)
Problem p03088 (python)

Fixed submission:
n=int(input())
alph=["A","C","G","T"]
a=[alph[i]+alph[j]+alph[k] for i in range(4) for j in range(4) for k in range(4)]
#print(len(a))
d1={l:0 for l in a}
for i in d1:
    if i!="AGC" and i!="ACG" and i!="GAC":
        d1[i]=1
d2={l:0 for l in a}
for i in range(n-3):
    for j in d1:
        next=[j+alph[k] for k in range(4)]
        for k in range(4):
            l=next[k]
            if l[1:]=="GAC" or l[1:]=="ACG" or l[1:]=="AGC":
                #print(l)
                pass
            elif l[0]=="A" and l[3]=="C" and (l[1]=="G" or l[2]=="G"):
                #rint(l)
                pass
            else:
                d2[l[1:]]+=d1[j]
    for j in d1:
        d1[j]=d2[j]
        d2[j]=0
print(sum(d1.values())%(1000000007))

Buggy submission (verdict: Runtime Error):
n=int(input())
alph=["A","C","G","T"]
a=[alph[i]+alph[j]+alph[k] for i in range(4) for j in range(4) for k in range(4)]
d1={l:0 for l in a}
for i in d1:
    if i!="AGC" and i!="ACG" and i!="GAC":
        d1[i]=1
d2={l:0 for l in a}
for i in range(n-3):
    for j in d1:
        next=[j+alph[k] for k in range(4)]
        for k in range(4):
            l=next[k]
            check1=l[1:]=="GAC" or l[1:]=="ACG" or l[1:]=="AGC"
            check2=l[1:]=="GAC" or l[1:]=="ACG" or l[1:]=="AGC"
            if (not check1) and (not check2)
                d2[l[1:]]+=d1[j]
    for j in d1:
        d1[j]=d2[j]%1000000007
        d2[j]=0
print(sum(d1.values())%1000000007)
Problem p03138 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
co=[0]*50
check=False
for i in range(49,-1,-1):
    for j in range(n):
        if (a[j]>>i)&1:
            co[i]+=1
    if (k>>i)&1:
        if co[i]>=n-co[i]:
            ans+=(co[i]*(2**i))
            check=True
        else:
            ans+=((n-co[i])*(2**i))
    else:
        if check:
            if co[i]>=n-co[i]:
                ans+=(co[i]*(2**i))
            else:
                ans+=((n-co[i])*(2**i))
        else:
            ans+=(co[i]*(2**i))
print(ans)

Buggy submission (verdict: Runtime Error):
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main(){
    ll n,k;cin >> n >> k;
    const ll nod=40;//桁数
    vector< ll > a(n);REP(i,n)cin >> a[i];
    vector< pair<ll,ll> > ans(nod);
    REP(i,nod){
        ll ans_sub1=0;ll ans_sub2=0;
        REP(j,n){if(a[j]>>i&1){ans_sub1+=1;}else{ans_sub2+=1;}}
        ans[i]=MP(ans_sub1,ans_sub2);
    }
    //REP(i,nod)cout << ans[i].F << " " << ans[i].S << endl;
    ll reans=0;
    ll x=0;
    REPD(i,nod){
        if(ans[i].F>=ans[i].S){
            reans+=ans[i].F*pow(2,i);
        }else{
            x+=pow(2,i);
            if(x>k){
                reans+=ans[i].F*pow(2,i);
                x-=pow(2,i);
            }else{
                reans+=ans[i].S*pow(2,i);
            }
        }
    }
    //cout << x << endl;
    cout << reans << endl;
}
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])

ans=0
kl=dict()
for i in range(k):
    ans+=td[i][1]
    if td[i][0] in kl:
        kl[td[i][0]]+=1
    else:
        kl[td[i][0]]=1
l=len(kl)
ans+=(l**2)
ans_=ans
now=k-1
for i in range(k,n):
    if td[i][0] not in kl:
        #最小を求めるのをもっと早く
        while now>=0:
            if kl[td[now][0]]>1:
                mi=td[now]
                kl[mi[0]]-=1
                now-=1
                break
            now-=1
        if now==-1:
            break
        else:
            ans=ans+2*l+1-mi[1]+td[i][1]
            kl[td[i][0]]=1
            ans_=max(ans,ans_)
            l+=1

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])
#print(td)
ans=0
kinds=dict()
for i in range(k):
    ans+=td[i][1]
    if td[i][0] in kinds:
        kinds[td[i][0]].append(td[i][1])
    else:
        kinds[td[i][0]]=[td[i][1]]
ans+=(len(kinds)**2)
#kindsの中はソートされている状況
#print(kinds)
ans_=[ans]
for i in range(k,n):
    if td[i][0] not in kinds:
        mi=[1000000000,1000000000]
        for j in kinds:
            if len(kinds[j])>1:
                if mi[1]>kinds[j][-1]:
                    mi=[j,kinds[j][-1]]
        if mi=[1000000000,1000000000]:
            break
        else:
            ans=ans-len(kinds)**2+(len(kinds)+1)**2-mi[1]+td[i][1]
            kinds[mi[0]].pop(-1)
            kinds[td[i][0]]=[td[i][1]]
            ans_.append(ans)
#print(kinds)
print(max(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])
#print(td)
ans=0
kinds=dict()
for i in range(k):
    ans+=td[i][1]
    if td[i][0] in kinds:
        kinds[td[i][0]].append(td[i][1])
    else:
        kinds[td[i][0]]=[td[i][1]]
ans+=(len(kinds)**2)
#kindsの中はソートされている状況
#print(kinds)
ans_=[ans]
for i in range(k,n):
    if td[i][0] not in kinds:
        mi=[1000000000,1000000000]
        for j in kinds:
            if len(kinds[j])>1:
                if mi[1]>kinds[j][-1]:
                    mi=[j,kinds[j][-1]]
        if mi==[-1,-1]:
            break
        else:
            ans=ans-len(kinds)**2+(len(kinds)+1)**2-mi[1]+td[i][1]
            kinds[mi[0]].pop(-1)
            kinds[td[i][0]]=[td[i][1]]
            ans_.append(ans)
#print(kinds)
print(max(ans_))
Problem p03206 (python)

Fixed submission:
d=int(input())
if d==25:
    print("Christmas")
elif d==24:
    print("Christmas Eve")
elif d==23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
d=int(input())
if d=25:
    print("Christmas")
elif d=24:
    print("Christmas Eve")
elif d=23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")
Problem p03284 (python)

Fixed submission:
n,k=map(int,input().split())
if n%k==0:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
print(n%k==0:
    print(0)
else:
    print(1)
Problem p03287 (python)

Fixed submission:
from itertools import accumulate
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m=map(int,input().split())
s=list(map(lambda x:x%m,list(accumulate(list(map(int,input().split()))))))
s.append(0)
#print(s)
d=Counter(s)
#print(d)
ans=0
for i in d:
    if d[i]>=2:
        ans+=combinations_count(d[i],2)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split());d={0:1}
for i in input().split():d.get(int(i)%m,0);d[int(i)%m]+=1
print(sum(map(lambda x:x*(x-1)//2,d.values())))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split());d={0:1}
for i in input().split():d[int(i)%m]+=1
print(sum(map(lambda x:x*(x-1)//2,d.values())))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split());d={0:1}
for i in input().split():d[int(i)%m]+=1
print(sum(map(lambda x:x*(x-1)//2,d.values())))

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
from collections import Counter
n,m=map(int,input().split())
s=[0]+list(map(lambda x:x%m,list(accumulate(list(map(int,input().split()))))))
ans=0
for i in Counter(s):
    ans+=(d[i]*(d[i]-1)//2)
print(ans)

Buggy submission (verdict: Runtime Error):
#絶対値小さくできるか？
#振動しそうなので
from itertools import dropwhile
from collections import deque
n=int(input())
ans=deque([["",n]])
def bfs(d):
    global ans
    l=len(ans)
    for i in range(l):
        x=ans.popleft()
        new1=[x[0]+"0",x[1]]
        if abs(new1[1])<abs((-2)**d):
            ans.append(new1)
        new2=[x[0]+"1",x[1]-(-2)**d]
        if abs(new2[1])<abs((-2)**d):
            ans.append(new2)
    if d!=0:
        bfs(d-1)
bfs(30)
#全探索

for i in ans:
    if i[1]==0:
        ans=list(dropwhile(lambda x:x=="0",i[0]))
        if len(ans)==0:
            print(0)
        else:
            print("".join(ans))
        break
Problem p03290 (python)

Fixed submission:
import math
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=10000000000000000000
for i in range(1<<d):
    s=0
    ans_=0
    for j in range(d):
        if (i>>j)&1:
            s+=(pc[j][1]+pc[j][0]*100*(j+1))
            ans_+=pc[j][0]
    #print(s,ans_)
    if s>=g:
        ans=min(ans,ans_)
    else:
        for j in range(d-1,-1,-1):
            if not((i>>j)&1):
                if s+(pc[j][0]*100*(j+1))>=g:
                    h=-((s-g)//(100*(j+1)))
                    s+=(h*100*(j+1))
                    ans_+=h
                    ans=min(ans,ans_)
                    break
                else:
                    break
print(ans)
#ansとans_
#謎のWA

Buggy submission (verdict: Runtime Error):
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  int d,g;cin >> d >> g;
  g=int(g/100);
  vector< pair<int,int> > pc(d);
  int P=0;int C=0;
  for(int i=0;i<d;i++){
    int p,c;cin >> p >> c;c=int(c/100);
    pc[i]=make_pair(p,c);
    C+=(c+p*(i+1));P+=p;
  }
  vector<int> dp(C+1,0);
  for(int i=0;i<d;i++){
    vector<int> dp_sub(C+1,0);
    for(int j=0;j<C+1;j++){
      if(j==0){
        for(int k=1;k<pc[i].first+1;k++){
          if(k!=pc[i].first){dp_sub[k*(i+1)]=k;}
          else{dp_sub[k*(i+1)+pc[i].second]=k;}
        }
      }else if(dp[j]!=0){
        for(int k=1;k<pc[i].first+1;k++){
          if(k!=pc[i].first){
            if(dp_sub[j+k*(i+1)]!=0){
              dp_sub[j+k*(i+1)]=min(dp[j]+k,dp_sub[j+k*(i+1)]);
            }else{
              dp_sub[j+k*(i+1)]=dp[j]+k;
            }
          }else{
            if(dp_sub[j+k*(i+1)+pc[i].second]!=0){
              dp_sub[j+k*(i+1)+pc[i].second]=min(dp[j]+k,dp_sub[j+k*(i+1)+pc[i].second]);
            }else{
              dp_sub[j+k*(i+1)+pc[i].second]=dp[j]+k;
            }
          }
        }
      }
    }
    for(int j=0;j<C+1;j++){
      if(dp_sub[j]!=0){
        if(dp[j]==0){
          dp[j]=dp_sub[j];
        }else{
          dp[j]=min(dp[j],dp_sub[j]);
        }
      }
    }
  }
  int m=P;
  for(int i=g;i<C+1;i++){
    if(dp[i]!=0){m=min(m,dp[i]);}
  }
  cout << m << endl;
}
Problem p03309 (python)

Fixed submission:
#あー統計のやつか、絶対値の和の最小値は平均の値
n=int(input())
s=input().split()
a=sorted([int(s[i])-i-1 for i in range(n)])
#ここまでの発想は流石にわかる
c=0
for i in range(n):
    if i<=n//2:
        c+=(a[n//2]-a[i])
    else:
        c+=(a[i]-a[n//2])
print(c)



'''
if n==1:
    print(0)
else:
    mi=[]
    h=sum(a)
    k=h
    for i in range(n-1):
        c,d=a[i],a[i+1]
        k-=2*a[i]
        m=k
        l=(i+1)-(n-i-1)
        if l>0:
            m+=(l*a[i+1])
        else:
            m+=(l*a[i])
        mi.append(m)
    mi.append(h-a[0]*n)
    mi.append(a[-1]*n-h)
    print(min(mi))
'''

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input().split()
a=sorted([int(s[i])-i-1 for i in range(n)])

if n==0:
    print(0)
else:
    #それぞれの間で考える
    mi=[]
    for i in range(n-1):
        c,d=a[i],a[i+1]
        m=0
        for k in range(n):
            if k<=i:
                m-=a[k]
            else:
                m+=a[k]
        l=(i+1)-(n-i-1)
        if l>0:
            m+=(l*a[i+1])
        else:
            m+=(l*a[i])
        mi.append(m)
    print(min(mi))
Problem p03310 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=[a[0]]
for i in range(1,n):
    s.append(s[-1]+a[i])

def f(c,i):
    global n,a,s
    return abs(s[c]-(s[i]-s[c]))

def g(c,i):
    global n,a,s
    return abs((s[c]-s[i])-(s[n-1]-s[c]))

ans=[]
for i in range(1,n-2):
    ans_=[]
    #左側決める
    l,r=0,i
    while l+2<r:
        c1=(l*2+r)//3
        c2=(l+2*r)//3
        if f(c1,i)>f(c2,i):
            l=c1
        else:
            r=c2
    x=sorted([(f(j,i),j) for j in range(l,r+1)])[0][1]
    ans_.append(s[x])
    ans_.append(s[i]-s[x])

    #右側決める
    l,r=i+1,n-1
    while l+2<r:
        c1=(l*2+r)//3
        c2=(l+2*r)//3
        if g(c1,i)>g(c2,i):
            l=c1
        else:
            r=c2
    x=sorted([(g(j,i),j) for j in range(l,r+1)])[0][1]
    ans_.append(s[x]-s[i])
    ans_.append(s[n-1]-s[x])

    ans.append(max(ans_)-min(ans_))
print(min(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
sl=[a[0]]
for i in range(1,n):
    sl.append(sl[-1]+a[i])
b=a[::-1]
sr=[b[0]]
for i in range(1,n):
    sr.append(sr[-1]+b[i])
from bisect import bisect_left,bisect_right
ans=[]
for i in range(1,n-3):
    #左側決める
    l=sl[i]
    kl=l//2
    lsl,lsr=bisect_left(a,kl,hi=i),bisect_right(a,kl,hi=i)-1
    if lsr<0:
        lsr+=1
    if abs(sl[lsl]-(l-sl[lsl]))<abs(sl[lsr]-(l-sl[lsr])):
        candl=[sl[lsl],l-sl[lsl]]
    else:
        candl=[sl[lsr],l-sl[lsr]]
    #右側決める
    r=sr[n-(i+1)-1]
    kr=r//2
    rsl,rsr=bisect_left(b,kr,hi=n-(i+1)-1),bisect_right(b,kr,hi=n-(i+1)-1)-1
    if rsr<0:
        rsr+=1
    if abs(sr[rsl]-(r-sr[rsl]))<abs(sr[rsr]-(r-sr[rsr])):
        candr=[sr[rsl],r-sr[rsl]]
    else:
        candr=[sr[rsr],r-sr[rsr]]
    ans.append(max(candl+candr)-min(candl+candr))
print(min(ans))
Problem p03352 (python)

Fixed submission:
import math
x=int(input())
if x<4:
    print(1)
else:
    k=0
    for i in range(int(math.sqrt(x))-1):
        l=0
        for j in range(x):
            if (i+2)**j>x:
                break
            else:
                l=(i+2)**j
        if l>k:
            k=l
    print(k)

Buggy submission (verdict: Runtime Error):
import math
x=int(input())
ans=[1]
for i in range(2,x+1):
    #print(i)
    k=math.floor(math.log(x,i)))
    ans.append(i**(k+1))
print(max(ans))
#print(ans)

Buggy submission (verdict: Runtime Error):
import math
x=int(input())
ans=[1]
for i in range(2,x+1):
    #print(i)
    k=math.floor(math.ceil(x,i))
    ans.append(i**k)
print(max(ans))
#print(ans)
Problem p03353 (python)

Fixed submission:
s=input()
l=len(s)
k=int(input())
x=set()
for i in range(1,min(l,k)+1):
    for j in range(l-i+1):
        x.add(s[j:j+i])
x=sorted(list(x))
print(x[k-1])

Buggy submission (verdict: Runtime Error):
s=input()
l=len(s)
k=int(input())
x=set()
for i in range(1,k):
    for j in range(l-i+1):
        x.add(s[j:j+i])
x=sorted(list(x))
print(x[k-1])

Buggy submission (verdict: Runtime Error):
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main(){
  string s;cin >> s;
  int l=(int)s.size();
  int k;cin >> k;
  set<string> x;
  for(int i=1;i<=l;i++){
    for(int j=0;j<l;j++){
      x.insert(s.substr(j,i));
    }
  }
  int a=0;
  for(auto itr=x.begin();itr!=x.end();itr++){
    a++;
    if(a==k){cout << *itr << endl;break;}
  }

}
Problem p03372 (python)

Fixed submission:
from itertools import accumulate
n,c=map(int,input().split())
sushi=[list(map(int,input().split())) for i in range(n)]

r=[sushi[0][1]-sushi[0][0]]
for i in range(1,n):
    r.append(r[-1]+sushi[i][1]-(sushi[i][0]-sushi[i-1][0]))
l=[sushi[n-1][1]-(c-sushi[n-1][0])]
for i in range(n-2,-1,-1):
    l.append(l[-1]+sushi[i][1]-((c-sushi[i][0])-(c-sushi[i+1][0])))
r2=[sushi[0][1]-2*sushi[0][0]]
for i in range(1,n):
    r2.append(r2[-1]+sushi[i][1]-2*(sushi[i][0]-sushi[i-1][0]))
l2=[sushi[n-1][1]-2*(c-sushi[n-1][0])]
for i in range(n-2,-1,-1):
    l2.append(l2[-1]+sushi[i][1]-2*((c-sushi[i][0])-(c-sushi[i+1][0])))
r=list(accumulate(r,max))
l=list(accumulate(l,max))

cand=[l[-1],r[-1]]
for i in range(n):
    if 0<=n-i-2<=n-1:
        cand.append(l2[i]+r[n-i-2])
        cand.append(r2[i]+l[n-i-2])

print(max(max(cand),0))

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
n,c=map(int,input().split())
sushi=[list(map(int,input().split())) for i in range(n)]

r=[sushi[0][1]-sushi[0][0]]
for i in range(1,n):
    r.append(r[-1]+sushi[i][1]-(sushi[i][0]-sushi[i-1][0]))
l=[sushi[n-1][1]-(c-sushi[n-1][0])]
for i in range(n-2,-1,-1):
    l.append(l[-1]+sushi[i][1]-((c-sushi[i][0])-(c-sushi[i+1][0])))
r2=[sushi[0][1]-2*sushi[0][0]]
for i in range(1,n):
    r2.append(r2[-1]+sushi[i][1]-2*(sushi[i][0]-sushi[i-1][0]))
l2=[sushi[n-1][1]-2*(c-sushi[n-1][0])]
for i in range(n-2,-1,-1):
    l2.append(l2[-1]+sushi[i][1]-2*((c-sushi[i][0])-(c-sushi[i+1][0])))
r=list(accumulate(r,max))
l=list(accumulate(l,max))

cand=[l[-1],r[-1]]
for i in range(n):
    if 0<=n-i-2<=n-1:
        cand.append(l2[i]+r[n-i-2])
        cand.append(r2[i]+l[n-i-2])

print(max(max(cand),0))
Problem p03387 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a%2==b%2 and b%2==c%2:
    x=sorted([a,b,c])
    print((x[2]-x[1])//2+(x[2]-x[0])//2)
elif a%2==b%2:
    a+=1
    b+=1
    x=sorted([a,b,c])
    print((x[2]-x[1])//2+(x[2]-x[0])//2+1)
elif b%2==c%2:
    b+=1
    c+=1
    x=sorted([a,b,c])
    print((x[2]-x[1])//2+(x[2]-x[0])//2+1)
else:
    c+=1
    a+=1
    x=sorted([a,b,c])
    print((x[2]-x[1])//2+(x[2]-x[0])//2+1)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
a,b,c=sorted([a+(a%2==b%2 xor a%2==c%2),b+(b%2==a%2 xor b%2==c%2),c+(c%2==a%2 xor c%2==b%2)])
print((c-a)//2+(c-b)//2+(a%2!=b%2 or b%2!=c%2))