akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;

deque<pair<int, int> > deq;

const int MAX = 1000;
/* 配列 a の [left, right) をソートします */
void MergeSort(int a[], int left, int right) {
    if (right - left == 1) return;
    int mid = left + (right - left) / 2;

    // 左半分 [left, mid) をソート
    MergeSort(a, left, mid);

    // 右半分 [mid, right) をソート
    MergeSort(a, mid, right);

    //一旦「左」と「右」のソート結果をコピーしておく (右側は左右反転)
    int buf[1000];
    int index_buf = 0;
    for (int i = left; i < mid; ++i) {
        buf[index_buf++] = a[i];
    }
    for (int i = right-1; i >= mid; --i) {
        buf[index_buf++] = a[i];
    }
    int last_index_buf = --index_buf;

    // マージする
    int iterator_left = 0;                    // 左側のイテレータ
    //int iterator_right = (int)buf.size() - 1; // 右側のイテレータ
    int iterator_right = last_index_buf;
    for (int i = left; i < right; ++i) {
        // 左側採用
        if (buf[iterator_left] <= buf[iterator_right]) {
            a[i] = buf[iterator_left++];
        }
        // 右側採用
        else {
            a[i] = buf[iterator_right--];
        }
    }
}

#include <queue>
#include <stack>

void breadthFirstSearch(Graph& G,const int n,int initVertex,vector<int>& dist){
    //BFS用のデータ構造
    dist.assign(n,-1);//頂点の深さ記録
    queue<int> que;//次の訪問先を記録

    //初期値
    dist[initVertex] = 0;
    que.push(initVertex);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(auto next_v:G[v]){
            if(dist[next_v] != -1) continue;
            dist[next_v] = dist[v] + 1;
            que.push(next_v);
        }

    }

}

vector<bool> seen;
vector<int> first_order;
vector<int> last_order;
void dfs(Graph& G,int v,int& first,int& last){
    first_order.push_back(first++);
    seen[v] = true;
    for(auto next_v:G[v]){
        if(seen[next_v]) continue;
        dfs(G,next_v,first,last);
    }

    last_order.push_back(last++);




}

double calc(double v){
    int sum=0;
    for(int i=1;i <= v;i++){
        sum = sum + i;
    }

    double ans = sum / v;


    return ans;
}

