akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void)
{
    int n,card[4][13],i,j,number,gara;
    char ch,mark;
    
    for(i=0;i<4;i++)
    {
        for(j=1;j<=13;j++) card[i][j]=0;
    }
    
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%c",&ch);
        scanf("%c %d",&mark,&number);
        
        if(mark=='S') gara=0;
        else if(mark=='H') gara=1;
        else if(mark=='C') gara=2;
        else if(mark=='D') gara=3;
        
        card[gara][number]=1;
    }
    
    for(i=0;i<4;i++)
    {
        for(j=1;j<=13;j++)
        {
            if(card[i][j]==0)
            {
                if(i==0) mark='S';
                else if(i==1) mark='H';
                else if(i==2) mark='C';
                else if(i==3) mark='D';
                
                printf("%c %d\n",mark,j);
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 2036
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,fractions
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))
def inpl_str(): return list(sys.stdin.readline().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n,k = inpl()
ab = []
for i in range(n):
    a,b = inpl()
    ab.append([a,b])
ab.sort()
cnt = 0
for i in range(n):
    if cnt + ab[i][1] >= k:
        print(ab[i][0])
        break
    else:
        cnt += ab[i][1]



Measured memory_bytes: 22684
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << ' ' << x << ' ' << y << "\n";

	return 0;
}

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

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

using namespace std;
using lint=long long;

int n[3];
lint a[3][1000];

struct state{
	int i,j,k;
	state(int i,int j,int k):i(i),j(j),k(k){}
	int &operator[](int l){
		if     (l==0) return i;
		else if(l==1) return j;
		else          return k;
	}
};

lint value(state x){
	lint res=0;
	rep(i,3) res+=a[i][x[i]];
	return res;
}

bool operator<(state x,state y){
	if(value(x)!=value(y)) return value(x)<value(y);
	rep(i,3) if(x[i]!=y[i]) return x[i]<y[i];
	return false;
}

int main(){
	rep(i,3) cin>>n[i];
	int k; cin>>k;
	rep(i,3){
		rep(j,n[i]) cin>>a[i][j];
		sort(a[i],a[i]+n[i],greater<lint>());
	}

	priority_queue<state> Q;
	Q.emplace(0,0,0);
	set<state> Vis;
	Vis.emplace(0,0,0);
	rep(_,k){
		auto x=Q.top(); Q.pop();
		cout<<value(x)<<endl;
		rep(i,3) if(x[i]<n[i]-1) {
			x[i]++;
			if(Vis.count(x)==0){
				Q.emplace(x);
				Vis.emplace(x);
			}
			x[i]--;
		}
	}

	return 0;
}


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

int main(){
  int n;
  cin>>n;
  ll ans=0;
  ll vec[n];
  map<ll,ll> ma;
  for(int i=0;i<n;i++){
    cin>>vec[i];
    ma[i+1-vec[i]]++;
  }
  for(int i=0;i<n;i++){
    ans+=ma[i+1+vec[i]];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 27908
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double max = 0;
    int water=0;
    int sugar=0;
    for (int i = 0; 100 * a * i <= f; i++)
    {
        for (int j = 0; 100 * a * i + 100 * b * j <= f; j++)
        {
            for (int k = 0; 100 * a * i + 100 * b * j + k * c <= f && k * c <= (a * i + b * j) * e; k++)
            {
                for (int l = 0; 100 * a * i + 100 * b * j + k * c + l * d <= f && (k * c + l * d) <= (a * i + b * j) * e; l++)
                {
                    if ((double(k * c + l * d) / (100 * a * i + 100 * b * j + k * c + l * d))>=max){
                        max = double(k * c + l * d) / (100 * a * i + 100 * b * j + k * c + l * d);
                        water = 100 * a * i + 100 * b * j;
                        sugar = k * c + l * d;
                    }
                }
            }
        }
    }
    cout << water + sugar << " " << sugar << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    string num;
    int ans;
    if (0 == M)
    {
        switch (N)
        {
        case 1:
            cout << 0 << endl;
            break;

        case 2:
            cout << 10 << endl;
            break;
        
        case 3:
            cout << 100 << endl;
        }
        return 0;
        
    }
    for (int i = 0; i < N; i++)
    {
        num.push_back('a');
    }

    int s;
    char c;
    for (int i = 0; i < M; i++)
    {
        cin >> s >> c;
        if (num[s - 1] == 'a')
        {
            num[s - 1] = c;
        }else
        {
            if (c != num[s - 1])
            {
                cout << -1 << endl;
                return 0;
            }
            
        }
        
    }

    if (num.size() > 1)
    {
        if (num[0] == 'a') num[0] = '1';
        if (num[0] == '0')
        {
            cout << -1 << endl;
            return 0;
        }

    }

    for (int i = 1; i < num.size(); i++)
    {
        if (num[i] == 'a') num[i] = '0';
    }
    
    ans = stoi(num);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <iomanip>
#include <fstream>
#include <ctime>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    int n;
    cin >> n;
    int x, ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        if (i % 2 == 1 && x % 2 == 1)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
using var = long long;
#define rep(i,n) for(var i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<var> a(n);rep(i,n){cin>>a[i];}
#define in(a) var a;cin>>a;
#define out(a) cout<<a;
int main()
{
	in(n);
	repin(w, n);
	var sum = accumulate(w.begin(), w.end(),0ULL);
	var s = 0;
	var m = numeric_limits<var>().max();
	rep(i, n-1) {
		s += w[i];
		m = min(m,abs(sum - s - s));
	}
	out(m);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

P calc(ll a) {
	P res;
	res.second = a % 10;
	while (a >= 10) {
		a /= 10;
	}
	res.first = a;
	return res;
}

int main() {
	IOS;
	ll n;
	cin >> n;
	vector<vector<ll>> c(10, vector<ll>(10, 0));
	FOR(i,1, n+1) {
		P p = calc(i);
		c[p.first][p.second]++;
	}
	ll res = 0;
	FOR(i,1, 10) {
		FOR(j,1, 10) {
			res += c[i][j] * c[j][i];
		}
	}
	put(res);
	return 0;
}


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

int main(){
   int N,W;
   cin >> N >> W;
   int v[N],w[N];
   for(int i=0;i<N;i++)
      cin >> v[i] >> w[i];
   int DP[N+1][W+1];
   for(int j=0;j<=W;j++)
      DP[0][j]=0;
   for(int i=1;i<=N;i++)
      for(int j=0;j<=W;j++)
         if(j<w[i-1])
            DP[i][j]=DP[i-1][j];
         else{
            if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1])
               DP[i][j]=DP[i-1][j];
            else
               DP[i][j]=DP[i][j-w[i-1]]+v[i-1];
         }
   cout << DP[N][W] << endl;
   return 0;
}

Measured memory_bytes: 7000
from itertools import accumulate
n, W = [int(item) for item in input().split()]
wv = [[] for _ in range(4)]
for i in range(n):
    w, v = [int(item) for item in input().split()]
    if i == 0:
        w1 = w
    wv[w-w1].append(v)
for i in range(4):
    wv[i] = sorted(wv[i], reverse=True)
    wv[i] = [0] + list(accumulate(wv[i]))

ans = 0
for i in range(len(wv[0])):
    for j in range(len(wv[1])):
        for k in range(len(wv[2])):
            for l in range(len(wv[3])):
                if j*1 + k*2 + l*3 <= W - w1*(i+j+k+l):
                    ans = max(ans, wv[0][i] + wv[1][j] + wv[2][k] + wv[3][l])
print(ans)

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

int main(void){
    int n,m,l;
    cin >> n >> m >> l;
    int a[n][m];
    int b[m][l];
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin >> b[i][j];
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            long d = 0;
            for(int k=0;k<m;k++){
                d+=a[i][k]*b[k][j];
            }
            cout << d;
            if(j==l-1){
                cout << endl;  
            }else{
                cout << " ";
            }
            
        }
    }
    
    return 0;
}



