Harryxun/stf_run huggingface dataset:
INF = 10000000000000
class Vertice:
  def __init__(self, num):
    self.num = num
    self.connected = []
    self.edge = []
    self.pos = INF
    
def DFS(vertice):
  judge = True
  connected_num = len(vertice.connected)
  for i in range(connected_num):
    con = vertice.connected[i]
    if con.pos == INF:
      con.pos = vertice.pos + vertice.edge[i]
      judge = DFS(con)
    elif con.pos != vertice.pos + vertice.edge[i]:
      judge = False
    if judge == False:
      break
  return judge
 
N, M = map(int, input().split())
L, R, D = ([None for i in range(M)] for j in range(3))
vertices = [Vertice(i) for i in range(N)]
for i in range(M):
  L[i], R[i], D[i] = map(int, input().split())
for i in range(M):
  if not vertices[R[i] - 1] in vertices[L[i] - 1].connected:
    vertices[L[i] - 1].connected.append(vertices[R[i] - 1])
    vertices[R[i] - 1].connected.append(vertices[L[i] - 1])
    vertices[L[i] - 1].edge.append(D[i])
    vertices[R[i] - 1].edge.append(-D[i])
judge = True
for i in range(N):
  if vertices[i].pos == INF:
    vertices[i].pos = 0
    judge = DFS(vertices[i])
    if judge == False:
      break
if judge:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import sys
sys.setrecursionlimit(2000002)

def DFS(i, pos, connected, distances):
  if pos[i] == None:
    pos[i] = 0
  size = len(connected[i])
  for j in range(size):
    if pos[connected[i][j]] == None:
      pos[connected[i][j]] = pos[i] + distances[i][j]
      if DFS(connected[i][j], pos, connected, distances) == False:
        return False
    elif pos[connected[i][j]] != pos[i] + distances[i][j]:
      return False
  return True

N, M = map(int, input().split())
pos = [None for i in range(N + 1)]
connected = [[] for i in range(N + 1)]
distances = [[] for i in range(N + 1)]
for i in range(M):
  l, r, d = map(int, input().split())
  connected[l].append(r)
  distances[l].append(d)
  connected[r].append(l)
  distances[r].append(-d)
judge = True
for i in range(1, N + 1):
  if pos[i] == None:
    judge = DFS(i, pos, connected, distances)
    if judge == False:
      break
if judge:
  print('Yes')
else:
  print('No')
# -*- utf-8 -*-

while True:
    i = map(int, raw_input().split())
    if i == None:
        break
    a = i[0]
    b = i[1]
    
    s = a + b
    
    ans = 0
    
    while s >= 1:
        s /= 10
        ans += 1
    
    print ans

### FIXED CODE ###

# -*- utf-8 -*-

while True:
    try:
        inp = raw_input()
        i = map(int, inp.split())
        a = i[0]
        b = i[1]
    
        s = a + b
    except:
        break
    
    ans = 0
    
    while s >= 1:
        s /= 10
        ans += 1
    
    print ans
N = int(input())
s = set()
for i in range(N+1):
    a = input()
    s.add(a)
if(len(s) == 3):
  print("Three")
else:
  print("Four")

### FIXED CODE ###

N = int(input())
a = list(input().split())

if("Y" in a):
  print("Four")
else:
  print("Three")
n=input()
s=(n*(n+1))/2
print(s)

### FIXED CODE ###

n=int(input())
print(int(n*(n+1)/2))
n=int(input())
x=list(map(int,input().split()))

x.sort()
ans=0

for i range(n):
  if i%2==1:
    pass
  else:
    ans+=min(x[i],x[i+1])
    
print(ans)

### FIXED CODE ###

N = int(input())

L = list(map(int, input().split()))

L.sort()

ans = 0

for i in range(N):
    ans = ans + L[i*2]
    
print(ans)
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y//gcd(x,y)
# LCM --- END ---

