akhauriyash/Code-Regression huggingface dataset:
/*****TEMPLATE*****/
      

#include <algorithm>
#include <array>
#include <bitset>
#include <cctype> 
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cstring>
#include <cstdio>
#include <stdio.h>
//INCLUDES
using namespace std;

#define lld long long int
#define ulld unsigned long long int
#define mod 1000000007
#define pb push_back
#define umap unordered_map
#define mp make_pair
#define fi first
#define se second 
#define rep(n) for(int i=0;i<n;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//DEFINES

lld gcd(lld a,lld b){ if(a<b) { a=a+b; b=a-b; a=a-b;}while(b!=0){lld r=a%b; a=b; b=r;} return a;}
lld bs(lld arr[], lld l, lld r, lld x) { if (r >= l) {  lld mid = l + (r - l) / 2;  if (arr[mid] == x)  return mid; if (arr[mid] > x)  return bs(arr, l, mid - 1, x);  return bs(arr, mid + 1, r, x);  }  return -1; }
lld mypower(lld x, lld n){	if (n == 0)	return 1;	if (n & 1) 	return (((x * mypower(x, n / 2))%mod) * (mypower(x, n / 2)%mod)%mod);return (((mypower(x, n / 2))%mod) * (mypower(x, n / 2)%mod))%mod;}
lld modinv(lld a) { lld g = gcd(a, mod); if (g != 1) return -1;else{  return mypower(a, mod-2)%mod; } } 

