Harryxun/stf_run huggingface dataset:
import sys

for i in sys.stdin:
    lst = i.split(' ')
    n = 1
    while n <= lst[0]:
        lst = map(int, lst)
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
            print lst[0]/n
            break
        n = n+1
    else:
        print 1

### FIXED CODE ###

import sys                                               
for i in sys.stdin:
    lst = i.split(' ')
    lst = map(int, lst)
    lst.sort()

    n = 1
    maxn = 1
    while n*n <= lst[0]:
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
            print lst[0]/n
            break
        elif lst[0]%n == 0 and lst[1]%n == 0:
            maxn = n
        n = n+1
    else:
        print maxn
    sys.exit(0)
N,Q =map(int,input().split())
S = input()
t = [0]* (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2]=='AC' else 0)
for i in range(N):
    l,r =map(int,input().split())
    print(t[r-1]-t[l-1])


### FIXED CODE ###

N,Q =map(int,input().split())
S = input()
t = [0]* (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2]=='AC' else 0)
for i in range(Q):
    l,r =map(int,input().split())
    print(t[r-1]-t[l-1])
#coding:utf-8
n, a, b = map(int, input().split())

if n >= (a+b):
    count = n // (a+b)
    mod = n % (a+b)
    #print(count, mod)
else:
    count = 1
    mod = 0

if mod != 0:
    ball = ('b'* a + 'r'* b) * (count + 1)
else:
    ball = ('b'* a + 'r'* b) * count

ans_ball = ball[:n]

print(ans_ball.count('b'))

### FIXED CODE ###

#coding:utf-8
n, a, b = map(int, input().split())

if a == 0 and b == 0:
    print(0)
    exit()

count = n // (a+b)
mod = n % (a+b)

ans = a * count + min(mod, a)
print(ans)
n=int(input())
s,t=input().split()
a=""
for i , j in (s,t):
  a+=i
  a+=j
print(a)

### FIXED CODE ###

n=int(input())
s,t=input().split()
a=""
for i in range(n):
  a+=s[i]
  a+=t[i]