Measured memory_bytes: 3152
#include <stdio.h>

int main(){
	int i, num;
	char number[1001];
	scanf("%s",number);
	while(number[0] != '0'){
		num = 0;
		for(i = 0;number[i] != '\0';i++){
			num += number[i] - '0';
		}
		printf("%d\n", num);
		scanf("%s",number);
	}
	return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0; // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

ll N;
ll sum = 0;
ll times = 0;
ll A[100010];
ll B[100010];
ll D[100010];

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> A[i];
    sum += A[i];
  }
  ll NN = (N * (N+1) / 2);
  if (sum % NN != 0) {
    cout << "NO" << endl;
    return 0;
  }
  times = sum / NN;
  A[N] = A[0];
  for (auto i = 0; i < N; ++i) {
    B[i] = A[i+1] - A[i];
  }
  for (auto i = 0; i < N; ++i) {
    B[i] -= times;
  }
  for (auto i = 0; i < N; ++i) {
    if (B[i] <= 0 &&  B[i]%N == 0) {
      D[i] = B[i]/N;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 2560
#mult 10**9 
import sys
input = sys.stdin.readline
from decimal import Decimal
from math import gcd
from collections import Counter
n=int(input())
a=[int(Decimal(input())*10**9) for _ in range(n)]

tf = []

for i in range(n):
    t=0;f=0;
    while a[i]%2==0:
        t+=1
        a[i]//=2
    while a[i]%5==0:
        f+=1
        a[i]//=5
    tf.append((t-9,f-9))

ctf = Counter(tf)
ans=0
for t,f in ctf:
    for t2,f2 in ctf:
        if t+t2>=0 and f+f2>=0:
            if t!=t2 or f!=f2:
                ans+= ctf[(t,f)]*ctf[(t2,f2)]
            else:
                ans+= ctf[(t,f)]*(ctf[(t,f)]-1)
print(ans//2) 




Measured memory_bytes: 290940
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        var town = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var hero = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        long monster = 0;
        for(int i=N-1;i>=0;i--){
            if(town[i+1]>=hero[i]){
                town[i+1] -= hero[i];
                monster += hero[i];
            }else{
                hero[i] -= town[i+1];
                monster += town[i+1];
                town[i+1] = 0;
                if(town[i]>hero[i]){
                    town[i] -= hero[i];
                    monster += hero[i];
                }else{
                    monster += town[i];
                    town[i] = 0;
                }
            }
        }
        Console.WriteLine(monster);
    }
}

Measured memory_bytes: 36164
#include<stdio.h>
 
#define MAXLEN 20000
 
int garea,gareas[(MAXLEN/2)+1],gcnt,gend;
 
 
int getArea( char *inputs, int start, int end )
{
    int i;
    int ravine,water;
    
    gareas[gcnt]=ravine=water=0;
    for( i=start; i!=end; i++ ) {
        if( '\\'== *(inputs+i) ) {
           	water+=(ravine*2);
            ravine++;
            water++;
        } else if( 0 != ravine && '/' == *(inputs+i) ) {
        	ravine--;
        } else {
	     	water+=ravine;
        }       
    }
	gareas[gcnt]+=water;
    
    return gareas[gcnt];
}
  
int checkRavine( char *inputs, int start )
{
    int i;
    int ravine, minh, tmpi;
    
    ravine=0;
    tmpi=minh=MAXLEN;
    for( i=start; i<=gend && '\0'!=*(inputs+i); i++ ) {
        if( '\\'== *(inputs+i) ) {
            ravine++;
        } else if( 0 != ravine && '/' == *(inputs+i) ) {
            ravine--;
            if( ravine < minh ) {
        		minh=ravine;
        		tmpi=i;
            }
            if( 0 == ravine ) {
            	garea+=getArea( inputs, start, i+1 );
            	gcnt++;
			    gend=MAXLEN;           	
                return i-start;
            }
        }
    }
	gend=tmpi;
    return 0;
}
 
 
void getAreas( char *inputs )
{
    int i,next;
     
    next=0;
    for( i=0; '\0'!=inputs[i]; i++ ) {
    	if( '_' !=inputs[i] ) {
	        next=checkRavine( inputs, i );
	        i+=next;
        }
    }
 
    return;
}
 
int main( void ) 
{
    char inputs[MAXLEN+1];
    int i;
 
    scanf( "%s", inputs );
    garea=gcnt=0;
    gend=MAXLEN;
    getAreas( inputs );
     
    printf( "%d\n", garea );
    
    if( gcnt ) {
        printf( "%d ", gcnt );
        for( i=0; i<gcnt; i++ ) {
            printf( "%d", gareas[i] );
            if( i < gcnt-1 ) {
            	printf( " " );  
            }
        }
        printf( "\n" );
       
    } else {
        printf( "0\n" );
    }
     
    return 0;
}

Measured memory_bytes: 576
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 2e3 + 5;
const int Mod = 1e9 + 7;

int h, w;
char m[MAX][MAX];
int A[MAX][MAX], B[MAX][MAX];
int main()
{
    cin >> h >> w;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> m[i][j];
        }
    }
    int cnt;
    for(int i = 1; i <= h; i++){
        int l = 1, r = 1;// [)
        while(1){
            cnt = 0;
            while(r <= w && m[i][r] != '#')
                r++, cnt++;
            for(int j = l; j < r; j++)
                A[i][j] = cnt;
            while(r <= w && m[i][r] == '#')
                r++;
            l = r;
            if(l > w) break;
        }
    }
    for(int i = 1; i <= w; i++){
        cnt = 0;
        int l = 1, r = 1;
        while (1)
        {
            cnt = 0;
            while(r <= h && m[r][i] != '#')
                r++, cnt++;
            for(int j = l; j < r; j++)
                B[j][i] = cnt;
            while(r <= h && m[r][i] == '#')
                r++;
            l = r;
            if(l > h) break;
        }
    }
    int Max = 0;
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++){
            Max = max(Max, A[i][j] + B[i][j]);
        }
    cout << Max-1 << endl;
    return 0;
}

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

