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

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

    ll N;
    cin >> N;
    
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N);

    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    vector<ll> bc(N);

    for(int i = 0; i < N; i++) {
        ll x = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
        bc[i] = N - x;
    }

    for(int i = N - 2; i >= 0; i--) {
        bc[i] += bc[i + 1];
    }

    ll ans = 0;

    for(int i = 0; i < N; i++) {
        ll x = upper_bound(B.begin(), B.end(), A[i]) - B.begin();
        ans += bc[x];
    }

    cout << ans << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	int n;
	int a;
	cin >> n;
	FOR(i, 1, n) {
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 != 0 && a % 5 != 0) {
				ps(DENIED);
				return(0);
			}
		}
	}
	ps(APPROVED);
	return(0);
}

Measured memory_bytes: 256
import sys
from itertools import permutations

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    edge = set()
    for _ in range(m):
        a, b = map(int, input().split())
        edge.add((a - 1, b - 1))
        edge.add((b - 1, a - 1))

    res = 0
    for pattern in permutations(range(n)):
        if pattern[0] == 0:
            for i in range(1, n):
                prev = pattern[i - 1]
                now = pattern[i]
                if (prev, now) not in edge:
                    break
            else:
                res += 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)

using namespace std;
typedef long long ll;

int a[22], b[22], c[22];

int main(){
    ios_base::sync_with_stdio(0);

    int n; cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n - 1; i++) cin >> c[i];

    int res = 0;
    for(int i = 0; i < n; i++){
        res += b[a[i] - 1];
        if(i != 0 && a[i] - a[i - 1]==1) res += c[a[i - 1] - 1];
    }
    cout << res;
}


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

int main(){
  ll N; cin>>N;
  map<ll, ll> R;
  for(ll i=0; i<N; i++){
    ll A; cin>>A;
    if(R.count(A)) R[A]++;
    else R[A]=1;
  }
  priority_queue<int> pq;
  ll count=0;
  for(auto p:R){
    auto k=p.first;
    auto v=p.second;
    if(v>=2){
      while(v>=2){
        pq.push(k);
        v=v/2;
      }
      count++;
    }
  }
  if(count<2) cout<<0<<endl;
  else{
    ll ans=pq.top();
    pq.pop();
    cout<<ans*pq.top()<<endl;
  }
}


Measured memory_bytes: 6528
//
//  main.c
//  q_01
//
//  Created by k19104kk on 2020/08/22.
//  Copyright © 2020 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n, x, t;
    
    scanf("%d %d %d", &n, &x, &t);
    
    if (n%x != 0) {
        printf("%d\n", (n/x+1)*t);
    } else {
        printf("%d\n", (n/x)*t);
    }
    
}


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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

void vprint(vector<ll> A){
    if(A.size()==0){
        p("");
    }else{
        cout << A[0];
        FOR(i, 1, A.size()){
            cout << " " << A[i];
        }
        cout << endl;
    }
}

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

    // input
    ll N, Q;
    cin >> N >> Q;

    list<ll> L[N];
    
    while(Q--){
        ll a;
        cin >> a;

        if(a==0){
            // insert
            ll t, x;        
            cin >> t >> x;
            L[t].push_back(x);
        }
        else if(a==1){
            // dump
            ll t;
            cin >> t;
            list<ll>::iterator it;
            for(it=L[t].begin(); it!=L[t].end(); it++){
                if(it!=L[t].begin()){
                    cout << " ";
                }
                cout << *it;
            }
            cout << endl;
        }
        else{
            // sprice
            ll s, t;
            cin >> s >> t;
            L[t].splice(L[t].end(), L[s]);
        }
    }
    
    return 0;
}


Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
  L=A+B;
  R=C+D;
  if(L>R){
    cout << "Left" << endl;
  }
  if(L==R){
    cout << "Balanced" << endl;
  }
  if(L<R){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8
import sys
sysread = sys.stdin.readline
from itertools import combinations
def run():
    N,M,Q = map(int, sysread().split())
    cri = []
    for _ in range(Q):
        cri.append(list(map(int,sysread().split())))

    ret = 0

    S = list(range(1, N+M))
    for j in combinations(S, N):
        tmp_arr = [j[0]]
        pre_val = j[0]
        for idx, val in enumerate(j[1:],1):
            tmp_arr.append(tmp_arr[idx-1] + val - pre_val - 1)
            pre_val = j[idx]
        total = 0
        for a,b,c,d in cri:
            a -= 1
            b -= 1
            if tmp_arr[b] - tmp_arr[a] == c:
                total += d
        ret = max(ret, total)
    print(ret)

if __name__ == "__main__":
    run()

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  while(true){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
        cout << ans << endl;
        return 0;
      }
    }
    for(int i = 0; i < n; i++){
      a[i] /= 2;
    }
    ans++;
  }
}

