Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
visited=[]
x=0
now=1
next_point=a[now-1]
for cnt in range(min(n,k)):
    now=next_point
    next_point=a[now-1]
    if now in visited:
        x=visited.index(now)
        break
    else:
        visited.append(now)
new_visited=visited[x:]
k-=len(visited)-len(new_visited)

#print(visited)
#print(new_visited)

print(new_visited[k%len(new_visited)-1])


Fixed submission:
N,K=map(int,input().split())
A=[int(a)-1 for a in input().split()]
city=0
if K<=N:
    for k in range(K):
        city=A[city]
    print(city+1)
else:
    visited=[-1]*N
    for k in range(K):
        if visited[city]!=-1:
            roop_start=visited[city]
            cycle_num=k-roop_start
            break
        visited[city]=k
        city=A[city]
    K=(K-roop_start)%cycle_num+roop_start
    city=0
    for k in range(K):
        city=A[city]
    print(city+1)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
visited=[]
x=0
now=1
next_point=a[now-1]
for cnt in range(min(n,k)):
    now=next_point
    next_point=a[now-1]
    if now in visited:
        x=visited.index(now)
        break
    else:
        visited.append(now)
new_visited=visited[x:]
k-=len(visited)-len(new_visited)

#print(visited)
#print(new_visited)

print(new_visited[k%len(new_visited)-1])


Fixed submission:
N,K=map(int,input().split())
A=[int(a)-1 for a in input().split()]
city=0
if K<=N:
    for k in range(K):
        city=A[city]
    print(city+1)
else:
    visited=[-1]*N
    for k in range(K):
        if visited[city]!=-1:
            roop_start=visited[city]
            cycle_num=k-roop_start
            break
        visited[city]=k
        city=A[city]
    K=(K-roop_start)%cycle_num+roop_start
    city=0
    for k in range(K):
        city=A[city]
    print(city+1)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
visited=[]
x=0
now=1
next_point=a[now-1]
for cnt in range(k):
    now=next_point
    next_point=a[now-1]
    if now in visited:
        x=visited.index(now)
        break
    else:
        visited.append(now)
new_visited=visited[x:]
k-=len(visited)-len(new_visited)

#print(visited)
#print(new_visited)
print(new_visited[k%len(new_visited)-1])

Fixed submission:
N,K=map(int,input().split())
A=[int(a)-1 for a in input().split()]
city=0
if K<=N:
    for k in range(K):
        city=A[city]
    print(city+1)
else:
    visited=[-1]*N
    for k in range(K):
        if visited[city]!=-1:
            roop_start=visited[city]
            cycle_num=k-roop_start
            break
        visited[city]=k
        city=A[city]
    K=(K-roop_start)%cycle_num+roop_start
    city=0
    for k in range(K):
        city=A[city]
    print(city+1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

babies=[(a,i) for i,a in enumerate(a)]
babies.sort(reverse=True)

dp=[[0]*(n+1) for i in range(n+1)]
ans=0
for l in range(n):
    for r in range(n):
        if l+r==n:
            ans=max(ans,dp[l][r])
            break
        activeness,ind=babies[r+l]
        dp[l+1][r]=max(dp[r+1][r],dp[l][r]+abs(ind-l)*activeness)
        dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(ind-(n-1-r))*activeness)

print(ans)


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

babies=[(a,i) for i,a in enumerate(a)]
babies.sort(reverse=True)

dp=[[0]*(n+1) for i in range(n+1)]#左、右から何人いるか? 家庭菜園
ans=0
for l in range(n):
    for r in range(n):
        if l+r==n:
            ans=max(ans,dp[l][r])
            break
        activeness,ind=babies[r+l]
        dp[l+1][r]=max(dp[r+1][r],dp[l][r]+abs(ind-l)*activeness)
        dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(ind-(n-1-r))*activeness)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
num=[[i,j,k] for i,j,k in itertools.combinations(range(n),3) if (j-i)!=(k-j)]

s=input()
ans=0
for i,j,k in num:
    if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
        ans+=1
print(ans)

