Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
bisect_left = np.searchsorted
N = input()
a = np.int32(input().split())
b = np.int32(input().split())
ans = 0
for k in range(29):
    low = pow(2, k)
    high = pow(2, k + 1)
    x = a % high
    y = b % high
    y.sort()
    y = np.hstack((y - high, y))  # 配列を横に連結
    left = bisect_left(y, low - x)
    right = bisect_left(y, high - x)
    if np.sum(right - left) % 2:
        ans += low
print(ans)


Fixed submission:
import numpy as np
bisect_left = np.searchsorted
N = input()
a = np.int32(input().split())
b = np.int32(input().split())
ans = 0
for k in range(29):
    low = pow(2, k)
    high = pow(2, k + 1)
    x = a % high
    y = b % high
    y.sort()
    y = np.hstack((y - high, y))  # 配列を横に連結
    left = bisect_left(y, low - x)
    right = bisect_left(y, high - x)
    if np.sum(right - left) % 2:
        ans += low
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
def f(i):
  res=0
  t=2**i
  a_nex=sorted([p%(2*t) for p in a])
  b_nex=sorted([p%(2*t) for p in b])
  l=0
  p=q=r=0
  for k in reversed(a_nex):
    while p<N and k+b_nex[p]<t:
      p+=1
    while q<N and k+b_nex[q]<2*t:
      q+=1
    while r<N and k+b_nex[r]<3*t:
      r+=1
    l+=q-p+N-r
  res=(l%2)<<i
  return res
for k in range(29):
  ans+=f(k)
print(ans)   
  


Fixed submission:
import numpy as np
bisect_left = np.searchsorted
N = input()
a = np.int32(input().split())
b = np.int32(input().split())
ans = 0
for k in range(29):
    low = pow(2, k)
    high = pow(2, k + 1)
    x = a % high
    y = b % high
    y.sort()
    y = np.hstack((y - high, y))  # 配列を横に連結
    left = bisect_left(y, low - x)
    right = bisect_left(y, high - x)
    if np.sum(right - left) % 2:
        ans += low
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
travel_plan = [tuple(map(int, input().split())) for i in range(n)]
travel_plan = [(0, 0, 0)] + travel_plan

for i in range(n+1):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y < t or (x + y + t) % 2:
        print("No")
        exit()
print("Yes")

Fixed submission:
n = int(input())
travel_plan = []
for i in range(n):
    travel_plan.append(tuple(map(int, input().split())))
travel_plan = [(0, 0, 0)] + travel_plan

for i in range(n):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y > t or (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
n = int(input())
travel_plan = list(tuple(map(int, input().split())))
travel_plan = [(0, 0, 0)] + travel_plan
for i in range(n+1):
    t1, x1, y1 = travel_plan[i][0] + travel_plan[i][1] + travel_plan[i][2]
    t2, x2, y2 = travel_plan[i+1][0] + travel_plan[i+1][1] + travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y < t or (x + y + t) % 2:
        print("No")
        exit()
print("Yes")

Fixed submission:
n = int(input())
travel_plan = []
for i in range(n):
    travel_plan.append(tuple(map(int, input().split())))
travel_plan = [(0, 0, 0)] + travel_plan

for i in range(n):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y > t or (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let a: u32 = read();
    let b: u32 = read();
    let mut ans = 0;
    for i in 1..n+1 {
        let s = i/10000+(i%10000)/1000+(i%1000)/100+(i%100)/10+(i%10);
        if s >= a && s <= b {
            ans += i
        }
    }
    println!("{}", ans);
}

Fixed submission:
S = str(input())
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])


for i in range(0, 2):
    for j in range(0, 2):
        for k in range(0, 2):
            ans = ''
            if i == 0:
                AB = A + B
                ans += str(A) + '+' + str(B)
            else:
                AB = A - B
                ans += str(A) + '-' + str(B)
            if j == 0:
                ABC = AB + C
                ans += '+' + str(C)
            else:
                ABC = AB - C
                ans += '-' + str(C)
            if k == 0:
                ABCD = ABC + D
                ans += '+' + str(D)
            else:
                ABCD = ABC - D
                ans += '-' + str(D)
            if ABCD == 7:
                ans += '=7'
                print(ans)
                quit()