Measured memory_bytes: 3608
from heapq import heappop, heappush

x, y, a, b, c = map(int, input().split())
apple = []
# Red is 0, Green is 1, Colorless is 2
for p in map(int, input().split()):
  heappush(apple, (-p, 0))
for q in map(int, input().split()):
  heappush(apple, (-q, 1))
for r in map(int, input().split()):
  heappush(apple, (-r, 2))
delicious = 0
colorless = 0
while x + y > colorless:
  minus_taste, color = heappop(apple)
  if color == 0:
    if x > 0:
      delicious -= minus_taste
      x -= 1
  elif color == 1:
    if y > 0:
      delicious -= minus_taste
      y -= 1
  else:
    delicious -= minus_taste
    colorless += 1
print(delicious)

Measured memory_bytes: 44872
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; 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()
using namespace std;

int findIndex( int value );

int main(void){
    int A,B,ans=0;

    cin >> A >> B;

    if(A <=9 && B<=9)
        ans = A * B;
    else ans = -1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
int binarySearch(int *S,int key,int n);

int main(){
  int i,n,q,c,cnt = 0,value;
  int S[MAX],T[MAX];
  
  scanf("%d",&n);
  if(n>=100001) exit(1);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  if(q>=50001) exit(2);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    value = binarySearch(S,T[i],n);
    if(value != -1){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  
  return 0;
}

int binarySearch(int *S,int key,int n){
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid = (left + right)/2;
    if(S[mid] == key){
      return mid;
    }
    else if(key < S[mid]){
      right = mid;
    }
    else left = mid + 1;
  }
   return -1;
}



Measured memory_bytes: 2300
a=int(input())
b=int(input())
c=int(input())
x=int(input())
num=0
if a*500+b*100+c*50<x:
    print(0)
else:
    for i in range(0,a+1):
        for j in range(0,b+1):
            for k in range(0,c+1):
                if 500*i+100*j+50*k==x:
                    num+=1
    print(num)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
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);
}

int prime[10000007];
void SieveOfEratosthenes(ll n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (ll i=p*p; i*i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

vector<pair<ll, ll>> v;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        v.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            v.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        v.pb({n,1}); 
} 


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    //SieveOfEratosthenes(1e12);
    ll n;
    cin>>n;
    v.clear();
    factorize(n);
    ll ans=0;
    lp(0,v.size()){
        ll c=v[i].ss;
        ll sans=0;
        for(int i=1; i<=c; i++){
            if((i*(i+1))/2 <= c){
                sans=i;
            }
            else break;
        }
        ans += sans;
    }
    cout<<ans<<endl;
}

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

