akhauriyash/Code-Regression huggingface dataset:
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**13
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 distance_p(a, b):
    return distance(a[0], a[1], b[0], b[1])

def main():
    rr = []

    def f(n,m):
        a = [LI() for _ in range(n)]
        b = [LI() for _ in range(m)]

        def search(a,b1,b2,rg):
            d = collections.defaultdict(lambda: inf)
            s = 0
            t = 1
            d[s] = 0
            q = []
            heapq.heappush(q, (0, s))
            v = collections.defaultdict(bool)
            while len(q):
                k, u = heapq.heappop(q)
                if v[u]:
                    continue
                v[u] = True
                if u == t:
                    return d[u]

                for uv in rg:
                    if v[uv]:
                        continue
                    if kosa(a[u],a[uv], b1,b2):
                        continue
                    ud = distance_p(a[u],a[uv])
                    vd = k + ud
                    if d[uv] > vd:
                        d[uv] = vd
                        heapq.heappush(q, (vd, uv))

            return -1

        ad = distance_p(a[0], a[1])
        bd = distance_p(b[0], b[1])
        ar = search(a,b[0],b[1],list(range(1,n)))
        br = search(b,a[0],a[1],list(range(1,m)))
        r = -1
        if ar < 0:
            if br < 0:
                return r
            return '{:0.9f}'.format(br + ad)
        if br < 0:
            return '{:0.9f}'.format(ar + bd)

        return '{:0.9f}'.format(min(ar + bd, br + ad))

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

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


print(main())



