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

    int main(){
        int N; cin >> N;
        int order = 1;
        int val = 10;
        while(1){
            if(val>N) break;
            else {order++; val*=10;}
        }
        val /= 10;
        int ans;
        if(order%2 != 0) ans = N - val + 1;
        else ans = 0;

        for(int i=order-1; i>0; i--){
            if(i%2 == 0) continue;
        
            if(i==1) ans += 9;
            else ans += pow(10, i) - pow(10,i-1);
        }
        cout << ans << endl;
    }


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<queue>
#include<unordered_map>
#include<map>
#include<stack>
#include<bits/stdc++.h>
#include<string.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define f first
#define s second
#define respr(fir,sec) for(int i=0;i<=fir;i++){for(int j=0;j<=sec;j++){cout << res[i][j] << " ";}cout << "\n";}
#define pb push_back
//#define INF (1LL<<31)
using namespace std;
using namespace __gnu_pbds;
const int mod = 1e9+7;
const ll MAX = 1000000000000000000;
typedef pair<int,ll> pii;
typedef pair<ll,int> pi;
typedef tuple<long long,int> tp;
typedef tuple<int,int,long long> tu;
typedef multimap<pii , int> mpp;
typedef priority_queue< tp , vector<tp>, greater<tp>>  minheap;
typedef priority_queue<pii , vector<pii>> maxheap;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
const int maxi = 10000001;

void add(int &m, int x){
	m += x;
	m %= mod;
}

int main()
{
	FASTIO;
	
	int n;
	cin >> n;
	vector<vector<int>> arr(n, vector<int>(n));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin >> arr[i][j];
		}
	}
	vector<int> dp((1<<n));
	dp[0]=1;
	for(int mask=0;mask<(1<<n)-1;mask++){
		int a = __builtin_popcount(mask);
		for(int b=0;b<n;b++){
			if(arr[a][b] && !(mask & (1<<b))){
				int m = mask ^(1<<b);
				add(dp[m],dp[mask]);
			}
		}
	}
	
	cout << dp[(1<<n)-1] << "\n";
	return 0;
}


