akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
ll n,q,a[100100],b[100100],x,tmp,ans,l,r,all;
const ll M=1000000000;
 
struct nodes
{
	ll p,p2;
	nodes *l,*r;
	nodes():p(0),p2(0),l(0),r(0){}
};
nodes *head;
 
void fix(nodes *&o,ll l,ll r,ll x)
{
	ll m=l+r>>1;
	o->p++,o->p2+=x;
	if(l==r)
		return;
	if(x<=m)
	{
		if(!o->l)
			o->l=new nodes();
		fix(o->l,l,m,x);
	}
	else
	{
		if(!o->r)
			o->r=new nodes();
		fix(o->r,m+1,r,x);
	}
}
 
int search(nodes *o,ll l,ll r,ll tl,ll tr)
{
	if(l<=tl&&tr<=r)
		return o->p;
	ll m=tl+tr>>1,re=0;
	if(l<=m&&o->l)
		re+=search(o->l,l,r,tl,m);
	if(m+1<=r&&o->r)
		re+=search(o->r,l,r,m+1,tr);
	return re;
}
 
ll search2(nodes *o,ll l,ll r,ll tl,ll tr)
{
	if(l<=tl&&tr<=r)
		return o->p2;
	ll m=tl+tr>>1,re=0;
	if(l<=m&&o->l)
		re+=search2(o->l,l,r,tl,m);
	if(m+1<=r&&o->r)
		re+=search2(o->r,l,r,m+1,tr);
	return re;
}
 
ll f1(ll x)
{
	ll l=0,r=M-x-1,m;
	while(l!=r)
	{
		m=l+r>>1;
		if(search(head,max(0LL,x-m),x+m,1,M)+1<search(head,x+m+1,M,1,M))
			l=m+1;
		else
			r=m;
	}
	return l;
}
 
ll f2(ll x)
{
	ll l=0,r=n+1,m;
	while(l!=r)
	{
		m=l+r>>1;
		if(a[m]<x)
			l=m+1;
		else
			r=m;
	}
	return l;
}
 
int main()
{Tie
	head=new nodes();
	cin>>n>>q,a[n+1]=2000000000;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i],fix(head,1,M,a[i]),b[i]=a[i],all+=a[i];
		if(i>1)
			b[i]+=b[i-2];
	}
	for(int i=0;i<q;i++)
	{
		cin>>x;
		tmp=f1(x);
		l=search(head,x-tmp,x+tmp,1,M);
		if(x+tmp+1>1000000000)r=0;
		else r=search(head,x+tmp+1,M,1,M);
		ans=0;
		if(l==r)
		{
			ans=search2(head,x-tmp,x+tmp,1,M);
			if(a[1]<x-tmp)
			{
				tmp=f2(x-tmp)-2;
				if(tmp>=0)
					ans+=b[tmp];
			}
		}
		else if(l+1==r)
		{
			ans=search2(head,x-tmp,x+tmp,1,M);
			if(a[1]<x-tmp)
			{
				tmp=f2(x-tmp)-1;
				if(tmp>=0)
					ans+=b[tmp];
			}
		}
		else if(l==r+1)
		{
			ans=search2(head,x-tmp,x+tmp,1,M);
			ans-=a[f2(x+tmp+1)-1];
			if(a[1]<x-tmp)
			{
				tmp=f2(x-tmp)-1;
				if(tmp>=0)
					ans+=b[tmp];
			}
		}
		cout << all-ans<<'\n';
	}
}

Measured memory_bytes: 69376
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	string s;
	cin>>s;
	if(s.size()==3){
		reverse(s.begin(),s.end());
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  cin>>e;
  cin>>k;
  if(e-a<=k) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
  return 0;
}

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

typedef long long ll;
typedef pair<ll,int> pli;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)