Measured memory_bytes: 9736
/* 
	"Never trust anyone too much. Remember that the devil was once an angel." 
								~ Kaneki Ken (Tokyo Ghoul) ~ 
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
LL n, m;

int main() {
	scanf("%lld %lld", &n, &m);
	LL res = min(n, m/2);
	m -= 2*res;
	res += m/4;
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://abc067.contest.atcoder.jp/tasks/abc067_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    A, B = map(int, input().split())
    if (A+B) % 3 == 0 or A % 3 == 0 or B % 3 == 0:
        print('Possible')
    else:
        print('Impossible')


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3060
from collections import deque
import sys
input =sys.stdin.readline
N = int(input())

#構造入力
color_max =0
connection ={i:deque() for i in range(1,N+1)}
edge_color={}
A =[(-1,-1)]*N
for i in range(1,N):
    a,b = (int(x) for x in input().split())
    connection[a].append(b)
    connection[b].append(a)
    edge_color[(a,b)] =-1
    A[i] =(a,b)
    color_max =max(color_max, len(connection[a]) , len(connection[b]))

#幅優先探索で色塗る
passed =set()
#edge_color ={i:-1 for i in range(1,N+1)}
parent ={i:-1 for i in range(1,N+1)}
parent[1] =0
dq =deque()
dq.append(1)
color =0
#prev =0 #頂点１の親は０とする
edge_color[(0,1)] =0
#node_color[1] =0
while dq:
    now =dq.popleft()
    passed.add(now)
    na_max =max(parent[now],now)
    na_min =min(parent[now],now)
    i_color =edge_color[(na_min,na_max)]
    for next in connection[now]:
        if next in passed:
            continue
        else:
            i_color +=1
            n_max =max(now,next)
            n_min =min(now,next)
            edge_color[(n_min,n_max)] =(i_color)% color_max 
            dq.append(next)
            parent[next] =now
print(color_max)
del edge_color[(0,1)]
for i in range(1,N):
    print(edge_color[A[i]] +1 )

Measured memory_bytes: 117036
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int m, k;

int a[1 << 17];


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> m >> k;


	if (m == 1) {
		if (k == 0) {
			cout << "0 0 1 1" << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}
	if ((1<<m) <= k) {
		cout << -1 << endl;
		return 0;
	}


	cout << k;
	rep(i, 1<<m) {
		if (i != k)cout << ' ' << i;
	}
	cout << ' ' << k;
	for (int i = (1 << m) - 1; i >= 0; i--) {
		if (i != k)cout << ' ' << i;
	}
	
	cout << endl;



	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    x %= b;
    cout << x << endl;

    return 0;
}



Measured memory_bytes: 256
import sys
f = sys.stdin


from collections import defaultdict
from collections import Counter
while True:
    n = int(f.readline())
    if n == 0:
        break
    words = [f.readline().strip() for _ in range(n)]
    words = [(ord(wi[0]) - ord('a'),ord(wi[-1]) - ord('a')) for wi in words]

    pre = Counter(w[0] for w in words)
    post = Counter(w[-1] for w in words)
    if pre != post:
        print('NG')
        continue
        
    path = [[0 for j in range(26)] for i in range(26)]
    for s, e in words:
        path[s][e] = 1
    for k in range(26):
        for i in range(26):
            for j in range(26):
                if path[i][k] and path[k][j]:
                    path[i][j] = 1
    s = words[0][0]
    flg = True
    for k in pre.keys():
        if not path[s][k]:
            flg = False
            break
 
    print('OK' if flg else 'NG')

Measured memory_bytes: 9640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    VL a(n), b(n);
    REP(i,n) scanf("%lld %lld", &a[i], &b[i]);

    ll ans = 0, add = 0;
    FORR(i,n-1,0){
        a[i] += add;
        ll p = (a[i] + b[i] - 1) / b[i];
        ll x = b[i] * p - a[i];
        add += x;
        ans += x;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*; 
 
class Main { 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
      	//int x = sc.nextInt();
      	//int t = sc.nextInt();
      	PrintWriter out = new PrintWriter(System.out);
        out.println(Math.max(sc.nextInt() - sc.nextInt(), 0));
      	out.flush();
    }

private static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}

    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        int n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}


}



Measured memory_bytes: 22612
// C

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N;
  cin>>N;
  int x[15][15][2],A[15];
  for (int i(0);i<N;i++){
    cin>>A[i];
    for (int j(0);j<A[i];j++){
      cin>>x[i][j][0]>>x[i][j][1];
    }
  }
  int ans(0);
	for (int bit = 0; bit < (1<<N); ++bit) {
      vector<int> S;
      int cnt(0);
      int syouziki[15] = {0};
      int uso[15] = {0};
      for (int i = 0; i < N; ++i) {
          if (bit & (1<<i)) { // i が bit に入るかどうか
            syouziki[i]++;
            for (int j(0);j<A[i];j++){
              if (x[i][j][1] == 0){
                uso[x[i][j][0]-1]++;
              }else{
                syouziki[x[i][j][0]-1]++;
              }
            }
            cnt++;
          }else{
            uso[i]++;
          }
      }
      bool flag=true;
      for (int i(0);i<N;i++){
        if (syouziki[i] >= 1 && uso[i] >= 1) flag = false;
      }
      if (flag){//生合成が取れていたら
        ans = max(ans,cnt);
      }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,c,L,T,x[N],w[N],p[N];
int main(){
	scanf("%d%d%d",&n,&L,&T);
	for(int i=0;i<n;i++)
		scanf("%d%d",&x[i],&w[i]);
	for(int i=0;i<n;i++){
		if(w[i]==2)	w[i]=-1;
		int d=x[i]+w[i]*T;
		if(d>0)	c=(c+d/L)%n;
		if(d<0)	c=((c+(d+1)/L-1)%n+n)%n;
		p[i]=(d%L+L)%L;
	}
	sort(p,p+n);
	for(int i=0;i<n;i++)
		printf("%d\n",p[(i+c)%n]);
	return 0;
}


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

using namespace std;


int main(){
  string s,t;
  cin>>s>>t;
  int size = s.size()>=t.size() ? s.size() : t.size();
  string lcs = "";
  int LCS[s.size()+1][t.size()+1];
  for(int i=0;i<=s.size();i++){
    for(int j=0;j<=t.size();j++){
        if(i ==0 || j==0)
          LCS[i][j] =0;
        else if(s[i-1] == t[j-1]){
          LCS[i][j] = 1 +LCS[i-1][j-1];
        }
        else{
            LCS[i][j] = max(LCS[i][j-1],LCS[i-1][j]);
        }
    }
  }
  int i=s.size(),j=t.size();
  while(i>0 && j>0){
     if(s[i-1] == t[j-1]){
       lcs = s[i-1] + lcs;
       i--;
       j--;
     }
     else{
       if(LCS[i-1][j]>LCS[i][j-1]){
         i--;
       }
       else
        j--;
     }

  }
  cout<<lcs;

  return 0;
}


Measured memory_bytes: 38840
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;

void main(){
    int n = to!int(readln().chomp());
    int[100] list;
    for(int i=0;i<n;i++){
	auto s = split(readln()).to!(int[]);
	list[s[0]] = s[1];
    }
    int ans=1;
    for(int i=1;i<=n;i++){
	if(list[ans] < list[i]){
	    ans = i;
	} 
    }
    writef("%d %d\n",ans,list[ans]);
}

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

int main(void){
    string s,t;
    cin >> s;
    cin >> t;
    sort(s.begin(),s.end(),less<char>());
    sort(t.begin(),t.end(),greater<char>());
    cout << (s<t?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let N = get!(usize);
    let A = get!(usize);

    let ans = N * N - A;

    // 出力
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
	int A[200000];
	int K, N;
	int k_tmp;
	int tmp = -1;
	int k_min;
	int i;

	scanf("%d %d", &K, &N);
	scanf("%d", &A[0]);
	for (i = 1; i < N; i++) {
		scanf("%d", &A[i]);
		k_tmp = A[i]-A[i-1];
		if ( k_tmp > tmp ) {
			tmp = k_tmp;
		}
	}
	k_tmp = (K-A[N-1])+A[0];
	if ( k_tmp > tmp ) { tmp = k_tmp; }

	k_min = K-tmp;
	printf("%d\n", k_min);

	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
constexpr ll MOD = ((1e9) + 9);

mat mul(const mat& A, const mat& B)
{
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < (int)A.size(); i++) {
        for (int k = 0; k < (int)B.size(); k++) {
            for (int j = 0; j < (int)B[0].size(); j++) {
                C[i][j] = (C[i][j] + (A[i][k] * B[k][j]) % MOD) % MOD;
            }
        }
    }
    return C;
}

mat pow(mat A, ll n)
{
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < (int)A.size(); i++) {
        B[i][i] = 1;
    }
    while (n > 0) {
        if (n & 1) {
            B = mul(B, A);
        }
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

int main()
{
    ll W, H, N, tc = 0;
    while (cin >> W >> H >> N, W) {
        map<ll, vector<ll>> mp;
        for (int i = 0; i < N; i++) {
            ll x, y;
            cin >> x >> y; x--; y--;
            mp[y].emplace_back(x);
        }        

        for (auto& m : mp) {
            auto& v = m.second;
            sort(v.begin(), v.end());
        }
        
        mat A(W, vec(W));
        for (int i = 0; i < W; i++) {
            for (int j = -1; j <= 1; j++) {
                int k = i + j;
                if (0 <= k && k < W) {
                    A[i][k] = 1;
                }
            }
        }
        
        ll curr = 0;
        mat B(W, vec(W, 0)); B[0][0] = 1;
        for (const auto& m : mp) {
            ll next = m.first;
            B = mul(B, pow(A, next - curr));
            for (const auto& x : m.second) {
                B[0][x] = 0;
            }                
            curr = next;
        }

        B = mul(B, pow(A, H - curr - 1));

        if (mp.count(0) > 0 && mp[0][0] == 0) {
            cout << "Case " << ++tc << ": " << 0 << endl;
        } else {            
            cout << "Case " << ++tc << ": " << B[0][W - 1] << endl;
        }
    }        
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  int n=s.size()+1;
  //num[i]はa[i+1]の左にある＜と右にある＞が連続する数の最大値
  vector<int>num(n);
  //左の＜について
  int left=0;
  for(int i=1;i<n;i++){
    if('<'==s[i-1]){
      left++;
      num[i]=left;
    }
    else{
      left=0;
      num[i]=left;
    }
  }
  //右の＞について
  int right=0;
  for(int i=1;i<n;i++){
    if('>'==s[n-1-i]){
      right++;
      num[n-1-i]=max(right,num[n-1-i]);
    }
    else{
      right=0;
      num[n-1-i]=max(right,num[n-1-i]);
    }
  }
  //答え求める
  long long ans=0;
  for(int i=0;i<n;i++) ans+=num[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 2820
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	sort.Sort(sort.IntSlice(list))
	result := list[n/2] - list[n/2-1]
	fmt.Println(result)

}


Measured memory_bytes: 5504
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
using namespace std;
typedef long long LL;
const LL maxn=500050;
LL d[maxn];
int main() {
	LL n,x,cur=0;
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>x;
		d[x]=d[x-1]+1;
		cur=max(cur,d[x]);
	}
	cout<<n-cur<<endl;
	return 0;
}

Measured memory_bytes: 1792
import sys

sys.setrecursionlimit(10000)

def search(a, b, left, right):
    mid = int(left + (right - left) / 2)
    if(b[mid] == a):
        return b[mid]
    if(len(b) <= mid + 1):
        return b[mid]
    if(b[mid] >= a and a >= b[mid+1]):
        if(b[mid]- a >= a - b[mid+1]):
            return b[mid+1]
        else:
            return b[mid]
    if(b[mid] <= a):
        return search(a, b, left, mid)
    else:
        return search(a, b, mid, right)

n = int(input())
a = list(map(int, input().split(" ")))

b = sorted(a, reverse=True)
for i in b:
    m = i/2
    j = search(m, b, 0, len(b))
    print("%d %d" %(i, j))
    break

Measured memory_bytes: 14348
/*input
3 5
*/
fn main() {
    let mut input = format!("");
    std::io::stdin().read_line(&mut input).ok();
    let v: Vec<u16> = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    println!("{} {}", v[0] * v[1], v[0] * 2 + v[1] * 2);
}



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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n,m,X,Y;
    cin>>n>>m>>X>>Y;
    int x[n],y[m];

    for(int i=0;i<n;i++)cin>>x[i];
    for(int i=0;i<m;i++)cin>>y[i];
    sort(x,x+n);
    sort(y,y+m);
    int z[2]={max(X+1,x[n-1]),min(Y,y[0])};
    if(z[0]<z[1])cout<<"No War"<<endl;
    else cout<<"War"<<endl;

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main(void){
  int n, k, q;

  std::cin >> n >> k >> q;

  std::vector<int> point(n, k-q);

  for(int i=0; i<q; i++){
    int a;
    std::cin >> a;
    point[a-1]++;
  }

  for(int i=0; i<n; i++){
    if(point[i] > 0) std::cout << "Yes" << std::endl;
    else               std::cout << "No" << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

#define ll long long
#define ull unsigned long long
#define lld long double
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vt vector
#define vll vt<ll>
#define pll pair<ll,ll>
#define vpll vt<pll>
#define vvll vt<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl '\n'
template <typename T> using mxpq = priority_queue<T>;
template <typename T> using mnpq = priority_queue<T, vt<T>, greater<T>>;
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)

#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"

const ll mod = 1e9 + 7;
const ll N = 6e4 + 6;
const ll maxN = 1e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

int dx[4] = { -1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
// up, right, down, left
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions
//int dx[]={-2,-2,-1,1,-1,1,2,2};///Knight moves
//int dy[]={1,-1,-2,-2,2,2,-1,1};///Knight moves

ll powerM(ll x, ll y, ll M = mod) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in4.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	FIO
	ll x;
	cin >> x;
	x = !x;
	cout << x;
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main() {
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	cout << W * H * 0.5 << " ";
	if (x == W * 0.5 && y == H * 0.5)cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

if __name__ == '__main__':
    n = int(input())
    w = list(map(int, input().split()))

    m = sum(w)
    for i in range(1, len(w)):
        ans = abs(sum(w[:i]) - sum(w[i:]))
        if m > ans:
            m = ans
    print(m)

Measured memory_bytes: 3060
import sys,bisect as bs,collections as cl
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
n = onem()
m = onem()
a = l()
mid = m//2
ans = 0
for i in range(n):
    if mid >= a[i]:
        ans += 2 * a[i]
    else:
        ans += 2 * abs(m - a[i])
print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int y=(s[5]-'0')*10+s[6]-'0';
	if(y<=4){
		cout<<"Heisei"<<endl;
	}else{
		cout<<"TBD"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    S = inp.readline().strip()
    return "x" * len(S)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int a[303][303];
int posx[90001];
int posy[90001];
int cost[303][303];
int f(int from,int to){
    int fx = posx[from];
    int fy = posy[from];
    int tx = posx[to];
    int ty = posy[to];
    return abs(fx-tx) + abs(fy-ty);
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h,w,d;
    cin >> h >> w >> d;
    rep(i,h)rep(j,w){
        cin >> a[i][j];
        int now = a[i][j];
        posx[now] = i;
        posy[now] = j;
    }
    vector<vector<ll>> memo(d+1);

    for(int i=1;i<=d;i++){
        int start = i;
        memo[i].push_back(0);
        for(int j=start;j+d<=h*w;j+=d){
            memo[i].push_back(memo[start].back()+f(j,j+d));
        }
    }

    int q;
    cin >> q;
    rep(i,q){
        ll ans = 0;
        int l,r;
        cin >> l >> r;
        int type;
        if(l%d==0 || r % d == 0)type = d;
        else type = l%d;
        cout << memo[type][(r-type)/d] - memo[type][(l-type)/d] << endl;
    }
}

Measured memory_bytes: 6400
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto S = sread();
    auto C = new uint[](N);
    foreach (i; 0 .. N)
    {
        C[i] = (1 << (S[i] - 'a'));
    }
    long ans = -1;
    foreach (i; 1 .. N)
    {
        uint a = (C[0 .. i + 1] ~ 0).reduce!"a|b"();
        uint b = (C[i + 1 .. $] ~ 0).reduce!"a|b"();
        // writefln("%030b %030b %030b", a, b, a & b);
        ans = ans.max(popcnt(a & b));
    }
    writeln(ans);
}


Measured memory_bytes: 380
use std::io::{self, BufRead};

fn ff(vec:&mut Vec<i64>) -> i64 {
    let mut min = vec[0];
    let mut rv = vec[1] - vec[0];

    for n in 1 .. vec.len() {
        if rv < vec[n] - min {
            rv = vec[n] - min;
        }
        if vec[n] < min {
            min = vec[n]
        }

    }

    rv
}

fn main() {
    let mut s = String::new();
    let stdin = io::stdin();

    let _ = stdin.read_line(&mut s);
    let n:usize = s.trim().parse().unwrap();

    s.clear();

    // let nums:Vec<i64> = stdin.lock()
    //     .lines()
    //     .take(n)
    //     .map(|s| s.ok().unwrap().trim().parse().unwrap_or(0))
    //     .collect();

    let mut nums:Vec<i64> = Vec::new();

    for _ in 0 .. n {
        let _ = stdin.read_line(&mut s);
        //println!("{}", s.trim());
        nums.push(s.trim().parse().unwrap());
        s.clear();
    }

    println!("{}", ff(&mut nums));
}



Measured memory_bytes: 6972
N, M = map(int, input().split())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a,b])

sortedAB = sorted(AB, key=lambda x:x[0])

ans = 0
for i in range(N):
    a = sortedAB[i][0]
    b = sortedAB[i][1]
    if M == 0:
        print(ans)
        exit()
    if b <= M:
        ans += a*b
        M -= b
    else:
        ans += a*M
        M = 0

print(ans)      

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

// 0-indexed
template <class T>
struct BIT {
  int treesize;
  vector<T> lst;
  // constructor
  BIT(int newn = 0) : treesize(newn), lst(newn + 1, 0) {}
  // a_place += num
  void add(int place, T num) {
    ++place;
    while (place <= treesize) {
      lst[place] += num;
      place += place & -place;
    }
  }
  // sum between [0,place)
  T sum(int place) {
    T res = 0;
    while (place > 0) {
      res += lst[place];
      place -= place & -place;
    }
    return res;
  }
  // sum [l,r)
  T sum(int left, int right) { return sum(right) - sum(left); }
};

using P = pair<int, int>;
int n, q;
vector<int> c;
vector<int> id, res, memo;
map<int, int> mp;
vector<P> queries;
BIT<int> bit;

int main() {
  cin >> n >> q;
  c.resize(n);
  for (auto &p : c) {
    cin >> p;
    --p;
  }
  queries.resize(q);
  for (auto &p : queries) {
    cin >> p.first >> p.second;
    --p.first;
  }
  for (int i = 0; i < q; ++i) id.push_back(i);
  {  // sort
    auto asc = [](int lid, int rid) {
      P l = queries[lid], r = queries[rid];
      if (l.second != r.second) return l.second < r.second;
      return l.first < r.first;
    };
    sort(id.begin(), id.end(), asc);
  }
  memo.assign(n, -1);
  res.resize(q);
  bit = BIT<int>(n);
  for (int i = 0, sec = 0; i < q; ++i) {
    P p = queries[id[i]];
    while (sec < n && sec < p.second) {
      if (memo[c[sec]] >= 0) bit.add(memo[c[sec]], -1);
      memo[c[sec]] = sec;
      bit.add(sec, 1);
      ++sec;
    }
    res[id[i]] = bit.sum(p.first, p.second);
  }
  for (auto p : res) cout << p << endl;

  return 0;
}

Measured memory_bytes: 17488
#include<stdio.h>

int main(void){
    int N,K;
    scanf("%d %d", &N, &K);

    int p[N];
    int temp,sum=0;
    for(int i=0;i<N;i++){
        scanf("%d", &p[i]);
    }

    for(int j=0;j<N;j++){
        for(int k=j+1;k<N;k++){
            if(p[j]>p[k]){
                temp = p[j];
                p[j] = p[k];
                p[k] = temp;
            }
        }
    }

    for(int n=0;n<K;n++){
        sum += p[n];
    }

    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[101];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    int mx=a[n-1],mn=a[0];
    int ans=1000100010;
    for(int i=mn;i<=mx;++i){
        int sum=0;
        rep(j,n) sum+=(i-a[j])*(i-a[j]);
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
import Data.List
import Data.ByteString.Char8 as BC (words, getLine, readInt)
import Data.Maybe (fromJust)

main = do
  n <- fst . fromJust . BC.readInt <$> BC.getLine
  a <- sort . map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
  b <- sort . map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
  c <- sort . map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
  printAns a b c

p :: Int -> Int -> Int
p x y = x + y

m :: Int -> Int -> Int
m x y = x * y

ltList' :: [Int] -> [Int] -> [Int]
ltList' a b = scanl1 p $ ltList a b

ltList :: [Int] -> [Int] -> [Int]
ltList _  []     = []
ltList [] (b:bs) = 0 : ltList [] bs
ltList a  (b:bs) = let lt = length $ takeWhile (< b) a
                       remain = drop lt a
                   in lt : ltList remain bs

gtList :: Int -> [Int] -> [Int] -> [Int]
gtList n _  []     = []
gtList n [] (b:bs) = 0 : gtList n [] bs
gtList n a  (b:bs) = let le =  length $ takeWhile (<= b) a
                         remain = drop le a
                     in (n-le) : gtList (n-le) remain bs

printAns :: [Int] -> [Int] -> [Int] -> IO ()
printAns a b c = print . sum $ zipWith m (ltList' a b) (gtList (length c) c b)


Measured memory_bytes: 47484
import itertools
N, C = map(int, input().split())
D = [tuple(map(int, input().split())) for _ in range(C)]
c = [tuple(map(lambda x: x-1, map(int, input().split()))) for _ in range(N)]

grid = [[0] * C for _ in range(3)]
for i, j in itertools.product(range(N), repeat=2):
    grid[(i+j)%3][c[i][j]] += 1

ans = float("inf")
for color_after in itertools.permutations(range(C), 3):
    s = sum([sum([grid[g][color_before]*D[color_before][color_after[g]] for color_before in range(C)]) for g in range(3)])
    ans = min(ans, s)

print(ans)


Measured memory_bytes: 5108
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong(),a=sc.nextLong(),b=sc.nextLong();
        long ans=n/(a+b)*a;
        long r=n%(a+b);
        if(r>a)r=a;
        System.out.println((ans+r));
    }
}

Measured memory_bytes: 22612
using System;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Exec(args);
            // QuestionB.Main(args);
            Console.Out.Flush();
        }

        private static void Exec(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 個数
            int N = int.Parse(Console.ReadLine());
            string[] inputs = new string[N];
            
            Dictionary<string, int> counts = new Dictionary<string, int>()
            {
                {"AC", 0},
                {"WA", 0},
                {"TLE", 0},
                {"RE", 0},
            };
            
            for (var i = 0; i < N; i++)
            {
                var s = Console.ReadLine();
                counts[s]++;
            }

            foreach (var pair in counts)
            {
                Console.WriteLine($"{pair.Key} x {pair.Value}");
            }
            
            Console.Out.Flush();
        }
    }
}


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