Measured memory_bytes: 8448
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int n,q; cin >> n >> q;
	string s; cin >> s;
	vector<int> ac(n,0);
	int state = 0;
	rep(i,n){
		if(i) ac[i] = ac[i-1];
		if(state == 0){
			if(s[i] == 'A'){
				state++;
			}
		}else if(state == 1){
			if(s[i] == 'C'){
				ac[i]++;
			}else if(s[i] == 'A'){
				state++;
			}
			state--;
		}
	}
	Rep(q){
		int l,r; cin >> l >> r;
		--l; --r;
		if(l==0){
			cout << ac[r] << endl;
		}else{
			cout << ac[r] - ac[l-1] - (s[l-1] == 'A' && s[l] == 'C') << endl;
		}
	}
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        if (a < 1200) {
            System.out.println("ABC");
        } else if (a <2800){
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 23508
#include <stdio.h>
 
         
        int main(void){
            int  i = 0;
            int num = 0;
           char buf[4];
           scanf("%s", &buf);
           
           while(i <= 3){
            switch(buf[i]){
                case '+': num = num+1; break;
                case '-': num = num-1; break;
            }
            i++;
           }
           printf("%d\n", num);
           return 0;
        } 

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    int ans=0;
    for(int i=a;i<=b;i++){
        if(c%i==0)ans++;
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;



int main()
{

    ll n;
    cin>>n;
    ll a[n+1][3];

    for(ll i=1; i<=n; i++)
    {
        cin>>a[i][0];
        cin>>a[i][1];
        cin>>a[i][2];

    }
    ll dp[n+1][3];
    memset(dp,0,sizeof(dp));

    for(ll i=1; i<=n; i++)
    {

        for(ll j=0; j<3; j++)
        {
            for(ll k=0; k<3; k++)
            {
                if(j==k)
                    continue;
                dp[i][j]=max(dp[i][j],a[i][j]+dp[i-1][k]);
            }
        }


    }

    cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<nn;


}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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


/* ACL */

//using namespace atcoder;

#define overX INF/2
#define X overX-1

int main(){
    int H,W;
    cin >> H >> W;
    int Ch,Cw;
    cin >> Ch >> Cw;
    int Dh,Dw;
    cin >> Dh >> Dw;

    vector<vector<ll>> maze(H,vector<ll>(W,X));
    vector<string> maze_string(H);

    rep(i,H){
        cin >> maze_string.at(i);
    }

    queue<pair<int,int>> que;
    queue<pair<int,int>> highest_cost_area;

    que.push({Ch,Cw});
    //maze.at(Ch-1).at(Cw-1) = 0;

    pair<int,int> now;
    int cost = 0;
    #define COST(i,j) maze.at(now.first-1+i).at(now.second-1+j)
    #define MAZE(i,j) maze_string.at(now.first+i-1)[now.second+j-1]
    while(que.size() > 0){
        while(que.size() > 0){
            now = que.front();
            que.pop();

            COST(0,0) = cost;
            highest_cost_area.push({now.first,now.second});
            
            if(now.first != 1 && MAZE(-1,0) != '#' && COST(-1,0) != cost){
                COST(-1,0) = cost;
                que.push({now.first-1,now.second});
            }
            if(now.first != H && MAZE(1,0) != '#' && COST(1,0) != cost){
                COST(1,0) = cost;
                que.push({now.first+1,now.second});
            }
            if(now.second != 1 && MAZE(0,-1) != '#' && COST(0,-1) != cost){
                COST(0,-1) = cost;
                que.push({now.first,now.second-1});
            }
            if(now.second != W && MAZE(0,1) != '#' && COST(0,1) != cost){
                COST(0,1) = cost;
                que.push({now.first,now.second+1});
            }
        }

        while(highest_cost_area.size() > 0){
            now = highest_cost_area.front();
            highest_cost_area.pop();

            for(int i=-2;i<=2;i++){
                for(int j=-2;j<=2;j++){
                    if(1 <= now.first+i && now.first+i <= H && 1 <= now.second+j && now.second+j <= W && MAZE(i,j)!='#' && COST(i,j) == X){
                        que.push({now.first+i,now.second+j});
                        COST(i,j) = cost + 1;
                    }
                }
            }
        }
        cost ++;
    }

    if(maze.at(Dh-1).at(Dw-1) != X){
        cout << maze.at(Dh-1).at(Dw-1) << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;

    
}

Measured memory_bytes: 13384
import java.util.*;
import java.lang.*;


public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int maxrange = -Integer.MAX_VALUE;
        int min = Integer.MAX_VALUE;
        
        for (int i = 0; i < n; i++) {
            int r = sc.nextInt();
            maxrange = Math.max(maxrange, r - min);
            min = Math.min(min, r);
        }
        System.out.println(maxrange);
    }
}


Measured memory_bytes: 98436
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		
		for(int i = 0; i < param.size();i++){
			System.out.println(param.get(i));
			System.out.println(param.get(i));
		}
	}
}

Measured memory_bytes: 25704
char s[1001],*S="JOI";
int N,n,M[1000][8];
int dfs(d,prev){
	if(d==N)return 1;
	if(M[d][prev])return M[d][prev];
	int i=1,r=0;
	for(;i<8;i++)if((s[d]&i)&&(prev&i))r=(r+dfs(d+1,i))%10007;
	return M[d][prev]=r;
}
main(){
	scanf("%d%s",&N,s);
	for(;n<N;n++)s[n]=1<<(strchr(S,s[n])-S);
	n=!printf("%d\n",dfs(0,1));
}

Measured memory_bytes: 692
N,M=map(int,input().split())
A=[0]*M
for i in range(M):
 A[i]=list(map(int,input().split()))
P=list(map(int,input().split()))
F=0
for i in range(2**N):
 E=0
 Sui=[0]*N
 for j in range(N):
  if ((i >> j) & 1):
   Sui[j]+=1
 for k in range(M):
  D=0
  for l in range(1,A[k][0]+1):
   if Sui[A[k][l]-1]==1:
    D+=1
  if D%2==P[k]:
   E+=1
 if E==M:
  F+=1
print(F)

Measured memory_bytes: 42480
from collections import Counter
s = input()
MOD = 2019
ts = [0]
cur = 0
for i, j in enumerate(s[::-1], 1):
    cur = (cur + pow(10, i, MOD) * int(j)) % MOD
    ts.append(cur)
ct = Counter(ts)
res = 0
for k, v in ct.items():
    if v > 1:
        res += v * (v-1) // 2
