akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define MIN(x, y) ( (x) < (y) ? (x) : (y) )
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define IVFOR(p,a) for(vector<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ILFOR(p,a) for(list<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define CHECK(x)  cout << #x << " = " << (x) << endl
#define FINA(y) cout << (y) << endl

int main(){

  string s;
  cin >> s;

  int alp[26] = {0};
  int j;
  
  FOR(i,0,s.size()){
    j = int(s[i]) - int('a');
    alp[j]++;
  }

  int flag = 0;

  FOR(i,0,26){
    //    CHECK(alp[i]);
    if(alp[i] % 2 != 0){
      FINA("No");
      flag = 1;
      break;
    }
  }
  if(flag == 0)
    FINA("Yes");
  
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric> 
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
///////////////////////////////////////////////////////////////////////


int main() {
    int n, k;
    scanf("%d%d", &n ,&k);
    vector<int> a(n);
    for (int& x : a) scanf("%d", &x);
    vector<bool> dp(k  + 1);
    for (int stones = 0; stones <= k; stones++) {
        for (int x : a) {
            if (stones >= x && !dp[stones - x]) dp[stones] = true;
        }
    }    
    puts(dp[k] ? "First" : "Second");
}

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

const int MAXN = 1e5 + 100;

using ll = long long;

int N, W;

ll dp[MAXN];

ll v[MAXN], w[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin >> N >> W;
    for (int i = 1; i <= N; ++i) {
        cin >> w[i] >> v[i];
    }
    for (int i = 1; i <= N; ++i) {
        for (int j = W; j >= w[i]; --j) {
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    cout << dp[W];
    return 0;
}

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

int main(void){
    int N,X;
    cin>>N>>X;
    vector<int> m(N);
    for(int i=0;i<N;i++){
        cin>>m[i];
    }
    int count=0;
    for(int i=0;i<N;i++){
        X=X-m[i];
        count++;
    }
    sort(m.begin(),m.end());
    while(X>=m[0]){
        X=X-m[0];
        count++;
    }
    cout<<count<<endl;
    return 0;
}



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

int N;
vector<int> scores;
int judge;

int main()
{
        while(cin >> N){
                if(N==0) break;
                int sum = 0;
                for(int i=0;i<N;i++){
                        cin >> judge;
                        scores.push_back(judge);
                }

                sort(scores.begin(),scores.end());
                scores.erase(scores.begin());
                scores.erase(scores.end()-1);
                for(int i=0;i<N-2;i++){
                        sum += scores[i];
                }
                cout << sum/scores.size() << endl;
                scores.clear();
        }

        return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
using namespace std;
using li = long long;
using vi = vector<li>;
using vs = vector<string>;

int main(int argc,char* argv[])
{
    int n,m;
    cin>>n>>m;
    bool a[n]={0},b[n]={0};
    rep(i,m) {
        int x,y;
        cin>>x>>y;
        if(x==1) a[y-1]=1;
        if(y==n) b[x-1]=1;
    }
    rep(i,n)if(a[i] && b[i]) cout<<"POSSIBLE\n",exit(0);
    cout<<"IMPOSSIBLE\n";
    
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 6;
int H,W,K;
char C[MAX][MAX];

int f(int x,int y){
    int ret = 0;
    char copy[MAX][MAX];
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            copy[i][j] = C[i][j];
        }
    }

    for(int i = 0;i < H;i++){
        if((x >> i) & 1){
            for(int j = 0;j < W;j++){
                copy[i][j] = ' ';
            }
        }
    }
    for(int i = 0;i < W;i++){
        if((y >> i) & 1){
            for(int j = 0;j < H;j++){
                copy[j][i] = ' ';
            }
        }
    }
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(copy[i][j] == '#')ret++;
        }
    }
    return ret;
}

int main(){
    int ans = 0;

    cin >> H >> W >> K;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cin >> C[i][j];
        }
    }

    for(int i = 0;i < (1 << H);i++){
        for(int j = 0;j < (1 << W);j++){
            if(f(i,j) == K)ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


//UnionFind
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int n) : par(n, -1) { }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool merge(int x, int y) {//xの木とyの木を結合する
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {//sizeの取得
        return -par[root(x)];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,k,l;
    cin >> n >> k >> l;
    UnionFind c(n),t(n);
    rep(i,k){
        int p,q;
        cin >> p >> q;
        p--;q--;
        c.merge(p,q);
    }
    rep(i,l){
        int r,s;
        cin >> r >> s;
        r--;s--;
        t.merge(r,s);
    }
    map<P,int>mp;
    vector<P>v(n);
    rep(i,n){
        int x,y;
        x = c.root(i);
        y = t.root(i);
        P p = make_pair(x,y);
        v[i]=p;
        mp[p]++;
    }
    rep(i,n){
        P now = v[i];
        ll res = mp[now];
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 16640
N=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        if 4*i*j-N*(i+j)>0 and N*i*j%(4*i*j-N*(i+j))==0:
            print(i,j,N*i*j//(4*i*j-N*(i+j)))
            exit()

Measured memory_bytes: 40812
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			int numOfPrimeNumbers = Integer.parseInt(br.readLine());
			if( numOfPrimeNumbers == 0 )	break;
			System.out.println(getSumOfPrimeNumbers(numOfPrimeNumbers));
		}
	}
	public static long getSumOfPrimeNumbers(int numOfPrimeNumbers){
		long sum = 0;
		ArrayList<Long> primeNumber = getPrimeNumbers();
		for(int i = 0; i < numOfPrimeNumbers; i++){
			sum += (long)primeNumber.get(i);
		}
		return sum;
	}
	private static ArrayList<Long> getPrimeNumbers(){
		ArrayList<Long> primeNumber = new ArrayList<Long>();
		int numPrimeNumbers = 0;
		long n = 1;
		while(numPrimeNumbers < 10000){
			if( isPrimeNumber(++n) ){
				primeNumber.add(Long.valueOf(n));
				numPrimeNumbers++;
			}
		}
		return primeNumber;
	}
	private static boolean isPrimeNumber(long target){
		if( target == 2 )	return true;
		if( target % 2 == 0 )	return false;
		for(int i = 3; i * i < target + 1; i = i + 2){
			if( target % i == 0){
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 36936
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s,t;
    cin >> s>> t;
    int n=s.size();
    int m=t.size();
    int ans=INF;
    rep(i,n-m+1){
        int temp=0;
        rep(j,m){
            if(s[i+j]!=t[j]){
                temp++;
            }
        }
        ans=min(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
cout<<(a+b)*c/2;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a<b&&b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
   
    return 0;
}



Measured memory_bytes: 2108
#include<iostream>
using namespace std;
int main() {
  int list[32768];
  int i,j,c;
  for(i=2; i<32770; i++) list[i-2] = i;
  for(j=2; j*j<32771; j++) {
    if(list[j-2]!=0) {
      for(i=1; j-2+list[j-2]*i < 32769; i++) {
	list[j-2+list[j-2]*i] = 0;
      }
    }
  }

  while(1){
    cin>>i;
    if(i==0) break;
    c=0;
    for(int k=2; k<=(i/2); k++)
      if((list[k-2]!=0)&&(list[i-k-2]!=0))c++;
    cout<<c<<"\n";
  }
}

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

ll mod=1e9+7;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<vector<ll>> comb(2005,vector<ll>(2005));
    comb[0][0]=1;
    for(ll i=1;i<2005;i++){
        for(ll j=0;j<=i;j++){
            if(j==0||j==i){
                comb[i][j]=1;
            }else{
                comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
                comb[i][j]=(comb[i][j]+mod)%mod;
            }
        }
    }
    for(ll i=1;i<=k;i++){
        if(i>n-k+1){
            cout<<0<<endl;
        }else{
            ll ans=comb[n-k+1][i]*comb[k-1][i-1];
            cout<<(ans+mod)%mod<<endl;
        }
    }
}


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

int main()
{
  int n,x;
  while(1){
    int count =0;
    cin >> n >> x;
    if(n==0 && x==0) break;
    for(int i=3;i<=n;i++){
      for(int j=2;j<i;j++){
	for(int k=1;k<j;k++){
	  if(i+j+k==x) count++;
	}
      }
    }
    cout << count << endl;
  }
  return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
	//cin >> tt;
	
	while (tt--)
	{
		int n; cin >> n;
		
		int sum = 0;
		for (int i = 1; i <= n; i++)
		{
			if(i % 3 == 0 or i % 5 == 0) {}
			else
			{
				sum += i;
			}
		}
		cout << sum ;
		
	}
    return 0;
}


Measured memory_bytes: 3648
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
x = sum(b)
for i in range(n - 1):
    if a[i] + 1 == a[i+1]:
        x = x + c[a[i]-1]
print(x)

Measured memory_bytes: 3060
N, Y = map(int, input().split())

for x in range(N+1):
    for y in range(N+1):
        if x + y > N:
            break
        if x * 10000 + y * 5000 + (N-x-y)*1000 == Y:
            print(x, y, N-x-y)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 2940
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

typedef vector < vector < int > > matrix;

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200, mod = 1e9 + 7;

matrix mul(const matrix& A, const matrix& B) {
	int n = A.size();
	matrix C(n, vector < long long > (n, 0));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			long long current = 0;
			for (int k = 0; k < n; ++k) {
				current += A[i][k] * B[k][j];
				if (current >= inf) {
					current %= mod;
				}
			}
			C[i][j] = current % mod;
		}
	}
	return C;
}
 
matrix pow(const matrix& A, long long n) {
	if (n == 0) {
		matrix B(A.size(), vector < long long > (A.size(), 0));
		for (int i = 0; i < A.size(); ++i) {
			B[i][i] = 1;
		}
		return B;
	}
	matrix B = pow(A, n / 2);
	B = mul(B, B);
 
	if (n % 2 == 0) {
		return B;
	} else {
		return mul(B, A);
	}
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	matrix A(n, vector <int> (n));
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cin >> A[i][j];
		}
	}
	A = pow(A, k);
	int sum = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			(sum += A[i][j]) %= mod;
		}
	}
	cout << sum;
	return 0;
}












Measured memory_bytes: 384
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 105;
int n, m, dp[N][N][2];
char a[N][N];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	fw (i, 0, n) fw (j, 0, m) cin >> a[i][j];
	memset(dp, 63, sizeof dp);
	if (a[0][0] == '.') dp[0][0][0] = 0;
	else dp[0][0][1] = 1;
	fw (i, 0, n) fw (j, 0, m) fw (k, 0, 2) if (dp[i][j][k] != inf) {
		if (i < n - 1) {
			if (a[i + 1][j] == '.') {
				dp[i + 1][j][0] = min(dp[i + 1][j][0], dp[i][j][k]);
			} else {
				dp[i + 1][j][1] = min(dp[i + 1][j][1], dp[i][j][k] + 1 - k);
			}
		}
		if (j < m - 1) {
			if (a[i][j + 1] == '.') dp[i][j + 1][0] = min(dp[i][j + 1][0], dp[i][j][k]);
			else dp[i][j + 1][1] = min(dp[i][j + 1][1], dp[i][j][k] + 1 - k);
		}
	}
	cout << min(dp[n - 1][m - 1][0], dp[n - 1][m - 1][1]);
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    ll A,V,B,W,T;
    cin>>A>>V>>B>>W>>T;
    ll X=abs(A-B);
    
    if(X==0){cout<<"YES"<<endl;return 0;}
    if(V<=W){cout<<"NO"<<endl;return 0;}
    ll sa=V-W;
    if(X<=sa*T){cout<<"YES"<<endl;return 0;}
    cout<<"NO"<<endl;

}

Measured memory_bytes: 3640
sx, sy, tx, ty = map(int, input().split())


def get_route(start_x, start_y, end_x, end_y):
    route = ''
    d_y = end_y - start_y
    dir = ''
    if d_y < 0:
        dir = 'D'
    else:
        dir = 'U'
    for i in range(abs(d_y)):
        route += dir

    d_x = end_x - start_x
    dir = ''
    if d_x < 0:
        dir = 'L'
    else:
        dir = 'R'
    for i in range(abs(d_x)):
        route += dir

    return route


ans = get_route(sx, sy, tx, ty)
ans += get_route(tx, ty, sx, sy)
ans += 'LU' + get_route(sx, sy, tx, ty) + 'RD'
ans += 'RD' + get_route(tx, ty, sx, sy) + 'LU'

print(ans)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
int N , K, h  ;
int c=0;
 cin >> N>> K ;
 for (int i=1 ; i<=N; i++)
 {
     cin >> h;
     if(h>=K)
        c++;
 }

 cout << c;



    return 0;
}


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