int main() {
  int N, N1, N2, N3, N4;
  cin >> N;
  N1 = N%10;
  N2 = (N/10)%10;
  N3 = (N/100)%10;
  N4 = (N/1000)%10;
    
  if (N2 == N3){
    if (N1 == N2 || N3 == N4){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int X;cin>>X;
    cout<<10-X/200<<endl;
}





Measured memory_bytes: 3652
program main
implicit None
	integer(8)::n,i,j,p
	integer(8),allocatable::h(:)
	
	read*,n
	allocate(h(n))
	read*,h
	
	p = 0
	do i = 1,n
		do
			if(h(i) == 0) exit
			do j = i,n
				if(h(j) == 0) exit
				h(j) = h(j)-1
			enddo
			p = p + 1
		enddo
	enddo
	print "(i0)",p
end program main

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int N;
int A[200000];

int main(void) {
    int i, max = 0, semimax = 0;
    bool maxdup = false;
    cin >> N;
    for (i = 0; i < N; i++) {
        cin >> A[i];
        if (max < A[i]) {
            semimax = max;
            max = A[i];
            maxdup = false;
        } else if (max == A[i]) {
            maxdup = true;
        } else if (semimax < A[i]) {
            semimax = A[i];
        }
    }

    for (i = 0; i < N; i++) {
        if (A[i] == max) {
            if (maxdup == false) {
                cout << semimax;
            } else {
                cout << max;
            }
        } else {
            cout << max;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;

/**
 * @author yoshida3203
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int X=sc.nextInt();
		int A=sc.nextInt();
		sc.close();

		if(X<A){
			System.out.println(0);
		}else{
			System.out.println(10);
		}

}

}


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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, k = rli()
    la = rli()
    MOD = len(la)
    lb = [-1 for _ in range(len(la))]
    periods = dict()
    for i, a in enumerate(la):
        periods.setdefault(a, [])
        periods[a].append(i)
    for v in periods.values():
        for i, e in enumerate(v):
            if i == len(v)-1:
                lb[e] = (v[0] + 1) % MOD
            else:
                lb[e] = (v[i+1] + 1) % MOD
    loop = [0]
    b = 0
    while True:
        nb = lb[b]
        if nb == 0:
            break
        if nb-b <= 1:
            loop.append(nb)
        b = nb
    # 周期を計算
    period = len(loop)
    if loop[-1] == len(loop)-1:
        loop.append(None)
        period += 1

    start = loop[(k-1)%period]
    if start is None:
        print()
        return
    lc = la[start:]

    counts = dict()
    for i, a in enumerate(lc):
        counts.setdefault(a, 0)
        counts[a] += 1

    ans = []
    target = None
    for a in lc:
        if target is None:
            count = counts[a]
            if counts[a] >= 2:
                target = a
            else:
                ans.append(a)
        else:
            counts[a] -= 1
            if a == target:
                counts[a] -= 1
                target = None
    # print(la[start:], lc)
    # print(lb, loop)
    print(" ".join(map(str, ans)))


if __name__ == '__main__':
    main()


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

ll dp[303][303][303];

void modadd(ll &a, ll b){
	a += b;
	a %= MOD;
}

vector<vector<P>> que(303);

int main(){
	
	ll n,m;cin >> n >> m;
	REP(i,m){
		ll a,b,c;cin >> a >> b >> c;
		que[b].EB(a,c);
	}
	
	dp[0][0][0] = 1;
	
	REP(i,n+1){
		REP(j,n+1){
			REP(k,n+1){
				if(dp[i][j][k] == 0)continue;
				int r = max(i,max(j,k));
				REP(ii,que[r].size()){
					int cou = 0;
					if(i >= que[r][ii].FI)cou++;
					if(j >= que[r][ii].FI)cou++;
					if(k >= que[r][ii].FI)cou++;
					if(cou != que[r][ii].SE)dp[i][j][k] = 0;
				}
				modadd(dp[r+1][j][k], dp[i][j][k]);
				modadd(dp[i][r+1][k], dp[i][j][k]);
				modadd(dp[i][j][r+1], dp[i][j][k]);
			}
		}
	}
	
	ll ans = 0;
	REP(i,n+1){
		REP(j,n+1){
			REP(k,n+1){
				int r = max(i,max(j,k));
				if(r == n){
					//cout << "seica " << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
					modadd(ans,dp[i][j][k]);
				}
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

int MinimumNumIncreasingSubsequences(long long int arr[], long long int n)
{
    multiset<int> last;

    // last element in each  increasing subsequence
    // found so far
    for (int i = 0; i < n; i++) {

        // here our current element is arr[i]
        multiset<int>::iterator it = last.lower_bound(arr[i]);

        // iterator to the first element larger
        // than or equal to arr[i]
        if (it == last.begin())

            // if all the elements in last larger
            // than or to arr[i] then insert it into last
            last.insert(arr[i]);

        else {
            it--;

            // the largest element smaller than arr[i] is the number
            // before *it which is it--
            last.erase(it); // erase the largest element smaller than arr[i]
            last.insert(arr[i]); // and replace it with arr[i]
        }
    }
    return last.size(); // our answer is the size of last
}

// Driver program
int main()
{
    long long int n;
    cin>>n;
    long long int arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
         cout<< MinimumNumIncreasingSubsequences(arr, n);
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, k, temp, ans;
    cin >> n >> k;
    map<int, int> mp;
    rep(i, n) {
        cin >> temp;
        mp[temp]++;
    }
    vector<int> t(mp.size());
    int j = 0;
    for(pair<int, int> p : mp) t.at(j++) = p.second;
    sort(t.begin(), t.end(), greater<int>());
    temp = 0;
    rep(i, min(k, (int)(mp.size()))) temp += t.at(i);
    ans = n - temp;
    cout << ans << endl;
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N + 1);
    Rep(i, M) cin >> A[i];
    vector<int> dp(N + 1);
    int index = 0;
    dp[0] = 1;
    for (int i = 1; i <= N; i++) {
        if (i == A[index]) {
            index++;
            continue;
        }
        else if (i == 1) dp[1] = 1;
        else dp[i] = (dp[i - 2] + dp[i - 1]) % 1000000007;
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm;

void main() {
  long[] xs = new long[](5);
  foreach (i; 0..5) {
    readf("%d\n", &xs[i]);
  }

  auto xss = permutations(xs);

  long ans = cast(long)1e10+7;
  foreach (ys; xss) {
    long t = 0;
    foreach (y; ys) {
      t += t % 10 == 0 ? 0 : 10 - (t % 10);
      t += y;
    }
    ans = min(t, ans);
  }

  writeln(ans);

}


Measured memory_bytes: 256
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    x = 0
    ans = 0

    for i in range(1, n):
        x = (x + a_list[i - 1]) % mod
        ans = (ans + a_list[i] * x) % mod

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  double n;

  while(cin >> n) {
    if(n > 91.00) cout << "heavy";
    else if(n > 81.00) cout << "light heavy";
    else if(n > 75.00) cout << "middle";
    else if(n > 69.00) cout << "light middle";
    else if(n > 64.00) cout << "welter";
    else if(n > 60.00) cout << "light welter";
    else if(n > 57.00) cout << "light";
    else if(n > 54.00) cout << "feather";
    else if(n > 51.00) cout << "bantam";
    else if(n > 48.00) cout << "fly";
    else cout << "light fly";
    cout << endl; 
  } 
}

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

typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;

/**
# of ways to select 3 sides that forms a non-deg. triangle
*/
int n , a[ N ];

int bin_search( int lo , int hi , int val ) {
        int l = lo , r = hi , ret1 = -1 , ret2 = -1;
        while( l <= r ) {
                int mid = ( l + r ) >> 1;
                if( a[mid] < val ) ret1 = mid , l = mid + 1;
                else r = mid - 1;
        }
        l = lo , r = hi;
        while( l <= r ) {
                int mid = ( l + r ) >> 1;
                if( a[mid] < val ) ret2 = mid , r = mid - 1;
                else r = mid - 1;
        }
        return ret1 == -1 ? 0 : ret1 - ret2 + 1;
}
int main( int argc , char const *argv[] ) {
        int t = 1;
        for( int tc = 1; tc <= t; tc++ ) {
                scanf("%d",&n);
                for( int i = 1; i <= n; i++ ) scanf("%d",&a[i]);
                sort( a + 1 , a + n + 1 );
                LL ans = 0;
                for( int i = 1; i <= n - 2; i++ ) {
                        for( int j = i + 1; j <= n - 1; j++ ) {
                                ans += bin_search( j + 1 , n , a[i] + a[j] );
                        }
                }
                printf("%lld\n",ans);
        }
        return 0;
}














Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int Z_algo(string s) {
    int n = s.length();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R - L] == s[R]) R++;
            z[i] = R - L; R--;
        }
        else {
            int k = i - L;
            if (z[k] < R - i + 1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R - L] == s[R]) R++;
                z[i] = R - L; R--;
            }
        }
    }
    int mx = 0;
    for (int i = 0; i < n; i++) mx = max(mx, min(i, z[i]));
    return mx;
}
const int mxN = 1e9 +7;

