Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
ABs = list([list(map(int,input().split())) for _ in range(M)])
 
ship1 =[]
shipn =[]
 
for ab in ABs:
    if ab[0]==1:ship1.append(ab[1])
    elif ab[1]==N:shipn.append(ab[0])

jdg=False      
      
for j in ship1:
    if j in shipn:jdg=True
if jdg:print('POSSIBLE')
else:print('IMPOSSIBLE')

Fixed submission:
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
ABs = list([list(map(int,input().split())) for _ in range(M)])
 
ship1 =[]
shipn =[]
 
for ab in ABs:
    if ab[0]==1:ship1.append(ab[1])
    elif ab[1]==N:shipn.append(ab[0])
 
      
if list(set(ship1) & set(shipn)) ==[]:print('IMPOSSIBLE')
else:print('POSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
ABs = list([list(map(int,input().split())) for _ in range(M)])

ship1 =[]
shipn =[]

jdg=False      

for i in range(2,N):
    if [1, i] in ABs and [i, N] in ABs:jdg=True
      
if jdg:print('POSSIBLE')
else:print('IMPOSSIBLE')

Fixed submission:
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
ABs = list([list(map(int,input().split())) for _ in range(M)])
 
ship1 =[]
shipn =[]
 
for ab in ABs:
    if ab[0]==1:ship1.append(ab[1])
    elif ab[1]==N:shipn.append(ab[0])
 
      
if list(set(ship1) & set(shipn)) ==[]:print('IMPOSSIBLE')
else:print('POSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
ABs = list([list(map(int,input().split())) for _ in range(M)])

ship1 =[]
shipn =[]

for ab in ABs:
    if ab[0]==1:ship1.append(ab)
    elif ab[1]==N:shipn.append(ab)

jdg=False      
      
for _, j in ship1:
    if [j, N] in shipn:jdg=True
if jdg:print('POSSIBLE')
else:print('IMPOSSIBLE')

Fixed submission:
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
ABs = list([list(map(int,input().split())) for _ in range(M)])
 
ship1 =[]
shipn =[]
 
for ab in ABs:
    if ab[0]==1:ship1.append(ab[1])
    elif ab[1]==N:shipn.append(ab[0])
 
      
if list(set(ship1) & set(shipn)) ==[]:print('IMPOSSIBLE')
else:print('POSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
g = [set() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].add(b-1)
    g[b-1].add(a-1)


def dfs(s, e, flag):
    visited = [-1]*n
    visited[0] = 0
    cnt = 1
    if flag: temp = [[s, [[0]]]]
    else: temp = [[s]]
    lst = []
    while temp:
        p = temp.pop()
        for a in g[p[0]]:
            if flag: q = p[1][:]
            if visited[a] != -1:continue
            visited[a] = visited[p[0]] + 1
            if flag: q.append([a])
            if a == e:
                lst = q[:]
                return lst
            if flag: temp.append([a, q])
            else: temp.append([a])
            cnt += 1
    return cnt

lst = dfs(0, n-1, True)

m = (len(lst) - 1) // 2
g[lst[m][0]].discard(lst[m+1][0])
g[lst[m+1][0]].discard(lst[m][0])

c0 = dfs(0, n-1, False)

if c0 > n - c0: print('Fennec')
else:print('Snuke')

Fixed submission:
n = int(input())
g = [set() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].add(b-1)
    g[b-1].add(a-1)

def dfs(s):
    visited = [-1]*n
    visited[s] = 0
    temp = [s]
    lst = []
    while temp:
        p = temp.pop()
        for a in g[p]:
            if visited[a] != -1:continue
            visited[a] = visited[p] + 1
            temp.append(a)
    return visited

lst0 = dfs(0)
lstn = dfs(n-1)
cnt = 0
for i in range(n):
    if lst0[i] <= lstn[i]: cnt += 1

if cnt > n - cnt: print('Fennec')
else:print('Snuke')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

b = []
while len(a)>=2:
    b.append(a.pop(0))
    b.insert(0, a.pop(0))

if len(a)==1:
    b.append(a.pop(0))
    b.reverse()
    
print(*b)        

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

b = []

b_odd = []
b_even = []

for i in range(len(a)):
    if i%2==0:b_even.append(a[i])
    else:b_odd.append(a[i])

if len(a)%2==0:
    b_odd.reverse()
    b_odd+=b_even
    print(*b_odd)
else:
    b_even.reverse()
    b_even+=b_odd
    print(*b_even)

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

b = []

for i in a:
    b.append(i)
    b.reverse()
    
print(*b)

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

b = []

b_odd = []
b_even = []

for i in range(len(a)):
    if i%2==0:b_even.append(a[i])
    else:b_odd.append(a[i])

if len(a)%2==0:
    b_odd.reverse()
    b_odd+=b_even
    print(*b_odd)
else:
    b_even.reverse()
    b_even+=b_odd
    print(*b_even)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(map(int,input().split()))

cnt=0

for i in range(n-1):
    sum_a = sum(a[0:i+1])
    if abs(sum_a) >= abs(a[i+1]) or sum_a*a[i+1]>=0:
        if sum_a<0:
            cnt += abs(-sum_a+1 -a[i+1])
            a[i+1]=-sum_a+1
        elif sum_a>=0:
            cnt+=abs(-sum_a-1-a[i+1])
            a[i+1]=-sum_a-1
print(cnt)

Fixed submission:
import numpy as np
import copy

n = int(input())

a = list(map(int,input().split()))
b=copy.deepcopy(a)

cntm=0
cntp=0
sum_a=0
sum_b=0

if a[0]<=0:
    cntp+=-a[0]+1
    a[0]=1
if b[0]>=0:
    cntm+=b[0]+1
    b[0]=-1
for i in range(n-1):
    sum_a += a[i]
    sum_b += b[i]
    if abs(sum_a) >= abs(a[i+1]) or sum_a*a[i+1]>=0:
            cntp += abs(-sum_a-np.sign(sum_a) -a[i+1])
            a[i+1]=-sum_a-np.sign(sum_a)
    if abs(sum_b) >= abs(b[i+1]) or sum_b*b[i+1]>=0:
            cntm += abs(-sum_b-np.sign(sum_b) -b[i+1])
            b[i+1]=-sum_b-np.sign(sum_b)
print(min(cntm, cntp))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

rate=1

for i in range(1,N+1):
    rate*=i


print(rate%(10**9+7))
  

Fixed submission:
from math import factorial

N = int(input())

print(factorial(N)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

c = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if (x + y + z) == S:c+=1
print(c)

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

c = 0

for x in range(K+1):
    for y in range(K+1):
        if 0 <= S - (x + y) <= K:c+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

f, a0 = map(int, input().split())

for i in range(n-1):
    t1, a1 = map(int, input().split())
    
    if f % t1 != 0:
        f += t1 - f % t1
    while (f // t1) * a1 < a0:
        f += t1
    a0 = (f // t1) * a1
print(f + a0)

Fixed submission:
n = int(input())

t0, a0 = 1, 1

for i in range(n):
    t1, a1 = map(int, input().split())
    f0 = t0 // t1
    if t0 % t1 != 0:f0 += 1
    f1 = a0 // a1
    if a0 % a1 != 0:f1 += 1
    f = max(f0, f1)
    t0, a0 = t1*f, a1*f

print(t0 + a0)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations_with_replacement, product
n, k = map(int, input().split())
d = [int(x) for x in input().split()]
dd = set(list(range(10))) - set(d)

x = str(n)
lst = []
dd = list(dd)
dd.sort()
sel = []
for i in dd:
    if int(x[0]) <= i and len(sel) < 3: sel.append(i*10**(len(x)-1))
if len(sel) < 2:
    if dd[0] != 0:
        sel.append((dd[0]*10 + dd[1])* 10 ** (len(x)-1))
    else:
        sel.append((dd[1]*10 + dd[0])* 10 ** (len(x)-1))
for j in sel:
    for l in combinations_with_replacement(dd, len(x)-1):
        cnt = j
        for i in range(len(x)-1):
            cnt += 10 ** (len(x)-i-2) * l[i]
        if cnt >= n: lst.append(cnt)
print(min(lst))


Fixed submission:
from itertools import combinations_with_replacement
n, k = map(int, input().split())
d = [int(x) for x in input().split()]
dd = set(list(range(10))) - set(d)

x = str(n)
lst = []
dd = list(dd)
dd.sort()
sel = []
for i in dd:
    if int(x[0]) <= i and len(sel) < 3: sel.append(i*10**(len(x)-1))
if len(sel) < 2:
    if len(dd) == 1:
        sel.append((dd[0]*10 + dd[0])* 10 ** (len(x)-1))
    else:
        if dd[0] != 0:
            sel.append((dd[0]*10 + dd[0])* 10 ** (len(x)-1))
        else:
            sel.append((dd[1]*10 + dd[0])* 10 ** (len(x)-1))
for j in sel:
    for l in combinations_with_replacement(dd, len(x)-1):
        cnt = j
        for i in range(len(x)-1):
            cnt += 10 ** (len(x)-i-2) * l[i]
        if cnt >= n: lst.append(cnt)
print(min(lst))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(max([a*c,a*d,b*c,c*d])


Fixed submission:
a=list(map(int,input().split()))
print(max([a[0]*a[2],a[0]*a[3],a[1]*a[2],a[1]*a[3]]))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
p=1
for i in a[:k]:
    p*=i
for i in range(k,len(a)):
    q=p//a[i-k]*a[i]
    if q>p: print("Yes")
    else: print("No")
    p=q


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,len(a)):
    if a[i]>a[i-k]: print("Yes")
    else: print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
p=1
for i in a[:k]:
    p*=i
for i in range(k,len(a)):
    q=p*a[i]/a[i-k]
    if q>p: print("Yes")
    else: print("No")
    p=q


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,len(a)):
    if a[i]>a[i-k]: print("Yes")
    else: print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
p=1
for i in a[:k]:
    p*=i
for i,j in zip(a[k:],a):
    q=p*i/j
    if q>p: print("Yes")
    else: print("No")
    p=q


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,len(a)):
    if a[i]>a[i-k]: print("Yes")
    else: print("No")
Buggy python submission (verdict: Runtime Error):
k,n=map(int,input().split())
a=list(map(int,intput().split()))
if sum(a)>=k:
  print("Yes")
else:
  print("No")

Fixed submission:
k,n=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)>=k:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
k=reduce(lambda x,y:x*y//gcd(x,y),a)
ans=sum(list(map(lambda x:k//x,a)))
print(ans%(10**9+7))


Fixed submission:
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
k=reduce(lambda x,y:x*y//gcd(x,y),a)
ans=sum(list(map(lambda x:k//x,a)))
print(ans%(10**9+7))

Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
k=reduce(lambda x,y:x*y//gcd(x,y),a)
ans=sum(list(map(lambda x:k//x,a)))
print(ans)


Fixed submission:
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
k=reduce(lambda x,y:x*y//gcd(x,y),a)
ans=sum(list(map(lambda x:k//x,a)))
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
print("".jion(s.split()))

Fixed submission:
'''
author : w2sc
  date : 2019/12/22
  time : 20:03:13
'''
n=int(input())
a,b=input().split()
i=0
s=""
while i<n:
    s+=a[i]+b[i]
    i+=1
print(s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
edge=[]
G=[[] for _ in range(n+1)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edge.append([x,y])
    G[x].append(_)
    G[y].append(_)
k=0
root=0
for i in range(1,n+1):
    if k<len(G[i]):
        root=i
        k=len(G[i])
co=[1 for i in range(n+1)]
vis=[False for i in range(n+1)]
def dfs(node,lastco=-1):
    tmp=lastco
    for v in G[node]:
        if not vis[v]:
            tmp+=1
            co[v]=tmp%k
            vis[v]=True
            if node==edge[v][0]:
                dfs(edge[v][1],co[v])
            else:
                dfs(edge[v][0],co[v])

dfs(root)
print(k)
for i in range(n-1):
    print(co[i]+1)


Fixed submission:
import sys
sys.setrecursionlimit(100010)
n=int(input())
edge=[]
G=[[] for _ in range(n+1)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edge.append([x,y])
    G[x].append(_)
    G[y].append(_)
k=0
root=0
for i in range(1,n+1):
    if k<len(G[i]):
        root=i
        k=len(G[i])
co=[1 for i in range(n+1)]
vis=[False for i in range(n+1)]
def dfs(node,lastco=-1):
    tmp=lastco
    for v in G[node]:
        if not vis[v]:
            tmp+=1
            co[v]=tmp%k
            vis[v]=True
            if node==edge[v][0]:
                dfs(edge[v][1],co[v])
            else:
                dfs(edge[v][0],co[v])

dfs(root)
print(k)
for i in range(n-1):
    print(co[i]+1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
edge=[]
G=[[] for _ in range(n+1)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edge.append([x,y])
    G[x].append(_)
    G[y].append(_)
k=0
root=0
for i in range(1,n+1):
    if k<len(G[i]):
        root=i
        k=len(G[i])
co=[1 for i in range(n+1)]
def dfs(node,pa=-1):
    #print(node)
    tmp=0
    if pa>=0:
        tmp=co[pa]
    for v in G[node]:
        if pa not in edge[v]:
            #print("??",v)
            tmp+=1
            co[v]=tmp%k+1
            if node==edge[v][0]:
                dfs(edge[v][1],node)
            else:
                dfs(edge[v][0],node)

dfs(root)
print(k)
for i in range(n-1):
    print(co[i])


Fixed submission:
import sys
sys.setrecursionlimit(100010)
n=int(input())
edge=[]
G=[[] for _ in range(n+1)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edge.append([x,y])
    G[x].append(_)
    G[y].append(_)
k=0
root=0
for i in range(1,n+1):
    if k<len(G[i]):
        root=i
        k=len(G[i])
co=[1 for i in range(n+1)]
vis=[False for i in range(n+1)]
def dfs(node,lastco=-1):
    tmp=lastco
    for v in G[node]:
        if not vis[v]:
            tmp+=1
            co[v]=tmp%k
            vis[v]=True
            if node==edge[v][0]:
                dfs(edge[v][1],co[v])
            else:
                dfs(edge[v][0],co[v])

dfs(root)
print(k)
for i in range(n-1):
    print(co[i]+1)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(lambda x:(int(x)-1)%k,input().split()))
s=[0,0]
#print(a)
for i in a:
    s.append((s[-1]+i)%k)
s.append(s[-1])
#print(s)
mp={}
ans=0
for i in range(len(s)):
    if i-k>=0:
        mp[s[i-k]]-=1
    if s[i] in mp:
        ans+=mp[s[i]]
    if i>0:
        if s[i-1] in mp:
            mp[s[i-1]]+=1
        else:
            mp[s[i-1]]=1
    #print(i,ans)
print(ans)


Fixed submission:
n,k=map(int,input().split())
a=list(map(lambda x:(int(x)-1)%k,input().split()))
s=[0]
#print(a)
for i in a:
    s.append((s[-1]+i)%k)
#print(s)
mp={}
ans=0
for i in range(len(s)):
    if i-k>=0:
        mp[s[i-k]]-=1
    if s[i] in mp:
        ans+=mp[s[i]]
    if s[i] in mp:
        mp[s[i]]+=1
    else:
        mp[s[i]]=1
    #print(i,ans)
print(ans)
#ans+=sum(list(map(lambda x: x==0,s)))
#print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
s=input()
pos=n
p=n
tmp=n
ans=[]
while pos>0:
    q=p
    while pos-q<m and q>0:
        q-=1
        #print(q)
        if s[q]=='0':
            tmp=q
    #print()
    if tmp>=pos:
        print(-1)
        exit(0)
    ans.append(pos-tmp)
    pos=tmp
#print()
for i in range(1,1+len(ans)):
    print(ans[-i],end=' ')


Fixed submission:
n,m=map(int,input().split())
s=input()
pos=n
p=n
tmp=n
ans=[]
while pos>0:
    q=p
    while pos-q<m and q>0:
        q-=1
        #print(q)
        if s[q]=='0':
            tmp=q
    p=q
    #print()
    if tmp>=pos:
        print(-1)
        exit(0)
    ans.append(pos-tmp)
    pos=tmp
#print()
for i in range(1,1+len(ans)):
    print(ans[-i],end=' ')
Buggy python submission (verdict: Runtime Error):
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long u64;

const int maxn = 100000 + 10;
u64 n, m, p, fac[maxn];

inline u64 Fast_Pow(u64 x, u64 k) {
    u64 ans = 1;
    while(k) {
        if( k&1 ) ans = ans * x % p;
        k >>= 1, x = x * x % p;
    }
    return ans;
}

u64 C(u64 k, u64 b) {
    if( k<b )  return 0;
    return fac[k] * Fast_Pow(fac[b] % p, p-2) % p * Fast_Pow(fac[k-b] % p, p-2) % p;
}

u64 Lucas(u64 k, u64 b) {
    if( !b )  return 1;
    return C(k%p, b%p) * Lucas(k/p, b/p) % p;
}

int main(int argc, char const *argv[])
{
    int t;  scanf("%d", &t);
    while( t-- ) {
        fac[0] = 1;
        scanf("%lld%lld%lld", &n, &m, &p);
        for(int i=1; i<=p; ++i)
            fac[i] = fac[i-1] * i % p;
        printf("%lld\n", Lucas(n+m, m));
    }
    return 0;
}

Fixed submission:
print(int(input())**2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
print(["No","Yes"][s[:int(n/2)]]==s[int(n/2):])

Fixed submission:
n=int(input())
s=input()
print(["No","Yes"][s[:int(n/2)]==s[int(n/2):]])
Buggy python submission (verdict: Runtime Error):
print(~int(input())

Fixed submission:
a = int(input())
if a == 0:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
if a >= 0:
  if d <= 0:
    print(a*d)
  else:
    print(b*d)
    
elif b>0:
  if d<0:
    print(a*c)
  else:
    print(max(a*c,b*d)
else:
  if c>=0:
    print(b*c)
  else:
    print(a*c)

Fixed submission:
a,b,c,d = map(int,input().split())
if a >= 0:
  if d <= 0:
    print(a*d)
  else:
    print(b*d)
    
elif b>0:
  if d<0:
    print(a*c)
  else:
    print(max(a*c,b*d))
else:
  if c>=0:
    print(b*c)
  else:
    print(a*c)
Buggy python submission (verdict: Runtime Error):
A=[ord(i) for i in range(chr(a),chr(z)+1)]
a=input()
if a in A:
  print("a")
else:
  print("A")

Fixed submission:
A=[chr(i) for i in range(ord("a"),ord("z")+1)]
a=input()
if a in A:
  print("a")
else:
  print("A")
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

d=dict()
sum=0
for i in A:
  if not i in d:
    d[i]=0
  d[i]+=1
  sum+=i
#counterと同じ
for i in range(int(input())):
  b,c=map(int,input().split())
  if not c in d:
    d[c]=0
    
  sum=sum-(d[b]*b)
  sum=sum-(d[c]*c)
  d[c]+=d[b]
  d[b]=0
  sum=sum+(d[c]*c)
  #print(d)
  print(sum)

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

d=dict()
sum=0
for i in A:
  if not i in d:
    d[i]=0
  d[i]+=1
  sum+=i
#counterと同じ
for i in range(int(input())):
  b,c=map(int,input().split())
  if not c in d:
    d[c]=0
  if not b in d:
    d[b]=0
    
  sum=sum-(d[b]*b)
  sum=sum-(d[c]*c)
  d[c]+=d[b]
  d[b]=0
  sum=sum+(d[c]*c)
  #print(d)
  print(sum)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=float(b)*1000
b=int(b)
print(int((a*b)//1000)

Fixed submission:
a,b=input().split()
a=int(a)
b=float(b)*1000
b=int(b)
print(int((a*b)//1000))
Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())
if x**0.2==int(x**0.2):
  print(int(x**0.2),0)
  exit()
i=int(-(x**0.2))
while True:
  h=(x+(i**5))**0.2
  if h==int(h):
    print(int(h),i)
    exit()
  i+=1

Fixed submission:
x=int(input())
for i in range(-200,200):
  for j in range(-200,200):
    if (i**5)-(j**5)==x:
      print(i,j)
      exit()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
s=[(i+1)+L[i] for i in range(N)]
d=[(i+1)-L[i] for i in range(N)]
ans=0
for i in range(N):
  for j in range(N):
    if i==j:
      continue
    if s[i]==d[j]:
      ans+=1
print(ans)

Fixed submission:
from collections import Counter
N=int(input())
L=list(map(int,input().split()))
s=[(i+1)+L[i] for i in range(N)]
s=Counter(s)
d=[(i+1)-L[i] for i in range(N)]
d=Counter(d)
ans=0
for i in s:
  if i in d:
    ans+=s[i]*d[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
s=input()
R=s.count("R")
G=s.count("G")
B=s.count("B")
ans=R*G*B

#全探索する
for i in range(N-2):
  a=s[i]
  for j in range(i+1,N-1):
    if a==s[j]:
      continue
    b=s[j]
    k=2*j-i
    if "R" not in a+b:
      try:
        if s[k]=="R":
          ans-=1
      except:
        pass
      
    if "G" not in a+b:
      try:
        if s[k]=="G":
          ans-=1
      except:
        pass
      
    if "B" not in a+b:
      try:
        if s[k]=="B":
          ans-=1
      except:
        pass

print(ans)


Fixed submission:
print("Yes" if input().count("7")!=0 else "No")
Buggy python submission (verdict: Runtime Error):
def f(n):
  return (n*(n-1))//2
N=int(input())
A=list(map(int,input().split()))
d=dict()
ans=0
#それぞれが何個あるかを辞書に登録
for i in range(len(A)):
  if A[i] not in d:
    d[i]=0
  d[i]+=1
for i in d:
  ans+=f(d[i])
for i in range(len(A)):
  print(ans-d[A[i]]-1)

Fixed submission:
def f(n):#nC2の関数
    if n==0:
        return 0
    return n*(n-1)/2
N=int(input())
A=list(map(int,input().split()))
d=dict()
e=dict()
ans=0
for i in range(N):#辞書を作る
    if A[i] not in d:
        d[A[i]]=0
    d[A[i]]+=1

for j in d:#それぞれのキーの個数をnC2として保存
    e[j]=f(d[j])
    ans+=e[j]#nC2の総和をとる

for i in A:
    print(int(ans-d[i]+1))
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
from math import sqrt
a,b,c=map(int,input().split())
if Decimal(sqrt(a))+Decimal(sqrt(b))<Decimal(sqrt(c)):
  print("Yes")
else:
  print("No")
  

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

Buggy python submission (verdict: Runtime Error):
from math import sqrt
a,b,c=map(int,input().split())
if sqrt(a)+sqrt(b)<sqrt(c):
  print("Yes")
else:
  print("No")

Fixed submission:
L=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[int(input())-1])
Buggy python submission (verdict: Runtime Error):
from dicimal import Decimal
a,b,c=map(Decimal,input().split())
if (a.sqrt()+b.sqrt())<c.sqrt():
  print("Yes")
else:
  print("No")

Fixed submission:
from decimal import Decimal
a,b,c=map(Decimal,input().split())
if (a.sqrt()+b.sqrt())<c.sqrt():
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
from collections import deque
S=deque(input())
Q=int(input())
for i in range(Q):
  N=list(input().split())
  if N[0]=="1":
    S.reverse()
  elif N[1]=="1":#先頭にC1
    S.appendleft(N[2])
  else:#末尾にC1
    S.append(N[2])
S="".join(S)
print(S)

Fixed submission:
N=input()
if N[0]==N[1] and N[0]==N[2]:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N,B,R=map(int,input().split())
if B==0:
  print(0)
  exit()
ans=B×N//(R+B)
if N%(R+B)>=B:
  print(ans+B)
else:
  print(ans+B-N%(R+B))

Fixed submission:
N,B,R=map(int,input().split())
if B==0:
  print(0)
  exit()
ans=B*(N//(R+B))
if N%(R+B)>=B:
  print(ans+B)
else:
  print(ans+N%(R+B))
Buggy python submission (verdict: Runtime Error):
print((int(input())+1//2)

Fixed submission:
import math
N=int(input())
print(math.ceil(N/2))