Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
A= input()
cnt = 0
tmp = []
for i in range(2,len(A)+1):
    for j in range(len(A)-i+1):
        t = A[j:j+i]
        flag = 0
        for k in range(i//2):
            if t[k] == t[len(t)-k-1]:
                continue
            else:
                flag = 1
                break
        if flag ==1:
            tmp.append(A[:j]+t[::-1]+A[j+i:])

print(len(set(tmp))+1)


Fixed submission:
import collections
A= input()
Ac = collections.Counter(A)
cnt = 0
for val in Ac.values():
    cnt += val*(val-1)//2
print(len(A)*(len(A)-1)//2-cnt+1)

Buggy python submission (verdict: Time Limit Exceeded):
A= input()
cnt = 0
tmp = []
for i in range(2,len(A)+1):
    for j in range(len(A)-i+1):
        t = A[j:j+i]
        flag = 0
        for k in range(i//2):
            if t[k] == t[len(t)-k-1]:
                continue
            else:
                flag = 1
                break
        if flag ==1:
            tmp.append(A[:j]+t[::-1]+A[j+i:])

print(len(set(tmp))+1)


Fixed submission:
import collections
A= input()
Ac = collections.Counter(A)
cnt = 0
for val in Ac.values():
    cnt += val*(val-1)//2
print(len(A)*(len(A)-1)//2-cnt+1)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

int(input())
list(map(int,input().split()))
input().rstrip()

Fixed submission:
import sys
input = sys.stdin.readline

x,a,b = list(map(int,input().split()))
print('A' if abs(x-a) < abs(x-b) else 'B')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(input().split())
b = []
for i in a:
    b.append(i)
    b = b[::-1]

for s in b:
    print(s,end= ' ')


Fixed submission:
n = int(input())
a = list(input().split())
num = list(range(n-1,-(n-1)-2,-2) )
for i in range(len(num)):
    if num[i]<0:
        num[i] = abs(num[i]+1)
    print(a[num[i]], end = ' ')
Buggy python submission (verdict: Runtime Error):
	N,M = list(map(int,input().split()))
lis = []
for i in range(N):
    lis.append([i+1])
for i in range(M):
    a,b = list(map(int,input().split()))
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(N):
    print(len(lis[i])-1)


Fixed submission:
N,M = list(map(int,input().split()))
lis = []
for i in range(N):
    lis.append([i+1])
for i in range(M):
    a,b = list(map(int,input().split()))
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(N):
    print(len(lis[i])-1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
road = [0]*(N-1)
for _ in range(M):
    l,r=map(int,input().split())
    for i in range(l-1,r-1):
        road[i]+=1
if sum(road)%2==0:
    print('YES')
else:
    print('NO')


Fixed submission:
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
road = [0]*(N)
for _ in range(M):
    l,r=map(int,input().split())
    road[l-1]+=1
    road[r-1]-=1
road = list(itertools.accumulate(road))[:-1]

flag=0
for ro in road:
    if ro%2==1:
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

sum_odd = sum(a[1::2])
sum_eve = sum(a[::2])

count = 0
sum_a  = 0
if sum_odd >= sum_eve:#奇数の和がおおきいので、偶数　0,2,4...を負にする
    for i in range(n):
        
        sum_a = sum_a + a[i]
        #print('sum_a : ' +str(sum_a))
        #print('sum_a *(-1)**(i+1) : '+str(sum_a *(-1)**(i+1)))
        if sum_a *(-1)**(i+1) < 1:
            while sum_a*(-1)**(i+1) <1:
                count += 1
                a[i] += 1*(-1)**(i+1)
                sum_a += 1*(-1)**(i+1)
else:
    for i in range(n):
       
        sum_a = sum_a + a[i]
        if sum_a *(-1)**(i) < 1:
            while sum_a*(-1)**(i) <1:
                count += 1
                a[i] += 1*(-1)**(i)
                sum_a += 1*(-1)**(i)
print(count)


Fixed submission:

import sys
import copy
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
b = copy.copy(a)
sum_odd = sum(a[1::2])
sum_eve = sum(a[::2])

ans = 0
sum_a  = 0
for i in range(n):
        
    sum_a = sum_a + a[i]
        
    if sum_a *(-1)**(i+1) < 1:
        kari = 1-sum_a *(-1)**(i+1)
        a[i] += 1*(-1)**(i+1) *(kari)
        sum_a += 1*(-1)**(i+1) *(kari)
            
        ans = ans + abs(kari)
            
ans1 = 0
sum_b = 0
             
for i in range(n):
       
    sum_b = sum_b + b[i]
    if sum_b *(-1)**(i) < 1:
        kari = (1-sum_b *(-1)**(i))
        b[i] += 1*(-1)**(i) * kari
        sum_b += 1*(-1)**(i) * kari

        ans1 = ans1 + abs(kari)


print(min(ans,ans1))
Buggy python submission (verdict: Runtime Error):
s = input()
a=0
b=0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s),-1,-1):
  if s[i] == 'Z':
    b = i
    break
print(b-a+1)
  

Fixed submission:
s = input()
a=0
b=0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s)-1,-1,-1):
  if s[i] == 'Z':
    b = i
    break
print(b-a+1)
Buggy python submission (verdict: Time Limit Exceeded):
K,S = list(map(int,input().split()))
counter = 0
counter_d = 0
counter_tri =0
for i in range(K+1):
    for j in range(i+1,K+1):
        for k in range(j+1,K+1):
            if i+j+k ==S:
                counter +=6
for i in range(K+1):
    for k in range(K+1):
       if 2*i+k== S:
           if i == k:
               counter += 1
           else:
               counter +=3
print(counter)


Fixed submission:
K,S = list(map(int,input().split()))
counter = 0
for i in range(K+1):
    for j in range(K+1):
            if 0<=S-i-j<=K:
                counter +=1
               # print(str(i)+' '+str(j)+ ' ' + str(S-i-j))
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
K,S = list(map(int,input().split()))
counter = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k ==S:
                counter +=1
print(counter)


Fixed submission:
K,S = list(map(int,input().split()))
counter = 0
for i in range(K+1):
    for j in range(K+1):
            if 0<=S-i-j<=K:
                counter +=1
               # print(str(i)+' '+str(j)+ ' ' + str(S-i-j))
print(counter)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
t= 1
a= 1

def t_small(t,a,t1,a1):
    gain = -(-t//t1)
    t = gain*t1
    a_tmp=gain*a1
    if a_tmp<a:
        gain_a = -(-a//a_tmp)
        t *= gain_a
        a = a_tmp*gain_a
    else:
        a = a_tmp
    return t,a,t+a

def a_small(t,a,t1,a1):
    gain = -(-a//a1)
    a = gain*a1
    t_tmp=gain*t1
    if t_tmp<t:
        gain_t = -(-t//t_tmp)
        a *= gain_t
        t = t_tmp*gain_t
    else:
        t = t_tmp
    return t,a,t+a

ans = 0
for _ in range(N):
    t1,a1 = map(int,input().split())
    tt1,aa1,sta1 = t_small(t,a,t1,a1)
    tt2,aa2,sta2 = a_small(t,a,t1,a1)
    if sta1<=sta2:
        t=tt1;a=aa1,ans = sta1
    else:
        t=tt2,a=aa2,ans=sta2
print(ans)

Fixed submission:
import math
N = int(input())
t= 1
a= 1

def t_small(t,a,t1,a1):
    gain = -(-t//t1)
    t = gain*t1
    a_tmp=gain*a1
    if a_tmp<a:
        gain_a = -(-a//a_tmp)
        t *= gain_a
        a = a_tmp*gain_a
    else:
        a = a_tmp
    return t,a,t+a

def a_small(t,a,t1,a1):
    gain = -(-a//a1)
    a = gain*a1
    t_tmp=gain*t1
    if t_tmp<t:
        gain_t = -(-t//t_tmp)
        a *= gain_t
        t = t_tmp*gain_t
    else:
        t = t_tmp
    return t,a,t+a

ans = 0
for _ in range(N):
    t1,a1 = map(int,input().split())
    tt1,aa1,sta1 = t_small(t,a,t1,a1)
    tt2,aa2,sta2 = a_small(t,a,t1,a1)
    if sta1<=sta2:
        t=tt1;a=aa1;ans = sta1
    else:
        t=tt2;a=aa2;ans=sta2
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
s = input()
ls = len(s)
if ls ==2 and s[0]=!s[1]:
    print(-1,-1)
elif ls ==2 and s[0]==s[1]:
    print(1,2)
for i in range(2,ls):
    tmp = collections.Counter(s[i-2:i+1])
    if len(tmp.keys())<=2:
        print(i-1,i+1)
        exit()
print(-1,-1)

Fixed submission:
import collections
s = input()
ls = len(s)
if ls ==2 and s[0]!=s[1]:
    print(-1,-1)
    exit()
elif ls ==2 and s[0]==s[1]:
    print(1,2)
    exit()
for i in range(2,ls):
    tmp = collections.Counter(s[i-2:i+1])
    if len(tmp.keys())<=2:
        print(i-1,i+1)
        exit()
print(-1,-1)
Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print(*s,sep="")

Fixed submission:
import sys
input = sys.stdin.readline

a,b,c = sorted(list(map(int,input().split())))
print('YES' if a==b and b==5 and c==7 else 'NO')
Buggy python submission (verdict: Runtime Error):
import sys,math,collections,itertools,bisect
input = sys.stdin.readline

N,K=list(map(int,input().split()))
D = list(map(int,input().split()))
Ds = set([0,1,2,3,4,5,6,7,8,9])-set(D)
can = list(itertools.product(Ds,repeat = 5))
candi = []
for c in can:
    candi.append(1**4*c[0]+10**3*c[1]+10**2*c[2]+10**1*c[3]+c[4])
candi = sorted(candi)
print(candi[bisect.bisect_left(candi,N)])


Fixed submission:
import sys,math,collections,itertools,bisect
input = sys.stdin.readline

N,K=list(map(int,input().split()))
D = list(map(int,input().split()))
Ds = set([0,1,2,3,4,5,6,7,8,9])-set(D)
if 0 in Ds:
    can = list(itertools.product(Ds,repeat = 5))
    candi = []
    for c in can:
        candi.append(10**4*c[0]+10**3*c[1]+10**2*c[2]+10**1*c[3]+c[4])
    candi = sorted(candi)
else:
    Ds = Ds | set([0])
    can = list(itertools.product(Ds,repeat = 5))
    candi = []
    for c in can:
        cs = (10**4*c[0]+10**3*c[1]+10**2*c[2]+10**1*c[3]+c[4])
        s = list(str(cs))
        if '0' in s:
            continue
        else:
            candi.append(cs)
    candi = sorted(candi)
    
print(candi[bisect.bisect_left(candi,N)])
Buggy python submission (verdict: Runtime Error):
import sys

arg = sys.argv
#arg.pop(0)
#print(arg)

for i in range(arg[0]):
  print('ACL')

Fixed submission:
print('ACL'*int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, N = map(int, input().split())
if N > B:
	N = B
ans = 0
for x in range(1, N+1):
	y = math.floor(A * x / B) - A * math.floor(x / B)
	ans = max(ans, y)
print(ans)

Fixed submission:
import math
A, B, N = map(int, input().split())
if N >= B:
	N = B - 1
ans = math.floor(A * N / B)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, N = map(int, input().split())
ans = 0
for x in range(1, N+1):
	y = math.floor(A * x / B) - A * math.floor(x / B)
	ans = max(ans, y)
print(ans)

Fixed submission:
import math
A, B, N = map(int, input().split())
if N >= B:
	N = B - 1
ans = math.floor(A * N / B)
print(ans)
Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
if W >= S:
	print(unsafe)
else:
	print(safe)

Fixed submission:
S, W = map(int, input().split())
if W >= S:
	print('unsafe')
else:
	print('safe')
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
while A % B != 0:
	A, B = B, A % B
G = B
ans = 1
list = [2]
for i in range(3, G + 1):
	chk = True
	for j in list:
		if i % j == 0:
			chk = False
	if chk == True:
		list.append(i)
for k in list:
	if G % k == 0:
		ans += 1
print(ans)

Fixed submission:
N = int(input())
print(((N + 1) // 2) / N)
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
while A % B != 0:
	A, B = B, A % B
G = B
ans = 1
list = [2]
for i in range(3, G + 1):
	chk = True
	for j in list:
		if i % j == 0:
			chk = False
	if chk == True:
		list.append(i)
for k in list:
	if G % k == 0:
		G /= k
		ans += 1
print(ans)

Fixed submission:
import collections
def prime_factorize(n):
	list = []
	while n % 2 == 0:
		list.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			list.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		list.append(n)
	return list

A, B = map(int, input().split())
while A % B != 0:
	A, B = B, A % B
G = B
c = collections.Counter(prime_factorize(G))
print(len(list(c.keys())) + 1)

Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
while A % B != 0:
	A, B = B, A % B
G = B
ans = 1
list = [2]
for i in range(3, G + 1):
	chk = True
	for j in list:
		if i % j == 0:
			chk = False
	if chk == True:
		list.append(i)
for k in list:
	if G % k == 0:
		ans += 1
print(ans)

Fixed submission:
import collections
def prime_factorize(n):
	list = []
	while n % 2 == 0:
		list.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			list.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		list.append(n)
	return list

A, B = map(int, input().split())
while A % B != 0:
	A, B = B, A % B
G = B
c = collections.Counter(prime_factorize(G))
print(len(list(c.keys())) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
def quiz(n, a, p):
	for i in range(n):
		p[i] -= 1
	p[a-1] += 1

N, K, Q = map(int, input().split())
p = [K] * N
for i in range(Q):
	a = int(input())
	quiz(N, a, p)
for i in range(N):
	if p[i] > 0:
		print('Yes')
	else:
		print('No')

Fixed submission:
N, K, Q = map(int, input().split())
p = [K] * N
for i in range(Q):
	a = int(input())
	p[a-1] += 1
for i in range(N):
	if p[i] > Q:
		print('Yes')
	else:
		print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(N):
	if sum(x % (N - i) for x in ans) != a[N - 1 - i]:
		ans.append(N - i)
print(len(ans))
Ans = [str(x) for x in ans]
print(' '.join(Ans))

Fixed submission:
r = int(input())
print(3 * (r ** 2))
Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
	divisors = [1]
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
N = int(input())
a = list(map(int, input().split()))
num = 0
ans = []
for i in range(N):
	list = make_divisors(N - i)
	if a[N - 1 - i] % 2 == 1:
		num += 1
		ans.append(N - i)
		for j in list:
			a[j - 1] += 1
print(num)
Ans = [str(x) for x in ans]
print(' '.join(Ans))

Fixed submission:
N = int(input())
a = [0] + list(map(int, input().split()))
ans = [0] * (N + 1)
an = []
for i in range(N, 0, -1):
	if sum(ans[i * 2 :: i]) % 2 != a[i]:
		ans[i] = 1
		an.append(i)
print(len(an))
Ans = [str(x) for x in an]
print(' '.join(Ans))

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
	divisors = [1]
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
N = int(input())
a = list(map(int, input().split()))
num = 0
ans = []
for i in range(N):
	list = make_divisors(N - i)
	if a[N - 1 - i] % 2 == 1:
		num += 1
		ans.append(N - i)
		for j in list:
			a[j - 1] += 1
print(num)
Ans = [str(x) for x in ans]
print(' '.join(Ans))

Fixed submission:
N = int(input())
a = [0] + list(map(int, input().split()))
ans = [0] * (N + 1)
an = []
for i in range(N, 0, -1):
	if sum(ans[i * 2 :: i]) % 2 != a[i]:
		ans[i] = 1
		an.append(i)
print(len(an))
Ans = [str(x) for x in an]
print(' '.join(Ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(N):
	if sum(x % (N - i) for x in ans) != a[N - 1 - i]:
		ans.append(N - i)
print(len(ans))
Ans = [str(x) for x in ans]
print(' '.join(Ans))

Fixed submission:
N = int(input())
a = [0] + list(map(int, input().split()))
ans = [0] * (N + 1)
an = []
for i in range(N, 0, -1):
	if sum(ans[i * 2 :: i]) % 2 != a[i]:
		ans[i] = 1
		an.append(i)
print(len(an))
Ans = [str(x) for x in an]
print(' '.join(Ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
A.extend(A)
B = []
for i in range(N):
	x = 0
	for j in range((N - 1) // 2):
		x += A[i + 2 * j + 1]
	B.append(S - 2 * x)
C = [str(a) for a in B]
print(' '.join(C))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
B = []
x = 0
for j in range((N - 1) // 2):
	x += A[2 * j + 1]
B.append(S - 2 * x)
for i in range(N - 1):
	x = A[i] * 2 - B[i]
	B.append(x)
C = [str(a) for a in B]
print(' '.join(C))
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
if N == 1:
	print(1)
else:
	L = []
	for i in range(N):
		a, b = x[i][0], x[i][1]
		for j in range(N):
			if a > x[j][0] or b > x[j][1]:
				L.append((a - x[j][0], b - x[j][1]))
	c = collections.Counter(L)
	max = c.most_common(1)[0][1]
	print(N - max)

Fixed submission:
N, K = map(int, input().split())
if K == 1:
	print(0)
else:
	print(N - K)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[1] >= 0:
	print(sum(A) - 2 * A[0])
	y = A[0]
	for i in range(N - 2):
		print(y, A[i + 1])
		y -= A[i + 1]
	print(A[-1], y)
elif A[-1] < 0:
	print(-sum(A) + 2 * A[-1])
	y = A[-1]
	for i in range(N - 1):
		print(y, A[i])
		y -= A[i]
else:
	for i in range(N - 1):
		if A[i] < 0 and A[i + 1] >= 0:
			n = i
	print(-sum(A[:i]) + sum(A[i:]))
	y = A[0]
	for i in range(N - n - 2):
		print(y, A[-i - 2])
		y -= A[-i - 2]
	print(A[-1], y)
	y = A[-1] - y
	for i in range(n):
		print(y, A[i + 1])

Fixed submission:
N, K = map(int, input().split())
if K == 1:
	print(0)
else:
	print(N - K)
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
if N == 1
	print(1)
else:
	L = []
	for i in range(N):
		a, b = x[i][0], x[i][1]
		for j in range(N):
			if a > x[j][0] or b > x[j][1]:
				L.append((a - x[j][0], b - x[j][1]))
	c = collections.Counter(L)
	max = c.most_common(1)[0][1]
	print(N - max)

Fixed submission:
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
if N == 1:
	print(1)
else:
	L = []
	for i in range(N):
		a, b = x[i][0], x[i][1]
		for j in range(N):
			if a > x[j][0] or b > x[j][1]:
				L.append((a - x[j][0], b - x[j][1]))
	c = collections.Counter(L)
	max = c.most_common(1)[0][1]
	print(N - max)

Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
L = []
for i in range(N):
	a, b = x[i][0], x[i][1]
	for j in range(N):
		if a > x[j][0] or b > x[j][1]:
			L.append((a - x[j][0], b - x[j][1]))
c = collections.Counter(L)
max = c.most_common(1)[0][1]
print(N - max)

Fixed submission:
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
if N == 1:
	print(1)
else:
	L = []
	for i in range(N):
		a, b = x[i][0], x[i][1]
		for j in range(N):
			if a > x[j][0] or b > x[j][1]:
				L.append((a - x[j][0], b - x[j][1]))
	c = collections.Counter(L)
	max = c.most_common(1)[0][1]
	print(N - max)

Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
L = []
for i in range(N):
	a, b = x[i][0], x[i][1]
	for j in range(N):
		if a >= x[j][0] and b >= x[j][1] and not(a == x[j][0] and b == x[j][1]):
			L.append((a - x[j][0], b - x[j][1]))
c = collections.Counter(L)
max = c.most_common()[0][1]
print(N - max)

Fixed submission:
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
if N == 1:
	print(1)
else:
	L = []
	for i in range(N):
		a, b = x[i][0], x[i][1]
		for j in range(N):
			if a > x[j][0] or b > x[j][1]:
				L.append((a - x[j][0], b - x[j][1]))
	c = collections.Counter(L)
	max = c.most_common(1)[0][1]
	print(N - max)
Buggy python submission (verdict: Runtime Error):
mod = 10 ** 6 + 3

W = [1] * (mod)
for i in range(mod - 1):
	W[i + 1] = ((i + 1) * W[i]) % mod

def rev(a):
	return pow(a, mod - 2, mod)

def f(x, d, n):
	if d == 0:
		return pow(x, n, mod)
	else:
		d_r = rev(d)
		xdr = d_r * x % mod
		if xdr == 0:
			return 0
		elif (xdr + n - 1) >= mod:
			return 0
		else:
			return (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod

ans = []
q = int(input())
for _ in range(q):
    x,d,n = map(int,input().split())
    ans.append(f(x,d,n))
for i in ans:
    print(i)

Fixed submission:
N = int(input())
print((N - 2) * 180)
Buggy python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
mod = 10 ** 9 + 7

W = [1] * (2 * N)
for i in range(2 * N - 1):
	W[i + 1] = ((w + 1) * W[i]) % mod

def rev(a):
	return pow(a, mod - 2, mod)

def comb(a, b):
	return (W[a] * rev(W[b]) * rev(W[a - b])) % mod

def f(a, b):
	res = 0
	for i in range(N):
		res += ((i + N) * com[i] * pow(b, i, mod)) % mod
		res %= mod
	return (pow(a, N, mod) * res) % mod

a = A * rev(A + B)
b = B * rev(A + B)
c = C * rev(100)
com = [comb(i + N - 1, i) for i in range(N)]

w_a = f(a, b)
w_b = f(b, a)
ans = ((w_a + w_b) * rev(1 - c)) % mod
print(ans)

Fixed submission:
N, A, B, C = map(int, input().split())
mod = 10 ** 9 + 7

W = [1] * (2 * N)
for i in range(2 * N - 1):
	W[i + 1] = ((i + 1) * W[i]) % mod

def rev(a):
	return pow(a, mod - 2, mod)

def comb(a, b):
	return (W[a] * rev(W[b]) * rev(W[a - b])) % mod

def f(a, b):
	res = 0
	for i in range(N):
		res += ((i + N) * com[i] * pow(b, i, mod)) % mod
		res %= mod
	return (pow(a, N, mod) * res) % mod

a = A * rev(A + B)
b = B * rev(A + B)
c = C * rev(100)
com = [comb(i + N - 1, i) for i in range(N)]

w_a = f(a, b)
w_b = f(b, a)
ans = ((w_a + w_b) * rev(1 - c)) % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
n_switch = []
switch = []
for i in range(M):
	s = list(map(int, input().split()))
	n_switch.append(s[0])
	switch.append(s[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	x = 1
	b = bin(i)[2:].rjust(N, '0')
	for j in range(M):
		n_light = 0
		for k in range(n_switch[j]):
			if b[switch[j][k] - 1] == '1':
				n_light += 1
		if n_light % 2 != p[j]:
			x *= 0
			break
	if x == 1:
		ans += 1
print(ans)

Fixed submission:
A, P = map(int, input().split())
print((3 * A + P) // 2)