akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    R(s);
    LL now=0,an=0;
    REP(i,SZ(s)){
        if(s[i]=='W'){
            an+=i-now;
            now++;
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
typedef double ld;
const int maxn=300005;
int n,a[maxn];
i64 sum[maxn],g[maxn],l[maxn],r[maxn],f[maxn],w[maxn];
inline i64 get(int n){return 1ll*n*(n+1)/2;}
inline ld calc(int x,int y){return (ld)(g[x]-g[y])/(x-y);}
int t,q[maxn];
inline void pop(int x){
	while(t>1&&calc(q[t-1],q[t])<=x)t--;
}
inline void push(int x){
	while(t>1&&calc(q[t-1],q[t])<=calc(q[t],x))t--;
	q[++t]=x;
}
inline void dodp(i64 f[]){
	q[t=1]=0;
	rep(i,1,n)sum[i]=(sum[i-1]+a[i]);
	rep(i,1,n){
		pop(i);
		f[i]=max(f[i-1],f[q[t]]+get(i-q[t])-sum[i]+sum[q[t]]);
		g[i]=f[i]+get(i-1)+sum[i];push(i);
	}
}
inline void solve(int L,int R){
	if(L==R)return;int md=(L+R)>>1;t=0;
	rep(i,L,md)g[i]=l[i]+get(i-1)+sum[i],push(i);
	rep(i,md+1,R){
		pop(i);
		w[i]=l[q[t]]+r[i+1]+get(i-q[t])-sum[i]+sum[q[t]];
	}
	f[R]=max(f[R],w[R]);
	per(i,R-1,md+1){
		f[i]=max(f[i],w[i]=max(w[i],w[i+1]));
	}
	solve(L,md);solve(md+1,R);
}
int main(){
	read(n);
	rep(i,1,n)read(a[i]),f[i]=-1e18;
	dodp(l);
	reverse(a+1,a+1+n);
	dodp(r);
	reverse(a+1,a+1+n);
	reverse(r+1,r+1+n);
	rep(i,1,n)sum[i]=sum[i-1]+a[i];
	solve(0,n);
	reverse(a+1,a+1+n);
	reverse(f+1,f+1+n);
	reverse(l+1,l+1+n);
	reverse(r+1,r+1+n);
	swap(l,r);
	rep(i,1,n)sum[i]=sum[i-1]+a[i];
	solve(0,n);
	reverse(a+1,a+1+n);
	reverse(f+1,f+1+n);
	reverse(l+1,l+1+n);
	reverse(r+1,r+1+n);
	swap(l,r);
	int q;read(q);
	while(q--){
		int x,k;read(x);read(k);
		printf("%lld\n",max(l[x-1]+r[x+1],f[x]+a[x]-k));
	}	
	return 0;
}


Measured memory_bytes: 17792
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  long int x;cin>>x;
  
  long int ans=0,tmp=100;
  while(true){
    tmp*=1.01;
    ans++;
    if(tmp>=x){
      break;
    }
  }
  cout<<ans;
  
  
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int ui;

int main()
{

#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
#endif
		
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int a,b;
  	cin>>a>>b;
  	cout<<a*1LL*b<<endl;
		
}

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

typedef long long ll;
using namespace std;
int main()
{
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans=a*x+b*y;

  reps(i,max(x,y)+1){
    ll tmp=2*i*c+a*max(0LL,x-i)+b*max(0LL,y-i);
    ans=min(ans,tmp);
  }


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


Measured memory_bytes: 3592
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(c: "List[str]"):
    print("".join(c[i][i] for i in range(3)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = [next(tokens) for _ in range(3)]  # type: "List[str]"
    solve(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int a[1050][1050];
int main()
{
    int n;
    cin>>n;
    for(int p=0;p<n;p++)
    {
        int u,k;
        cin>>u>>k;
        while(k--)
        {
            int x;
            cin>>x;
            a[u][x]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j-1)cout<<' ';
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3460
#include <stdio.h>

//?????????????´???????????????????
void trace(int A[], int N){
  int i;
  for(i = 0; i < N; i++){
    if(i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N){
  int j, i, v;
  for(i = 1; i < N; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main(){
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for(i = 0; i < N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n;
ll k;
vector<int> a, cyc;

int main() {
    cin >> n >> k;
    a.resize(n + 1);
    reps(i, n) { cin >> a[i]; }
    vector<bool> seen(n + 1);
    int crt = 1;
    cyc.push_back(1);
    seen[1] = true;
    while (true) {
        crt = a[crt];
        if (seen[crt]) break;
        seen[crt] = true;
        cyc.push_back(crt);
    }
    int lp_len = cyc.end() - find(all(cyc), crt);
    int nlp_len = cyc.size() - lp_len;
    k++;
    if (k < (ll)cyc.size())
        cout << cyc[k - 1] << endl;
    else
        cout << cyc[(k - nlp_len + lp_len - 1) % lp_len + nlp_len] << endl;

    return 0;
}

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

using namespace std;

const int MAX_N = 1005;
const int MOD = 1000000007;

int n, m;

char mat[MAX_N][MAX_N];

long long dp[MAX_N][MAX_N];

int main() {
  scanf("%d %d\n", &n, &m);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      scanf("%c", &mat[i][j]);
    }
    if (i < n) {
      scanf("\n");
    }
  }
  dp[1][1] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (mat[i][j] == '.') {
        dp[i][j] = max(dp[i][j], dp[i - 1][j] + dp[i][j - 1]) % MOD;
      } else {
        dp[i][j] = 0;;
      }
      dp[i][j] %= MOD;
    }
  }
  printf("%lld", dp[n][m]);
  return 0;
}


Measured memory_bytes: 9088
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;


int32_t main()
{
	int n,k,c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	
	vector<int> a,b;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='o')
		a.push_back(i),i=i+c;
	}
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='o')
		b.push_back(i),i-=c;
	}
	
	for(int i=0;i<k;i++)
	{
		if(a[i]==b[k-1-i])cout<<a[i]+1<<'\n';
	}
	
}

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

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

int main() {
  long long N;
  long long ans = 0;
  cin >> N;
  for (int i=1; i<=N; i++) {
    for (int j=1; j<=N; j++) {
      for (int k=1; k<=N; k++) {
        ans += gcd(i,gcd(j,k));
      }
    }
  }
  cout << ans << endl;

}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)3001;
int N;
double p[MAXN], dp[MAXN][MAXN];

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for(int i=0; i<N; i++)
    {
        cin >> p[i];
    }

    dp[0][0] = 1.0;
    for(int i=1; i<=N; i++)
    {
        for(int j=0; j<=i; j++)
        {
            if(j)
                dp[i][j] += dp[i-1][j-1]*p[i-1];
            dp[i][j] += dp[i-1][j]*(1-p[i-1]);
        }
    }
    double ans = 0;
    for(int i=N/2+1; i<=N; i++)
    {
        ans += dp[N][i];
    }
    cout << setprecision(14) << fixed << ans;
    return 0;
}


Measured memory_bytes: 68992
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
	int A, B,f=0;
	scanf("%d %d", &A, &B);
	if (A*B >= A + B && A*B >= A-B && f==0) {
		printf("%d", A*B);
		f = 1;
	}
	if (A + B >= A*B && A + B >= A-B && f==0) {
		printf("%d", A + B);
		f = 1;
	}if (A-B >= A*B && A-B >= A + B && f==0) {
		printf("%d",A-B);
		f = 1;
	}
	return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<61);
const int mod=1000000007;
inline int gcd(int a,int b) { return b ? gcd(b, a % b) : a; }
int saik(int now,int h,int w,int sh,int sw,int ban[20][20]){
	int dan[20][20]={0};
	int i,j,ok,ret=9999,id=0;
	ban[sh][sw]=0;
	if(now>10){return ret;}
	for(i=0;i<h;i++){for(j=0;j<w;j++){dan[i][j]=ban[i][j];}}
	i=sh;j=sw;ok=1;id=0;
	while(-1){
		i--;id++;
		if(i<0){ ok=0;break; }
		if(dan[i][j]==3){ return now; }
		if(dan[i][j]==1&&id<2){ ok=0;break; }
		if(dan[i][j]==1){ dan[i][j]=0;break; }
	}
	if(ok==1){dan[i+1][j]=2;ret=min(ret,saik(now+1,h,w,i+1,j,dan));}

	for(i=0;i<h;i++){for(j=0;j<w;j++){dan[i][j]=ban[i][j];}}
	i=sh;j=sw;ok=1;id=0;
	while(-1){
		i++;id++;
		if(i>=h){ok=0;break;}
		if(dan[i][j]==3){return now;}
		if(dan[i][j]==1&&id<2){ ok=0;break; }
		if(dan[i][j]==1){ dan[i][j]=0;break; }
	}
	if(ok==1){dan[i-1][j]=2;ret=min(ret,saik(now+1,h,w,i-1,j,dan));}

	for(i=0;i<h;i++){for(j=0;j<w;j++){dan[i][j]=ban[i][j];}}
	i=sh;j=sw;ok=1;id=0;
	while(-1){
		j--;id++;
		if(j<0){ok=0;break;}
		if(dan[i][j]==3){return now;}
		if(dan[i][j]==1&&id<2){ ok=0;break; }
		if(dan[i][j]==1){ dan[i][j]=0;break; }
	}
	if(ok==1){dan[i][j+1]=2;ret=min(ret,saik(now+1,h,w,i,j+1,dan));}

	for(i=0;i<h;i++){for(j=0;j<w;j++){dan[i][j]=ban[i][j];}}
	i=sh;j=sw;ok=1;id=0;
	while(-1){
		j++;id++;
		if(j>=w){ok=0;break;}
		if(dan[i][j]==3){return now;}
		if(dan[i][j]==1&&id<2){ ok=0;break; }
		if(dan[i][j]==1){ dan[i][j]=0;break; }
	}
	if(ok==1){dan[i][j-1]=2;ret=min(ret,saik(now+1,h,w,i,j-1,dan));}
	return ret;
	
}
bool solve(void){
	int w,h,i,j=0;
	int ban[20][20];
	int sh=0,sw=0,ans=0;
	scanf("%d %d",&w,&h);
	if(w*h==0){return false;}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			scanf("%d",&ban[i][j]);
			if(ban[i][j]==2){sh=i;sw=j;}
		}
	}
	ans=saik(1,h,w,sh,sw,ban);
	if(ans>100){ans=-1;}
	printf("%d\n",ans);
	return true;
}
int main(void){
	while(solve()){}
	return 0;
}

Measured memory_bytes: 2600
def BlCannotGo(dt, dx, dy): ## 行けないならTrue
    if (dt % 2) != ((dx + dy) % 2) or (dx + dy) > dt:
        return True
    else:
        return False

if __name__ == '__main__':
    n = int(input())
    l = list(list(map(int, input().split())) for _ in range(n))

    dt = l[0][0]
    dx = l[0][1]
    dy = l[0][2]
    if BlCannotGo(dt, dx, dy):
        print('No')    
        exit()
        
    for i in range(1,n):
        dt = l[i][0] -  l[i-1][0] 
        dx = l[i][1] -  l[i-1][1]
        dy = l[i][2] -  l[i-1][2]
        if BlCannotGo(dt, dx, dy):
            print('No')    
            exit()

    print('Yes')

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

#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define maxn 3010

using namespace std;

int F[maxn][maxn];
string res;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string S, T;
    cin >> S >> T;
    int len = max(S.size(), T.size());
    FOR(i, 0, len)
        F[i][0] = F[0][i] = 0;
    FOR(i, 1, S.size())
    FOR(j, 1, T.size()) {
        if (S[i-1] == T[j-1])
            F[i][j] = F[i-1][j-1] + 1;
        else
            F[i][j] = max(F[i-1][j], F[i][j-1]);
    }

    int curx = S.size(), cury = T.size();
    res == "";
    while (curx && cury) {
        if (S[curx-1] == T[cury-1]) {
            res.push_back(T[cury-1]);
            --curx; --cury;
            continue;
        }
        if (F[curx][cury] == F[curx-1][cury])
            --curx;
        else
            --cury;
    }
    reverse(res.begin(), res.end());
    cout << res;
	return 0;
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

const int MOD = 1000000007;
lint calcedF[1001][1001];

lint F(const char map[1001][1001], int i, int j, int Height, int Width)
{
    if (i > Height || j > Width) return 0;
    if (map[i][j] == '#') return 0;
    if (i == Height && j == Width) return 1;
    if (calcedF[i][j] != -1) return calcedF[i][j];
    calcedF[i][j] =
        (F(map, i + 1, j, Height, Width) + F(map, i, j + 1, Height, Width)) %
        MOD;
    return calcedF[i][j];
}

void resolve()
{
    int H, W;
    cin >> H >> W;
    char a[1001][1001];
    RPT1(i, H) RPT1(j, W) cin >> a[i][j];

    RPT1(i, H) RPT1(j, W) calcedF[i][j] = -1;
    lint ans = F(a, 1, 1, H, W);
    cout << ans << endl;
}

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


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

using namespace std;

int a[12];

void init()
{
	for (int i = 0; i < 3; ++i)
	{
		scanf("%d", &a[i]);
	}
	sort(a, a + 3);
	int cnt = 0;
	for (int i = 0; i < 3; ++i)
	{
		if(a[i] != a[i + 1]) cnt++;
		//else cnt++;
	}
	printf("%d\n", cnt);
}
int main()
{


	init();

	return 0;
}

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

struct UnionFind{
  
  // -----0-indexed----- //
  
  vector<ll> par;
  vector<ll> siz;
  
  UnionFind(ll sz_): par(sz_), siz(sz_, 1){
    for(ll i = 0; i < sz_; i++) par[i] = i;
  }
  void init(ll sz_){
    par.resize(sz_);
    siz.assign(sz_, 1);
    for(ll i = 0; i < sz_; i++) par[i] = i;
  }
  
  
  ll root(ll x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  
  bool merge(ll x, ll y){
    ll rx = root(x);
    ll ry = root(y);
    if(rx == ry) return false;
    if(siz[rx] < siz[ry]) swap(rx, ry);
    siz[rx] += siz[ry];
    par[ry] = rx;
    return true;
  }
  
  bool issame(ll x, ll y){
    return root(x) == root(y);
  }
  
  ll size(ll x){
    return siz[root(x)];
  }
};

int main(){
  ll N, K, L; cin >> N >> K >> L;
  UnionFind rd(N), rw(N);
  vector< pair<ll, ll> > grp(N);
  map< pair<ll, ll>, ll > cnt;
  
  for(ll k = 0; k < K; k++){
    ll p, q; cin >> p >> q;
    rd.merge(p-1, q-1);
  }
  for(ll l = 0; l < L; l++){
    ll r, s; cin >> r >> s;
    rw.merge(r-1, s-1);
  }
  
  
  for(ll i = 0; i < N; i++){
    grp[i] = pair<ll, ll> (rd.root(i), rw.root(i));
    cnt[grp[i]]++;
  }
  
  for(ll i = 0; i < N; i++){
    cout << cnt[grp[i]] << ' ';
  }
}

Measured memory_bytes: 21120
#include <stdio.h>
#include <string.h>

#define N 100

static int num[N];
static int ind = 0;

void push(int value) {
    ind++;
  num[ind] = value;
}

int pop() {
  int tmp = num[ind];
  ind--;
  return tmp;
}

int main() {
    int i = 0, n, tmp;
    int j;
    int result = 0;
    char value;
    char calc[N];
    while(scanf("%s", calc) != EOF) {
      if(calc[0] == '+') {
        result = pop() + pop();
        push(result);
      } else if(calc[0] == '-') {
        tmp = pop();
        result = pop() - tmp;
        push(result);
      } else if(calc[0] == '*') {
        result = pop() * pop();
        push(result);
      } else {
        n=0;
          for(j = 0; j < calc[j]!='\0'; j++) {
            n = n * 10 + (calc[j] - '0');
          }
          push(n);
      }
    }
      printf("%d\n", pop());
      return 0;
}

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

#define int long long

const int MOD = 998244353;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> l(k), r(k);
  for (int i = 0; i < k; i++) 
    cin >> l[i] >> r[i];
  vector<int> pre(n + 1), dp(n + 1);
  dp[1] = pre[1] = 1;
  auto sum = [&](int l, int r) {
    l = max(l, 0ll);
    // cout << l << ' ' << r << '\n';
    return pre[r] - (l == 0 ? 0 : pre[l - 1]);
  };
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < k; j++) if (i - l[j] >= 0) {
      int cur = sum(i - r[j], i - l[j]) % MOD;
      dp[i] += cur % MOD;
      dp[i] %= MOD;
    }
    pre[i] = (pre[i - 1] % MOD + dp[i] % MOD) % MOD;
  }
  dp[n] %= MOD;
  cout << (dp[n] + MOD) % MOD << '\n';
  return 0;
}