print(a)
x = int(input((" :"))
print(" ".swapcase)

### FIXED CODE ###

s = input()
print(s.swapcase())
r,D,x=map(int,input().split())

tmp=x
for i in range(10):
  tmp=tmp*r-d
  print(tmp)

### FIXED CODE ###

r,D,x=map(int,input().split())

tmp=x
for i in range(10):
  tmp=tmp*r-D
  print(tmp)
n, m, k = map(int, input().split())
arA = list(map(int, input().split()))
arB = list(map(int, input().split()))

idxA = idxB = 0
readTime :int = 0
readBooks :int = 0

"""
while readTime < k:
    #if arA[idxA] <= arB[idxB] and idxA < n:
    if idxA < n and arA[idxA] <= arB[idxB]:
        if k < readTime + arA[idxA]:
            break
        readTime += arA[idxA]
        idxA += 1
    else:
        if k < readTime + arB[idxB]:
            break
        readTime += arB[idxB]
        idxB += 1
    readBooks += 1
    if idxA >= n and idxB >= m:
        break
"""

while readTime < k:
    if idxA < n and arA[idxA] <= arB[idxB]:
        readTime += arA[idxA]
        idxA += 1
    else:
        readTime += arB[idxB]
        idxB += 1

    if readTime <= k:
        readBooks += 1
    else:
        break
    if idxA >= n and idxB >= m:
        break

print(readBooks)


### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
import sys

args = sys.argv

sum = int(args[0])+int(args[1])+int(args[2])

if sum > 21:
	print(bust)
else:
	print('win')

### FIXED CODE ###

A1,A2,A3=map(int,input().split())
if A1 + A2 + A3 > 21:
	print("bust")
else:
	print("win")
s = input()
t = input()

print('Yes' if ''.join(sorted(s)) < ''.join(sorted(t,reverse=True) else 'No')


### FIXED CODE ###

s = input()
t = input()

ss = ''.join(sorted(s))
tt = ''.join(sorted(t , reverse = True))

if ss < tt:
    print('Yes')
else:
    print('No')
N = int(input())
if N == 1:
    print('Hello World')
else:
    a, b = map(int, input().split())
    print(a + b)


### FIXED CODE ###

N = int(input())
if N == 1:
    print('Hello World')
else:
    a = int(input())
    b = int(input())
    print(a + b)
import itertools
n,m,q=map(int,input().split())
qs = [list(map(int,input().split())) for i in range(q)]
mids = [i for i in range(m)]
# print(nums)
max_ans= 0
for mid in itertools.combinations_with_replacement(nums, n-1):
    if sum(mid)>m-1:
        continue
    sum_ans=0
    for i in qs:
        sum_mid = 0
        for j in range(i[0]-1,i[1]-1):
            sum_mid += mid[j]
        if sum_mid == i[2]:
            sum_ans += i[3]
    if sum_ans > max_ans:
        max_ans = sum_ans
        
print(max_ans)


### FIXED CODE ###

import itertools
n,m,q=map(int,input().split())
qs = [list(map(int,input().split())) for i in range(q)]

max_ans = 0
for mid in itertools.combinations_with_replacement(range(1,m+1), n):
    sum_ans=0
    for q in qs:
        if mid[q[1]-1]-mid[q[0]-1] == q[2]:
            sum_ans += q[3]
    if sum_ans > max_ans:
        max_ans = sum_ans
        
print(max_ans)
n = int(input())
ais = input().split()
ais_sort = sort(ais)
alice = 0
bob = 0
if n % 2 == 0:
  for i in range(n):
    if i % 2 == 1:
      alice += int(ais_sort[i])
    else:
      bob += int(ais_sort[i])
else:
  for j in range(n):
    if i % 2 == 0:
      alice += int(ais_sort[i])
    else:
      bob += int(ais_sort[i])
print(alice - bob)

### FIXED CODE ###

n = int(input())
ais = input().split()
ais_int = [int(a) for a in ais]
ais_sort = ais_int.sort()
alice = 0
bob = 0
if n % 2 == 0:
  for i in range(n):
    if i % 2 == 1:
      alice += int(ais_int[i])
    else:
      bob += int(ais_int[i])
else:
  for j in range(n):
    if j % 2 == 0:
      alice += int(ais_int[j])
    else:
      bob += int(ais_int[j])
print(alice - bob)
a, b, c = map(int, input().split())
print("Yes" if sqrt(a*10000000) + sqrt(b*10000000) < sqrt(c*10000000) else "No")

### FIXED CODE ###

from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No")
a = map(int, input().split())
a.sort()
print(a[0], a[1], a[2])

### FIXED CODE ###

a = list(map(int, input().split()))
a.sort()
print(a[0], a[1], a[2])
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
r=sum(A[0:K])
re=r
for i in range(N-K):
    r=r+A[K+i]-A[i]
    if r > re:
        re=r
        
print((re+K)/2)

### FIXED CODE ###

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

hoge=0
for i in range(K):
    hoge += A[i]

re=hoge
for i in range(N-K):
    hoge=hoge+A[K+i]-A[i]
    if hoge >= re:
        re=hoge
        
print((re+K)/2)
int five = 0;
int seven = 0;

if A == 5:
    five ++
elif A == 7:
        sevent ++

if B == 5:
    five ++
elif B == 7:
        sevent ++

if C == 5:
    five ++
elif C == 7:
        sevent ++

if five == 2 and seven == 1:
    print 'YES'
    else print 'NO'


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
# カウンタのクリア
five_count = 0
seven_count = 0
# 5,7,5を判定
def setsu_check(x):
	global five_count, seven_count
	if x == 5:
		five_count+=1
	elif x == 7:
		seven_count+=1
# 判定関数のCALL
setsu_check(a)
setsu_check(b)
setsu_check(c)
if five_count == 2 and seven_count == 1:
	print("YES")
else:
	print("NO")
N = int(input())
li = list(map(int, input().split()))
ans = dict()
for i in range(len(li)):
    ans[li[i]] = i + 1
ali = []
for j in sorted(ans.keys()):
    ali.append(ans[j])
print(ali.split())



### FIXED CODE ###

N = int(input())
li = list(map(int, input().split()))
ans = dict()
for i in range(len(li)):
    ans[li[i]] = i + 1
ali = []
for j in sorted(ans.keys()):
    ali.append(ans[j])
print(*ali)
W,H,x,y,r = list(map(int,input().split()))
print('YES'if 0 <= x - r <= x + r and 0 <= y - r <= y + r,else'NO')

### FIXED CODE ###

W, H, x, y, r = list(map(int, input().split()))
print('Yes' if 0 <= x - r <= x + r <= W and 0 <= y - r <= y + r <= H else 'No')
a, b = map(int, raw_input().split())
print '%d %d %.6f' % (a/b, a%b, double(a/b))

### FIXED CODE ###

a, b = map(int, raw_input().split())
print '%d %d %f' % (a/b, a%b, float(a)/b)
b = map(int, input().split())
a = b[0] * b[1]
	if a % 2 == 0:
	  print('Even')
	else:
	  print('Odd')

### FIXED CODE ###

a, b = map(int, input().split())
c = int(a * b)
def f(n):
  if n % 2 == 0:
    return 'Even'
  else:
    return 'Odd'
print(f(c))
k,x=map(int.input(),split())
if x <= k :
    print("Yes")
else :
    print("No")


### FIXED CODE ###

k,x = map(int,input().split())
if x <= 500*k :
    print('Yes')
else :
    print('No')
MOD=10**9+7
 
n=int(input())
edge=[[] for _ in range(n)]
for _ in range(n-1):
  p,q = [int(i)-1 for i in input().split()]
  edge[p].append(q)
  edge[q].append(p)

flag=[0]*n

if n==1:
  ans=2
else:
  dp=[[0] * 2 for i in range(n)]
  for i in range(n):
    if len(edge[i])==1:
      dp[i]=[1,1]
      flag[i]=1
    else:
      dp[i]=[0,0]
  dp[0]=[0,0]
  stack = [0]
  while len(stack)!=0:
    term=0
    white=1
    black=1
    for i in range(len(edge[stack[len(stack)-1]])):
      if flag[edge[stack[len(stack)-1]]]==0:
        flag[edge[stack[len(stack)-1]][i]]=1
        stack.append(edge[stack[len(stack)-1]][i])
        term=1
      else:
        sub1=max(1,(dp[edge[stack[len(stack)-1]][i]][0]+dp[edge[stack[len(stack)-1]][i]][0])%MOD)
        sub2=max(1,dp[edge[stack[len(stack)-1]][i]][0])
        white=(white*sub1)%MOD
        black=(black*sub2)%MOD
    if term == 0:
      dp[stack[len(stack)-1]]=[white,black]
      stack.pop()
  
  ans = (dp[0][0]+dp[0][1])%MOD


print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

MOD=10**9+7
 
n=int(input())
edge=[[] for _ in range(n)]
for _ in range(n-1):
  p,q = [int(i)-1 for i in input().split()]
  edge[p].append(q)
  edge[q].append(p)

flag=[0]*n
flag[0]=1
if n==1:
  ans=2
else:
  dp=[[0] * 2 for i in range(n)]
  for i in range(n):
    if len(edge[i])==1:
      dp[i]=[1,1]
      flag[i]=1
    else:
      dp[i]=[0,0]
  dp[0]=[0,0]
  stack = [0]
  while len(stack)!=0:
    term=0
    white=1
    black=1
    length=len(stack)-1
    for i in range(len(edge[stack[length]])):
      if flag[edge[stack[length]][i]]==0:
        flag[edge[stack[length]][i]]=1
        stack.append(edge[stack[length]][i])
        term=1
      else:
        sub1=max(1,(dp[edge[stack[length]][i]][0]+dp[edge[stack[length]][i]][1])%MOD)
        sub2=max(1,dp[edge[stack[length]][i]][0])
        white=(white*sub1)%MOD
        black=(black*sub2)%MOD
    if term == 0:
      dp[stack[length]]=[white,black]
      stack.pop()
  
  ans = (dp[0][0]+dp[0][1])%MOD

print(ans)
import numpy as np
n = int(input())
val = map(int, input().split())
count = 0
val_list = np.array(list(map(int, val.split())))

while True:
    # 偶数の数算出
    even_cnt = len(list(filter(lambda x:x % 2 == 0, val_list)))
    
    # 配列の値の偶数判定
    if n == even_cnt:
        # 配列の割り算
        val_list = val_list/2
        # 上記繰り返しの回数保存
        count += 1
    else:
        break
print(count)

### FIXED CODE ###

import numpy as np
n = int(input())
count = 0
val_list = np.array(list(map(int, input().split())))

while True:
    # 偶数の数算出
    even_cnt = len(list(filter(lambda x:x % 2 == 0, val_list)))
    
    # 配列の値の偶数判定
    if n == even_cnt:
        # 配列の割り算
        val_list = val_list/2
        # 上記繰り返しの回数保存
        count += 1
    else:
        break
print(count)
import numpy as np
N,M=map(int,input().split())
listH=list(map(int,input().split()))
listN=np.zeros((N,N))
for i in range(M):
  A,B=map(int,input().split())
  if listH[A-1]>listH[B-1]:
    listN[A-1][B-1]=A
    listN[B-1][A-1]=A
  if listH[A-1]<listH[B-1]:
    listN[A-1][B-1]=B
    listN[B-1][A-1]=B
  else:
    listN[A-1][B-1]=-1
    listN[B-1][A-1]=-1
ans=0
for i in range(N):
  if len(set(listN[i]))==2 and (i+1 in set(listN[i])):
    ans+=1
  if len(set(listN[i]))==1:
    ans+=1
print(ans)    

### FIXED CODE ###

N,M=map(int,input().split())
listH=list(map(int,input().split()))
listN=[0]*N
for i in range(M):
  A,B=map(int,input().split())
  if listH[A-1]>listH[B-1]:
    listN[B-1]=-1
  if listH[A-1]<listH[B-1]:
    listN[A-1]=-1
  if listH[A-1]==listH[B-1]:
    listN[A-1]=-1
    listN[B-1]=-1   
ans=0    
for i in listN:
  if i>=0:
    ans+=1
print(ans)
ソースコード 

Copy
Copy
from scipy.sparse import *
from itertools import *
 
n,m,r = [int(x) for x in input().split()]
R = [int(i)-1 for i in input().split()]
route_list = [[0]*n for i in range(n)]
ans = 10**9
for j in range(m):
  a,b,c = map(int,input().split())
  route_list[a-1][b-1] = c
  route_list[b-1][a-1] = c
 
Co = csgraph.floyd_warshall(csr_matrix(route_list))
 
for v in permutations(R):
  temp = 0
  for i in range(1,r):
    temp += Co[v[i-1]][v[i]]
  ans = min(ans,temp)
print(int(ans))

### FIXED CODE ###

import math
from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n=len(d[0])
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

N,M,R=[int(x) for x in input().split()]
r=[int(x)-1 for x in input().split()]

route_list=[[10**9]*N for i in range(N)]

for i in range(M):
    a,b,c=[int(x) for x in input().split()]
    route_list[a-1][b-1]=c
    route_list[b-1][a-1]=c

wa_list=warshall_floyd(route_list)
ans=30**9

for perm in permutations(r):
    #print(perm)
    cur = sum(wa_list[v][u] for v, u in zip(perm, perm[1:]))
    ans = min(ans, cur)

print(ans)
n,k=map(int,input().split())
sum=k
tmp=abs(k,0)
for i in range(1,n):
  sum+=k+i
  if tmp>abs(k+i,0):
    tmp=abs(k+i,0)
print(sum-tmp)

### FIXED CODE ###

n,k=map(int,input().split())
sum=k
tmp=k
for i in range(1,n):
  sum+=k+i
  if abs(tmp)>abs(k+i):
    tmp=k+i
print(sum-tmp)
from collections import Counter

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

v1 = v[0::2]
v2 = v[1::2]

c1 = Counter(v1)
c2 = Counter(v2)

c1 = c1.most_common()
c2 = c2.most_common()

if c1[0][0] != c2[0][0]:
    ans = n - c1[0][1] - c2[0][1]
elif c1[0][1] + c2[1][1] >= c2[0][1] + c1[1][1]:
    ans = n - c1[0][1] - c2[1][1]
else:
    ans = n - c2[0][1] - c1[1][1]

print(ans)

### FIXED CODE ###

from collections import Counter

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

v1 = v[0::2]
v2 = v[1::2]

c1 = Counter(v1)
c2 = Counter(v2)

c1 = c1.most_common()
c2 = c2.most_common()

if c1[0][0] != c2[0][0]:
    ans = n - c1[0][1] - c2[0][1]
else:
    if len(c2) > 1:
        choice_1 = c1[0][1] + c2[1][1]
    else:
        choice_1 = c1[0][1]
    if len(c1) > 1:
        choice_2 = c2[0][1] + c1[1][1]
    else:
        choice_2 = c2[0][1]
    ans = n - (max(choice_1, choice_2))

print(ans)
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
import bisect

INF = 1145141919

a = []
dp = []
ans = []
T = []


def dfs(v: int, p: int):
    index = bisect.bisect_left(dp, a[v])
    dp[index], a[v] = a[v], dp[index]

    ans[v] = bisect.bisect_left(dp, INF)

    for u in T[v]:
        if u != p:
            dfs(u, v)

    dp[index], a[v] = a[v], dp[index]


def solve(N: int, tmp_a: "List[int]", tmp_T: "List[List[int]]"):
    global dp, ans, a, T
    dp = [INF] * N
    ans = [0] * N
    a = tmp_a
    T = tmp_T

    dfs(0, -1)

    print("\n".join(map(str, ans)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    T = [[] for _ in range(N)]  # type: "List[List[int]]"
    for i in range(N - 1):
        u = int(next(tokens)) - 1
        v = int(next(tokens)) - 1
        T[u].append(v)
        T[v].append(u)
    solve(N, a, T)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys
import bisect

INF = 1145141919

a = []
dp = []
ans = []
T = []


def dfs(v: int, p: int):
    index = bisect.bisect_left(dp, a[v])
    dp[index], a[v] = a[v], dp[index]

    ans[v] = bisect.bisect_left(dp, INF)

    for u in T[v]:
        if u != p:
            dfs(u, v)

    dp[index], a[v] = a[v], dp[index]


def solve(N: int, tmp_a: "List[int]", tmp_T: "List[List[int]]"):
    sys.setrecursionlimit(10 ** 6)

    global dp, ans, a, T
    dp = [INF] * N
    ans = [0] * N
    a = tmp_a
    T = tmp_T

    dfs(0, -1)

    print("\n".join(map(str, ans)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    T = [[] for _ in range(N)]  # type: "List[List[int]]"
    for i in range(N - 1):
        u = int(next(tokens)) - 1
        v = int(next(tokens)) - 1
        T[u].append(v)
        T[v].append(u)
    solve(N, a, T)


if __name__ == '__main__':
    main()
A,B,C,D = map(int, input().split())
count = 0

#最大公約数
def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a
 #最小公倍数
def lcm(a,b):
    return a*b // gcd(a,b)

def calc_num(n, C, D):
    """
    0~Nまでで、C or Dで割り切れない数の個数
    """
    div_C = n//C
    div_D = n//D
    div_CD = n//(lcm(C, D))
    return n-div_C-div_D+div_CD


def solve():
    A, B, C, D = map(int, input().split())
    return calc_num(B, C, D)-calc_num(A-1, C, D)

print(solve())

### FIXED CODE ###

#最大公約数
def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a
 #最小公倍数
def lcm(a,b):
    return a*b // gcd(a,b)

def calc_num(n, C, D):
    """
    0~Nまでで、C or Dで割り切れない数の個数
    """
    div_C = n//C
    div_D = n//D
    div_CD = n//(lcm(C, D))
    return n-div_C-div_D+div_CD


def solve():
    A, B, C, D = map(int, input().split())
    return calc_num(B, C, D)-calc_num(A-1, C, D)

print(solve())
R, G, B, N = map(int, input().split())

ans = 0
i = 0

while (i * R <= N):
  
  j = 0

  while (i * R + j * G <= N):

    tmp = N - (R * i) - (G * j)
    
    if tmp % B == 0 and tmp >= 0:
      ans += 1
      # print('{},{}'.format(i,j))
    j += 1
  
  i += 1

print('{0}'.format(ans))




### FIXED CODE ###

N, K = map(int, input().split())
ans = 0
for i in range(1, N + 1):
  if i + K - 1 <= N:
    ans += 1
  else:
    break

print('{}'.format(ans))
def f(n):
  if N%2 == 0:
    return n //2
  return 3*n+1

s = int(input())
ans = 1
used = set()
while True:
  if s in used:
    break
  used.add(s)
  ans += 1
  s = f(s)
print(ans)

### FIXED CODE ###

def f(n):
    if n%2 == 0:
        return n //2
    return 3*n+1

s = int(input())
ans = 1
used = set()
# 同じものがでるまで処理を繰り返す
while True:
    if s in used:
        break
    used.add(s)
    ans += 1
    s = f(s)
print(ans)
try:
    result = result2 = count = 0
    while True:
        a, b = map(int, input().split(','))
        result += a*b
        result2 += b
        count += 1
except:
    print(result)
    print((round(result2/count+0.5))

### FIXED CODE ###

try:
    result = result2 = count = 0
    while True:
        a, b = map(int, input().split(','))
        result += a*b
        result2 += b
        count += 1
except:
    print(result)
    print(round(result2/count+0.5))
n=int(input())
a=list(map(int,input().split()))
a.sort()
CNT=[]
cnt=0
for i in range(n-1):
  cnt=0
  for j in range(n-i):
    if a[i+j]-a[i]<2:
      cnt+=1
    else:
      CNT.append(cnt)
      break
print(max(CNT))

  


### FIXED CODE ###

import collections
import sys
n=int(input())
a=list(map(int,input().split()))
b=list(collections.Counter(a).items())
b.sort(key=lambda x:int(x[0]))
if len(b)==1:
  print(n)
  sys.exit()
lst=[]
num=b[0][1]
if int(b[1][0])-int(b[0][0])==1:
  num+=b[1][1]
lst.append(num)
for i in range(1,len(b)-1):
  num=b[i][1]
  if int(b[i+1][0])-int(b[i][0])==1:
    num+=b[i+1][1]
  if int(b[i][0])-int(b[i-1][0])==1:
    num+=b[i-1][1]
  lst.append(num)
num=b[len(b)-1][1]
if int(b[len(b)-1][0])-int(b[len(b)-2][0])==1:
  num+=b[len(b)-2][1]
lst.append(num)
print(max(lst))
n = int(input())
s = [ int(input()) for i in range(n)]
dp = [[0 for _ in range(n+1)] for _ in range(n) ]

for i in range(1, n + 1):
  dp[0][i] = s[0]

for i in range(1, n):
  for  j in range(n + 1):
    if (i == j):
      dp[i][j] = dp[i - 1][j]
    else:
      dp[i][j] = dp[i - 1][j] + s[i]

print(max([it for it in dp[n - 1] if (it % 10 != 0)]))

### FIXED CODE ###

import itertools
n = int(input())
score = [ int(input()) for _ in range(n)]
cnt = max([sum(c) if sum(c) % 10 != 0 else 0 for i in sorted(range(n-1, n+1)) for c in itertools.combinations(score, i)])
print(cnt)
N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(min(l), max(l)):
  ans=0
  for i in range(N):
    ans += (l[i] - j)**2
  k.append(ans)
print(min(k))

### FIXED CODE ###

N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(101):
  ans=0
  for i in range(N):
    ans += (l[i] - j)**2
  k.append(ans)
print(min(k))
#奇数だったら左にずらす。
#左にずらせないのであれば、下にずらす
h, w = map(int, input().split())
grid = []
ans = []
for i in range(h):
    grid.append(list(map(int, input().split())))
for i in range(h):
    for j in range(w):
        if grid[i][j] % 2 != 0:
            if j == w - 1 and i != h - 1:
                ans.append([i+1,j+1,i+2,j+1])
                grid[i+1][j] += 1
            else:
                ans.append([i+1,j+1,i+1,j+2])
                grid[i][j+1] += 1
n = len(ans)
print(n)
for i in ans:
    print("{} {} {} {}".format(i[0], i[1],i[2],i[3]))


### FIXED CODE ###

#奇数だったら左にずらす。
#左にずらせないのであれば、下にずらす
h, w = map(int, input().split())
grid = []
ans = []
for i in range(h):
    grid.append(list(map(int, input().split())))
for i in range(h):
    for j in range(w):
        if grid[i][j] % 2 != 0:
            if j == w - 1:
                if i != h - 1:
                    ans.append([i+1,j+1,i+2,j+1])
                    grid[i+1][j] += 1
            else:
                ans.append([i+1,j+1,i+1,j+2])
                grid[i][j+1] += 1
n = len(ans)
print(n)
for i in ans:
    print("{} {} {} {}".format(i[0], i[1],i[2],i[3]))
n,m = map(int,input().split())
ans = [0]*n
miss = [0]*n

for _ in range(m+1):
    p,s = map(str,input().split())
    p = int(p)
#    print(p,s)
    if ans[p-1] == 0 and s == "WA":
        miss[p-1] += 1
    elif ans[p-1] == 0 and s == "AC":
        ans[p-1] += 1
    else:
        pass

#print(ans)
#print(miss)
a = sum(ans)
b = sum(miss)

print(a,b)


### FIXED CODE ###


n, m = map(int, input().split())
bool_lst = [False] * n
ac_lst = [0] * n
wa_lst = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if bool_lst[p] == False:
        if s == 'AC':
            bool_lst[p] = True
            ac_lst[p] += 1
        else:
            wa_lst[p] += 1

ac_cnt = 0
wa_cnt = 0
for i in range(n):
    if bool_lst[i] == True:
        ac_cnt += ac_lst[i]
        wa_cnt += wa_lst[i]

print(ac_cnt, wa_cnt)
n = int(input())

for i in range(1, n**.5+1):
  if n%i == 0:
    p = i

q = n//p

print(p+q-2)

### FIXED CODE ###

n = int(input())

for i in range(1, int(n**.5)+1):
  if n%i == 0:
    p = i

q = n//p

print(p+q-2)
while True:
    m, f, r = [int(i) for i in input().solit()]

    if m == f == r == -1:
        break

    if m == -1 or f == -1:
        print("F")

    if m + f >= 80:
        print("A")

    if 65 <= m + f < 80:
        print("B")

    if 50 <= m + f < 65:
        print("C")

    if 30 <= m + f < 50:
        print("D")

    elif 30 <= m + f < 50 and r >= 50:
        print("C")

    if m + f < 30:
        print("F")

### FIXED CODE ###

while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    elif m == -1 or f == -1:
        print("F")

    elif m + f >= 80:
        print("A")

    elif 65 <= m + f < 80:
        print("B")

    elif 50 <= m + f < 65:
        print("C")

    elif 30 <= m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")

    elif m + f < 30:
        print("F")

    elif m + f < 30:
        print("F")