using namespace std;

int main()
{
	long long A, B, C, ans;
	cin >> A >> B >> C;

	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
		ans = 0;
	else
		ans = min({ A * B, B* C, C * A });

	cout << ans << endl;

	return 0;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  string S;
  cin >> S;
  bool flag = true;
  int cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    if (i == 0) {
      if (S[i] != 'A') {
        flag = false;
      }
    } else if (i >= 2 && i < S.size() - 1 && S[i] == 'C') {
        cnt++;
    } else{
      if(S[i] - 'A' <= 25){
        flag = false;
      }
    }
  }
  if(cnt == 1 && flag){
    cout << "AC" <<endl;
  } else{
    cout << "WA" <<endl;
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  string s;cin >> s;
  int s_sum = 0;
  int t_sum = 0;
  int reduce = 0;
  for(int i = 0; i<s.size();i++){
    if(s_sum > t_sum && s.at(i)=='T'){
      reduce++; 
    }
    if(s.at(i) == 'T' && s_sum > t_sum) t_sum++;
    else if(s.at(i) == 'S') s_sum++;
  }
  cout << s.size() - reduce*2 << "\n";
}


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

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static int Solve(int N, Tuple<int, int>[] tuples)
        {
            long[][] dp = new long[N][];
            dp[0] = Enumerable.Repeat(long.MaxValue, N + 1).ToArray();
            dp[0][0] = 0;
            dp[0][1] = tuples[0].Item2;
            for (int i = 1; i < N; ++i)
            {
                dp[i] = new long[N + 1];
                dp[i][0] = 0;
                for (int j = 1; j <= N; ++j)
                {
                    if (dp[i - 1][j - 1] <= tuples[i].Item1)
                    {
                        dp[i][j] = Math.Min(dp[i - 1][j - 1] + tuples[i].Item2, dp[i - 1][j]);
                    }
                    else
                    {
                        dp[i][j] = dp[i - 1][j];
                    }
                }
            }
            for (int j = 0; j <= N; ++j)
            {
                if (dp[N - 1][j] == long.MaxValue) { return j - 1; }
            }
            return N;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var tuples = new Tuple<int, int>[N];
            for (int i = 0; i < N; ++i)
            {
                var values = ReadInts();
                tuples[i] = new Tuple<int, int>(values[0], values[1]);
            }
            int ans = Solve(N, tuples.OrderBy(pair => pair.Item1 + pair.Item2).ToArray());
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 215208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >>a>>b>>c;
  int m=max({a,b,c});
  int y=m*3-a-b-c;
  int ans;
  if(y%2 == 1){
    ans = (y+3)/2;
  }
  else ans = y/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
和が全て同じ
*/

ll n;

int main(void){
	cin>>n;
	if(n%2==0){
		//最大と最小をペアに
		cout<<n*(n-1)/2 - n/2<<endl;
		reg(i,1,n){
			reg(j,1,i-1){
				if(j==n-i+1)continue;
				cout<<i<<" "<<j<<endl;
			}
		}
	}else{
		//最後だけ全ての要素とペアに
		//最後以外最大と最小をペアに
		n--;
		cout<<n*(n-1)/2 - n/2 + n<<endl;
		reg(i,1,n){
			reg(j,1,i-1){
				if(j==n-i+1)continue;
				cout<<i<<" "<<j<<endl;
			}
		}
		reg(i,1,n){
			cout<<n+1<<" "<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;




int main()
{
  int n;
  char tmp1,tmp2;
  string s,t,res;
  cin >>n;
  cin>>s>>t;
  for(int i=0 ; i<n ; i++ ){
    tmp1=s[i];
    tmp2=t[i];
    res+=tmp1;
    res+=tmp2;
  }
  cout <<res;

  return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

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;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    string x;
    cin>>n>>x;
    reverse(begin(x),end(x));
    ll cnt=0;
    rep(i,n){
        if(x[i]=='1'){
            cnt++;
        }
    }
    map<ll,ll> mp;
    map<ll,vector<ll>> vec;
    FOR(i,-1,2){
        ll mod=cnt+i;
        if(mod<=0) continue;
        ll sum=0;
        ll dig=1%mod;
        vec[mod].push_back(dig);
        rep(j,n){
            sum+=dig*ll(x[j]-'0');
            sum%=mod;
            dig*=2;
            dig%=mod;
            vec[mod].push_back(dig);
        }
        mp[mod]=sum;
    }
    for(int i=n-1;i>=0;i--){
        ll mod=cnt;
        if(x[i]=='0') mod++;
        else mod--;
        if(mod==0){
            cout<<0<<endl;
            continue;
        }
        ll now=mp[mod];
        if(x[i]=='0'){
            now+=vec[mod][i];
            now%=mod;
        }else{
            now-=vec[mod][i];
            now+=mod;
            now%=mod;
        }
        ll ans=1;
        while(now){
            ll div=__builtin_popcountll(now);
            now%=div;
            ans++;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 9700
A, B, C = map(int, input().split())
num = sorted([A, B, C])
if (num[1] - num[0]) % 2 == 0:
  print((num[2] - num[1]) + (num[1] - num[0]) // 2)
else:
  print(((num[2] + 1) - (num[1] + 1)) + ((num[1] + 1) - num[0]) // 2 + 1)


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

int absolute(int N, int K){
  int x;
  x = N - K;
  if(x < 0){
    x = x * (-1);
  }
  return x;
}

int main(void){
  int A, B, K, max;
  int x[2];
  bool ans = false;
  cin >> A >> B;
  if(A > B)
    max = A;
  else
    max = B;
  for(int i = 0; i < max; i++){
    x[0] = absolute(A, i);
    x[1] = absolute(B, i);
    if(x[0] == x[1]){
      K = i;
      ans = true;
      break;
    }
  }
  if(ans) cout << K << "\n";
  else cout << "IMPOSSIBLE" << "\n";
  return 0;
}


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

int main(void) 
{
   int a,b,c,d;
   cin >> a >> b >> c >> d;

   while(a > 0)
   {
       c = c - b;
       if(c <= 0)
       {
           cout << "Yes" << endl;
           return 0;
       }
       a = a - d;
   }

   cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include<vector>

using namespace std;

long long int N;
vector<long long int> V;

int check(long long int m) {
	if (m <= 0) { return -1; }

	if ((N / m) == (N%m)) { return 1; }
	return 0;
}

int main(void) {

	cin >> N;

	long long int ans = 0;

	for (long long int i = 1; i*i <= N; i++) {
		if (N%i != 0) { continue; }
		long long int m = N / i - 1;
		if (check(m) == 1) { ans += m; }
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def md(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
b = [0]*n
ans = []
for i in range(n-1,-1,-1):
    if (b[i]%2 != a[i]):
        c = md(i+1)
        ans.append(i+1)
        for j in c:
            b[j-1] += 1
if (b[0]%2!=a[0]):
    print(-1)
else:
    print(len(ans))
    print(*ans)

Measured memory_bytes: 69084
#include <stdio.h>
 
main(){

  int i,j,n,id,k,p,c1,c2,count;

  int C[100001][3]; 

  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      C[i][j]=-1;
    }
  }
   
  for(i=0;i<n;i++){

    scanf("%d %d",&id,&k);

    if(k>0){
      int array[k];
      for(j=0;j<k;j++){
        if(j==0){ 

      scanf("%d",&array[j]);
      C[id][1]=array[j]; 
          C[array[j]][0]=id;
    }
        else {
      scanf("%d",&array[j]);
          C[array[j-1]][2]=array[j];
      C[array[j]][0]=id;
    }
      }
    }
  }
   
    
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,C[i][0]);
     
    p=C[i][0];

    count=0;

    while(1){
      if(p==-1) break;
      p=C[p][0];
      count++;
       
    }   

    printf("depth = %d, ",count);
 
    if(C[i][0]==-1) printf("root, ");
    else if(C[i][1]==-1){
      printf("leaf, []\n");
      continue;
    }
    else printf("internal node, ");
    
 
    if(C[i][1]!=-1){
 
      c1=C[i][1];
      if(C[c1][2]!=-1)printf("[%d, ",C[i][1]);
      else printf("[%d",C[i][1]);
 
      c2=C[C[i][1]][2];
       
      while(1){ 
        if(C[c2][2]==-1) printf("%d",c2); 
    else if(c2==-1) break;

    else printf("%d, ",c2);
        c2=C[c2][2];
      }
      printf("]\n");
    }
    else printf("[]\n");
  }
  return 0;
}
 

Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int main(void) {
	ll dp[45];
	int n;

	dp[0] = dp[1] = 1;

	cin >> n;

	FOR(i, 2, n) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[n] << endl;
	
	return 0;
}


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

int main(void){
    int N,K;
    cin >> N >> K;
    int num = 1;
    
    bool judge = true;
    int counter = 0;
    
    while(judge == true){ 
        if(num * 2 > num + K) num += K;
        else num *= 2;
        counter++;
        if(counter == N) judge = false;
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            string S = Console.ReadLine();
            int y = int.Parse(S.Substring(0, 4));
            int m = int.Parse(S.Substring(5, 2));
            int d = int.Parse(S.Substring(8, 2));

            long x = y * 10000L + m * 100L + d * 1L;
            long c = 2019 * 10000L + 4 * 100L + 30 * 1L;

            Console.WriteLine(x <= c ? "Heisei" : "TBD");
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11092
# include "cstdio"
# include "iostream"

using namespace std;

inline int n_lowbit(int x){
	int count=0;
	while(x){
		if(x&1){
			return count; 
		}
		count++; 
		x>>=1; 
	}
	return count; 
} 

int
	ans, 
	N, 
	a; 

int main(){
	scanf("%d",&N);
	while(N--){
		scanf("%d",&a);
		ans+=n_lowbit(a); 
	}
	printf("%d",ans); 
	return 0; 
} 

Measured memory_bytes: 256
N,X,M = map(int,input().split())
L = [X]
S = set([X])
idx = N
MOD = 10**9+7
for i in range(1,N):
  X = (X**2%M)
  if len(S) != len(L):
    idx = L.index(X)
    break
  L.append(X)
  S.add(X)

if idx == N:
  print(sum(L[:idx]))
else:
  k = (N-idx)%len(L[idx:])
  print(sum(L[:idx])+((N-idx)//len(L[idx:]))*sum(L[idx:])+sum(L[idx:idx+k]))

Measured memory_bytes: 13260
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int> H(N);
  for(int i=0;i<N;i++)
    cin>>H.at(i);
  int ans=1;
  int Max=H.at(0);
  for(int i=1;i<N;i++){
  if(Max<=H.at(i)){
  Max=H.at(i);
    ans++;
  }
  
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
//52
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

struct S{
  int t;
  vector<char> v;
};

int main(){
  for(int n;cin>>n,n;){
    S is;
    is.t=0;
    is.v.resize(n*n);
    for(int i=0;i<n*n;i++){
      cin>>is.v[i];
    }
    queue<S> que;
    que.push(is);
    set<vector<char> > p;
    while(!que.empty()){
      S c=que.front();
      if(find(c.v.begin(),c.v.end(),'#')==c.v.end())break;
      que.pop();
      if(!p.insert(c.v).second)continue;
      int ps=find(c.v.begin(),c.v.end(),'@')-c.v.begin();
      int x=ps%n;
      int y=ps/n;
      for(int i=-1;i<=1;i++){
	for(int j=-1;j<=1;j++){
	  int nx=x+j;
	  int ny=y+i;
	  if(0<=ny&&ny<n&&0<=nx&&nx<n&&c.v[ny*n+nx]=='.'){
	    vector<char> nv(n*n);
	    for(int k=0;k<n;k++){
	      for(int l=0;l<n;l++){
		if(k==ny&&l==nx){
		  nv[ny*n+nx]='@';
		}else{
		  int ni=0;
		  for(int m=max(0,k-1);m<=min(k+1,n-1);m++){
		    for(int o=max(0,l-1);o<=min(l+1,n-1);o++){
		      ni+=c.v[m*n+o]=='#'||ny==m&&nx==o;
		    }
		  }
		  nv[k*n+l]=((c.v[k*n+l]=='#'&&(ni==3||ni==4))
			     ||(c.v[k*n+l]!='#'&&ni==3))?'#':'.';
		}
	      }
	    }
	    S ns={c.t+1,nv};
	    que.push(ns);
	  }
	}
      }
    }
    cout<<(que.empty()?-1:que.front().t)<<endl;
  }
  return 0;
}

Measured memory_bytes: 2932
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a,b,c,flow,used[101];
struct edge{ll to,cap,rev;};
vector<edge>v[101];
ll dfs(ll s,ll t,ll f){
    if(s==t)return f;
    used[s]=1;
    for(int i=0;i<v[s].size();i++){
        edge &u=v[s][i];
        if(used[u.to]==0&&u.cap>0){
            ll d=dfs(u.to,t,min(f,u.cap));
            if(d>0){
                u.cap-=d;
                v[u.to][u.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        //edge ed1={b,c,v[b].size()};
        v[a].push_back({b,c,(ll)v[b].size()});
        v[b].push_back((edge){a,0,(ll)v[a].size()-1});//v[a].size()-1});
    }
    while(1){
        for(int i=0;i<101;i++)used[i]=0;
        ll f=dfs(0,n-1,1LL<<60);
        flow+=f;
        if(f==0){
            cout<<flow<<endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3184
n,k=map(int,input().split())
a=list(map(int,input().split()))

visited=[1]
for i in range(n):
    visited.append(a[visited[-1]-1])

if k < n:
    print(visited[k])
else:
    first = visited.index(visited[-1])
    loop = visited[::-1][1:].index(visited[-1])+1
    last = (k-first)%loop
    print(visited[first+last])


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

int main() {
        int n, k;
        scanf("%d%d", &n, &k);
        vector<int> a(n);
        rep(i, n) {
                scanf("%d", &a[i]);
        }
        n ++;
        vector<long long> acc(n);
        rep(i, n) if (i) {
                acc[i] = acc[i - 1] + a[i - 1];
        }
        map<int, int> cnt;
        vector<int> b(n);
        rep(i, n) {
                b[i] = ((acc[i] - i) % k + k) % k;
        }
        long long ans = 0;
        rep(i, min(n, k)) {
                ans += cnt[b[i]];
                cnt[b[i]] ++;
        }
        for (int i = k; i < n; i ++) {
                cnt[b[i - k]] --;
                ans += cnt[b[i]];
                cnt[b[i]] ++;
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    cout<<'A'<<b.at(0)<<'C'<<endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    bool is_ok = false;
    ll val = -1;
    rep(i,0,N+1){
        if(i * (i+1) == 2 * N){
            val = i;
            is_ok = true;
        }
    }
    if(!is_ok){
        print("No");
        return 0;
    }else{
        print("Yes");
        print(val+1);
        vector<ll> arr[500];
        ll ss = 0;
        ll gg = 1;
        rep(j,1,N+1){
            arr[ss].push_back(j);
            arr[gg].push_back(j);
            gg++;
            if(gg == val+1){
                ss++;
                gg = ss+1;
            }
        }
        rep(i,0,val+1){
            cout << val << " ";
            ll vsize = arr[i].size();
            rep(j,0,vsize){
                if(j == vsize-1){
                    cout << arr[i][j] << endl;;
                }else{
                    cout << arr[i][j] << " ";
                }
            }
        }

    }
}


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

using ll = long long;
const int N = 3005;
ll dp[N][N], s[N], a[N];

template <class X, class Y>
bool chkmax(X &a, const Y &b){
	return a < b ? a = b, 1 : 0;
}

ll sum(int i, int j){
	return s[j] - s[i - 1];
} 

ll calc(int i, int j){
	if (dp[i][j] != -1) return dp[i][j];
	if (i == j) return dp[i][j] = a[i];
	return dp[i][j] = sum(i, j) - min(calc(i + 1, j), calc(i, j - 1));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> a[i]; s[i] = s[i - 1] + a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << calc(1, n) * 2 - s[n] << '\n';
}

Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,low,high,mid;cin>>a>>b;
	ll ta,tb,ans=-1;
	ta=(a*100/8);tb=(b*10);
	low=(ta>tb)?tb:ta;
	high=(ta>tb)?ta+1:tb;
	while(low<=high)
	{
		mid=low+(high-low)/2;
		ta=(8*mid/100);
		tb=(mid/10);
		if(ta==a&&tb==b)
		{
			ans=mid;
			high=mid-1;
		}
		else
		{
			if(ta>a)
			{
				high=mid-1;
			}
			else if(ta<a)
			{
				low=mid+1;
			}
			else if(tb>b)
			{
				high=mid-1;
			}
			else if(tb<b)
			{
				low=mid+1;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
const lines=readlines()
input()=shift!(lines)
int(x)=parse(Int,x)
intLine()=map(int,split(input()))
function inE(e)
    u,v=intLine()
    push!(e[u],v)
end
function bfs(e,f,s,t)
    q=Array{Tuple{Int,Int}}([(s,1)])
    while !isempty(q)
        v,m=shift!(q)
        u=m>2?1:m+1
        for w=e[v]
            if f[w,u]<0
                f[w,u]=f[v,m]+1
                push!(q,(w,u))
            end
        end
    end
end
function main()
    n,m=intLine()
    e=Array{Int,1}[[]for i=1:n]
    for i=1:m;inE(e);end
    s,t=intLine()
    f=ones(Int,(n,3))*-3
    f[s,1]=0
    bfs(e,f,s,t)
    show(f[t,1]÷3)
end
main()

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0002

int main() {
	int a, b;
	while (cin >> a >> b) {
		int sum = a + b;
		int d = 0;
		while (sum > 0) {
			sum /= 10;
			d++;
		}
		cout << d << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
-- end of templete

f :: Int -> [Int] -> [Int]
f k [x] = [x]
f k (x:xs@(y:ys))
  | mod x k > mod y k = y : f k (x:ys)
  | otherwise = x : f k xs

main = do
    [n,m] <- getInts
    as <- replicateM n getInt
    mapM_ print $ foldl (flip f) as [1..m]


Measured memory_bytes: 4176
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
    std::vector<int> v(5);
    int ans=0;

    for(int i=0;i<5;i++)
    {
        cin>>v[i];
        if(v[i]==0)
            ans=i+1;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3564
unittest
{
	assert( [ "2", "2 3" ].parse.expand.solve == 7 );
	assert( [ "3", "3 3 3" ].parse.expand.solve == 26 );
	assert( [ "1", "100" ].parse.expand.solve == 1 );
	assert( [ "10", "90 52 56 71 44 8 13 30 57 84" ].parse.expand.solve == 58921 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto dp = new long[][]( 2, as.length );
	dp[ 0 ][ 0 ] = ( as[ 0 ] % 2 == 0 ) ? 1 : 2;
	dp[ 1 ][ 0 ] = ( as[ 0 ] % 2 == 0 ) ? 2 : 1;
	foreach( i, a; as[ 1 .. $ ] )
	{
		if( a % 2 == 0 )
		{
			// aが偶数の場合、a-1とa+1は奇数
			dp[ 0 ][ 1 + i ]  = dp[ 0 ][ i ] * 3 + dp[ 1 ][ i ];		// 偶数*偶数=偶数 or 偶数*奇数=偶数 or 奇数*偶数=偶数
			dp[ 1 ][ 1 + i ]  = dp[ 1 ][ i ] * 2;						// 奇数*奇数=奇数
		}
		else
		{
			// aが奇数の場合、a-1とa+1は偶数
			dp[ 0 ][ 1 + i ]  = dp[ 0 ][ i ] * 3 + dp[ 1 ][ i ] * 2;		// 偶数*偶数=偶数 or 偶数*奇数=偶数 or 奇数*偶数=偶数
			dp[ 1 ][ 1 + i ]  = dp[ 1 ][ i ];								// 奇数*奇数=奇数
		}
	}
	return dp[ 0 ][ $ - 1 ];
}


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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int N = 1000007, inf = 0x3f3f3f3f;

char ind[] = {'p', 'p', 'h', 'b', 'h', 'h', 'p', 'h', 'p', 'h', 'h'};
int main() {
	ios::sync_with_stdio(0); cin.tie(0);

	int n; cin >> n;

	cout << ind[n%10] << "on\n";
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

struct path
{
	int nex,to;
}edge[200005];

int head[100005],done[100005],total,number[100005],ok[100005],now;

inline void addedge(int nex, int to)
{
	edge[total].nex = head[nex];
	edge[total].to = to;
	head[nex] = total++;
}

void dfs(int point)
{
	ok[number[point]] = now;
	done[point] = now;
	for (int i = head[point]; i != -1; i = edge[i].nex)
	{
		if (!done[edge[i].to])
		{
			dfs(edge[i].to);
		}
	}
}

int main()
{
	int n,m,a,b,answer;
	answer = 0;
	scanf("%d%d",&n,&m);
	memset(head,-1,sizeof(head));
	for (int i = 1; i <= n; i++)
	{
		scanf("%d",&number[i]);
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d",&a,&b);
		addedge(a,b);
		addedge(b,a);
	}
	for (int i = 1; i <= n; i++)
	{
		if (!done[i])
		{
			now++;
			dfs(i);
		}
	}
	for (int i = 1; i <= n; i++)
	{
		answer += (done[i] == ok[i]);
	}
	printf("%d\n",answer);
	return 0;
}


Measured memory_bytes: 4352