int main() {
    
    
    int n,k;
    cin >> n >> k;
    vector<double> a(n);

    for(int i=0;i<n;i++) cin >> a[i];
    
    vector<int> s(n+1,0);
    //累積和
    for(int i=0;i < n;i++) s[i+1] = s[i] +a[i];

    //区間kで最大
    int max_range=0;
    int index;
    for(int i=k;i <= n;i++){
        int tmp = s[i] - s[i - k];
        
        if(max_range  < tmp){
            max_range = tmp;
            index = i-k;
        }
    }
    
    double ans =0;
    for(int i=0;i < k;i++){
        double val = (double)a[index++];
        ans = ans + calc(val);

    }


    
    //小数点以下の長さを指定
    cout << fixed << setprecision(10) << ans << endl;


    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int > x(n,0);
  vector<int > y(n,0);
  vector<int > h(n,0);
  REP(i, n){
    cin >> x[i] >> y[i] >> h[i];
  }
  int ansCx,ansCy,ansH;
  REP(cx, 101){
    REP(cy, 101){
      int tmpH;
      bool flag = true;
      REP(i, n){
	if(h[i] > 0){
	  tmpH = abs(x[i] - cx) + abs(y[i] - cy) + h[i]; 
	  break;
	}
      }
      REP(i, n){
	int test = max(tmpH -  abs(x[i] - cx) - abs(y[i] - cy), 0);
	if(test != h[i]){
	  flag = false;
	  break;
	}
      }
      if(flag){
	ansCx = cx;
	ansCy = cy;
	ansH = tmpH;
	cout << cx << " " << cy << " " << ansH << endl;
	return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


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

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans = imn, ct = 0;
	for(int i = 0; i < n; i++)
	{
		if(s[i]=='I') ct++;
		else ct--;
		ans = max(ct, ans);
	}
	p(max(ans, 0));
	return 0;
}	

Measured memory_bytes: 256
'use strict'
function Main(input) {
  let jumpNum = input.split("\n")[0].split(" ")[0]*1;
  let jumpLimit = input.split("\n")[0].split(" ")[1]*1;
  let arr = input.split("\n")[1].split(" ");
  let count = 1;
  let sum = 0;
  for(let i in arr){
    sum += arr[i]*1;
    if(sum <= jumpLimit){
    	count++;
    }
    else{
		break;
    }
  }
  console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const ll M=2e5;
void dfs(vector<vector<ll>> &adj,ll src,ll par,vector<ll> &dp,vector<ll> &bit,ll v[],ll mxx){
 
 for(auto it: adj[src]){
 	if(it!=par){
 		vector<ll> vx;
 		ll x=v[it]-1;
 		ll sum=0;
 		while(x>0){
 			sum=max(bit[x],sum);
 			x-=(x&-x);
 		}
 		sum++;
 		x=v[it];
 		while(x<=M)
 		{
 			vx.push_back(bit[x]);
 			bit[x]=max(bit[x],sum);
 			x+=(x&-x);
 		}
 		dp[it]=max(sum,mxx);
 		ll mxz=max(mxx,sum);

 		dfs(adj,it,src,dp,bit,v,mxz);
 		x=v[it];
 		ll c=0;
 		while(x<=M)
 		{
 			//vx.push_back(bit[x]);
 			bit[x]=vx[c];
 			x+=(x&-x);
 			c++;
 		}

 	}
 }


}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	ll v1[n],v2[n],v[n+1];
	ll i,j;
	for(i=0;i<n;i++){
		cin>>v1[i];
		v2[i]=v1[i];
	}
	sort(v2,v2+n);
	for(i=0;i<n;i++){
		ll a=v1[i];
		v[i+1]=(lower_bound(v2,v2+n,a)-v2)+1;
	}
	vector<vector<ll>> adj(n+1);
	for(i=0;i<n-1;i++){
		ll a,b;cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	vector<ll> dp(n+1,1),bit(M+1,0);
	ll x=v[1];
	//x++;
	while(x<=M){
		bit[x]=1;
		x+=(x&-x);
	}
	//for(i=1;i<=n;i++)
		//cout<<bit[i]<<endl;
	//cout<<endl;
	dfs(adj,1,1,dp,bit,v,1);
	for(i=1;i<=n;i++)
		cout<<dp[i]<<endl;
	return 0;
} 

Measured memory_bytes: 81312
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}


int main(){
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
		#if __cplusplus >= 201103L
		auto start = steady_clock::now();
		#endif
	#endif
	int n = read(), m = read();
	int l = 0, r = n;
	while (m--) {
		int a = read(), b = read();
		l = max(l, a);
		r = min(r, b);
	}
	if (r >= l) {
		cout << r - l + 1 << endl;
	}else cout << 0 << endl;

	#ifdef LOCAL
		#if __cplusplus >= 201103L
		auto end = steady_clock::now();
		duration<double> time_span = duration_cast<duration<double>>(end - start);;
		printf("Total time: %.6fs\n", time_span.count());
		#endif
	#endif
	return 0;
}

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

int main () {
  int n;
  cin >> n;
  vector<int>vec(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> vec[i];
  }
  
  sort(vec.begin(),vec.end());
  
  for(int i=0;i<n-1;i++){
    sum+=vec[i];
  }
  
  if(vec[n-1]<sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define p 37
#define N 305
using namespace std;

typedef long long ll;

ll n, ans, x[N][N], y[N][N];
char a[N][N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);

	scanf("%lld",&n);

	for(int i = 0; i < n; i++)
		scanf("%s",a[i]);

	for(int i = 0; i < n; i++)
		for(int b = 0; b < n; b++){
			for(int k = 0, ind = b; k < n; k++, ind++){
				x[i][b] = x[i][b]*p%mod;
				x[i][b] = (x[i][b] + a[i][ind%n] - 'a' + 1)%mod;
			}
			// printf("x[%d][%d] = %lld\n", i, b, x[i][b]);
		}
	for(int j = 0; j < n; j++)
		for(int b = 0; b < n; b++){
			for(int k = 0, ind = b; k < n; k++, ind++){
				y[j][b] = y[j][b]*p%mod;
				y[j][b] = (y[j][b] + a[ind%n][j] - 'a' + 1)%mod;
			}
			// printf("y[%d][%d] = %lld\n", j, b, y[j][b]);
		}
	for(int a = 0; a < n; a++)
		for(int b = 0; b < n; b++){
			int f = 1, ind1 = a, ind2 = b;
			for(int k = 0; k < n; k++, ind1++, ind2++){
				if(x[ind1%n][b] != y[ind2%n][a])
					f = 0;
				// cout << k << " " << a << " " << b << " -> " << x[k][b] << " " << y[n - k - 1][a] << endl;
			}
			ans += f;
		}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	ll t,s,total[4010];
	int sb[100000];
	int n;
	for(;cin>>n,n;){
		bool f=false;
		rep(i,4010)total[i]=0;
		rep(i,n)sb[i]=0;
		rep(i,n){
			int p;
			cin>>p>>t>>s;
			total[p]+=t*s;
			sb[i]=p;
		}
		rep(i,4001){
			if(total[sb[i]]>=1000000){
				cout<<sb[i]<<endl;
				total[sb[i]]=0;
				f=true;
			}
		}
		if(!f)cout<<"NA\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

#define rep2(i, b, n) for(int i=b; i < n; ++i)
#define rep(i, n) rep2(i, 0, n)
#define sz(x) x.size()
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)
#define B first
#define E second

using namespace std;

typedef pair<int, int> pii;

int cnt[10000];
vector<pii> v[10000];

bool used[1000];

int main( void )
{
	int n, m;
	while(cin >> n >> m, n | m) {
		fill(cnt, cnt+1000, 0);
		memset(used, false, sizeof(used));
		rep(i, m) v[i].clear();

		int r; cin >> r;
		rep(i, r) {
			int tt, nn, mm, ss;
			cin >> tt >> nn >> mm >> ss;
			--mm;
			if(ss) {
				if(used[nn]) continue;
				if(cnt[mm] == 0) {
					v[mm].pb(mk(tt, 0));
				}
				++cnt[mm];
				used[nn] = true;
			}
			else {
				if(!used[nn]) continue;
				--cnt[mm];
				if(cnt[mm] == 0) {
					v[mm][sz(v[mm])-1].E = tt;
					//cout << v[mm][sz(v[mm])-1].B << ' ' << v[mm][sz(v[mm])-1].E << endl;
				}
				used[nn] = false;
			}
		}
		
		int q; cin >> q;
		rep(i, q) {
			int ts, te, mm, time;
			cin >> ts >> te >> mm;
			--mm;
			time = 0;
			rep(j, sz(v[mm])) {
				if((ts <= v[mm][j].B && v[mm][j].B <= te) ||
					(ts <= v[mm][j].E && v[mm][j].E <= te) ||
					(v[mm][j].B <= ts && te <= v[mm][j].E)
				) {
					time += (min(te, v[mm][j].E) - max(ts, v[mm][j].B));
				}
			}
			cout << time << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
N,M = map(int,input().split())
ura=0

#角
#ura += 0

#辺
if M==1 and N==1:
  ura +=1
else:
  if M*N==M or M*N==N:
    ura += max(M,N)-2
#内側
ura += max(N-2,0) *max(M-2,0)

print(ura)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
	int n;
	int i, nx, ns;
	while ( scanf( "%d", &n ) != EOF ) {
		ns = 0;
		for ( i=1; (nx = ( n * i )) < 600; i++ ) ns += nx * nx * n;
		printf( "%d\n", ns );
	}
	
	return 0;
}

Measured memory_bytes: 596
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static HashMap<Point,Integer> map = new HashMap<Point,Integer>();
	static int N,W;
	static int[] w,v;
	
//	static int count =0;
	
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);	
		N = io.nextInt();
		W = io.nextInt();
		w = new int[N+1];
		v = new int[N+1];
		
		for (int i = 0; i < N; i++) {
			w[i+1] = io.nextInt();
			v[i+1] = io.nextInt();
		}
		
//		long time1 = System.currentTimeMillis();
		System.out.println(value(N,W));
//		long time2;
//		time2 = System.currentTimeMillis();
//		System.out.println("\ntime02:"+(time2 -time1));
//		System.out.println("count:: "+count);
		
	}
	public static int value(int i,int wMax){
		Point p = new Point(i,wMax);
//		System.out.print("now i wMax: "+i+" "+wMax+" /");
		if(map.containsKey(p)){
//			System.out.println("ok!");
			return map.get(p);
		}
//		System.out.println("non");
//		count ++;
		int val;
		if(i==0){
			val = 0;
		}else if(wMax<w[i]){
			val = value(i-1,wMax);
		}else{
			val = Math.max(value(i-1,wMax),value(i-1,wMax-w[i])+v[i]);
		}
		map.put(p,val);
		return val;
	}
}

class Point{
	int i;
	int w;
	public Point(int i, int w){
		this.i = i;
		this.w = w;
 	}
	@Override
	public boolean equals(Object p){
		return (i==((Point)p).i && w==((Point)p).w);
	}
	@Override
	public int hashCode(){
		return w % 10000;
	}
}

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

using namespace std ;

#define inf 214748364700
#define N 200000
#define int long long

int tot , n , m , root , now , ans ;
int nex[2*N] , fire[N] , to[2*N] , len[2*N] ;
int siz[N] , mx[N] , dep[N] ;

void add(int u , int v , int w){
    nex[++tot] = fire[u] ;
    fire[u] = tot ;
    to[tot] = v ;
    len[tot] = w ;
    return ;
}

void getroot(int x , int fr){
    siz[x] = 1 ;
    for(int i = fire[x] ; i ; i = nex[i] ){
        int v = to[i] ;
        if( v == fr ) continue ;
        getroot( v , x ) ;
        siz[x] += siz[v] ;
        mx[x] = max( mx[x] , siz[v] ) ;
    }
    mx[x] = max( mx[x] , n - siz[x] ) ;
    if( mx[x] < mx[root] ) root = x , now = mx[root] ;
    return ;
}

void dfs(int x , int fr){
    ans += dep[x] ;
    for(int i = fire[x] ; i ; i = nex[i] ){
        int v = to[i] ;
        if( v == fr ) continue ;
        dep[v] = dep[x] + len[i] ;
        dfs( v , x ) ;
    }
    return ;
}

signed main()
{
    scanf("%lld" , &n ) ;
    for(int i = 1 ; i <= n - 1 ; i++ ){
        int u , v , w ;
        scanf("%lld%lld%lld" , &u , &v , &w ) ;
        add( u , v , w ) ; add( v , u , w ) ;
    }
    mx[0] = n ; root = 0 ;
    getroot( 1 , 0 ) ; dfs( root , 0 ) ;
    int Min = inf ; ans = ans * 2 ;
    for(int i = fire[root] ; i ; i = nex[i] ){
        Min = min( Min , len[i] ) ;
        int v = to[i] ;
        if( mx[v] == mx[root] ){ Min = len[i] ; break ; }
    }
    printf("%lld\n" , ans - Min ) ;
    return 0 ;
}

Measured memory_bytes: 17792
#include <iostream>

int main()
{
    using namespace std;
    string SA;
    cin >> SA;
    string SB;
    cin >> SB;
    string SC;
    cin >> SC;

    int nA{SA.length()};
    int nB{SB.length()};
    int nC{SC.length()};

    int curA{nA};
    int curB{nB};
    int curC{nC};
    char curPlayer{'a'};
    char winner{'N'};

    do
        {
        switch (curPlayer)
            {
            case 'a':
                if (curA > 0)
                    {
                        curPlayer = SA.at(nA - curA);
                        curA -= 1;
                    }
                else
                    winner = 'A';

                break;
            case 'b':
                if (curB > 0)
                    {
                        curPlayer = SB.at(nB - curB);
                        curB -= 1;
                    }
                else
                    winner = 'B';

                break;
            case 'c':
                if (curC > 0)
                    {
                        curPlayer = SC.at(nC - curC);
                        curC -= 1;
                    }
                else
                    winner = 'C';

                break;
            default:
                break;
            }
        }
    while (winner == 'N');

    cout << winner << endl;

    return 0;
}

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

using modint = atcoder::modint998244353;

struct S{
    modint val, unit;
};
using F = int;
const F ID = 0;
S op(S a, S b){ return {a.val+b.val, a.unit + b.unit}; }
S e(){ return {0, 0}; }
S mapping(F f, S x){
    if(f != ID) x.val = f * x.unit;
    return x;
}
F composition(F f, F g){ return (f != ID ? f : g); }
F id(){ return ID; }

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

    vector<S> init(N);
    modint pw10 = 1;
    // 右端が1の位
    for(int i=N-1; i>=0; i--){
        init[i] = {pw10, pw10};
        pw10 *= 10;
    }
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(init);
    while(Q--){
        int l, r, d;
        cin >> l >> r >> d;
        seg.apply(l-1, r, d);
        cout << seg.all_prod().val.val() << endl;
    }
}


Measured memory_bytes: 9796
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

H1, M1, H2, M2, K = getNM()
opt1 = H1 * 60 + M1
opt2 = H2 * 60 + M2
print(abs(opt2 - opt1) - K)

Measured memory_bytes: 72596
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int main() {
  int N;
  cin >> N;
  string s,t;
  cin >> s >> t;
  for(int i=0;i<N;i++){
    cout << s[i] << t[i];
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();		//数字列の長さ
		
		double ans=0;
		for(int i=0;i<n;i++) {
			double a=sc.nextDouble();
			ans+=1.0/a;
		}
		ans=1.0/ans;
		System.out.println(ans);

	}

}


Measured memory_bytes: 22484
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
	int[] elements = new int[n];
	String[] input = scan.nextLine().split(" ");
	for (int i = 0; i < n; i++) {
	    elements[i] = Integer.parseInt(input[i]);
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
	    int min = i;
	    for (int j = i; j < n; j++) {
		if (elements[j] < elements[min]) {
		    min = j;
		}
	    }
	    if (i != min) {
		cnt++;
		int tmp = elements[i];
		elements[i] = elements[min];
		elements[min] = tmp;
	    }
	}
	for (int i = 0; i < n-1; i++) {
	    System.out.print(elements[i] + " ");
	}
	System.out.println(elements[n-1]);
	System.out.println(cnt);
    }
}

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

int a;
int f,t,o;

main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(a%4==0)f++;
		else if(a%2==0)t++;
		else o++;
	}
	if(o>f)
	{
		if(t==0&&f>=1&&o==f+1)printf("Yes\n");
		else printf("No\n");
	}
	else
		printf("Yes\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x) 
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
int main()
{
    int n = read<int>(), k = read<int>(),ans = 0;
    while(n)
    {
        n = n/k;
        ans++;
    }
    write(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t L_pre = 2, L_next=1;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    int64_t L = L_next;
    L_next += L_pre;
    L_pre = L;
  }
  cout << L_pre;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cstdlib>
 
using namespace std;
 
int getTime(string s){
  int a=atoi(s.substr(0,2).c_str());
  int b=atoi(s.substr(3,2).c_str());
  return a*60+b;
}
int main(){
  int n;
  while(cin>>n&&n){
    map<string,int> ans;
    map<string,int> info;
    for(int i=0;i<n;i++){
      string s1,s2,s3,s4;
      cin>>s1>>s2>>s3>>s4;
      int time=getTime(s2);
      if(s3=="I")info[s4]=time;
      else{
    int diff=time-info[s4];
    if(s4=="000"){
      for(map<string,int>::iterator it=info.begin();
          it!=info.end();it++){
        if(it->first=="000")continue;
        int a=time-max(info["000"],(it->second));
        ans[it->first]+=a;
      }
    }
    else if(info.count("000")>0)
      ans[s4]+=(time-max(info["000"],info[s4]));
    info.erase(s4);
      }
    }
    int res=0;
    for(map<string,int>::iterator it=ans.begin();
    it!=ans.end();it++)
      res=max(res,it->second);
    cout<<res<<endl;
  }
   
  return 0;
}

Measured memory_bytes: 968
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

const int MAX = 1e5;
typedef pair<int, int> P;
typedef long long ll;
int N;
ll K;
int a, b;
P p[MAX+5];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    p[i] = P(a, b);
  }
  sort(p, p + N);
  for (int i = 0; i < N; i++) {
    if (K - p[i].second <= 0) {
      cout << p[i].first << endl;
      break;
    } else {
      K -= p[i].second;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	ll K;
	cin>>K;
	int N = 50;
	vector<ll> a(N,N-1);
	rep(i,N) a[i] += K/N;
	rep(i,K%N){
		rep(j,N){
			if(j==i) a[j] += N;
			else a[j]--;
		}
	}
	cout<<N<<endl;
	rep(i,N) cout<<a[i]<<" ";
	puts("");
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i;
ll l[101];
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	l[0]=2,l[1]=1;
	for(i=2;i<=86;i++)l[i]=l[i-1]+l[i-2];
	cout<<l[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	int a,b,c,d;
	double g;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d))
	{
		g=(double)a*(double)b/2.0;
		printf("%lf ",g);
		if(a=c*2&&b==d*2)
		printf("1\n");
		else
		printf("0\n");
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;
int main(){
  ll n;cin>>n;
  bool found=false;
  ll a, b, c;
  for(a=1;a<=3500;a++){
    for(b=a;b<=3500;b++){
      ll s=n*a*b;
      ll t=4*a*b-n*b-n*a;
      if(t<=0)continue;
      if(s%t==0){c=s/t;found=true;break;}
    }
    if(found)break;
  }
  cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	mp := make(map[int]int)
	cnt := 0
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(read, &a)
		mp[a]++
		if mp[a] >= 2 {
			cnt++
		}
	}

	if cnt == 0 {
		fmt.Fprintln(write, "YES")
	} else {
		fmt.Fprintln(write, "NO")
	}
}


Measured memory_bytes: 12800
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(q)]
ans = 0
for i in combinations_with_replacement(range(1, m + 1), n):
    cnt = 0
    for a, b, c, d in abcd:
        if i[b - 1] - i[a - 1] == c:
            cnt += d
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 9184
N, M, Q = map(int, input().split())

A = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    A[L][R] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        A[i][j] += A[i][j - 1]
for j in range(1, N + 1):
    for i in range(1, N + 1):
        A[i][j] += A[i - 1][j]

ans = []
for _ in range(Q):
    p, q = map(int, input().split())
    p -= 1
    ans.append(A[q][q] - A[q][p] - A[p][q] + A[p][p])
print(*ans, sep='\n')


Measured memory_bytes: 66520
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int m;
        scanf("%d",&m);
        for(int i=1;i<=m;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int a=sc.nextInt();
            String b = sc.next();
            int c = sc.nextInt();
            if(b.equals("?")) break;
            else if(b.equals("+")) System.out.println(a+c);
            else if(b.equals("-")) System.out.println(a-c);
            else if(b.equals("*")) System.out.println(a*c);
            else if(b.equals("/")) System.out.println(a/c);
        }
    }
}