int main() {
	int N; cin >> N;
	vector<int> A(N); rep(i,N) cin >> A[i];
	ll tmp = 0, gl = 0;
	rep(i,N) {
		tmp *= 10;
		tmp += A[i]-1;
		gl *= 10;
		gl += i;
	}
	vector<pli> candidate[2];
	rep(a,2) {
		queue<pli> q;
		q.push(pli(!a ? tmp : gl, 0));
		unordered_set<ll> used;
		used.insert(q.front().first);
		while(q.size()) {
			candidate[a].push_back(q.front());
			ll t = q.front().first;
			ll turn = q.front().second; q.pop();
			if(turn > 4) break;
			vector<int> v(N);
			rrep(i,N) {
				v[i] = t % 10;
				t /= 10;
			}
			rep(i,N) {
				for(int j = i+1; j < N; j++) {
					vector<int> vv = v;
					ll nx = 0;
					reverse(vv.begin()+i, vv.begin()+j+1);
					rep(i,N) {
						nx *= 10;
						nx += vv[i];
					}
					if(used.find(nx) == used.end()) {
						used.insert(nx);
						q.push(pli(nx,turn+1));
					}
				}
			}
		}
		sort(candidate[a].begin(), candidate[a].end());
	}
	int res = 9;
	rep(i,candidate[0].size()) {
		int indx;
		indx = lower_bound(candidate[1].begin(), candidate[1].end(), candidate[0][i])
			- candidate[1].begin();
		if(candidate[0][i].first == candidate[1][indx].first) {
			res = min(res, candidate[0][i].second+candidate[1][indx].second);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 84492
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;

	int a[6];

	int flag;

	for(i=1;i<=5;i++)
	{
		cin>>a[i];
		if(a[i]!=i)
		{
			flag=i;
		}
	}
	cout<<flag<<endl;
	

}

Measured memory_bytes: 3536
#include <cstdio>
const int MAXN = 55;
char S[MAXN];
int N;

int main() {
  scanf(" %d%s", &N, S);
  int ret = 0;
  bool A = false;
  bool B = false;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'A') {
      A = true;
      B = false;
    } else if (S[i] == 'B') {
      B = A;
      A = false;
    } else if (S[i] == 'C') {
      if (B) ++ret;
      A = B = false;
    }
  }
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
typedef struct mode{
  int i;
  int num;
}m;

int main(){
  m mode[100] ,temp;
  int i ,j=0 ,k ,n ,cnt=0 ,tmp;

  for( i=0 ; i<100 ; i++ ){
    mode[i].num = 0;
  }

  while( scanf( "%d",&n) != EOF ){     // 数字のでた回数
    mode[n].num++;
    cnt++;
  }

  for( j=1 ; j<=100 ; j++ ){           // でた数字
    mode[j].i = j;
  }

  for( j=0 ;j<cnt-1 ; j++ ){           // でた回数が多い順にソート　（最頻値）
    for( k=cnt ; k>j ; k-- ){
      if( mode[k].num > mode[k-1].num ){
	temp = mode[k];
	mode[k] = mode[k-1];
	mode[k-1] = temp;
      }
    }
  }

  j=0;
  k=1;
  
  while( mode[j].num == mode[j+1].num ){
    if( mode[j].i > mode[j+1].i ){
      tmp = mode[j].i;
      mode[j].i = mode[j+1].i;
      mode[j+1].i = tmp;
    }
    j++;
    k++;
  }

  for( j=0 ; j<k ; j++ ){
    printf( "%d\n",mode[j].i );
  }

  return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
int in() {
	int n = 0, c = gcu();
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
//void scan(string &s) {for (char c; !isspace(c = gcu()); s += c);}
bool scan(int &n) {int c=gcu();if(c==EOF)return false;ungetc(c,stdin);n=in();return true;}
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int main() {
	int a;
	while (scan(a))
		out(a + in(), '\n');
}


Measured memory_bytes: 2396
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>
#define chmin(x, y) x = min(x, y);

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;
const int INF = 1001001001;


int main(){
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int> > dist(n, vector<int>(n, INF));
    rep(i, n) dist[i][i] = 0;
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = dist[b][a] = c;
    }
    rep(k, n)rep(i, n)rep(j, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);
    vector<vector<int> > dist2(n, vector<int>(n, INF));
    rep(i, n)rep(j, n){
        if(dist[i][j] <= l) dist2[i][j] = 1;
    }
    rep(k, n)rep(i, n)rep(j, n) chmin(dist2[i][j], dist2[i][k] + dist2[k][j]);
    
    int q;
    cin >> q;
    int ans[q];
    rep(i, q){
        int s, t;
        cin >> s >> t;
        s--; t--;
        ans[i] = dist2[s][t] - 1;
        if(dist2[s][t] == INF) ans[i] = -1;
    }
    rep(i, q) cout << ans[i] << endl;

}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N, L;
    cin >> N >> L;
    vi A(N);
    rep(i, N) cin >> A[i];

    bool ok = false;
    int tp = 0;
    stack<int> st;
    rep(i, N-1) {
        if(A[i]>=L || A[i]+A[i+1]>=L) {
            ok = true;
            st.push(i+1);
            tp = i+1;
            break;
        }
    }
    if(!ok) {
        cout << "Impossible" << endl;
        return 0;
    } else cout << "Possible" << endl;

    for(int i=tp-1; i>=1; i--) {
        st.push(i);
    }
    for(int i=tp+1; i<=N-1; i++) {
        st.push(i);
    }

    while(!st.empty()) {
        cout << st.top() << endl;
        st.pop();
    }

    return 0;
}

Measured memory_bytes: 2212
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

int Cal(int x, int y)
{
	if(!y) return -x;
	int z = x % y;
	return Cal(y ,z) + (x / y) * 2 * y;
}

signed main()
{
	int n = read(), x = read();
	if(x > n - x) x = n - x;
	int ans = n + Cal(n - x, x);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#define T 10000
#define inf 0x7fffffff
using namespace std;
#define int long long
const int mod=998244353;
int dp[3005][3005];
signed main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	dp[a][b]=1;
	for(int i=a; i<=c; i++)
		for(int j=b; j<=d; j++)
		{
			if(i==a&&j==b)
				continue;
			else
				dp[i][j]=(dp[i-1][j]*j%mod+dp[i][j-1]*i%mod-(i-1)*(j-1)*dp[i-1][j-1]%mod+mod)%mod;
		}
	cout<<dp[c][d]<<endl;
	return 0;
}


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

int main() {
    vector<char> ans;
    string s;
    cin >> s;
    for (int i  = 0; i < s.length(); i++){
        if (s[i] == '0' || s[i] == '1'){
            ans.push_back(s[i]);
        }
        else if (ans.size() > 0){
            ans.pop_back();
        }
    }
    for (int i = 0; i < ans.size(); i++){
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {

	var n int
	fmt.Scan(&n)

	a := make([]int64, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	nn := 0
	m := int64(math.MaxInt64)
	var ret int64
	for _, k := range a {
		if k < 0 {
			nn++
		}
		aba := abs(k)
		m = min(m, aba)
		ret += aba
	}

	if nn%2 == 1 {
		ret -= 2 * m
	}
	fmt.Println(ret)
}

func abs(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}

func min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int numR;
		int numC;
		int add = 0;

		String outPut = "";

		int[][] tableList;

		Scanner sc = null;

		try {
			//??\????????????
			sc = new Scanner(System.in);

			numR = sc.nextInt();
			numC = sc.nextInt();

			//???????????°??¨
			//System.out.println(numR + " " + numC);

			//??¨??????????????£?¨?
			tableList = new int[numR + 1][numC + 1];

				//??¨?????\??????????????????
				for (int i = 0; i < numR; i++) {

					for (int j = 0; j < numC; j++) {
						tableList[i][j] = sc.nextInt();
						add += tableList[i][j];
					}
					//??????????¨???????????´?
					tableList[i][numC] =add;

					//??????????¨???????????´?
					for (int k = 0; k < tableList[0].length; k++) {
						tableList[numR][k] += tableList[i][k];
					}
					//????¨???????????????????
					add = 0;
				}

				//??¨?????????
				for (int i = 0; i < tableList.length; i++) {
					for (int j = 0; j < tableList[0].length; j++) {

						if (!outPut.equals("")) {
							outPut += " ";
						}
						outPut += tableList[i][j];

					}
					System.out.println(outPut);
					outPut = "";
				}

			}finally {
				sc.close();
			}
	}

}

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

using namespace std;

int main()
{
	int n,k;

	while (1) {
		cin >> n >> k;

		if (n == 0 && k == 0 ){
			break;
		} // end if

		vector <int> a (n + 1, 0 );
		int res = 0, s = 0;

		for (int i = 1; i <= n; ++i){
			cin >> a[i];
			if (i < k ){
				s += a[i];
			}else if (i == k ){
				s += a[i];
				res = s;
			}else{ // if (i > k ){
				s -= a[i-k];
				s += a[i];
				res = max (res , s );
			} // end if				
		} // end for

		cout << res << endl;
	} // end loop
		
	return 0;
}

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

using namespace std;

int n;
const int mod = 1e9+7;
vector<vector<int> > tb;
vector<vector<int> > dp;


int solve(int i, int mask){
	if(i==n) return mask == (1<<n)-1;
	if(dp[i][mask]!=-1) return dp[i][mask];
	int c = 0;
	for(int j = 0; j < n; j++){
		if(tb[i][j] && !(mask & (1 << j) )){
			c+=solve(i+1,mask | (1<<j));
			c%=mod;
		}
	}
	return dp[i][mask] = c;
}


int main(){
	cin >> n;
	tb = vector<vector<int>>(n,vector<int>(n));
	dp = vector<vector<int>>(n+1,vector<int>(1<<n,-1));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> tb[i][j];
	cout << solve(0,0);				
	return 0;
}


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

using namespace std;

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

	vector <int> a (n);

	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}

	long long ans = 0;

	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			ans += a[i] * a[j];
		}
	}

	printf("%lld\n", ans);


	return 0;

}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
    for (;;) {
        int r, c, q;

        scanf("%d %d %d", &r, &c, &q);
        if (r == 0 && c == 0 && q == 0)
            break;

        int a[50000], b[50000], o[50000];
        for (int i = 0; i < q; ++i)
            scanf("%d %d %d", &a[i], &b[i], &o[i]);

        int e = 0, nr = r, nc = c;
        bool f[2][50000] = {};
        for (int i = q - 1; i >= 0; --i) {
            if (!f[a[i]][b[i]]) {
                f[a[i]][b[i]] = true;

                if (a[i] == 0) {
                    --nr;
                    if (o[i] == 1)
                        e += nc;
                } else {
                    --nc;
                    if (o[i] == 1)
                        e += nr;
                }
            }
        }

        printf("%d\n", e);
    }

    return 0;
}

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