int main() {
    int n;
    cin >> n;
    int last = -1;
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x;cin >> x;
        if (x <= last) cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
        last = x;
    }
    cout << ans;
    return 0;
}

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

#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll>> //vvl data(10, vector<ll>(10);
#define fo(i,a,b) for(ll i=a; i<b; i++)

int main(){
    int x, y;
    cin >> x >> y;

    fo(i, 0, x+1){
        if(i*2 + (x-i)*4 == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
  int num,X[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};
  cin>>num;
  cout<<X[num-1];
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;
map<int, int> mp;

bool check(){
	REP(i, (n+1)/2){
		if(n % 2){
			if(i == 0){
				if(mp[2*i] != 1) return 0;
			}else{
				if(mp[2*i] != 2) return 0;
			} 
		}else{
			if(mp[2*i + 1] != 2) return 0;
		}
	}
	return 1;
}

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n;
	REP(i, n){
		int x;
		cin >> x;
		mp[x] ++;
	}
	if(!check()) cout << 0 << endl;
	else{
		ll ans = 1;
		REP(i, n/2) ans = ans * 2 % MOD;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}  
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        s: String,
        t: String,
    };

    if &s == &t[0..s.len()] {
        println!("Yes");
    } else {
        println!("No")
    }
}


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

main(){
  long N;
  cin >> N;
  long A[N],B[N],C[N];
  for(long ii=0;ii<N;ii++){
    cin >> A[ii];
  }
  for(long ii=0;ii<N;ii++){
    cin >> B[ii];
  }
  long n=0;
  long dec=0;
  for(long ii=0;ii<N;ii++){
    if(A[ii]<B[ii]){
      n++;//たりない個数
      dec+=B[ii]-A[ii];//足りない総和
      C[ii]=0;
    }
    else C[ii]=A[ii]-B[ii];//超過した分。
  }
  sort(C,C+N);
  long tmp=0;
  if(dec==0)tmp=1;
  for(long ii=N-1;ii>=0;ii--){
    dec-=C[ii];
    n++;
    if(dec<=0)break;
    if(ii==0)n=-1;
  }
  if(tmp==1)cout << 0 << endl;
  else cout << n << endl;
}


Measured memory_bytes: 2560
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

char table[10][11];
int H,W;
vector<char> ret;
int rem;
void search(int x, int y, int state){
	if(rem==0){
		for(auto item:ret){
			cout << item;
		}
		cout << endl;
		exit(0);
	}
	int dx[]={0,1,0,-1};
	int dy[]={1,0,-1,0};
	char ng[]={'L','U','R','D'};
	char dir[]={'R','D','L','U'};
	table[x][y]='.';
	for(int i=0;i<4;i++){
		if(state==ng[i])continue;
		int p=x+dx[i];
		int q=y+dy[i];
		while(0<=p&&p<H&&0<=q&&q<W){
			if(table[p][q]=='o'){
				rem--;
				ret.push_back(dir[i]);
				search(p,q,dir[i]);
				ret.pop_back();
				rem++;
				break;
			}
			p+=dx[i];
			q+=dy[i];
		}
	}
	table[x][y]='o';
}
int main() {
	cin >> H >> W;
	char state=0;
	int x=0,y=0;
	for(int i=0;i<H;i++){
		cin >> table[i];
		for(int j=0;j<W;j++){
			switch(table[i][j]){
				case '.':
					break;
				case 'o':
					rem++;
					break;
				default:
					x=i;
					y=j;
					state=table[i][j];
					break;
			}
		}
	}
	search(x,y,state);
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    vector<int> v0(100000, 0), v2(100000,0);
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) v0[v[i] - 1]++;
        else v2[v[i] - 1]++;
    }
    int max_num = 0, max_count = 0;
    int second_count = 0;
    for (int i = 0; i < 100000; i++) {
        if (v0[i] > max_count) {
            second_count = max_count;
            max_count = v0[i];
            max_num = i;
        } else {
            second_count = max(second_count, v0[i]);
        }
    }
    int max_num2 = 0, max_count2 = 0;
    int second_count2 = 0;
    for (int i = 0; i < 100000; i++) {
        if (v2[i] > max_count2) {
            second_count2 = max_count2;
            max_count2 = v2[i];
            max_num2 = i;
        } else {
            second_count2 = max(second_count2, v2[i]);
        }
    }
    // cout << max_count << " " << max_count2 << endl;
    if (max_num == max_num2) {
        cout << min(n - (max_count + second_count2), n - (max_count2 + second_count)) << endl;
    } else {
        cout << n - (max_count + max_count2) << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int a, b;
  cin >> a >> b;
  if (b % a == 0) {
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }
  return 0;
}


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

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define ff first
#define ss second
#define err stderr
#define out stdout

