akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

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

    //write here
    //ll X,Y;
    //cin >> X >> Y;
    //cout << X + Y / 2;
    ll N,T,A;
    vector<ll> H;
    cin >> N;
    cin >> T >> A;

    REP(i,N){
        ll tmp = 0;
        cin >> tmp;
        H.push_back(tmp);
    }
    double h_diff= (double)(T - A);
    double min = 100000000;
    ll index = -1;
    REP(i,N){
        if(abs(h_diff - 0.006 * H[i]) < min){
            min = abs(h_diff - 0.006 * H[i]);
            index = i;
        }
    }
    cout << index + 1;


    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define for_range(i, a, b) for (int i = (a); i < (b); i++)
#define for_range_rev(i, a, b) for (int i = (b)-1; i >= (a); i++)
using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using u32 = uint_fast32_t;
const u64 MOD = 1'000'000'007;
// const u64 MOD = 998'244'353;

int ceil_pow2(int n) {
    int x = 0;
    while ((1u << x) < (u32)(n)) x++;
    return x;
}

struct fwtree {
    using T = i64;
    static T op(T x, T y) { return x + y; }
    static T rop(T x, T y) { return x - y; }

    int n;
    vector<T> d;

    fwtree() : n(0) {}
    fwtree(int sz) : n(sz), d(n) {}

    void add(int k, T x) {
        assert(0 <= k && k < n);
        k++;
        while (k <= n) {
            d[k - 1] = op(d[k - 1], x);
            k += k & -k;
        }
    }

    T sum(int r) {
        T s = 0;
        while (r > 0) {
            s = op(s, d[r - 1]);
            r -= r & -r;
        }
        return s;
    }