Measured memory_bytes: 26120
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n;
  cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  cout << A.size() << endl;
}


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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	int N, M;
	cin >> N >> M;
	int sum = 0;
	rep(i,0,M){
		int a; cin >> a;
		sum+=a;
	}
	if (N< sum)
		cout << "-1\n";
	else
		cout << N-sum << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair


using namespace std;

ll gcd(ll a, ll b){
    if(a < b) return gcd(b,a);

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

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

int main(){

    //Tiの最小公倍数をとればよい、10^18を扱うのでlong long intで。

    int n;
    cin >> n;

    ll ans = 1;
    vector<ll> v;

    rep(i,n){
        ll tmp;
        cin >> tmp;
        v.pback(tmp);
    }

    sort(v.begin(), v.end());

    for(int i = n - 1; i >= 0; i--){
        ans = lcm(ans, v[i]);
        //cerr << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let s:Vec<char> = st.trim().chars().collect();
    let mut start:usize = 0;
    let mut end:usize = 1;
    let mut result: i64 = 1;
    for i in 1..(s.len()) {
        if s[start..end] == s[end..i+1] {
            continue;
        } else {
            start = end;
            end = i+1;
            result += 1;
        };
    };
    println!("{}", result);
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;


int main()
{
    int n;cin >>n;
    bool flg=true;
    rep(i,n){
        int a;cin >>a;
        if(a%2==0){
            if(a%3==0||a%5==0)continue;
            else flg=false;
        }
    }
    if(flg)puts("APPROVED");
    else puts("DENIED");
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

if sum(a)<sum(b):
 print(-1)
 exit()

c=[]
lack=0
cnt=0
for i,j in zip(a,b):
  t=i-j
  if i-j>=0:
    c.append(t)
  else:
    lack+=abs(t)
    cnt+=1

if cnt==0:
  print(0)
  exit()

c=sorted(c,reverse=True)
ru=list(accumulate(c))
for i in range(len(ru)):
  if ru[i]>=lack:
    cnt+=i+1
    break

print(cnt)

Measured memory_bytes: 19068
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef int64_t ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n, k, s;
  cin >> n >> k >> s;

  rep(i, k) {
    cout << s << " ";
  }
  int pad = 1e+9;
  if (s == 1e+9) pad = 1;
  rep(i, n-k) {
    cout << pad << " ";
  }
  cout << endl;

  // 43601 8070 4435

  return 0;
}


Measured memory_bytes: 1280
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        s: chars
    }
    
    let ans: String = std::iter::repeat('x').take(s.len()).collect();
    println!("{}", ans)
}


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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, ans = INT_MAX;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= 100; ++i) {
        int cost = 0;
        for (int j = 0; j < n; ++j) {
            cost += (i - a[j]) * (i - a[j]);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int N = 1e6 + 7;
int n, q;

string s;

int main()
{

        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);
        cin >> n;
        cin >> s;
        int w = 0, r = 0;
        for (int i = 0; i < n; i++)
        {
                if (s[i] == 'W')
                        w++;
                else
                        r++;
        }

        int W = 0 , R = 0 ; 
        for(int i = 0 ;i < r ;i++)
                W+=(s[i] == 'W') ; 
        for(int i = r ; i < n;i++)
                R+=(s[i] == 'R') ; 
        
        cout<< W + R - min(W , R) ;

        return 0;
}

Measured memory_bytes: 3728
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int f[10005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int x = 1; x*x <= n; ++x){
		for(int y = 1; x*x + y*y + x*y <= n; ++y){
			for(int z = 1; x*x + y*y + z*z + x*y + y*z + z*x <= n; ++z){
				++f[x*x + y*y + z*z + x*y + y*z + z*x];
			}
		}
	}
	for(int i = 1; i <= n; ++i) cout << f[i] << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;

const int MX = 505;
int dp[MX][MX];

int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    rep(i, MX) rep(j, MX) {
        dp[i][j] = INF;
    }
    dp[0][0] = 0;
    rep(i, n) rrep(j, MX) rrep(k, MX) {
        if (j-a[i]>=0 && k-b[i]>=0) {
            chmin(dp[j][k], dp[j-a[i]][k-b[i]] + c[i]);
        }
    }
    int ans = INF;
    int x = ma;
    int y = mb;
    while (1) {
        chmin(ans, dp[x][y]);
        x += ma;
        y += mb;
        if (x>=MX || y>=MX) break;
    }
    if (ans==INF) ans = -1;
    
    cout << ans << endl;
    return 0;
}


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

