problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03339
s735978723
Accepted
n=int(input()) s=list(input()) E=s.count('E') W=s.count('W') if s[0]=='E': ans=E-1 else: ans=E ans1=[] ans1.append(ans) for x in range(1,n): if s[x]=='E': if s[x-1]=='E': ans-=1 else: if s[x-1]=='W': ans+=1 ans1.append(ans) print(min(ans1))
p02861
s950726869
Accepted
from itertools import permutations from math import sqrt n = int(input()) temp_list = [] for i in range(n): temp_list.append([int(s) for s in input().split()]) ans = 0 for count, temp in enumerate(permutations(list(range(n)))): for i in range(n - 1): a = temp[i + 1] b = temp[i] ans += sqrt((temp_list[a][0] - temp_list[b][0]) ** 2 + (temp_list[a][1] - temp_list[b][1]) ** 2) ans /= (count + 1) print(ans)
p02843
s601421497
Accepted
x = int(input()) q,r = divmod(x, 100) if r <= q*5: print(1) else: print(0)
p02700
s053973205
Accepted
import sys import numpy as np a, b, c, d = map(int, sys.stdin.readline().strip().split()) attack_t = np.ceil(c / b) attack_a = np.ceil(a / d) if attack_t <= attack_a: print('Yes') else: print('No')
p02982
s063504688
Wrong Answer
import sys,math input = sys.stdin.readline N, D = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(N)] cnt = 0 num = 0 print(X) for i in range(1,N): for j in range(1,D): #num += pow(abs(X[i-1][j-1] - X[i][j]) ,2) print(X[i-1][j-1],X[i][j]) #if int(math.sqrt(num)): #print(math.sqrt(num)) #cnt += 1 #print(cnt)
p02801
s424362271
Accepted
print(chr(ord(input().rstrip())+1))
p02766
s220827059
Wrong Answer
N,K=map(int,input().split()) x=0 while True: if N<=K**x: print(x) break x+=1
p03485
s850864922
Wrong Answer
a,b=map(int,input().split()) print(round((a+b+1)/2))
p02823
s053842296
Wrong Answer
n, a, b = map(int, input().split()) if (b-a)%2==0: print(abs(a-b)//2) else: print(min(n-b, n-a))
p02797
s812064809
Wrong Answer
n, k, s = map(int, input().split()) els = 10**9+7 for i in range(n): if i < k: print(s, end=" ") else: print(els, end=" ")
p02663
s880222508
Wrong Answer
#import numpy as np #from itertools import combinations as comb #from itertools import combinations_with_replacement as comb_with #A = int(input()) H1,M1,H2,M2,K= map(int,input().split()) #A = list(map(int,input().split())) #B = list(map(int,input().split())) #S= str(input()) H=(H2-H1)*60 m=H-K print(m)
p02624
s909418376
Accepted
n=int(input()) ans=0 for i in range(n): m=n//(i+1) ans += (i+1) *m*(m+1)/2 print(int(ans))
p02603
s195395501
Accepted
n = int(input()) a = list(map(int,input().split())) money = 1000 stock = 0 for i in range(n-1): if a[i+1] > a[i]: stock = money // a[i] money = money - stock*a[i] + stock*a[i+1] print(money)
p02665
s636593570
Wrong Answer
import numpy as np import math import collections N = int(input()) A = list(map(int, input().split())) ans = 0 node_num = 1 pre_node_num = 1 B = [1 - A[0]] for i in range(1, N): tmpB = min(2 * B[i - 1] - A[i], sum(A[i + 1:])) # print(tmpB) if tmpB < B[i - 1] - A[i]: ans = -1 break B.append(tmpB) if ans != -1: ans = sum(A) + sum(B) print(ans)
p02711
s465065460
Accepted
N = input() if '7' in N: print('Yes') else: print('No')
p03803
s614889113
Wrong Answer
a,b=map(int,input().split()) if a==1:a=14 if b==1:b=14 if a<b: print("Alice") elif a==b: print("Draw") else: print("Bob")
p02785
s157302151
Wrong Answer
n, k = map(int, input().split(' ')) nums = list(map(int, input().split(' '))) nums.sort(reverse=True) if k >= n: print(0) else: if k > 0: nums = nums[:k] print(sum(nums))
p02842
s794754956
Accepted
N = int(input()) ans = ':(' for i in range(N+1): if int(i * 1.08) == N: ans = i break print(ans)
p02946
s985722397
Accepted
k, x = map(int, input().split()) for i in range(x-k+1, x+k): print(i, end = " ")
p02639
s360497056
Wrong Answer
x = list(map(int, input().split())) print(x)
p02842
s614483277
Accepted
n=int(input()) lowx=-(-n*100//108) highx=-(-(n+1)*100//108) if lowx<highx: print(lowx) else: print(':(')
p02742
s885907623
Wrong Answer
a,b=map(int,input().split()) print ((a*b+1)//2)
p03838
s475932724
Accepted
a,b = map(int, input().split()) ans = abs(abs(a) - abs(b)) sign = inc = 0 if a*b < 0: sign = 1 if a-b < 0: inc = 1 if a==0 and b==0: print(0) exit() elif a==0: if inc == 0: ans += 1 print(ans) exit() elif b==0: if inc == 0: ans += 1 print(ans) exit() if sign == 0 and inc == 0: ans += 2 elif sign == 0 and inc == 1: pass else: ans += 1 print(ans)
p02702
s020747028
Accepted
S = list(input()) for i in range(len(S)): S[i] = int(S[i]) A = [S[len(S)-1]] mod = 2019 for i in range(1,len(S)): A.append((S[len(S)-i-1]*pow(10,i,mod)+A[i-1]) % mod) from collections import Counter c = Counter(A) ans = c[0] for i in range(0,2019): if c[i] >= 2: ans += (c[i]*(c[i]-1)) //2 print(ans)
p02835
s275035433
Accepted
a, b, c = map(int, input().split()) abc = a + b + c if abc > 21: print("bust") else: print("win")
p02823
s375324847
Wrong Answer
N,A,B = map(int, input().split()) if (A-B)%2 ==0: print(A/B/2) else: print(min(A-1,N-B)+1+(B-A-1)/2)
p02570
s946150150
Accepted
D,T,S=map(int,input().split()) a=D/S if T>=a: print("Yes") else: print("No")
p02773
s313047498
Accepted
N = int(input()) dic = dict() lis = list() for i in range(N): tmp = input() lis.append(tmp) dic[tmp] =0 maxi = 0 for i in lis: dic[i] +=1 if maxi < dic[i]: maxi = dic[i] result = list() for name in dic: if dic[name] == maxi: result.append(name) for i in sorted(result): print(i)
p03485
s233136280
Accepted
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque if __name__ == '__main__': a = [int(i) for i in input().split()] sum = a[0]+a[1] ans =sum //2 if sum%2 ==1: ans +=1 print(ans)
p02595
s373599312
Accepted
n, d = map(int, input().split()) xy = [list(map(int, input().split())) for _ in range(n)] ans = 0 for x, y in xy: distance = (x ** 2 + y ** 2) ** 0.5 if distance <= d: ans += 1 print(ans)
p03836
s053112693
Accepted
sx,sy,tx,ty=map(int,input().split()) x=tx-sx y=ty-sy path="U"*y+"R"*x+"D"*y+"L"*(x+1)+"U"*(y+1)+"R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U" print(path)
p02922
s155569817
Wrong Answer
import math a,b=map(int,input().strip().split()) print(math.ceil(b/a))
p02771
s108172116
Accepted
def main(): li = list(map(int, input().split())) ans = "Yes" if len(set(li)) == 2 else "No" print(ans) if __name__ == "__main__": main()
p02677
s630337293
Wrong Answer
import math A, B, H, M = map(float, input().split()) kakudo = (30 * H + 0.5 * M) - 6 * M if kakudo > 180: kakudo -= 180 # print(kakudo) ans2 = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.pi * (kakudo / 180)) # print(ans2) print(math.sqrt(ans2))
p03417
s039386992
Accepted
n,m=map(int,input().split()) if (n,m)==(1,1): print(1) elif min(n,m)==1: print(max(n,m)-2) else: print((n-2)*(m-2))
p02848
s041351674
Wrong Answer
N=int(input()) S=input() ANS="" for i in range(len(S)): ANS+=chr(64+((ord(S[i])+N)-64)%26) print(ANS)
p03419
s720258282
Accepted
N, M = map(int, input().split()) if N > M: N, M = M, N if N == 1 and M == 1: print(1) elif N == 1: print(M - 2) else: print(N * M - 2 * N - 2 * M + 4)
p02854
s971632492
Accepted
n = int(input()) l = list(map(int,input().split())) from itertools import accumulate tot=sum(l) ans=2020202020*100000 for i in list(accumulate(l)): ans=min(ans, abs(tot-(i*2))) for i in list(accumulate(l[::-1])): ans=min(ans, abs(tot--(i*2))) print(ans)
p02916
s906103154
Accepted
n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) ans=0 for i in range(n-1): if a[i+1]-a[i]==1: ans+=c[a[i]-1] print(ans+sum(b))
p03017
s367495142
Accepted
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,a,b,c,d = list(map(int, input().split())) a -= 1 b -= 1 c -= 1 d -= 1 s = input() if "##" in s[a:c+1]: ans = "No" elif "##" in s[b:d+1]: ans = "No" elif c>d and "..." not in s[b-1:d+2]: ans = "No" else: ans = "Yes" print(ans)
p03699
s375348691
Accepted
import sys import copy import math import itertools import numpy as np import re N = int(input()) s = [int(input()) for c in range(N)] ans = sum(s) s = [c for c in sorted(list(set(s))) if c%10 != 0] if ans % 10 ==0: if len(s) > 0: print(ans-s[0]) sys.exit(0) else: print(0) sys.exit(0) else: print(ans) sys.exit(0) print(0)
p03696
s669152949
Accepted
N=int(input()) S=input() A=0 #( B=0 #) for s in S: if s=='(': A+=1 elif s==')' and A>0: A-=1 else: B+=1 print('('*B+S+')'*A)
p02756
s455822065
Accepted
from collections import deque Q=deque(list(input())) rev=0 for _ in range(int(input())): query=input() if query[0]=='1': rev^=1 else: q,f,c=query.split() if (f=='1')^(rev): Q.appendleft(c) else: Q.append(c) if rev: Q=reversed(Q) print(''.join(Q))
p03359
s916776223
Accepted
a,b=map(int,input().split()) print(a if b>=a else a-1)
p02743
s214867926
Wrong Answer
a,b,c=map(int,input().split()) import math if math.sqrt(a*b)<c-b-a: print('Yes') else: print('No')
p03721
s276149715
Wrong Answer
N,K=map(int,input().split()) C=0 for i in range(N): a,b=map(int,input().split()) C+=b if C>=K: print(a) break
p02707
s034319197
Wrong Answer
N = int(input()) A = list(map(int,input().split())) tmp2 = 0 for i in range(N+1): if(i == 0): tmp=A.count(1) print(str(tmp)) else: tmp2 = i + 1 tmp=A.count(tmp2) print(str(tmp))
p02603
s330661226
Accepted
import numpy as np n=int(input()) a = list(map(int, input().split())) m = 1000 kabu = 0 for i in range(n-1): if a[i] < a[ i +1 ]: kabu = kabu + int((m - (m % a[i])) / a[i]) m = m % a[i] elif a[i] > a[ i +1 ]: m = m + (a[i] * kabu) kabu = 0 if kabu > 0: m = m + kabu * a[-1] print(m)
p03665
s841177099
Accepted
N, P = map(int, input().split(' ')) A = tuple(map(int, input().split(' '))) dp = [[0, 0] for _ in range(N + 1)] dp[0][0] = 1 for index, a in enumerate(A, start=1): if a % 2 == 0: dp[index][0] = dp[index - 1][0] * 2 dp[index][1] = dp[index - 1][1] * 2 else: dp[index][0] = dp[index - 1][1] + dp[index - 1][0] dp[index][1] = dp[index - 1][0] + dp[index - 1][1] print(dp[N][P])
p02777
s683235718
Accepted
s, t = input().split() a, b = map(int, input().split()) u = input() if u == s: print(a - 1, b) else: print(a, b - 1)
p02675
s594113481
Accepted
n=int(input())%10 if n in [ 2, 4, 5, 7,9]: print('hon') elif n in [0,1,6,8]: print('pon') else: print('bon')
p03338
s204385413
Accepted
N = int(input()) s = input() result = 0 for i in range(N - 1): a = set(s[:i]) b = set(s[i:]) result = max(result, len(a & b)) print(result)
p02555
s305903249
Accepted
s=int(input()) mod=10**9+7 dp=[0]*(s+1) dp[s]=1 for i in range(s,2,-1): for j in range(3,s+1): if i-j<0:break dp[i-j]+=dp[i] dp[i-j]%=mod print(dp[0])
p03778
s062350428
Accepted
W, a, b = map(int, input().split()) if a < a + W <= b: ans = b - (a + W) elif a <= b <= a + W: ans = 0 elif a <= b + W <= a + W: ans = 0 else: ans = a - (b + W) print(ans)
p02917
s413694920
Accepted
N = int(input()) B = list(map(int, input().split())) A = [0]*N A[0] = B[0] for i in range(1, N-1): A[i] = min(B[i-1], B[i]) A[N-1] = B[N-2] print(sum(A))
p03327
s553456824
Accepted
n = int(input()) print("ABC" if n<=999 else "ABD")
p03210
s724754020
Wrong Answer
age = int(input()) if age == 7 or age == 5 or age == 3: print("Yes") else: print("No")
p02615
s181456508
Wrong Answer
import copy inp = input() friends = input() friendList = friends.split() sortedFriends = sorted(friendList, reverse=True) confs = [sortedFriends[0]] # copied = copy.deepcopy(sortedFriends)[1:] sortedFriends.extend(sortedFriends[1:]) sortedFriends = sorted(sortedFriends, reverse=True) #for i in sortedFriends: # print(int(i)) confSum = 0 for i in range(int(inp)-1): conf = int(sortedFriends[i]) confSum += conf print(str(confSum))
p02779
s500725397
Accepted
n=int(input()) a=[int(i) for i in input().split()] a.sort() ch=0 for i in range(1,n): if a[i]==a[i-1]: ch=1 if ch==1: print("NO") else: print("YES")
p02888
s167731008
Accepted
n = int(input()) l = list(map(int,input().split())) l.sort(reverse=True) l.append(0) c = 0 for i in range(n-2): for j in range(i+1,n-1): z = l[i]-l[j] if l[j+1] <= z: break else: a = j+1 b = n+1 while a+1 < b: m = (a+b)//2 if l[m] > z: a = m else: b = m c += a-j print(c)
p02796
s846933935
Accepted
N = int(input()) LR = [None] * N for i in range(N): center, length = [int(i) for i in input().split()] LR[i] = (center + length, center - length) # right, left LR.sort() now = LR[0][0] ans = 1 for i in range(1, N): right, left = LR[i] if now > left: continue else: ans += 1 now = right print(ans)
p03910
s470849947
Accepted
n = int(input()) i = int((2*n)**(1/2)) while i*(i+1)<=2*n: i+=1 j = (i+1)*i//2-n for k in range(1,i+1): if k!= j: print(k)
p04011
s637824583
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n <= k: print(n*x) else: print(k*x+(n-k)*y)
p04005
s166104352
Wrong Answer
A, B, C = map(int, input().split()) ans = A*B*C if (A*B*C)%2==0: print(0) else: cnt = 0 for i in [A,B,C]: if i%2==1 and i>cnt: cnt = i print(ans//i)
p02706
s267801457
Accepted
N,M=map(int,input().split()) A=list(map(int,input().split())) ans=N-sum(A) print(ans if ans>=0 else -1)
p02594
s070497659
Accepted
X = int(input()) ans = 'Yes' if X < 30: ans = 'No' print(ans)
p02754
s695131279
Accepted
N, A, B = input().split() N, A, B = int(N), int(A), int(B) print(N//(A+B)*A + min([A, N%(A+B)]))
p02793
s772529690
Accepted
N = input() A = [int(x) for x in input().split()] def gcd(a, b): return a if b == 0 else gcd(b, a % b) def lcm(a, b): return a // gcd(a, b) * b L = 1 for a in A: L = lcm(L, a) print(sum(L // a for a in A) % (10 ** 9 + 7))
p02705
s217437367
Accepted
#!/usr/bin/env python3 import sys pi = 3.1415 def main(): R =int(input()) print(2 * R * pi) return if __name__ == '__main__': main()
p03250
s790755298
Wrong Answer
a,b,c=map(int,input().split()) print(c*10+b+c)
p03359
s417910307
Accepted
a,b=map(int,input().split()) if a>b:print(a-1) else:print(a)
p03012
s739137537
Wrong Answer
N = int(input()) W = list(map(int, input().split())) d = sum(W) / 2 count = 0 for i in range(N): count += W[i] if count >= d: if i == 0: print(W[0] - sum(W[1:])) else: print(min(sum(W[i:]) - sum(W[:i]), sum(W[:i + 1]) - sum(W[i+1:])))
p02922
s046578162
Wrong Answer
a, b = map(int, input().split()) cnt = 1 tmp = 0 ans = 0 while True: if b == 1: print(ans) break if cnt >= 2: tmp += a - 1 else: tmp += a cnt += 1 ans += 1 if tmp >= b: break print(ans)
p03799
s080205778
Accepted
import bisect,copy,heapq,itertools,math,string from collections import * import sys def input() : return sys.stdin.readline().strip() def INT() : return int(input()) def MAP() : return map(int,input().split()) def LIST() : return list(MAP()) n, m = MAP() print(min((2*n+m)//4,m//2))
p02756
s800621722
Accepted
from collections import deque s = deque(input()) Q = int(input()) t = True for i in range(Q): query = input().split() if query[0] == '1': t = not t else: if(t and query[1] == '1') or (not t and query[1] == '2'): s.appendleft(query[2]) else: s.append(query[2]) s = ''.join(s) if not t: s = s[::-1] print(s)
p03557
s079997755
Accepted
n=int(input()) a=map(int,input().split()) b=map(int,input().split()) c=map(int,input().split()) a=sorted(a) b=sorted(b) c=sorted(c) import bisect m=0 d=[0 for i in range(n)] for i in range(n): y=bisect.bisect_right(c,b[n-1-i]) m+=n-y d[n-1-i]=m m=0 for i in a: x=bisect.bisect_right(b,i) try : m+=d[x] except IndexError: pass print(m)
p02833
s312780775
Accepted
n = int(input()) if n%2 == 1: print(0) exit() else: cnt = 0 x=1 for i in range(1,26): x=x*5 y=2*x cnt += n//y print(cnt)
p03721
s029165717
Accepted
#!/usr/bin/env python3 N, K = map(int, input().split()) num = {} cnt = 0 for i in range(N): a, b = map(int, input().split()) if a in num: num[a] += b else: num[a] = b for k, v in sorted(num.items()): cnt += v if K <= cnt: print(k) exit()
p02683
s392726064
Accepted
n, m, x = map(int, input().split()) C = [list(map(int, input().split())) for _ in range(n)] import itertools as it import math cost = math.inf for comb in it.chain(*(it.combinations(C, r) for r in range(1, n+1))): c, *a = map(sum, zip(*comb)) if min(a) >= x: cost = min(cost, c) if cost is not math.inf: print(cost) else: print(-1)
p03455
s246098330
Wrong Answer
a, b = input().split() if (int(a) * int(b)) // 2 == 0: print('Even') else: print('Odd')
p02720
s720138662
Wrong Answer
S = int(input()) if S<10: print(S) else: number=9 for i in range(1,2**32): if number==S: print(i-1) break s=str(i) a=0 for j in range(len(s)-1): if abs(int(s[j])-int(s[j+1]))<=1: a=1 break if a==1: number+=1
p03524
s474125381
Accepted
def solve(): s = list(input()) a=s.count('a') b=s.count('b') c=s.count('c') if abs(a-b) <= 1 and abs(b-c) <= 1 and abs(c-a) <= 1: return 'YES' return 'NO' print(solve())
p03493
s176079131
Accepted
print(input().count('1'))
p03469
s420198536
Wrong Answer
s = input() s = '2017' + s[4:] print(s)
p03274
s500957275
Accepted
n,k = map(int, input().split()) x = list(map(int, input().split())) ans = abs(x[k-1]) + 2*abs(x[0]) for i in range (n-k+1): if x[i+k-1] <= 0: ans = min(ans, -x[i]) elif x[i] >= 0: ans = min(ans, x[i+k-1]) else: ans = min(ans, -2*x[i] + x[i+k-1], 2*x[i+k-1] - x[i]) print(ans)
p03319
s825095927
Accepted
n,k = map(int,input().split()) a = list(map(int,input().split())) print((n-3+k)//(k-1))
p03419
s821173372
Accepted
import sys input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(int, input().split()) inl = lambda: list(map(int, input().split())) out = lambda x: print('\n'.join(map(str, x))) n, m = inm() if n == 1 and m == 1: print(1) elif n == 1: print(m-2) elif m == 1: print(n-2) else: print((m-2) * (n-2))
p03455
s670480684
Wrong Answer
a,b = map(int, input().split()) if (a*b) / 2 == 0: print("Even") else : print("Odd")
p03637
s459720246
Accepted
n = int(input()) a_list = list(map(int,input().split())) cntn = 0 cnt2 = 0 cnt4 = 0 for i in a_list: if i%4 == 0: cnt4 += 1 elif i%2 == 0: cnt2 += 1 else: cntn += 1 flag = True if cnt4+ 1 >= cntn : flag = True else: flag = False if cnt2 >= 1: if cnt4 >= cntn : flag = True else: flag = False if flag: print('Yes') else: print('No')
p03723
s065732515
Accepted
a, b, c = map(int, input().split()) counter = 0 while a%2==b%2==c%2==0: a, b, c = (b+c)//2, (a+c)//2, (a+b)//2 counter += 1 if counter > 31: counter = -1 break print(counter)
p03730
s058067130
Accepted
a,b,c=map(int,input().split()) flag=False for i in range(1,b+1): if ( c%b-(a%b)%b )%b == a*i%b: flag=True break if flag: print("YES") else: print("NO")
p02933
s544485610
Wrong Answer
# abc138_a # a>=3200ならSと出力 # a<3200ならredと出力 a = int(input()) if a >= 3200: print('pink') elif a < 3200: print('red')
p03274
s319512927
Accepted
N, K = map(int, input().split()) lst = [int(x) for x in input().split()] ret = 100 ** 100 for i in range(N - K + 1): if lst[i] >= 0 and lst[i + K - 1] >= 0: t = lst[i + K - 1] elif lst[i] < 0 and lst[i + K - 1] < 0: t = abs(lst[i]) else: t = lst[i + K - 1] - lst[i] + min(abs(lst[i]), abs(lst[i + K - 1])) ret = min(ret, t) print(ret)
p02785
s821611686
Wrong Answer
N, K = [int(i) for i in input().split(' ')] H = list(reversed([int(i) for i in input().split(' ')])) print(sum(H[K:]))
p02552
s762215307
Accepted
int_a = int(input()) if int_a == 1: print(0) else: print(1)
p03059
s774378829
Accepted
a, b, c = map(int, input().split()) print(c // a * b)
p03804
s332779252
Accepted
import sys N, M = map(int, input().split()) A = [list(input()) for i in range(N)] B = [list(input()) for i in range(M)] for k in range(N-M+1): for i in range(N-M+1): a = [A[j+k][i:i+M] for j in range(M)] if a == B: print('Yes') sys.exit() print('No')
p03760
s395197197
Accepted
O = input() E = input() lo = len(O) le = len(E) ans = [] for a, b in zip(O, E[:min(le, lo)]): ans.append(a) ans.append(b) if le < lo: ans.append(O[-1]) print("".join(ans))
p02708
s521729721
Accepted
n, k = [int(_) for _ in input().split()] ans = 0 for i in range(k, n+2): ans += (((n + (n-i+1)) * i) / 2) - ((i-1) * i) / 2 + 1 ans = ans % (10**9+7) print(int(ans))
p03998
s713179001
Accepted
def resolve(): A = list(input()) B = list(input()) C = list(input()) A.reverse() B.reverse() C.reverse() d = {"a": A, "b": B, "c": C} turn = "a" while True: if len(d[turn]) == 0: print(turn.upper()) return _next = d[turn].pop() turn = _next if '__main__' == __name__: resolve()