Measured memory_bytes: 6360
N, A, B = map(int, input().split())
X_arr = list(map(int, input().split()))
X_diff = []
for i in range(N-1):
    X_diff.append(X_arr[i+1] - X_arr[i])
# print(X_diff)
ans = 0
for d in X_diff:
    if d * A < B:
        ans += d * A
    else:
        ans += B
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int, int>
#define endl "\n"
#define MAXN 100005
using namespace std;

int d, t, s;

void solve()
{
    cin >> d >> t >> s;
    if (s * t >= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class Main{
  public static void main(String[] args)throws IOException{
     
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
 
    String[] strAry = str.split(" ");
    int x = Integer.parseInt(strAry[0]);
    int y = Integer.parseInt(strAry[1]);
 
    System.out.println(x*y +" "+ 2*(x+y));
  }
}

Measured memory_bytes: 24176
#include <bits/stdc++.h>
using namespace std;
int main(){           
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   //freopen("input.in","r",stdin); 
                          string s1,s2;
cin>>s1>>s2;
s2+=s1;
cout<<s2;

   return 0;              
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

struct Point {
  double x;
  double y;
  void pr() {
    printf("%.8f %.8f\n", x, y);
  }
};

void draw(int n, Point &a, Point &b) {
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;
  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  if (n == 1) {
    a.pr(); s.pr(); u.pr(); t.pr();
  }
  else {
    draw(n - 1, a, s); draw(n - 1, s, u);
    draw(n - 1, u, t); draw(n - 1, t, b);
  }
}

int main() {
  int n;
  std::cin >> n;
  Point a{0.0, 0.0}, b{100.0, 0.0};
  if (n == 0) a.pr();
  else draw(n, a, b);
  b.pr();
  return 0;
}



Measured memory_bytes: 3228
//https://atcoder.jp/contests/abc177/tasks/abc177_b
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s, t;
    cin>>s>>t;
 
    int lenS=s.length();
    int lenT=t.length();
    int ans=1e4;
    for (int i=0; i+lenT<=lenS; i++) {
        int change=0;
        for (int j=0; j<lenT; j++) {
            if (s[i+j]!=t[j]) {
                change++;
            }
        }
        ans = min(ans, change);
    }
 
    cout<<ans<<"\n";
 
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end(), greater<int>());
  ll x=0, y=0;
  for(ll i=0; i<N-1; ++i) {
    if(A[i] == A[i+1]) {
      if(x == 0) x = A[i];
      else if(y == 0) y = A[i];
      ++i;
    }
  }
  cout << x * y << endl;
}

Measured memory_bytes: 1024
D=int(input())
c = list(map(int,input().split()))

s=[None]*D
for i in range(D):
    s[i] = list(map(int,input().split()))

def maxarg(l):
    nl=len(l)
    ma=-10**20
    idx=-1
    for i in range(nl):
        if l[i]>ma:
            ma=l[i]
            idx=i
    return (idx,ma)

last=[0]*26
for j,ss in enumerate(s):
    
    cand = [ss[i]-c[i]*(j+1-last[i]) for i in range(26)]
    
    idx,val = maxarg(cand)
    last[idx]=j+1
    
    print(idx+1)

Measured memory_bytes: 73924
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n;
    cin >> a >> b;
    int na=0,nb=0,nc=0;
    REP(i,n){
        int p;
        cin >> p;
        if(p<=a){
            na++;
        }else if(p<=b){
            nb++;
        }else{
            nc++;
        }
    }
    cout << min(na,min(nb,nc)) << endl;
    return 0;
}

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