typedef long long int ll;
typedef long double ld;
typedef short int sh;

inline void readI(int *i)
{
	register int t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=(t*znak);
}
inline void readUI(int *i)
{
	register int t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=t;
}
inline void readL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak*=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=(t*znak);
}
inline void readUL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=t;
}
inline void writeL(ll l)
{
	if (l==0)
	{
		putchar(48);
	}
	else
	{
		if (l<0)
		{
		   l*=-1;
		   putchar(45);
		}
		int _tab[21];
		int wsk=0;
		while (l>0)
		{
			++wsk;
			_tab[wsk]=(l%10)+48;
			l/=10;
		}
		for (int j=wsk; j>=1; --j)
		{
			putchar(_tab[j]);
		}
	}
}
inline void writeS(string s)
{
	int l=s.length();
	for (int i=0; i<l; ++i)
	{
		putchar(s[i]);
	}
}
inline void space()
{
	putchar(32);
}
inline void endl()
{
	putchar(10);
}

#define debug if(0)
#define debug2 if(1)
#define debug3 if(1)
#define debug4 if(1)

int n, a;
int ile[5];
ld dp[305][305][305];

int main()
{
	readUI(&n);
	for (int i=1; i<=n; ++i)
	{
		readUI(&a);
		++ile[a];
	}
	for (int k=0; k<=n; ++k)
	{
		for (int j=0; j<=n; ++j)
		{
			for (int i=0; i<=n; ++i)
			{
				int c=n-i-j-k;
				if (!(i+j+k) || n<i+j+k)
				{
					continue;
				}
				ld x=0;
				if (i)
				{
					x+=(dp[i-1][j][k])*((ld)i/n);
				}
				if (j)
				{
					x+=(dp[i+1][j-1][k])*((ld)j/n);
				}
				if (k)
				{
					x+=(dp[i][j+1][k-1])*((ld)k/n);
				}
				dp[i][j][k]=(ld)(x+1)/((ld)1-(ld)c/n);
				debug
				{
					fprintf (err, "i=%d j=%d k=%d dp[i][j][k]=%Lf x=%Lf\n", i, j, k, dp[i][j][k], x);
				}
			}
		}
	}
	fprintf (out, "%0.12Lf\n", dp[ile[1]][ile[2]][ile[3]]);
	return 0;
}
/*
*/




