problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03073
s171188629
Accepted
s=input() a=0 b=0 for i in range(len(s)): if i%2==0: if s[i]!="0": a+=1 else: if s[i]!="1": a+=1 for i in range(len(s)): if i%2==1: if s[i]!="0": b+=1 else: if s[i]!="1": b+=1 print(min(a,b))
p02730
s266513107
Wrong Answer
S = input() N = len(S)#7 a = 0 f = (N-1)//2 for i in range(f): if S[i] !=S[f-i-1]: a = 1 b = 0 for j in range((N+3)//2-1,N): b += 1 if S[j] != S[N-b]: a = 1 if a == 0: print("Yes") else: print("No")
p03206
s977707184
Wrong Answer
x=int(input()) out="Christmas" for i in range(x-25): out+=" Eve" print(out)
p04005
s391062461
Accepted
A, B, C = map(int, input().split()) if A % 2 == 0 or B % 2 == 0 or C % 2 ==0: print(0) else: print(min(A*B, B*C, C*A))
p02823
s077250016
Accepted
n,a,b=map(int,input().split()) if (b-a)%2==0: print((b-a)//2) else: c=(a-1)+(b-a+1)//2 d=(n-b)+(b-a+1)//2 print(min(c,d))
p03486
s985255858
Wrong Answer
s = input() s_n = ''.join(sorted(s)) t = input() t_n = ''.join(sorted(t,reverse = True)) if s_n > t_n: print('No') else: print('Yes')
p02572
s635351320
Accepted
n,*a=map(int,open(0).read().split()) b=sum(map(lambda x:x*x,a)) mod=10**9+7 ans=(sum(a)**2-b)//2 print(ans%mod)
p02768
s795570768
Wrong Answer
from functools import reduce n,a,b = [int(i) for i in input().split()] mod = 10**9 + 7 total = (2**n -1)%mod def f(A): num = reduce(lambda x, y: x * y % mod, range(n, n - a, -1)) den = reduce(lambda x, y: x * y % mod, range(1, a + 1)) return num * pow(den, mod - 2, mod) % mod print((total - f(a) - f(b))%mod)
p02831
s480199771
Wrong Answer
def actual(a, b): multiple_a_set = set() multiple_b_set = set() for i in range(2, 10 ** 5 + 1): if i % a == 0: multiple_a_set.add(i) if i % b == 0: multiple_b_set.add(i) if multiple_a_set & multiple_b_set: return min(multiple_a_set & multiple_b_set) # 共通の倍数を持たない場合は、積が最小公倍数 return a * b a, b = map(int, input().split()) print(actual(a, b))
p02772
s797764605
Accepted
n = int(input()) A = list(map(int, input().split())) for i in A: if i % 2 == 0: if i % 3 != 0 and i % 5 != 0: print('DENIED') exit() print('APPROVED')
p03030
s605938214
Accepted
n = int(input()) list_res = [] for i in range(0, n): s, p = input().split() list_res.append([s, int(p), i + 1]) list_res_point = sorted(list_res, key=lambda x: (x[1]), reverse=True) list_ans = sorted(list_res_point, key=lambda x: (x[0])) for i in range(0, n): print(list_ans[i][2])
p02843
s942664030
Accepted
X = int(input()) dp = [True] + [False] * (X) if X < 106: if 100 <= X <= 105: print(1) exit() else: print(0) exit() # 100~105円はyes for i in range(100,106): dp[i] = True for i in range(106,X+1): for j in range(100,106): if dp[i-j] == True: dp[i] = True break print(1 if dp[X] == True else 0)
p03665
s727980150
Accepted
from math import factorial def f(a, b): if a == 0 or b == 0: return 1 else: return factorial(a) // (factorial(a - b) * factorial(b)) n, p = map(int, input().split()) a = [int(x) % 2 for x in input().split()] e, o = a.count(0), a.count(1) if p == 0: print((2**e)*sum([f(o, i) for i in range(0, o+1, 2)])) else: print((2**e)*sum([f(o, i) for i in range(1, o+1, 2)]))
p03730
s219331301
Wrong Answer
a,b,c=map(int,input().split()) x = a%b f = False for i in range(1,b): if x*i == c: f = True print("Yes" if f is True else "No")
p03323
s067982534
Accepted
A, B = map(int, input().split()) if A <= 8 and B <= 8: print('Yay!') else: print(':(')
p02702
s253943724
Accepted
def main(): from collections import Counter s = input() l = [0] t = 1 for i, x in enumerate(s[::-1]): t = t * 10 % 2019 y = (l[-1] + int(x) * t) % 2019 l.append(y) c = Counter(l) ans = sum([v * (v - 1) // 2 for v in c.values()]) print(ans) if __name__ == '__main__': main()
p02982
s582369359
Accepted
import math n, d = map(int, input().split()) x = [] ans = [i**2 for i in range(1, (n*d)**2)] for i in range(n): tmp = list(map(int, input().split())) x.append(tmp) cnt = 0 sum_t = 0 for i in range(n): for j in range(i+1, n): sum_t = 0 for k in range(d): sum_t += (x[i][k]-x[j][k])**2 if sum_t in ans: cnt += 1 print(cnt)
p02951
s105738590
Accepted
A,B,C=map(int,input().split()) x=C-A+B if x<0: print(0) else: print(x)
p02780
s715251115
Accepted
n,k=map(int,input().split()) p=list(map(int,input().split())) maxim=[0]*(n-k+1) cnt=0 s=0 for i in range(n): cnt+=1 s+=p[i] if cnt==k: maxim[i-(k-1)]=s cnt=k-1 s+=-p[i-(k-1)] ans=(max(maxim)+k)/2 print(ans)
p02696
s868465129
Accepted
import sys input = sys.stdin.readline def main(): A, B, N = map(int, input().split()) x = min(B-1, N) ans = int(A*x/B) - A*int(x/B) print(ans) if __name__ == "__main__": main()
p02612
s704818940
Accepted
n=int(input()) if n%1000!=0: print(1000-n%1000) else: print(0)
p03239
s779767393
Accepted
n, T = list(map(int, input().split())) ans = 1001 for _ in range(n): c, t = list(map(int, input().split())) if t <= T: ans = min(ans, c) if ans == 1001: print('TLE') else: print(ans)
p03250
s990918359
Accepted
import sys def input(): return sys.stdin.readline()[:-1] a,b,t = map(int,input().split(' ')) S = a+b+t M = max(a,b,t) print(M*10+(S-M))
p02554
s445662609
Wrong Answer
m=10**9+7 n=int(input()) a=(8**n)%m b=(9**n)%m c=(10**n)%m print((2*b-c+a)%m)
p03493
s531872456
Accepted
s = input() print(len([i for i in s if i == '1']))
p02802
s684652934
Accepted
# coding: utf-8 N, M = map(int, input().split()) AC, WA = [], [] AC = [False for _ in range(10**5)] WA = [0 for _ in range(10**5)] ac, wa = 0, 0 for i in range(M): tmp = input().split() p = int(tmp[0]) - 1 s = tmp[1] if AC[p]: continue else: if s == "AC": AC[p] = True else: WA[p] += 1 for i in range(N): if AC[i]: ac += 1 wa += WA[i] print(ac, wa)
p02677
s741435401
Wrong Answer
import math A, B, H, M = map(int, input().split()) A_rad = (360/12)*H + ((360/12)/60)*M B_rad = (360/60)*M if A_rad > B_rad: rad_dif = A_rad -B_rad else: rad_dif = B_rad if rad_dif > 180: rad_dif = 360 - rad_dif ans = math.sqrt(A*A + B*B -2*A*B*math.cos(math.radians(rad_dif))) print('%20.20Lf' %ans)
p03474
s150510345
Accepted
def solve(): A, B = map(int, input().split()) S = input() if S[:A].isdigit() and S[A] == '-' and S[A+1:].isdigit(): print('Yes') else: print('No') if __name__ == "__main__": solve()
p03821
s065297373
Wrong Answer
n=int(input()) ab=[map(int,input().split()) for _ in range(n)] a,b = [list(i) for i in zip(*ab)] s=0 for i in range(n): if a[n-1-i]%b[n-1-i]==0: continue else: c=b[n-1-i]-((a[n-1-i]+s)%b[n-1-i]) s+=c print(s)
p04044
s125615508
Accepted
H, W = map(int, input().split()) S = [] for _ in range(H): S.append(input()) S.sort() #print(S) S_out='' for ii in S: S_out += ii print(S_out)
p02682
s308164084
Wrong Answer
A,B,C,K = map(int,input().split()) sum_ = 0 sum_ += min(A,K) K = max(K-A,0) if K > 0: K = min(K-B,0) if K > 0: sum_ -= min(K) print(sum_)
p03657
s963408587
Accepted
a,b=map(int,input().split()) if a%3==0 or b%3==0 or (a+b)%3==0: print("Possible") else: print("Impossible")
p03696
s203488552
Accepted
n=int(input()) s=input() a=0 l=0 for i in range(n): if s[i]=='(': a+=1 else: a-=1 if a<0: l+=1 a+=1 print('('*l+s+')'*a)
p02727
s068413995
Wrong Answer
X,Y,A,B,C=map(int,input().split()) P=sorted(list(map(int,input().split()))) Q=sorted(list(map(int,input().split()))) R=sorted(list(map(int,input().split()))) S=sorted(P[A-X:]+Q[B-Y:]) i=0 while S[i]<R[-1-i]: if len(R)>i or len(S)>i: break i+=1 print(sum(S[i+1:])+sum(R[-1-i:]))
p02916
s555264463
Wrong Answer
n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) ans=b[a[0]-1] for i in range(1,n): ans+=b[a[i]-1] if a[i]==a[i-1]+1: ans+=c[i-2] print(ans)
p02624
s301317118
Accepted
n = int(input()) print(sum(n//i * (n//i+1) // 2 * i for i in range(1, n+1)))
p02789
s743818243
Accepted
N, M = map(int, input().split()) print("Yes" if N == M else "No")
p03000
s992691106
Wrong Answer
n, x = map(int,input().split()) l = list(map(int,input().split())) i, d = 0, 0 while i<n and d < x: d += l[i] i += 1 print(i)
p02665
s743685044
Accepted
n = int(input()) a = list(map(int,input().split())) b = [0 for i in range(n+1)] leaf = sum(a) if n == 0 and a[0] != 1: print(-1) exit() b[0] = 1 - a[0] leaf -= a[0] ans = 1 for i in range(1,n+1): kosu = min(b[i-1] * 2,leaf) ans += kosu b[i] = kosu - a[i] if b[i] < 0: print(-1) exit() leaf -= a[i] print(ans)
p02909
s484873028
Wrong Answer
S = input() W = ["Sunny","Cloudy","Rainy"] print(W.index(S)+1 % 3)
p02832
s443136228
Accepted
N = int(input()) An = list(map(int, input().split())) done = 0 for i in An: if done+1 == i: done = i if done == 0: print(-1) else: print(N-done)
p02708
s695653019
Accepted
from sys import stdin input = stdin.readline def main(): N, K = list(map(int, input().split())) sum_ = 0 for k in range(K, N+2): sum_ += (k*(N-k+1)+1) print(sum_ % 1_000_000_007) if(__name__ == '__main__'): main()
p03043
s294327440
Wrong Answer
N, K = map(int, input().split()) ans = 0 for i in range(1, N + 1): tmp = 1 / N now = i while now <= K: now *= 2 tmp *= 1 / 2 ans += tmp print(ans)
p03163
s667301334
Accepted
n,w = map(int,input().split()) ww = [0]*n vv = [0]*n dp = [[0]*(w+1) for _ in range(n+1)] for i in range(n): ww[i],vv[i] = map(int,input().split()) for i in range(1,n+1): for j in range(1,w+1): dp[i][j] = dp[i-1][j] if j - ww[i-1] >= 0: dp[i][j] = max(dp[i][j], \ dp[i-1][j-ww[i-1]] + vv[i-1]) print(dp[-1][-1])
p02571
s607174622
Accepted
S = input() T = input() d = len(S) - len(T) print(len(T) - max(sum(t == s for t, s in zip(T, S[i : i + len(T) + 1])) for i in range(d + 1)))
p02687
s167534208
Wrong Answer
print('A%sC'%'BR'[id(id)%9%2])
p02595
s991760873
Wrong Answer
import math n,d=map(int,input().split()) c=0 for i in range(n): x,y=map(int,input().split()) res=math.floor(math.sqrt((x**2+y**2))) print(res) if(res<=d): c+=1 print(c)
p02603
s850686107
Wrong Answer
N = int(input()) A = list(map(int, input().split())) max_index = [i for i, x in enumerate(A) if x == max(A)] stopbuy = max_index[-1] money = 1000 stock = 0 for i in range(stopbuy): if A[i+1] > A[i]: stock = money // A[i] money = money % A[i] else: # A[i+1] <= A[i] money = money + A[i] * stock stock = 0 money = money + A[stopbuy] * stock print(money)
p02963
s498292449
Wrong Answer
S=int(input()) #S=x1y2-x2y1 #S+x2y1=x1y2 #S+y1=10**9y2 (x1=10**9, x2=1) Y1=S%(10**9) Y2=S//(10**9) print(10**9,Y1,1,Y2,0,0)
p02694
s511353599
Wrong Answer
# 1% import math N = int(input()) x = 100 ans = 0 while x < N: x += math.floor(x /100) ans += 1 print(ans)
p03289
s731195851
Accepted
S = list(map(str, input())) flg = 1 if S[0] != "A": flg = 0 ctr = 0 for i in range(2, len(S) - 1): if S[i] == "C": ctr += 1 if ctr != 1: flg = 0 ctr = 0 for s in S: if ord(s) <= 90: ctr += 1 if ctr != 2: flg = 0 if flg: print("AC") else: print("WA")
p03680
s816682054
Accepted
N=int(input()) mylist=[] j=0 n=0 for i in range(N): mylist.append(int(input())) for i in range(N): if n==1: print(j) break j=j+1 n=mylist[n]-1 if i==N-1: print("-1")
p03071
s843891320
Accepted
a,b=[int(x) for x in input().split()] ans=max(a+b,2*a-1,2*b-1) print(ans)
p02657
s390979577
Wrong Answer
a, b = input().split() print(int(round(int(a)*float(b)-0.5,0)))
p03633
s954540295
Accepted
import fractions n=int(input()) a=1 for i in range(n): b=int(input()) a=a*b//fractions.gcd(a,b) print(a)
p03163
s679126144
Wrong Answer
from numpy import * N,W=map(int,input().split()) dp=zeros(W+1) for i in range(N): w,v=map(int,input().split()) dp[w:]=maximum(dp[:-w]+v,dp[w:]) print(dp[-1])
p03448
s523578345
Accepted
A = int(input()) B = int(input()) C = int(input()) X = int(input()) N=0 for i in range(A+1): for j in range(B+1): for k in range(C+1): if i*500+j*100+k*50==X: N+=1 print(N)
p02791
s848039052
Accepted
def main(): N = int(input()) P = list(map(int, input().split())) ans = 0 tmp = N + 1 for p in P: if tmp > p: ans += 1 tmp = p print(ans) if __name__ == "__main__": main()
p03681
s233414069
Accepted
import math n, m = map(int, input().split()) mod = 10 ** 9 + 7 if n == m: res = 2 * math.factorial(n) * math.factorial(m) print(res % mod) elif abs(n - m) == 1: res = math.factorial(n) * math.factorial(m) print(res % mod) else: print(0)
p04043
s559774508
Wrong Answer
ABC = input().split() print('YES' if ABC.count('5') == 2 and ABC.count('7') ==1 else 'N0')
p03427
s966369784
Accepted
n = list(input()) if n[0] != '9': if n.count('9') != len(n)-1: n[0] = str(int(n[0])-1) for i in range(1, len(n)): n[i] = '9' else: for i in range(len(n)-1): if n[i+1] != '9': n[i] = str(int(n[i])-1) for j in range(i+1, len(n)): n[j] = '9' ans = 0 for i in range(len(n)): ans += int(n[i]) print(ans)
p03274
s589659891
Wrong Answer
N, K = map(int, input().split()) x = list(map(int, input().split())) ans = float('inf') for l in range(K): r = l + K - 1 if l>=N-1 or r>=N-1: continue tmp_1 = abs(x[l]) + abs(x[r]-x[l]) tmp_2 = abs(x[r]) + abs(x[r]-x[l]) tmp = min(tmp_1,tmp_2) ans = min(ans,tmp) print(ans)
p03494
s262350577
Accepted
n = int(input()) listA = list(map(int, input().split())) count = 0 isBroken = False while True: for i in range(n): if listA[i] % 2 == 0: listA[i] //= 2 else: isBroken = True break if isBroken: break else: count += 1 print(count)
p04031
s731587753
Accepted
from math import * n=int(input()) l=list(map(int,input().split())) s=ceil(sum(l)/n) ss=s-1 c=0 x=0 for i in range(n): c+=(s-l[i])**2 for i in range(n): x+=(ss-l[i])**2 print(min(c,x))
p03657
s647940288
Wrong Answer
a,b=map(int,input().split()) if (a+b)%3==0: print("Possible") else: print("Imposible")
p02732
s725091816
Wrong Answer
import collections n = int(input()) a = list(map(int,input().split())) c = collections.Counter(a) comon = c.most_common() ans = 0 for i in comon: if i[1] != 1: ans += (i[1]*(i[1]-1)//2) for i in a: for j in comon: if i == j[0]: co = j[1] break if co == 1: print(0) else: print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))
p02879
s550572993
Accepted
a, b = map(int, input().split()) if max(a,b)<=9: print(a*b) else: print(-1)
p03407
s151415973
Accepted
a, b, c = map(int, input().split()) if a + b < c: print('No') else: print('Yes')
p03331
s971224077
Wrong Answer
n=int(input()) ans=10e6 for a in range(2,n+1): b=n-a ans=min(ans,sum([int(i) for i in str(a)])+sum([int(i) for i in str(b)])) print(ans)
p03645
s418452128
Accepted
#coding: utf-8 import math import heapq import bisect import numpy as np from collections import Counter #from scipy.misc import comb N,M = map(int, input().split()) A = [] B = [] for _ in range(M): a,b = map(int, input().split()) if a == 1: A.append(b) elif b == N: B.append(a) B.sort() for a in A: if bisect.bisect_left(B, a) < len(B) and B[bisect.bisect_left(B, a)]==a: print("POSSIBLE") exit() print("IMPOSSIBLE")
p02790
s045834480
Accepted
a, b = map(int, input().split()) if a > b: print(str(b)*a) else: print(str(a)*b)
p03087
s672892289
Accepted
n,q=map(int,input().split()) s=input() cnt=[0]*n for i in range(1,n): if s[i-1]=='A' and s[i]=='C': cnt[i]=cnt[i-1]+1 else: cnt[i]=cnt[i-1] for _ in range(q): l,r=map(int,input().split()) print(cnt[r-1]-cnt[l-1])
p03434
s737897934
Wrong Answer
N = int(input()) a_list = list(map(int, input().split())) a_list.sort(reverse=True) Alice = 0 Bob = 0 print(a_list) for i in range(len(a_list)): if i % 2 == 0: Alice += a_list[i] else: Bob += a_list[i] print(Alice-Bob)
p03250
s795865103
Accepted
A,B,C = sorted(list(map(int,input().split()))) print(A+B+C*10)
p03469
s834437025
Accepted
s=input();print(s[:3]+'8'+s[4:])
p02785
s297660682
Accepted
N,K=map(int,input().split()) H=sorted(list(map(int,input().split())),reverse=True) if N<K:K=N for i in range(K):H[i]=0 print(sum(H))
p03073
s469815396
Accepted
S = input() n = S[::2].count("0") + S[1::2].count("1") print(min(n, len(S) - n))
p03471
s228411056
Wrong Answer
N,Y = map(int,input().split()) x = 0 y = 0 z = 0 flag = False for i in range(N+1): for j in range(N+1): if int((Y-10000*i-5000*j)/1000) == N-i-j: x = i y = j z = N-i-j flag = True break break if flag == False: print(-1,-1,-1) else: print(x,y,z)
p03557
s310490129
Accepted
import bisect N = int(input()) A_list = sorted(list(map(int,input().split()))) B_list = sorted(list(map(int,input().split()))) C_list = sorted(list(map(int,input().split()))) ans = 0 for B in B_list: a_cnt = bisect.bisect_left(A_list,B) c_cnt = len(C_list) - bisect.bisect_right(C_list,B) ans += a_cnt * c_cnt print(ans)
p03645
s059880950
Wrong Answer
import collections [n,m] = [int(i) for i in input().split()] dic = collections.defaultdict(int) for i in range(m): [a,b] = [int(j)-1 for j in input().split()] if a == 0: dic[b] += 1 elif b == 0: dic[a] += 1 if max(dic.values()) >= 2: print("POSSIBLE") else: print("IMPOSSIBLE")
p02756
s804342480
Wrong Answer
S=input() Q=int(input()) A= [input().split() for i in range(Q)] from collections import deque ans = deque() tmp=0 ans.append(S) for li in A: if li[0]=='1': tmp=(tmp+1)%2 else: if (tmp+int(li[1]))%2 == 1: ans.appendleft(li[2]) else: ans.append(li[2]) if tmp == 0: re=map(str, list(ans)) print(''.join(re)) else: re=map(str, list(ans)[::-1]) print(''.join(re))
p03605
s928996438
Wrong Answer
N=int(input()) if N%10==9 or N%10==9: print("Yes") else: print("No")
p03038
s771138157
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) a = [] for i in range(M): b = list(map(int, input().split())) a.append(b) from operator import itemgetter A.sort() a.sort(key = itemgetter(1)) count = 0 for i in range(N): if A[i] < a[-1-count][1]: A[i] = a[-1-count][1] a[-1-count][0] -= 1 if a[-1-count][0] == 0: count += 1 if count == M: break print(sum(A))
p03456
s514681032
Wrong Answer
def main(): a, b = input().split() a += b n = int(a) for i in range(1, 101): if i * i == n: print("Yes") exit() print("No") if __name__ == "__main__": main()
p04005
s070574330
Wrong Answer
a,b,c=map(int,input().split()) for i in [a,b,c]: if i%2==0: print(0) break else: s=a*b*c/max(a,b,c) print(int(s))
p03487
s159830595
Accepted
from collections import Counter n = int(input()) a = list(map(int,input().split())) ans = 0 c = Counter(a) for k,v in c.items(): if k<v: ans+=v-k elif k>v: ans+=v print(ans)
p02987
s039429472
Accepted
S = input() import collections S_list = list(S) c = collections.Counter(S_list) if min(c.values()) == 2 and len(c.keys()) == 2: print("Yes") else: print("No")
p02888
s495127218
Accepted
N = int(input()) l = list(map(int,input().split())) l.sort() ans = 0 for i in range(N-2): for j in range(i+1,N-1): s = l[i]+l[j] start = j+1 end = N while start != end: center = (start + end)//2 if s <= l[center]: end = center else: start = center + 1 ans += end-j-1 print(ans)
p02658
s432991598
Accepted
n=int(input()) a=list(map(int,input().split())) x=10**18 ans=1 for num in a: ans*=num if ans>x: ans=-1 break if 0 in a: ans=0 print(ans)
p03037
s675296374
Wrong Answer
n,m = map(int,input().split()) l_max=0 r_min=10**5 for i in range(m): l,r = map(int,input().split()) l_max = max(l_max,l) r_min = min(r_min,r) print(r_min - l_max + 1)
p03073
s233870809
Accepted
s = input() #奇数が1 countA = 0 for i in range(len(s)): if i%2==0 and s[i]=="0": countA += 1 elif i%2==1 and s[i]=="1": countA += 1 #偶数が1 countB = 0 for i in range(len(s)): if i%2==0 and s[i]=="1": countB += 1 elif i%2==1 and s[i]=="0": countB += 1 print(min(countA,countB))
p03281
s480956652
Accepted
n = int(input()) ans = 0 for i in range(1, n+1): stock = 0 for j in range(1, n+1): if i % j == 0: stock += 1 if stock == 8 and i % 2: ans += 1 print(ans)
p02753
s239267979
Accepted
def main(): S=input() if S=="AAA" or S=="BBB": print("No") else: print("Yes") if __name__ == '__main__': main()
p02859
s529931392
Accepted
print(int(input())**2)
p02645
s759310591
Wrong Answer
s = input() print(s[0:2])
p02760
s698274255
Accepted
import numpy as np card = np.array([list(map(int, input().split())) for _ in range(3)], dtype=np.int64) n = int(input()) for _ in range(n): num = int(input()) card[card == num] = 0 card = card == 0 def check_vertical(card): return np.all(card, axis=0).sum() >= 1 def check_horizon(card): return np.all(card, axis=1).sum() >= 1 def check_diagonal(card): check1 = np.diag(card).sum() check2 = np.diag(np.fliplr(card)).sum() return check1 == 3 or check2 == 3 if check_vertical(card) or check_horizon(card) or check_diagonal(card): print('Yes') else: print('No')
p02848
s632894021
Accepted
n = int(input()) s = input() ans ='' for i in s: ans += chr((ord(i)-65+n)%26+65) print(ans)
p02607
s128903792
Accepted
N=int(input()) a = list(map(int,input().split())) ans = 0 for i in range(N): if (i+1) % 2 and a[i] % 2: ans += 1 print(ans)
p02775
s979690012
Accepted
s = '0' + input() m = len(s) up = 0 cnt = 0 y = [] for i in range(-1, -m-1, -1): cs = int(s[i]) + up if cs < 5 or (cs == 5 and int(s[i-1]) < 5): cnt += cs y.append([cs, s[i]]) up = 0 else: cnt += 10 - cs y.append([10 - cs, s[i]]) up = 1 print(cnt)
p02982
s259710737
Accepted
n,d=map(int,input().split()) x=[list(map(int,input().split())) for _ in range(n)] cnt=0 for i in range(n): for j in range(i+1,n): dist=0 for k in range(d): dist+=(abs(x[i][k]-x[j][k])**2) for l in range(int(dist**.5)+1): if dist==l**2: cnt+=1 print(cnt)