print(res)

Measured memory_bytes: 76376
from math import sin, cos, radians, sqrt

A, B, H, M = list(map(int, input().split()))
# print(A, B, H, M)

degree_a = -360 * (H * 60 + M) / (60 * 12)
radian_a = radians(degree_a)
degree_b = -360 * (M / 60)
radian_b = radians(degree_b)

A = {
    'x': A * cos(radian_a),
    'y': A * sin(radian_a),
}
B = {
    'x': B * cos(radian_b),
    'y': B * sin(radian_b),
}

distance = sqrt((A['x'] - B['x']) ** 2 + (A['y'] - B['y']) ** 2)

print(distance)

Measured memory_bytes: 9504
#include<stdio.h>
#include<string.h>
int main()
{
    int n,s[4]={0};
    char b[3];
    for(;;)
    {
        if(scanf("%d",&n)==EOF)
            break;
        scanf(",%s",&b);
        if(!strcmp("A",b))
            s[0]++;
        else if(!strcmp("B",b))
            s[1]++;
        else if(!strcmp("AB",b))
            s[2]++;
        else
            s[3]++;
    }
    for(n=0;n<4;n++)
        printf("%d\n",s[n]);
    return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll a, b, x; cin >> a >> b >> x;
  if (a == 0) outl(b / x + 1);
  else outl(b / x - (a - 1) / x);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

typedef long long LL;  //Attention!!
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const LL M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

LL n,i,j,m,L;

cin>>n>>L;

vector <LL> v(n);

LL ans = -1;

for(i=0;i<n;i++) 
	cin>>v[i];

for(i=0;i<(n-1);i++)
 	if(v[i]+v[i+1] >= L)
 		{
 		ans = i;	
 		break;
 		}

if(ans == -1)
	{
	cout<<"Impossible"<<endl;
	return 0;	
	}

cout<<"Possible"<<endl;

ans++;

for(i=1;i<ans;i++)
	cout<<i<<endl;
for(i=(n-1);i>ans;i--)
	cout<<i<<endl;
cout<<ans<<endl;

}


Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define loop(i,start, stop) for(int i = start; i < (stop); i++)
using namespace std;

int main(){

  ll N;
  cin >> N;
  ll A[200001] = {0};
  ll ans[200001] = {0};
  loop(i,0,N){
    cin >> A[i];
    ans[A[i]]++;
  }

  loop(i,1,N+1)
    cout << ans[i] << endl;

  return 0;
}

Measured memory_bytes: 6748
while line=gets
  n,r=line.split(/ /).map{|i| i.to_i}
  break if n==0
  a=Array.new(n)
  for i in 0..n-1
    a[i]=n-i
  end
  for i in 0..r-1
    p,c=gets.chomp.split(/ /).map{|i| i.to_i}
    tmp1=a[0..p-2]
    tmp2=a[p-1..p-2+c]
    for i in 0..c-1
      a[i]=tmp2[i]
    end
    for i in c..p-2+c
      a[i]=tmp1[i-c]
    end
  end
  print a[0],"\n"
end

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
 
template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
 
int main()
{
    string s;
    cin >> s;
 
    ll Q;
    cin >> Q;
 
    bool reverse = false;
    ll changed = 0;
    string ans = s;
    rep(i,Q)
    {
        int tmp;
        cin >> tmp;
        if( tmp == 1 )
        {
            reverse = !reverse;
            changed++;
        }
        else
        {
            int key;
            string c;
            cin >> key >> c;
            if( (reverse&&key==2) || (!reverse&&key==1) )
            {
                ans.insert(0,c);
            }
            else
            {
                ans += c;
            }
        }
    }
    if( (changed+2)%2 == 0 ) cout << ans << endl;
    else
    {
        rep(i,ans.size()) cout << ans[ans.size()-1-i];
        cout << endl;
    }
}

Measured memory_bytes: 1084
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'

struct maxxor {
	ll best[64], msb;
	maxxor() { memset(best, -1, sizeof best); }
	void add(ll x) { 
		while(x > 0) {
			msb = 63 - __builtin_clzll(x);
			if(best[msb] == -1) {
				best[msb] = x; break;
			} else x = x ^ best[msb]; 
		}
	}
	ll get(ll ret = 0) {
		for(ll i = 63; i >= 0; i--) {
			if(best[i] != -1) 
				ret = max(ret, ret ^ best[i]);
		} return ret;
	}
} ds;