Buggy python submission (verdict: Time Limit Exceeded):
class WarshallFloyd():
    def __init__(self, N):
        self.N = N
        self.d = [[float("inf") for i in range(N)]
                  for i in range(N)]  # d[u][v] : 辺uvのコスト(存在しないときはinf)

    def add(self, u, v, c, directed=False):
        """
        0-indexedであるに注意
        u = from, v = to, c = cost
        directed = Trueなら、有向グラフである
        """
        if directed is False:
            self.d[u][v] = c
            self.d[v][u] = c
        else:
            self.d[u][v] = c

    def WarshallFloyd_search(self):
        # これを d[i][j]: iからjへの最短距離 にする
        # TODO verify both in directed and non-directed
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(
                        self.d[i][j], self.d[i][k] + self.d[k][j])
        for i in range(self.N):
            self.d[i][i] = 0
        return self.d


import itertools

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for i in range(M)]
graph = WarshallFloyd(N)
for a, b, c in ABC:
    graph.add(a-1, b-1, c)

d = graph.WarshallFloyd_search()
ans = float('inf')
for each in itertools.permutations(r):
    cur = 0
    for i in range(R - 1):
        cur += d[each[i] - 1][each[i + 1] - 1]
    ans = min(ans, cur)

print(ans)

Fixed submission:
class WarshallFloyd():
    def __init__(self, N):
        self.N = N
        self.d = [[float("inf") for i in range(N)]
                  for i in range(N)]  # d[u][v] : 辺uvのコスト(存在しないときはinf)

    def add(self, u, v, c, directed=False):
        """
        0-indexedであるに注意
        u = from, v = to, c = cost
        directed = Trueなら、有向グラフである
        """
        if directed is False:
            self.d[u][v] = c
            self.d[v][u] = c
        else:
            self.d[u][v] = c

    def WarshallFloyd_search(self):
        # これを d[i][j]: iからjへの最短距離 にする
        # TODO verify both in directed and non-directed
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(
                        self.d[i][j], self.d[i][k] + self.d[k][j])
        for i in range(self.N):
            self.d[i][i] = 0
        return self.d


import itertools

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
graph = WarshallFloyd(N)
for i in range(M):
    a, b, c = map(int, input().split())
    graph.add(a-1, b-1, c)

d = graph.WarshallFloyd_search()
ans = float('inf')
for each in itertools.permutations(r):
    cur = 0
    for i in range(R - 1):
        cur += d[each[i] - 1][each[i + 1] - 1]
    ans = min(ans, cur)

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict


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

lengthNumberDict = defaultdict(int)
for a in A:
    lengthNumberDict[a] += 1

lengthNumberList = [a for a in list(lengthNumberDict.items()) if a[1] >= 2]
lengthNumberList = sorted(lengthNumberList, key=lambda x: x[0], reverse=True)

if len(lengthNumberList) <= 1 and lengthNumberList[0][1] <= 3:
    print(0)
    quit()

if lengthNumberList[0][1] >= 4:
    print(lengthNumberList[0][0] ** 2)
else:
    print(lengthNumberList[0][0] * lengthNumberList[1][0])

Fixed submission:
from collections import defaultdict


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

lengthNumberDict = defaultdict(int)
for a in A:
    lengthNumberDict[a] += 1

lengthNumberList = [a for a in list(lengthNumberDict.items()) if a[1] >= 2]
lengthNumberList = sorted(lengthNumberList, key=lambda x: x[0], reverse=True)
if len(lengthNumberList) == 0:
    print(0)
    quit()
if len(lengthNumberList) == 1 and lengthNumberList[0][1] <= 3:
    print(0)
    quit()

if lengthNumberList[0][1] >= 4:
    print(lengthNumberList[0][0] ** 2)
else:
    print(lengthNumberList[0][0] * lengthNumberList[1][0])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(str, input().split()))

B = []
for a in A:
    B.append(a)
    B = B[::-1]

print(' '.join(B))

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