int main(){
	string S, A="abcdefghijklmnopqrstuvwxyz";
	cin >> S;
	for(int i=0; i<S.size(); i++){
		for(int j=0; j<A.size(); j++){
			if(S[i]==A[j]){
				A[j] = 'A';
			}
		}
	}
	for(int i=0; i<A.size(); i++){
		if(A[i]!='A'){
			cout << A[i];
			return 0;
		}
	}
	cout << "None";
}

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

int main(){
    int n,x;

    while(true){
        cin >> n >> x;
        if(n==0 && x==0)break;

        int count=0;
        for(int i=1; i<=n-2; i++){
           for(int j=i+1; j<=n-1; j++){
               for(int k=j+1; k<=n; k++){
                   if(i+j+k==x){count++;}
               }
           }
        }
        cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb(x) push_back(x)
#define int long long 
#define mod 1000000007
void swap(int *a,int *b){
	int *t=a;
	a=b;
	b=t;
}
int dfs(vector<int> v[],int n,int i,int &ans,vector<int> &vis){
	if(vis[i]){
		return vis[i];
	}
	// int temp=0;
	for(auto j:v[i]){
		// temp++;
		vis[i]=max(vis[i],dfs(v,n,j,ans,vis));
	}
	vis[i]++;
	ans=max(ans,vis[i]);
	// if(temp==0){
	// 	return 1;

	// }
	return vis[i];
}
int32_t main(){
	int n,m;
	cin>>n>>m;
	vector<int> v[n+1];
	int l,r;
	while(m--){
		cin>>l>>r;
		v[l].push_back(r);
	}

	int ans=0;
	std::vector<int> vis(n+1,0);
	for(int i=1;i<=n;i++)
	dfs(v,n,i,ans,vis);

	cout<<ans-1<<endl;


}

Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
#define MAX 100001
int Q;
int p[MAX],p2[MAX],c[MAX],m=0;
int main(){
  cin >> Q;
  for(int i=2;i<MAX;i++)p[i]=1;
  for(int i=2;i*i<MAX;i++){
    if(p[i]==1){
      for(int j=2*i;j<MAX;j+=i)p[j]=0;
    }
  }
  for(int i=2;i<MAX;i++)if(p[(i+1)/2]==1)p2[i]=1;
  for(int i=2;i<MAX;i++){
    if(p[i]==1 && p2[i]==1) m++;
    c[i]=m;
  }
  for(int i=0;i<Q;i++){
    int l,r;
    cin >> l >> r;
    cout << c[r]-c[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int s,d,f,g,h,j,a;
	scanf("%d %d %d %d %d %d",&s,&d,&f,&g,&h,&j);
	a=s*1+d*5+f*10+g*50+h*100+j*500;
	if(a>=1000){
		printf("1\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}

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

int main()
{
  	int n, m;
  	cin >> n >> m;
  	int ll = 1, rr = n;
  	while (m--)
    {
      	int l, r;
      	cin >> l >> r;
      	ll = max(l, ll);
      	rr = min(r, rr);
    }
  	cout << max(0, rr - ll + 1);
}

Measured memory_bytes: 256
n = int(input())
cnt = 1
while cnt*(cnt+1)//2 < n:
    cnt+=1
if cnt*(cnt+1)//2 == n:
    for i in range(cnt):
        print(i+1)
else:
    bad = -1
    total = cnt*(cnt+1)//2
    for i in range(1, cnt+1):
        if total-i == n:
            bad = i
            break
    for i in range(1, cnt+1):
        if i == bad:
            continue
        print(i)


Measured memory_bytes: 9260
#include <bits/stdc++.h>
using namespace std;
long long n,z,x,c,s,a[200001],maxz=1000000000;
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)
    {
        maxz=min(maxz,a[i]);
        if(a[i]<=maxz)
            s++;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 1792
'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');

const boxes = inputs[0].split(' ').map(v => parseInt(v, 10));

let tmp = boxes[1];
boxes[1] = boxes[0];
boxes[0] = tmp;

tmp = boxes[2]
boxes[2] = boxes[0]
boxes[0] = tmp;

console.log(boxes.join(' '));


Measured memory_bytes: 21064
#include <stdio.h>

#define MIN(a,b) (a<b ? a : b)
#define MAX(a,b) (a<b ? b : a)


int GCD(int a,int b){
  int max=0,min=0;
  max=MAX(a,b); min=MIN(a,b);
  int tmp;
  while(1){
    tmp=min;
    min=max%tmp;
    max=tmp;
    if(min==0)break;
    if(min==1){
      return 1;
    }
  }
  return max;
}


int main(void){
  int Input1,Input2;

  scanf("%d %d",&Input1 ,&Input2);
  printf("%d\n",GCD(Input1,Input2));

  return 0;
}

Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=s[0]-'0';
    int b=s[1]-'0';
    int c=s[2]-'0';
    int d=s[3]-'0';
    if(a+b+c+d==7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a+b+c-d==7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    }
    else if(a+b-c+d==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a+b-c-d==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    }
    else if(a-b+c+d==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a-b+c-d==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    }
    else if(a-b-c+d==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    }
    else if(a-b-c-d==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N,M,Q;
vector<int> V[100010];
P2 c[100010][11];
priority_queue<P3> P;

int main(){
	scanf("%d%d" , &N , &M);
	repp(i,0,M){
		int a , b;
		scanf("%d%d" , &a , &b);
		V[a].PB(b);
		V[b].PB(a);
	}
	repp(i,1,N+1){
		fill(c[i],c[i]+11,MP(-1,0));
	}
	scanf("%d" , &Q);
	repp(i,0,Q){
		int x,y,z;
		scanf("%d%d%d" , &x ,&y , &z);
		c[x][y] = MP(i,z);
		if(y > 0) P.push(M3P(i,x,y));
	}
	while(!P.empty()){
		int x = P.top().first.second;
		int y = P.top().second;
		P.pop();
		int z = c[x][y].first;
		int w = c[x][y].second;
		for(auto e : V[x]){
			if(c[e][y-1].first < z){
				c[e][y-1] = MP(z,w);
				if(y > 1) P.push(M3P(z,e,y-1));
			}
		}
	}
	repp(i,1,N+1){
		int x = 0;
		repp(j,1,11){
			if(c[i][x].first < c[i][j].first) x = j;
		}
		printf("%d\n" , c[i][x].second);
	}
	return 0;
}


Measured memory_bytes: 21612
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

sat=sum(B)
#print(sat)

for i in range(0,n-1):
    if int(A[i])+1 == int(A[i+1]):
        name=int(A[i])
        #print('料理の名前は')
        #print(name)
      
        sat = sat + int(C[name-1])
        #print(sat)
    else:
      #print('none')
      continue

print(sat) 


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = y1-y2;
  int dy = x2-x1;

  int x3 = x2+dx;
  int y3 = y2+dy;
  int x4 = x1+dx;
  int y4 = y1+dy;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


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

int main() {
  int N, Y;
  cin >> N >> Y;
  int res10000 = -1, res5000 = -1, res1000 = -1;
  for (int x=0; x <= N; ++x) {
    for (int y=0; x + y <= N; ++y) {
      int z = N - x - y;
      int total = 10000*x + 5000*y + 1000*z;
      if (total == Y) {
        res10000 = x;
        res5000 = y;
        res1000 = z;
      }
    }
  }
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){int n,k,i,f;while(~scanf("%d",&n)){

        for(f=i=0;k=n-i/100-(i/10)%10-i%10,i<1000;++i)

            if(k<10&&k>=0) f++;

        printf("%d\n",f);

    }

}

Measured memory_bytes: 0
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

AB = []
for a in A:
    for b in B:
            AB.append(a+b)
AB = sorted(AB,reverse=True)[:K]
C = sorted(C,reverse=True)
ABC = []

for c in C:
    for ab in AB:
        ABC.append(c + ab)
ABC = sorted(ABC,reverse=True)        
print(*ABC[:K],sep="\n")        
    


Measured memory_bytes: 223852
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int cnt=0;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]!=s[i+1]){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<string.h>
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define None cout<<"None"<<endl
typedef long long ll;
using namespace std;

int main() {
	int N,M; cin >> N >> M;
	int a[M],b[M];
	int c[N];
	for (int i = 1; i <= N; ++i) {
		c[i] = 0;
	}
	
	for (int i = 1; i <= M; ++i) {
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i <= M; ++i) {
		for (int j = 1; j <= N; ++j) {
			if (a[i] == j) ++c[j];
			if (b[i] == j) ++c[j];
		}
	}
	for (int i = 1; i <= N; ++i) {
		cout << c[i] << endl;
	}
}

Measured memory_bytes: 256
n,m = map(int,input().split())

num = [0]*n
for i in range(m):
    s,c = map(int,input().split())
    if n >= 2:
        if s == 1 and c == 0:
            print(-1)
            exit()
    if num[s-1] == 0:
        num[s-1] = c
    elif num[s-1] != c:
        print(-1)
        exit()

if n >= 2 and num[0] == 0:
    num[0] = 1

num_ =''
num = list(map(str,num))
for i in range(n):
    num_ += num[i]

print(int(num_))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
const int INF = 1<<29;
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max(a, max(b,c)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int N;
    cin >> N;
    if(N % 10 == 9 || ( N / 10 ) % 10 == 9){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 200001;
int A[N], B[N];
vector<int > v;

int bs(int x) {
  int res = -1;
  int lo = 0, hi = (int)v.size() - 1;
  while(lo <= hi) {
    int mi = (lo + hi) >> 1;
    if(v[mi] <= x) {
      res = mi;
      lo = mi + 1;
    } else {
      hi = mi - 1;
    }
  }
  return res + 1;
}

int getCount(int a, int b) {
  return bs(b) - bs(a - 1);
}

int main() {
  int n;
  S(n);
  rep(i,0,n) S(A[i]);
  rep(i,0,n) S(B[i]);
  int ans = 0;
  for(LL f = 2; f <= (1<<30); f <<= 1) {
    v.clear();
    rep(i,0,n) {
      int x = A[i] % f;
      v.pb(x);
    }
    sort(all(v));
    int l = f / 2;
    int r = f - 1;
    int cnt = 0;
    rep(i,0,n) {
      int x = B[i] % f;
      int a = l - x;
      int b = r - x;
      cnt ^= getCount(max(a, 0), b) & 1;
      if(a < 0) {
        cnt ^= getCount(f + a, r) & 1;
      }
    }
    ans += (f / 2) * cnt;
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 2936
#include <iostream>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	return 0;//第二次提交同样代码，加一个注释-
}

Measured memory_bytes: 256