int N, D;

int main(){
    cin >> N >> D;
    vector<long long> X(N);
    vector<long long> Y(N);
    int ans = 0;
    for(int i = 0; i < N; ++i){
        cin >> X[i] >> Y[i];
    }
    for(int i = 0; i < N; ++i){
        if(sqrt(X[i]*X[i] + Y[i]*Y[i]) <= D) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6452
use std::io;
fn main() {
    solve_d();
}

fn solve_d() {
    let mut rc = String::new();
    io::stdin().read_line(&mut rc).unwrap();
    let rc: Vec<_> = rc.trim()
        .split(' ')
        .map(|s| s.parse::<usize>().unwrap())
        .collect();
    let n = rc[0];
    let m = rc[1];
    let l = rc[2];

    let mut a: Vec<u64> = vec![0; n * m];
    for i in 0..n {
        let mut row = String::new();
        io::stdin().read_line(&mut row).unwrap();
        let row: Vec<_> = row.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        for (j, x) in row.into_iter().enumerate() {
            a[i * m + j] = x;
        }
    }
    let mut b: Vec<u64> = vec![0; m * l];
    for i in 0..m {
        let mut row = String::new();
        io::stdin().read_line(&mut row).unwrap();
        let row: Vec<_> = row.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        for (j, x) in row.into_iter().enumerate() {
            b[i * l + j] = x;
        }
    }

    for i in 0..n {
        for k in 0..l {
            let mut cell = 0;
            for j in 0..m {
                cell += a.get(i * m + j).unwrap() * b.get(j * l + k).unwrap();
            }
            if k != l - 1 {
                print!("{} ", cell);
            } else {
                print!("{}", cell);
            }
        }
        print!("\n");
    }
}



Measured memory_bytes: 5044
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        sc.close();

        // 主処理
        int num = Integer.parseInt(String.valueOf(n.charAt(n.length() - 1)));

        String result;
        if (num == 3) {
            result = "bon";
        } else if (num == 0 || num == 1 || num == 6 || num == 8) {
            result = "pon";
        } else {
            result = "hon";
        }

        // 出力
        System.out.println(result);
    }
}


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

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = 0;
    ans += n / (a + b) * a;

    ll amari = n % (a + b);
    if (amari > a)
    {
        ans += a;
    }
    else
    {
        ans += amari;
    }
    cout << ans << endl ;
}

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

