Harryxun/stf_run huggingface dataset:
n = int(input())
words = [input() for _ in range(n)]
print("Yes" if all([y[0] == x[-1] for x, y in zip(words, words[1:]) and len(set(words)) == n else "No")

### FIXED CODE ###

n = int(input())

words = [input() for _ in range(n)]

spoken = {words[0]}

for x, y in zip(words, words[1:]):
    if y[0] != x[-1]:
        print("No")
        exit()
    if y in spoken:
        print("No")
        exit()
    spoken.add(y)
else:
    print("Yes")
import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
wv = [[0,0]]
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = max(dp[n-1][w:W+1], dp[n-1][W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])


### FIXED CODE ###

import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = np.maximum(dp[n-1][w:W+1], dp[n-1][:W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])
N=int(input())
A=[input() for i in range(N)]
B=[]
while len(A)!=0:
  if A[0] not in B:
    B.append(A[0])
  A.popleft()
print(len(B))

### FIXED CODE ###

N=int(input())
A=[int(input()) for i in range(N)]
B=[]
while len(A)!=0:
  if A[0] not in B:
    B.append(A[0])
  A.pop(0)
print(len(B))
a,b = map(int,input().split())
print("<" if ord(b) > ord(a) else ">")

### FIXED CODE ###

a,b = map(str,input().split())
if ord(a) == ord(b):
  print("=")
elif ord(a) > ord(b):
  print(">")
else:
  print("<")
import sys

from scipy.special import comb

#import numpy as np

n = int(input())

a = [int(i) for i in input().split()]

num = [[-1,0,0]]*(200000)

asort = sorted(a)

#print(asort)

sum = 0
i = 0
while i < n-1:
    counter = 1
    index = asort[i]
    while  i < n-1 and asort[i] == asort[i+1]:
        #print("yes")
        counter +=1
        i+=1
    #print("no")
    i+=1
    num[index] = [counter,comb(counter,2),comb(counter-1,2)]
    sum+=num[index][1]




for i in a:
    print(int(sum-num[i][1]+num[i][2]))


### FIXED CODE ###

import sys

#from scipy.misc import comb #scipy.special

#import numpy as np

def choose(n):
    return n*(n-1)/2

n = int(input())

a = [int(i) for i in input().split()]

bunpu = [0]*(n+1)

for i in range(len(a)):
    bunpu[a[i]]+=1


sum = 0
for i in bunpu:
    sum+=choose(i)
i = 0
for i in a:
    print(int(sum-choose(bunpu[i])+choose(bunpu[i]-1)))
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass

n = i()
a = intl()
if n == 1:print(0)
else:
    s = max(a)+min(a)
    k1 = s//2
    k2 = s//2 + s%2
    k3 = s//2 -1
    c1 = 0
    c2 = 0
    c3 = 0
    for i in range(n):
        c3 += (a[i]-k3)**2
        c2 += (a[i]-k2)**2
        c1 += (a[i]-k1)**2
    print(min(c1,c2,c3))

### FIXED CODE ###

import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass

n = i()
a = [i for i in range(1,n+1)]
print(sum(a))
import bisect
import sys
sys.setrecursionlimit(10**8)


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

edges = [[] for _ in range(n)]
for _ in range(n-1):
    from_, to = map(int, input().split())
    edges[from_-1].append(to-1)
    edges[to-1].append(from_-1)


DP = [10**9+7] * n
DP[0] = 0
ans = [0] * n


def dfs(node):
    node = node
    num = A[node]
    update_idx = bisect.bisect_left(DP, num)
    prev = DP[update_idx]
    DP[update_idx] = num
    lis = bisect.bisect_left(DP, 10**9+1) - 1
    ans[node] = lis
    for to in edges[node]:
        if not ans[to]:
            dfs(to)

    DP[update_idx] = prev


dfs(0)
for res in ans:
    print(res)


### FIXED CODE ###

import bisect
import sys
sys.setrecursionlimit(10**8)


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

edges = [[] for _ in range(n)]
for _ in range(n-1):
    from_, to = map(int, input().split())
    edges[from_-1].append(to-1)
    edges[to-1].append(from_-1)


DP = [10**9+7] * (n+1)
DP[0] = 0
ans = [0] * n


def dfs(node):
    node = node
    num = A[node]
    update_idx = bisect.bisect_left(DP, num)
    prev = DP[update_idx]
    DP[update_idx] = num
    lis = bisect.bisect_left(DP, 10**9+1) - 1
    ans[node] = lis
    for nex in edges[node]:
        if not ans[nex]:
            dfs(nex)

    DP[update_idx] = prev


dfs(0)
for res in ans:
    print(res)
D, G = map(int, input().split())
PC = [list(map(int,input().split())) for i in range(D)]

PC1 = [[0,0,0,0]]*D
for i in range(D):
  PC1[i] = [((i+1)*100*PC[i][0]+PC[i][1])/PC[i][0], PC[i][0], (i+1)*100, PC[i][1]]

count = 0
for j in range(D):
  count += PC[j][0]
  
PC1.sort()
accum = 0
ans = 0
for i in range(count):
  if G - accum < D * (PC[D-1][0]-1):
    for j in range(PC[D-1][0]-1):
      accum += D*100
      ans += 1
      if accum >= F:
        print(ans)
        exit()
  else:
    for j in range(PC1[i][1]):
      accum += PC1[i][2]
      ans += 1
      if j == PC1[i][1]-1:
        accum += PC1[i][3]
      if accum >= G:
        print(ans)
        exit()
print(ans)
          


### FIXED CODE ###

D, G = map(int, input().split())
PC = [list(map(int,input().split())) for i in range(D)]

l = []
for i in range(2 ** D):
  t = 0
  c = 0
  for j in range(D):
    if ((i >> j) & 1):
      t += (j+1)*100*PC[j][0]+PC[j][1]
      c += PC[j][0]
  if t >= G:
    l.append(c)
  else:
    ck = []
    for j in range(D):
      if ((i >> j) & 1):
        continue
      else:
        ck.append(j)
    if ck == []:
      continue
    ckm = max(ck)
    for k in range(PC[ckm][0]):
      t += (ckm+1)*100
      c += 1
      if t >= G:
        l.append(c)
        break
      
print(min(l))
s = int(input())
if a[5]+a[6] > 4:
  print("Heisei")
else:
  print("TBD")


### FIXED CODE ###

s = input()
if s <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")
t

### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[12]:


from collections import deque


# In[1]:


K = int(input())


# In[15]:


q = deque(list(range(1,10)))
for i in range(K-1):
    x = q.popleft()
    if x%10 != 0:
        y = x*10 + x%10 - 1
        q.append(y)
    y = x*10 + x%10
    q.append(y)
    
    if x%10 != 9:
        y = x*10 + x%10 + 1
        q.append(y)
    
ans = q.popleft()
print(ans)


# In[ ]:
a,b,c = map(int,input.split(" "))
print((a*b)/c)

### FIXED CODE ###

a,b,c = map(int,input().split(" "))
print(int((a*b)/2))
import math
[a,b,h,m] = [int(x) for x in input().split(" ")]
short = (h*60+m)/(12*60)*360
long = (m)/(60)*360
theta = min(abs(long-short),abs(360-abs(short-long)))

print( math.sqrt(a*2+b*2+a*b*math.cos(math.radians(theta))))

### FIXED CODE ###

import math
 
[a, b, h, m] = [int(x) for x in input().split(" ")]
short = ((h) * 60 + m) / (12 * 60) * 360
long = (m) / (60) * 360
theta = abs(long - short)
inte = math.cos(math.radians(theta))
print(math.sqrt(a ** 2 + b ** 2- 2*a * b * inte))
n = (int)(input())
l = (list)(map(int, input().split()))

max_l = max(l) if max(l) >= 0 else 0
min_l = min(l) if min(l) <= 0 else 0

l_sort = sorted(l)

for i in range(n):
    if l[i] == min(l):
        cost = max(l)*2 + (lambda -x*2: x if x <= 0 else 0)(l_sort[1])
    elif l[i] == max(l):
        cost = -min(l)*2 + (lambda x*2: x if x >= 0 else 0)(l_sort[n-2])
    else:
        cost = -min_l*2 + max_l*2
    print(cost)


### FIXED CODE ###

n = int(input())
a = [int(i) for i in ("0 "+input()+" 0").split()]
ans = sum(abs(a[i+1]-a[i]) for i in range(n+1))
for i in range(n):
    print(ans-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i]))