int n;
string str[2];
string s[4] = {"lu","ru","ld","rd"};

int main(){
	while(scanf("%d",&n),n){
		int ans = 0;
		for(int i = 1; i < n; i += 2){
			cin >> str[0] >> str[1];
			if((str[0]==s[0]&&str[1]==s[1])||(str[0]==s[1]&&str[1]==s[0])||(str[0]==s[2]&&str[1]==s[3])||(str[0]==s[3]&&str[1]==s[2])) ans++;
		}
		if(n%2==1) cin >> str[0];
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1248
#include <stdio.h>

int main()
{
    int N;
    int K;
    char S[50+1];

    scanf("%d %d", &N, &K);
    scanf("%s", S);

    S[K-1] = S[K-1] - 'A' + 'a';

    printf("%s\n", S);

    return 0;
}


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

int main(){
  string s,c="TBD";
  for(int i=0;i<10;i++){
    char a;
    cin >> a;
    if(a!='/')
      s += a;
  }  
  if(stoi(s) <= 20190430)
    c = "Heisei";
  cout << c << endl;
}

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

int main() {
  char a;
  cin >> a;
  if (a=='a'||a=='i'||a=='u'||a=='e'||a=='o')
    cout << "vowel"<<endl;
  else
    cout << "consonant"<<endl;
  return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
q = []
heapq.heapify(q)
heapq.heapify(ab)
total = 0
for i in range(m, -1, -1):
    while True:
        if len(ab) != 0:
            p = heapq.heappop(ab)
            if p[0] + i <= m:
                heapq.heappush(q, -p[1])
            else:
                heapq.heappush(ab, p)
                break
        else:
            break
    if len(q) != 0:
        p = heapq.heappop(q)
        total += -p
print(total)

Measured memory_bytes: 27884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

struct UnionFindTree {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        siz.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        siz[x] += siz[y];
    }
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        x = find(x);
        return siz[x];
    }
};

int main() {
    ll n, m;
    cin >> n >> m;
    vector<P> es;
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        es.push_back({a,b});
    }
    UnionFindTree g;
    g.init(n);
    vector<ll> ans(m);
    ll cnt = n*(n-1)/2;
    for(int i=m-1; i>=0; i--){
        ans[i] = cnt;
        int a = es[i].first, b = es[i].second;
        if(g.is_same(a,b)) continue;
        cnt -= ll(g.size(a)) * ll(g.size(b));
        g.unite(a,b);
    }
    for(int i=0; i<m; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4084
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A.sort()
i = 1
cnt = 1
ans = 0
while True:
    if i >= len(A):
        break
    if A[i] == A[i - 1]:
        cnt += 1
    else:
        if cnt % 2 != 0:
            ans += 1
        cnt = 1
    i += 1
if cnt % 2 != 0:
    ans += 1
print(ans)


Measured memory_bytes: 7388
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
const int maxn=200022;
LL n,a[maxn],b[maxn],c[maxn];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=n;++i)
	{
		b[i]=a[i]+i;
		c[i]=i-a[i];
	}
	sort(b+1,b+1+n);
	sort(c+1,c+1+n);
	LL co=1;
	LL asd=0;
	b[n+1]=-1;
	for(int i=2;i<=n+1;++i)
	{
		if(b[i]!=b[i-1])
		{
			LL k=upper_bound(c+1,c+1+n,b[i-1])-lower_bound(c+1,c+1+n,b[i-1]);
			asd+=co*k;
			co=1;
		}
		else co++;
	}
	printf("%lld\n",asd);
}

Measured memory_bytes: 8396
M = 15
T = 8


def main():
    win_table = [c == "o" for c in input()]
    k = len(win_table)
    num_win = sum(win_table) + (M - k)
    if num_win >= T:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int x; cin>>x; bool ans=false;
  while(x>0) ans|=(x%10==9),x/=10;
  Yn(ans);
}













Measured memory_bytes: 256