int main() {
int a,b;
char op;
while(1){cin>>a>>op>>b;
if(op=='?') break;
if(op=='+')cout<< a+b <<endl;
else if(op=='-')cout<< a-b <<endl;
else if(op=='*')cout<< a*b <<endl;
else if(op=='/')cout<< a/b <<endl;


}
	// your code goes here
	return 0;
}

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

int main()
{
	int i;
	double a, sum;
	cout<<setprecision(8);
	cout<<setiosflags(ios::fixed);
	while (cin>>a) {
		sum = 0.0;
		for (i = 1; i <= 10; i++) {
			sum += a;
			if (i&1) a *= 2.0;
			else a /= 3.0;
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 0
/*
* welcome to my code!
* ------------------------------------------
* author : lynmisakura(twitter : @andoreiji11)
*/

#include<bits/stdc++.h>
using namespace std;

using ll = long long;

// macro templates

#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < n;i++)
#define dv(TYPE,VAL) TYPE VAL;cin >> VAL;
#define vi(TYPE,NAME,SIZE,INIT) vector<TYPE> NAME(SIZE,(INIT))
#define vin(TYPE,NAME,SIZE) vector<TYPE> NAME(SIZE);rep(i,SIZE)cin >> NAME[i]
#define vout(ARRAY) for(auto i : ARRAY)cout << i << ' ';cout << '\n'
#define vvi(TYPE,NAME,LOW,COL,INIT) vector<vector<TYPE>> NAME(LOW,vector<TYPE>(COL,INIT))
#define vpi(T1,T2,NAME,SIZE,I1,I2) vector<pair<T1,T2>> NAME(SIZE,make_pair(I1,I2))
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define dup(x,y) (x + y - 1)/y
#define sz(v) (int64_t)v.size()
#define CUM(arr,cum) vector<ll> cum(sz(a)+1,0); rep(i,sz(a)) cum[i+1] = cum[i] + 1
#define PY(COND) if(COND){cout << "YES" << '\n';return;}
#define PN(COND) if(COND){cout << "NO" << '\n';return;}
#define PYN(COND) cout << ((COND) ? "YES" : "NO") << '\n';return
#define Py(COND) if(COND){cout << "Yes" << '\n';return;}
#define Pn(COND) if(COND){cout << "No" << '\n';return;}
#define Pyn(COND) cout << ((COND) ? "Yes" : "No") << '\n';return

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pi acos(-1)
#define fi first
#define se second
#define pq priority_queue

#define MULTITEST; int t;cin >> t;rep(_,t)main2();
#define IOB; cin.tie(0);ios::sync_with_stdio(false);

template<class T> bool chmin(T& a,T b){if(a>b){a=b;return 1;}else return false;}
template<class T> bool chmax(T& a,T b){if(a<b){a=b;return 1;}else return false;}

// templates end

void main2(){

}

int main(void){
    IOB;
    //MULTITEST

    string s;cin >> s;
    cout << s.substr(0,3) << '\n';

}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
ll n,k,x,y;
 
int main(){
  ll ans=llMIN;
  cin >> n >> k;
  
  vi p(n),c(n);
  REP(i,n){
    cin>>p[i];
    p[i]--;
    }
  REP(i,n) cin>>c[i];
 
  vvi data(n, vi(n));  // N * M の2次元配列
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      data[i][j]=llMIN;
    }
  }
 
  ll nowmasu=-1;
  ll score=0;
  for(ll i=0;i<n;i++){//最初に選ぶマス
    nowmasu=i;
    score=0;
    //data[i][i]=0;//score
    ll cnt=0;
    for(ll j=0;j<min(k,n);j++){
      if (data[i][p[nowmasu]]!=llMIN)break;
      nowmasu=p[nowmasu];
      score+=c[nowmasu];
      cnt++;
      data[i][nowmasu]=score;
      ans=max(ans,score);
    }
    //今のnowmasuは必ず最初の地点
    if (k!=cnt){
      ll nnum=(k-cnt)/cnt;
      score*=nnum;
      if (nnum!=0)ans=max(ans,score);
      ll kk=k-nnum*cnt;
      
      for(ll j=0;j<kk;j++){
        nowmasu=p[nowmasu];
        score+=c[nowmasu];
        ans=max(ans,score);
      }
    }
 
    
 
  }
 
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 198848
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    double x;
    if(n==1)
        {
            x=n/n;
        }
    if(n%2==0)
    {
        double y=n/2;
        x=y/n;
    }
    else{
        double y=n/2;
        y+=1;
        x=y/n;
    }
    cout<<fixed<<setprecision(10)<<x<<endl;
    return 0;
}


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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll a,b;
        cin>>a>>b;
        cout<<a*b;

    }
    return 0;
}


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