const int maxn=100010;
ll a[maxn];
int n;
int main()
{
	ll x=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x^=a[i];
	}
	ll an=0;
	for(int j=0;j<64;j++){
		if(x&(1LL<<j)){
			an+=(1LL<<j);
			for(int i=0;i<n;i++){
				if(a[i]&(1LL<<j)){
					a[i]^=(1LL<<j);
				}
			}
		}
	}
	for(int i=0;i<n;i++)ds.add(a[i]);
	cout<<an+ds.get()*2LL<<endl;
	return 0;
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
string s;

int main() {
  cin >> N >> s;

  int ans = 0, x = 0;
  rep(i, N) {
    if (s[i] == 'I') {
      ++x;
    } else {
      --x;
    }
    ans = max(ans, x);
  }

  cout << ans << endl;

  return 0;
}


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

#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

using edge = pair<ll, ll>;  // {to, cost}
using Graph = vector<vector<edge>>;

vector<ll> dijkstra(const Graph &g, ll s) {
  vector<ll> dist((int)g.size(), INF);
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    ll cost, idx;
    tie(cost, idx) = que.top();
    que.pop();
    if (dist[idx] < cost) continue;
    for (auto e : g[idx]) {
      if (dist[e.first] > cost + e.second) {
        dist[e.first] = cost + e.second;
        que.push(P(dist[e.first], e.first));
      }
    }
  }

  return dist;
}

int main() {
  ll n, x, y;
  cin >> n >> x >> y;
  --x, --y;
  Graph g(n);
  REP(i, n - 1) {
    g[i].push_back(edge(i + 1, 1));
    g[i + 1].push_back(edge(i, 1));
  }
  g[x].push_back(edge(y, 1));
  g[y].push_back(edge(x, 1));

  map<ll, ll> mp;
  REP(i, n) {
    auto d = dijkstra(g, i);
    FOR(j, i + 1, n) {
      ll dist = d[j];
      mp[dist]++;
    }
  }

  FOR(k, 1, n) { cout << mp[k] << endl; }

  return 0;
}

Measured memory_bytes: 512
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let mut n: usize = parse!(it);
    let mut g = vec![vec![0; n]; n];
    fn f(l: usize, r: usize, v: usize, g: &mut Vec<Vec<usize>>) {
        if r - l == 1 {
            return;
        }
        let m = (l + r) / 2;
        for i in l..m {
            for j in m..r {
                g[i][j] = v;
            }
        }
        f(l, m, v + 1, g);
        f(m, r, v + 1, g);
    }
    f(0, n, 1, &mut g);
    for i in 0..(n - 1) {
        println!(
            "{}",
            ((i + 1)..n)
                .map(|j| g[i][j].to_string())
                .collect::<Vec<String>>()
                .join(" ")
        );
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 6652
#include <bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define TEST(t) int inox,t;cin>>t; for(inox=1;inox<=t;inox++)
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,n) for(i=n-1;i>=0;i--)
#define modd 1000000007
using namespace std;
int main(){
ll a,b,c; cin>>a>>b>>c;
ll d=c-a-b;
if(d<0)cout<<"No";
else{
 if(4*a*b<((c-a-b)*(c-a-b)))

cout<<"Yes";
else cout<<"No";
}
}

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

struct edge{
    int s,t;
    bool operator<(const edge& r)const{
        if(s!=r.s) return s<r.s;
        else return t<r.t;
    }
};

class UnionFind{
public:
    vector<int> p,s;
	int cnt;
	UnionFind(){}
	UnionFind(int N){
		cnt = N;
		p = s = vector<int>(N,0);
		for(int i=0;i<N;i++){
			p[i] = i; s[i] = 1;
		}
	}
	int find(int x){
		if(p[x]==x) return x;
		else return p[x] = find(p[x]);
	}
	void unite(int x,int y){
		x = find(x); y = find(y);
		if(x==y) return;
		if(s[x]>s[y]){
			p[y] = x;
			s[x] += s[y];
		}else{
			p[x] = y;
			s[y] += s[x];
		}
		cnt--;
	}
	bool is_same_set(int x,int y) {return find(x)==find(y);}
	int size(int x) {return s[find(x)];}
	int compnents_number(){return cnt;}
};

