akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
 
int main()
{
    ll x,y;
    cin >> x >> y;

    ll ans = 0;
    while(++ans){
        x *= 2;
        if(x > y){
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<cmath>
#define LL long long
using namespace std;
inline void read(LL &x){
	x=0;int f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();	}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	x*=f;
}
LL a,b,k;
int main()
{
	read(a),read(b);
	//a-k =k-b
	if((a+b)%2==0)
	    printf("%lld",(a+b)/2);
	else
	    puts("IMPOSSIBLE");
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x,l,r;
    string s;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> re;
    vector<ll> de;

    cin >> n >> m;

    // rep(i, n){
        ll _k;
        cin >> _k;

        rep(j,_k){
            ll hoge;
            cin >> hoge;
            re.push_back(hoge);
        }
    // }

    if(n!=1){
        rep(i,n-1){
            ll __k;
            cin >> __k;
            vector<ll> tmp;
            rep(j, __k){
                ll fuga;
                cin >> fuga;
                
                auto it = find(all(re), fuga);
                if(it != re.end()){
                    tmp.push_back(fuga);
                }
            }
            re = tmp;
        }
    }

    ans = re.size();



    
    std::cout << ans << endl; 

    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,l = inpl()
a = inpl()
for i in range(1,n):
    if a[i] + a[i-1] >= l:
        print('Possible')
        for j in range(1,i):
            print(j)
        for k in range(i+1,n)[::-1]:
            print(k)
        print(i)
        break
else:
    print('Impossible')
        

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

int main(){
  int X,M; cin >> X >> M;
  int r=1;
  for(int i=0;i<M;i++){
    r *= 2;
  }
  int sum;
  sum = (100*(X-M)+1900*M)*r;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<int>& a, vector<int>& b) {
	return a[0] < b[0];
}

int ycomp(vector<int>& a, vector<int>& b) {
	return a[1] < b[1];
}

int zcomp(vector<int>& a, vector<int>& b) {
	return a[2] < b[2];
}
#define XSORT(c) sort((c).begin(),(c).end(),xcomp)
#define YSORT(c) sort((c).begin(),(c).end(),ycomp)
#define ZSORT(c) sort((c).begin(),(c).end(),zcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	int N;
	cin >> N;
	vector<vector<int>> x(N,vector<int>(2,-1));
	vector<int> A(N*N, 0);
	REP(i, N) {
		cin >> x[i][0];
		x[i][1] = i + 1;
		A[x[i][0] - 1] = i + 1;
	}
	XSORT(x);
	bool flag = true;
	REP(i, N) {
		LL now = 0;
		REP(j, x[i][1] - 1) {
			if (A[now] == 0) {
				A[now] = x[i][1];
				now++;
			}
			else {
				if (A[now] == x[i][1]) {
					flag = false;
					goto GOMI;
				}
				else {
					now++;
					j--;
				}
			}
		}
	}

	REP(i, N) {
		LL now = N*N-1;
		REP(j, N- x[N-i-1][1]) {
			if (A[now] == 0) {
				A[now] = x[N - i - 1][1];
				now--;
			}
			else {
				if (A[now] == x[N - i - 1][1]) {
					flag = false;
					goto GOMI;
				}
				else {
					now--;
					j--;
				}
			}
		}
	}

GOMI:

	if (flag) {
		cout << "Yes" << endl;
		REP(i, N*N) {
			cout << A[i] << " ";
		}
		cout << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 2176
N,M,X=map(int,input().split())
listA=list(map(int,input().split()))
for i in range(M-1):
  if listA[i]<X<listA[i+1]:
    ans=min(i+1,M-i-1)
  elif listA[i]==0:
    ans=min(i,M-i-1)
if X<listA[0] or listA[M-1]<X:
  ans=0
print(ans)

Measured memory_bytes: 3060
// 移動ベクトルという概念
// 今埋めようとしている周囲に#が1個のみならば埋める、
// そうでなければ方向転換.方向転換後1つも埋められないなら終わり

#include<iostream>
using namespace std;

int dir[4][2] = {{-1,0} , {0,1}, {1,0}, {0,-1}};
char mat[100][100];
int n;

bool ok(int x, int y){
    int count = 0;
    for(int i = 0; i < 4; i++){
        int ni = x + dir[i][0];
        int nj = y + dir[i][1];
        if(0 <= ni && ni < n && 0 <= nj && nj < n && mat[ni][nj] == '#'){
            count++;
        }
    }
    return count <= 1;
}

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

    for(int c = 0; c < d; c++){
        if(c)   cout << endl;

        cin >> n;

        for(int i = 0; i < 100; i++){
            for(int j = 0; j < 100; j++){
                mat[i][j] = ' ';
            }
        }

        int move = 0;

        int i = n, j = 0;
        while(1){
            int ni = i + dir[move][0];
            int nj = j + dir[move][1];

            if(0 <= ni && ni < n & 0 <= nj && nj < n && ok(ni, nj)){
                mat[ni][nj] = '#';
                i = ni;
                j = nj;
            }else{
                move = (move+1)%4;
                ni = i + dir[move][0];
                nj = j + dir[move][1];
                if(0 <= ni && ni < n & 0 <= nj && nj < n && ok(ni, nj)){
                    mat[ni][nj] = '#';
                    i = ni;
                    j = nj;
                }else{
                    break;
                }
            }
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                cout << mat[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define max 100001
struct node {int p,l,r;};
struct node t[max];
int n;
void ppreorder(int root){
  if(root==-1)return;
  cout<<" "<<root;
  ppreorder(t[root].l);
  ppreorder(t[root].r);
}
void pinorder(int root){
  if(root==-1)return;
  pinorder(t[root].l);
  cout<<" "<<root;
  pinorder(t[root].r);
}
void ppostorder(int root){
  if(root==-1)return;
  ppostorder(t[root].l);
  ppostorder(t[root].r);
  cout<<" "<<root;
}
int main(){
  int i,id,root;
  cin>>n;
  for(int i=0;i<n;i++)
    t[i].p=t[i].l=t[i].r=-1;
  for(i=0;i<n;i++){
    cin>>id;
    cin>>t[id].l>>t[id].r;
    if(t[id].l!=-1)t[t[id].l].p=id;
    if(t[id].r!=-1)t[t[id].r].p=id;
  }

  for(int i=0;i<n;i++){
    if(t[i].p==-1)root=i;
  }
  cout<<"Preorder"<<endl;
  ppreorder(root);
  cout<<endl<<"Inorder"<<endl;;
  pinorder(root);
  cout<<endl<<"Postorder"<<endl;
  ppostorder(root);
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3092
import math
a,b,c=map(float,raw_input().split())
crad=math.radians(c)
h=b*math.sin(crad)
s=a*h/2
d=(abs((a**2)+(b**2)-(2*a*b*math.cos(crad))))**(0.5)
l=a+b+d
print s
print l
print h


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int count = 0;
    FOR(i,a,b+1){
        if(c%i==0)count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
vi to[100005];
int deg[100005];
vi par;
int dp0[100005];
int dp[100005];
vi dp_uu;
int n;

int dfs(int u, int ou) {
  par[u] = ou;
  int to_leaf = 0;
  for (int ku : to[u]) {
    if (ku == ou) continue;
    to_leaf = dfs(ku, u) + 1;
  }
  if (to_leaf >= 0) {
    if (deg[ou] == 2 && ou != 0)
      return to_leaf;
    else {
      dp0[u] = to_leaf;
      return -10;
    }
  }
  dp_uu.push_back(u);
  return -10;
}

bool check(int m) {
  rep(i, n) dp[i] = dp0[i];
  //cout << "m=" << m << endl;
  for (int u : dp_uu) {
    vi dists(0);
    for (int ku : to[u]) {
      if (ku == par[u]) continue;
      dists.push_back(dp[ku] + 1);
    }
    sort(dists.begin(), dists.end());
    //cout << "u=" << u << endl;
    //for (int d : dists) cout << d << " ";
    //cout << endl;
    int n_child = dists.size();
    if (dists[n_child - 1] > m) return false;

    //cout << n_child << " " << (n_child & 1) << endl;
    if ((n_child & 1) == 0) {
      bool success = true;
      rep(i, n_child / 2) if (dists[i] + dists[n_child - 1 - i] > m) {
        //cout << "fail" << dists[i] << " " << dists[n_child - 1 - i] << endl;
        n_child--;
        success = false;
        break;
      }
      if (success) {
        dp[u] = 0;
        continue;
      }
    }

    int l = -1, r = n_child;
    while (l + 1 < r) {
      int c = (l + r) / 2;
      int i = 0, j = n_child - 1;
      bool ok = true;
      rep(_, n_child / 2) {
        if (i == c) i++;
        if (j == c) j--;
        if (dists[i] + dists[j] > m) {
          if (c == n_child - 1) return false;
          ok = false;
          break;
        }
        i++;
        j--;
      }
      if (ok)
        r = c;
      else
        l = c;
    }
    dp[u] = dists[r];
  }
  if ((deg[0] & 1) == 0 && dp[0] > 0) return false;
  return true;
}

int main() {
  cin >> n;
  par.resize(n, -1);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  //奇数次数の頂点数を求める
  int n_odd_deg = 0;
  rep(i, n) if (deg[i] & 1 == 1) n_odd_deg++;

  //木DPの為に枝を縮める
  dfs(0, -1);

  //二分探索でBを決める
  int l = -1, r = n;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    //cout << l << " " << m << " " << r << endl;
    if (check(m))
      r = m;
    else
      l = m;
  }

  cout << n_odd_deg / 2 << " " << r << endl;
  return 0;
}


Measured memory_bytes: 10880
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split(" ");

const A = parseInt(input[0], 10);
const B = parseInt(input[1], 10);
const K = parseInt(input[2], 10);

let count = 0;

for (let i = 100; i > 0; i--) {
  if (A % i === 0 && B % i === 0) { count++; }
  if (count === K) {
    console.log(i);
    return;
  }
}


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b)
{
    if((a%b) == 0) return b;
    return GCD(b, a%b);
}

int main()
{
    long long gcd, lcm, n;
    cin >> n;
    gcd = GCD(n, 2);
    lcm = (2*n)/gcd;
    cout << lcm << endl;
    return 0;
}


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

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n;
    cin>>n;
    vector<vector<int> >a(2,vector<int>(3));
    f(i,0,1)
    {
        f(j,0,2)
        {
            cin>>a[i][j];
        }
    }
    vector<int>dp(n+1,0);
    f(i,0,2)
    {
        f(j,0,n)
        {
            dp[j]=max(dp[j],j);
            if(j)
            {
                dp[j]=max(dp[j],dp[j-1]);
            }
            if(j-a[0][i]>=0)
            {
                dp[j]=max(dp[j],dp[j-a[0][i]]+a[1][i]);
            }
        }
    }
    n=dp[n];
    dp.assign(n+1,0);
    f(i,0,2)
    {
        f(j,0,n)
        {
            dp[j]=max(dp[j],j);
            if(j)
            {
                dp[j]=max(dp[j],dp[j-1]);
            }
            if(j-a[1][i]>=0)
            {
                dp[j]=max(dp[j],dp[j-a[1][i]]+a[0][i]);
            }
        }
    }
    cout<<dp[n]<<endl;
    return 0;

}





































Measured memory_bytes: 198504
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    rep(i, A + 1) {
        rep(j, B + 1) {
            rep(k, C + 1) {
                if(i * 500 + j * 100 + k * 50 == X) ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    Vi cnt(26);
    bool ok = true;
    for (const auto& c : S) {
        if (cnt[c - 'a'] != 0) {
            ok = false;
            break;
        }
        ++cnt[c - 'a'];
    }
    cout << (ok ? "yes\n" : "no\n");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
vector<int> G[100000];
void dfs(int v, int p, int dist, vector<ll> &d) {
	d[v] = dist;
	for (int to : G[v]) {
		if (to == p) continue;
		dfs(to, v, dist + 1, d);
	}
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<ll> dist1(N), dist2(N);
	dfs(0, -1, 0, dist1);
	dfs(N - 1, -1, 0, dist2);
	int fen = 0, snu = 0;
	for (int i = 0; i < N; i++) {
		if (dist1[i] <= dist2[i]) {
			fen++;
		}
		else {
			snu++;
		}
	}
	if (fen > snu) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}
}

Measured memory_bytes: 13568
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(input())

# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

R = INT()
G = INT()
add = G - R
print(G + add)

Measured memory_bytes: 5148
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    long int arr[200010]={0};
    long int arrmin;
    long int dmax;
    int n=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%ld",&arr[i]);
        if(i==0){
            arrmin=arr[0];
            continue;
        } 
        if(i==1) dmax=arr[1]-arr[0];
        if(arr[i-1]<=arr[i]){
            dmax=max(arr[i]-arrmin,dmax);
        }else{
            arrmin=min(arr[i],arrmin);
        }        
    } 
    printf("%ld\n",dmax);


    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <double, double> pdd;

#define pb push_back
#define mp make_pair

string s;
int n;
int nxt[26][200010];
vector<int> g[26];
char used[200010];
int p[200010];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> s;
    n = s.length();
    s = "#" + s;
    for(int i = 1; i <= n; i++){
        g[s[i] - 'a'].pb(i);
    }
    for(int i = 0; i < 26; i++) reverse(g[i].begin(), g[i].end());
    for(int i = 0; i <= n; i++){
        if(i != 0) g[s[i] - 'a'].pop_back();
        for(int j = 0; j < 26; j++){
            if(g[j].empty()) continue;
            nxt[j][i] = g[j].back();
        }
    }
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int i = 0; i < 26; i++){
            if(!nxt[i][v]){
                string res;
                res.pb(i + 'a');
                for(; v != 0; v = p[v]){
                    res.pb(s[v]);
                }
                reverse(res.begin(), res.end());
                cout << res << endl;
                exit(0);
            }
            else{
                if(!used[nxt[i][v]]){
                    used[nxt[i][v]] = true;
                    q.push(nxt[i][v]);
                    p[nxt[i][v]] = v;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b, c, x; cin >> a >> b >> c >> x;
    int ans = 0;

    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(500*i + 100*j + 50*k == x) ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(f.readLine());
        String str = new String(f.readLine());
        int r = 0;
        int w = 0;
        for(int i = 0; i < n; i++){
            if(str.charAt(i) == 'R') r++;
            else w++;
        }
        int cnt = 0;
        for(int i = 0; i < r; i++){
            if(str.charAt(i) == 'W') cnt++;
        }
        out.println(cnt);



        out.close();
    }
}


Measured memory_bytes: 36024
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N=scan.next();
        if(N.substring(N.length()-1,N.length()).equals("s")){System.out.println(N+"es");}
        else{System.out.println(N+"s");}
    }
}



Measured memory_bytes: 27032
function Main(input){
var A = new Number(input.split(" ")[0]);
var B = new Number(input.split(" ")[1]);
var C = new Number(input.split(" ")[2]);
var unA = A - B;
var remC = C -unA;
if(remC <= 0){
  console.log(0);
}else{
  console.log(remC);
}
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> red(N),blue(N);
    rep(i,N){
        int a,b;
        cin >> a >> b;
        red[i] = make_pair(a,b);
    }
    rep(i,N){
        int a,b;
        cin >> a >> b;
        blue[i] = make_pair(a,b);
    }
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
    vector<bool> use(N,false);
    int ans = 0;
    int ix;
    rep(i,N){
        ix = -1;
        int tmp = -1;
        rep(j,N){
            if(use[j]==true) continue;
            if(blue[i].first>red[j].first && blue[i].second>red[j].second){
                if(tmp<red[j].second){
                    tmp = red[j].second;
                    ix = j;
                }
            }
        }
        // cout << "i:" << i << " j:" << ix << endl;
        if(ix>=0){
            use[ix]=true;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    int N, T, A;
    cin >> N >> T >> A;
    T *= 1000;
    A *= 1000;
    int h;
    cin >> h;
    int n(0);
    int tt(T - 6 * h);
    int md(abs(tt - A));
    for (int i = 1; i < N; ++i) {
        cin >> h;
        int tt(T - 6 * h);
        if (md > abs(tt - A)) {
            md = abs(tt - A);
            n = i;
        }
    }
    cout << n+1 << endl;
}



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

points = [a, b, c, d, e]
result = []
for point1 in points:
    for point2 in points:
        kyori = point2 - point1
        if kyori > k:
            result.append(True)
        else:
            result.append(False)
if True in result:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		ll a, b, v, w, t;
		cin >> a >> v;
		cin >> b >> w;
		cin >> t;
		if(cin.fail()) break;

		bool ans=false;
		if(v>w)
		{
			ll d=llabs(a-b);
			ll dv=v-w;
			ans=(dv*t>=d);
		}

		if(ans) cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fore(i, init, n) for(long long i = init; i < n; i++)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
 
const int MAXN = 1e4+5;
int sn, tn, dp[MAXN][MAXN];
string s, t;
 
int main() {
    FIN;
 
    cin >> s >> t;
    
    sn = s.size(); 
    tn = t.size();
 
    for(int i = sn-1; i >= 0; i--) {
        for(int j = tn-1; j >= 0; j--) {
            if (s[i] == t[j]) {
                dp[i][j] = 1 + dp[i+1][j+1];           
            } else dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
        }
    }
 
    int i = 0, j = 0;
    string res;
 
    while(i < sn && j < tn) {
        if (s[i] == t[j]) {
            res += s[i];
            i++;j++;
        } else { 
            if (dp[i+1][j] > dp[i][j+1]) i++;
            else j++;
        }
    }
 
    cout << res << endl;
 
}

Measured memory_bytes: 117888
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	ll N, K; 
	cin >> N >> K; 
	vector<int> h(N);
	rep(i, N) cin >> h[i];
	
	ll ans = 0;
	rep(i, N) {
		if(h[i]>=K) ans++;
	}

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

Measured memory_bytes: 640
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, X, Y = iim()
    ans = [N-i-1 for i in range(N-1)]
    X1, Y1 = X-1, Y -1

    xy2 = (X+Y)  // 2
    for i in range(0, xy2):
        x1 = X1 - i
        if x1 < 0: x1 = -x1
        for j in range(xy2, N):
            d1 = j - i - 1
            y1 = Y1-j
            if y1 < 0: y1 = -y1
            d2 = x1 + y1
            if d1 > d2:
                #print((i+1, j+1), d1+1, d2+1, x1, y1)
                ans[d1] -= 1
                ans[d2] += 1

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3444
#include<stdio.h>
int main(void)
{
  double a,b,c,d,e,f;
  double x1,y1;
  int x2,y2;

  while(scanf("%lf %lf %lf %lf %lf %lf", &a,&b,&c,&d,&e,&f)!=EOF){
    x1=(c*e-b*f)/(a*e-b*d);
    y1=(c*d-a*f)/(b*d-a*e);
    x2=x1*10000;
    y2=y1*10000;
    if(x2%10>=5)
      x2=x2-x2%10+10;
    x1=x2/10000.0;
    if(y2%10>=5)
      y2=y2-y2%10+10;
    y1=y2/10000.0;
    printf("%.3f %.3f\n",x1,y1);
  }
  return 0;
}

Measured memory_bytes: 652
///Author:- lazy_coder99

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)
    {
        cout<<b<<'\n';
    }
    else if(a<13 && a>=6)
    {
        cout<<b/2<<'\n';
    }
    else if(a<6)
    {
        cout<<"0"<<'\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int c=0;
  double a,i=1.0;
  scanf("%lf",&a);
  if(a==0)
    printf("0\n");
  else{
  while(a>=i){
    i=i*2.0;
    c++;
  }
  printf("%d\n",c);
  }
  return 0;
  }

Measured memory_bytes: 624
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline
def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
#import numpy as np

from collections import deque

def main():
	n,q=MI()
	E=[[] for _ in range(n+1)]
	X=[0]*(n+1)

	for _ in range(n-1):
		a,b=MI()
		E[a].append(b)
		E[b].append(a)
	for _ in range(q):
		p,x=MI()
		X[p]+=x
	#print(E)

	Q=deque([1])

	while Q:
		#print(Q)
		now=Q.popleft()
		#print(now)
		if E[now]!=[]:
			for i in E[now]:
				if E[i]!=[]:
					Q.append(i)
					X[i]+=X[now]
			E[now]=[]
	print(*X[1:])


if __name__ == "__main__":
	main()

Measured memory_bytes: 49888
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;

  Int sum=0;
  for(Int i=1;i<=n;i++)
    if(i%3 and i%5) sum+=i;

  cout<<sum<<newl;
  return 0;
}


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

typedef complex<double> P;

int main(){
	int n;
	cin >> n;
	while(n--){
		double x,y,r,X,Y,R;
		cin >> x >> y >> r >> X >> Y >> R;
		double d = hypot(x-X,y-Y);
		if( d+R < r - 1e-9 ) {
			cout << 2 << endl;
		}else if(d+r < R - 1e-9) {
			cout << -2 << endl;
		}else if( d > r + R + 1e-9 ){
			cout << 0 << endl;
		}else{
			cout << 1 << endl;
		}
		
	}
}

Measured memory_bytes: 3152
#include<stdio.h>
int main()
{
	int y,m,d,a[5]={1868,1912,1926,1989},b[5]={9,7,12,1},c[5]={7,29,24,7},i;
	char e[5][20]={"pre-meiji","meiji","taisho","showa","heisei"};
	for(;~scanf("%d%d%d",&y,&m,&d);)
	{
		for(i=0;i<4;i++)
			if(y<a[i]||(y==a[i]&&m<b[i])||(y==a[i]&&m==b[i]&&d<=c[i]))
			{
				printf("%s",e[i]);
				i==0?puts(""):printf(" %d %d %d\n",y-a[i-1]+1,m,d);
				break;
			}
		if(i==4)
			printf("%s %d %d %d\n",e[i],y-a[i-1]+1,m,d);
	}
	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  while(cin>>n){
    int cnt = 0;
    rep(i,10)rep(j,10)rep(k,10)rep(l,10)
      if(n == i + j + k + l){
	cnt++;
      }
      cout<<cnt<<endl;


  }
    
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	if (N < 1000){
		cout << "ABC" << endl;
	}else{
		cout << "ABD" << endl;
	} // end if

	return 0;
}

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

using namespace std;

int main()
{
    long long int n , ans  , i , j , k ;
    string s ;
    vector<int> r , g , b;
    cin>>n;
    cin>>s;
    for( i = 0 ; i < n ; i++)
    {
        if(s[i]=='R')r.push_back(i+1);
        else if(s[i]=='G')g.push_back(i+1);
        else b.push_back(i+1);
    }
    ans=r.size()*g.size()*b.size();
    for( i = 0 ; i < r.size() ; i++)
    {
        for( j = 0 ; j < g.size() ; j++ )
        {
            for( k = 0 ; k < b.size() ; k++)
            {
                if(2*r[i]==g[j]+b[k] || 2*g[j]==r[i]+b[k] || 2*b[k]==r[i]+g[j])ans--;
            }
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3636
N = gets.to_i

# 2の階乗の配列（１００未満を用意する）
two_array = []
7.times{|i| two_array << 2 ** i }

# Nより小さくてかつ、Nに近い2の階乗を探す
two_array_abs = two_array.select{|v| v <= N}.map{|v| (v - N).abs}
index = two_array_abs.index(two_array_abs.min)
puts two_array[index]


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

using namespace std;

double arr[] = {-9999999, 0.2, 0.6, 1.1, 999999999};

int main() {
  
  double a, b;
  int cntL[4] = {};
  int cntR[4] = {};
  while(cin >> a >> b) {
    for(int i=0; i<4; i++) {
      if(arr[i] <= a && a < arr[i+1]) cntL[3-i] ++;
      if(arr[i] <= b && b < arr[i+1]) cntR[3-i] ++;
    }
  }
  for(int i=0; i<4; i++)
    cout << cntL[i] << " " << cntR[i] << endl;
  
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

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

    vector<long long> a(n+1);

    long long x;
    for(long long i = 1; i <= n; i++){
        cin >> x;
        a[i] = x;
    }

    long long count = 0;
    for(long long i = 1; i <= n; i++){
        if(a[a[i]] == i){
            count++;
        }
    
    }

    cout << count/2 << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        // ?????????????§???????
        while(true) {
        int n = Integer.parseInt(GetSubStringLine()[0]);
        if (n == 0) {
            break;
        }
        String[] s = GetSubStringLine();
        int[] a = new int[1000];
        int min = 1000000;
        for (int i=0;i<n;i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        for (int i=0;i<n-1;i++) {
            for (int j=i+1;j<n;j++) {
                if (Math.abs(a[i]-a[j]) < min) {
                    min = Math.abs(a[i]-a[j]);
                }
            }
        }
        System.out.println(min);
        }
    }

    public static String[] GetSubStringLine() {
        String s = sc.nextLine();
        return s.split(" ");
    }
}

Measured memory_bytes: 39092
#include<iostream>
#include<string>
#include<set>
#include <iterator>
using namespace std;
template<typename T>
void print(T value)
{
	cout << value << endl;
}

void init() 
{
	
}
int n, m;
string result;
string str;
int main() 
{
	cin >> str >> n;
	for(int i = 0; i < str.length(); i+=n)
	{
		result +=str[i];
	}
	print(result);
	return 0;
}

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

typedef struct{

  double i;

  double j;
  
}Roll;

void kockCurve(int,Roll,Roll);

int main(){

  Roll p1={0.0,0.0},p2={100.0,0.0};

  int n;
 
  scanf("%d\n",&n);
  
  printf("%f %f\n",p1.i,p1.j);

  kockCurve(n,p1,p2);

  printf("%f %f\n",p2.i,p2.j);
   
  return 0;
}

void kockCurve(int n,Roll p1,Roll p2){

  Roll s,t,u;

  if(n == 0)return; 
   
  s.i = (2 * p1.i + 1 * p2.i) / 3;

  s.j = (2 * p1.j + 1 * p2.j) / 3;

  t.i = (1 * p1.i + 2* p2.i) / 3;

  t.j = (1 * p1.j + 2 * p2.j) / 3;

  u.i = (t.i - s.i) / 2 - (t.j - s.j) / 2 * sqrt(3) + s.i;

  u.j = (t.i - s.i) / 2 * sqrt(3) + (t.j - s.j) / 2 + s.j;
 
  kockCurve(n-1,p1,s);

  printf("%f %f\n",s.i,s.j);

  kockCurve(n-1,s,u);

  printf("%f %f\n",u.i,u.j);

  kockCurve(n-1,u,t);

  printf("%f %f\n",t.i,t.j);

  kockCurve(n-1,t,p2);
  
}

Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include<string>
#include <sstream>
using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
string str;
char mozi[66];
string d;
int e;
int use;
char i ='a';
bool flag;
int main()
{
  for(int j = 1; j <=6;j++){
    for(int l = 1;l <=5;l++){
      if(j ==6&&l >=2)
	break;
      mozi[j*10+l] =i++;
	 }
      }
    mozi[62] ='.';
    mozi[63] ='?';
    mozi[64] ='!';
    mozi[65] =' ';
  while(cin>>str){
    string ans;
    if(str.size()%2){
      cout <<"NA"<<endl;
    }else{
      flag = false;
      for(int i = 0;i <str.size();i+=2){
      d = str.substr(i, 2);
      e =toInt(d);
      ans +=mozi[e];
      if(e<11||(e >15&&e <=20)||(e >25&&e <=30)||(e>35&&e <=40)||(e>45&&e <=50)||(e >55&&e <=60)||(e >65)){
	flag = true;
	break;
      }
      }
      if(flag){
	cout <<"NA"<<endl;
      }else{
	cout <<ans<<endl;
      }
    }
    ans.clear();
  }
  return 0;
}

Measured memory_bytes: 1220
#include<cstdio>
int main(){
    char str[1001];
    bool n=false,w=false,s=false,e=false;
    scanf("%s",str);
    for(int i=0;str[i]!='\0';i++){
        if(str[i]=='N')n=true;
        else if(str[i]=='W')w=true;
        else if(str[i]=='S')s=true;
        else e=true;
    }
    printf("%s",((n==s)&&(w==e))?"Yes":"No");
    return 0;
}

Measured memory_bytes: 128
import sys
import math
a,b,c,x,y = map(int,input().split())
ans=0
i=0
j=0
while True:
    if i==x and j==y:
        break
    elif i==x:
        if c*2<b:
            ans+=c*2
        else:
            ans+=b
        j+=1
    elif j==y:
        if c*2<a:
                ans+=c*2
        else:
            ans+=a
        i+=1
    else:
        if c*2<(a+b):
            ans+=c*2
        else:
            ans+=a+b
        i+=1
        j+=1
print(ans)

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

int main()
{
  int ans=0;
  string a,b;
  cin>>a>>b;
  if(a[0]==b[0])ans++;
  if(a[1]==b[1])ans++;
  if(a[2]==b[2])ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import math
N = 10000
N = 1000003
N = 9876543210

N = int(input())


def calculate(n):
    mid = math.ceil(math.sqrt(n))
    res = -1
    while mid>=0:

        if n % mid == 0:
            s = n // mid
            res =  max(len(str(s)),len(str(mid)))
            break
        mid = mid - 1



    if res== -1:
        print(len(str(n)))
    else:
        print(res)


calculate(N)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;
int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int ans = v[N/2] - v[N/2 - 1];
	
	cout << max(ans,0) << endl;
	return 0;
}


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

    int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a>=13){cout<<b<<endl;}
    else if(a>=6&&a<=12){cout<<b/2<<endl;}
    else{cout<<0<<endl;}}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  int A = 0;
  for (int i = 0; i < N; i++) cin >> d.at(i);
  for (int i = 0; i < N; i++) {
    if (d.at(i) != 0) {
      A++;
      int x = d.at(i);
      for(int j = i; j < N; j++) {
        if (d.at(j) == x) d.at(j) = 0;
      }
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
#define INF (1e18)
using namespace std;
typedef pair<int, int> P;

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

int d[55][55];

char board[55][55];
int h, w;

int bfs() {
	queue<P>q;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			d[i][j] = INF;
		}
	}
	q.push(P(1, 1));
	d[1][1] = 0;
	while (!q.empty()) {
		P p = q.front();q.pop();
		if ((p.first == h) && (p.second == w))break;
		for (int i = 0;i < 4;i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if ((1 <= nx) && (nx <= h) && (1 <= ny) && (ny <= w) && (board[nx][ny] != '#') && (d[nx][ny] == INF)) {
				q.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h][w];
}


int main(void) {
	int a, b, q;
	ll x, res = 1000000000000000000;
	cin >> a >> b >> q;
	vector<ll>s(a + 2), t(b + 2);
	s[0] = (ll)-INF;s[a + 1] = (ll)INF;
	t[0] = (ll)-INF;t[b + 1] = (ll)INF;
	for (int i = 1;i <= a;i++)cin >> s[i];
	for (int i = 1;i <= b;i++)cin >> t[i];
	for (int i = 0;i < q;i++) {
		res = INF;
		cin >> x;
		ll v1 = lower_bound(s.begin(), s.end(), x) - s.begin();
		ll v2 = lower_bound(t.begin(), t.end(), x) - t.begin();
		for (ll i = v1 - 1;i <= v1;i++) {
			for (ll j = v2 - 1;j <= v2;j++) {
				ll d1 = (ll)abs(x - s[i]) + abs(t[j] - s[i]);
				ll d2 = (ll)abs(x - t[j]) + abs(t[j] - s[i]);
				res = min(min(res, d1), d2);
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int r= sc.nextInt();
		int g= sc.nextInt();
		int b= sc.nextInt();
		int n = sc.nextInt();
		

		int r_c = n/r;
		int count = 0;
		for(int a = 0; a<=r_c; a++) {
			int n_minus_r = n - a*r;
			
			int g_c = n_minus_r/g;
			for(int c = 0; c<=g_c;c++) {
				int n_minus_rg = n_minus_r - g*c;
				if (n_minus_rg % b == 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;
int maxcount;
int dx[] = {1, 0};
int dy[] = {0, 1};

void dfs(pair<int, int> &s, pair<int, int> &g, vector<vector<int> > &mata, vector<vector<int> > &table){
	if(s.first==g.first&&s.second==g.second){
		maxcount++;
		return;
	}
	table[s.second][s.first] = 1;
	for(int i = 0; i < 2; i++){
		if((s.first+dx[i]<0||s.first+dx[i]>=table[0].size())||(s.second+dy[i]<0||s.second+dy[i]>=table.size())) continue;
		bool f = false;
		for(int j = 0; j < mata.size(); j++){
			if(s.first==mata[j][0]&&s.second==mata[j][1]&&s.first+dx[i]==mata[j][2]&&s.second+dy[i]==mata[j][3]){
				f = true;
			}
			if(s.first==mata[j][2]&&s.second==mata[j][3]&&s.first+dx[i]==mata[j][0]&&s.second+dy[i]==mata[j][1]){
				f = true;
			}
		}
		if(f || table[s.second+dy[i]][s.first+dx[i]]) continue;
		pair<int, int> tmp(s.first+dx[i], s.second+dy[i]);
		dfs(tmp, g, mata, table);
	}
	table[s.second][s.first] = 0;
}

int main(){
	int n = 0;
	cin >> n;
	while(n--){
		pair<int, int> s(0, 0);
		pair<int, int> g;
		cin >> g.first >> g.second;
		vector<vector<int> > table(g.second+1, vector<int>(g.first+1, 0));
		int matanum = 0;
		cin >> matanum;
		vector<vector<int> > mata(matanum, vector<int>(4, 0));
		for(int i = 0; i < matanum; i++){
			cin >> mata[i][0] >> mata[i][1] >> mata[i][2] >> mata[i][3];
		}
		maxcount = 0;
		dfs(s, g, mata, table);
		if(maxcount) cout << maxcount << endl;
		else cout << "Miserable Hokusai!" << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <algorithm>
#include <iostream>
#include <cstdint>
#include <cmath>
#include <numeric>

int main() {
    int N;
    std::int64_t a[200000];

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

    std::uint64_t diff = UINT64_MAX;
    std::int64_t x = 0;
    std::int64_t y = std::accumulate(a, a+N, (std::int64_t)0);

    for (int i = 0; i < N-1; i++) {
        x += a[i];
        y -= a[i];
        std::uint64_t d = std::abs(x-y);
        diff = std::min(d, diff);
    }

    std::cout << diff << std::endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String input = sc.nextLine();
			String[] array = input.split(" ");
			int h = Integer.parseInt(array[0]);
			int w = Integer.parseInt(array[1]);
			if (h == 0 && w == 0) {
				System.exit(0);
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if ((i + j) % 2 == 0) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");

		}
	}
}

Measured memory_bytes: 36620
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int A,B,C,X,Y,ans=100000000000;
  cin >> A >> B >> C >> X >> Y;
  for(int i=0;i<=max(X,Y);i++){
    if(X>=i && Y>=i) chmin(ans,A*(X-i)+B*(Y-i)+2*C*i);
    else if(X>=i && Y<i) chmin(ans,A*(X-i)+2*C*i);
    else chmin(ans,B*(Y-i)+2*C*i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,n;
  cin>>h>>w>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  vector<vector<int>> c(h,vector<int>(w));
  int x=0;
  for(int i=0;i<h;i++){
    bool p=(i%2==0);
    for(int j=(p?0:w-1);j<w&&j>=0;j+=(p?1:-1)){
      c.at(i).at(j)=x+1;
      a.at(x)--;
      if(a.at(x)==0)
        x++;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      cout<<c.at(i).at(j)<<(j+1<w?" ":"");
    cout<<endl;
  }
}

Measured memory_bytes: 384