Harryxun/stf_run huggingface dataset:
class Vector2:
    """
    A simple 2D vector class.
    @Author:whitestone0811(Vir_MeL0)
    """
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __add__(self,other):
        return Vector2(self.x+other.x,self.y+other.y)
    def __sub__(self,other):
        return Vector2(self.x-other.x,self.y-other.y)
    def __mul__(self,other):
        if isinstance(other, Vector2):
            return self.x*other.x+self.y*other.y
        else:
            return Vector2(self.x*other,self.y*other)
    def __rmul__(self,other):
        if not isinstance(other,Vector2):
            return Vector2(self.x*other,self.y*other)
    def abs(self):
        return (self.x**2+self.y**2)**0.5
    def cos(self,other):
        return (self*other)/(self.abs()*other.abs())
    def __str__(self):
        return "[{0},{1}]".format(self.x,self.y)
    def __neg__(self):
        return Vector2(-self.x,-self.y)
#    
_in=input()
while _in!='':
    cors=[float(cor)for cor in _in.split(',')]
    vAB=Vector2(cors[2]-cors[0],cors[3]-cors[1])
    vBC=Vector2(cors[4]-cors[2],cors[5]-cors[3])
    vCD=Vector2(cors[6]-cors[4],cors[7]-cors[5])
    vDA=Vector2(cors[0]-cors[6],cors[1]-cors[7])
    cnv_a=True if(vAB-vDA)*(vAB+vBC)>0 else False
    cnv_b=True if(vBC-vAB)*(vBC+vCD)>0 else False
    cnv_c=True if(vCD-vBC)*(vCD+vDA)>0 else False
    cnv_d=True if(vDA-vCD)*(vDA+vAB)>0 else False
    print("YES" if cnv_a and cnv_b and cnv_c and cnv_d else "NO")
    _in=input()

### FIXED CODE ###

class Vector2:
    """
    A simple 2D vector class.
    @Author:whitestone0811(Vir_MeL0)
    """
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __add__(self,other):
        return Vector2(self.x+other.x,self.y+other.y)
    def __sub__(self,other):
        return Vector2(self.x-other.x,self.y-other.y)
    def __mul__(self,other):
        if isinstance(other, Vector2):
            return self.x*other.x+self.y*other.y
        else:
            return Vector2(self.x*other,self.y*other)
    def __rmul__(self,other):
        if not isinstance(other,Vector2):
            return Vector2(self.x*other,self.y*other)
    def abs(self):
        return (self.x**2+self.y**2)**0.5
    def cos(self,other):
        return (self*other)/(self.abs()*other.abs())
    def __str__(self):
        return "[{0},{1}]".format(self.x,self.y)
    def __neg__(self):
        return Vector2(-self.x,-self.y)
#  
import sys  
lines=sys.stdin
for _in in lines:
    cors=[float(cor)for cor in _in.split(',')]
    vAB=Vector2(cors[2]-cors[0],cors[3]-cors[1])
    vBC=Vector2(cors[4]-cors[2],cors[5]-cors[3])
    vCD=Vector2(cors[6]-cors[4],cors[7]-cors[5])
    vDA=Vector2(cors[0]-cors[6],cors[1]-cors[7])
    cnv_a=True if(vAB-vDA)*(vAB+vBC)>0 else False
    cnv_b=True if(vBC-vAB)*(vBC+vCD)>0 else False
    cnv_c=True if(vCD-vBC)*(vCD+vDA)>0 else False
    cnv_d=True if(vDA-vCD)*(vDA+vAB)>0 else False
    print("YES" if cnv_a and cnv_b and cnv_c and cnv_d else "NO")
def solve(a,b,c):
    li = [a,b,c]
    cf = 0
    cs = 0
    for i in li:
        if i == 5:
            cf +=1
        if i==7:
            cs +=1
    if cf == 2 and cs ==1:
        return YES
    else:
        return NO
            
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c))

def main():
    a, b, c = readQuestion()
    answer = solve(a, b, c)
    print(answer)
    
if __name__ == '__main__':
    main()    

### FIXED CODE ###

import sys

def solve(a,b,c):
    li = [a,b,c]
    cf = 0
    cs = 0
    for i in li:
        if int(i) == 5:
            cf +=1
        if int(i) == 7:
            cs +=1
    if cf == 2 and cs ==1:
        return 'YES'
    else:
        return 'NO'
            
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c))

def main():
    a, b, c = readQuestion()
    answer = solve(a, b, c)
    print(answer)
    