Measured memory_bytes: 436480
n,m=map(int,input().split())
city=[[0,0,0,0] for _ in range(m)]
for i in range(m):
    p,y=map(int,input().split())
    city[i][0]=p
    city[i][1]=y
    city[i][2]=i
city=sorted(city, key=lambda x:(x[0], x[1]))

cnt=1
for j in range(m):
    ans=''
    ans+='{:06}'.format(city[j][0])
    ans+='{:06}'.format(cnt)
    city[j][3]=ans
    if j==m-1:
        continue
    elif city[j][0]==city[j+1][0]:
        cnt+=1
    else:
        cnt=1
city=sorted(city, key=lambda x:(x[2]))
for k in range(m):
    print(city[k][3])

Measured memory_bytes: 37404
#include <iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;

using namespace std;

int main(void){

    int N,M;
    cin >> N >> M;

    char A[N][N];
    char B[M][M];

    REP(i,N){
        REP(j,N){
            cin >> A[i][j];
        }
    }

    REP(i,M){
        REP(j,M){
            cin >> B[i][j];
        }
    }

    int diff = N - M +1;

    REP(i,diff){
        REP(j,diff){
            bool flag = false;
            REP(h,M){
                REP(w,M){
                    if(A[h+i][w+j] != B[h][w]){
                        flag = true;
                        break;
                    }
                }
                if(flag) break;
            }
            if(flag == false){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
dic = {}
time = 0
flag = 0

for _ in range(N):
    a, b = map(int, input().split())
    if b in dic:
        dic[b] += a
    else:
        dic[b] = a

deadlines = sorted(dic.keys())

for dead in deadlines:
    time += dic[dead]
    if time > dead:
        flag += 1

if flag:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 110036
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int n; std::cin >> n;
	std::string str; std::cin >> str;
	auto reversed = str; std::reverse(reversed.begin(), reversed.end());
	auto hash = [](const std::pair<std::string, std::string>& pair) {return std::hash<std::string>()(pair.first) ^ std::hash<std::string>()(pair.second); };
	std::unordered_map<std::pair<std::string, std::string>, int, decltype(hash)> map(1 << n, hash);
	for (auto i = 0; i < (1 << n); ++i) {
		std::string blue, red;
		for (auto j = 0; j < n; ++j) {
			if ((i & (1 << j)) != 0) blue.push_back(str[j]);
			else red.push_back(str[j]);
		}
		map[std::make_pair(blue, red)]++;
	}
	long long int result = 0;
	for (auto i = 0; i < (1 << n); ++i) {
		std::string blue, red;
		for (auto j = 0; j < n; ++j) {
			if ((i & (1 << j)) != 0) blue.push_back(reversed[j]);
			else red.push_back(reversed[j]);
		}
		result += map[std::make_pair(blue, red)];
	}
	std::cout << result << std::endl;
}

Measured memory_bytes: 45308
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int h,w;
	cin>>h>>w;
	int a[h+5][w+5];
	int k=0;
	for(int i=0; i<=h+1; i++){
		for(int j=0; j<=w+1; j++){
			a[i][j]=1e9;
		}
	}
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			char dum;
			cin>>dum;
			if(dum=='#'){
				a[i][j]=0;
			}else {
				a[i][j]=1e9;
				k++;
			}
		}
	}
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			a[i][j]=min(a[i][j],min(a[i-1][j],min(a[i+1][j],min(a[i][j-1],a[i][j+1])))+1);
		}
	}
	for(int i=h; i>=1; i--){
		for(int j=w; j>=1; j--){
			a[i][j]=min(a[i][j],min(a[i-1][j],min(a[i+1][j],min(a[i][j-1],a[i][j+1])))+1);
		}
	}
	int maxi=0;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			maxi=max(maxi,a[i][j]);
		}
	}
	cout<<maxi<<endl;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
  int a, b, x;
  scanf("%d%d%d", &a, &b, &x);
  if(a <= x && x <= a + b) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}