from math import gcd
a, b, c, d = map(int, input().split())
ans = b-a+1

amari_ac = a % c
amari_ad = a % d
if amari_ac == 0:
    c_min = a
else:
    c_min = a+c - amari_ac
if amari_ad == 0:
    d_min = a
else:
    d_min = a+d - amari_ad

amari_bc = b % c
amari_bd = b % d
c_max = b-amari_bc
d_max = b-amari_bd

c_count = (c_max-c_min)//c + 1
d_count = (d_max-c_min)//d + 1

lcm_cd = c*d // gcd(c, d)
amari_acd = a % lcm_cd
if amari_acd == 0:
    cd_min = a
else:
    cd_min = a+lcm_cd - amari_acd

amari_bcd = b % lcm_cd
cd_max = b - amari_bcd

cd_count = (cd_max-cd_min)//lcm_cd + 1

if cd_max < a or b < cd_max:
    cd_count = 0
if cd_min < a or cd_min > b:
    cd_count = 0

print(ans-c_count-d_count+cd_count)


### FIXED CODE ###

from fractions import gcd
a, b, c, d = map(int, input().split())
ans = b-a+1
lcm_cd = (c*d)//gcd(c, d)

under_a = (a-1)//c + (a-1)//d - (a-1)//lcm_cd
under_b = b//c + b//d - b//lcm_cd
print(ans-(under_b-under_a))
N = int(input())
N = N % 10
if N in (2, 4, 5, 7, 9):
    print ("hon")
