akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int l[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;
  cin >> K;
  cout << l[K - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  vector<int> d;
  int n,m;
  cin>>n>>m;
  for(int i=0;i<2*n;i++)d.push_back(i+1);
  for(int i=0;i<m;i++){
    int k;
    cin>>k;
    if(k==0){
      vector<int> tmp[3];
      for(int j=0;j<n;j++)tmp[0].push_back(d[j]);
      for(int j=0;j<n;j++)tmp[1].push_back(d[j+n]);
      for(int j=0;j<n;j++){
	tmp[2].push_back(tmp[0][j]);
	tmp[2].push_back(tmp[1][j]);
      }
      d=tmp[2];
    }else{
      vector<int> tmp;
      for(int j=0;j<2*n-k;j++)tmp.push_back(d[k+j]);
      for(int j=0;j<k;j++)tmp.push_back(d[j]);
      d=tmp;
    }
  }
  for(int i=0;i<2*n;i++){
    cout<<d[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
using System;
using System.Collections.Generic;
using System.Linq;
public class Pg
{
    static void Main()
    {
        var rd = Console.ReadLine();
        var ck = new Checker();
        Console.WriteLine(ck.GetParenth(rd));

    }
}
class Checker
{
    internal int GetParenth(string n)
    {
        int num = 0;
        foreach (var v in n)
        {
            if (v == '*')
            {
                num = n.IndexOf(v);
                break;
            }
        }
        int ans = 0;
        for (int i = 0; i < num; ++i)
        {
            if (n[i]=='(')
            {
                ans += 1;
            }
            else
            {
                ans -= 1;
            }
        }
        return ans;
    }
}


Measured memory_bytes: 17936
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,l;
	cin >> n;
	vector<ll> a(n);
	for(ll i = 0; i < n; i++) {
		cin >> l;
		a[i] = l - i + 1;
	}
	sort(ALL(a));
	ll b = a[n / 2];
	ll ans = 0;
	for(ll i = 0; i < n; i++) {
		ans += abs(a[i] - b);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>

using namespace std;

int main()
{
  uint32_t N;
  cin >> N;
  for(uint32_t A = 1; A <= 9; A++){
    for(uint32_t B = 1; B <= 9; B++){
        if((A * B) == N){
            cout << "Yes" << endl;
            return 0;
        }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
def partition(A,p,n):
    x=A[n-1]
    i=p-1
    for j in range(n-1):
        if A[j]<=x:
            i+=1
            A[i],A[j]=A[j],A[i]
    A[i+1],A[n-1]=A[n-1],A[i+1]
    
    A[i+1]="[{}]".format(A[i+1])
    
    print(*A)
    

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

partition(A,0,n)

Measured memory_bytes: 18196
a = input()
b = input()
c = input()
t = 0
x,y,z = 0,0,0
while True:
	if t == 0:
		if x == len(a):
			print('A')
			quit()
		if a[x] == 'a':
			t = 0
		elif a[x] == 'b':
			t = 1
		elif a[x] == 'c':
			t = 2
		else:
			t = (t+1)%3
		x += 1
	elif t == 1:
		if y == len(b):
			print('B')
			quit()
		if b[y] == 'a':
			t = 0
		elif b[y] == 'b':
			t = 1
		elif b[y] == 'c':
			t = 2
		else:
			t = (t+1)%3
		y += 1
	elif t == 2:
		if z == len(c):
			print('C')
			quit()
		if c[z] == 'a':
			t = 0
		elif c[z] == 'b':
			t = 1
		elif c[z] == 'c':
			t = 2
		else:
			t = (t+1)%3
		z += 1
	

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;

void input(string& rsColor)
{
  cin >> rsColor;
}

int fnChangeCnt(string sBgnColor, string sColor)
{
  int nChangeCnt = 0;

  for (int i = 0; i < sColor.size(); i++)
  {
    int n = i % 2;
    if (sColor[i] != sBgnColor[n]) nChangeCnt++;
  }
  return nChangeCnt;
}

int calcMinChangeCnt(string sColor)
{
  int nMinChangeCnt = INT_MAX;
  nMinChangeCnt = min(nMinChangeCnt, fnChangeCnt("01", sColor));
  nMinChangeCnt = min(nMinChangeCnt, fnChangeCnt("10", sColor));

  return nMinChangeCnt;
}
 
int main()
{
  string sColor;
  input(sColor);
  cout << calcMinChangeCnt(sColor) << endl;

  return 0;
}

Measured memory_bytes: 3848
#include<iostream> 
using namespace std;

int gcd(int x, int y){
    if (y>x) swap(x,y);
    while(x%y!=0){
        int b = x;
        x = y;
        y = b%y;
    }
    return y;
}

int main(){
    int a,b;
    cin >> a >> b;
    cout << gcd(a,b) << endl;
}


Measured memory_bytes: 3084
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
sum = 0
smallnum = 10

listX = [A, B, C, D, E]

for i in listX:
    if i % 10 == 0:
        sum += i
    else:
        if i % 10 < smallnum:
            smallnum = i % 10
        sum += (10 + i - i%10)

print(sum + smallnum - 10)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int ans,i;
	int N;
	scanf("%d",&N);
	int A[N+1];
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	A[N] = 0;
	int sum = abs(A[0]);
	for(i=0;i<N;i++){
		sum += abs(A[i+1] - A[i]);
	}
	printf("%d\n",sum-abs(A[0])-abs(A[0]-A[1])+abs(A[1]));
	for(i=1;i<N;i++){
		ans = sum;
		ans -= abs(A[i+1]-A[i]);
		ans -= abs(A[i]-A[i-1]);
		ans += abs(A[i+1]-A[i-1]);
		printf("%d\n",ans);
	}
	return 0;}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b){
        ll t=a;
        a=b;
        b=t;
    }
    if((b-a)%2==0)
    cout<<(b-a)/2;
    else
    cout<<min(a-1,n-b)+(b-a+1)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

ll N;
string S;

void solve(){
    if(N % 2 != 0) { cout << "No"; return; }
    for(ll i = 1; i <= N / 2; i++){
        if(S[i - 1] != S[N / 2 + i - 1]) { cout << "No"; return; }
    }
    cout << "Yes";
}
int main(){
    cin >> N >> S;
    solve();
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import heapq

H,W=map(int,raw_input().split())

#隣接リスト
c=[[] for i in range(10)]
for i in range(10):
	a=map(int,raw_input().split())
	for j in range(10):
		c[i].append(a[j])

#print c

A=[]
for i in range(H):
	A.append(map(int, raw_input().split()))
#print A


def djk(n):
	#開始位置
	Start=n

	#初期化
	d=[-1 for i in range(10)]
	d[Start]=0


	#優先度付きキューに[距離,頂点の番号]を格納する
	#スタート地点の頂点1には距離0を入れる
	q=[]
	heapq.heappush(q, [0,Start])

	while len(q)!=0:
		#距離が最小の頂点を取り出し
		l,u=heapq.heappop(q)
		for i,val in enumerate(c[u]):
			v=i
			l_u_v=val
			#print v, l_u_v
			if (d[v]>d[u]+l_u_v) or d[v]==-1:
				d[v]=d[u]+l_u_v
				heapq.heappush(q, [d[v],v])
	return d[1]


sum=0
temp=[0 for i in range(10)]
for i in range(H):
	for j in range(W):
		if A[i][j]==-1 or A[i][j]==1:
			continue
		else:
			if temp[A[i][j]]==0:
				temp[A[i][j]]=djk(A[i][j])
			sum+=temp[A[i][j]]

print sum


Measured memory_bytes: 3072
import math
N, K = map(int, input().split())
x = list(map(int, input().split()))
for i in range(N):
  if x[i] == 0:
    p, m = i, i+1
    break
  elif x[i] > 0:
    p, m = i, i
    break
    
if (x[0]<0) and (x[-1]>0):
  pls = x[p:]
  mns = x[:m]
  ans = math.inf

  for i in range(len(pls)):
    if i < K-1:
      if pls[0] == 0:
        n = K - i
      else:
        n = K - i - 1
      if len(mns) >= n:
        tmp = 2*abs(mns[-n]) + pls[i]
        ans = min(ans, tmp)
    if i == K-1:
      ans = min(ans, pls[i])
      break
    
  for i in range(len(mns)):
    m = len(mns)-i
    if m < K:
      if pls[0] == 0:
        n = K - m
      else:
        n = K - m - 1
      if len(pls) > n:
        tmp = 2*pls[n] + abs(mns[-m])
        ans = min(ans, tmp)
    if m == K:
      ans = min(ans, abs(mns[i]))
    
elif x[0] >= 0:
  ans = x[K-1]
  
else:
  ans = abs(x[-K])
  
print(ans)

Measured memory_bytes: 20196
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int n;cin >>n;
    V a(n);
    V c(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        c[i]=a[i];
    }
    sort(all(c));
    int mx=c.back();
    int se=c[n-2];
    for (int i = 0; i < n; ++i) {
        if(a[i]==mx)cout <<se<<endl;
        else cout <<mx<<endl;
    }
}



Measured memory_bytes: 4844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}

int len(ll n) {
    int i = 1;
    ll deg = 10;
    while (deg <= n) {
        ++i;
        deg *= 10;
    }
    return i;
}


void oneCase () {
    ll n;
    cin >> n;
    int best = len(n);
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            best = min(best, len(n / i));
        }
    }
    cout << best << "\n";
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int h, w;
    int dp[50][50];
    char area[50][50];
    cin >> h >> w;
    for (int y=0; y<h; y++) {
        for (int x=0; x<w; x++) {
            cin >> area[x][y];
        }
        cin.ignore();
    }
    dp[0][0] = area[0][0]-'0';
    for (int y=1; y<h; y++) {
        dp[0][y] = dp[0][y-1]+area[0][y]-'0';
    }
    for (int x=1; x<w; x++) {
        dp[x][0] = dp[x-1][0]+area[x][0]-'0';
    }
    for (int y=1; y<h; y++) {
        for (int x=1; x<w; x++) {
            dp[x][y] = min(dp[x-1][y], dp[x][y-1])+area[x][y]-'0';
        }
    }
    cout << dp[w-1][h-1] << endl;
    return 0;
}

Measured memory_bytes: 1172
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[M];
    int[] B = new int[M];
    for (int i = 0; i < M; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    int[] C = new int[K];
    int[] D = new int[K];
    for (int i = 0; i < K; i++) {
      C[i] = sc.nextInt();
      D[i] = sc.nextInt();
    }
    sc.close();

    Map<Integer, Set<Integer>> f = new HashMap<>();
    for (int i = 0; i < M; i++) {
      Integer a = Integer.valueOf(A[i]);
      Integer b = Integer.valueOf(B[i]);
      if (!f.containsKey(a)) f.put(a, new HashSet<>());
      if (!f.containsKey(b)) f.put(b, new HashSet<>());
      f.get(a).add(b);
      f.get(b).add(a);
    }

    int[] gn = new int[N + 1];
    int[] gc = new int[N + 1];
    for (int i = 1; i < N + 1; i++) {
      Deque<Integer> q = new ArrayDeque<>();
      q.addLast(i);
      while (!q.isEmpty()) {
        int n = q.pollLast();
        if (gn[n] != 0) continue;
        gn[n] = i;
        gc[i]++;
        q.addAll(f.getOrDefault(n, Collections.emptySet()));
      }
    }

    int[] bc = new int[N + 1];
    for (int i = 0; i < K; i++) {
      int c = C[i];
      int d = D[i];
      if (gn[c] == gn[d]) {
        bc[c]++;
        bc[d]++;
      }
    }

    int[] ans = new int[N + 1];
    for (int i = 1; i < N + 1; i++)
      ans[i] = gc[gn[i]] - 1
          - f.getOrDefault(i, Collections.emptySet()).size()
          - bc[i];

    for (int i = 1; i < N + 1; i++)
      System.out.print(ans[i] + " ");
    System.out.println();
  }
}

Measured memory_bytes: 137884
n, k = gets.chomp.split(" ").map(&:to_i);
arr = Array.new(n, false)

k.times do
  d = gets
  as = gets.chomp.split(" ").map(&:to_i);
  as.each do |a|
    arr[a-1] = true
  end
end

puts arr.count(false)

Measured memory_bytes: 14332
def main():
	n = int(input())
	a = input().split(" ")
	for i in range(n):
		a[i] = int(a[i])
	for ai in a:
		if ai == 0:
			print("0")
			return
	ans = 1
	for ai in a:
		ans *= ai
		if ans > 1e18:
			print("-1")
			return
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 80464
#include<iostream>
using namespace std;

int main(){
  int n,a[101],b[101];
  while(1){
    
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    
    int max=0,min=10001;
    for(int i=0;i<n;i++){
      if(max<a[i]){
	max=a[i];
      }
      if(min>a[i]){
	min=a[i];
      }
    }
    
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=a[i];
    }
    sum-=(max+min);
    
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++){
        string str;
        cin >> str;
        mp[str]++;
    }
    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 19224
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y){
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}
int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = a * b / gcd(a, b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


string board[50];
ll dx[]={-1,-1,-1,1,1,1,0,0};
ll dy[]={-1,0,1,-1,0,1,-1,1};

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  ios::sync_with_stdio(false);
  ll X,Y;
  cin>>X>>Y;
  rep(i,X) cin>>board[i];
  rep(i,X){
    rep(j,Y){
      if(board[i][j]=='.'){
        ll cnt=0;
        rep(k,8){
          ll x=i+dx[k];
          ll y=j+dy[k];
          if(0<=x && x<X && 0<=y && y<Y && board[x][y]=='#') cnt++;
        }
        board[i][j]='0'+cnt;
      }
    }
  }
  rep(i,X){
    cout<<board[i]<<endl;
  }
  
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
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 LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def _kosa(a1, a2, b1, b2):
    x1,y1,_ = a1
    x2,y2,_ = a2
    x3,y3,_ = b1
    x4,y4,_ = b2

    tc = (x1-x2)*(y3-y1)+(y1-y2)*(x1-x3)
    td = (x1-x2)*(y4-y1)+(y1-y2)*(x1-x4)
    return tc*td < 0

def kosa(a1, a2, b1, b2):
    return _kosa(a1,a2,b1,b2) and _kosa(b1,b2,a1,a2)


def distance(x1, y1, x2, y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

def distance3(p1, p2, p3):
    x1,y1,_ = p1
    x2,y2,_ = p2
    x3,y3,_ = p3

    ax = x2 - x1
    ay = y2 - y1
    bx = x3 - x1
    by = y3 - y1

    r = (ax*bx + ay*by) / (ax*ax+ay*ay)
    if r <= 0:
        return distance(x1,y1, x3,y3)
    if r >= 1:
        return distance(x2,y2, x3,y3)
    return distance(x1 + r*ax, y1 + r*ay, x3,y3)

def main():
    rr = []

    def f(n):
        a = [S() for _ in range(n)]
        b = []
        for i in range(n):
            f = True
            for j in range(n):
                if i == j:
                    continue
                if a[i] in a[j]:
                    f = False
                    break
            if f:
                b.append(a[i])
        a = b
        n = len(b)
        d = [[0]*n for _ in range(n)]
        for i in range(n):
            ai = a[i]
            for j in range(n):
                if i == j:
                    continue
                aj = a[j]
                for k in range(1, min(len(ai), len(aj))):
                    if ai[-k:] == aj[:k]:
                        d[i][j] = k

        ii = [2**i for i in range(n)]
        q = collections.defaultdict(int)
        for i in range(n):
            q[(ii[i], i)] = 0
        for _ in range(n-1):
            nq = collections.defaultdict(int)
            for i in range(n):
                t = ii[i]
                for k,v in q.items():
                    if k[0] & t:
                        continue
                    key = (k[0] | t, i)
                    nv = v + d[k[1]][i]
                    if nq[key] < nv:
                        nq[key] = nv
            q = nq
        fr = max(q.values())
        return sum(map(len, a)) - fr


    while True:
        n = I()
        if n == 0:
            break
        rr.append(f(n))
        # print(n, rr[-1])

    return '\n'.join(map(str, rr))



print(main())



Measured memory_bytes: 18376
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nopf(T) [](T a){return a;}
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int a, b, m;
	scanf("%d%d%d", &a, &b, &m);
	vector<int> aa(a), bb(b);
	rep(i, a)scanf("%d", &aa[i]);
	rep(i, b)scanf("%d", &bb[i]);
	int ans = *min_element(all(aa)) + *min_element(all(bb)), x, y, c;
	rep(i, m) {
		scanf("%d%d%d", &x, &y, &c);
		ans = min(ans, aa[--x] + bb[--y] - c);
	}
	printf("%d\n", ans);

	Please AC;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>

using namespace std;
vector<pair<pair<int, int>, int> > vp;

void full_graph(int n) {
    for (int i = 1; i < n; i++) {
        vp.push_back({{i, i + 1}, 0});
        vp.push_back({{i, i + 1}, 1 << (n - i - 1)});
    }
}

int main() {

    int n;
    scanf("%d", &n);

    n--;
    int tmp = n;
    int cnt = 0;
    while (tmp) {
        cnt++;
        tmp /= 2;
    }

    full_graph(cnt);
    tmp = n;
    int cur = 0;
    bool b = 1;
    for (int i = cnt; i >= 0; i--) {
        if (((n >> i) & 1) && !b) {
            vp.push_back({{1, cnt - i}, cur});
            cur |= (1 << i);
        } else if ((n >> i) & 1) {
            cur |= (1 << i);
            b = 0;
        }
    }
    if(n == 1){
        vp.push_back({{1, 2}, 0});
        vp.push_back({{1, 2}, 1});
        cnt = 2;
    }else {
        vp.push_back({{1, cnt}, n});
    }
    printf("%d %d\n", cnt, vp.size());
    for (auto cur : vp) {
        printf("%d %d %d\n", cur.first.first, cur.first.second, cur.second);
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int a[100500];

int main()
{
    int N=0; scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        int t=0; scanf("%d",&t);
        a[t]=i+1;
    }
    for(int i=1;i<=N;i++)
    {
        printf("%d ",a[i]);
    }
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;

int main(){
    vector<int>a(5);
  
  	for(int i = 0;i < 5;i++){
      cin >> a.at(i);
      if(a.at(i) == 0){
        cout << i+1 << endl;
        break;
      }
    }
  
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    for (int i = 0; i < b; i++) {
        cout << (char)('0' + a);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstring>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int A, B;

int main(void) {
    scanf("%d %d", &A, &B);

    if (A <= 9 && B <= 9) printf("%d\n", A*B);
    else puts("-1");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a, b, k;
    cin >> a >> b >> k;

    set<int> se;
    for (int i = a; i <= b; i++) {
        if (i - a < k || b - i < k) se.insert(i);
    }

    for (auto x : se) cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;
typedef long long lint;
const int MAX = 555;
int dp[MAX][MAX];

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    for (int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        --l;
        dp[l][r] += 1;
    }
    for (int len = 1; len < MAX; ++len) {
        for (int i = 0; i+len < MAX; i++) {
            dp[i][i+len] += dp[i][i+len-1] + dp[i+1][i+len] - dp[i+1][i+len-1];
        }
    }
    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        cout << dp[p-1][q] << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main{
	int INF = 1 << 24;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int k = sc.nextInt();
			ArrayList<HashSet<Integer>> data = new ArrayList<HashSet<Integer>>();
			for(int i = 0; i < k; i++){
				data.add(new HashSet<Integer>());
				int m = sc.nextInt();
				for(int j = 0; j < m; j++){
					data.get(i).add(sc.nextInt());
				}
			}
			HashSet<Integer> badfeel = new HashSet<Integer>();
			int r = sc.nextInt();
			for(int i = 0; i < r; i++){
				int p = sc.nextInt();
				int q = sc.nextInt();
				int pind = -1, qind = -1;
				for(int j = 0; j < data.size(); j++){
					if(data.get(j).contains(p)){
						pind = j;
					}
					if(data.get(j).contains(q)){
						qind = j;
					}
				}
				if(pind == qind){
					badfeel.add(p);
					badfeel.add(q);
				}
			}
			System.out.println(badfeel.size());
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 24520
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int d,g;
    cin>>d>>g;
    vector<int> p(d),c(d);
    for(int i=0;i<d;i++)
    {
        cin>>p.at(i)>>c.at(i);
    }
    int count = 10000;
    for(int tmp=0;tmp<(1 << 10);tmp++)
    {
        int tmp_count = 0;
        int tmp_score = 0;
        bitset<10> b(tmp);
        for(int i=0;i<d;i++)
        {
            if(b.test(i))
            {
                tmp_count += p.at(i);
                tmp_score += p.at(i)*100*(i+1) + c.at(i);
            }
        }
        int num = d-1;
        while(tmp_score < g)
        {
            if(!b.test(num))
            {
                for(int j = 0;j < p.at(num);j++)
                {
                    tmp_score += 100*(num + 1);
                    tmp_count++;
                    if(tmp_score >= g)
                    {
                        break;
                    }
                }
                if(tmp_score < g)
                {
                    tmp_score += c.at(num);
                }
            }
            num--;
        }
        if(tmp_count < count)
        {
            count = tmp_count;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import math

a, b, C = map(int, raw_input().split())

S = a*b*math.sin(math.radians(C))/2.0

c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))
L = a+b+c

h = 2*S/a

print S
print L
print h

Measured memory_bytes: 6848
#include <stdio.h>
#include <string.h>

#define N 50


int main()
{
    int m,n;
    char s1[10],s2[10],s3[10];
    
    scanf("%s %s",s1,s2);
    scanf("%d %d",&m,&n);
    scanf("%s",s3);
    
    if(strcmp(s1,s3)==0)       //s1和s2相同
    {
        printf("%d %d\n",m-1,n);
    }
    else
    {
        printf("%d %d\n",m,n-1);
    }
    
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
void Yay(bool condition){

    if(condition){
        p("Yay!");
    }else{
        p(":(");
    }
    return;
}

//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll s,t;
ll x[300005],y[300005],z[100005];
ll dp[5505][5505];

ll sum;
ll part(ll n,ll m){
	if(m > n){
		return 0;
	}else if(n == m){
		return 1;
	}
	ll a = n - m;
	if(m == 0){
		return 0;
	}else if(m == 1){
		return 1;
	}
	return dp[a+m-1][m-1];
}

int main(){
	cin >> n >> k;
	dp[0][0] = 1;
	for(i=1;i<=5000;i++){
		for(j=0;j<=i;j++){
			if(j == 0 || j == i){
				dp[i][j] = 1;
			}else{
				dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
				dp[i][j] %= mod;
			}
			//pe(dp[i][j]);
		}
		//el;
	}
	for(i=1;i<=k;i++){
		ll tmp = (part(n-k,i-1) + part(n-k,i)*2 + part(n-k,i+1));
		//p(tmp);
		tmp %= mod;
		ans = part(k,i)*tmp;
		ans %= mod;
		p(ans);
	}

	return 0;
}


Measured memory_bytes: 227840
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

int main(){
	double x, h;
	double ans;
	while (cin >> x >> h) {
		
		
		if (x == 0 && h == 0) {
			break;
		}
		ans = x * x + x * sqrt(h*h + (x / 2)*(x / 2)) * 2;
		printf("%.6lf\n", x * x + x * sqrt(h*h + (x / 2)*(x / 2)) * 2);
	}
	return 0;
}


Measured memory_bytes: 3188
// Atcoder 176 ABC
// A

/*#include <iostream>
using namespace std;
#define ll long long
#define M 1000000007
int main(){
	int n , x, t;
	cin>>n>>x;
	cin>>t;
	if(n%x == 0){
		cout << (n/x)*t << endl;
	}
	else{
		cout << (n/x + 1)*t << endl;
	}
	return 0;

}
*/
/*
// B
#include <iostream>
using namespace std;
#define ll unsigned long long
#define M 1000000007
#define int t; cin>>t; while(t--)
#include <cstring>
// See limits once 
// 0≤N<10^200000
ll digit(string s, ll n){
	ll sum = 0;
	for(int i = 0; i < s.size(); i++){
		sum+=s[i]-'0';
	}
	return sum;
}
int main(){
string s;
cin>>s;
ll n = s.size();
ll ans = digit(s, n);
if(ans == 0){
	cout << "Yes" << endl;
	return 0;
}
if(ans%3 == 0 && ans&1){
	cout << "Yes" <<endl;
}
else{
	cout << "No" << endl;
}
	return 0;
}

*/
#include <iostream>
using namespace std;
#define ll  long long
#define M 1000000007
#define tc int t; cin>>t; while(t--)
#include <cstring>

ll stoolHeight(ll height[], int n){
	ll stool = 0;
	if( n == 1){
		return 0;
	}
	for(int i = 1; i < n; i++){
		if(height[i] < height[i-1]){
			stool+=height[i-1] - height[i];
			height[i] = height[i-1]; 
		}
	}
	return stool;
}
int main(){

	int n;
	cin>>n;
	ll height[n];
	for(int i = 0; i < n; i++){
		cin>>height[i];
	}
	cout << stoolHeight(height, n) << endl;
}

















Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);
int main(){ 
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while (r - l > 1LL) {
    ll x = (r + l) / 2;
    auto ok = [&]() {
      ll cnt = 0;
      for (int i = 0; i < n; i++) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (r - l > 1) {
            int idx = (r + l) / 2;
            if (a[idx] * a[i] < x) r = idx;
            else l = idx;
          }
          cnt += n - r;
        } else {
          int l = -1, r = n;
          while (r - l > 1) {
            int idx = (r + l) / 2;
            if (a[idx] * a[i] < x) l = idx;
            else r = idx;
          }
          cnt += r;
        }
        if (a[i] * a[i] < x) cnt--;
      }
      cnt /= 2;
      return cnt < k;
    };
    if (ok()) l = x;
    else r = x;
  }
  cout << l << endl;
  return 0;
} 

Measured memory_bytes: 1792
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

A.insert(0, 0)
A.append(0)

ans = 0
for i in range(N+1):
	ans += abs(A[i+1]-A[i])

for i in range(N):
	if A[i]<=A[i+1]<=A[i+2] or A[i+2]<=A[i+1]<=A[i]:  # 消すところが真ん中
		print(ans) 
	else:
		print(ans-2*
			min(
				abs(A[i+2]-A[i+1]), 
				abs(A[i+1]-A[i])
				)
			)


Measured memory_bytes: 14672
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a,b;
    cin >> a >> b;
    if(10>a+b)cout << a+b << endl; else cout << "error" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

int w,h,n,x[10],y[10];
const int inf = 2000000;
char s[1000][1001];
int m[1000][1000];
int f(int c){
	int a=x[c],b=y[c];
	int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
	queue<pii> q;
	rep(i,h)rep(j,w)m[i][j]=inf;
	m[b][a]=0;
	q.push(pii(b,a));
	while(!q.empty()){
		int tx=q.front().second,ty=q.front().first;
		q.pop();
		rep(i,4){
			int cx=tx+dx[i],cy=ty+dy[i];
			if(in(cx,0,w-1) && in(cy,0,h-1) && s[cy][cx]!='X'){
				if(m[cy][cx]>m[ty][tx]+1){
					m[cy][cx]=m[ty][tx]+1;
					q.push(pii(cy,cx));
				}
			}
		}
	}
	return m[y[c+1]][x[c+1]];
}
int main(){
	int cnt;
	scanf("%d%d%d",&h,&w,&n);
	rep(i,h){
		scanf("%s",s[i]);
		rep(j,w){
			if(s[i][j]=='S'){
				x[0]=j;
				y[0]=i;
			}else if(in(s[i][j],'1','9')){
				int c=s[i][j]-'0';
				x[c]=j;
				y[c]=i;
			}
		}
	}
	cnt=0;
	rep(i,n)cnt+=f(i);
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N, M;
    cin >> N >> M;
    vector<string> a(N);
    vector<string> b(M);
    rep(i, N) cin >> a[i];
    rep(i, M) cin >> b[i];

    bool ans = false;

    //開始点(左上）を決定するforループ
    rep(i, N-M+1){
        rep(j, N-M+1){
            int cnt = 0;
            //各行を見るforループ
            rep(k, M){
                string S = a[i+k].substr(j, M);
                string T = b[k];
                if(S == T) cnt++;
            }
            if(cnt == M) ans = true;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define pdd              pair<double, double>
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
 {
    return (a*b)/gcd(a, b);
 }
bool sortByVal(const pair<int, int> &a,
               const pair<int, int> &b)
{
    return (a.second < b.second);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
int main()
{
    fast;
    ll i,j,n,c=0,d=0,e=0,f=0,sum=0,l;
    cin>>n;
    map<ll,ll> m;
    vector<ll> a(n);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    for(auto x:m)
    {
            c=x.second;
            sum+=((c*(c-1))/2);
    }
    for(i=0;i<n;i++)
    {
        c=m[a[i]];
        d=(c*(c-1))/2;
        sum-=d;
        c=m[a[i]]-1;
        e=(c*(c-1))/2;
        sum+=e;
        cout<<sum<<endl;
        sum-=e;
        sum+=d;
    }

}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int H;
int fld[5][10];
void drop(){
      REP(i,5){
            REP(j,H){
                  if(fld[i][j]==-1){
                        for(int k=j;k<H;k++){
                              if(fld[i][k]!=-1){
                                    int tmp=fld[i][k];
                                    fld[i][k]=fld[i][j];
                                    fld[i][j]=tmp;
                                    break;
                              }
                        }
                  }
            }
      }
}
int main(){
      while(cin>>H&&H){
            memset(fld,-1,sizeof(fld));
            for(int i=H-1;i>=0;i--)REP(j,5)cin>>fld[j][i];
            bool update=true;
            ll ans=0;
            while(update){
                  update=false;
                  REP(i,H){
                        int s,e,d=0;bool change=false;
                        while(d<5){
                              if(fld[d][i]==-1){
                                    d++;
                                    continue;
                              }
                              s=d;
                              while(fld[s][i]==fld[d][i]&&d<5)d++;
                              if(d-s>=3){
                                    e=d;
                                    change=true;
                                    break;
                              }
                        }
                        if(change){
                              update=true;
                              ans+=(e-s)*fld[s][i];
                              for(int j=s;j<e;j++)fld[j][i]=-1;
                        }
                  }
                  drop();
            }
            cout<<ans<<endl;
      }
      return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;

int main()
{
	string s, t;
	bool ans = false;
	
	cin >> s >> t;
	string tmp = s + s;
	//cout << tmp << endl;
	for (int i = 0; i <= s.length(); i++) {
		bool fg = true;
		for (int j = 0; j < t.length(); j++) {
			if (tmp[i + j] != t[j]) {
				fg = 0; break;
			}
		}
		if (fg) {
			ans = true; break;
		}
	}
	puts(ans ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define drep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define MAGICLINE ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define se second
#define fs first
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, int> PLI;
typedef priority_queue<int> PQI;
typedef priority_queue<LL> PQL;
typedef priority_queue<PLI,
                       vector<PLI>,
                       greater<PLI> > dijQ;

const int MN = 100002;
const LL M = 1000000007;
LL tree[MN][2];
bool visit[MN];
vector<int> V[MN];

void prefill(int n){
  rep(i, 1, n+1){
    tree[i][0] = 1;
    tree[i][1] = 1;
  }
}

void dfs(int node){
  rep(i, 0, V[node].size()){
    int next = V[node][i];
    if(!visit[next]){
      visit[next] = true;
      dfs(next);
      tree[node][0] = (tree[node][0] * (tree[next][0] + tree[next][1])) % M;
      tree[node][1] = (tree[node][1] * tree[next][0]) % M;
    }
  }
}

int main(){
  MAGICLINE;
  int n; scanf("%d", &n);
  prefill(n);
  rep(i, 0, n-1){
    int a, b; scanf("%d %d", &a, &b);
    V[a].pb(b);
    V[b].pb(a);
  }
  visit[1] = true;
  dfs(1);
  printf("%lld\n", (tree[1][0] + tree[1][1]) % M);
  return 0;
}


Measured memory_bytes: 12928
function Main(input) {
  input = input.trim();
  var A = parseInt(input.split(" ")[0]);
  var B = parseInt(input.split(" ")[1]);
  var C = parseInt(input.split(" ")[2]);
  var X = parseInt(input.split(" ")[3]);
  var Y = parseInt(input.split(" ")[4]);
  
  var output = 1000000000000;
  for(var i = 0; i <= 100000; i++){
    output = Math.min(output, i * 2 * C +Math.max(0,X-i)*A + Math.max(0,Y-i)*B);
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define co cout
#define ci cin
#define sf1(n) scanf("%lld",&n);
#define sf2(n,m) scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define en cout<<endl;
#define pb push_back
#define coy cout<< "YES"<<endl;
#define con cout<< "NO"<<endl;
#define For(a,b) for(ll a=0;a<b;a++)
#define br break;
#define i64 long long
i64 M=10000000;
//ll b[805],ans[805];
map< ll,pair<ll,ll> >mp;

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,res,c1,x,y,c2;
    ci>>n>>m;
    if(n>9||m>9) co<< "-1";
    else co<< (n*m);
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a;
    rep(i, n){
        int x; cin >> x;
        a.push_back(x);
    }
    if(n==1) cout << abs(a[0]-w) << endl;
    else cout << max(abs(a[n-1]-w), abs(a[n-1]-a[n-2])) << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;

int main(){
    ll N,K,Q;
    cin >> N >> K >> Q;
    ll A[100010];
    ll P[100010];
    for(ll i = 0;i < Q;i++){
        cin >> A[i];
    }
    for(int i = 0;i < N;i++){
        P[i] = K - Q;
    }
    for(ll i = 0;i < Q;i++){
        P[A[i]-1]++;
    }
    for(ll i = 0;i < N;i++){
        if(P[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
}


Measured memory_bytes: 2176
n,m=map(int,input().split())
ll=[];rl=[]

for i in range(m):
    l,r=map(int,input().split())
    ll.append(l,);rl.append(r)
    
tans=min(rl)-max(ll)+1
if tans>=0:print(tans)
else:print(0)

Measured memory_bytes: 10996
use strict;
use warnings;

my $n = <>;
chomp $n;

my @string;
foreach (1..$n){
	my $in = <>;
	chomp $in;
	$string[$_ - 1] = [sort {$a cmp $b} split(//, $in)];
	#print @{$string[$_ - 1]};
	#print "\n";
}

my $ostr = "";
while (1){
	my $chk = shift @{$string[0]};
	if (!$chk){
		last;
	}
	my $flag = 1;
	foreach (2..$n){
		my $i = $_ - 1;
		if (!@{$string[$i]}){
			goto END;
		}
		while (@{$string[$i]}){
			if ($chk gt $string[$i]->[0]){
				shift @{$string[$i]};
			}elsif($chk lt $string[$i]->[0]){
				$flag = 0;
				last;
			}else{
				shift @{$string[$i]};
				last;
			}
		}
	}
	if ($flag){
		$ostr .= $chk;
	}
}
END:
print $ostr;
print "\n";

exit;


Measured memory_bytes: 896
#include <bits/stdc++.h>

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    constexpr int MAXV = 1000;
    int n, w;
    cin >> n >> w;

    // what is the min weight to get value i
    constexpr ll INF = 1e17;
    vector<ll> dp(MAXV * n + 1, INF);
    dp[0] = 0;

    for (int i = 0; i < n; ++i) {
        ll wi, vi;
        cin >> wi >> vi;
        for (int j = (int)dp.size() - 1 - vi; j >= 0; --j) {
            dp[j + vi] = min(dp[j + vi], dp[j] + wi);
        }
    }
    
    int ans = 0;
    for (int i = 0; i < dp.size(); ++i) {
        if (dp[i] <= w)
            ans = i;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024