int map[102][52];
int memo[4][52];
int maxDeep;
int getAns(int deep){
	int i,cur=1;
	for(i=1;i<(deep+1)/2;i++){
		for(int j=1;j<=i;j++){
			if(memo[2][j]<memo[1][j]+map[i+1][j])memo[2][j]=memo[1][j]+map[i+1][j];
			if(memo[2][j+1]<memo[1][j]+map[i+1][j+1])memo[2][j+1]=memo[1][j]+map[i+1][j+1];
		}
		for(int j=1;j<=2;j++){
			for(int k=1;k<=i+1;k++){
				memo[j][k]=memo[j+1][k];
			}
		}
	}
	for(;i<deep;i++){
		for(int j=1;j<=deep-i;j++){
			if(memo[1][j]<memo[1][j+1])memo[2][j]=memo[1][j+1]+map[i+1][j];
			else memo[2][j]=memo[1][j]+map[i+1][j];
		}
		for(int j=1;j<=2;j++){
			for(int k=1;k<=i+1;k++){
				memo[j][k]=memo[j+1][k];
			}
		}
	}
	return memo[1][1];
}
int
main(){
	string buf;
	for(int i=0;i<=101;i++){
		for(int j=0;j<=51;j++)map[i][j]=-1;
	}
	for(int i=0;i<=3;i++){
		for(int j=0;j<=51;j++)memo[i][j]=-1;
	}
	for(int i=1;cin>>buf;i++){
		stringstream ss(buf);
		for(int j=1;ss>>map[i][j];j++){
			char tmp;
			ss>>tmp;
			if(i==1&&j==1)memo[i][j]=map[i][j];
		}
		maxDeep=i;
	}
	cout<<getAns(maxDeep)<<endl;
	return 0;
}