class PopableUnionFind{
public:
    vector<int> p,s;
    stack<edge> history;
    PopableUnionFind(UnionFind const& u):p(u.p),s(u.s){}
    //経路圧縮しない
    int find(int x){
        while(p[x]!=x) x = find(p[x]);
        return x;
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x==y) return ;
        if(s[x]<s[y]) swap(x,y);
        //繋ぐ前の親
        history.push({p[x],p[y]});
        //繋いだ頂点
        history.push({x,y});
        s[x] += s[y];
        p[y] = x;
    }
    void pop(){
        while(!history.empty()){
            edge e = history.top(); history.pop();
            edge e2 = history.top(); history.pop();
            int x = e.s,y = e.t;
            p[x] = e2.s,p[y] = e2.t;
        }
    }    
    bool is_same_set(int x,int y){return find(x)==find(y);}
};

struct query{
    int type;
    edge e;
};

int main(){
    int N,K;
    cin >> N >> K;
    constexpr int si = 200;
    int S = (K+si-1)/si;
    vector<vector<query>> queries(S);
    for(int i=0;i<K;i++){
        int c,s,t;
        cin >> c >> s >> t;
        queries[i/si].push_back({c,{s,t}});
    }
    set<edge> s;
    for(int i=0;i<S;i++){
        set<edge> now;
        for(auto& q:queries[i]){
            if(q.type==2){
                if(s.count(q.e)==1){
                    s.erase(q.e);
                    now.insert(q.e);
                }
            }
        }
        UnionFind uf(N);
        for(auto x:s) uf.unite(x.s,x.t);
        PopableUnionFind puf(uf);
        for(auto& q:queries[i]){
            if(q.type==1) now.insert(q.e);
            else if(q.type==2) now.erase(q.e);
            else{
                for(auto x:now){
                    puf.unite(x.s,x.t);
                }
                cout << (puf.is_same_set(q.e.s,q.e.t)? "YES":"NO") << endl;
                puf.pop();
            }
        }
        for(auto x:now) s.insert(x);
    }
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
#define debug(x) cerr << #x << " is " << x << endl;
#define st pair<ll,pll>
using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// unordered_map<long long, int, custom_hash> safe_map;
// FOR VIEWERS, CODE STARTS HERE

int main()
{
    // #ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    // #endif
    FIO;
    ll t, q, n, m, prev, maxx,  i, j, k1, k2, k3, k, x, y, flag, sum, cnt, ans;
    cin>>n>>k;
    cout<<6 - n - k<<endl;
    return 0;    
}

Measured memory_bytes: 256
using System;
class E { static void Main() { new K(); } }
class K
{
	public K()
	{
		var N = int.Parse(Console.ReadLine());
		var X = Console.ReadLine().Length;
		memo = new long[N + 1, N + 1];
		used = new bool[N + 1, N + 1];
		Console.WriteLine(Calc(N, X));
	}
	long[,] memo;
	bool[,] used;
	long Calc(int n, int x)
	{
		if (n == 0) return x == 0 ? 1 : 0;
		if (x > n) return 0;
		if (!used[n, x])
		{
			used[n, x] = true;
			memo[n, x] = (Calc(n - 1, x + 1) * 2 + Calc(n - 1, x == 0 ? x : x - 1)) % 1000000007;
		}
		return memo[n, x];
	}
}

Measured memory_bytes: 111960
import math
s = list(map(int, input().split()))
n=s[0]
k=s[1]-1
s = list(map(int, input().split()))
ind=s.index(1)
# print(ind,n-ind-1,math.ceil(ind/k),math.ceil((n-ind-1)/k))
print(math.ceil((n-1)/(k)))

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  cout << 180*(n-2) << endl;
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  upgranet
//
//  Created by Dong Truong on 7/5/19.
//  Copyright Â© 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;
#define maxn 1000005
#define gh 1005
#define long long long

long n,m;
void nhap()
{
    cin>>n>>m;
    long kq=0;
    for (int i=1;i<=n;++i)
        for (int j=10;j<=m;++j)
        {
            long fi=j%10,se=(j/10)%10;
            if (fi>=2 && se>=2 && fi*se==i) ++kq;
        }
    cout<<kq;
}
int main(int argc, const char * argv[]) {
    //freopen("a.inp","r",stdin);
    nhap();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;


int main()
{
	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < d; ++j) {
			cin >> x[i][j];
		}
	}
	int count = 0;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int dis = 0;
			for (int k = 0; k < d; ++k) {
				dis += abs(x[i][k] - x[j][k]) * abs(x[i][k] - x[j][k]);
			}
			for (int l = 0; l * l <= dis; ++l) {
				if (l * l == dis) {
					count++;
					break;
				}
			}
		}
	}
	cout << count << endl;

	return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N, K;
    cin >> N >> K;

    int ans;
    if (N % K == 0) ans = 0;
    else ans = 1;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: a, b, c, k, filled, fill, res
  read *, a, b, c, k

  fill = min(a, k)
  res = fill
  filled = fill

  fill = min(b, k - filled)
  filled = filled + fill

  fill = min(c, k - filled)
  res = res - fill
  filled = filled + fill

  print "(i0)", res
