akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, int> P;

P bunkai(int i) {
    int a = i % 10;
    int b = 0;

    while (i > 0) {
        b = i;
        i /= 10;
    }
    return P(a, b);
}



int main() {
    int N;
    cin >> N;
    map<P, int> kosuu;
    
    for (int i = 1; i <= N; i++) {
        P p = bunkai(i);
        kosuu[p]++;
    }
    
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        P p = bunkai(i);
        P q(p.second, p.first);
        ans +=kosuu[q];
    }

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

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <deque>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000;

int N, M;
std::vector<int> G[MAX_N];
std::deque<int> deq;
bool used[MAX_N];

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, M )
  {
    int A, B;
    scanf( "%d%d", &A, &B );
    --A; --B;
    G[A].push_back( B );
    G[B].push_back( A );

    if( !i )
    {
      deq.push_back( A );
      deq.push_back( B );

      used[A] = used[B] = true;
    }
  }

  while( true )
  {
    int f = deq.front();

    bool upd = false;

    for( auto &v : G[f] ) if( !used[v] && !upd )
      deq.push_front( v ), used[v] = true, upd = true;

    if( !upd )
      break;
  }

  while( true )
  {
    int f = deq.back();

    bool upd = false;

    for( auto &v : G[f] ) if( !used[v] && !upd )
      deq.push_back( v ), used[v] = true, upd = true;

    if( !upd )
      break;
  }

  printf( "%d\n", deq.size() );
  rep( i, deq.size() )
    printf( "%d%c", deq[i]+1, i==deq.size()-1?'\n':' ' );

  return 0;
}

Measured memory_bytes: 6784
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<bitset>
#include<stack>
#include<cctype>
#define sc(x) scanf("%d",&x);
#define pr(x) cout<<#x<<": "<<x<<" ";
#define prln(x) cout<<#x<<": "<<x<<endl;
#define bug() cout<<"bug: "<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps = 1e-4;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+7;
const int maxm = 1e6+7;
const double pi = acos(-1.0);


int main(){
	char s[maxn]; scanf("%s",s);
	int cnt[100];
	for(int i=0; i<strlen(s); i++)
		cnt[s[i]-'a']++;
	bool flag=false;
	for(int i=0; i<26; i++){
		if(cnt[i]==0){
			printf("%c\n",'a'+i);
			flag=true;
			break;
		}
	}
	if(!flag)
		puts("None");
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int K;
    cin >> K;

    FOR(i,1,K+1) FOR(j,1,K+1) FOR(k,1,K+1) ans += GCD(i,GCD(j,k));
    pa;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc162/abc162_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc162/abc162_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc162/abc162_c && sh shellscripts/submit_cpp.sh
*/


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

//const INF = 1e9+5;

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

    int n;
    cin>>n;
    vector<int> dp(3);
    for(int i=0;i<n;i++){
        vector<int> ndp(3,0);
        int ar[3];
        for (int j = 0; j < 3; ++j) {
            cin>>ar[j];
        }
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if(j!=k){
                    ndp[k]=max(ndp[k],dp[j]+ar[k]);
                }
            }
        }
        dp.swap(ndp);
    }
    cout<<max(dp[0],max(dp[1],dp[2]))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

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