    T sum(int l, int r) {
        assert(0 <= l && l <= r && r <= n);
        return rop(sum(r), sum(l));
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    fwtree fw(n);

    for_range(i, 0, n) {
        i64 a;
        cin >> a;
        fw.add(i, a);
    }
    for_range(i, 0, q) {
        int t, a, b;
        cin >> t >> a >> b;
        if (t == 0)
            fw.add(a, b);
        else
            cout << fw.sum(a, b) << '\n';
    }
}

Measured memory_bytes: 8216
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;


void solve()
{
	int n ; 
	cin>>n ;
	int F[N]  = {0};
	repu(i ,  1 , 100){
		repu(j ,1 , 100){
			repu(k , 1  , 100){
				int num = i*i + j*j + k*k + k*i + k*j + j*i ;
				F[num]++;
			}
		}
	}
	repu(i , 1 , n){
		cout<<F[i]<<endl;
	}
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

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

    vector<int> a;
    a.push_back(0);
    for (int i = 1; i < 100005; i++) {
        a.push_back(a.back() + i);
        if (a[i] >= x) break;
    }

    cout << a.size() - 1 << endl;
    return 0;
}


Measured memory_bytes: 3752
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
const int mod = 1000000007;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
using namespace std;
int main() {	
	ll n, ans = 1,ct=0,ct2=0;
	cin >> n;
	int nn; 
	pp v[200010];
	rep(i, n) { cin >> nn; v[i] = pp{ nn,0 }; }
	rep(i, n) { cin >> nn; v[i+n] = pp{ nn,1 }; }
	sort(v, v + n * 2);
	//rep(i, n * 2)cout << v[i].first << "," << v[i].second<<endl;
	rep(i, 2 * n) {
		if (v[i].second == 0) {
			if (ct2 == 0)++ct;
			else { ans *= ct2; --ct2; ans %= mod; }
		}
		if (v[i].second == 1) {
			if (ct == 0)++ct2;
			else { ans *= ct; --ct; ans %= mod; }
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
#include <list>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

const int dx[] = {-1,0,1,1,1,0,-1,-1};
const int dy[] = {-1,-1,-1,0,1,1,1,0};
int field[5][4];
int ans;


void remove_pair(int x, int y, int tx, int ty){
    int i, sa = 1;
    if( 4*y + x < 4*ty + tx ){
        for(i=4*y+x; i<20-sa; i++){
            if( i+1 == 4*ty + tx ) sa++;
            field[i/4][i%4] = field[(i+sa)/4][(i+sa)%4];
        }
    }
    else{
        for(i=4*ty+tx; i<20-sa; i++){
            if( i+1 == 4*y + x ) sa++;
            field[i/4][i%4] = field[(i+sa)/4][(i+sa)%4];
        }
    }
}

void undo(int x, int y, int tx, int ty, int num){
    int i, sa = 2;
    if( 4*y + x > 4*ty + tx ){
        for(i=19; i-sa>=4*ty+tx; i--){
            if( i < 4*y + x ) sa = 1;
            field[i/4][i%4] = field[(i-sa)/4][(i-sa)%4];
        }
    }
    else{
        for(i=19; i-sa>=4*y+x; i--){
            if( i < 4*ty + tx ) sa = 1;
            field[i/4][i%4] = field[(i-sa)/4][(i-sa)%4];
        }
    }
    field[y][x] = field[ty][tx] = num;
}

/*
void output(int cnt){
    int i,j;
    rep(i,5){
        rep(j,4){
            if( 4*i+j >= 20-cnt-2 ) printf("-1 ");
            else printf("%2d ",field[i][j]);
        }
        puts("");
    }
    puts("");
}
*/

void backtrack(int cnt){
    int i,j,k;

    ans = min(ans, 20-cnt);
    if( cnt == 20 ) return;

    for(i=0; i<5; i++){
        for(j=0; j<4; j++){
            if( 4*i + j >= 20-cnt ) continue;
            for(k=0; k<8; k++){
                int tx = j + dx[k];
                int ty = i + dy[k];
                int num = field[i][j];
                if( tx < 0 || tx >= 4 || ty >= 5 || ty < 0 ) continue;
                if( 4*ty + tx >= 20-cnt || field[ty][tx] != field[i][j] ) continue;

                remove_pair(j,i,tx,ty);
                //printf("remove_pair %d\n",num);
                //output(cnt);
                //exit(0);

                backtrack(cnt+2);

                undo(j,i,tx,ty,num);
                //printf("undo %d, (%d,%d),(%d,%d)\n",num,j,i,tx,ty);
                //output(cnt-2);

                if( ans == 0 ) return;
            }
        }
    }
}

int main(){
    int T,i,j;

    cin >> T;
    while( T-- ){
        ans = 20;

        // input
        rep(i,5) rep(j,4) {
            cin >> field[i][j];
        }

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

    return 0;
}

Measured memory_bytes: 0
a = input()
sum = 0
if len(a) % 2 == 0:
    for i in range(1, len(a), 2):
        sum += (10 ** (i - 1)) * 9

else:
    for j in range(1, (len(a)-1), 2):
        sum += (10 ** (j - 1)) * 9
    b = 10 ** int(len(a) - 1)
    s = int(a) - b + 1
    sum += s
print(sum)



Measured memory_bytes: 3060
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        long[] s = Console.ReadLine().Split().Select(long.Parse).ToArray();
        Console.WriteLine(solve(s[0], s[1]));
    }
    static int solve(long x, long y) {
        int count = 0;
        while(x <= y) {
            count ++;
            x *= 2;
        }
        return count;
    }
}

Measured memory_bytes: 13396
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr -- START --
def nCr(n,r):
  if n<r:
    return 0
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
# nCr --- END ---

def main():
  n,m=LI()
  ans=0

  ans+=nCr(n,2)
  ans+=nCr(m,2)

  return ans

# main()
print(main())


Measured memory_bytes: 5716
#include<stdio.h>
int INFTY = (1<<21);

int main(){
  int n,i,j,M[100][100],k, c, u,o,m,doo[100],v[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&o,&c);
      M[u][o]=c;
    }
  }
  for(i=0;i<n;i++) {
    doo[i]=INFTY;
    v[i]=0;
  }
  doo[0]=0;
  while(1){
    m=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(m>doo[i]&&!v[i]){
	u=i;
	m=doo[i];
      }
    }
    if(u==-1) break;
    v[u]=1;
    for(i=0;i<n;i++){
      if(!v[i]&&M[u][i]!=INFTY){
	if(doo[i]>doo[u]+M[u][i]){
	  doo[i]=doo[u]+M[u][i];
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(doo[i]==INFTY?-1:doo[i]));
  }
  return 0;
}



Measured memory_bytes: 1956
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>

int main(void) {
	long long n, m;

	std::cin >> n >> m;

	std::vector<int> v(m, 0);

	for (size_t i = 0; i < n; i++) {
		int k;
		std::cin >> k;
		for (size_t j = 0; j < k; j++) {
			int a;
			std::cin >> a;
			v[a - 1]++;
		}
	}

	int ans = 0;
	for (size_t i = 0; i < v.size(); i++) {
		if (v[i] == n) {
			ans++;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
def flag(A):
    j = 0
    for i in range(len(A)-1):
        if A[i] > A[i+1]:
            j = 1
    return j != 0 
n = 0
while flag(A):
    for i in range(N-1):
        if A[i] > A[i+1]:
            A_i = A[i]
            A[i] = A[i+1]
            A[i+1] = A_i
            n += 1
print(*A)
print(n)


Measured memory_bytes: 5608
#include <stdio.h>

int main(){

  int n,q,i,key,a,b,X;

  int S[100000],ans = 0;

  scanf("%d" ,&n);

  for(i = 0 ; i < n ; i++){
   
   scanf("%d" , S + i);

  }

  scanf("%d" ,&q);

  for(i = 0 ; i < q ; i++){

    scanf("%d" ,&key);
    a = 0; b = n;
    
     while(b >= a){
     
      X = (a + b) / 2;

      if(S[X] == key){
    ans++;
    break;
  
     }

    if(S[X] < key){
     a = X+1;
    }else{

     b = X-1;
      }
    }
   }
   
  printf("%d\n" ,ans);

  return 0;
}

Measured memory_bytes: 2184
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<n; i++)
#define sz(v) (int)(v).size()
using vi = vector < int >;
using vii = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mod = 1e9 + 7;

void calc(char arr[][1010], int res[][1010], int h, int w) {
	for (int i = 1; i < h; i++) {
		if (arr[i][0] == '.') {
			res[i][0] = 1;
		} else {
			break;
		}
	}
	for (int j = 1; j < w; j++) {
		if (arr[0][j] == '.') {
			res[0][j] = 1;
		} else {
			break;
		}
	}
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (arr[i][j] == '.') {
				res[i][j] = (res[i - 1][j] % mod + res[i][j - 1] % mod) % mod;
			}
		}
	}
}





int main() {
// #ifndef ONLINE_JUDGE
// 	if (fopen("input.txt", "r")) {
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	}
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	char arr[1010][1010];
	int h, w;
	cin >> h >> w;
	int res[1010][1010] = {0};
	for0(i, h) {
		for0(j, w) {
			cin >> arr[i][j];
		}
	}

	calc(arr, res, h, w);
	cout << (res[h - 1][w - 1] % mod);
	return 0;
}



Measured memory_bytes: 5248
var x = require("fs").readFileSync("/dev/stdin", "utf8");
x = x.split(" ").map(Number);
var a = x[0], b = x[1], c = x[2];
var n = 0;
for (a; a <= b; a++){
    if (c % a === 0)n++;
}
console.log(n);


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

int main() {
    int n,x,cnt=0;;
    int m[1001];
    scanf("%d%d",&n,&x);
    for(int i=0; i<n; i++){
        scanf("%d",&m[i]);
        x-=m[i];
        cnt++;
    }
    
    sort(m,m+n);
    
    printf("%d",cnt+(x/m[0]) );
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int N;
	char S[101], T[101];
	int i;
	scanf("%d", &N);
	scanf("%s %s", &S, &T);
	for (i = 0; i < N; i++) {
		printf("%c", S[i]);
		printf("%c", T[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w, a, b;
	cin >> w >> a >> b;
	if (b > a + w)cout << b - a - w << endl;
	else if (b + w < a)cout << a - b - w << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int N;
	cin >> N;
	string str[4] = {"AC", "WA", "TLE", "RE"};
	int cnt[4] = {0};

	for (int i = 0; i < N; ++i) {
		string S;
		cin >> S;
		for (int i = 0; i < 4; ++i) {
			if (S == str[i]) {
				cnt[i]++;
				break;
			}
		}
	}

	for (int i = 0; i < 4; ++i) {
		cout << str[i] << " x " << cnt[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

struct edge{
	ll cap;
	int rev;
	int to;
};

vector<edge> g[225];
bool used[225];

void make_edge(int u, int v){
	edge e;
	e.cap = 1ll; e.rev = g[v].l_ength(); e.to = v;
	g[u].push_back(e);
	e.cap = 0ll; e.rev = g[u].l_ength()-1; e.to = u;
	g[v].push_back(e);
}

ll dfs(int s, int t, ll cap){
	int i;
	ll d;
	if(s==t){
		return cap;
	}
	used[s] = true;
	for(i=(g[s].l_ength()-1); i>=0; --i){
		if(used[g[s][i].to]){
			continue;
		}
		if(g[s][i].cap>0){
			d = dfs(g[s][i].to,t,min(cap,g[s][i].cap));
			if(d>0){
				g[s][i].cap -= d;
				g[g[s][i].to][g[s][i].rev].cap += d;
				return d;
			}
		}
	}
	return 0ll;
}

int a[121],b[121],c,d;

int main(void){
	int n,i,j,t;
	ll ans=0ll,f;
	cin >> n;
	for(i=0; i<n; ++i){
		make_edge(2*n,i);
		cin >> a[i] >> b[i];
	}
	for(j=0; j<n; ++j){
		make_edge(j+n,2*n+1);
		cin >> c >> d;
		for(i=0; i<n; ++i){
			if(a[i]<c && b[i]<d){
				make_edge(i,j+n);
			}
		}
	}
	while(true){
		fill(used,used+225,false);
		f = dfs(2*n,2*n+1,INFLL);
		if(!f){
			break;
		}
		ans += f;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();++i){
        s[i]=s[i]+n;
        if(s[i]>'Z')
            s[i]-=26;
    }
    cout<<s;
    return 0;
}


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

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define bitcount(n) __builtin_popcountll(n)


typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 1000000 + 7;
const int M = 20;
const int inf = 786433;
const long long linf = 1e18 + 7;
const double pi = acos(-1);
const double eps = 1e-7;
//const double PI = acos(-1);

int n;
int a[N];

void solve() {
    cin >> n;
    rep(i, 0, 2 * n) scanf("%d", a + i);
    sort(a, a + 2 * n);
    int ans = 0;
    for(int i = 0; i < 2 * n; i += 2)
        ans += a[i];
    cout << ans << "\n";
    
}

int main() {
//    freopen("alpinism.in", "r", stdin);
//    freopen("alpinism.out", "w", stdout);
    //freopen("in.txt", "r", stdin);
    int T = 1;
    //    cin >> T;
    rep(i, 1, T + 1) {
        //printf("Case #%d: ", i);
        solve();
    }
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[1001000];
int main ()
{
	scanf("%s",s);
	int len=strlen(s),ag=0,me=len/2 ;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='p')
			ag++;
	}
	printf("%d",me-ag);
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

inline s64 calc(s64 x, s64 y)
{
    static const s64 s = 32;
    return (x << s) | y;
}

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

    int h, w, n;
    cin >> h >> w >> n;

    vs64 vec;
    rep (i, n)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        rep (j, 3)
        {
            rep (k, 3)
            {
                int y = a - j;
                int x = b - k;
                if (IN(0, h - 2, y) && IN(0, w - 2, x))
                {
                    vec.push_back(calc(x, y));
                }
            }
        }
    }
    sort(vec.begin(), vec.end());

    vs32 ans(10, 0);
    int idx = 0;
    while (idx < vec.size())
    {
        int cnt = 0;
        s64 temp = vec[idx];
        while (idx < vec.size() && vec[idx] == temp) {++cnt; ++idx;}
        ++ans[cnt];
    }

    s64 zero = (s64)(h - 2) * (w - 2);
    rep (i, 10) zero -= ans[i];

    cout << zero << "\n";
    for (int i = 1; i < 10; ++i)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}



Measured memory_bytes: 10604
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,n,k;
    cin >> x >> n;
    vector<bool> p(102,0);
    rep(i,n){
        cin >> k;
        p[k] = 1;
    }
    ll ans = -1;
    rep(i,102){
        if (p[i]) continue;
        if (abs(ans-x) > abs(i-x)) ans = i;
    }
    PRINT(ans);
}


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    string s;
    cin >> s;
    ll cnt = 0, ans;
    for (int i = 0; i < s.size(); i++){
        if (cnt > 0) cnt += 1;
        else if (cnt == 0 && s[i] == 'A') cnt += 1;
        if (s[i] == 'Z') ans = cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> m(4,0);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    m.at(a%4)++;
  }
  cout<<(m.at(1)+m.at(3)<=m.at(0)||(m.at(2)==0&&m.at(1)+m.at(3)<=m.at(0)+1)?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A = inputInt()
	B = inputInt()

	lst = [1,2,3]

	lst.remove(A)
	lst.remove(B)

	print(lst[0])


if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=5e5+1;
const int INF=1e9;

int main(){
    int x,a;
    cin>>x>>a;
    if(x<a)
        cout<<0<<endl;
    else
        cout<<10<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

if __name__ == "__main__":
    n = int(input())
    pos = list()
    for i in range(n):
        pos.append(list(map(int, input().split())))

    # まず1個のボールを最初選びそこから次のボールを選んだときの距離をp,qとして
    # それぞれの組み合わせの最汎値を求める
    dist = list()
    for i in range(n):
        for j in range(n):
            if i != j:
                tmp = (pos[j][0] - pos[i][0], pos[j][1]-pos[i][1])
                dist.append(tmp)

    # most_comon(n)とすると、最も出現回数が多い順からn要素を抽出する
    pq = Counter(dist).most_common(1)

    print(n - pq[0][1] if n != 1 else 1)


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

int main()
{
  int i,j,k;
  int input;
  
  scanf("%d",&i);
  scanf("%d",&j);
  if(i>j){
    k = i;
    i = j;
    j = k;
  }
  
  if(i==1 && j==2){
    printf("3\n");
  }
  else if(i==1 && j==3){
    printf("2\n");
  }
  else if(i==2 && j==3){
    printf("1\n");
  }
  
  
  return 0;
}

Measured memory_bytes: 128
m,i,j,k,c[],p,d;	//c[16]
main(n){
	for(;scanf("%d%d",&n,&m),n;printf("%d\n",j>m?k:j)){
		for(k=3;k--;)
			for(scanf("%d",&i);i--;c[j]=k)scanf("%d",&j);
		for(j=i=0;i++<n;p=c[i]*2+p&3)
			j+=pow(3,n-i)*abs(p-c[i]);
		j=fmin(j,pow(3,n)+~j);
	}
}

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


int H, W;
int f[100][100];

void dfs(int y, int x){
    f[y][x] = 0;

    for(int i = -1; i <= 1; ++i){
        for(int j = -1; j <= 1; ++j){
            if(y+i<0 || x+j < 0 || y+i>=H || x+j>=W) continue;
            if(f[y+i][x+j]) dfs(y+i, x+j);
        }
    }
}

int main(){
    while(cin >> W >> H){
        if(W==0||H==0) break;
        rep(i,H) rep(j,W) cin >> f[i][j];
        int cnt = 0;
        rep(i,H)rep(j,W){
            if(f[i][j])cnt++, dfs(i,j);
        }
        cout << cnt << endl;
    }
    
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  ll a, b, c, x, y ;
  ll ans = 0LL ;

  cin >> a >> b >> c >> x >> y ;

  int temp = min(x, y) ;
  x-=temp , y-=temp ;

  if(a+b >= c*2){
    ans = temp*c*2 ;
  }
  else{
    ans = temp*(a+b) ;
  }

  if(!x){
    if(b>=c*2)
      ans+=(y*c*2) ;
    else
      ans+=(y*b) ;
  }
  else {
    if(a>=c*2)
      ans+=(x*c*2);
    else ans+=(x*a) ;
  }
  cout << ans << endl ;
	
  return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>

int abs(int x){
  if(x > 0) return x;
  else return -x;
}

int min(int a , int b){
  if(a > b) return b;
  else return a;
}

int main(){
  int n,l;
  scanf("%d%d\n",&n,&l);
  int sum = 0;
  for(int i = 0; i < n; ++i) sum += l + i;
  int minus;
  if(l * (l + n - 1) <= 0) minus = 0;
  else{
    minus = min(abs(l),abs(l+n-1));
    if(l < 0) minus = minus * (-1);
  }
  int answer = sum - minus;
  printf("%d",answer);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

#define ll long long
#define nums vector<int>
#define words vector<string>

using namespace std;

int main(void) {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s << endl;
        return 0;
    }
    string sub = s.substr(0, k);
    cout << sub << "..." << endl;

    return 0;
}


Measured memory_bytes: 3636
N = int(input())
C = [ x for x in input().split()]
C1 = C.copy()
C2 = C.copy()

def bubble_sort(N, C1):
    for i in range(N):
        for j in range(N-1, i, -1):
            if C1[j][1] < C1[j-1][1]: #2個目のカッコで文字数を指定(0スタート)
                C1[j], C1[j-1] = C1[j-1], C1[j]
    print(' '.join(map(str, C1)))   

def selection_sort(N, C2):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if C2[minj][1] > C2[j][1]:
                minj = j
        C2[i],C2[minj] = C2[minj],C2[i]

    print(' '.join(map(str, C2)))


#愚直な判定
def bubble(N, C, C1):
    while True:        
        for i in range(N-1):
            for j in range(i+1, N):
                for a in range(N-1):
                    for b in range(a+1, N):
                        if C[i][1] == C[j][1] and C[i] == C1[b] and C[j] == C1[a]:
                            print('Not stable')
                            return False                            
        print('Stable')
        break

def selection(N, C, C2):
    while True:        
        for i in range(N-1):
            for j in range(i+1, N):
                for a in range(N-1):
                    for b in range(a+1, N):
                        if C[i][1] == C[j][1] and C[i] == C2[b] and C[j] == C2[a]:
                            print('Not stable')
                            return False                            
        print('Stable')
        break


bubble_sort(N, C1)
bubble(N, C, C1)
selection_sort(N, C2) 
selection(N, C, C2)                       



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

int main()
{
    int n;
    cin >> n;
    cout << n * (n - 1) / 2 - n / 2 << endl;
    if(n % 2){
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                if(i + j != n) cout << i << " " << j << endl;
            }
        }
    }
    else{
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                if(i != j && i + j != n + 1) cout << i << " " << j << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C;cin>>N>>M>>C;
  int count=0,sum=0;
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++)cin>>B.at(i);
  for(int i=0;i<N;i++){
    sum=0;
    for(int j=0;j<M;j++)cin>>A.at(j);
    for(int j=0;j<M;j++){
      sum+=A.at(j)*B.at(j);
    }
    if(sum+C>0)count++;
  }
  cout<<count<<endl;
}

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

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

using namespace std;

int main()
{
  int n,m;
  scanf("%d %d", &n, &m);

  if(n==m)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<setprecision(10)<<w*h/2<<' ';
  if(x==w/2 && y==h/2){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<functional>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#include<ctime>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 1e5+7;
const int inf = 1e5;
const int modn = 1e9+7;
const ld eps = 1e-8;
const long double PI = acos(-1.0);
void qRead(ll &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
void qRead(int &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
ll qpow(ll a,ll b,ll mo = modn){
//    printf("%lld\n",mo);
    ll res = 1;
    while(b){
        if(b & 1)res = (res*a) % mo;
        a = (a*a) % mo;
        b >>= 1;
    }
    return res;
}
ld qpow(ld a,ll b){
    ld res = 1;
    while(b){
        if(b & 1)res *= a;
        a = a*a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
//ll vis[maxn],prime[maxn],cnt,smallP[maxn];
//void getPrime(int n){
//    cnt = 0;
//    for(int i = 1;i <= n;i++)vis[i] = 0;
//    for(ll i = 2;i <= n;i++){
//        if(!vis[i]){
//            prime[++cnt] = i;
//            smallP[i] = i;
//        }
//        for(int j = 1;j <= cnt && i*prime[j] <= n;j++){
//            vis[prime[j]*i] = 1;
//            smallP[prime[j]*i] = prime[j];
//            if((i % prime[j]) == 0)break;
//        }
//    }
//}
//ll cnm[maxn][maxn];
//void getCnm(){
//    cnm[0][0] = 1;
//    for(int i = 1;i < maxn;i++){
//        for(int j = 0;j <= i;j++){
//            cnm[i][j] = cnm[i-1][j];
//            if(j)cnm[i][j] += cnm[i-1][j-1];
//            cnm[i][j] %= (modn-1);
//        }
//    }
//}
//ll f[maxn],invF[maxn];
//void getF(){
//    f[0] = invF[0] = 1;
//    for(int i = 1;i < maxn;i++)f[i] = f[i-1]*i % modn;
//    invF[maxn-1] = qpow(f[maxn-1],modn-2);
//    for(int i = maxn-2;i >= 1;i--)invF[i] = invF[i+1]*(i+1) % modn;
//}
int main(){
    ll n;
    scanf("%lld",&n);
    if(n % 2)printf("%lld\n",2*n);
    else printf("%lld\n",n);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
#define INF (1LL<<60)
typedef long long Int;

struct node { int x, t, p; };
bool operator<(const node& l, const node& r) {
    return l.t!=r.t ? l.t<r.t : l.x!=r.x ? l.x<r.x : l.p<r.p;
}

int N, V, XL, XR;
node X[4000];

inline bool connect(int i, int j) {
    return abs(X[j].x-X[i].x)<=(long long)V*abs(X[j].t-X[i].t);
}

pair<int, int> pre[10000];
int vis[10000];
Int h[10000];
vector<int> v[10000];
vector<Int> c[10000];

inline void add_edge(int _u, int _v, Int _c) {
    v[_u].push_back(_v);
    c[_u].push_back(_c);
}

int main() {
    scanf("%d%d%d%d", &N, &V, &XL, &XR);
    X[0].x = XL;
    X[1].x = XR;
    rep(i, N) scanf("%d%d%d", &X[i+2].x, &X[i+2].t, &X[i+2].p);
    N += 2;
    sort(X, X+N);
    rep(i, 2) add_edge(0, 2+i*2, 0);
    rep(i, N) {
        const int f = 2+2*i+1;
        add_edge(f-1, f, -X[i].p);
        add_edge(f, 1, 0);
        for(int j=i+1; j<N; j++) if(connect(i, j)) add_edge(f, 2+j*2, 0);
    }
    rep(i, N) h[2+i*2] = INF;
    rep(i, 2) h[2+i*2] = 0, pre[2+i*2] = mp(0, i);
    rep(i, N) {
        const int f = 2+i*2+1;
        h[f] = h[f-1] - X[i].p;
        pre[f] = mp(f-1, 0);
        rep(j, v[f].size()) if(h[v[f][j]] > h[f]) {
            h[v[f][j]] = h[f];
            pre[v[f][j]] = mp(f, j);
        }
    }
    Int a = -h[1];
    int cur = 1;
    while(cur!=0) {
        const int f = pre[cur].first;
        const int k = pre[cur].second;
        add_edge(cur, f, -c[f][k]);
        c[f][k] = INF;
        cur = f;
    }
    priority_queue<pair<Int, int> > q;
    q.push(mp(0, 0));
    while(!q.empty()) {
        const pair<Int, int> vv(q.top());
        q.pop();
        const int cc = -vv.first;
        const int ix = vv.second;
        if(vis[ix]) continue;
        vis[ix] = 1;
        if(ix==1) {
            a -= h[1] + cc;
            break;
        }
        rep(i, v[ix].size()) {
            const Int nc = cc + c[ix][i] + h[ix] - h[v[ix][i]];
            if(vis[v[ix][i]]==0) q.push(mp(-nc, v[ix][i]));
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 112000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int func(int x){
  if(x<10) return x;
  else return x%10+func(x/10);
}
int main() {
  int n;
  cin >> n;
  
  
  int s = func(n);
  if (n%s == 0){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
   return 0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll x ;
    cin >> x ;

    if (x >= 400 and x <= 599)  cout << 8 ;
    else if (x >= 600 and x <= 799) cout << 7 ;
    else if (x >= 800 and x <= 999) cout << 6 ;
    else if (x >= 1000 and x <= 1199)   cout << 5 ;
    else if (x >= 1200 and x <= 1399)   cout << 4 ;
    else if (x >= 1400 and x <= 1599)   cout << 3 ;
    else if (x >= 1600 and x <= 1799)   cout << 2 ;
    else if (x >= 1800 and x <= 1999)   cout << 1 ;

    return 0 ;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if (x == 7 || x == 5 || x == 3)
                Console.WriteLine("YES");
            else Console.WriteLine("NO");
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int d;
    cin >> d;
    if(d==25) out("Christmas");
    else if(d==24) out("Christmas Eve");
    else if(d==23) out("Christmas Eve Eve");
    else out("Christmas Eve Eve Eve");
}

Measured memory_bytes: 256
#include<stdio.h>
int i,j,k;
int n,x;
int count(int n,int x){
	int cnt = 0;
	for(i=1; i<=n-2; i++){
		for(j=i+1; j <= n-1; j++){
			for(k= j+1; k<=n; k++){
				if(i+j+k ==x){
					cnt++;
				}
			}
		}
	}
	return cnt;
}

main(){
	while(1){
		scanf("%d %d",&n,&x);
		if(n == 0 && x == 0){
			break;
		}
		printf("%d\n",count(n,x));
	}
	return 0;
}
		

Measured memory_bytes: 600
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int r, b, g; cin >> r >> b >> g;
    cout << ((10*b+g)%4 ? "NO\n" : "YES\n");
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for _ in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    edge[x].append(y)
flag=[0]*n
dp=[0]*n
def dfs(s):
    if flag[s]:
        return dp[s]
    flag[s]=1
    dist=0
    for i in edge[s]:
        dist=max(dist,dfs(i)+1)
    dp[s]=dist
    return dp[s]
for i in range(n):
    dfs(i)
print(max(dp))

Measured memory_bytes: 62060
import numpy as np
from collections import deque
def s():
    return raw_input()
def li():
    return map(int,raw_input().split())

st = []
X = deque(s())
N = len(X)
st.append(X[0])
X.popleft()
#for i in range(len(X)-2):
for i in range(N-1):
    st.append(X[0])
    X.popleft()
    if len(st) >= 2:
        if st[-1] == 'T' and st[-2] == 'S':
            st.pop()
            st.pop()
print len(st)


Measured memory_bytes: 20268
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
#include <iomanip>
using namespace std;
typedef long long ll;

int gcd(int a,int b){
    int t;
    while(b>0){
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

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

int main(){
    ll n,a,b,c,d,e,k,l,m,o=0,p,q,r,x,y,z,max1=0,ans=0;
    string s,t,u;
    cin>>n;
    ll h[n],h1[n];
    for(ll i=0;i<n;i++){
        cin>>h[i]; 
        h1[h[i]-1]=i;
    }
    for(ll i=0;i<n;i++){
        cout<<h1[i]+1<<" ";
    }
}






Measured memory_bytes: 2432
#include <cstdio>
#include <cmath>

using namespace std;

long T;
int N;
long Begin[100001];
long End[100001];
long sum[100001];
int main(){
	scanf("%ld", &T);
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%ld %ld", &Begin[i], &End[i]);
	}
	for(int i = 0; i < N; i++){
		sum[i + 1] = sum[i] + (End[i] - Begin[i]);
	}
	long ans = 0;
	for(int i = 0; i < N; i++){
		int l = i - 1, r = N;
		while(r - l > 1){
			int m = (r + l) / 2;
			if(Begin[m] - Begin[i] <= T){
				l = m;
			}else{
				r = m;
			}
		}
		long aa = sum[l] - sum[i];
		if(End[l] - Begin[i] > T){
			aa += T - Begin[l];
		}else{
			aa += End[l] - Begin[l];
		}
		if(ans < aa) ans = aa;
	}
	printf("%ld\n", ans);
}
	

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

typedef long long ll;

ll MOD = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll cmb(ll n, ll k, ll mod) {
    ll res = 1;
    rep(i,k) res = res * (n - i) % mod;
    rep(i,k) res = res * mod_pow(i + 1, mod - 2, mod) % mod;
    return res;
}

void solve() {
    //素数判定表作成
    vector<bool> prime(100000, true);
    prime[0] = false;
    prime[1] = false;
    rep(i,100000) {
        if (i * i > 99999) break;
        if (!prime[i]) continue;
        for (int j = 2 * i; j < 100000; j += i) prime[j] = false;
    }
    //素数列作成
    vector<ll> primes;
    rep(i,100000) {
        if (prime[i]) primes.push_back(i);
    }
    int N, M;
    cin >> N >> M;
    //素因数分解
    vector<pair<ll, ll>> pf;
    rep(i,primes.size()) {
        int k = 0;
        while (true) {
            if (M % primes[i] == 0) {
                k++;
                M /= primes[i];
            } else break;
        }
        if (k) pf.push_back(make_pair(primes[i], k));
    }
    if (M > 1) pf.push_back(make_pair(M, 1));

    ll res = 1;
    rep(i,pf.size()) {
        res = res * cmb(N - 1 + pf[i].second, pf[i].second, MOD) % MOD;
    }
    cout << res << endl;
    return;
}

int main() {
    solve();
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL ans,n,nn,a[50];
char s[50];
void dfs(LL k,LL ii)
{
	if(ii<0LL)return;
	LL num,i;
	if(k==nn+1&&ii==0LL)
	{
		num=0LL;
		for(i=1;i<=n;i++)
		{
			num=num*10LL+(s[i]-'0');
			if(i==n)break;
			if(a[i]==1)
			{
				ans+=num;num=0LL;
			}
		}
		ans+=num;num=0LL;
		return;
	}
	if(k>=nn+1)return;
	for(i=0LL;i<=1LL;i++)
	{
		a[k]=i;
		if(i==0LL)dfs(k+1,ii);
		if(i==1LL)dfs(k+1,ii-1);
		a[k]=0LL;
	}
}
int main()
{
	LL i;
	scanf("%s",s+1);
	n=strlen(s+1);nn=n-1;
	ans=0LL;
	memset(a,0,sizeof(a));
	for(i=0;i<=n-1;i++)
	{
		dfs(1,i);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define NMAX 100

int main (void)
{
  int i,j,k,l,n,p[NMAX+1],m[NMAX+1][NMAX+1];

  scanf ("%d",&n);

  for (i = 1 ; i < n+1 ; i++)
    scanf ("%d %d",&p[i-1],&p[i]);

  for (i = 1 ; i < n+1 ; i++)
    m[i][i] = 0;
  for (l = 2 ; l < n+1 ; l++){
    for (i = 1 ; i < n-l+2 ; i++){
      j = i + l - 1;
      m[i][j] = (1<<21);
      for (k = i ; k < j ; k++){
        if (m[i][j] < m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j])
	  m[i][j] = m[i][j];
	else
	  m[i][j] = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
      }
    }
  }

  printf ("%d\n",m[1][n]);

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
 using namespace std;
  
 #define ll long long
 #define pb push_back
 #define an "\n"
 
int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   int a;
   for(int i=1;i<=5;i++) {
         cin >> a;
         if(a==0) {
             cout << i;
         }
     } 
}
           

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}
const ll MOD = 1000000007;

int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
bool solve(vector<string> v, int i, int j, int h, int w)
{
    bool ans = false;
    for(int k = 0; k < 4; k++){
        int l = i+dy[k], r = j+dx[k];
        if(l >= 0 && l < h && r >= 0 && r < w){
            if(v[l][r] == '#') ans = true;
        }
    }
    if(ans){
        return true;
    }
    else return false;
}

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    rep(i, h){
        cin >> v[i];
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(v[i][j] == '.')continue;
            if(!solve(v, i, j, h, w)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(void){
    vector<int> wscore(10);
    vector<int> kscore(10);

    int wmax = 0;
    int kmax = 0;

    for(int i=0; i < 10; i++){
        cin >> wscore[i];
    }
    for(int i=0; i < 10; i++){
        cin >> kscore[i];
    }

    for(int i=0; i < 3; i++){
        vector<int>::iterator max = max_element(wscore.begin(), wscore.end());
        wmax += *max;
        wscore.erase(max);
    }
    for(int i=0; i < 3; i++){
        vector<int>::iterator max = max_element(kscore.begin(), kscore.end());
        kmax += *max;
        kscore.erase(max);
    }

    cout << wmax << " " << kmax << endl;
    return 0;

}

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

using namespace std;
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};
//const int INF = (1 << 29);


int main(){

  string s,t;
  cin >> s >> t;
  cout << t + s;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
#define loopj(n)	for(int j=0;j<n;j++)
#define endl	"\n"
ll mod=1e9+7;
const int N = 1e6+7;
int arr[N];
int main()
{
      //freopen ("output.txt","w",stdout);
        ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0);

        int n;
        cin >>n;
        loop(n)cin >> arr[i];
        ll tot=0,tmp=0;
        loop(n+1){
            if(arr[i]==0){
                tot+=tmp/2;
                tmp=0;
            }
            tmp+=arr[i];
        }
        cout << tot <<endl;
}


Measured memory_bytes: 4004