if __name__ == '__main__':
    main()
N=int(input())
if N%10==3:
  print("bon")
else if N%10==0:
  print("pon")
else if N%10==1:
  print("pon")
else if N%10==6:
  print("pon")
else if N%10==8:
  print("pon")
else:
  print("hon")

### FIXED CODE ###

N=int(input())
for i in range(1):
  if N%10==3:
    print("bon")
    break
  if N%10==0:
    print("pon")
    break
  if N%10==1:
    print("pon")
    break
  if N%10==6:
    print("pon")
    break
  if N%10==8:
    print("pon")
    break
  print("hon")
# import sys
# sys.setrecursionlimit(2000)

N = int(input())
COR = [tuple((map(int, input().split()))) for _ in range(N)]


class Group:
    
    def __init__(self):
        self.n = 0
        self.x = []
        self.y = []
        
    def new_cor_n(self):
        if self.n <= 2:
            return 0
        s = len(self.x) * len(self.y) - self.n
        if s < 0:
            s = 0
        return 0


def grouping_y(group, y, xcor, ycor):
    ycor[y][1] = True
    group.y.append(y)
    for x in ycor[y][0]:
        if xcor[x][1]:
            continue
        group.n += 1
        grouping_x(group, x, xcor, ycor)
        
def grouping_x(group, x, xcor, ycor):
    xcor[x][1] = True
    group.x.append(x)
    for y in xcor[x][0]:
        if ycor[y][1]:
            continue
        group.n += 1
        grouping_y(group, y, xcor, ycor)
    
if N <= 2:
    print(0)
else:
    xcor, ycor = {}, {}
    for xi, yi in COR:
        if xi in xcor:
            xcor[xi][0].append(yi)
        else:
            xcor[xi] = [[yi], False]
        if yi in ycor:
            ycor[yi][0].append(xi)
        else:
            ycor[yi] = [[xi], False]
    group_list = []
    for x, v in xcor.items():
        if v[1]:
            continue
        group = Group()
        group_list.append(group)
        grouping_x(group, x, xcor, ycor)
    s = 0
    for group in group_list:
        s += group.new_cor_n()
    print(s)

### FIXED CODE ###

# import sys
# sys.setrecursionlimit(20000)


N = int(input())
COR = [tuple((map(int, input().split()))) for _ in range(N)]


class Group:
    
    def __init__(self):
        self.n = 0
        self.x = 0
        self.y = 0
        self.xy = {}
        
    def new_cor_n(self):
        return self.x * self.y - self.n
        

def grouping(group, x, xcor, ycor):
    x_list = []
    group.x += 1
    for y in xcor[x][0]:
        if (x, y) not in group.xy:
            group.n += 1
            group.xy[(x, y)] = None
        if ycor[y][1]:
            continue
        ycor[y][1] = True
        group.y += 1
        for x_ in ycor[y][0]:
            if (x_, y) not in group.xy:
                group.n += 1
                group.xy[(x_, y)] = None
            if xcor[x_][1]:
                continue
            xcor[x_][1] = True
            x_list.append(x_)
    return x_list

if N <= 2:
    print(0)
else:
    xcor, ycor = {}, {}
    for xi, yi in COR:
        if xi in xcor:
            xcor[xi][0].append(yi)
        else:
            xcor[xi] = [[yi], False]
        if yi in ycor:
            ycor[yi][0].append(xi)
        else:
            ycor[yi] = [[xi], False]
    group_list = []
    for i, v in xcor.items():
        if v[1]:
            continue
        group = Group()
        group_list.append(group)
        xcor[i][1] = True
        x_list = [i]
        while True:
            new_x_list = []
            for x in x_list:
                new_x_list += grouping(group, x, xcor, ycor)
            if new_x_list == []:
                break
            x_list = new_x_list
    s = 0
    for group in group_list:
        s += group.new_cor_n()
    print(s)
# coding: utf-8

import codecs
import sys

sys.stdout = codecs.getwriter("shift_jis")(sys.stdout) # ??????
sys.stdin = codecs.getreader("shift_jis")(sys.stdin) # ??\???

# ??\??¬?????????print??????????????´?????? print(u'?????????') ??¨??????
# ??\??¬?????????input??? input(u'?????????') ??§OK
# ??°?¢???????????????????????????´??????6,7???????????????????????¢??????

a = []
while True:
	n = input()
	if n == -1:
		break
	a.append(n)