def main():
  n,m=LI()
  s=S()
  t=S()
  a=lcm(n,m)

  y=['a']*(10**10)

  x=['.']*a
  for i in range(n):
    x[i*(a//n)]=s[i]

  # print(x)

  for i in range(m):
    if x[i*(a//m)]!='.' and x[i*(a//m)]!=t[i]:
      return -1

  return a

# main()
print(main())


### FIXED CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y//gcd(x,y)
# LCM --- END ---

def main():
  n,m=LI()
  s=S()
  t=S()
  a=lcm(n,m)

  x={}
  for i in range(n):
    x[i*(a//n)]=s[i]

  # print(x)

  for i in range(m):
    if i*(a//m) in x:
      if t[i]!=x[i*(a//m)]:
        return -1

  return a

# main()
print(main())
n , k = map(int,input().split())
list = input().split()
list1 = list.sort()
a = 0
 
for i in range(k):
  a += list[i]

### FIXED CODE ###

n , k = map(int,input().split())

list = map(int,input().split())
list = sorted(list)

a = 0

for i in range(k):
    a += list[i]

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

AB = sorted(A)
C = int(N/2)
for i in range(N):
    if AB[i] <= AB[C-1]:
        print(AB[C])
    else:
        print(AB[C-1])

### FIXED CODE ###

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

AB = sorted(A)
C = int(N//2)
for i in range(N):
    if A[i] <= AB[C-1]:
        print(AB[C])
    else:
        print(AB[C-1])
A,B,K = map(int,input().split())
import math
GcD = math.gco(A,B)
li = []
for i in range(1,GcD):
    if GcD % i == 0:
        li.append(i)
li.sort(reverse=True)
print(li[K-1]

### FIXED CODE ###

A,B,K = map(int,input().split())
def gcd(a, b):
    while b:
    	a, b = b, a % b
    return a
GcD = gcd(A,B)
li = []
for i in range(GcD+1):
    if GcD % (i+1) == 0:
        li.append(i+1)
li.sort(reverse=True)
print(li[K-1])
n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append([s,c])

ans='-1'
for i in range(10**n):
    x=str(i)
    c=0
    for j in range(m):
        if x[a[j][0]-1] == str(a[j][1]):
            c+=1
    if c==m:
        ans=i
        break
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append([s,c])

ans=-1
if n==1:
    for i in range(10):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
else:
    for i in range(10**(n-1),10**n):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
print(ans)
import copy

S = input()

dp = [0] * 13

dp[0] = 1

mod = 10 ** 9 + 7
mul = 1
for i in range(len(S)-1, -1, -1):
    # 二次元dpの代わり
    ndp = [0] * 13
    
    if S[i] == '?':
        for k in range(10):
            for j in range(13):
                # 次の桁の余りが加わった時に、そこへ前のdp[j]の値を入れる
                # ただし、0-9までの値をその桁が取る可能性があるので、
                #　それぞれの場合全てを加算する
                ndp[(k * mul + j) % 13] += dp[j]
                ndp[(k * mul + j) % 13] %= mod
    else:
        k = int(S[i])
        for j in range(13):
            # 次の桁の余りが加わった時に、そこへ前のdp[j]の値を入れる
            ndp[(k * mul + j) % 13] += dp[j]
            ndp[(k * mul + j) % 13] %= mod

    mul *= 10
    mul %= 13
    dp = copy.deepcopy(ndp)

# 13で割って5で余るものを出力
print(dp[5])


### FIXED CODE ###

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

K = (A + B) / 2
if K == int(K):
    print(int(K))
else:
    print('IMPOSSIBLE')
a,b,c=map(int,input().split())
if a,b,c == 5,5,7 or a,b,c == 7,5,5 or a,b,c == 5,7,5:
	print("YES")
else:
	print("NO")

### FIXED CODE ###

s=list(map(int,input().split()))
if s == [5,5,7] or s == [7,5,5] or s == [5,7,5]: 
	print("YES")
else:
	print("NO")
L,R = map(int,input().split())

if L == 0 or L%2019 == 0 or R%2019 == 0:
  print(0)
  exit()
elif R - L == 1:
  print(L*R)
  exit()

a = list(range(L,R+1))

N = len(a)
r = 0
total = []

for l in range(N):
  r = l + 1
  while r < N:
    total.append((a[l]*a[r])%2019)
    r += 1
  if l == r:
    l += 1
    
print(min(total))


### FIXED CODE ###

L,R = map(int,input().split())

total = 2019

if R-L >= 2019:
  print(0)
  exit()

for l in range(L,R):
  for r in range(L+1,R+1):
    if l*r%2019 == 0:
      print(0)
      exit()
    else:
      total = min(total,l*r%2019)
    
print(total)
c = sorted(list(map(int, input())))

if c[0]==A and c[2]==B:
  print('Yes')
else:
  print('No')



### FIXED CODE ###

c = sorted(input())
 
if c[0]=='A' and c[2]=='B':
  print('Yes')
else:
  print('No')
n=list(input())
k=int(input())
if len(n)==1:
  print('1')
else:
  one_list=[]
  while 1==1:
    if n[0]=='1':
      one_list.pop(n.pop(0))
    else:
      break
  if 0<len(one_list)<=k:
    print('1')
  else:
    print(n[0])



### FIXED CODE ###

n=list(input())
k=int(input())
if len(n)==1 and n[0]=='1':
  print('1')
else:
  one_list=[]
  while len(n)!=0:
    if n[0]=='1':
      one_list.append(n.pop(0))
    else:
      break
  if k<=len(one_list):
    print('1')
  else:
    print(n[0])
def fib_memo(n):
    memo=["EMPTY"]*(n+1)
    def _fib(n):
        if n == 1:
            return 0
        elif n == 2:
            return 1
        elif memo[n] != "EMPTY":
            return memo[n]
        else:
            memo[n] = _fib(n-1)+_fib(n-2)
            return memo[n]
    return _fib(n)
def fib(n):
    f = ((1 + 5**0.5) / 2)**n / 5**0.5 + 0.5
    return int(f)
  
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
if a:
  cnt=fib(a[0]+1)*fib(n-a[m-1]+1)
  for i in range(1,m):
    cnt*=fib(a[i]-a[i-1])
  print(cnt%(10**9+7))
else:
  print(fib_memo(n+2)%(10**9+7))


### FIXED CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[1]*(n+1)
dp[0]=1
dp[1]=1
for i in range(m):
  if a[i]==1:
    dp[1]=0
  else:
    dp[a[i]]=0
for i in range(2,n+1):
  if dp[i]:
    dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%(10**9+7))
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=0

for i in range(N):
  ans += max(0,V[i] - C[i]):
print(ans)

### FIXED CODE ###

N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=0

for i in range(N):
  ans += max(0,V[i] - C[i])
print(ans)
h, w=map(int, input().split())
a=[]
visited=[[True for i in range(w)] for j in range(h)]
need_visited=[[h+w for i in range(w)] for j in range(h)]
stack=[]
for i in range(h):
    a.append(list(input()))

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            stack.append([i, j])
            need_visited[i][j]=0
            visited[i][j]=False



dx=[1, -1, 0, 0]
dy=[0, 0, 1, -1]


while len(stack)!=0:
    now_point=stack.pop(0)
    now_y=now_point[0]
    now_x=now_point[1]
    for i in range(4):
        if 0<=now_x+dx[i]<=w-1 and 0<=now_y+dy[i]<=h-1:
            if a[now_x+dx[i]][now_y+dy[i]]==".":
                if visited[now_x+dx[i]][now_y+dy[i]]:
                    need_visited[now_x+dx[i]][now_y+dy[i]]=need_visited[now_x][now_y]+1
                    visited[now_x+dx[i]][now_y+dy[i]]=False

                    stack.append([now_x+dx[i], now_y+dy[i]])
max_list=[]
for i in range(h):
    max_list.append(max(need_visited[i]))
print(max(max_list))


### FIXED CODE ###

from collections import deque

H, W = [int(x) for x in input().split()]
cell = [list(input()) for i in range(H)]

painted = deque()
for h in range(H):
    for w in range(W):
        if cell[h][w] == '#':
            painted.append([h, w, 0])

ans = 0
while len(painted) > 0:
    blackcell = painted.popleft()
    for dy, dx in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
        nh = blackcell[0] + dy
        nw = blackcell[1] + dx
        d = blackcell[2]
        if 0 <= nh < H and 0 <= nw < W and cell[nh][nw] == '.':
            cell[nh][nw] = '#'
            painted.append([nh, nw, d + 1])
        ans = d

print(ans)
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n, m, k = map(int, input().split())
    fgraph = [list() for i in range(n)]
    bgraph = [list() for i in range(n)]
    cgraph = [list() for i in range(n)]


    seen = [False]*n
    def dfs(graph,s,t):
        seen[s] = True
        if t+1 in graph[s]:
            return True
        for i in range(len(graph[s])):
            if seen[graph[s][i]-1]:
                continue
            if dfs(graph, graph[s][i]-1, t):
                return True
        return False

    for i in range(m):
        a,b = map(int, input().split())

        fgraph[a-1].append(b)
        fgraph[b-1].append(a)

    for i in range(k):
        c,d = map(int, input().split())
        bgraph[d-1].append(c)
        bgraph[c-1].append(d)

    # print(fgraph)
    #print(bgraph)

    for i in range(n):
        for j in range(i,n):
            if j == i or j+1 in bgraph[i] or j+1 in fgraph[i]:
                continue
            # print(i+1,j+1)
            seen = [False]*n
            if dfs(fgraph, i, j):
                cgraph[i].append(j)
                cgraph[j].append(i)
            # i+1 から j+1 への経路の存在を探索する
    print(cgraph)    
    for i in range(n):

        print(len(set(cgraph[i])))
    
    return

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n, m, k = map(int, input().split())
    fgraph = [list() for i in range(n)]
    bgraph = [list() for i in range(n)]
    cgraph = [list() for i in range(n)]
    
    is_all_seen = [False]*n
    cnt = 0
    seen = [None]*n
    rks = [None] *n
    sys.setrecursionlimit(10**9)
    def dfs(graph,s,r):
        seen[s] = s+1
        if rks[s] is None:
            rks[s] = r

        for i in range(len(graph[s])):
            if seen[graph[s][i]-1]:
                continue
            dfs(graph, graph[s][i]-1,r)

    for i in range(m):
        a,b = map(int, input().split())

        fgraph[a-1].append(b)
        fgraph[b-1].append(a)

    # print(fgraph)
    #print(bgraph)
    # 連結成分に対してid的なindexをつける
    c = -1
    for i in range(n):

        if rks[i] is None:
            c += 1
            dfs(fgraph, i, c)
    
    for i in range(k):
        c,d = map(int, input().split())
        if rks[c-1] == rks[d-1]:
            bgraph[d-1].append(c)
            bgraph[c-1].append(d)

    counter = Counter(rks)
    for i in range(n):
        # counter[rks[i]] 連結成分のサイズ
        # len(fgraph[i]) 友達の数
        # len(bgraph[i]) 連結成分内のブロックの数
        # 1 自分
        print(counter[rks[i]] - len(fgraph[i]) - len(bgraph[i]) - 1)

if __name__ == '__main__':
    main()
H,W=map(int,input().split())
s=[list(map(int, list(input().replace('#','1').replace('.','0')))) for _ in range(W)]

padded = [[0 for i in range(W+2)] for j in range(H+2)]

for i in range(H):
  for j in range(W):
    padded[i+1][j+1] = s[i][j] 

for i in range(1,H+1):
  for j in range(1,W+1):
    if padded[i][j]==1:
      if padded[i+1][j]==0 and padded[i-1][j]==0 and padded[i][j+1]==0 and padded[i][j-1]==0:
        print('No')
        exit()
print('Yes')

### FIXED CODE ###

H,W=map(int,input().split())
s=[list(map(int, list(input().replace('#','1').replace('.','0')))) for _ in range(H)]

padded = [[0 for i in range(W+2)] for j in range(H+2)]

for i in range(H):
  for j in range(W):
    padded[i+1][j+1] = s[i][j] 

for i in range(1,H+1):
  for j in range(1,W+1):
    if padded[i][j]==1:
      if padded[i+1][j]==0 and padded[i-1][j]==0 and padded[i][j+1]==0 and padded[i][j-1]==0:
        print('No')
        exit()
print('Yes')
N=int(input())

x=100.0
for i in range(N):
    x=math.floor(x*1.01)
    if(x>=N):
        print(i+1)
        break;
    i+=1

### FIXED CODE ###

import math
N=int(input())

x=100.0
for i in range(N):
    x=math.floor(x*1.01)
    if(x>=N):
        print(i+1)
        break;
    i+=1
s = list(input())
cnt = 0
list = []
for i in range(len(s)):
    if s[i] in ['A','C','G','T']:
        cnt += 1
    else:
        list.append(cnt)
        cnt = 0
max = max(list)
print(max)


### FIXED CODE ###

s = list(input())
cnt = 0
list = []
for i in range(len(s)):
    if s[i] in ['A','C','G','T']:
        cnt += 1
    else:
        if cnt > 0:
            list.append(cnt)
            cnt = 0
if not cnt == 0:
    list.append(cnt)
if len(list) == 0:
    list.append(0)
max = max(list)
print(max)
def main(N,A):
    B=[0]

    for i in range(int(len(A))):
        T = A[i] + B[i]
        B.append(T)
    count = 0
    for i in range(i+1)):
        for m in range(i+1):
            if i > i-m:
                T = B[i]-B[i-m]
                # print(i, m)
                # print(B[i],B[i-m])
                # print(T)
                if T == 0:
                    # print("kore",B[i],B[i-m])
                    count += 1

    #print(count)
    #print(B)
    return print(count)




if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))
    main(N,A)

### FIXED CODE ###

import collections

def main(N,A):
    B=[0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]

        B.append(T)
    c = collections.Counter(B)

    for i in range(len(c)):
        k, v = c.popitem()
        for z in range(v):
            count += z

    return print(count)

if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))

    main(N,A)
d=[0]*13
d[0]=1
s=input()
for k,t in enumerate(s[::-1]):
    if t=='?':
        d2=[0]*13
        for i in range(10):
            u=i*pow(10,d,13)
            for i in range(13):
                d2[(i+u)%13]+=d[i]
    else:
        u=int(t)*pow(10,d,13)
        d2=[0]*13
        for i in range(13):
            d2[(i+u)%13]+=d[i]
    for i in range(13):
        d[i]=d2[i]%(10**9+7)
print(d[5])

### FIXED CODE ###

d=[0]*13
d[0]=1
s=input()
for k,t in enumerate(s[::-1]):
    if t=='?':
        d2=[0]*13
        for i in range(10):
            u=i*pow(10,k,13)
            for i in range(13):
                d2[(i+u)%13]+=d[i]
    else:
        u=int(t)*pow(10,k,13)
        d2=[0]*13
        for i in range(13):
            d2[(i+u)%13]+=d[i]
    for i in range(13):
        d[i]=d2[i]%(10**9+7)
print(d[5])
A,B = [int(i) for i in input().split()]
c = 0
if 1 <= A <= 99999:
    if 1 <= B <= 99999:
        for p in range(A,B):
            if p // 10000 == i % 10 and p // 1000 == p % 100 - p % 10:
                c += 1
            elif p // 100 == i % 10:
                c += 1
print(c)           

### FIXED CODE ###

A,B = [int(i) for i in input().split()]
c = 0
if 1 <= A <= 99999:
    if 1 <= B <= 99999:
        for p in range(A, B + 1):
            if p // 10000 == p % 10 and p // 1000 - 10 * ( p // 10000 ) == p % 100 // 10:
                c += 1
            elif p // 100 == p % 10:
                c += 1            
print(c)
N = int(input())
R = int(input())
if N >= 10: 
  return R 
else: 
  return 100 * ( 10 - N ) + R


### FIXED CODE ###

N, R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print( 100 * (10 - N) + R )
#main
n, y = map(int, raw_input().split())
solve(n, y)




### FIXED CODE ###

def solve(n, y):
    for man in range(n + 1):
        for gosen in range(n - man + 1):
            sen = n - man - gosen
            if 10000*man + gosen*5000 + sen*1000 == y and man + gosen + sen == n:
                print('{} {} {}'.format(man, gosen, sen))
                return
    print("-1 -1 -1")
    return            

#main
n, y = map(int, raw_input().split())
solve(n, y)
X = int(input())

if X in range(400,600):
  print(8)
elif X in range(600,800)
  print(7)
elif X in range(800,1000)
  print(6)
elif X in range(1000,1200)
  print(5)
elif X in range(1200,1400)
  print(4)
elif X in range(1400,1600)
  print(3)
elif X in range(1600,1800)
  print(2)
elif X in range(1800,1900)
  print(1)

### FIXED CODE ###

X = int(input())

if X in range(400,600):
  print(8)
elif X in range(600,800):
  print(7)
elif X in range(800,1000):
  print(6)
elif X in range(1000,1200):
  print(5)
elif X in range(1200,1400):
  print(4)
elif X in range(1400,1600):
  print(3)
elif X in range(1600,1800):
  print(2)
else:
  print(1)
s=str(input())
if s=="hi" or s=="hihi" s=="hihihi" or s=="hihihihi" or s=="hihihihihi":
  print('Yes')
else:
  print('No')

### FIXED CODE ###

S=input()
if S=='hi' or S=='hihi' or S=='hihihi' or S=='hihihihi' or S=='hihihihihi':
  print("Yes")
else:
  print("No")
n = input()
list = []

for i in range(n):
    print("str: ")
    sp = input().split()
    s = str(sp[0])
    p = int(sp[1])

    #s, p = sp[0], int(sp[1])
    list.append([i+1, s, p])
"""
list.append([1, "test2", 3])
list.append([2, "test3", 1])
list.append([3, "test1", 5])
list.append([4, "test1", 4])
"""

list.sort(key=lambda x:(x[1],x[2]))
for l in list:
    print(l[0])


### FIXED CODE ###


n = int(input())
list = []

for i in range(n):
    sp = input().split()
    s = str(sp[0])
    p = int(sp[1])
    list.append([i+1, s, p])

list.sort(key=lambda x:(x[1],-x[2]))
for l in list:
    print(l[0])
N_s = input()
N = int(N_s)
ans = 0
for i in range(1, len(N_s)):
	if i % 2 == 1:
    	ans += 10**i - 10**(i - 1)
if len(N_s) % 2 == 1:
  	ans += 1 - 10**(len(N_s)-1) + N
print(ans)

### FIXED CODE ###

n = int(input())
cnt = 0
for i in range(1, n + 1):
  if len(str(i)) % 2 == 1:
    cnt +=1
print(cnt)
n=input()
satis=[]

for i in range(n):
  satis += list(map(int,input().split()))

tempA=satis[0]
tempB=satis[1]
tempC=satis[2]
if n > 1:
  for i in range(n-1):
    tempA2=satis[3*i+3]+max([tempB,tempC])
    tempB2=satis[3*i+4]+max([tempA,tempC])
    tempC2=satis[3*i+5]+max([tempA,tempB])
    tempA=tempA2
    tempB=tempB2
    tempC=tempC2
  print(max([tempA,tempB,tempC]))
else:
  print(max([tempA,tempB,tempC]))

### FIXED CODE ###

n=int(input())
satis=[]

for i in range(n):
  A=list(map(int,input().split()))
  satis.extend(A)

tempA=satis[0]
tempB=satis[1]
tempC=satis[2]
if n > 1:
  for i in range(n-1):
    tempA2=satis[3*i+3]+max([tempB,tempC])
    tempB2=satis[3*i+4]+max([tempA,tempC])
    tempC2=satis[3*i+5]+max([tempA,tempB])
    tempA=tempA2
    tempB=tempB2
    tempC=tempC2
  print(max([tempA,tempB,tempC]))
else:
  print(max([tempA,tempB,tempC]))
def main():
    antenna = []
    for i in range(5):
        antenna.append(int(raw_input()))
    k = int(raw_input())
    if (antenna[-1] - antenna[0]) < k:
        print("yes")
    else:
        print("no")



if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    antenna = []
    for i in range(5):
        antenna.append(int(raw_input()))
    k = int(raw_input())
    if (antenna[-1] - antenna[0]) <= k:
        print("Yay!")
    else:
        print(":(")



if __name__ == "__main__":
    main()
b = input()
if b = A:
    print(T)
elif b = C:
    print(G)
elif b = G:
    print(C)
else:
    print(A)            


### FIXED CODE ###

b = input('')
if b == 'A':
    print('T')
elif b == 'C':
    print('G')
elif b == 'G':
    print('C')
else:
    print('A')