end program main


Measured memory_bytes: 2924
// ABC79-C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    string s;
    cin>>s;
    int num=pow(2,3);
    int ans_i=0;
    for(int i=0;i<num;i++){
        int cur=(s[0]-'0');
        for(int j=0;j<3;j++){
            if((i>>j)&1){
                cur+=(s[j+1]-'0');
            }else cur-=(s[j+1]-'0');
        }
        //cout<<cur<<" "<<i<<endl;
        if(cur==7){
            ans_i=i;
            break;
        }
    }

    string ans="";
    ans+=s[0];
    for(int i=0;i<3;i++){
        if((ans_i>>i)&1){
            ans+="+";
            ans+=s[i+1];
        }else{
            ans+="-";
            ans+=s[i+1];
        }
    }
    ans+="=7";
    cout<<ans<<endl;
    return 0;
}   

Measured memory_bytes: 256
#include<cstdio>
#define for(a,b,c) for(int a=b;a<=c;a++)
typedef long long ll;
ll abs(ll a){return a>0?a:-a;}
ll a[1<<19];
int n;
int main(){
	scanf("%d",&n);
	int t=1<<n;
	for (i,1,t) scanf("%lld",&a[i]);
	t>>=1;
	while (t){
		int tot=0;
		for (i,1,t) a[++tot]=a[i<<1]==a[(i<<1)-1]?a[i<<1]:abs(a[i<<1]-a[(i<<1)-1]);
		t>>=1;
	}
	printf("%lld",a[1]);
}