#a = [0,5,2,3,4,1]

a.sort()
a.reverse()

print a[0]
print a[1]
print a[2]

### FIXED CODE ###

# coding: utf-8

import codecs
import sys

sys.stdout = codecs.getwriter("shift_jis")(sys.stdout) # ??????
sys.stdin = codecs.getreader("shift_jis")(sys.stdin) # ??\???

# ??\??¬?????????print??????????????´?????? print(u'?????????') ??¨??????
# ??\??¬?????????input??? input(u'?????????') ??§OK
# ??°?¢???????????????????????????´??????6,7???????????????????????¢??????

a = []
for i in range(10):
	n = input()
	a.append(n)

#a = [0,5,2,3,4,1]

a.sort(reverse=True)

print a[0]
print a[1]
print a[2]
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem D

if __name__ == '__main__':
    from bisect import bisect_left
    from bisect import bisect_right
    from itertools import combinations

    n = int(input())
    a = list(map(int, input().split()))
    a_max = max(a)
    a.remove(a_max)
    a = sorted(a)

    if max(a) == 0:
        print(str(a_max) + ' ' + str(a[0]))
        exit()

    left = bisect_left(a, a_max // 2)
    right = n - bisect_right(a, a_max // 2)
    a_right = combinations(range(1, a_max + 1), a[right])
    a_left = combinations(range(1, a_max + 1), a[left])

    if len(list(a_left)) > len(list(a_right)):
        print(str(a_max) + ' ' + str(a[left]))
    else:
        print(str(a_max) + ' ' + str(a[right]))


### FIXED CODE ###

# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem D

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    a_max = max(a)
    a.remove(a_max)
    a = sorted(a)

    # See:
    # https://www.youtube.com/watch?v=RwWljbtCrPA
    # https://img.atcoder.jp/arc095/editorial.pdf
    diff = float('inf')
    center = 0

    for ai in a:
        current_diff = abs(a_max / 2 - ai)

        if current_diff < diff:
            diff = current_diff
            center = ai

    print(str(a_max) + ' ' + str(center))
import sys
def input():
	return sys.stdin.readline().strip()

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(N):
	A[i] = -A[i]

heapq.heapify(A)


for i in range(M):
	x = heapq.heappop(A)
	x /= 2
	x = heapq.heappush(A, x)

total = 0
for i in range(N):
	total -= math.ceil(A[i])

print(total)




### FIXED CODE ###

import math
import heapq
from itertools import product, permutations,combinations

import sys
def input():
	return sys.stdin.readline().strip()

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(N):
	A[i] = -A[i]

heapq.heapify(A)


for i in range(M):
	x = heapq.heappop(A)
	x /= 2
	x = heapq.heappush(A, x)

total = 0
for i in range(N):
	total -= math.ceil(A[i])

print(total)
s = input()

a = a.count('+')
b = a.count('-')

x = a - b

print(x)

### FIXED CODE ###

s = input()

a = s.count('+')
b = s.count('-')

x = a - b

print(x)
from sys import stdin
import sys

a,b = [int(x) for x in stdin.readline().rstrip().split()]
print(a*(b*100)/100)

### FIXED CODE ###

from sys import stdin
import sys

a, b = [x for x in stdin.readline().rstrip().split()]
a = int(a)
b = int(b.replace('.',''))

print(a * b  // 100)
a,b,c=0,1,2
one,zero=1,0
x,y=5,6
pi,pj=7,8
z=9
p(a,b,one);l(zero,one,one)
def p(i,j,k):print("+",i,j,k)
def l(i,j,k):print("<",i,j,k)
def s(i,j):
    for k in range(j):p(i,i,i)
for i in range(29,0,-1):
    p(one,zero,pi);s(pi,i)
    p(x,pi,pi);l(a,pi,pi);l(pi,one,pi)
    p(one,zero,y)
    for j in range(29,0,-1):
        p(one,zero,pj);s(pj,j)
        p(y,pj,pi);l(b,pj,pj);l(pj,one,pj)
        l(pi,pj,z);l(z,pj,z);s(z,i+j);p(c,z,c)
        s(pj,j);p(y,pj,y)
    s(pi,i);p(x,pi,x)

### FIXED CODE ###

a,b,c=0,1,2
one,zero=3,4
x,y=5,6
pi,pj=7,8
z=9
def p(i,j,k):print("+",i,j,k)
def l(i,j,k):print("<",i,j,k)
def s(i,j):
    for k in range(j):p(i,i,i)
print(60452)
p(a,b,one);l(zero,one,one)
for i in range(29,-1,-1):
    p(one,zero,pi);s(pi,i)
    p(x,pi,pi);l(a,pi,pi);l(pi,one,pi)
    p(zero,zero,y)
    for j in range(29,-1,-1):
        p(one,zero,pj);s(pj,j)
        p(y,pj,pj);l(b,pj,pj);l(pj,one,pj)
        l(pi,pj,z);l(z,pj,z);s(z,i+j);p(c,z,c)
        s(pj,j);p(y,pj,y)
    s(pi,i);p(x,pi,x)
n, k = map(int, input().split())
h = list(map(int, input().split()))

inf = 1e18
dp = [inf] * (n + 10)
dp[0] = 0
for i in range(1, n):
    for j in range(1, k + 1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
print(dp[n - 1])


### FIXED CODE ###

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

dp = [0] * (n + 10)
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[n - 1])
j,f,h,m=map(int,input().split())
df=6*m
dh=m/2+30*h
d=0
if df>dh:
  d=df-dh
else:
  d=dh-df
l=(j**2+f**2-2*j*f*math.cos(math.radians(d)))
print(l)

### FIXED CODE ###

import math
j,f,h,m=map(int,input().split())
df=6*m
dh=m/2+30*h
d=0
if df>dh:
  d=df-dh
else:
  d=dh-df
l=(j**2+f**2-2*j*f*math.cos(math.radians(d)))**0.5
print(l)
a,b,c = list(map(int, input().split()))
print("A"+ b[0]+ "C")

### FIXED CODE ###

a,b,c = input().split()
print("A"+ b[0]+ "C")
N, A, B = map(int, input().split())

counter = [0 for _ in range(N)]
ans = 0

for i in range(N):
    string = str(i)
    for j in range(len(string)):
        counter[i] += string[j]

for i in range(N):
    if(counter[i]<=B && counter[i]>=A):
        ans += i

print(ans)

### FIXED CODE ###

N, A, B = map(int, input().split())
ans = 0

for i in range(1, N+1):
    num_sum = 0
    for j in str(i):
        num_sum += int(j)
    if A<= num_sum <= B:
        ans += i

print(ans)
a,b = int(input()), int(input())
print(max(a + b, a + a - 1, b + b - 1))

### FIXED CODE ###

a,b=map(int,input().split())
print(max(a+b,2*a-1,2*b-1))
k, n = map(int, input())
l = list(map(int, input()))
maxi = [k-l[-1]+l[0]]
for i in range(1, n):
  maxi = max(l[i] - l[i-1], maxi)
print(k-maxi)

### FIXED CODE ###

k, n = map(int, input().split())
l = list(map(int, input().split()))
maxi = k-l[-1]+l[0]
for i in range(1, n):
    maxi = max(l[i] - l[i-1], maxi)
print(k-maxi)
from sys import stdin


def increment_left(li, As):
    while True:
        if As[li] < As[li + 1]:
            li += 1
            continue
        break
    return li


def decrement_right(ri, As):
    while True:
        if As[ri] > As[ri - 1]:
            ri -= 1
            continue
        break
    return ri


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    result = 0
    li = 0
    ri = N - 1
    while True:
        li = increment_left(li, As)
        ri = decrement_right(ri, As)
        if ri <= li:
            result += 1
            break
        if As[li] < As[ri]:
            result += 1
        else:
            result += 2
        li += 1
        ri -= 1
        if ri <= li:
            break
    print(result)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import bisect
from collections import deque
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    As = [int(stdin.readline().rstrip()) for x in range(N)]
    dq = deque([])
    for A in As:
        idx = bisect.bisect_left(dq, A)
        if idx == 0:
            dq.appendleft(A)
        else:
            dq[idx - 1] = A
    print(len(dq))


if __name__ == "__main__":
    main()
n = int(input())
S = ['S']
H = ['H']
C = ['C']
D = ['D']
for i in range(0, n):
 x = list(input().split())
 if x[0] == 'S':
  S.append(int(x[1]))
 elif x[0] == 'H':
  H.append(int(x[1]))
 elif x[0] == 'C':
  C.append(int(x[1]))
 else:
  D.append(int(x[1]))
def print(list):
 list.sort()
 for i in range(1, 14):
  if i not in list:
   print("{0} {1}".format(list[0], i))
   print()
print(S)
print(H)
print(C)
print(D)
 

### FIXED CODE ###

n = int(input())
S = []
H = []
C = []
D = []
for i in range(0, n):
 x = list(input().split())
 if x[0] == 'S':
  S.append(int(x[1]))
 elif x[0] == 'H':
  H.append(int(x[1]))
 elif x[0] == 'C':
  C.append(int(x[1]))
 else:
  D.append(int(x[1]))
def pr(list, type):
 list.sort()
 for i in range(1, 14):
  if i not in list:
   print("{0} {1}".format(type, i))
pr(S, 'S')
pr(H, 'H')
pr(C, 'C')
pr(D, 'D')
n,k = map(int,input().split())

if k > (n-1)*(n-2)//2:
  print(-1)
  exit()
    
m = (n-1)*(n-2)//2+(n-1)-k
print(m)
for i in range(n-1):
  print(1,2+i)
    
if m > n-1:
  c = m-(n-1)
  for i in range(1,n-1):
    if c == 0:
        break
    for j in range(2,n-i+1):
      print(j,j+i)
      cnt -= 1
      if c == 0:
        break

### FIXED CODE ###

n,k = map(int,input().split())
if n == 2 and k == 0:
  print(1)
  print(1,2)
  exit()
  
if k > (n-1)*(n-2)//2 or n == 2:
  print(-1)
  exit()
  
if n == 3:
  if k == 1:
    print(2)
    print(1,2)
    print(2,3)
  elif k == 0:
    print(3)
    print(1,2)
    print(2,3)
    print(3,1)
  else:
    print(-1)
  exit()
    
m = (n-1)*(n-2)//2+(n-1)-k
print(m)
for i in range(n-1):
  print(1,2+i)
for i in range(min(n-1,m-n+1)):
  if 3+i > n:
    print(2+i,2)
  else:
    print(2+i,3+i)
    
if m > (n-1)*2:
  cnt = m-(n-1)*2
  for i in range(2,n-2):
    if cnt == 0:
        break
    for j in range(2,n-i+1):
      print(j,j+i)
      cnt -= 1
      if cnt == 0:
        break
n,m,p=map(int,input().split())
A=[]
for i in range(m):
    a,b,c=map(int,input().split())
    A.append((a,b,p-c))

def BellmanFord(edges,num_v,source):
    #グラフの初期化
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0
  
    #辺の緩和
    buf=0
    for i in range(num_v*2):
        for edge in edges:
            if dist[edge[0]] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                if i>=num_v:
                    dist[edge[1]-1] =-inf
        if i==num_v-2:
            buf=dist[-1]
    if dist[-1]!=buf or dist[-1]==inf:
        return False
    return dist[-1]*-1

x=BellmanFord(A,n,1)
if x==False:
    print(-1) 
else:
    print(x if x>0 else 0)

### FIXED CODE ###

"""解説を見てから解いたコード"""
N, M, P = map(int, input().split())
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a, b, c-P))

INF = float('inf')

coin_map = [-INF] * (N+1)
coin_map[1] = 0

for i in range(2*N):
    for a, b, c in edges:
        if coin_map[b] < coin_map[a] + c:
            coin_map[b] = coin_map[a] + c
            if i >= N:
                coin_map[b] = INF

    if i == N - 1:
        ans = coin_map[N]

if ans != coin_map[N]:
    print(-1)
else:
    print(max(0, coin_map[N]))
import math

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

if x > (a*a*b)/2:
    h = (2*x)/(a*a)-b
    kaku = 90 - math.degrees(math.atan(a/(b-h)))
    print(kaku)
else:
    h = (2*x)/(a*b)
    kaku = 90 - math.degrees(math.atan(h/b))
    print(kaku)

### FIXED CODE ###

import math

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

if x == (a*a*b):
    print("0")
elif x > (a*a*b)/2:
    h = (2*x)/(a*a)-b
    kaku = 90 - math.degrees(math.atan(a/(b-h)))
    print(kaku)
else:
    h = (2*x)/(a*b)
    kaku = 90 - math.degrees(math.atan(h/b))
    print(kaku)
while True:
    m, n = (int(s) for s in input().split())
    if not m:
        break

    objs = [int(input(), 2) for i in range(n)]
    dp = [[0] * (1<<m) for i in range(1 << m)]
    bits = [1 << i for i in range(m)]

    for mask in reversed(range(1 << m)):
        s = Counter(obj & mask for obj in objs)
        for mask0, value in s.items():
            if value > 1:
                dp[mask][mask0] = min(max(dp[mask | b][mask0],
                                          dp[mask | b][mask0 | b]) + 1
                                      for b in bits if not b & mask)
    print(dp[0][0])

### FIXED CODE ###

from collections import Counter

while True:
    m, n = (int(s) for s in input().split())
    if not m:
        break

    objects = [int(input(), 2) for i in range(n)]
    dp = [bytearray(1 << m) for i in range(1 << m)]
    bits = [1 << i for i in range(m)]

    for asked in reversed(range((1 << m) - 1)):
        for masked, count in Counter(obj & asked for obj in objects).items():
            if count > 1:
                dp[asked][masked] = min(max(dp[asked + b][masked],
                                            dp[asked + b][masked + b])
                                        for b in bits if not b & asked) + 1
    print(dp[0][0])
import sys
args = sys.argv

if(args == "ABC"){
print("ARC")
}elif(args=="ARC"){
print("ABC")
}


### FIXED CODE ###

args = input()
if args == "ABC":
 print("ARC")
elif(args=="ARC"):
 print("ABC")
a,b,c=map(int, input().split())
if (a*b)%2==0:
  print('Even')
  esle:
    print('odd')

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2==0:
  print("Even")
else:
  print("Odd")
N,M,Q = map(int,input().split())
li = []
counter = 0
n = []
for s in range(Q):
  li.append(list(map(int,input().strip())))

for i in range(10**(N-1),10**N):
  k = str(i)
  for q in range(Q):
    if k[li[q][1]] -  k[li[q][0]] ==  k[li[q][2]]:
      counter +=  k[li[q][3]]
    n.append(counter)
    counter = 0
print(max)

### FIXED CODE ###

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

li = [list(map(int,input().split())) for i in range(Q) ]

from itertools import combinations_with_replacement
counter = []

for comb in combinations_with_replacement(range(1,M+1),N):
    A = list(comb)
    tmp = 0
   
    for i in li:
        if A[i[1]-1] - A[i[0]-1] == i[2]:
            tmp += i[3]

    counter.append(tmp)


print(max(counter))
n=int(input())
s=input()
count=0
for i in range(len(s)):
    if s[i]=="A":
        if s[i+1]=="B":
            if s[i+2]=="C":
                count+=1
print(count)


### FIXED CODE ###

n=int(input())
s=input()
count=0
for i in range(n):
    if s[i]=="A":
        if i+1<n and s[i+1]=="B":
            if i+2<n and s[i+2]=="C":
                count+=1
print(count)
#D
import queue
H,W=map(int,input().split())
P=[0 for i in range(H)]
for i in range(H):
    P[i]=str(input())

ans=0
for i in range(H*W):
    s=(i%W,i//W)
    if P[s[0]][s[1]]=="#":
        continue
    st=queue.Queue()
    st.put(s)
    log=[[-1 for i in range(W)] for j in range(H)]
    log[s[0]][s[1]]=0
    while not st.empty():
        x,y=st.get()
        for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
            if not (0<=z and 0<=w):
                continue
            elif not (z<W and w<H):
                continue
            elif P[z][w]=="." and log[z][w]==-1:
                st.put((z,w))
                log[z][w]=log[x][y]+1
                ans=max(ans,log[z][w])
print(ans)

### FIXED CODE ###

#D
import queue
H,W=map(int,input().split())
P=[0 for i in range(H)]
for i in range(H):
    P[i]=str(input())
ans=0
for i in range(H*W):
    s=(i//W,i%W)
    if P[s[0]][s[1]]=="#":
        continue
    st=queue.Queue()
    st.put(s)
    log=[[-1 for i in range(W)] for j in range(H)]
    log[s[0]][s[1]]=0
    while not st.empty():
        y,x=st.get()
        for z,w in [(y+1,x),(y-1,x),(y,x+1),(y,x-1)]:
            if 0>z or 0>w:
                continue
            elif z>=H or w>=W:
                continue
            elif P[z][w]=="." and log[z][w]==-1:
                st.put((z,w))
                log[z][w]=log[y][x]+1
                ans=max(ans,log[z][w])
print(ans)
n,l=map(int,input().split())

k=[]

for i in range(n):
  s=input()
  k.append(s)

x=sort(k)
z="".join(x)

print(z)
  

### FIXED CODE ###

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

k=[]

for i in range(n):
  s=input()
  k.append(s)

x=sorted(k)
z="".join(x)

print(z)