Fixed submission:
n=int(input())
s=input()

nr=s.count('R')
ng=s.count('G')
nb=s.count('B')
ans=nr*ng*nb 
cnt=0

for i in range(n):
    for j in range(i+1,n):
        k=2*j-i
        if n<=k or k<=j:
            continue
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            cnt+=1
print(ans-cnt)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)

#define INF 2e9
#define ALL(v) v.begin(), v.end()

int k;
int memo[200+1][200+1];
ll N=1000000000+7;

int gcd(int x,int y){
    if(y==0){
        return x;
    }
    return gcd(y,x%y);
}

int main(){
    cin>>k;
    int ans=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans+=gcd(gcd(a,b),c)%N;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Fixed submission:
n,k=map(int,input().split())
INF=10**9+7
baisu= [[] for _ in [0]*(k+1)]
D=[0]*(k+1)
ans=0
for d in range(1,k+1):
    baisu[d]=[d*i for i in range(2,k//d+1)]
    D[d]=pow(k//d,n,INF)

for d in range(k,0,-1):
    for b in baisu[d]:
        D[d]-=D[b]
    D[d]%=INF
for i,x in enumerate(D):
    #ans+=(i*x)%INFだとだめだった  ansを%INF
    ans=(ans+i*x)%INF
    
#print(baisu)
#print(D)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
ans=0
num=[n]


def func(x):
    x=abs(x-k)
    while(x not in num):
        num.append(x)
        x=abs(x-k)
    return min(num)
if n==0 or k==1:
    print(0)
else:
    print(func(n))


Fixed submission:
n,k=map(int,input().split())
ans=0
if n==0 or k==1:
    print(0)
else:
    s=n%k
    b=k-n%k
    print(min(s,b))
Buggy python submission (verdict: Time Limit Exceeded):
k=input()
n=len(k)
cnt=9
def lunlun(x):
    flag=True
    x=str(x)
    for num in range(len(x)-1):
        a=x[num]
        b=x[num+1]
        if abs(int(a)-int(b))>1:
            flag=False
            break
    return flag
i=9
if n==1:
    print(k)
else:
    while cnt!=k:
        i+=1
        if lunlun(i):
            cnt+=1
    print(i)


Fixed submission:
#abc161 d 
k=int(input())

lunlun=[1,2,3,4,5,6,7,8,9]

def lunlun_generate(p):
    last=p%10
    if last-1>=0:
        yield p*10+last-1
    yield p*10+last
    if last+1<=9:
        yield p*10+last+1


p=0
while len(lunlun)<k:
    for new_lunlun in lunlun_generate(lunlun[p]):#３つ目のyieldが判定されるとfor文を抜ける
        lunlun.append(new_lunlun)
    p+=1
    
print(lunlun[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
#abc160 d
from collections import deque
import itertools
n,x,y=map(int,input().split())
g=[[False]*n for _ in range(n)]

for i in range(n-1):
    g[i][i+1]=True
    g[i+1][i]=True
g[x-1][y-1]=True
g[y-1][x-1]=True

def bfs(s,e):
    color=[False]*n
    dis=[0]*n
    q=deque()
    q.append(s-1)
    color[s-1]=True

    while q:
        now=q.popleft()

        if now==(e-1):
            break
        for i in range(n):
            if g[now][i]==True and color[i]==False:
                dis[i]+=dis[now]+1
                color[i]=True
                q.append(i)
    return dis[e-1]
l=[i for i in range(1,n+1)]
c=itertools.combinations(l,2)
ans=[0]*n
for s,e in c:
    distance=bfs(s,e)
    ans[distance]+=1
for i in range(1,n):
    print(ans[i])

Fixed submission:
n,x,y=map(int,input().split())
x,y=x-1,y-1

ans=[0]*(n+1)



for i in range(n):
    for j in range(i+1,n):
        a=abs(i-j)
        b=abs(i-x)+1+abs(y-j)
        c=abs(y-i)+1+abs(x-j)
        ans[min(a,b,c)]+=1
for i in range(1,n):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
ans=0
if a==0:
    ans=0
elif b==0:
    ans=n 
else:
    while True:
        if n-a>=0:
            n-=a
            ans+=a
        else:
            ans+=n
            break
        n-=b
        if n<=0:
            break
print(ans)

Fixed submission:
n,a,b=map(int,input().split())
ans=0
if a==0:
    ans=0
elif b==0:
    ans=n
else:
    ans=a*(int(n/(a+b)))
    n=n%(a+b)
    while True:
        if n==0:
            break
        if n-a<0:
            ans+=n
            break
        else:
            ans+=a
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
ans=0
while True:
    if n-a>=0:
        n-=a
        ans+=a
    else:
        ans+=n
        break
    n-=b
    if n<=0:
        break
print(ans)

Fixed submission:
n,a,b=map(int,input().split())
ans=0
if a==0:
    ans=0
elif b==0:
    ans=n
else:
    ans=a*(int(n/(a+b)))
    n=n%(a+b)
    while True:
        if n==0:
            break
        if n-a<0:
            ans+=n
            break
        else:
            ans+=a
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
ans=0
flag=False
for i in range(b*10,(b+1)*10+1):
    x=i*8
    if 100*(a+1>x>=100*a:
        flag=True
        ans=i
        break
print(ans if flag else -1)

Fixed submission:
a,b=map(int,input().split())
ans=0
flag=False
for i in range(b*10,(b+1)*10):
    x=i*8
    if 100*(a+1)>x>=100*a:
        flag=True
        ans=i
        break
print(ans if flag else -1)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
for i in range(q):
    line=list(input().split())
    if len(line)==1:
        s=s[::-1]
    else:
        t=line[2]
        if line[1]=="1":
            s=t+s
        else:
            s=s+t
print(s)


Fixed submission:
#abc 158 d
from collections import deque
x=deque()
flag=True # muki  true: migi false: hidari
s=input()
x.append(s)
q=int(input())
cnt=0
for i in range(q):
    line=list(input().split())
    if len(line)==1:
        cnt+=1
        if cnt%2==1:
            flag=False
        else:
            flag=True
    else:
        t=line[2]
        if line[1]=="1":
            if flag==True:
                x.appendleft(t)
            else:
                x.append(t)
        else:
            if flag==True:
                x.append(t)
            else:
                x.appendleft(t)
ans="".join(x)
if flag==False:
    ans=ans[::-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
q=int(input())
for i in range(q):
    line=list(input().split())
    if line[0]==1:
        s=s[::-1]
    else:
        t=line[2]
        if line[1]==1:
            s=t+s 
        else:
            s=s+t
print(s)

Fixed submission:
#abc 158 d
from collections import deque
x=deque()
flag=True # muki  true: migi false: hidari
s=input()
x.append(s)
q=int(input())
cnt=0
for i in range(q):
    line=list(input().split())
    if len(line)==1:
        cnt+=1
        if cnt%2==1:
            flag=False
        else:
            flag=True
    else:
        t=line[2]
        if line[1]=="1":
            if flag==True:
                x.appendleft(t)
            else:
                x.append(t)
        else:
            if flag==True:
                x.append(t)
            else:
                x.appendleft(t)
ans="".join(x)
if flag==False:
    ans=ans[::-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
#157 b
a=[]
call_num=[]
for i in range(3):
    x,y,z=map(int,input().split())
    a.append(x)
    a.append(y)
    a.append(z)
n=int(input())
for i in range(n):
    x=int(input())
    if x in a:
        call_num.append(a.index(x))
bingo
ans=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for x in ans:
    flag=True
    for y in x:
        if y not in call_num:
            flag=False
    if flag:
        print("Yes")
        bing=True
        break
if bingo!=True:        
    print("No")


Fixed submission:
#157 b
a=[]
call_num=[]
for i in range(3):
    x,y,z=map(int,input().split())
    a.append(x)
    a.append(y)
    a.append(z)
n=int(input())
for i in range(n):
    x=int(input())
    if x in a:
        call_num.append(a.index(x))
bingo=False
ans=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for x in ans:
    flag=True
    for y in x:
        if y not in call_num:
            flag=False
    if flag:
        print("Yes")
        bingo=True
        break
if bingo!=True:
    print("No")

Buggy python submission (verdict: Runtime Error):
#157 b 
a=[]
call_num=[]
for i in range(3):
    x,y,z=map(int,input().split())
    a.append(x)
    a.append(y)
    a.append(z)
n=int(input())
for i in range(n):
    x=int(input())
    if x in a:
        call_num.append(a.index(x))
bingo
ans=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for x in ans:
    flag=True
    for y in x:
        if y not in call_num:
            flag=False
    if flag:
        print("Yes")
        bing=True
        break
if bing!=True:        
    print("No")


Fixed submission:
#157 b
a=[]
call_num=[]
for i in range(3):
    x,y,z=map(int,input().split())
    a.append(x)
    a.append(y)
    a.append(z)
n=int(input())
for i in range(n):
    x=int(input())
    if x in a:
        call_num.append(a.index(x))
bingo=False
ans=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for x in ans:
    flag=True
    for y in x:
        if y not in call_num:
            flag=False
    if flag:
        print("Yes")
        bingo=True
        break
if bingo!=True:
    print("No")
Buggy python submission (verdict: Runtime Error):
#154 c
n=int(input())
a=list(map(int,input().split()))
num=dict()
flag=True
for x in a:
    if x not in num:
        a[x]=1
    else:
        flag=False
    if flag==False:
        break
if flag:
    print("YES")
else:
    print("NO")


Fixed submission:
#154 c
n=int(input())
a=list(map(int,input().split()))
num=set(a)
if len(a)==len(num):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
#154 d
def kitaichi(x):
    return (x+k)/2

n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
for i in range(n-k+1):
    s=0
    s=sum(p[i:i+k])
    if s>=ans:
        ans=s
print(kitaichi(ans))


Fixed submission:
#abc154 d
n,k=map(int,input().split())
p=list(map(int,input().split()))
wa=[0]*(n+1)

for i in range(n):
    wa[i+1]=p[i]+wa[i]

ans=0
for i in range(n-k+1):
    kitai=k+wa[i+k]-wa[i]
    if kitai>ans:
        ans=kitai
ans/=2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#154 d
def kitaichi(x):
    return (x+1)/2

n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
for i in range(n-k+1):
    s=0
    for j in range(k):
        s+=kitaichi(p[i+j])
    if s>=ans:
        ans=s
print(ans)


Fixed submission:
#abc154 d
n,k=map(int,input().split())
p=list(map(int,input().split()))
wa=[0]*(n+1)

for i in range(n):
    wa[i+1]=p[i]+wa[i]

ans=0
for i in range(n-k+1):
    kitai=k+wa[i+k]-wa[i]
    if kitai>ans:
        ans=kitai
ans/=2
print(ans)
Buggy python submission (verdict: Runtime Error):
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int i=scan.nextInt();
    int j=scan.nextInt();
    if (i!=j){
      System.out.println("No");
    }else
      System.out.println("Yes");
    scan.close();
  }
}


Fixed submission:
#a ac or wa
n,m=input().split()
ans="No"
if n==m:
    ans="Yes"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#d
import itertools
n=int(input())
ans=0
num=[str(i) for i in range(1,n+1)]
for i in num:
    for j in num:
        if i[0]==j[-1] and i[-1]==j[0]:
            ans+=1
print(ans)

Fixed submission:
#abc152 d
n=int(input())

def first_num(x):
    l=x
    while int(x/10)>0:
        x=int(x/10)
        l=x
    return l

kiroku=dict()
for i in range(1,n+1):
    first=first_num(i)
    last=i%10
    #組はタプルに入ってる
    if (first,last) in kiroku:
        kiroku[first,last]+=1
    else:
        kiroku[first,last]=1

ans=0
for key in kiroku.keys():
    f,l=key
    if (l,f) in kiroku:
        kumi=kiroku[f,l]*kiroku[l,f]
        ans+=kumi
print(ans)
Buggy python submission (verdict: Runtime Error):
#c welcome to atcoder
import sys
n,m=map(int,input().split())
ps=[]
num={}
#辞書
ac=0
pena=0
if m==0:
    print('0 0')
    sys.exit()
for i in range(m):
    result=input().split()
    ps.append(result)

for x in ps:
    print(x[0])
    if x[0] not in num:
        num[x[0]]=0
    print(num[x[0]])
    if x[1]=="WA" and num[x[0]]==0:
        pena+=1
    if x[1]=="AC" and num[x[0]]==0:
        ac+=1
        num[x[0]]=1

print(num)

print(ac,pena)

Fixed submission:
#a 
c=input()
ans=ord(c)+1
print(chr(ans))
Buggy python submission (verdict: Time Limit Exceeded):
#c welcome to atcoder
import sys
n,m=map(int,input().split())
ps=[]
num={}
correct=[]
#辞書
ac=0
pena=0
if m==0:
    print('0 0')
    sys.exit()
for i in range(m):
    result=input().split()
    ps.append(result)
    if result[1]=="AC":
        correct.append(result[0])

for x in ps:
    if not x[0] in correct:
        continue
    if x[0] not in num:
        num[x[0]]=0
    if x[1]=="WA" and num[x[0]]==0:
        pena+=1
    if x[1]=="AC" and num[x[0]]==0:
        ac+=1
        num[x[0]]=1

print(ac,pena)

Fixed submission:
#c welcome to atcoder
import sys
n,m=map(int,input().split())
ps=[]
num={}
#辞書
ac=0
pena=0
if m==0:
    print('0 0')
    sys.exit()
for i in range(m):
    result=input().split()
    ps.append(result)
    if result[1]=="AC":
        num[result[0]]=0

for x in ps:
    if not x[0] in num:
        continue
    if x[1]=="WA" and num[x[0]]==0:
        pena+=1
    if x[1]=="AC" and num[x[0]]==0:
        ac+=1
        num[x[0]]=1

print(ac,pena)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(a-1,n-B)+1+(b-a-1)//2)


Fixed submission:
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2)
Buggy python submission (verdict: Runtime Error):
#b strings with the same length
n=int(input())
sentence=input().split()
ans=""
for i in range(2):
    ans=ans+sentence[0][i]+sentence[1][i]
print(ans)

Fixed submission:
#b strings with the same length
n=int(input())
sentence=input().split()
ans=""
for i in range(n):
    ans=ans+sentence[0][i]+sentence[1][i]
print(ans)

Buggy python submission (verdict: Runtime Error):
#b strings with the same length
n=int(input())
sentence=input().split()
ans=""
for i in range(n):
    ans+=sentence[i]
print(ans)

Fixed submission:
#b strings with the same length
n=int(input())
sentence=input().split()
ans=""
for i in range(n):
    ans=ans+sentence[0][i]+sentence[1][i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(60):
    ichi=0
    for j in range(n):
        if (a[j]>>i)&1:
            ichi+=1
    zero=n-ichi
    s=ichi*zero*pow(2,i,mod)%mod# xorをしたあとi桁目が1になる組み合わせの個数 x 2**i
    ans+=s
    ans%=mod
print(ans)


Fixed submission:
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(60):
    ichi=0
    for j in range(n):
        if (a[j]>>i)&1:
            ichi+=1
    zero=n-ichi
    s=ichi*zero*pow(2,i,mod)%mod# xorをしたあとi桁目が1になる組み合わせの個数 x 2**i
    ans+=s
    ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(60):
    ichi=0
    for j in range(n):
        if (a[j]>>i)&1:
            ichi+=1
    zero=n-ichi
    s=ichi*zero*2**i%mod# xorをしたあとi桁目が1になる組み合わせの個数 x 2**i
    ans+=s
    ans%=mod
print(ans)


Fixed submission:
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
ans=0
for i in range(60):
    ichi=0
    for j in range(n):
        if (a[j]>>i)&1:
            ichi+=1
    zero=n-ichi
    s=ichi*zero*pow(2,i,mod)%mod# xorをしたあとi桁目が1になる組み合わせの個数 x 2**i
    ans+=s
    ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
x=int(input())
p=[100,101,102,103,104,105]
ans=[False]*2001
ans[0]=True
for i in range(2000):
    if ans[i]:
        for j in p:
            if i+j>2000:
                continue
            else:
                ans[i+j]=True
if x>2000:
    print(1)
elif ans(x):
    print(1)
else:
    print(0)


Fixed submission:
x=int(input())
p=[100,101,102,103,104,105]
ans=[False]*2001
ans[0]=True
for i in range(2000):
    if ans[i]:
        for j in p:
            if i+j>2000:
                continue
            else:
                ans[i+j]=True
if x>2000:
    print(1)
elif ans[x]:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys 
sys.setrecursionlimit(10 ** 6)

p=[100,101,102,103,104,105]
x=int(input())

def dfs(sum):
    ans=False
    if sum>=x:
        return sum==x
    for i in p:
        ans|=dfs(sum+i)
    return ans 

if x>=2000:
    print(1)
elif dfs(0):
    print(1)
else:
    print(0)



    

Fixed submission:
x=int(input())
p=[100,101,102,103,104,105]
ans=[False]*2001
ans[0]=True
for i in range(2000):
    if ans[i]:
        for j in p:
            if i+j>2000:
                continue
            else:
                ans[i+j]=True
if x>2000:
    print(1)
elif ans[x]:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys 
sys.setrecursionlimit(10 ** 6)

p=[100,101,102,103,104,105]
x=int(input())

def dfs(sum):
    ans=False
    if sum>=x:
        return sum==x
    for i in p:
        ans|=dfs(sum+i)
    return ans 

if dfs(0):
    print(1)
else:
    print(0)
    

Fixed submission:
x=int(input())
p=[100,101,102,103,104,105]
ans=[False]*2001
ans[0]=True
for i in range(2000):
    if ans[i]:
        for j in p:
            if i+j>2000:
                continue
            else:
                ans[i+j]=True
if x>2000:
    print(1)
elif ans[x]:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys 
sys.setrecursionlimit(10 ** 6)

p=[100,101,102,103,104,105]
x=int(input())

def dfs(sum):
    ans=False
    if sum>=x:
        return sum==x
    for i in p:
        ans|=dfs(sum+i)
    return ans 

if dfs(0):
    print(1)
else:
    print(0)
    

Fixed submission:
x=int(input())
p=[100,101,102,103,104,105]
ans=[False]*2001
ans[0]=True
for i in range(2000):
    if ans[i]:
        for j in p:
            if i+j>2000:
                continue
            else:
                ans[i+j]=True
if x>2000:
    print(1)
elif ans[x]:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for a in range(n-2):
    for b in range(a+1,n-1):
        r=bisect_left(l, l[a] + l[b], b + 1, n)
        l=b+1
        ans+=r-l
        
print(ans)


Fixed submission:
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for a in range(n-2):
    for b in range(a+1,n-1):
        ans+=max(0,bisect_left(l, l[a] + l[b])-b-1)
        
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
l=list(map(int,input().split()))


def triangle(num):
    a,b,c=num
    if a<(b+c) and b<(a+c) and c<(a+b):
        return True
    else:
        return False
ans=0
for num in itertools.combinations(l,3):
    ans+=triangle(num)
print(ans)


Fixed submission:
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for a in range(n-2):
    for b in range(a+1,n-1):
        ans+=max(0,bisect_left(l, l[a] + l[b])-b-1)
        
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))


def triangle(num):
    a,b,c=num
    if a<(b+c) and b<(a+c) and c<(a+b):
        return True
    else:
        return False
ans=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            num=[l[i],l[j],l[k]]
            ans+=triangle(num)
print(ans)


Fixed submission:
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for a in range(n-2):
    for b in range(a+1,n-1):
        ans+=max(0,bisect_left(l, l[a] + l[b])-b-1)
        
        
print(ans)