Measured memory_bytes: 4224
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){
    int n; cin >> n;
    
    vector<vector<int>> card(4, vector<int>(13));
    vector<vector<bool>> check(4, vector<bool>(13, false));
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            card[i][j] = j+1;
        }
    }
    
    for(int i = 0; i < n; i++){
        char ch; int v;
        cin >> ch >> v;
        if(ch == 'S') check[0][v-1] = true;
        else if(ch == 'H') check[1][v-1] = true;
        else if(ch == 'C') check[2][v-1] = true;
        else check[3][v-1] = true;
    }
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(!check[i][j]){
                if(i == 0) cout << "S " << card[i][j] << endl;
                else if(i == 1) cout << "H " << card[i][j] << endl;
                else if(i == 2) cout << "C " << card[i][j] << endl;
                else cout << "D " << card[i][j] << endl;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3080
import java.util.*;
public class Main {

public static int [] m ={500,100,50,10,5,1};

	    public static void main(String[] args) throws java.io.IOException{
	        Scanner scan = new Scanner(System.in);
	        int sum=0;
	        double total_s =0;
	        int n=0;
	        while(scan.hasNext()){
	        	String [] strs = scan.nextLine().split(",");
	        	sum+=Integer.parseInt(strs[0])*Integer.parseInt(strs[1]);
	        	total_s+=Integer.parseInt(strs[1]);
	        	n++;
	        }
	        System.out.println(sum);
	        System.out.println((int)(total_s/n+0.5));

	    
	}
}

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

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  ll ans = 0;

  rep2(i, 1, n) ans += (n + i - 1) / i - 1;

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

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

using namespace std;

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

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

ll ans = 0;

void calc(ll a, ll b) {
    if(b == 0) return;
    ans += a / b * b * 3;
    calc(b, a % b);
}

int main() {
    ll N, X;
    cin >> N >> X;

    calc(N - X, X);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define esta(x,v) (find((v).begin(),(v).end(),(x)) !=  (v).end())
#define index(x,v) (find((v).begin(),(v).end(),(x)) - (v).begin())
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;

int main (){
	tint n, k;
	cin>>n>>k;
	tint res=k;
	forn(i, n-1){
		res*=(k-1);
	}
	cout<<res<<endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    ll ans = 0;
    for(int i=0; i<N-1; i++) {
        sum -= A[i];
        ans += (A[i]) * (sum % (1000000000+7));
        ans %= (1000000000+7);
    }
    cout << ans % (1000000000+7) << endl;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

void fail() {
    cout << "IMPOSSIBLE\n";
    exit(0);
}

int gcd(int a, int b) { return a ? gcd(b%a,a): b; }

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

    int mx = 0, d = 0, n, k;
    cin >> n >> k;
    vi a(n);
    forn(i,n) {
        cin >> a[i];
        d = gcd(d,a[i]);
        mx = max(mx, a[i]);
    }
    if (k > mx) fail();
    if (k%d) fail();
    cout << "POSSIBLE\n";

    return 0;
}


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


int binarySearch(vector<int> S, int key) {
  int left = 0;
  int right = S.size();
  int mid;
  while (left < right - 1) {
    mid = (left + right) / 2;
    if (S[mid] == key)
      return mid;
    else if (key < S[mid])
      right = mid;
    else if (S[mid] < key)
      left = mid;
  }
  return -1;
}
int main() {
  int n, q, cnt = 0;
  cin >> n;
  vector<int> S(n);
  for (size_t i = 0; i < n; i++) {
    cin >> S.at(i);
  }

  cin >> q;
  vector<int> T(q);
  for (size_t i = 0; i < q; i++) {
    cin >> T.at(i);
  }

  for (auto v : T) {
    if (binarySearch(S, v) != -1) {
      cnt++;
    }
  }

  cout << cnt << endl;
}



Measured memory_bytes: 3824
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var S = sc.next();
        var mae = Convert.ToInt32(S.Substring(0, 2));
        var ato = Convert.ToInt32(S.Substring(2, 2));

        if (mae == 0 && ato > 0 && ato <= 12) {
            WriteLine("YYMM");
            return;
        }

        if (mae > 0 && mae <= 12 && ato == 0) {
            WriteLine("MMYY");
            return;
        }

        if (mae == 0 || ato == 0) {
            WriteLine("NA");
            return;
        }

        if (mae <= 12 && ato <= 12) {
            WriteLine("AMBIGUOUS");
        } else if (mae <= 12 && ato > 12) {
            WriteLine("MMYY");
        } else if (mae > 12 && ato <= 12) {
            WriteLine("YYMM");
        } else {
            WriteLine("NA");
        }
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int a, b;

int process(){
	int sum = a + b;
	int digit = 1;
	
	while (sum / 10 > 0){
		sum /= 10;
		digit++;
	}
	
	return digit;
}

int main(){
	while (cin >> a >> b){
		cout << process() << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3048
#!/usr/bin/env python3
from functools import lru_cache
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
#solve
def solve():
    n = II()
    c = LI()
    c1, c2, c3 = [c.count(i) for i in range(1, 4)]
    d = [[[0] * (n + 2) for _ in range(n + 2)] for _ in range(n + 2)]
    for i in range(c3 + 1):
        di = d[i]
        dim1 = d[i - 1]
        for j in range(c3 + c2 + 1 - i):
            dim1jp1 = dim1[j + 1]
            dijm1 = di[j - 1]
            dij = di[j]
            for k in range(c3 + c2 + c1 - i - j + 1):
                l = i + j + k
                if l == 0: continue
                res = n
                if i: res += i * dim1jp1[k]
                if j: res += j * dijm1[k + 1]
                if k: res += k * dij[k-1]
                dij[k] = res / l
    print(d[c3][c2][c1])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 505480
#include <stdio.h>
void printAChessboard(int h, int w) {
  int i, j, k;

  for (i = 0; i < h / 2; i++) {
    for (j = 0; j < w / 2; j++) {
      printf("#.");
    }
    if (w % 2 == 1)
      printf("#\n");
    else
      printf("\n");

    for (j = 0; j < w / 2; j++) {
      printf(".#");
    }
    if (w % 2 == 1)
      printf(".\n");
    else
      printf("\n");
  }
  if (h % 2 == 1){
    for (j = 0; j < w / 2; j++) {
      printf("#.");
    }
    if (w % 2 == 1)
      printf("#\n");
    else
      printf("\n");
  } else {
    // puts("");
  }
  puts("");
}

int main(int argc, char const *argv[]) {
  int H[100000], W[100000];
  int i, n = 0;

  do {
    scanf("%d %d", &H[n], &W[n]);
    n++;
  } while (!(H[n - 1] == 0 && W[n - 1] == 0));

  for (i = 0; i < n - 1; i++)
    printAChessboard(H[i], W[i]);

  return 0;
}

Measured memory_bytes: 1040
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int h, w, c;
int field[10][10][10];
bool visit[10][10];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int dfs(int depth, int x, int y, int tc) {
  if (visit[y][x]) { return 0; }
  visit[y][x] = true;
  const int ndepth = depth + 1;
  const int pc = field[depth][0][0];
  field[ndepth][y][x] = tc;
  int ret = 1;
  REP(dir, 4) {
    int nx = x + dx[dir];
    int ny = y + dy[dir];
    if (nx < 0 || nx >= w || ny < 0 || ny >= h) { continue; }
    if (field[depth][ny][nx] != pc) { continue; }
    ret += dfs(depth, nx, ny, tc);
  }
  return ret;
}

int calc(int depth) {
  if (depth == 5) {
    if (field[depth][0][0] != c) { return 0; }
    MEMSET(visit, false);
    memcpy(field[depth + 1], field[depth], sizeof(field[depth]));
    return dfs(depth, 0, 0, c);
  }
  int ret = 0;
  FOREQ(i, 1, 6) {
    MEMSET(visit, false);
    memcpy(field[depth + 1], field[depth], sizeof(field[depth]));
    dfs(depth, 0, 0, i);
    ret = max(ret, calc(depth + 1));
  }
  return ret;
}

int main() {
  while (scanf("%d %d %d", &h, &w, &c), h|w|c) {
    REP(y, h) {
      REP(x, w) {
        scanf("%d", &field[0][y][x]);
      }
    }
    cout << calc(0) << endl;
  }
}

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
using namespace std;

int N;
int A[1000][999];
int next_idx[1000] = {};
map<pair<int, int>, set<pair<int, int>>> adj;
map<pair<int, int>, int> in_deg;


int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i][0];
    A[i][0]--;
    for(int j = 1; j < N - 1; j++){
      cin >> A[i][j];
      A[i][j]--;
      auto from = make_pair(min(i, A[i][j - 1]), max(i, A[i][j - 1]));
      auto to   = make_pair(min(i, A[i][j]),     max(i, A[i][j]));
      adj[from].insert(to);
      in_deg[to]++;
    }
  }

  vector<pair<int, int> > first_games;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      auto now = make_pair(i, j);
      if(in_deg[now] == 0){
	first_games.push_back(now);
      }
    }
  }

  /*
  for(auto now: first_games){
    cout << now.first << ' ' << now.second << endl;
  }
  */

  set<int> gamers;
  for(auto now: first_games){
    gamers.insert(now.first);
    gamers.insert(now.second);
    next_idx[now.first]++;
    next_idx[now.second]++;
  }

  int ans = 0;
  while(!gamers.empty()){
    set<pair<int, int>> games;
    for(auto pl: gamers){
      if(next_idx[pl] < N - 1){
	int rival = A[pl][next_idx[pl]];
	int rival_rival = A[rival][next_idx[rival]];
	if(rival_rival == pl){
	  games.insert(make_pair(min(pl, rival), max(pl, rival)));
	}
      }
    }

    gamers.clear();
    //cout << ans << endl;
    for(auto game: games){
      
      //cout << game.first << ' ' << game.second << endl;
      gamers.insert(game.first);
      gamers.insert(game.second);
      next_idx[game.first]++;
      next_idx[game.second]++;
    }

    ans++;
  }

  bool ok = true;
  for(int i = 0; i < N; i++){
    if(next_idx[i] != N -1){
      ok = false;
    }
  }
  if(ok){
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }


}


Measured memory_bytes: 129024