int main(){
    //FILE *inp = freopen("in.txt", "r", stdin);
    int n, q;
    cin>>n;
    long arr[n];
    for(int i = 0; i < n; ++i) cin>>arr[i];
    cin>>q;
    long query[q];
    for(int i = 0; i < q; ++i) cin>>query[i];
    int cnt = 0;
    for(int i = 0; i < q; ++i){
        for(int j = 0; j < n; ++j){
            if(arr[j]==query[i]){
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
    //fclose(inp);
    return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;
	vector<int> a(n);
	vector<long long> summ(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			summ[i] = a[i];
		}
		else {
			summ[i] = summ[i - 1] + a[i];
		}
	}

	int counter = 1;

	for (int i = n - 2; i >= 0; i--) {
		if (summ[i]*2 >= a[i + 1]) {
			counter++;
		}
		else {
			break;
		}
	}
	cout << counter << endl;

	return 0;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long 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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int mod = 998244353;

int main(){
    int N; cin >> N;
    vector<int> a(N);
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        sum += a[i];
    }

    vector<vector<ll>> dp(N, vector<ll>(sum+1, 0));
    vector<vector<ll>> dp2(N, vector<ll>(sum+1, 0));

    // 初期化
    dp[0][a[0]] = 1;
    dp[0][0] = 2;

    // 配るdp：dp[i][A]がdp[i+1][?]に貢献する値を配っていく
    for(int i=0; i<N-1; i++){
        for(int A=0; A<=sum; A++){
            if(dp[i][A] == 0) continue;

            // i+1番目をAに入れないなら、BかCに入れるかの２通りがある
            dp[i+1][A] += 2*dp[i][A];
            dp[i+1][A] %= mod;
            // i+1番目をAに入れるなら、１通り
            dp[i+1][A+a[i+1]] += dp[i][A];
            dp[i+1][A+a[i+1]] %= mod;
        }
    }

    // printf("  |");
    // for(int i=0; i<N; i++) printf("%4d|", i);
    // cout << endl;
    // for(int A=0; A<=sum; A++){
    //     printf("---");
    //     for(int i=0; i<N; i++) printf("-----");
    //     printf("\n");
    //     printf("%2d|", A);
    //     for(int i=0; i<N; i++) printf("%4lld|", dp[i][A]);
    //     cout << endl;
    // }

    ll sub1 = 0;
    for(int A=((sum-1)/2+1); A<=sum; A++){
        sub1 += dp[N-1][A];
        sub1 %= mod;
    }
    sub1 = sub1*3%mod;
    //cout << sub1 << endl;


    // 初期化
    dp2[0][a[0]] = 1;
    dp2[0][0] = 1;

    // 同様にやっていく
    for(int i=0; i<N-1; i++){
        for(int A=0; A<=sum; A++){
            if(dp[i][A] == 0) continue;

            // Aに入れない場合はBに入れるので１通り
            dp2[i+1][A] += dp2[i][A];
            dp2[i+1][A] %= mod;

            dp2[i+1][A+a[i+1]] += dp2[i][A];
            dp2[i+1][A+a[i+1]] %= mod;
        }
    }

    // printf("  |");
    // for(int i=0; i<N; i++) printf("%4d|", i);
    // cout << endl;
    // for(int A=0; A<=sum; A++){
    //     printf("---");
    //     for(int i=0; i<N; i++) printf("-----");
    //     printf("\n");
    //     printf("%2d|", A);
    //     for(int i=0; i<N; i++) printf("%4lld|", dp2[i][A]);
    //     cout << endl;
    // }

    ll sub2;
    if(sum%2 == 1) sub2 = 0;
    else sub2 = dp2[N-1][sum/2];

    sub2 = 3*sub2%mod;
    //cout << sub2 << endl;

    ll ans = 1LL;
    for(int i=0; i<N; i++) ans = ans*3%mod;
    //cout << ans << endl;

    ans -= sub1;
    if(ans < 0){
        ans += mod;
        ans %= mod;
    }
    ans += sub2;
    ans %= mod;

    cout << ans << endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(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 sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

vector<pair<int, int>> edge[100000];
ll dist[100000];

void dfs(int cur, int prev) {
  rep (i, edge[cur].size()) {
    if (edge[cur][i].F == prev) continue;
    dist[edge[cur][i].F] = dist[cur] + edge[cur][i].S;
    dfs(edge[cur][i].F, cur);
  }
}

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

  rep (i, N - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[a - 1].eb(mp(b - 1, c));
    edge[b - 1].eb(mp(a - 1, c));
  }

  int Q, K;
  cin >> Q >> K;

  dfs(K - 1, K - 1);

  rep (i, Q) {
    int x, y;
    cin >> x >> y;
    cout << dist[x - 1] + dist[y - 1] << endl;
  }
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
long long enum_divisors(int N) {
    long long res=0;
    for (int i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res++;
            if(N/i!=i)res++;
        }
    }
    return res;
}
int main(){
  int n;
  cin>>n;
  long long ans=0;
  for(int i=1;i<=n;i++){
    long long p=enum_divisors(n-i);
    ans+=p;
  }
  cout<<ans<<endl;
  return 0;
}
  

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

int main() {
    string a;
    cin >> a;
  if(a=="Sunny"){
  cout << "Cloudy";
  }
  if (a=="Cloudy"){
  cout << "Rainy";
  }
  if (a=="Rainy"){
  cout << "Sunny";
  }
  
  
}

Measured memory_bytes: 256
N, D, A = map(int, input().split())
X = [0] * N
for i in range(N):
    x, h = map(int, input().split())
    X[i] = (x, h)
X = sorted(X)

from collections import deque

q = deque()

ans = 0
total = 0
for i in range(N):
    x, h = X[i]
    while (len(q) > 0 and q[0][0] < x):
        total -= q[0][1] 
        q.popleft()
    h -= total
    if h > 0:
        num = (h + A - 1) // A
        ans += num
        damage = num * A
        total += damage
        q.append((x + 2 * D, damage))
print(ans)

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

signed main() {
    int n;
    cin >> n;

    vector<pair<double,double>> v(n);
    rep(i,n){
        cin >> v[i].first >> v[i].second;
    }

    double sum = 0;
    vector<int> a(n);
    for(int i = 0; i < n; i++) a[i] = i;

    do {
        for(int i = 1; i < n; i++){
            double x = abs(v[a[i]].first - v[a[i-1]].first);
            double y = abs(v[a[i]].second - v[a[i-1]].second);
            double d = sqrt(x * x + y * y);
            sum += d;
        }
    } while(next_permutation(a.begin(),a.end()));
    double div = 1;
    for(double i = 1; i <= n; i++) div *= i;

    cout << fixed << setprecision(10) << sum / div << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second 

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

// End of template code!
int main() 
{
    buff();
    int n; string s;
    cin >> n >> s;
    vector<int> arr;
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'R') arr.push_back(0);
        else if(s[i] == 'G') arr.push_back(1);
        else arr.push_back(2);
    }
    
    vector<int> accumulate_right(n, 0);
    for(int i = 1; i < n; ++i) accumulate_right[arr[i]]++;
    
    long long ans = 0;
    for(int j = 1; j < n; ++j) {
        accumulate_right[ arr[j] ]--;
        // agora vamos olhar todas as posicoes antes
        for(int i = 0; i < j; ++i) {
            if( arr[i] != arr[j] ) {
                // entao podemos fazer algum estrago!
                int inc = 0;
                rep(x, 0, 3) if(x != arr[i] && x != arr[j]) inc += accumulate_right[x];
                int dist = (j - i);
                if( j + dist < n ) {
                    if(arr[j + dist] != arr[i] && arr[j + dist] != arr[j]) inc--;
                }
                ans += inc;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3668
import math
N,H = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
maxa = max(A)
B.sort(reverse=True)
c = 0
for c in range(N):
    if B[c] >= maxa:
        H-=B[c]
        if H <= 0:
            c+=1
            break
        elif c == N-1:
            c+=1
    else:
        break
if H <= 0:
    print(c)
else:
    c+=math.ceil(H/maxa)
    print(c)

Measured memory_bytes: 11264
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
int main(){
    int N, K, min = 0, t=0;
    bool answer = true;
    cin >> N >> K;
    vector<char> D(K);
    for(int i = 0; i < K; i++){
        cin >> D[i];
    }
    for(int i = N; i < 1000000; i++){
        answer = true;
        for(int j = 0; j < to_string(i).size(); j++){
            for(int l = 0; l < K;l++){
                if(to_string(i).at(j) == D[l]){answer = false;}
            }
        }
        if(answer == true){
                min = i;
                break;
        }
    }
    cout << min << endl;
}

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

using namespace std;
#define ll long long
#define stuff ios::sync_with_stdio(0);cin.tie(0)
#define INF 1e9+5


int main()
{
    ll n;
    cin>>n;
    ll a[n][3],dp[n][3]={{-1,-1,-1}};

    /*for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
            cout<<dp[i][j]<<" ";
        cout<<"\n";
    }*/

    for(ll i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];

    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];

    for(ll i=1;i<n;i++)
    {
        for(ll j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
            }
            else if(j==1)
            {
                dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
            }
            else if(j==2)
            {
                dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
            }
        }
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";


    return 0;
}


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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

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

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a = b; return true;} return false; }


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

    const int W = 5;

    while(true)
    {
        int H; cin >> H;
        if(H == 0) break;
        vector<vi> block(H, vi(W)); REP(i, H) REP(j, W) cin >> block[i][j];

        int score = 0;
        bool update = true;

        while(update)
        {
            update = false;
            // blockを消す
            REP(i, H)
            {
                int count = 0, mc = 0, index = 0;
                REP(j, W)
                {
                    if(j > 0 && block[i][j] != block[i][j-1]) count = 0;
                    if(block[i][j] != -1) count++;
                    if(chmax(mc, count)) index = j;
                }
                if(mc >= 3)
                {
                    update = true;
                    score += mc * block[i][index];
                    for(int j = index-mc+1; j <= index; j++)
                    {
                        block[i][j] = -1;
                    }
                }
            }

            // blockを移動
            REP(j, W)
            {
                int k = H-1;
                while(k >= 0 && block[k][j] > 0) k--;
                if(k > 0)
                {
                    for(int n = k-1; n >= 0; n--)
                    {
                        if(block[n][j] > 0)
                        {
                            swap(block[k][j], block[n][j]);
                            k--;
                        }
                        if(k < 0) break;
                    }
                }
            }

            /*
            cout << endl;
            REP(i, H)
            {
                REP(j, W) cout << block[i][j] << " ";
                cout << endl;
            }
            cout << endl;
            */
        }
        cout << score << endl;
    }
}
    


Measured memory_bytes: 3032
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
#define fe(i, start, end) for (lli i = start; i <= end; ++i)
#define L(T)  \
    lli T;    \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
int dp[3007][3007];
int main()
{
    // cout<<"OP";
    FASTIO
    //   L(T)
    lli l1, l2;
    char a[3007], b[3007];
    cin >> a >> b;
    l1 = strlen(a);
    l2 = strlen(b);
    memset(dp, 0, sizeof(dp));
    fe(i, 1, l1)
    {
        fe(j, 1, l2)
        {
            if (a[i - 1] == b[j - 1])
            {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            }
            else
            {
                dp[i][j] = max(dp[i][j], dp[i][j - 1]);
                dp[i][j] = max(dp[i - 1][j], dp[i][j]);
            }
        }
    }
    // fw(i, 1, l1 + 1)
    // {
    //     fw(j, 1, l2 + 1)
    //     {
    //         cout << dp[i][j] << " ";
    //         // cout << "\n";
    //     }
    //     cout << "\n";
    // }

    lli i = l1 - 1;
    lli j = l2 - 1;
    string res = "";
    // res += a[2];
    while (i != -1 && j != -1)
    {
        if (a[i] == b[j])
        {
            res += a[i];
            i--;
            j--;
        }
        else
        {
            if (dp[i + 1][j + 1] == dp[i][j + 1])
                i--;
            if (dp[i + 1][j + 1] == dp[i + 1][j])
            {
                j--;
            }
        }
    }

    reverse(res.begin(), res.end());
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N , w , x , y , z;
    cin >> N;
    z = N % 10;
    y = (N % 100 - z) / 10;
    x = (N % 1000 - (y * 10) - z) / 100;
    w = (N - z - (y * 10) - (x * 100)) / 1000;
    if(x == y && w == y){
        cout << "Yes" << endl;
    }
    else if(x == y && z == y){
      cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int a; cin >> a;
	string s; cin >> s;

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}

	return 0;
}


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

#define SIZE 200001

using namespace std;

int main() {
    long  long int i,j,k,M,K,Q;
    long  long int X,N,T,Y,Z,nb,deb,fin,mil;
    long  long int A[SIZE],B[SIZE],B2[SIZE];
    long long int T_B,maxi,borne;
    long encore;

    cin >> N >> M >> K;
    for (i=0;i<N;i++)
      cin >> A[i];
      for (i=0;i<M;i++)
        cin >> B[i];

    if (B[0] <= K) {
      B2[0] = B[0];
      T_B = 1;
      encore = 1;
      for (i=1;(i<M) && encore;i++) {
        B2[i] = B2[i-1]+B[i];
        if (B2[i] <= K)
          T_B++;
        else encore =0;
      }
    }
    else {
      T_B = 0;
    }

    maxi = T_B;
    borne = K;
    fin = T_B-1;

    encore = 1;
    for (i=0;(i<N) && encore;i++) {
      borne -= A[i];
      // nombre(A) = i+1
      if (borne < 0)
        encore = 0;
      else {
        // on cherche j tel que B2[deb] <= borne < B2[fin]
        if (B2[0] > borne) {
          fin = 0;
          if ((i+1) > maxi)
            maxi = i+1;
        }
        else if (B2[fin] <= borne) {
          if ((i+fin+2) > maxi)
            maxi = i+fin+2;
        }
        else {
          deb = 0; // B2[deb] <= borne < B2[fin]
          while ((fin-deb) > 1) {
            mil = (fin+deb)/2;
            if (B2[mil] <= borne)
              deb = mil;
            else
              fin = mil;
          }
          if ((i+deb+2) > maxi)
            maxi = i+deb+2;
        }
      }
    }

     cout << maxi << endl;

  return 0;

}


Measured memory_bytes: 8244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S,T;
  cin >> S >> T;
  int ans = S.size();
  for (int i = 0; i < (int)S.size(); i++) {
    if (S[i] == T[i]) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    int N;  cin>>N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }

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

    for (int i = 0; i < N-1; ++i) {
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        String s = scanner.next();
        char[] c = s.toCharArray();

        int red = 0;
        for (int i = 0; i < N; i++) {
            if (c[i] == 'R') red++;
        }

        int answer = 0;
        for (int i = 0; i < red; i++){
            if (c[i] == 'W') answer++;
        }

        System.out.println(answer);
    }

}


Measured memory_bytes: 41148
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	string s;
	cin >> s;
	cout << s[0] << (s.size() - 2) << s[s.size() - 1];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<int> a(N+1);
    REP(i, N) cin >> a[i+1];

    // 1から始まる最大単調増加列を求める
    vector<int> dp(N + 1, 0); // dp[i]: i番目まで見たときの最後の要素
    FOR(i, 1, N)
        if(dp[i-1] + 1 == a[i])
            dp[i] = a[i];
        else
        {
            dp[i] = dp[i-1];
        }
    if(dp[N] == 0) {
        cout << -1 << endl;
    } else {
        cout << N - dp[N] << endl;
    }
    return 0;
}