Measured memory_bytes: 0
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1286

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include <iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int N,M,K;

int dfs(int n, int total)
{
	int res=0;
	if(n == 0){
		return ( (total - K) > 0 ) ? total - K : 1;
	}
	else{
		REP( i, 1, M+1 ){
			res += dfs( n-1, total+i );
		}
	}
	return res;
}

int main()
{
	cout << setprecision(8) << fixed;

	while(cin >> N >> M >> K && N)
	{
		double d = pow(M,N);
		cout << dfs(N,0) / d << endl;
	}

	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  vector<int> changed(N);
  for (int i = 0; i < N; i++) {
    int S = 0, k = 0;
    for (int j = 0; j < N; j++) {
      if (vec.at(j) > S) {
        S = vec.at(j);
        k = j;
      }
    }
    changed.at(i) = S;
    vec.at(k) = 0;
  }
  int A = 0;
  for (int i = 0; i < N / 2 + N % 2; i++) {
    A += changed.at(2 * i);
  }
  for (int i = 0; i < N / 2; i++) {
    A -= changed.at(2 * i + 1);
  }
  cout << A << endl;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<algorithm> 
#define ll long long
using namespace std;
int n,m,tr[2000005],ans[500005],c[500005],last[500005];
struct node{
	int l,r,id;
}a[500005];
bool cmp(node a,node b){
	return a.r<b.r;
}
void modify(int t,int l,int r,int key,int val){
	if (l==r){
		tr[t]+=val;
		return;
	}
	int mid=(l+r)>>1;
	if (key<=mid) modify(t<<1,l,mid,key,val);
	else modify(t<<1|1,mid+1,r,key,val);
	tr[t]=tr[t<<1]+tr[t<<1|1];
}
int query(int t,int l,int r,int x,int y){
	if (r<x || l>y) return 0;
	if (l>=x && r<=y){
		return tr[t];
	}
	int mid=(l+r)>>1;
	return query(t<<1,l,mid,x,y)+query(t<<1|1,mid+1,r,x,y);
}
int main(){
	scanf("%d",&n);
	scanf("%d",&m);
	for (int i=1;i<=n;i++){
		scanf("%d",&c[i]);
	}
	for (int i=1;i<=m;i++){
		scanf("%d%d",&a[i].l,&a[i].r);
		a[i].id=i;
	}
	sort(a+1,a+m+1,cmp);
	int head=1;
	for (int i=1;i<=n;i++){
		if (last[c[i]]) modify(1,1,n,last[c[i]],-1);
		last[c[i]]=i;
		modify(1,1,n,i,1);
		while (head<=m && a[head].r==i){
			ans[a[head].id]=query(1,1,n,a[head].l,a[head].r);
			head++;
		}
	}
	for (int i=1;i<=m;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

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

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

    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        if ((i % 15 != 0) && (i % 3 != 0) && (i % 5 != 0)){
            sum += i;
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 3636
s = input()
q = int(input())
Q = [ list(input().split()) for _ in range(q) ]

from collections import deque
s = deque(list(s))

count = 0
for i in range(q):
    t = int(Q[i][0])
    if t==1:
        count += 1
    else:
        f = int(Q[i][1])
        new = Q[i][2]
        if count%2==0 and f==1:
            s.appendleft(new)
        elif count%2==0 and f==2:
            s.append(new)
        elif count%2==1 and f==1:
            s.append(new)
        elif count%2==1 and f==2:
            s.appendleft(new)
        else:
            pass

# print(count)

if count%2==0:
    print("".join(s))
    exit()
else:
    s = list(s)[::-1]
    print("".join(s))
    exit()

Measured memory_bytes: 118104
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<set>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n, k;
	cin >> n >> k;
	set<int>d;
	int x;
	rep(i, k){
		cin >> x;
		d.insert(x);
	}
	int tmp;
	int cnt = 0;
	for (int i = n; i < 100000; i++){
		tmp = i;
		while (tmp>0){
			if (d.count(tmp % 10) != 0){
				cnt = 1;
				break;
			}
			tmp /= 10;
		}
		if (cnt == 1){
			cnt = 0;
			continue;
		}
		cout << i << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        
        int res;

        if(x==0){
            res = 1;
        }else{
            res = 0;
        }
        
        
        System.out.println(res);
        
        }
    }

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


int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  ll l = -INF, r = INF;

  // 答えを求めるための二分探索
  while (l + 1 < r){
    ll x = (l + r) / 2;
    bool ok = [&]{
      ll tot = 0;
      rep (i, N) {
        if (A[i] < 0) {
          int l = -1, r = N;
          while (l + 1 < r) {
            int c = (l + r) / 2;
            if (A[c] * A[i] < x) {
              r = c;
            } else {
              l = c;
            }
          }
          tot += N - r;
        } else {
          int l = -1, r = N;
          while (l + 1 < r) {
            int c = (l + r) / 2;
            if (A[c] * A[i] < x) {
              l = c;
            } else {
              r = c;
            }
          }
          tot += r;
        }
        if (A[i] * A[i] < x) tot--;
      }
      tot /= 2;
      return tot < K;
    }();

    if (ok) {
      l = x;
    } else {
      r = x;
    }
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::Itertools;
use num_integer::div_floor;

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")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr >() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn main() {
    let a:i32 = read();
    println!("{}", a + a.pow(2) + a.pow(3));

}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll H,W,K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i,H){
        cin >> S[i];
    }
    ll ans = 1e18;
    rep(i,(1LL << (H-1))){
        vector<ll> gr(H);
        ll tmp = 0;
        gr[0] = 0;
        ll cur = 0;
        rep(j,H-1){
            if((i >> j)&1LL){
                tmp++;
                gr[j+1] = ++cur;
            }else{
                gr[j+1] = cur; 
            }
        }
        vector<ll> bar(cur+1);
        rep(j,W){
            rep(i,H){
                if(S[i][j] == '1'){
                    bar[gr[i]]++;
                }else{
                    continue;
                }
            }
            bool flag = 0;
            rep(i,H){
                if(bar[gr[i]] > K){
                    flag = 1;
                    bar = vector<ll>(cur+1,0);
                    tmp++;
                    break;
                }
            }
            if(flag){
                rep(i,H){
                    if(S[i][j] == '1'){
                       bar[gr[i]]++;
                       if(bar[gr[i]] > K){
                           goto gt;
                       }
                    }else{
                        continue;
                    }
                }
            }
        }
        cmin(ans,tmp);
        gt:
        continue;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()

int prod(const pair<int, int>& p){return p.first * p.second;}

int main(){
    int n, w, d;
    while(cin >> n >> w >> d, n|w|d){
        vector<pair<int, int> > cake;
        cake.emplace_back(w, d);
        rep(_, n){
            int p, s;
            cin >> p >> s;
            p--;
            s %= (cake[p].first + cake[p].second);
            pair<int, int> a(cake[p]), b(cake[p]);
            if(s < cake[p].first)a.first = s, b.first -= s;
            else a.second = s-a.first, b.second -= s-b.first;
            if(b < a)swap(a, b);
            cake.insert(cake.end(), {a, b});
            cake.erase(cake.begin() + p);
        }
        sort(all(cake), [](const pair<int, int>& a, const pair<int, int>& b){return prod(a) < prod(b);});
        rep(i, n+1)cout << prod(cake[i]) << (i != n? ' ': '\n');
    }
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string s;
  cin>>N;
  cin>>s;
  int count = 0;
  for(int i = 0; i <= N-3; i++){
  	if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')count+=1;
  }
  cout<<count<<endl;

  return 0;
}

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

using namespace std;

typedef long long ll;

const int maxn= 1e4+5;

int main() {
	int a[105],N,cnt[105] = {0},num=0;
	scanf("%d",&N);
	for(int i = 1 ; i<=N ; i++) {
		scanf("%d",&a[i]);
	}
	for(int i = 1 ; i<=N ; i++) {
		if(i%2==1) cnt[i]++;
		if(a[i] %2 == 1) cnt[i]++;
	}
	for(int i = 1 ; i<= N ; i++) {
		if(cnt[i] == 2) num++;
	}
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int L,R,ans=114514;
signed main(){
  cin >> L >> R;
  for(int i=L;i<R;i++){
    for(int j=i+1;j<=R;j++){
      if(i*j%2019==0){
        cout << "0" << endl;
        return 0;
      }
      chmin(ans,i*j%2019);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import scala.annotation.tailrec

object Main extends App {

  import scala.io.StdIn._

  val fee = Array(
    Array(0, 6, 10, 12, 14, 27, 33),
    Array(0,7,9,12,23,30),
    Array(0,5,8,20,27),
    Array(0,5,17,26),
    Array(0,12,23),
    Array(0,10),
    Array(0)
  )
  val icFee = Array.tabulate(7){from ⇒ Array.tabulate(7){to ⇒ if (from > to) fee(to)(from - to) else fee(from)(to - from)}}
  val icDist = Array(0, 6,13,18,23,43,58)
  solve
  @tailrec
  def solve: Unit = {
    val d = readLine.trim.toInt
    if (d == 0) return
    val Array(startHour, startMinute) = readLine.trim.split(' ').map(_.toInt)
    val a = readLine.trim.toInt
    val Array(reachHour, reachMinute) = readLine.trim.split(' ').map(_.toInt)
    val range = HourRange(Hour(17, 30), Hour(19, 30))
    if (range.contains(Hour(startHour, startMinute)) || range.contains(Hour(reachHour, reachMinute))) {
      if (math.abs(icDist(a - 1) - icDist(d - 1)) <= 40) {
        println((icFee(a - 1)(d - 1) + 1) / 2 * 50)
      }else{
        println(icFee(a - 1)(d - 1) * 50)
      }
    }else {
      println(icFee(a - 1)(d - 1) * 50)
    }
    solve
  }
  case class HourRange(from: Hour, to: Hour) {
    def contains(that: Hour): Boolean = from <= that && that <= to
  }
  case class Hour(hour: Int, minute: Int) extends Ordered[Hour] {
    override def compare(that: Hour): Int = (hour * 60 + minute).compare(that.hour * 60 + that.minute)
  }

  implicit class Extention[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 44384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll h,w;
    cin >> h >> w;
    cout << (h == 1 || w == 1 ? 1 : ll(ceil(h/2.0)*ceil(w/2.0) + ((h/2) * (w/2)))) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
    #define REP(i,n) for(int i=0;i<(int)(n);++i)
    #define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
     
    using namespace std;
    typedef long long ll;
     
    int main(){
        int K,X;
        cin >> K >> X;

        int left = max(X - K + 1,-1000000);
        int right = min(X + K -1,1000000);
    	
        FOR(i,left,right){
            cout << i << " ";
        }
        cout << right << endl;
    	
    	return 0;
    }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int ans = 0;
		string[] str = Console.ReadLine().Split();
		int M = int.Parse(str[0]);
		int D = int.Parse(str[1]);
		for(var i=1;i<=M;i++){
			for(var j=1;j<=D;j++){
				int d1 = j%10;
				int d10 = j/10;
				if(d1>=2 && d10>=2 && d1*d10==i){
					ans++;
				}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
import bisect as bi
a,b,c,d,e,f = map(int,input().split())

liw = [0]*31
liw[0] = 1
for i in range(30):
  if liw[i] == 1:
    if i+a <= 30:
      liw[i+a] = 1
    if i+b <= 30:
      liw[i+b] = 1

liww = []
for i in range(1,31):
  if liw[i] == 1:
    liww.append(i)

maxs = 30*e+1
lis = [0]*maxs
lis[0] = 1
for i in range(maxs-1):
  if lis[i] == 1:
    if i+c <= maxs-1:
      lis[i+c] = 1
    if i+d <= maxs-1:
      lis[i+d] = 1
liss = []
for i in range(1,maxs):
  if lis[i] == 1:
    liss.append(i)

ans = [0,0,0]
#print(liss)
for i in liww:
  if 100*i > f:
    break
  maxsug = min(f-100*i,i*e)
  #print(maxsug)
  if bi.bisect_right(liss,maxsug) == 0:
    tmpsug = 0
  else:
    #print(bi.bisect_right(liss,maxsug))
    tmpsug = liss[bi.bisect_right(liss,maxsug)-1]
  #print(tmpsug)
  if ans[2] <= tmpsug/(tmpsug+100*i):
    ans[0] = tmpsug+100*i
    ans[1] = tmpsug
    ans[2] = tmpsug/(tmpsug+100*i)
print("{} {}".format(ans[0],ans[1]))

Measured memory_bytes: 3188
#include<stdio.h>
int main(){
  int n,m,l,i,j,k;
  int a[101][101],b[101][101];
  long long ans[101][101]={};
  scanf("%d%d%d",&n,&m,&l);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(j=0;j<m;j++){
    for(i=0;i<l;i++){
      scanf("%d",&b[j][i]);
      
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      for(k=0;k<m;k++){
	ans[i][j]+=a[i][k]*b[k][j];
      }
      printf("%lld",ans[i][j]);
      if(j!=l-1){
	printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}
      



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

const ll nax = 1e18L+5;


int main(){
    int n;
    scanf("%d",&n);
    ll a[n];
    ll sum[n+1];
    sum[0] = 0;
    for(int i = 0;i<n;i++){
        scanf("%lld",&a[i]);
        sum[i+1] = sum[i] + a[i];
    }
    
    ll dp[n][n];
    for(int i = 0;i<n;i++)
        dp[i][i] = 0;
    
    
    for(int len = 2;len<=n;len++){
        for(int  i = 0;i<=n-len;i++){
            int  j = i+len-1;
            dp[i][j] = nax;
            for(int k = i;k<=j-1;k++){
               // cout<<(sum[j+1]-sum[i])<<"\n";
                dp[i][j]  = min(dp[i][j],dp[i][k] + dp[k+1][j] + (sum[j+1]-sum[i]));
            }
        }
    }
    
    
    
    printf("%lld\n" , dp[0][n-1]);
    return 0;
}

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


int main(){
    double N,K;
    cin >> N >> K;
    
    double ans=0;
    for(int i=1; i<=N; i++){
        //int sum=0;
        double ret= 1/N;
        int num=i;
        while(num < K){
            ret *= 0.5;
            num *= 2;
        }
        ans += ret;
    }
    
    cout << setprecision(13) << ans << endl;
}


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

#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)

using ll = long long;
#define INF 1e9

#define mod 1e9+7

int main(){
  int x;
  cin >> x;
  if(x < 1200){
    cout << "ABC" << endl;
  }
  else{
    cout << "ARC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int oturi,n,ans,coin[6]={500,100,50,10,5,1},i,j;
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        ans=0;
        oturi=1000-n;
        for(i=0;i<6;i++){
            while(oturi>=coin[i]){
                oturi-=coin[i];
                ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 600
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))

MOD = 1000000007
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0
for i in range(2, n + 1):
    if i in a:
        dp[i] = 0
        continue
    dp[i] = dp[i - 1] + dp[i - 2]
    dp[i] = dp[i] % MOD
print(dp[n])


Measured memory_bytes: 11884
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;

int main(){
    int n; cin>>n;
    map<string,bool> m;
    string s; cin>>s;
    m[s] = true;
    char c = s[s.size()-1];
    string ans="Yes";
    for(int i = 0; i < n-1; i++){
        cin>>s;
        if(s[0]!=c || m[s]) ans="No";
        c = s[s.size()-1];
        m[s] = true;
    }
    cout<<ans;
    
}

Measured memory_bytes: 256