elif N in (0, 1, 6, 7):
    print ("pon")
elif N in (3):
    print ("bon")


### FIXED CODE ###

N = int(input())
N = N % 10
if N in (2, 4, 5, 7, 9):
    print ("hon")
elif N in (0, 1, 6, 8):
    print ("pon")
elif N == 3:
    print ("bon")
a, b = input()
a = int(a)
b = int(b)

x = 1
num = 0
while True:
    x += a - 1
    num += 1
    if x >= b:
        break
        
print(num)

### FIXED CODE ###

a, b = input().split()
a = int(a)
b = int(b)

x = 1
num = 0
while True:
    if b == 1:
        num = 0
        break
    x += (a - 1)
    num += 1
    if x >= b:
        break
        
print(num)
n = int(input())
d = list(map(int,input().split()))
d.sort()
if d[int(n/2)-1] == d[(int(n/2))+1]:
    print(0)
else:
    print(d[(int(n/2))] - d[int(n/2)-1])

### FIXED CODE ###

n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[(int(n/2))] - d[int(n/2)-1])
#!/usr/bin/python

import math

r = int(raw_input())

area = r * r * math.pi
length = 2 * r * math.pi

print str(area) + " " + str(length)

### FIXED CODE ###

import math
n = input()
S = '%.6f' % (float(n)**2 * math.pi)
L = '%.6f' % (float(n) * 2 * math.pi)
print "{} {}".format(S,L)
mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, 10 ** 4 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((- inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    n = (x + y) // 3
    r = min((2 * y - x) // 3, (2 * x - y) // 3)
    return cmb(n, r, mod)

_x, _y = map(int, input().split())
print(solve(_x, _y))


### FIXED CODE ###

def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    n = (x + y) // 3
    r = min((2 * y - x) // 3, (2 * x - y) // 3)
    return cmb(n, r, mod)

_x, _y = map(int, input().split())

mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, max(_x, _y) + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((- inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

print(solve(_x, _y))
N=int(input())
an=list(map(int,input().split()))
n=0
for i in range(N):
    if an[i]%2==0:
        an[i]//2
        n+=1
print(n)


### FIXED CODE ###

print(input().count('1'))
n,k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
count = [0]*2000
A = (10**9)+7
c_in = 0
for i in range(n):
  for j, t in enumerate(a[:i]):
    c_in += int(t > a[i])
  count[a[i]-1] += 1
c_out = 0
for i in range(n):
  c_out += sum(count[:a[i]-1])
N = (c_in*k)%A + (k*(k-1)//2)*c_out%A
print(N)

### FIXED CODE ###

m,d = map(int, input().split(' '))
mlist = list(range(m+1))
c = 0
for _d in range(d+1):
	d1 = _d // 10
	d0 = _d % 10
	if d1 > 1 and d0 > 1 and d1*d0 in mlist:
		c+=1
print(c)
s = input() #alphabet hitotsu sakino moji
print(chr(ord(s) + 1)

### FIXED CODE ###

s = input()
print(chr(ord(s) + 1))
a = input()
ar = []
for i in range(3):
    ar.append(a[i]) 
n = len(ar)
ret = 0
for i in range(n+1):
    s = "+"
    tmp = ""
    for j in range(n):
        if (1 & (i >> j)) == 1:
            tmp += ar[j]
            tmp += s
        else:
            tmp += ar[j]
    stmp = tmp.split("+")
    ret += sum(int(k) for k in stmp)
print(ret)


### FIXED CODE ###

a = input()
ar = []
for i in range(len(a)):
    ar.append(a[i])
n = len(ar)
ret = 0
for i in range(2**(n-1)):
    s = "+"
    tmp = ""
    for j in range(n):
        if (1 & (i >> j)) == 1:
            tmp += ar[j]
            tmp += s
        else:
            tmp += ar[j]
    stmp = tmp.split("+")
    ret += sum(int(k) for k in stmp)
print(int(ret))
import sys
input = sys.stdin.readline

N,K = (int(x) for x in input().rstrip('\n').split())
vs = [int(x) for x in input().rstrip('\n').split()]
g = []
rest = K
for k in [K-1,K]:
  for b in range(K//2):
    t = k-b
    if t>N:
      t=N
    for i in range(t+1):
      v = []
      if i <t:
        v.extend(vs[:i])
        v.extend(vs[-(t-i):])
        for _ in range(b):
          if min(v)<0:
            v.remove(min(v))
          else:
            break
      else:
        v.extend(vs[:t])
        for _ in range(b):
          if min(v)<0:
          	v.remove(min(v))
      g.append(sum(v))
if max(g)<0:
  print(0)
else:
  print(max(g))

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,K = (int(x) for x in input().rstrip('\n').split())
vs = [int(x) for x in input().rstrip('\n').split()]
g = [vs[0],vs[-1]]
rest = K
for k in [K-1,K]:
  for b in range(K//2):
    t = k-b
    if t>N:
      t=N
    for i in range(t+1):
      v = []
      if i <t:
        v.extend(vs[:i])
        v.extend(vs[-(t-i):])
        for _ in range(b):
          if min(v)<0:
            v.remove(min(v))
          else:
            break
      else:
        v.extend(vs[:t])
        for _ in range(b):
          if min(v)<0:
          	v.remove(min(v))
      g.append(sum(v))
if max(g)<0:
  print(0)
else:
  print(max(g))
import numpy as np
N,M,Q=map(int, input().split())
matrix=[]
for _ in range(Q):
    c=list(map(int, input().split()))
    matrix.append(c)
matrix = np.array(matrix)
import itertools
ansscore = 0
maxscore = sum([row[3] for row in matrix])
for i in itertools.product(range(1,M+1), repeat=N):
    i = list(i)
    i.sort()
    score=0
    for l in matrix:
        a=l[0]
        b=l[1]
        c=l[2]
        d=l[3]
        if i[b-1]-i[a-1]==c:
            score+=d
    ansscore = score if score>ansscore else ansscore
    if ansscore == maxscore:
        break
print(ansscore)

### FIXED CODE ###

#import numpy as np
N,M,Q=map(int, input().split())
matrix=[]
for _ in range(Q):
    c=list(map(int, input().split()))
    matrix.append(c)
#matrix = np.array(matrix)
import itertools
ansscore = 0
combi = list(itertools.combinations_with_replacement(range(1,M+1),N))
for i in combi:
    i = list(i)
    i.sort()
    score=0
    for l in matrix:
        a=l[0]
        b=l[1]
        c=l[2]
        d=l[3]
        if i[b-1]-i[a-1]==c:
            score+=d
    ansscore = score if score>ansscore else ansscore

print(ansscore)
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
print(sum(l[:k])

### FIXED CODE ###

n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
print(sum(l[:k]))
from math import gcd
A, B, C, D = map(int, input().split())
k = B - A
count = round(k//C + k//D - k//((C*D)/gcd(C,D)))
print(k-count)


### FIXED CODE ###

import fractions
def lcm(a,b):
  return a*b //fractions.gcd(a, b)

A, B,C,D = map(int, input().split())

b_num = B//C + B//D - B//lcm(C, D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)
print((B-(A-1))-(b_num-a_num))
l = input().split()
print(int(l[0])*int(l[1]),2*int(l[0])+2*int(l[1])

### FIXED CODE ###

inp=input().split()
ab=[int(inp[0]),int(inp[1])]
print(ab[0]*ab[1],ab[0]*2+ab[1]*2)
s,t=input().split()
cnt=0
for i in range(3):
  if s[i]==t[i]:
    cnt+=1
print(cnt)


### FIXED CODE ###

s=input()
t=input()
cnt=0
for i in range(3):
  if s[i]==t[i]:
    cnt+=1
print(cnt)
#factorial
mod = 998244353 
N = 1000000
modinv_t = [0, 1]
modfact_t = [1, 1]
modfactinv_t = [1, 1]
for i in range(2,N+1):
  modfact_t.append(modfact_t[-1] * i % MOD)
  modinv_t.append(modinv_t[MOD%i] * (MOD-(MOD//i)) % MOD)
  modfactinv_t.append(modfactinv_t[-1] * modinv_t[-1] % MOD)
# permutation
def nPr(n, r):
  return  modfact_t[n] * modfactinv_t[n-r] % MOD
# combination
def nCr(n, r):
  return  modfact_t[n] * modfactinv_t[n-r] * modfactinv_t[r] % MOD
#
def nHr(n, r):
  return  nCr(n+r-1,r)
#

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

t = M*pow(M-1,N-1,mod)
for i in range(1,K+1):
  t += M*pow(M-1,N-1-i,mod)*nCr((N-1),i)
  t %= mod
#
print(t)


### FIXED CODE ###

#factorial
MOD = 998244353 

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

modinv_t = [0, 1]
modfact_t = [1, 1]
modfactinv_t = [1, 1]
for i in range(2,N+1):
  modfact_t.append(modfact_t[-1] * i % MOD)
  modinv_t.append(modinv_t[MOD%i] * (MOD-(MOD//i)) % MOD)
  modfactinv_t.append(modfactinv_t[-1] * modinv_t[-1] % MOD)
# permutation
def nPr(n, r):
  return  modfact_t[n] * modfactinv_t[n-r] % MOD
# combination
def nCr(n, r):
  return  modfact_t[n] * modfactinv_t[n-r] * modfactinv_t[r] % MOD
#
def nHr(n, r):
  return  nCr(n+r-1,r)
#


t = M*pow(M-1,N-1,MOD)
for i in range(1,K+1):
  t += M*pow(M-1,N-1-i,MOD)*nCr((N-1),i)
  t %= MOD
#
t %= MOD
print(t)
from collections import deque

H, W = list(map(int, input().split()))
field = [input() for _ in range(H)]
dist = [[5000] * W for _ in range(H)]

def bfs():
  q = deque()
  for y in range(H):
    for x in range(W):
      if field[y][x] == '#':
        q.append((y, x))
        dist[y][x] = 0
  while len(q) > 0:
    y, x = q.popleft()
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
      ny, nx = y + dy, x + dx
      if ny < 0 or ny >= H or nx < 0 or nx >= W:
        continue
      if field[ny][nx] == '#':
        continue
      if dist[ny][nx] < dist[y][x] + 1:
        continue
      dist[ny][nx] = dist[y][x] + 1
      q.append((ny, nx))
      
bfs()
print(max([max[i] for i in dist]))

### FIXED CODE ###

from collections import deque
import copy

def main():
  H, W = map(int, input().split())
  maps = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if maps[i][j]])
  count = 0
  while True:
    nq = deque()
    while q:
      x, y = q.popleft()
      if x > 0 and not maps[x-1][y]:
        maps[x-1][y] = True
        nq.append((x-1,y))
      if y > 0 and not maps[x][y-1]:
        maps[x][y-1] = True
        nq.append((x,y-1))
      if x < H-1 and not maps[x+1][y]:
        maps[x+1][y] = True
        nq.append((x+1,y))
      if y < W-1 and not maps[x][y+1]:
        maps[x][y+1] = True
        nq.append((x,y+1))
    if nq:
      q = copy.copy(nq)
    else:
        break
    count += 1
  print(count)

if __name__ == "__main__":
  main()
N = int(input())
M = 0
for P in map(int, input().split()):
    if P <= N:
        N = x
        M += 1
print(M)

### FIXED CODE ###

N = int(input())
P = tuple(map(int, input().split()))

pmin = P[0]

m = 1

for i in range(1, N, 1):
    if P[i] < pmin:
        pmin = P[i]
        m += 1

print(m)
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = 0
count = 0
i = 2
while d <= x:
    d = d + l[i - 2]
    count += 1
    i += 1

print(count)

### FIXED CODE ###

import itertools
import math
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = 0
count = 0
i = 1
while d <= x and i <= n:
    d = d + l[i - 1]
    count += 1
    i += 1
if d <= x:
    count += 1

print(count)
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N, Y = LI()
y = 1000 * N
for i in range(N+1):
    for j in range(n-i+1):
        if i * 10000 + 5000 * j + 1000 * (N-i-j) == y:
            print(i, j, N-i-j)
            exit()
print("-1 -1 -1")

### FIXED CODE ###

import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N, Y = LI()
y = 1000 * N
for i in range(N+1):
    for j in range(N-i+1):
        if i * 10000 + 5000 * j + 1000 * (N-i-j) == Y:
            print(i, j, N-i-j)
            exit()
print("-1 -1 -1")
from collections import deque

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

num_books = 0
remaining_time = K

while True:
    consumption = 0

    if len(A) == 0 and len(B) == 0: break

    if len(A) == 0:
        consumption = B.popleft()
    elif len(B) == 0:
        consumption = A.popleft()
    elif A[0] == B[0]:
        if A[1] < B[1]:
            consumption = A.popleft()
        else: 
            consumption = B.popleft()
    elif A[0] < B[0]:
        consumption = A.popleft()
    else:
        consumption = B.popleft()
    # print(consumption)
    
    remaining_time -= consumption
    if remaining_time < 0: break

    num_books += 1

print(num_books)
    


### FIXED CODE ###

from collections import deque

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


consumptions_A = [0]
for i in range(len(A)):
    consumptions_A.append(consumptions_A[i] + A[i])

consumptions_B = [0]
for i in range(len(B)):
    consumptions_B.append(consumptions_B[i] + B[i])

answer = 0
j = M
for i in range(len(consumptions_A)):
    if (consumptions_A[i] > K): break

    remaining_time = K - consumptions_A[i]
    while consumptions_B[j] > remaining_time:
        j -= 1
    
    num_books = i + j
    answer = max(answer, num_books)

print(answer)
# coding: utf-8

line = raw_input()
result = ''
for s in line:
    if s.isalpha():
        if s.isupper():
            result += s.lower(),
        else:
            result += s.upper(),
    else:
       print result += s

print result

### FIXED CODE ###

# coding: utf-8

line = raw_input()
print ''.join([((s.lower() if s.isupper() else s.upper()) if s.isalpha() else s) for s in line])