Measured memory_bytes: 4684
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;
bool sr(ll a, ll b)
{
	return a > b;
}
bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(ll n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n), b(n), dis(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	ll x = 0, y = 0; //x->a,y->b
	rep(i, n)
	{
		dis[i] = b[i] - a[i];
		
		if (dis[i] < 0)
		{
			y += -dis[i];
		}
		else
		{
			if (dis[i] % 2 != 0)
			{
				dis[i]++;
				y++;
			}
			x += dis[i] / 2;
		}
	}
	//	cout << x << " " << y << endl;
	if (x - y >= 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 512
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;

void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}

const int N=1e6+3,M=1e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;

int n,a,b,c;

int& get(char cc){
    if (cc == 'A')
        return a;
    else if (cc == 'B')
        return b;
    else
        return c;
}

vector<int> nxt[3];

int main(){
    //IO();
    cin >> n >> a >> b >> c;
    int zeros = (a == 0) + (b == 0) + (c == 0);
    vector<char> v;
    vector<string> ss(n);
    for(int i = 0 ; i < n ; i++){
        cin >> ss[i];
        nxt[ss[i][0] - 'A'].push_back(i);
        nxt[ss[i][1] - 'A'].push_back(i);
    }
    for(int i = 0 ; i < n ; i++){
        string& s = ss[i];
        int& x = get(s[0]);
        int& y = get(s[1]);
        if (!x){
            x++;
            y--;
            v.push_back(s[0]);
        }
        else if (!y){
            y++;
            x--;
            v.push_back(s[1]);
        }
        else if (x > 1 || y > 1){
            if (x < y){
                x++;
                y--;
                v.push_back(s[0]);
            }
            else{
                x--;
                y++;
                v.push_back(s[1]);
            }
        }
        else{
            int p = s[0] - 'A';
            int nxt_x = upper_bound(nxt[p].begin(),nxt[p].end(),i) - nxt[p].begin();
            if (nxt_x == sz(nxt[p]))
                nxt_x = 1e9;
            else
                nxt_x = nxt[p][nxt_x];
            p = s[1] - 'A';
            int nxt_y = upper_bound(nxt[p].begin(),nxt[p].end(),i) - nxt[p].begin();
            if (nxt_y == sz(nxt[p]))
                nxt_y = 1e9;
            else
                nxt_y = nxt[p][nxt_y];
            if (nxt_x < nxt_y){
                x++;
                y--;
                v.push_back(s[0]);
            }
            else{
                x--;
                y++;
                v.push_back(s[1]);
            }
        }
        if (a < 0 || b < 0 || c < 0){
            assert(zeros >= 2);
            return !printf("No\n");
        }
    }
    printf("Yes\n");
    for(auto c : v)
        printf("%c\n",c);
}


Measured memory_bytes: 7768
#include<iostream>
#include<math.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;

int a[N];

int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double ans = a*a+b*b;
	double k = fabs(m*6-(h*30+m/2));
	double t = min(360-k,k);
	ans = ans -2*a*b*cos(t*M_PI/180);
	printf("%.11lf\n",sqrt(ans));
	return 0;
}