#define N 60

int arr[N], cnt[N], n, m;

int main()
{
	scanf("%d", &n);
	cnt[0] = 1;
	for(int i = 0; i < n; ++i)
	{
		int x; scanf("%d", &x);
		cnt[x] ++;
	}

	n = 0;
	for(int k = 0; k <= 12; ++k)
	{
		if(cnt[k] > 2)
		{
			printf("0\n");
			return 0;
		}
		if(cnt[k] == 1) arr[n ++] = k;
	}

	const int u = 1 << n;

	m = n;
	for(int k = 0; k <= 12; ++k)
		if(cnt[k] == 2)
		{
			arr[m ++] = k;
			arr[m ++] = 24 - k;
		}

	int ans = 0;
	for(int k = 0; k < u; ++k)
	{
		int cur = 0x7fffffff;
		for(int i = 0; i < m; ++i)
		{
			int x = (i < n) ? (((k >> i) & 1) ? arr[i] : 24 - arr[i]) : arr[i];
			for(int j = i + 1; j < m; ++j)
			{
				int y = (j < n) ? (((k >> j) & 1) ? arr[j] : 24 - arr[j]) : arr[j];
				int d = std::abs(x - y);
				cur = std::min(cur, std::min(d, 24 - d));
			}
		}
		ans = std::max(ans, cur);
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef gp_hash_table<int, null_type,hash<int>, equal_to<int>, direct_mask_range_hashing<int>, linear_probe_fn<>,
    hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>,true>> hash_set;
typedef gp_hash_table<int,null_type> hash_map;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 100005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

const ld PI = (ld)4*atanl(1);

mt19937 g1(chrono::steady_clock::now().time_since_epoch().count());

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,K,arr[MAXN];
ll res,f[MAXN];

ll inv(ll a){
    ll x1 = 1, b1 = a, x2 = 0, b2 = MOD;
    while(b2){
        ll q = b1/b2;
        b1-=q*b2, x1-=q*x2;
        swap(x1,x2);
        swap(b1,b2);
    }
    return ((x1%MOD)+MOD)%MOD;
}

ll cnk(ll n, ll k){
    if(k > n) return 0;
    ll q = (inv(f[k])*inv(f[n-k]))%MOD;
    return (f[n]*q)%MOD;
}

int main(){
    scanf("%d %d",&len,&K);
    for(int i=1; i<=len; i++)
        scanf( "%d",&arr[i]);
    f[0] = 1;
    for(int i=1; i<=len; i++)
        f[i] = (f[i-1]*i)%MOD;
    sort(arr+1,arr+len+1);
    for(int i=2; i<=len; i++){
        ll tot = cnk(len,K)*(arr[i]-arr[i-1])%MOD;
        ll rem = cnk(i-1,K)*(arr[i]-arr[i-1])%MOD;
        ll rem2 = cnk(len-i+1,K)*(arr[i]-arr[i-1])%MOD;
        tot = (tot-rem+MOD)%MOD;
        tot = (tot-rem2+MOD)%MOD;
        res = (res+tot)%MOD;
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 1408
a,b,c = map(int,input().split())
for i in range(c):
    if i%2 == 0:
        if a%2 !=0:
            a = a-1
        a /= 2
        b += a
    else:
        if b%2 !=0:
            b = b-1
        b /= 2
        a += b
d = int(a)
e = int(b)
print(d,e)


Measured memory_bytes: 3064
n = int(input())
ai = list(map(int,input().split()))
a = [0]
for i in ai:
  a.append(i)
al = [0] * (n+1)
for i in range(n+1):
  al[i] = abs(a[(i+1)%(n+1)] - a[i])
s = sum(al)
for i in range(1,n+1):
  print(s-al[i-1]-al[i]+abs(a[(i+1)%(n+1)]-a[i-1]))

Measured memory_bytes: 14176
import Control.Applicative

main :: IO ()
main = do
    cs <- getContents
    putStr $ unlines $ map show $ solve $ map read (lines cs)

solve :: [Int] -> [Int]
solve [] = []
solve (n':ns) = (solve' n'):(solve ns)
    where
        solve' :: Int -> Int
        solve' n = length $ takeWhile (\x -> x <= n) primes

primes = 2:3:[x|i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x]
    where
        isPrime n = null [i|i<-takeWhile (\x->x*x<=n) primes, rem n i == 0]

Measured memory_bytes: 10132
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

struct Node {
	int a, b, ma, mb;
	
	Node() {}
	Node(int a, int b, int ma, int mb) : a(a), b(b), ma(ma), mb(mb) {}
};

int n;
Node node[100];
bool istop[100];

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

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

int dfs(int pos) {
	Node &now = node[pos];
	
	int a = now.a, b = now.b, ma = now.ma, mb = now.mb;
	
	ma = ma ? dfs(ma - 1) : 1;
	mb = mb ? dfs(mb - 1) : 1;
	
	int l = lcm(a * ma, b * mb);
	return l / a + l / b;
}

int main() {
	while (cin >> n, n) {
		fill(istop, istop + n, false);
		
		REP(i, n) {
			int a, b, ma, mb;
			scanf("%d %d %d %d", &a, &b, &ma, &mb);
			int g = gcd(a, b);
			//a /= g; b /= g;
			node[i] = Node(a, b, ma, mb);
			
			if (ma != 0) istop[ma - 1] = true;
			if (mb != 0) istop[mb - 1] = true;
		}
		
		int st = 0;
		while (istop[st]) st++;
		cout << dfs(st) << endl;
	}
	return 0;
}

// 2:00

Measured memory_bytes: 3136
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
void fx(vector<int> &a,int n, int m){

}

// -----------------------------------------------------------------------

int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}

// -----------------------------------------------------------------------



void q1(){
	int n;
	cin>>n;
	n*=(n+1);
	n/=2;
	cout<<n;
}
// -----------------------------------------------------------------------


void q2(){
	string s,t;
	cin>>s;
	t="";
	int skip=0;
	for(int i=(int)s.size()-1;i>=0;i--){
		if(s[i]=='B'){
			skip++;
		} else{
			if(skip>0){
				skip--;
			} else{
				t+=s[i];
			}
		}
	}
	for(int i=sz(t)-1;i>=0;--i)
	cout<<t[i];
}

// -----------------------------------------------------------------------

void q3(){
	int n;
	cin>>n;
	input(n);
	ld sum=0;
	for(int i=0;i<n;++i){
		sum+=arr[i];
	}
	sum/=n;
	int l=sum;
	sum+=1.00;
	int u=sum;
	int pp,p;
	pp=0;
	sum=l;
	for(int i=0;i<n;++i){
		pp+=((arr[i]-sum)*(arr[i]-sum));
	}p=0;sum=u;
	for(int i=0;i<n;++i){
		p+=((arr[i]-sum)*(arr[i]-sum));
	}
	cout<<min(p,pp);
}


// -----------------------------------------------------------------------

void q4(){
	string s;
	cin>>s;
	int xp=sz(s);
	for(int i=0;i<xp-2;++i){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return ;
		}
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return ;
		}
	}
	if(s[xp-1]==s[xp-2]){
		cout<<xp-1<<" "<<xp<<endl;
		return ;
	}
	cout<<"-1 -1\n";
	return ;
}

// -----------------------------------------------------------------------


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q2();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, D;
  cin >> N >> D;
  ll x, y;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    if (x * x + y * y <= D * D) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
using namespace std;
const int N=300005;
int n,m,ans=1,cnt,ok;
int x[N],t[N],l[N],r[N];
int main(){
	scanf("%d%d",&n,&m); m*=2;
	For(i,1,n) scanf("%d",&x[i]);
	For(i,1,n) scanf("%d",&t[i]);
	For(i,1,n){
		int v=t[i]%m;
		ans+=t[i]/m+(t[i]%m!=0);
		l[i]=(0<v&&v<=2*x[i]);
		r[i]=(0<v&&v<=m-2*x[i]);
	}
	For(i,1,n-1)
		if (cnt&&r[i]){
			if (l[i]) ++ok;
			--ans; --cnt;
		}
		else if (l[i]) cnt++;
		else if (r[i]&&ok) ok--,cnt++;
	if (r[n]) ans--;
	printf("%lld",1ll*ans*m);
}

Measured memory_bytes: 4992
# 俺はBFSが実装できるようになる！！！
from collections import deque

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    edges[a].append(b)
    edges[b].append(a)

next_v = deque([0])
INF = 10**18
# 0からの距離を保存する部分
dist = [INF]*n
dist[0] = 0
# 1からnまででどこからきたのか記述する
prev = [-1]*n
while next_v:
    v1 = next_v.popleft()
    for v2 in edges[v1]:
        if dist[v2] != INF:
            continue
        dist[v2] = dist[v1] + 1
        prev[v2] = v1
        next_v.append(v2)

if min(prev[1:]) == -1:
    print('No')
else:
    print('Yes')
    ans = [x+1 for x in prev[1:]]
    print(*ans, sep='\n')


Measured memory_bytes: 40612
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x,k,s1=0,s2=0;
    scanf("%d%d%d",&n,&m,&x);
    for(int i=0;i<m;i++)
        {
            scanf("%d",&k);
            if(k>x)
                s1++;
            else s2++;
        }
        printf("%d\n",min(s1,s2));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int D;
    cin >> D;
    if(D == 22)cout << "Christmas Eve Eve Eve" << endl;
    else if(D == 23)cout << "Christmas Eve Eve" << endl;
    else if(D == 24)cout << "Christmas Eve" << endl;
    else if(D == 25)cout << "Christmas" << endl;
return 0;
}


Measured memory_bytes: 256
N,Y = map(int,input().split())
ans = [-1,-1,-1]
for x in range(N+1) :
    man = x * 10000
    for y in range(N+1-x) :
        gosen = y * 5000
        sen = (N-x-y) * 1000
        if (man+gosen+sen) == Y :
            ans = [x,y,N-x-y]
print(*ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007


int N;
int A[1005][1005];

int matchNum(int i,int j){//0~M-1
    if(i>j)return matchNum(j,i);
    if(i==0)return j-i-1;
    else return (N-1+N-i)*i/2+(j-i)-1;
}

int dist[10005*10005/2];
int start[10005*10005/2];
int ifvis[10005*10005/2];
vector<int> edges[1005*1005/2];

int dfs(int v) {//vから深さ優先探索を始める
    if (start[v]) {
        if (!ifvis[v]) return -1;//戻ってきてしまったら閉路が存在する
        return dist[v];//二回呼び出しちゃった時用
    } else {
        start[v] = true;
        int k = 0;
        for (int e=0;e<edges[v].size();e++) {
            int nxt = dfs(edges[v][e]);//辺をたどっていく
            if (nxt == -1) return -1;
            else k = max(k, nxt);
        }
        ifvis[v] = true;
        dist[v] = k + 1;
        return dist[v];
    }
}

signed main(){
    scanf("%lld",&N);
    rep(i,N)rep(j,N-1){scanf("%lld",&A[i][j]);A[i][j]--;}
    //試合を頂点に見立てて辺を貼る
    const int M=N*(N-1)/2;
    rep(i,N)rep(j,N-2){
        int first=matchNum(i,A[i][j]);
        int second=matchNum(i,A[i][j+1]);
        edges[first].pb(second);
    }
    //深さ優先探索で閉路があるかどうかと最長パス長を調べる
    int ans=0;
    rep(i,M)dist[i]=-1;//初期化
    rep(i,M){//各頂点を始点として深さ優先探索
        int d=dfs(i);
        if (d == -1) {//閉路が見つかった場合
            ans = -1;
            break;
        } else {//見つからなかった場合
            ans = max(ans, d);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 53632
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007

long long dp[211111];
long long ep[211111];
long long acc = 0;

long long add(long long &x, long long y){
    x = (x + y) % MOD;
}

int main(){
    long long N;
    cin >> N;
    vector<long long> B(N);
    for(int i=0; i<N; i++) cin >> B[i];
    vector<long long> C;
    C.push_back(0);
    for(int i=0; i<N; i++)
        if(C.back() != B[i])
            C.push_back(B[i]);
    N = C.size() - 1;
    if(N == 1){
        cout << 1 << endl;
        return 0;
    }
    C.push_back(0);

    //for(auto x : C)
    //    cerr << x << " ";
    //cerr << endl;

    dp[0] = 1;
    for(int i=1; i<=N; i++){
        add(dp[i], ep[C[i]]);
        add(acc, dp[i-1]);
        add(ep[C[i]], acc);

        //cerr << i << endl;
        //for(int j=0; j<=N; j++)
        //    cerr << C[j] << " ";
        //cerr << endl;
        //for(int j=0; j<=N; j++)
        //    cerr << dp[j] << " ";
        //cerr << endl;
        //for(int j=0; j<=N; j++)
        //    cerr << ep[j] << " ";
        //cerr << endl;
    }
    long long ans = 0;
    for(int i=0; i<=N; i++)
        add(ans, dp[i]);
    cout << ans << " " << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    rep(i,0,n) cin >> a[i];
    sort(a,a+n,greater<ll>());

    ll ans = 0;
    if(n % 2 == 1){
        ll cnt = 0,cnt2 = 0;
        rep(i,0,n){
            if(i < n-2-(n-2)/2) cnt += 2*a[i];
            else if(i < n-(n-2)/2) cnt -= a[i];
            else cnt -= 2*a[i]; 
        }
        rep(i,0,n){
            if(i < (n-2)/2) cnt2 += 2*a[i];
            else if(i < (n-2)/2+2) cnt2 += a[i];
            else cnt2 -= 2*a[i];
        }
        ans = max(cnt,cnt2);
    }
    else{
        rep(i,0,n){
            if(i < (n-2)/2) ans += 2*a[i];
            else if(i < (n-2)/2+1) ans += a[i];
            else if(i < (n-2)/2+2) ans -= a[i];
            else ans -= 2*a[i]; 
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4352
import java.io.FileNotFoundException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	public void run() throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] g = new ArrayList[V];
		for (int i = 0; i < g.length; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}
		int[] col = new int[V];
		scc(g, col);
		int q = sc.nextInt();
		while (q-- > 0) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			System.out.println(col[u] == col[v] ? 1 : 0);
		}
	}

	class State {
		int i, parent, j;

		public State(int i_, int parent_, int j_) {
			i = i_;
			parent = parent_;
			j = j_;
		}
	}

	int scc(ArrayList<Integer>[] g, int[] col) {
		int n = g.length;
		Arrays.fill(col, -1);
		int[] low = new int[n];
		int[] ord = new int[n];
		Arrays.fill(low, -1);
		Arrays.fill(ord, -1);
		boolean[] marked = new boolean[n];
		int order = 0;
		int cols = 0;
		ArrayDeque<State> stk = new ArrayDeque<>();
		ArrayDeque<Integer> pnd = new ArrayDeque<>();
		for (int ii = 0; ii < n; ++ii) {
			if (ord[ii] == -1) {
				stk.add(new State(ii, -1, 0));
			}
			while (!stk.isEmpty()) {
				State s = stk.pollFirst();
				if (ord[s.i] == -1) {
					low[s.i] = (ord[s.i] = order++);
					pnd.addFirst(s.i);
				}
				if (s.j > 0 && s.parent != g[s.i].get(s.j - 1) && !marked[g[s.i].get(s.j - 1)]) {
					low[s.i] = Math.min(low[s.i], low[g[s.i].get(s.j - 1)]);
				}
				if (s.j == g[s.i].size() && low[s.i] == ord[s.i]) {
					while (true) {
						int v = pnd.pollFirst();
						col[v] = cols;
						marked[v] = true;
						if (v == s.i) {
							break;
						}
					}
					++cols;
					continue;
				}
				if (s.j == g[s.i].size()) {
					continue;
				}
				int v = g[s.i].get(s.j);
				stk.addFirst(new State(s.i, s.parent, s.j + 1));
				if (ord[v] == -1) {
					stk.addFirst(new State(v, s.i, 0));
				} else if (!marked[v]) {
					low[s.i] = Math.min(low[s.i], low[v]);
				}
			}
		}
		return cols;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 101044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
char s[maxn];
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","w",stdout);
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    int x = 0;
    repd(i, 1, len)
    {
        x = x * 10 + s[i] - '0';
        x %= 1000;
    }
    x = 1000 - x;
    x %= 1000;
    cout << x << endl;
    return 0;
}




Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
using namespace std;

int p[10][10];
int n,m;

int main(){
	while(cin>>n>>m){
		for(int a=0;a<10;a++){
			for(int b=0;b<10;b++){
				cin>>p[a][b];
			}
		}
		for(int k=0;k<10;k++){
			for(int i=0;i<10;i++){
				for(int j=0;j<10;j++){
					p[i][j]=min(p[i][j],p[i][k]+p[k][j]);
				}
			}
		}
		int sum=0;
		for(int a=0;a<n*m;a++){
			int key;
			cin>>key;
			if(!(key==1||key==-1)) sum+=p[key][1];
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> T(N);
  vector<int> max_V(N+2);
  rep(i,N) cin >> T[i];
  max_V[0]=0;
  rep(i,N) cin >> max_V[i+1];
  max_V.pb(0);
  double ans=0;
  int sumT=0;
  rep(i,N) sumT += T[i];

  vector<int> T_;
  T_.pb(0);
  int tt = 0;
  for(int i=0;i<N;i++){
    tt += T[i];
    T_.pb(tt);
  }

  vector<double> time(sumT*2+1);
  vector<double> v(sumT*2+1,0);
  double t=0;
  for(int i=0;i<(int)time.size();i++){
    time[i] = t;
    t += 0.5;
  }
  v[0] = 0;
  for(int i=1;i<(int)time.size();i++){
    for(int j=1;j<=N;j++){
      if(T_[j-1] <= time[i] && time[i] < T_[j]){
        v[i] = max_V[j];
      }
    }
  }

  for(int i=0;i<(int)T_.size();i++){
    for(int j=0;j<(int)time.size();j++){
      if(time[j] >= (double)T_[i]){
        v[j] = min(v[j], (double)max_V[i]+(time[j]-(double)T_[i]));
      }
      if(time[j] <= (double)T_[i]){
        v[j] = min(v[j], (double)max_V[i+1]+((double)T_[i]-time[j]));
      }
    }
  }
  for(int i=0;i<(int)time.size();i++){
    //cout << time[i] << '\t' << v[i] << endl;
  }
  for(int i=1;i<(int)v.size();i++){
    ans += (v[i]+v[i-1])/4;
  }

  cout << setprecision(10)<<ans << endl;
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int N, A, B, d_a = 0, a_b = 0, u_b = 0;
	cin >> N >> A >> B;
	for (int a = 0; a < N; a++) {
			int p;
			cin >> p;
			if (p <= A) d_a++;
			else if (p > A&&p <= B) a_b++;
			else u_b++;
		}
	cout << min({ d_a,a_b,u_b }) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

struct UF{ //O(loga(n))
    int n;
    int m;
    vi d, r;
    UF(int n) : n(n), m(n), d(n, -1), r(n, 0){};
    int root(int i){
        if(d[i] < 0) return i;
        return d[i] = root(d[i]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(r[x] < r[y]) swap(x, y);
        else if(r[x] == r[y]) r[x]++;
        d[x] += d[y];
        d[y] = x;
        --m;
        return true;
    }
    int size(int i){
        return -d[root(i)];
    }
    int size() {
        return m;
    }
};

int main(){
    int n;
    cin >> n;
    vi x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    UF uf(n);
    using P = tuple<int, int, int>;
    vector<P> es;
    auto calc = [&](int i, int j) {
        return min(abs(x[i]-x[j]), abs(y[i] - y[j]));
    };
    vi id(n);
    rep(i, n) id[i] = i;

    sort(all(id), [&](int a, int b){return x[a] < x[b];});
    rep(i, n-1) es.emplace_back(calc(id[i], id[i+1]), id[i], id[i+1]);

    sort(all(id), [&](int a, int b){return y[a] < y[b];});
    rep(i, n-1) es.emplace_back(calc(id[i], id[i+1]), id[i], id[i+1]);
    sort(all(es));
    ll ans = 0LL;
    for(auto&& p: es) {
        int i = get<1>(p), j = get<2>(p);
        if(uf.unite(i, j)) ans += get<0>(p);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6900