int main() {
  while (1) {
    int R, W, C, r;
    scanf("%d %d %d %d", &R, &W, &C, &r);
    if (!R && !W && !C && !r) {
      break;
    }

    int target_r = W * C;
    if (target_r <= R) {
      cout << "0" << endl;
    } else {
      cout << ceil((double)(target_r - R) / r) << endl;
    }
  }
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX 10000005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
vector<int> primes;
ll sumprime[MAX];
bool is_prime[MAX];
void sieve(){
    is_prime[0]=is_prime[1]=true;
    for(int i=4;i<MAX;i+=2){
        is_prime[i]=true;
    }
    for(int i=3;i*i<MAX;i+=2){
        if(!is_prime[i]){
            for(int j=i*i;j<MAX;j+=i){
                is_prime[j]=true;
            }
        }
    }
    for(int i=0;i<MAX;i++){
        if(!is_prime[i]){
            sumprime[i]=sumprime[i-1]+i;
        }else{
            sumprime[i]=sumprime[i-1];
        }
    }
}
*/
/*
void lcs(char s1[],char s2[]){
    int n=strlen(s1);
    int m=strlen(s2);
    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int sum=0;
            if(s1[i-1]==s2[j-1]){
                sum=1+dp[i-1][j-1];
            }
            else{
                sum=max(dp[i-1][j],dp[i][j-1]);
            }
            dp[i][j]=sum;
        }
    }
    
    int index=dp[n][m];
    //cout<<index<<endl;
    char ans[index+1];
    ans[index]='\0';
    index--;
    int x=n;
    int y=m;
    while(x>0 and y>0){
        if(dp[x-1][y]==dp[x][y-1] and dp[x-1][y]!=dp[x][y]){
            ans[index]=s1[x-1];
            index--;
            x--;
            y--;
        }else if(dp[x-1][y]>dp[x][y-1]){
            x--;
        }else{
            y--;
        }

    }
    //reverse(ans.begin(),ans.end());

    cout<<ans;
    return;
}
*/

int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    //cin>>t;
    for(int tc=1;tc<=t;tc++){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int ans=1000;
        int i=0;
        while(i<n-1){
            while(i<n-1 and a[i]>=a[i+1]){
                i++;
            }
            if(i==n-1){
                break;
            }
            int j=i;
            i++;
            while(i<n and a[i]>=a[i-1]){
                i++;
            }
            int lau=ans/a[j];
            ans%=a[j];
            ans+=(lau*a[i-1]);
        }
        cout<<ans<<'\n';
    }
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
    long long a,b,g;
    int x=0;
    cin>>a>>b;
    while(a && b){
        a%=b;
        if(a==0)break;
        b%=a;
    }
    g=a+b;
    for(int i=2;i<=sqrt(g);i++){
        if(g%i==0){
            while(g%i==0)
                g/=i;
            x++;
        }
    }
    if(g>=2)x++;
        cout<<x+1<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = np.array(list(map(lambda x: int(x),input().split())))

A_allplus = np.where(A>=0,A,-A)
#print(A_allplus)
plus = A[A>=0]
minus = A[A<0]
#print(minus)
d = 0
if len(minus)%2==1:
    a = np.inf
    b = np.inf
    if len(minus)>0:
        a = max(minus)
    if len(plus)>0:
        b = min(plus)
    
    
    d = min(abs(a),abs(b))*2

print(sum(A_allplus)-d)

Measured memory_bytes: 23276
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

long long dp[55][55];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N, A, B;
	cin >> N >> A >> B;

	vector<ll> v(N);
	map<ll, int>vm;
	ll before = 0;
	bool isSame = true;
	for (int i = 0; i < N; ++i) {
		cin >> v[i];
		if (i != 0 && before != v[i])isSame = false;
		before = v[i];
		vm[v[i]]++;
	}

	dp[0][0] = 1;
	for (int n = 1; n <= N; n++) {
		for (int k = 0; k <= n; k++) {
			if (k - 1 >= 0) {
				dp[n][k] = dp[n - 1][k - 1] + dp[n - 1][k];
			}
			else {
				dp[n][k] = dp[n - 1][k];
			}
		}
	}

	long double heikin = 0;
	ll ans = 0;
	if (isSame) {
		heikin = (long double)v.back();
		for (int i = A; i <= B; ++i) {
			ans += (ll)dp[N][i];
		}
	}
	else {
		ll sum = 0;
		map <ll, int > m;
		sort(v.begin(), v.end());
		isSame = true;
		int a = A;
		for (int i = N - 1; N - B <= i; --i) {
			sum += v[i];
			long double next = ((long double)sum) / ((long double)(N - i));
			if (0 < a || heikin <= next) {
				if (i != N - 1 && before != v[i]) {
					isSame = false;
				}
				m[v[i]]++;
				heikin = next;
				a--;
				before = v[i];
			}
			else break;
		}

		if (isSame) {
			for (auto ma : m) {
				for (int i = A; i <= ma.second;++i) {
					if (vm[ma.first] < i)break;
					ans += (ll)dp[vm[ma.first]][i];
				}
			}
		}
		else {
			ans = 1;
			for (auto ma : m) {
				ans *= dp[vm[ma.first]][ma.second];
			}
		}
	}

	cout << fixed << setprecision(10) << heikin << endl;
	cout << ans << endl;
}

Measured memory_bytes: 4992
A = list(map(int,input().split()))
ans = []
a = abs(A[0]-A[1])+abs(A[1]-A[2])##0→1→2
b = abs(A[0]-A[2])+abs(A[2]-A[1])##0→2→1
c = abs(A[1]-A[0])+abs(A[0]-A[2])##1→0→2
ans.append(a)
ans.append(b)
ans.append(c)
print(min(ans))


Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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


#define REP(i, n) for(ll i = 0; i < n; i++)
