Measured memory_bytes: 4224
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int i;
	cin>>i;
	if(i<1200)cout<<"ABC";
	else cout<<"ARC";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

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

    vector<int> ing;
    
    for(int i=0;i<n;++i){
        int v;
        cin >> v;
        ing.push_back(v);
    }

    sort(ing.begin(), ing.end());
    
    double res;
    res = ing[0];
    for(int i=1; i < n; ++i){
        res += ing[i];
        res = res/2.0;
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int i,n;
  double s[1000],m,a,b,c;
  while(1){
	scanf("%d",&n);
	if(n==0)break;
	for(i=0;i<n;i++){
  		scanf("%lf",&s[i]);
  		b+=s[i];
  	}
 	 m=b/n;
 	 b=0;
  	for(i=0;i<n;i++){
		c+=pow(s[i]-m,2);
	}
  	a=sqrt(c/n);
  	c=0;
  	printf("%lf\n",a);
  
  }
  return 0; 
}



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

int main() {
    string S;
    int K;

    cin >> K >> S;

    if(S.size()<=K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
    
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));

		int countResult = 0;

		int inputNumTimes = Integer.parseInt(br.readLine());

		for(int i = 0; i < inputNumTimes; i++) {
			int num = Integer.parseInt(br.readLine());
			boolean isPrimeNumber = true;

			for(int j = 2; j <= Math.sqrt(num); j++) {
				if(num % j == 0) {
					isPrimeNumber = false;
					break;
				}
			}
			if(isPrimeNumber) {
				countResult++;
			}
		}
		System.out.println(countResult);
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n; cin >> n;
    V<ll> a(n), b(n), c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i];

    sort(ALL(a));
    sort(ALL(c));
    ll ans = 0;
    for(int i = 0; i < n; i++){
        auto itea = lower_bound(ALL(a), b[i]);
        auto itec = upper_bound(ALL(c), b[i]);
        ll aa = itea - a.begin();
        ll cc = c.end() - itec;
        ans += aa * cc;
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

using namespace std;

int main() {
    int N,v,c;
    vector<int> V,C;
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> v;
        V.push_back(v);
    }
    for (int i=0;i<N;i++){
        cin >> c;
        C.push_back(c);
    }
    int sum=0;
    for (int i=0;i<N;i++){
        if (V[i] - C[i] > 0){
            sum += (V[i] - C[i]);
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256