B = ['_' for _ in range(N)]
if N % 2 == 0:
    for i, a in enumerate(A):
        if i % 2 == 0:
            B[N//2 + i//2] = a
        else:
            B[N//2 - (i+1)//2] = a
else:
    for i, a in enumerate(A):
        if i % 2 == 0:
            B[N//2 - i//2] = a
        else:
            B[N//2 + (i+1)//2] = a

print(' '.join(B))

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

B = []
for a in A:
    B.append(str(a))
    B = B[::-1]

print(' '.join(B))

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

B = ['_' for _ in range(N)]
if N % 2 == 0:
    for i, a in enumerate(A):
        if i % 2 == 0:
            B[N//2 + i//2] = a
        else:
            B[N//2 - (i+1)//2] = a
else:
    for i, a in enumerate(A):
        if i % 2 == 0:
            B[N//2 - i//2] = a
        else:
            B[N//2 + (i+1)//2] = a

print(' '.join(B))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().rstrip().split()))
for i in a:
    a.remove(i)
    d = 0
    for t in range(0,len(a)):
        for j in range(t+1,len(a)):
            if a[t] == a[j]:
                d += 1
    print(d)
    a.insert(0,i)
    

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
x = Counter(a)
y = 0
for i in x.values():
    y += int(i*(i-1)/2)
for i in a:
    print(y+1 - x[i])
Buggy python submission (verdict: Runtime Error):
ab = list(map(int,input().split()))
a,b = ab[0],ab[1]
d = []
for i in range(100):
    if (i*(i+1))/2 >a and ((i+1)*(i+2))/2 > b:
        d.append(i)
x,y = (d[0]*(d[0]+1))/2, ((d[1]+1)*(d[1]+2))/2
print(int(x - a))

Fixed submission:
ab = input().split()
a,b = int(ab[0]),int(ab[1])
d = []
z = b - a 
if ((z-1)*z)/2 >a and ((z+1)*(z+2))/2 > b:
    x,y = ((z-1)*z)/2, ((z+1)*(z+2))
print(int(x - a))

Buggy python submission (verdict: Runtime Error):
ab = list(map(int,input().split()))
a,b = ab[0],ab[1]
d = []
for i in range(999):
    if (i*(i+1))/2 >a and ((i+1)*(i+2))/2 > b:
        d.append(i)
x,y = (d[0]*(d[0]+1))/2, ((d[1]+1)*(d[1]+2))/2
print(int(x - a))

Fixed submission:
ab = input().split()
a,b = int(ab[0]),int(ab[1])
d = []
z = b - a 
if ((z-1)*z)/2 >a and ((z+1)*(z+2))/2 > b:
    x,y = ((z-1)*z)/2, ((z+1)*(z+2))
print(int(x - a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(input().split(" "))
b = [0 for i in range(n+1)]
for i in range(n):
    b[int(a[i])] += 1
for i in range(n):
    b[int(a[i])] -= 1
    sum = 0
    for j in range(n+1):
        sum += b[j]*(b[j]-1)/2
    print(int(sum))
    b[int(a[i])] += 1

Fixed submission:
n = int(input())
a = list(input().split(" "))
b = [0 for i in range(n+1)]
for i in range(n):
    b[int(a[i])] += 1
sum = 0
for j in range(n+1):
        sum += b[j]*(b[j]-1)/2
for i in range(n):
    print(int(sum)-b[int(a[i])]+1)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
sento = 0
for i in range(q):
    line = list(input().split(" "))
    if line[0] == "1":
        sento += 1
    elif line[1] == "1":
        if sento % 2 == 0:
            s.insert(0,line[2])
        else:
            s.append(line[2])
    else:
        if sento % 2 == 0:
            s.append(line[2])
        else:
            s.insert(0,line[2])
if sento % 2 ==1:
    s.reverse()
for i in range(len(s)):
    print(s[i],end ="")
print()

Fixed submission:
from collections import deque
s = deque(list(input()))
q = int(input())
sento = 0
for i in range(q):
    line = list(input().split(" "))
    if line[0] == "1":
        sento += 1
    elif line[1] == "1":
        if sento % 2 == 0:
            s.appendleft(line[2])
        else:
            s.append(line[2])
    else:
        if sento % 2 == 0:
            s.append(line[2])
        else:
            s.appendleft(line[2])
if sento % 2 ==1:
    s.reverse()
for i in range(len(s)):
    print(s[i],end ="")
print()

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
for i in range(q):
    line = list(input().split(" "))
    if line[0] == "1":
        s.reverse()
    elif line[1] == "1":
        s.insert(0,line[2])
    else:
        s.append(line[2])
for i in range(len(s)):
    print(s[i],end ="")
print()

Fixed submission:
from collections import deque
s = deque(list(input()))
q = int(input())
sento = 0
for i in range(q):
    line = list(input().split(" "))
    if line[0] == "1":
        sento += 1
    elif line[1] == "1":
        if sento % 2 == 0:
            s.appendleft(line[2])
        else:
            s.append(line[2])
    else:
        if sento % 2 == 0:
            s.append(line[2])
        else:
            s.appendleft(line[2])
if sento % 2 ==1:
    s.reverse()
for i in range(len(s)):
    print(s[i],end ="")
print()

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
for i in range(q):
    line = list(input().split(" "))
    if line[0] == "1":
        s.reverse()
    elif line[1] == "1":
        s.insert(0,line[2])
    else:
        s.append(line[2])
for i in range(len(s)):
    print(s[i],end ="")
print()

Fixed submission:
from collections import deque
s = deque(list(input()))
q = int(input())
sento = 0
for i in range(q):
    line = list(input().split(" "))
    if line[0] == "1":
        sento += 1
    elif line[1] == "1":
        if sento % 2 == 0:
            s.appendleft(line[2])
        else:
            s.append(line[2])
    else:
        if sento % 2 == 0:
            s.append(line[2])
        else:
            s.appendleft(line[2])
if sento % 2 ==1:
    s.reverse()
for i in range(len(s)):
    print(s[i],end ="")
print()
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = len(set(map(input().strip().split())))
print('Four' if l == 4 else 'Three')

Fixed submission:
n = input()
l = len(set(input().strip().split()))
print('Four' if l == 4 else 'Three')
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
# dfs, check path len, count paths                                                                                                                           
# test = 2                                                                                                                                                   
n, m = map(int, input().split())
edges = [map(int, input().split()) for i in range(n)]
graph = defaultdict(list)
for k,v in edges:
    graph[k].append(v)
    graph[v].append(k)

cnt = 0
# dfs                                                                                                                                                        
def dfs(node, visited):
    global cnt
    if node in visited:
        return None
    elif len(visited) + 1 == n:
        cnt += 1
        return None
    else:
        for v in graph[node]:
            dfs(v, visited+[node])
dfs(1, [])
print(cnt)


Fixed submission:
from collections import defaultdict
# dfs, check path len, count paths                                                                                                                           
# test = 2                                                                                                                                                   
n, m = map(int, input().split())
edges = [map(int, input().split()) for i in range(m)]
graph = defaultdict(list)
for k,v in edges:
    graph[k].append(v)
    graph[v].append(k)

cnt = 0
# dfs                                                                                                                                                        
def dfs(node, visited):
    global cnt
    if node in visited:
        return None
    elif len(visited) + 1 == n:
        cnt += 1
        return None
    else:
        for v in graph[node]:
            dfs(v, visited+[node])
dfs(1, [])
print(cnt)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split(' '))
if a + b + c != 17:
  print('NO')
else if a * b * c != 175:
  print('NO')
else:
  print('YES')

Fixed submission:
a, b, c = map(int, input().split(' '))
if a + b + c != 17:
  print('NO')
elif a * b * c != 175:
  print('NO')
else:
  print('YES')

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split(' '))
if a + b + c != 17:
  print 'NO'
elif a * b * c != 175:
  print 'NO'
else:
  print 'YES'

Fixed submission:
a, b, c = map(int, input().split(' '))
if a + b + c != 17:
  print('NO')
elif a * b * c != 175:
  print('NO')
else:
  print('YES')

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split(' '))
if a + b + c != 17:
  print 'NO'
else if a * b * c != 175:
  print 'NO'
else:
  print 'YES'

Fixed submission:
a, b, c = map(int, input().split(' '))
if a + b + c != 17:
  print('NO')
elif a * b * c != 175:
  print('NO')
else:
  print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
x, y = [int(i) for i in input().split()]
if (2*x - y)%3 != 0:
    print(0)
else:
    LIM = 2*(10**6 + 5)
    fct = [1]*LIM
    inv = [1]*LIM
    MOD = 10**9 + 7
    for i in range(1, LIM):
        fct[i] = ((i%MOD)*(fct[i-1]%MOD))%MOD
        fct[i] %= MOD

    for i in range(1, LIM):
        inv[i] = (((inv[i-1])%MOD)*(pow(i, MOD-2, MOD)%MOD)%MOD)
        inv[i] %= MOD
    
    B = (2*x - y)//3
    A = x - (2*B)
    num = fct[A+B]%MOD
    den = ((inv[A]%MOD)*(inv[B])%MOD)%MOD
    print(((num)%MOD*(den)%MOD))


Fixed submission:
x, y = [int(i) for i in input().split()]
if (2*x - y)%3 != 0:
    print(0)
elif (2*x - y < 0) or ((2*y - x) < 0):
    print(0)
else:
    LIM = 2*(10**6 + 5)
    fct = [1]*LIM
    inv = [1]*LIM
    MOD = 10**9 + 7
    for i in range(1, LIM):
        fct[i] = ((i%MOD)*(fct[i-1]%MOD))%MOD

    for i in range(1, LIM):
        inv[i] = (((inv[i-1])%MOD)*(pow(i, MOD-2, MOD)%MOD)%MOD)
    
    B = (2*x - y)//3
    A = x - (2*B)
    num = fct[A+B]
    den = ((inv[A]%MOD)*(inv[B])%MOD)%MOD
    print((((num)%MOD)*((den)%MOD))%MOD)
Buggy python submission (verdict: Runtime Error):
a, b = [int(i) for i in input().split()]

from math import gcd

g = gcd(a, b)

nof = 1
up = g
for i in range(2, up):
    if i*i > up:
        break
    if g%i == 0:
        nof += 1
        #print(i, nof)
        while g%i == 0:
            g = g//i
if g > 1:
    nof += 1
print(nof)
            


Fixed submission:
a, b = [int(i) for i in input().split()]

def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)



g = gcd(a, b)

nof = 1
up = g

for i in range(2, up):
    if i*i > up:
        break
    if g%i == 0:
        nof += 1
        #print(i, nof)
        while g%i == 0:
            g = g//i
if g > 1:
    nof += 1
print(nof)
Buggy python submission (verdict: Runtime Error):
n = int(input())
from collections import defaultdict as dd

hsh = dd(int)

for i in range(n):
  s = input()
  s = sorted(s)
  hsh[s] += 1

x = 0
for i in hsh:
  x += (hsh[i]*(hsh[i]-1))//2

print(x)

Fixed submission:
n = int(input())
from collections import defaultdict as dd

hsh = dd(int)

for i in range(n):
  s = list(input())
  s = ''.join(sorted(s))
  hsh[s] += 1

x = 0
for i in hsh.keys():
  x += (hsh[i]*(hsh[i]-1))//2

print(x)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = []
for i in range(n):
  s = input()
  A.append(sorted(s))
x = 0
for i in range(n):
	for j in range(i+1, n):
		if A[i] == A[j]:
			x+=1

print(x)

Fixed submission:
n = int(input())
from collections import defaultdict as dd

hsh = dd(int)

for i in range(n):
  s = list(input())
  s = ''.join(sorted(s))
  hsh[s] += 1

x = 0
for i in hsh.keys():
  x += (hsh[i]*(hsh[i]-1))//2

print(x)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = []
for i in range(n):
  s = input()
  A.append(sorted(s))
x = 0
for i in range(n):
  for j in range(i+1, n):
  	if A[i] == A[j]:
      x+=1
print(x)

Fixed submission:
n = int(input())
from collections import defaultdict as dd

hsh = dd(int)

for i in range(n):
  s = list(input())
  s = ''.join(sorted(s))
  hsh[s] += 1

x = 0
for i in hsh.keys():
  x += (hsh[i]*(hsh[i]-1))//2

print(x)