int main(){
    ll n;
    cin >> n;
    ll cnt[4] = {};
    REP(i, n){
        string s;
        cin >> s;
        if(s[0] == 'A') cnt[0]++;
        else if(s[0] == 'W') cnt[1]++;
        else if(s[0] == 'T') cnt[2]++;
        else cnt[3]++;
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
}

Measured memory_bytes: 3620
#include <iostream>
int main(void){
    int a,b,c;
    int i=0;
    std::cin >> a>>b>>c;
    for(int x=a;x<=b;x++)
    {
        if(c%x==0)
        {
            i++;
        }
    }
    std::cout << i << std::endl;
}


Measured memory_bytes: 3108
import Data.List hiding (find)
import Data.Tree
--import Data.Array
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
--import Data.Vector as V
import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Debug.Trace

type Str = UArray Int Char
--type Table = UArray (Int,Int) Int --sl*tl matrix
type DP s = STUArray s (Int,Int) Int
type DPTable = UArray (Int,Int) Int -- == freeze $ DP s

dp_i :: DP s -> Str -> Str -> Int -> Int -> ST s ()
dp_i dparr s t i j = do
   dpij   <- readArray dparr (i,j)
   dpi1j1 <- readArray dparr (i-1,j-1)
   dpi1j  <- readArray dparr (i-1,j)
   dpij1  <- readArray dparr (i,j-1)
   writeArray dparr (i,j-1) (max dpi1j1 dpij1)
   writeArray dparr (i-1,j) (max dpi1j1 dpi1j)
   if s!i == t!j then writeArray dparr (i,j) (max (dpi1j1+1) dpi1j1)
     else writeArray dparr (i,j) (max dpi1j dpij1) --無駄が多い。最後のみ必要。

--DPTableからStringを復元
mkans :: DPTable -> Str -> Int -> Int -> String
mkans dparr s i j
  | i == 0 || j == 0 = []
  | dparr!(i,j) == dparr!(i-1,j-1) = mkans dparr s (i-1) (j-1)
  | dparr!(i,j) == dparr!(i-1,j-1) + 1 =
    if dparr!(i,j) == dparr!(i-1,j) then mkans dparr s (i-1) j
    else if dparr!(i,j) == dparr!(i,j-1) then mkans dparr s i (j-1)
      else s!i : (mkans dparr s (i-1) (j-1))
  | otherwise = error "mkansError"

solve :: Str -> Str -> Int -> Int -> ST s String
solve s t sl tl = do
  dparr <- newArray ((0,0),(sl,tl)) 0
  forM_ [1..sl] $ \i ->
    forM_ [1..tl] $ \j -> dp_i dparr s t i j
  dparr' <- freeze dparr
  let ans = reverse $ mkans dparr' s sl tl
  return ans

main :: IO ()
main = do
  s <- getLine
  t <- getLine
  let sl = length s
      tl = length t
      s' = listArray (1,sl) s
      t' = listArray (1,tl) t
  putStrLn $ runST $ solve s' t' sl tl


Measured memory_bytes: 142332
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


////フォード - ファルカーソン法 O(Flow|E|)

typedef int Weight;

const Weight INF = 1e9;
const Weight ZERO = 0;
struct Edge {
	int src, dst;
	Weight weight;
	int rev;
	int id;
	Edge(int src_, int dst_, Weight weight_, const int rev_, const int id_) :
		src(src_), dst(dst_), weight(weight_), rev(rev_), id(id_) { }
	Edge(int src_, int dst_, Weight weight_, const int rev_) :
		src(src_), dst(dst_), weight(weight_), rev(rev_) { }
	Edge() :src(0), dst(0), weight(0) {
	}
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph&g, int from, int to, int cap)
{
	g[from].push_back(Edge(from, to, cap, (int)g[to].size()));
	g[to].push_back(Edge(to, from, 0, (int)g[from].size() - 1));
}
//二つを繋ぐ線を完全に消す
void erase_edge(Graph&g, const  int from, const int to) {
	g[from].erase(remove_if(g[from].begin(), g[from].end(), [=](const Edge&e) {return e.dst == to; }), g[from].end());
	g[to].erase(remove_if(g[to].begin(), g[to].end(), [=](const Edge&e) {return e.dst == from; }), g[to].end());
}
int dfs(vector<int>&used, Graph&g, int now, int t, int f)
{
	if (now == t) {
		return f;
	}
	used[now] = true;
	for (int i = 0; i<g[now].size(); ++i) {
		Edge &e = g[now][i];
		if (!used[e.dst] && e.weight>0) {
			int d = dfs(used, g, e.dst, t, min(f, e.weight));
			if (d > 0) {
				e.weight -= d;
				g[e.dst][e.rev].weight += d;
				return d;
			}
		}
	}
	return 0;
}
Weight fold_falc(Graph g, const int start, const int goal) {
	Weight ans = 0;
	while (1) {
		vector<int>used(g.size());
		int flow = dfs(used, g, start, goal, INF);
		if (!flow)return ans;
		else ans += flow;
	}
}

int main() {
	int N,A,B;cin>>N>>A>>B;
	vector<vector<int>>sas(2);
	int ans=0;
	for (int i = 0; i < N; ++i) {
		int a, b;cin>>a>>b;
		int num=a-b;
		if ( abs(num)<=A || (B <= abs(num) && abs(num) <= 2 * A)) {
			ans++;
		}
		else {
			if(num>0)sas[0].push_back(num);
			else sas[1].push_back(-num);
		}
	}
	const int start=0;
	const int zero=1;
	const int one=zero+sas[0].size();
	const int goal=one+sas[1].size();
	Graph g(goal+1);

	for (int i = 0; i < sas[0].size(); ++i) {
		add_edge(g,start,zero+i,1);
	}
	for (int i = 0; i < sas[0].size(); ++i) {
		for (int j = 0; j < sas[1].size(); ++j) {
			int x=zero+i;
			int y=one+j;
			int num=sas[0][i]-sas[1][j];

			if ( abs(num)<=A || (B <= (abs(num)) && (abs(num)) <= 2 * A)) {
				add_edge(g,x,y,1);
			}
		}
	}
	for (int i = 0; i < sas[1].size(); ++i) {
		add_edge(g, one+i, goal, 1);
	}

	ans+=fold_falc(g,start,goal);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6468
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	string s;
	cin >> s;

	int r, b;
	r = b = 0;
	for (int i = 0; i < N; i++)
		if (s[i] == 'R')
			r++;
		else
			b++;

	if (r > b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rp(i,k,n) for(int i=(k); i<(n); i++)
int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> vec(100,0);
  rp(i,0,m){
    int a;
    cin >> a;
    vec[a]++;
  }
  int cnt=0;
  rp(i,x,n+1){
    if(vec[i]==1){
      cnt++;
    }
  }
  int cnt2=0;
  for(int i=x; i>=0; i--){
    if(vec[i]==1){
      cnt2++;
    }
  }
  cout << min(cnt, cnt2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int A,B,n,sum=0;
  scanf("%d %d",&A,&B);
  for(n=1;n<=2;n++){
    if(A>=B){
      sum+=A;
      A--;
    }
    else{
      sum+=B;
      B--;
    }
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

struct modint
{
    ll a;
    modint():a(0){}
    modint(ll t){
        a=t%MOD;
        if(a<0) a+=MOD;
    }
    //operator long long() const{return a;}
    bool operator==(const modint & x)const{return a==x.a;}
    bool operator!=(const modint & x)const{return a!=x.a;}
    modint operator-() const {return modint(a?(MOD-a):0);}
    modint operator~() const {return modint(MOD -2);}
    modint operator+(const modint &x) const{return modint(*this)+=x;}
    modint operator-(const modint &x) const{return modint(*this)-=x;}
    modint operator*(const modint &x) const{return modint(*this)*=x;}
    modint operator/(const modint &x) const{return modint(*this)/=x;}
    modint &operator+=(const modint &x){
        a+= x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint &operator-=(const modint &x){
        a-= x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    
    modint &operator*=(const modint &x){
        a=a*x.a %MOD;
        return *this;
    }
    modint &operator/=(const modint &x){
        a=a*(~x).a %MOD;
        return *this;
    }

    friend ostream &operator<<(ostream &os,const modint &x){
        return os << x.a;
    }

    friend istream &operator>>(istream &is,modint &x){
        ll t;
        x=modint(t);
        return is;
    }

    modint pow(ll x)const{
        modint ret = 1,tmp=a;
        for(;x;tmp*=tmp,x>>=1){
            if(x&1) ret*=tmp;
        }
        return ret;
    }

};

modint nCr(int n,int r){
    modint ans=1;
    for(int i=1;i<=r;i++) ans*=modint(n-i+1)/modint(i);
    return ans;
}

int main(){
    ll n,m,k; cin >> n >> m >> k;

    rep(i,n+1)
        rep(j,m+1){
            if(j*(n-i)+i*(m-j)==k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <string>
    #include <set>
    #include <cmath>
    #include <map>
    #include <cstring>
    #include <stack>
    #include <cstdio>
    #include <complex>
    #include <iomanip>
    #include <cstring>
    #define rep(i,n) for(int i=0;i<n;++i)
    using namespace std;
    typedef long long ll;
    typedef pair<int,int> pii;
    #define show(x) cout << #x << " = " << x << endl;
     
    string s;
    string t;
    int p[100005],q[100005];
    int main(){
        int qq;
        cin >> s >> t >> qq;
        int ss = (int)s.size();
        int tt = (int)t.size();
        rep(i,ss){
            p[i+1]=p[i];
            if(s[i]=='A')p[i+1]++;
        }
        rep(i,tt){
            q[i+1]=q[i];
            if(t[i]=='A')q[i+1]++;
        }
        int a,b,c,d;
        rep(i,qq){
            scanf("%d %d %d %d",&a,&b,&c,&d);
            if((b-a+1+p[b]-p[a-1])%3==(d-c+1+q[d]-q[c-1])%3){
                puts("YES");
            }else{
                puts("NO");
            }
        }
        return 0;
    }

Measured memory_bytes: 1664
/* Distance */
#include <stdio.h>
#include <math.h>

int main()
{
    double x1, x2, y1, y2, P;

    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    P = 1.0 * pow(fabs(x2 - x1), 2) + pow(fabs(y2 - y1), 2);
    printf("%.8lf\n", sqrt(P));
    return 0;
}


Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin =new Scanner(System.in);
		while(true){
			int n  =cin.nextInt();
			if(n==0){
				break;
			}
			Line[] a = new Line[n+1];
			for(int i = 0;i<=n;i++){
				int m = cin.nextInt();
				a[i]=new Line(m);
				for(int j = 0;j<m;j++){
					int x=cin.nextInt();
					int y=cin.nextInt();
					a[i].lines[j][0]=x;
					a[i].lines[j][1]=y;
				}
			}
			for(int i = 1;i<=n;i++){
				if(a[0].equal(a[i])){
					System.out.println(i);
				}
			}
			System.out.println("+++++");
		}
		
	}
}
class Line{
	int size;
	int[][] lines; 
	Line(int a){
		size=a;
		lines=new int[a][2];
	}
	int[] v(int a,int b){
		int[] re = new int[2];
		re[0]=lines[b][0]-lines[a][0];
		re[1]=lines[b][1]-lines[a][1];
		return re;
	}
	void roll(){

			for(int i = 0;i<size;i++){
				int v1[]=this.lines[i].clone();
				this.lines[i][0]=-v1[1];
				this.lines[i][1]=v1[0];
			}
			
	}
	boolean equal(Line a){
		if(this.size!=a.size){
			return false;
		}
//		System.out.println("**************");
		for(int j = 0;j<4;j++){
			boolean f =true;
			for(int i = 0;i<size-1;i++){
				int[] v1=this.v(i+1, i);
				int[] v2=a.v(i+1, i);
//				System.out.println(v1[0]+" "+v1[1] + "   " + v2[0]+" "+v2[1]);
				if(!(v1[0]==v2[0]&&v1[1]==v2[1])){
					f=false;
				}
			}
			if(f){
				return true;
			}
//			System.out.println("-------------");
			f=true;
			for(int i = 0;i<size-1;i++){
				int[] v1=this.v(i+1, i);
				int[] v2=a.v(size-1-i,size-i-2);
//				System.out.println(v1[0]+" "+v1[1] + "   " + v2[0]+" "+v2[1]);
				if(!(v1[0]==v2[0]&&v1[1]==v2[1])){
					f=false;
				}
			}
			if(f){
				return true;
			}
			//System.out.println("-------------");
			a.roll();
		}
		return false;
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <math.h>

long long n;
long long sq;

int main(void)
{
	scanf("%lld", &n);
	
	sq = sqrt(n);
	
	for(long long i = sq ; i >= 1 ; i--)
	{
		if(n % i == 0)
		{
			printf("%lld", i - 1 + n / i - 1);
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    string key = "keyence";
    int ans=0,i,j,tmp,n=s.length();
    for(i=0;i<=7;i++){
        tmp=1;
        for(j=0;j<i;j++){
            if(s.at(j)!=key.at(j))tmp=0;
        }
        for(j=0;j<7-i;j++){
            if(s.at(n-1-j)!=key.at(6-j))tmp=0;
        }
        ans = max(ans,tmp);
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


struct UnionFind {
    vll par;
    vll _size;

    UnionFind(ll N) : par(N), _size(N, 1) {
        rep(i, N) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
        _size[ry] += _size[rx];
        _size[rx] = 0;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll size(ll x) {
        return _size[root(x)];
    }
};

ll comb(ll n) {
    return n * (n - 1) / 2;
}

int main()
{
    ll N, M; cin >> N >> M;
    UnionFind uf(N);
    vll A(M), B(M); rep(i, M) {
        cin >> A[i] >> B[i]; A[i]--, B[i]--;
    }

    vll ans(M);
    ll ucomf = N * (N - 1) / 2;
    for (ll i = M - 1; i >= 0; i--) {
        ll a = A[i], b = B[i];
        ans[i] = ucomf;
        if (!uf.same(a, b)) ucomf -= (comb(uf.size(a) + uf.size(b)) - comb(uf.size(a)) - comb(uf.size(b)));
        uf.unite(a, b);
    }
    for (auto elme : ans) {
        cout << elme << endl;
    }
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i = a ; i <= b ; ++i)
#define FOD(i, a, b) for(int i = a ; i >= b ; --i)
#define FRSZ(i, a) for(int i = 0 ; i < a.size() ; ++i)
#define FDSZ(i, a) for(int i = a.size() - 1 ; i >= 0 ; --i)
 
#define debug(x) cout << #x << " = " << x << endl;
#define debugvi(x) {FRSZ(_, x) cout << x[_] << " "; cout << endl;}
#define debugarr(x, n) {FOR(_, 1, n) cout << x[_] << " "; cout << endl;}
 
#define fi first
#define se second
#define pb push_back
using namespace std;
 
typedef int64_t ll;
const int MAX = 2e5 + 5;
int n;
int a[MAX], h[MAX];
 
struct FenwickTree{
    ll Tree[MAX];
    void Update(int u, ll x){
        for(; u <= n ; u += u & -u )
            Tree[u] = max(Tree[u], x);
    }
 
    ll Query(int u){
        if (u <= 0) return 0;
        ll ans = 0;
        for(; u > 0 ; u -= u & -u)
            ans = max(ans, Tree[u]);
        return ans;
    }
} BIT;
 
int main(){

 
    cin >> n;
    FOR(i, 1, n) cin >> h[i];
    FOR(i, 1, n) cin >> a[i];
 
    ll ans = 0;    
    memset(BIT.Tree, 0, sizeof(BIT.Tree));
    FOR(i, 1, n){
        ll tmp = BIT.Query(h[i] - 1) + a[i];
        ans = max(ans, tmp);
        BIT.Update(h[i], tmp);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
def combinations(N):
    comb = [[0] * (N + 1) for _ in range(N + 1)]
    comb[0][0] = 1
    for i in range(1, N + 1):
        for j in range(i + 1):
            comb[i][j] += comb[i - 1][j]
            if j > 0:
                comb[i][j] += comb[i - 1][j - 1]
    return comb


nCk = combinations(60)

N, A, B, *V = map(int, open(0).read().split())

V.sort(reverse=True)

num = V.count(V[A - 1])

ans = 0
if V[0] == V[A - 1]:
    for i in range(A, B + 1):
        ans += nCk[num][i]
else:
    a = V[:A].count(V[A - 1])
    ans = nCk[num][a]

ave = sum(V[:A]) / A

print("{:.9f}".format(ave))
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int a[3][3];
int main(){
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>a[i][j];
  for(int i=0;i<3;i++)for(int j=0;j<3;j++){
    if(a[i][0]-a[0][0] + a[0][j] != a[i][j]){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   string a,b; cin >> a >> b;
   a+=b[b.size()-1];
   if(a==b) cout << "Yes\n";
   else cout << "No\n";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

ll gcd(ll a, ll b){
  if(a<b) swap(a,b);
  ll r;
  while(b){
    r=a%b;
    a=b;
    b=r;
  }
  return a;
}

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

int main(){
  ll A,B,C,D; cin>>A>>B>>C>>D;
  ll ans=B-A+1;
  ll L=lcm(C,D);
  ans-=B/C-(A-1)/C;
  ans-=B/D-(A-1)/D;
  ans+=B/L-(A-1)/L;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
ar = gets.chomp!.split(" ")
n = ar[0].to_i
m = ar[1].to_i
a = Array.new(m){|item|item = 0}
count = 0
n.times do
    arr = gets.chomp!.split(" ").map{|item|item = item.to_i}
    arr.delete_at(0)
    arr.each do|b|
        a[b-1] += 1
        if a[b-1] == n then
            count+=1
        end
    end
end
puts count

Measured memory_bytes: 1788
from sys import stdin

s = stdin.readline().rstrip()

r = len(s)-1
l = 0
count = 0
while r-l > 0:
    if s[l] == s[r]:
        r -= 1
        l += 1
    elif s[l] == "x" and s[r] != "x":
        count += 1
        l += 1
    elif s[r] == "x" and s[l] != "x":
        count += 1
        r -= 1
    else:
        print(-1)
        exit()
print(count)

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    long long n,i;
    string s,t,r;
    cin>>n;
    cin>>s>>t;
    for(i=0;i<t.size();i++)
    {
        r.push_back(s[i]);
        r.push_back(t[i]);
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 3512
import java.util.Scanner;

public class Main {

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

		int counter = scanner.nextInt();

		int dice[][] = new int[counter][6];
		for (int index = 0; index < counter; index++) {
			for (int index2 = 0; index2 < 6; index2++) {
				dice[index][index2] = scanner.nextInt();
			}
		}

		String answer = "Yes";
		int copy = 0;

		for (int dicenum = 0; dicenum < counter - 1; dicenum++) {
			for (int dicenum2 = dicenum + 1; dicenum2 < counter; dicenum2++) {

				String order = "NNNNWNNNWNNNENNNENNNWNNN";
				for (int count = 0; count < order.length(); count++) {
					// 先頭の文字から試行
					char command = order.charAt(count);
					// commmandによって配列を入れ替え
					if (command == 'N') {
						copy = dice[dicenum][0];
						dice[dicenum][0] = dice[dicenum][1];
						dice[dicenum][1] = dice[dicenum][5];
						dice[dicenum][5] = dice[dicenum][4];
						dice[dicenum][4] = copy;

					} else if (command == 'S') {
						copy = dice[dicenum][0];
						dice[dicenum][0] = dice[dicenum][4];
						dice[dicenum][4] = dice[dicenum][5];
						dice[dicenum][5] = dice[dicenum][1];
						dice[dicenum][1] = copy;

					} else if (command == 'W') {
						copy = dice[dicenum][0];
						dice[dicenum][0] = dice[dicenum][2];
						dice[dicenum][2] = dice[dicenum][5];
						dice[dicenum][5] = dice[dicenum][3];
						dice[dicenum][3] = copy;

					} else if (command == 'E') {
						copy = dice[dicenum][0];
						dice[dicenum][0] = dice[dicenum][3];
						dice[dicenum][3] = dice[dicenum][5];
						dice[dicenum][5] = dice[dicenum][2];
						dice[dicenum][2] = copy;

					}

					if (dice[dicenum][0] == dice[dicenum2][0] && dice[dicenum][1] == dice[dicenum2][1]
							&& dice[dicenum][2] == dice[dicenum2][2] && dice[dicenum][3] == dice[dicenum2][3]
							&& dice[dicenum][4] == dice[dicenum2][4] && dice[dicenum][5] == dice[dicenum2][5]) {
						answer = "No";
						break;
					}
				}
			}
		}
		System.out.println(answer);

	}
}



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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265

typedef long long ll;

void InsertionSort( int a[], int n ) {
    for( int i = 0; i < n; i++ ) {
        int temp = a[ i ];
        int j    = i - 1;
        while( j >= 0 && a[ j ] > temp ) {
            a[ j + 1 ] = a[ j ];
            j--;
        }
        a[ j + 1 ] = temp;
        rep( k, n ) {
            if( k < n - 1 )
                cout << a[ k ] << " ";
            else
                cout << a[ k ] << endl;
        }
    }
}

//*******************
//エントリーポイント
//*******************
int main( void ) {
    int n;
    cin >> n;
    int a[ n ];
    rep( i, n ) cin >> a[ i ];
    InsertionSort( a, n );
    return 0;
}



Measured memory_bytes: 3092
n, a, b = map(int,input().split())
if a == 0 and b == 0:
    print(0)
if a != 0 or b != 0:
         
    kumi = n // (a + b)
    nokori = n % (a + b)
    if nokori == 0:
        print(a * kumi)
    elif nokori >= 1 and nokori < a:
        print(a * kumi + nokori)
    elif nokori >= a:
        print(a * kumi + a)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}
 
map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
int main(){
    string s,t,u;
    ll x,y;
    cin >> s >> t >> x >> y >> u;
    if (s==u)x--;
    if (t==u)y--;
    cout << x << " " << y << endl;
    return 0;
}
 


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n; scanf("%d", &n);
  if (n%1000) {
    printf("%d", 1000-n%1000);
  } else {
    printf("0");
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3808
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = ~~arg[0];
    const a = arg[1].split(" ").map(n=>~~n).sort((a,b)=>a-b);
    
    console.log(Math.max(...a) - Math.min(...a));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def bubble_sort(A, N):
    flag = 1
    cnt = 0
    while flag:
        flag = 0
        for j in reversed(range(1, N)):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 1
                cnt += 1
    return cnt


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    cnt = bubble_sort(A, N)
    print(*A)
    print(cnt)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7296
use proconio::input;

fn main() {
    input!{
        n: i32,
        y: i32,
    }

    for ten_thousands in 0..(y / 10000) + 1 {
        for five_thousands in 0..(y / 5000) + 1 {
            let one_thousands = n - (ten_thousands + five_thousands);
            if one_thousands < 0 {
                break;
            }

            let sum = 10000 * ten_thousands + 5000 * five_thousands + 1000 * one_thousands;
            if y == sum {
                println!("{} {} {}", ten_thousands, five_thousands, one_thousands);
                return;
            }
        }
    }

    println!("-1 -1 -1");
}


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

int main(){
	int N, T, H, L;
	int t[100], h[100];
	int con = 0;
	int d;
	cin >> N >> T >> H >> L;
	for(int i=0; i < N; i++)
		cin >> t[i] >> h[i];

	while(1){
		if(t[con%N] != 0){
			t[con%N]--;
			T++;
			d++;
		}
		else {
			h[con%N]--;
			H++;
			d += 10;
		}
		if(T < 0 || L < T || t[con%N] < 0 || h[con%N] < 0){
			cout << (con % N)+1 << endl;
			return 0;
		}
		if(9 <= d){
			d -= 9;
			if(10 <= d && T < d){
				H--;
				h[con%N]++;
			}
			else {
				t[con%N] += d;
				T -= d;
			}
			d = 0;
		}

		con++;
	}
}

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

int main(){

  int i, check=0;
  char S[10];
  scanf("%s", S);
  int len=strlen(S);

  if(S[0] == 'A' && 'a' <= S[1] && S[1] <= 'z' && 'a' <= S[len-1] && S[len-1] <= 'z'){
    for(i=2;i<len-1;i++){
      if(S[i] == 'C') check++;
      else if('a' > S[i] || S[i] > 'z') check=2;
    }
  }
  if(check == 1) puts("AC");
  else puts("WA");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int n;
R memo[301][301][301];

R rec(int a,int b,int c){
	R &ret = memo[a][b][c];
	if(ret >= 0.0) return ret;
	
	const R coef = 1.0 * (a + b + c) / n;
	ret = 1.0;
	if(a > 0) ret += 1.0 * a / n * rec(a - 1, b, c);
	if(b > 0) ret += 1.0 * b / n * rec(a + 1, b - 1, c);
	if(c > 0) ret += 1.0 * c / n * rec(a, b + 1, c - 1);
	ret /= coef;

	return ret;
}

int main(void){
	cin >> n;
	rep(i,n+1)rep(j,n+1)rep(k,n+1) memo[i][j][k] = -1.0;
	memo[0][0][0] = 0.0;

	vector<int> num(3,0);
	rep(i,n){
		int a;
		cin >> a;
		num[a-1]++;
	}

	cout.precision(20);
	cout << fixed << rec(num[0], num[1], num[2]) << endl;
	return 0;
}

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

int N;
int A[210];

int main(){
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  int res = 0;
  while(true){
    bool exist_odd = false;
    for (int i = 0; i < N; ++i){
      if (A[i] % 2 != 0) exist_odd = true;
    }
    
    if(exist_odd) break;
    
    for (int i = 0; i<N; ++i){
      A[i] /= 2;
    }
    ++res;
  }
  
  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    char ch='a';
    bool loop=true;
    while(loop){
        switch(ch){
        case 'a':if(a.size()==0){
        cout<<'A';
        loop=false;
        break;
        }
        ch=a[0];
        a.erase(0,1);
        break;

        case 'b':if(b.size()==0){
        cout<<'B';
        loop=false;
        break;
        }
        ch=b[0];
        b.erase(0,1);
        break;

        case 'c':if(c.size()==0){
        cout<<'C';
        loop=false;
        break;
        }
         ch=c[0];
         c.erase(0,1);
         break;
        }
    }
    return 0;
}


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

using namespace std;

pair<int, int> key(int a, int b) {
	return make_pair(min(a, b), max(a, b));
}

int main() {
	int N;
	cin >> N;
	vector<int> a(N - 1), b(N - 1);
	vector<vector<int>> g(N + 1);
	map<pair<int, int>, int> mp;
	for (int i = 0; i < N - 1; ++i) {
		cin >> a[i] >> b[i];
		g[a[i]].emplace_back(b[i]);
		g[b[i]].emplace_back(a[i]);
		mp[key(a[i], b[i])] = -1;
	}

	deque<int> que;
	que.push_back(1);
	while (!que.empty()) {
		int u = que.front(); que.pop_front();

		set<int> st;
		for (auto v : g[u]) {
			if (mp[key(u, v)] < 0) { continue; }
			st.insert(mp[key(u, v)]);
		}

		int c = 1;
		for (auto v : g[u]) {
			if (mp[key(u, v)] < 0) {
				while (st.count(c) != 0) { ++c; }
				mp[key(u, v)] = c;
				st.insert(c);
				que.push_back(v);
			}
		}
	}

	int K = 0;
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		K = max(K, itr->second);
	}
	cout << K << endl;
	for (int i = 0; i < N - 1; ++i) {
		cout << mp[key(a[i], b[i])] << endl;
	}

	return 0;
}


Measured memory_bytes: 13056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		int[] C = new int[N];
		int[] V = new int[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			V[i] = Integer.parseInt(tokens[i]);
		}
		tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			C[i] = Integer.parseInt(tokens[i]);
		}
		in.close();

		int result = 0;
		for (int i = 0; i < N; ++i) {
			if (V[i] - C[i] > 0) {
				result += V[i] - C[i];
			}
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define LL long long 
#define mod 998244353 
#define FOR(i, j, k) for (int i=j ; i<k ; i++)
#define ROF(i, j, k) for (int i=j ; i>=k ; i--) 
 
const long long INF = 1e18;
const long long MAX = 1e5+10;
 
int main() {
string s;
cin>>s;
if(s[3]==s[2] && s[5]==s[4]) cout<<"Yes";
else cout<<"No";
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		    String s = scanner.next();
		    int N = Integer.parseInt(s);
		    
		    if(N >= 1000)
		    {
		    	System.out.println("ABD");
		    }
		    else
		    {
		    	System.out.println("ABC");
		    }	
        	scanner.close();}
		  }

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
int main()
{
	int a, b , c;
	cin >> a >> b  >> c;
	// まず偶奇を揃える
	vector<int> A(3);
	int flag = 0;
	if(a%2 == b%2 && b%2 == c%2){
		// 偶奇は揃っている
	} else {
		if(a%2 == b%2 && b%2 != c%2){
			a++, b++;
		} else if(a%2 == c%2 && c%2 != b%2){
			a++, c++;
		} else {
			b++, c++;
		}
		flag = 1;
	}
	A[0] = a, A[1] = b, A[2] = c;
	sort(A.begin(),A.end());
	cout << flag + (A[2] - A[0] )/ 2 + (A[2] - A[1]) / 2 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[0] + a[1]);

    }
}

Measured memory_bytes: 21716