Measured memory_bytes: 888
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b, c = [0] * q, [0] * q
for i in range(q):
    b[i], c[i] = map(int, input().split())

sum = 0
kazu = [0] * (10**5+1) 
for i in a:
    kazu[i] += 1
    sum += i
for i in range(q):
    cnt = kazu[b[i]]
    kazu[b[i]] = 0
    kazu[c[i]] += cnt
    sa = c[i] - b[i]
    sum += (sa * cnt)
    print(sum)

Measured memory_bytes: 85192
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
	ll A, B;
	cin >> A >> B;
	ll cnt = 0;
	rep(i, A, B + 1){
		string tempA = to_string(i);
		string tempB = tempA;
		reverse(begin(tempB), end(tempB));
		if (tempA == tempB) cnt++;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string x;
    cin >> x;
    int a,b,c,d;
    a = x[0]-48;
    b = x[1]-48;
    c = x[2]-48;
    d = x[3]-48;
    int s[4] = {a,b,c,d};
    for (int i=0; i<8; i++){
        int ans = s[0];
        int flag[3];
        for (int j=0; j<3; j++){
            if (i & (1<<j)){
                ans = ans - s[j+1];
                flag[j] = 1;
            }
            else{
                ans = ans + s[j+1];
                flag[j] = 0;
            }
        }
        if (ans == 7){
            //pythonだとintの第二引数で基数を指定することができるから下のようなやり方ができると思う。
            //cout<<a<<i[0]<<b<<i[1]<<c<<i[2]<<d<<i[3]<<endl
            cout<<a;
            if (flag[0]==0){
                cout<<'+';
            }else{
                cout<<'-';
            }
            cout<<b;
            if (flag[1]==0){
                cout<<'+';
            }else{
                cout<<'-';
            }
            cout<<c;
            if (flag[2]==0){
                cout<<'+';
            }else{
                cout<<'-';
            }
            cout<<d<<"=7"<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int f[110000];
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        f[a]++;
    }
    for (int i = 0; i < 100000; i++) {
        int ans = f[i - 1] + f[i] + f[i + 1];
        res = max(res, ans);
    }
    cout << res << endl;
}


Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int p, m, c;

int main() {
	cin >> p >> m >> c;
	cout << p + m + c << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint N, M;
	cin >> N >> M;
	vector<lint>A(N);
	vector<lint>B(N);
	vector<lint>C(M);
	vector<lint>D(M);
	rep(i, N) {
		cin >> A[i] >> B[i];
	}
	rep(i, M) {
		cin >> C[i] >> D[i];
	}
	lint m = 10000000000;
	rep(i, N) {
		rep(j, M) {
			m = min(m, abs(A[i] - C[j]) + abs(B[i] - D[j]));
		}
		rep(j, M) {
			if (abs(A[i] - C[j]) + abs(B[i] - D[j]) == m) {
				cout << j+1 << endl;
				break;
			}
		}
		m = 10000000000;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	5005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int value[MAXN];
vector <int> a[MAXN];
bool check(int pos, int fa) {
	bool ans = false;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa && value[a[pos][i]] < value[pos]) {
			ans |= !check(a[pos][i], pos);
		}
	return ans;
}
int main() {
	int n; read(n);
	for (int i = 1; i <= n; i++)
		read(value[i]);
	for (int i = 1; i < n; i++) {
		int x, y;
		read(x), read(y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (int i = 1; i <= n; i++)
		if (check(i, 0)) printf("%d ", i);
	printf("\n");
	return 0;
}

Measured memory_bytes: 512