//FUNCTIONS
void solve()
{
    lld n,W;
    cin>>n>>W;
    lld v[n+1],w[n+1];
    rep(n){
        cin>>w[i+1]>>v[i+1];
    }
    vector<vector<lld> >dp(n+1,vector<lld>(100001,100000000009));
    for (int i = 0; i <=n; i++) {
        dp[i][0]=0;
    }
    
    for (lld i = 1; i<=n; i++)
    {
        for(lld j=1;j<=100000;j++)
        {
            if(j<v[i])
            dp[i][j]=dp[i-1][j];
            else
            dp[i][j]=min(dp[i-1][j],w[i]+dp[i-1][j-v[i]]);
        }
    }
    
    lld ans=0;
    for(lld i=1;i<100001;i++)
    {
        if(dp[n][i]<=W)
        {
            ans=i;
        }
    }
    cout<<ans<<"\n";
    return;
    
    
}
int main() 
{
    fast
    // lld t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}



Measured memory_bytes: 83168
#include<stdio.h>
#include<stdlib.h>
int main(void){
  char s[31];
  double z[31];
  double a,b,c,d,e,f;
  char g[6],h[6],i[6],j[6],k[6],l[6];
  double x,y;
  double n;
  while (fgets(s,30,stdin)!=NULL){
    sscanf(s,"%s %s %s %s %s %s",g,h,i,j,k,l);
    a=atof(g);
    b=atof(h);
    c=atof(i);
    d=atof(j);
    e=atof(k);
    f=atof(l);
    y=(c*d-a*f)/(b*d-a*e);
    x=(c-b*y)/a;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 612
import math
n = int(input())

no_tax = n / 1.08

no_tax = math.floor(no_tax)

l = [no_tax-1,no_tax,no_tax+1]

for i in l:
    if n == math.floor(i*1.08):
        print(math.floor(i))
        break
else:
    print(":(")

Measured memory_bytes: 3060
import numpy as np

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
  n, m = map(int, input().split())

  union = UnionFind(n)

  for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    union.union(a, b)

  print(union.group_count()-1)



main()


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

int main() {
	string S;
	int c0=0, c1=0;
	cin >> S;

	rep(i,S.size())
		if(S.at(i) == '0')
			++c0;
		else
			++c1;
	
	cout << min(c0,c1)*2 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

ll N, K, W, H, M;

const int MAX = 510000;

long long fac[MAX], comt[MAX], inv[MAX];

 ll modpow(ll a, ll b, ll mod) {
   ll res = 1;
   for (a %= mod; b; a = a * a % mod, b >>= 1)
     if (b & 1) res = res * a % mod;
   return res;
 }

 void init(){
	 inv[1] = 1;
	 for(int i = 2; i < MAX; ++i){
		 inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
	 }
 }

void com_init(ll n, ll k){
	init();
	comt[0] = 1; 
	comt[1] = n % MOD;
	for(int i = 2; i <= k; ++i){
		comt[i] = (comt[i-1]%MOD) * ((N - i + 1)%MOD)%MOD;
		comt[i] = ((comt[i]%MOD) *  inv[i])%MOD;
	}
}


int main() {
	ll a,b;
	cin >> N  >> a >> b;
	com_init(N, max(a,b));
	ll ans = (2*MOD + modpow(2, N, MOD) - comt[a])%MOD;
	ans = (2*MOD + ans - comt[b] )% MOD;
	cout  << ans - 1;
	return 0;
}

// 34076506

Measured memory_bytes: 6400
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans=INF;
	ll N,M,K,G,A[500010],B[500010];
	ll id=-1;
	ll sum;bool F=true;

int main(){
	ios_base::sync_with_stdio(false);
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];

	}
	REP(i,N-K+1){
		DEB(A[i])DEB(A[i+K-1])END
		//DEB(abs(A[i]))DEB(abs(A[i+K-1]))END
		if(A[i]<0&&A[i+K-1]>0){
			DEB(abs(A[i])*2+abs(A[i+K-1]))DEB(abs(A[i])+abs(A[i+K-1])*2)END
			ans=min({abs(A[i])*2+abs(A[i+K-1]),abs(A[i])+abs(A[i+K-1])*2,ans});
		}else{
			if(A[i]<0){ans=min(ans, abs(A[i]));DEB(abs(A[i]))END}
			else {ans=min(ans, abs(A[i+K-1]));DEB(abs(A[i+K-1]))END}
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
using namespace std;
static const int MAX=100;
int Taro[MAX], Hanako[MAX];
bool usedT[MAX], usedH[MAX];
int N;

int findUnused(int c, int sIdx = 0) {
    int idx = N;
    if (c == 0) {
        for (int i = sIdx; i < N; i++) if (!usedT[i]) { idx=i; break; }
        return idx;
    }
    for (int i = sIdx; i < N; i++) if (!usedH[i]) { idx=i; break; }
    return idx;
}

int findNext(int c, const int & val) {
    int idx = N;
    if (c == 0) {
        idx = int(lower_bound(Taro, Taro+N, val)-Taro);
        if (usedT[idx] && idx < N) idx = findUnused(c, idx);
        return idx;
    }
    idx = int(lower_bound(Hanako, Hanako+N, val)-Hanako);
    if (usedH[idx] && idx < N) idx = findUnused(c, idx);
    return idx;
}

int main() {
    int idxT, idxH, current, sumT, sumH;
    bool playerT, playerH;
    for (; ;) {
        scanf("%d", &N);
        if (N == 0) break;
        fill(usedT, usedT+N, 0);
        fill(usedH, usedH+N, 0);
        for (int i = 0; i < N; i++) scanf("%d", &Taro[i]);
        sort(Taro, Taro+N);
        idxT = idxH = 0;
        for (int i = 1; i <= N*2; i++) {
            if (Taro[idxT] != i) { Hanako[idxH++] = i; }
            else idxT++;
        }

        playerH = playerT = true;
        current = Taro[0]; usedT[0] = true;
        idxT = sumT = 1;
        idxH = sumH = 0;
        //printf("\n");
        for (; ;) {
            if (sumT == N) break;
            if (playerT) {
                idxH = findNext(1, current);
                if (idxH < N) {
                    current = Hanako[idxH];
                    usedH[idxH] = true;
                    sumH++;
                }
                else playerH = false;
            } else {
                idxH = findUnused(1);
                current = Hanako[idxH];
                usedH[idxH] = true;
                sumH++;
                playerT = true;
            }
            //printf("Hanako round - current: %d\n", current);

            if (sumH == N) break;

            if (playerH) {
                idxT = findNext(0, current);
                if (idxT < N) {
                    current = Taro[idxT];
                    usedT[idxT] = true;
                    sumT++;
                }
                else playerT = false;
            } else {
                idxT = findUnused(0);
                current = Taro[idxT];
                usedT[idxT] = true;
                sumT++;
                playerH = true;
            }
            //printf("Taro round - current: %d\n", current);
        }
        printf("%d\n", N- sumH);
        printf("%d\n", N- sumT);
    }
    return 0;
}



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

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    double n;cin>>n;
    double c=0;
    rep(i,1,n+1)
    {
        if(i&1)
            c++;
    }
    double p=(c)/(n);
    cout<<fixed<<setprecision(10)<<p<<endl;
}


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

int n,k;

signed main() {
  cin >> n >> k;
  vector<int> bumbo(n);
  for(int i=1; i<=n; i++) {
    int b = n;
    for(int c = i; c<k; c*=2) b *= 2;
    bumbo[i-1] = b;
  }
  int b0 = bumbo[0];
  int s = 1;
  for(int i=1; i<n; i++) {
    assert(bumbo[i] > 0);
    assert(b0 % bumbo[i] == 0);
    s += b0 / bumbo[i];
  }
  double ans = (double)s / b0;
  cout << fixed << setprecision(12) << ans << endl;
}


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

long long fact(long long n, long long m) {
  if (n == 0 || n == 1 || n == m) {
    return 1;
  } else {
    return n * fact(n - 1, m);
  }
}

long long comb(long long n, long long m) {
  return fact(n, n - m) / fact(m, 1);
}

int main(){
  long long ret = 0, a, b;
  cin >> a;
  if (a >= 2) {
    ret += comb(a, 2);
  }
  cin >> b;
  if (b >= 2) {
    ret += comb(b, 2);
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int a,b;

void solve(){
    cin >> a >> b;
    rep(x,100000){
        if(x*8/100==a && x*10/100==b){
            cout << x << endl;
            return;
        }
    }
    cout << -1 << endl;
}

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

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;

queue< pair<int, int> > q[2];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

char s[1010][1010];
int u[1010][1010];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    int sx, sy, ex, ey;
    scanf("%d%d%d%d", &sx, &sy, &ex, &ey);
    for(int i = 0; i <= n + 1; i++) {
        for(int j = 0; j <= m + 1; j++) s[i][j] = '#';
    }
    for(int i = 1; i <= n; i++) {
        scanf("%s", s[i] + 1);
        s[i][m + 1] = '#';
    }
    int x = 0;
    q[x].push( make_pair(sx, sy) );
    u[sx][sy] = 1;
    int ans = 0, flag = 0;
    while(1) {
//        printf("%d\n", ans);
        while(!q[x].empty()) {
            pair<int, int> now, temp;
            now = q[x].front();
//            printf("%d %d\n", now.first, now.second);
            q[x ^ 1].push(now);
            q[x].pop();
            for(int i = 0; i < 4; i++) {
                temp.first = now.first + dx[i];
                temp.second = now.second + dy[i];
                if(!u[temp.first][temp.second] && s[temp.first][temp.second] == '.') {
                    q[x].push(temp);
                    q[x ^ 1].push(temp);
                    u[temp.first][temp.second] = 1;
                }
            }
        }
        if(u[ex][ey]) break;
        ans++;
        x ^= 1;
        while(!q[x].empty()) {
            pair<int, int> now, temp;
            now = q[x].front();
            q[x].pop();
            for(int i = -2; i <= 2; i++) {
                for(int j = -2; j <= 2; j++) {
                    temp.first = now.first + i;
                    temp.second = now.second + j;
                    if(temp.first < 0 || temp.first > n) continue;
                    if(temp.second < 0 || temp.second > m) continue;
                    if(!u[temp.first][temp.second] && s[temp.first][temp.second] == '.') {
                        q[x ^ 1].push(temp);
                        u[temp.first][temp.second] = 1;
                    }
                }
            }
        }
        if(u[ex][ey]) break;
        x ^= 1;
        if(q[x].empty()) {
            flag = 1;
            break;
        }
    }
    if(flag) {
        printf("-1\n");
        return 0;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 8700
#include<bits/stdc++.h>
using namespace std;
struct node
{
	int x,v;
};
int n,m,ans;
int g[440],f[440],d[440][440];
vector<node>son[440];
bool flag=0;
void dfs(int x,int fa)
{
	if (f[x]) 
	{
		flag=1;
		return;
	}
	f[x]=1;
	int len=son[x].size();
	for (int i=0;i<len;++i)
	{
		int y=son[x][i].x;
		int v=son[x][i].v;
		if (v<fa) dfs(y,v);
//		if (flag) return;
	}
}
int main()
{

	scanf("%d%d",&n,&m);
	int x,y;
	for (int i=1;i<=m;++i)
	{
		scanf("%d%d",&x,&y);
		son[x].push_back((node){y,i});
		son[y].push_back((node){x,i});
	}
	for (int i=1;i<=n;++i)
	{
		memset(f,0,sizeof(f));
		flag=0;
		dfs(i,999999999);
		if (flag) g[i]=1;
		for (int j=1;j<=n;++j) d[i][j]=f[j];
	}
//	printf("::%d %d\n",d[4][8],d[8][4]);
	for (int i=1;i<=n;++i)
		for (int j=1;j<i;++j)
			if (g[i]==0 && g[j]==0)
			{
//				printf("%d %d\n",i,j);
				flag=0;
				for (int k=1;k<=n;++k)
				if ((d[i][k]&&d[j][k])) 
				{
					flag=1;
					break;
				}
				if (flag==0)
				{
//					printf("%d %d\n",i,j);
					++ans;
				}
			}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

int main() {
	int N, M;
	vector<vector<int> > PY;
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int P, Y;
		cin >> P >> Y;
		vector<int> tmp = {i,P,Y};
		PY.push_back(tmp);
	}
	vector<int> P(N+1, 0);
	sort(PY.begin(), PY.end(), [](vector<int> a, vector<int> b) {return a[2] < b[2]; });
	for (int i = 0; i < M; ++i) {
		
		PY[i].push_back(++(P[PY[i][1]]));
	}
	sort(PY.begin(), PY.end(), [](vector<int> a, vector<int> b) {return a[0] < b[0]; });
	for (auto tmp: PY) {
		printf("%06d%06d\n", tmp[1],tmp[3] );
	}
	return 0;
}

Measured memory_bytes: 7984
N = int(input())

def solve(n):
	if (1+n)*n//2 >= N:
		return 1
	else:
		return 0

def Binary_search(s,l):
	if s == l:
		return s
	if s+1 == l:
		if solve(s):
			return s
		else:
			return l

	c = s + (l-s)//2

	if solve(c):
		return Binary_search(s,c)
	else:
		return Binary_search(c,l)

maximum = Binary_search(1,N)
fuyou = ((1+maximum) * maximum // 2) - N
for i in range(1,maximum+1):
	if i == fuyou:
		continue
	print(i)

Measured memory_bytes: 3408
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int first(int n){
    int ans = n;
    if(n/10 != 0){
        ans = n/10;
        return first(ans);
    }
    return ans;
}

int last(int n){
    return n % 10;
}

int main(){
    int n;
    cin >> n;
    //先頭の数字と最後の数字を表す81個（9*9）のボックスを作って，数を数える．
    //最後にbox[1][2]*box[2][1]をすべてかけ合わせて足す．

    vvi box(10, vi(10, 0));

    for(int i=1;i<=n;i++){
        box[first(i)][last(i)]++;
    }

    int ans = 0;

    
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans += (box[i][j]*box[j][i]);
            //cout << box[i][j] << "  ";
        }
        cout << endl;
    }



    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<unordered_map>
using namespace std;


using ll = long long int;

/// <summary>
/// GCDを計算します
/// </summary>
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
	if (a < b) {
		NumType tmp = a;
		a = b;
		b = tmp;
	}

	NumType r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

/// <summary>
/// 約数を数えます
/// </summary>
template <typename NumType>
NumType cntDivisor(const NumType& num) {
	NumType cnt = 0;
	for (NumType i = 1; i * i <= num; ++i) {
		if (num % i == 0) {
			cnt++;
			if (i * i != num) cnt++;
		}
	}

	return cnt;
}

/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)

const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"


///////////////////////////////////////////////////////////////////////////

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

	ll N, L;
	cin >> N >> L;

	vector<ll> hoge;
	for (ll i = 0; i < N; ++i) {
		hoge.emplace_back(L + i);
	}

	ll ans = 0, tmp = 0;
	for (ll i = 1; i < N; ++i) {
		if (abs(hoge[tmp]) > abs(hoge[i])) {
			tmp = i;
		}
	}

	hoge[tmp] = 0;

	for (ll i = 0; i < N; ++i) {
		ans += hoge[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    int l[Q + 1], r[Q + 1];
    REP_1(i, Q) {
        cin >> l[i] >> r[i];
    }
    int ac[N + 1];
    ac[0] = 0;
    REP_1(i, N - 1) {
        if (S[i-1] == 'A' && S[i ] == 'C') { ac[i] = ac[i-1] + 1; }
        else{ac[i] = ac[i-1];}
    }
//    cout<<ac[0]<<endl<<ac[1]<<endl<<ac[2]<<endl;
    REP_1(i, Q) {
        cout << ac[r[i] - 1] - ac[l[i] - 1] << endl;
    }

}


Measured memory_bytes: 2176
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string ss = "";
            
            for(int i = 0 ; i < s.Length ; i++)
            {
                if((i+1) % 2 == 1)
                {
                    Console.Write(s[i]);
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 11196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
ll n;
ll a[200005], b[200005];
int main(int argc, char const *argv[])
{
	fast;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	if (n & 1)
		cout << b[n / 2] - a[n / 2] + 1;
	else
		cout << b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1;
	return 0;
}

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

#define ran 202202

int n, k, c;
char s[ran];
pair<int, int> pre[ran], suf[ran];

int main() {
	scanf("%d%d%d", &n, &k, &c);
	scanf("%s", s);
	
	int last = -c-2;
	pre[0] = make_pair(-c-2, 0);
	for(int i=0;i<n;i++)
		if(s[i]=='o'&& i-last>c) {
			pre[i+1] = make_pair(i+1, pre[i].second+1);
			last = i;
		} else pre[i+1] = pre[i];
		
	last = n+c+2;
	suf[n+1] = make_pair(n+c+2, 0);
	for(int i=n-1;i>=0;i--)
		if(s[i]=='o' && last-i>c) {
			suf[i+1] = make_pair(i+1, suf[i+2].second+1);
			last = i;
		} else suf[i+1] = suf[i+2];
		
	for(int i=1;i<=n;i++)
		if(pre[i-1].second + suf[i+1].second<k)
			printf("%d\n", i);
	
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n;
  vll v(5);
  cin >> n;
  rep(i, 5) {
    cin >> v[i];
  }

  auto min_index = distance(v.begin(), min_element(all(v)));
  ll ans = (n + v[min_index] - 1) / v[min_index];
  ans += 4;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A;
  for(int i=0;i<N;i++){
    cin >> A;
    if(A%2==0){
      if(!(A%3==0||A%5==0)){
        cout << "DENIED";
        return 0;
      }
    }
  }
  cout << "APPROVED";
  return 0;
}

Measured memory_bytes: 256
import collections
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
n=int(readline())
s=read().decode().splitlines()
c=collections.Counter(s)
print("AC x " + str(c["AC"]))
print("WA x " + str(c["WA"]))
print("TLE x " + str(c["TLE"]))
print("RE x " + str(c["RE"]))

Measured memory_bytes: 17504
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		int[] T = new int[D];
		for (int i = 0; i < D; i++) {
			T[i] = sc.nextInt();
		}
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			C[i] = sc.nextInt();
		}
		int dp[][] = new int[D][N];
		for(int i=0;i<D;i++) {
			for(int j=0;j<N;j++) {
				if(A[j]<=T[i] && T[i]<=B[j]) {
					if(i!=0) {
						for(int k=0;k<N;k++) {
							if (dp[i-1][k]!=-1) {
								dp[i][j] = max(dp[i][j],dp[i-1][k]+diff(C[k],C[j]));
							}
						}
					}else{
						dp[i][j] = 0;
					}
				}else{
					dp[i][j] = -1;
				}
			}
		}
		int ans = 0;
		for(int i=0;i<N;i++) {
			ans = max(ans,dp[D-1][i]);
		}
		System.out.println(ans);
	}
	static private int max(int a, int b) {
		return a > b ? a : b;
	}
	static private int diff(int a,int b) {
		return a>b ? a-b:b-a;
	}
}

Measured memory_bytes: 21128
from itertools import permutations
N,M,R=map(int, input().split())
G=[[float("INF")]*N for _ in range(N)]
r=list(map(int, input().split()))
for i in range(M):
    a,b,c=map(int, input().split())
    G[a-1][b-1]=c
    G[b-1][a-1]=c

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
#print(G)
for i in range(N):
    G[i][i] = 0 #自身のところに行くコストは０
warshall_floyd(G)


#print(G)

ans=float("INf")
for t in permutations(r):
    sub=0
    #print(t)
    for i in range(R):
        if i==0:
            now=t[i]
        sub+=G[now-1][t[i]-1]
        now=t[i]
        #print(now)
    ans=min(ans, sub)
print(ans)

Measured memory_bytes: 70756
n = gets.chomp.to_i
abckind = 3
abc = []
n.times{|i|
  abc[i] = gets.chomp.split(' ').map{ |e| e.to_i }
}

# p ['abc', abc]

dp = abc[0]

# p ['dp', dp]

(n - 1).times{|ii|
  i = ii + 1
  newdp = [-1, -1, -1]
  abckind.times{|j|
    abckind.times{|k|
      if k != j && dp[j] != -1
        cand = dp[j] + abc[i][k]
        newdp[k] = cand if cand > newdp[k]
      end
      # p ['newdp', newdp]
    }
  }
  dp = newdp
  # p ['dp', dp]
}
max = 0
abckind.times{|i|
  max = dp[i] if dp[i] > max
}
puts max


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

int main(void)
{
	int A, B, C, X;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

	int counter = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				int total = (500*i) + (100*j) + (50*k);
				if (total == X) counter++;
				else if (total > X) break;
			}
		}
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let a = read::<i32>();
  let b = read::<i32>();

  println!("{}", a - b + 1);
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define For(i,j,k) for(register int i=(j);i<=(k);++i)
#define Forr(i,j,k) for(register int i=(j);i>=(k);--i)
using namespace std;

template<typename T>
inline void read(T &x){
	T p=1,c=getchar();
	x=0;
	while(!isdigit(c)){
		if(c=='-') p=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	x*=p;
}

const int N=100+10;
int S[N][N],A,B,n,m,x,y;

inline void Init(){
	For(i,1,50) For(j,1,100) S[i][j]=1;
	For(i,51,100) For(j,1,100) S[i][j]=0;
}

int main(){
	read(A),read(B);
	Init();
	A--,B--;
	x=1,y=1;
	while(A){
		S[x][y]=0;
		if(y+2<=100) y+=2;
		else y=1,x+=2;
		A--;
	}
	x=52,y=1;
	while(B){
		S[x][y]=1;
		if(y+2<=100) y+=2;
		else y=1,x+=2;
		B--;
	}
	printf("100 100\n");
	For(i,1,100){
		For(j,1,100){
			if(S[i][j]==0) printf(".");
			else printf("#");
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 256
import random
from operator import itemgetter

N = int(input())
AB = []
for i in range(0,N):
	a,b = input().split()
	a_i = int(a)
	b_i = int(b)
	AB.append((a_i,b_i))

CD = []
for j in range(0,N):
	c,d = input().split()
	c_i = int(c)
	d_i = int(d)
	CD.append((c_i,d_i))

CD.sort()
AB.sort()

count = 0
for n in range(0,N):
	list_AB = []
	for m in range(0,len(AB)):

		if((AB[m])[0]<(CD[n])[0]):
			list_AB.append(AB[m])
	
	if(list_AB != []):
		list_AB = sorted(list_AB, key=itemgetter(1))
		list_AB.reverse()

		for q in range(0,len(list_AB)):
			if((list_AB[q])[1]<(CD[n])[1]):
				count += 1
				AB.remove(list_AB[q])
				break

print(count)

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    string S,T;
    ll N, ans;
    cin >> S;
    cin >> T;
    ans = 0;
    REP(int,i,0,3){
        if ( S.at(i) == T.at(i) ) ans++;
    }
    printf("%lld\n", ans);
    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)

vector<ll> factorize(ll x) {
    vector<ll> res;
    for(ll i=2;i*i<=x;i++)
    {
        if(x%i!=0) continue;
        int num=0;
        while(x%i==0)
        {
            num++;
            x/=i;
        }
        res.pb(num);
    }
    if(x!=1) res.pb(1);
    return res;
}

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        if(n==1)
        {
            cout<<0;
            nl;
            continue;
        }
        vector<ll>v=factorize(n);
        ll cnt=0;
        for(auto a:v)
        {
            ll temp=a;
            ll i=1;
            while(i<=temp)
            {
                temp-=i;
                i++;
                cnt++;
            }
        }
        cout<<cnt;
        nl;

    }
    return 0;
}


Measured memory_bytes: 3508
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

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

	vector<int> as(N);
	for (int i = 0; i < N; ++i) {
		cin >> as.at(i);
	}

	
	int sum = 0;
	for (auto t : as) {
		sum += t;
	}

	if (H <= sum) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

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

int main(){
    int N, x, y, ans = 0, ymax, index;
    cin >> N;
    pair<int , int> r[100], b[100];
    for(int i=0;i<N;i++){
	    cin >> x >> y;
		r[i] = make_pair(x , y);
    }
    for(int i=0;i<N;i++){
	    cin >> x >> y;
	    b[i] = make_pair(x , y);
    }
    // 昇順ソート（x座標）
    sort(b, b + N);
    bool c[100] = {};
    // 青い点をx座標が小さい順に見ていく
    for(int i=0;i<N;i++){
        ymax = -1;
        for(int j=0;j<N;j++){
            // ペアになる赤い点のうちy座標が最大のものを探す
            if(r[j].first < b[i].first && r[j].second < b[i].second && c[j] == 0){
                if(r[j].second > ymax){
                    ymax = r[j].second;
                    index = j;
                }
            }
        }
        // ペアが見つかった場合
        if(ymax > -1){
            c[index] = 1; 
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define inrep(t) int t;cin>>t; while(t--)
#define pb push_back
#define mp make_pair 
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi; 
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;


int main(){
	ios_base::sync_with_stdio(false); 
	ll x,y; cin>>x>>y; 
	int ans=0; 
	while(x<=y){
		x<<=1; ans++; 
	}
	cout<<ans; 
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  int L, R;
  cin >> L >> R;
  if (R - L + 1 >= 2019) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> v;
  for (int i = L; i <= R; i++) {
    v.PB(i % 2019);
  }

  int ans = INF;
  for(int i = 0; i < v.size(); i++) {
    for (int j = i + 1; j < v.size(); j++) {
      ans = min(ans, (v[i]*v[j]) % 2019);
    }
  }
  cout << ans << endl;
  return 0;
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  string s;
  cin >> s;

  int m, d;
  m = (s[5] - '0') * 10 + (s[6] - '0');
  d = (s[8] - '0') * 10 + (s[9] - '0');

  if (m > 4) {
    cout << "TBD" << endl;
  } else if (m == 4) {
    if (d > 30) {
      cout << "TBD" << endl;
    } else {
      cout << "Heisei" << endl;
    }
  } else {
    cout << "Heisei" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class AServalVsMonster {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int h, w;
        in>>h>>w;
        out<<(h+w-1)/w<<'\n';
    }
};


int main() {
	AServalVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int MAX = 100, OFS = MAX + 5;;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if( n == 0) break;
			
			int[][] height = new int[2*MAX + 10][2*MAX + 10];
			int[][] top = new int[2*MAX + 10][2*MAX + 10];
			for(int i=0;i<n;i++) {
				int t=sc.nextInt(), f = sc.nextInt();
				Dice d = new Dice(t, f);
				int nx = OFS, x = OFS, ny = OFS, y = OFS;
				for(;;) {
					int[] ret = d.max();
					x = nx; y = ny;
//					debug(nx, ny, ret);
					for(int j=0;j<2;j++) {
						if(ret[j] != 0) {
							if(height[ny][nx] > height[ny+dy[ret[j]-1]][nx+dx[ret[j]-1]]) {
								d.roll(ret[j]-1);
								ny += dy[ret[j]-1];
								nx += dx[ret[j]-1];
								break;
							}
						}
					}
					if( nx == x && ny == y) {
						height[y][x]++;
						top[y][x] = d.s[0];
//						debug(y, x, d.s[0]);
						break;
					}
				}
			}
//			for(int[] a: height)debug(a);
//			for(int[] a: top) debug(a);
			int table[] = new int[7];
			for(int i=0;i<2*MAX+10;i++) for(int j=0;j<2*MAX+10;j++) {
				table[top[i][j]]++;
			}
			
			for(int i=1;i<=6;i++) System.out.print(table[i] + (i==6? "\n": " "));
		}
	}
	
	int[] dx = {-1, 0, 1, 0};
	int[] dy = {0, -1, 0, 1};
	
	class Dice {
		int[] s= {1, 3, 5, 4, 2, 6};
		Dice(int t, int f) {
			if(!roll(0, 0, t)) roll(1, 0, t);
			roll(2, 1, f);
		}
		
		int[] max() {
			int[] tmp = {0, 0};
			int[] ret = {0, 0};
			for(int i=1;i<=4;i++) {
				if(tmp[0] < s[i]) {
					tmp[1] = tmp[0];
					ret[1] = ret[0];
					tmp[0] = s[i];
					ret[0] = tmp[0]>=4? i: 0;
				}
				else if(tmp[1] < s[i]) {
					tmp[1] = s[i];
					ret[1] = tmp[1]>=4? i: 0;
				}
			}
			return ret;
		}
		
		boolean roll(int d, int sur, int tar) {
			for(int i=0;i<4;i++) {
				if(s[sur] == tar) return true;
				if(d == 0) rollX(0);
				else if(d == 1) rollY(0);
				else       rollZ(0);
//				if(d == 1)debug(s);
//				debug("", d, s, tar);
			}
			return false;
		}
		
		void roll(int d) {
			if(d == 0) rollY(1);
			if(d == 1) rollX(1);
			if(d == 2) rollY(0);
			if(d == 3) rollX(0);
		}
		
		void rollX(int d) {
			if(d == 0) {
				roll(0, 2, 5, 4);
			}
			else {
				roll(0, 4, 5, 2);
			}
		}
		
		void rollY(int d) {
			if(d == 0) {
				roll(0, 1, 5, 3);
			}
			else {
				roll(0, 3, 5, 1);
			}
		}
		
		void rollZ(int d) {
			if(d == 0) {
				roll(1, 2, 3, 4);
			}
			else {
				roll(1, 4, 3, 2);
			}
		}
		
		void roll(int w, int x, int y, int z) {
			int tmp = s[w];
			s[w] = s[x];
			s[x] = s[y];
			s[y] = s[z];
			s[z] = tmp;
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 57180
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long n, i, j, ans;
  cin>>n;
  long long a[n][3];
  long long dp[n+1][3];
  for(i=0;i<n;i++)
  {
    for(j=0;j<3;j++)
      cin>>a[i][j];
  }
  dp[0][0]=0; dp[0][1]=0; dp[0][2]=0;
  for(i=1;i<=n;i++)
  {
    dp[i][0]=max(dp[i-1][1]+a[i-1][0], dp[i-1][2]+a[i-1][0]);
    dp[i][1]=max(dp[i-1][0]+a[i-1][1], dp[i-1][2]+a[i-1][1]);
    dp[i][2]=max(dp[i-1][0]+a[i-1][2], dp[i-1][1]+a[i-1][2]);
  }
  ans=max(dp[n][0], max(dp[n][1], dp[n][2]));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;// std::cout, std::cin
int main()
{
	int A, B;
	std::cin >> A >> B ;
	int tmp1 = A + B;
	int tmp2 = A - B;
	int tmp3 = A * B;
	int ans = tmp1;
	if (ans < tmp2){
		ans = tmp2;	
	}
	if (ans < tmp3) {
		ans = tmp3;
	}
	std::cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    string S;
    cin >> N >> A >> B >> S;
    int sum = 0, cnt = 0;
    for (auto& c : S) {
        if (c == 'a') {
            if (sum < A + B) {
                cout << "Yes" << endl;
                ++sum;
            } else {
                cout << "No" << endl;
            }
        } else if (c == 'b') {
            ++cnt;
            if (sum < A + B && cnt <= B) {
                cout << "Yes" << endl;
                ++sum;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int n,m,c;
	cin>>n>>m>>c;
    long int i,j,b[m],a[n][m],x,d=0,y=0;
	for(i=0;i<m;i++)
	{
		cin>>b[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(i=0;i<n;i++)
	{
		x=c;
		for(j=0;j<m;j++)
		{
			
			d=a[i][j]*b[j];
			x=x+d;
		}
		if(x>0)
		{
			y++;
		}
	}
	cout<<y<<endl;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    ids = [0] * (N + 1)
    for i, s in enumerate(S):
        p = -1 if s == "D" else 1
        ids[i + 1] += ids[i] + p
    print(max(ids))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, l, r;
    while(cin >> n >> l >> r, n){
        vector<int> v(n+1, 1);
        for (int i = 0; i < n; ++i) {
            scanf("%d", &v[i]);
        }
        int cnt = 0;
        for (int i = l; i <= r; ++i) {
            for (int j = 0; j <= n; ++j) {
                if(i%v[j] == 0) {
                    cnt += (j^1)&1;
                    break;
                }
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>
long long n,m,d[100][200010],p=1,i,j;
int main(){
  scanf("%lld %lld",&n,&m);
  for(i=0;i<n;i++)scanf("%lld",&d[0][i+1]);
  for(i=0;i<70;i++){
    for(j=1;j<=n;j++)d[i+1][j]=d[i][d[i][j]];
  }
  for(i=0;i<64;i++){
    if(((1LL<<i)&m))p=d[i][p];//printf("%lld %lld\n",(1LL<<i),p);
  }
  printf("%lld\n",p);
  return 0;
}


Measured memory_bytes: 112676
#pragma comment(linker, "/STACK:60777216")  

#include <cassert>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdlib>
#include<memory.h>
#include<ctime>
#include<bitset>
#include<fstream>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>

using namespace std;

typedef long double ld;

typedef long long ll;
typedef pair<int,int>	pii;
typedef pair<ld,ld>	pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pl;

#define FOR(i,a,b)		for(int i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)			memset(a,b,sizeof a)
#define pb				push_back

int main(){	
#ifdef LocalHost
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif

	int n,m;
	cin>>n>>m;

	int t = 100 * (n-m)+1900*m;
	int mm = 1<<m;

	cout<<t*mm<<endl;

	
#ifdef LocalHost
	printf("TIME: %.3lf\n",ld(clock())/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 256