akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N; cin >> N;
    ll A[200001];
    ll maxx1 = 0, maxx2 = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if(maxx1 <= A[i]){
            maxx2 = maxx1;
            maxx1 = A[i];
        } else if(maxx2 < A[i]){
            maxx2 = A[i];
        }
    }
    for (int i = 0; i < N; i++) {
        if(A[i] == maxx1){
            cout << maxx2 << endl;
        } else {
            cout << maxx1 << endl;
        }
    }
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll ans=0,k;
int main(){
	cin>>k;
	for(int a=1;a<=k;a++){
		for(int b=1;b<=k;b++){
			for(int c=1;c<=k;c++){
				ans+=__gcd(a,__gcd(b,c));
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int

let choice ok ng bool = if bool then ok else ng

readIntArray ()
|> fun [| _; m |] ->
    let x = readIntArray ()
    let all = x |> Array.reduce (+)
    x
    |> Array.sortDescending
    |> Array.take m
    |> Array.rev
    |> Array.head
    |> fun x -> x * 4 * m >= all
|> choice "Yes" "No"
|> printfn "%s"


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

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int last = 0, sx = 0, sy = 0;
    int ok = 1;
    for (int i = 0; i < n; ++i) {
        int t, x, y;
        scanf("%d %d %d", &t, &x, &y);
        int dx = abs(x-sx);
        int dy = abs(y-sy);
        int dz = dx+dy;
        int dt = abs(t-last);
        if (dz % 2 == dt % 2 && dz <= dt) {
            
        }
        else {
            ok = 0; 
        }
        last = t;
        sx = x;
        sy = y;
    }
    if(ok)puts("Yes");
    else puts("No");
}


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

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

struct UnionFind{
    vector<ll> par;
    vector<ll> num;

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

    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;
        num[ry] += num[rx];
        num[rx] = 0;
    }

    ll size(ll x){
        return num[x];
    }

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


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

    vector<ll> a; a.resize(m);
    vector<ll> b; b.resize(m);

    REP(i, m){
        cin >> a[i] >> b[i];
    }

    UnionFind tree(n);

    vector<ll> ans(m,0);
    ans[m-1] = n*(n-1)/2;

    REP(i, m-1){
        ll x = a[m-i-1]-1;
        ll y = b[m-i-1]-1;
        if (ans[m-i-1]==0){
            ans[m-i-2] = 0;
        }
        else if (tree.same(x, y)){
            ans[m-i-2] = ans[m-i-1];
        }
        else{
            ll rx = tree.root(x);
            ll ry = tree.root(y);
            ans[m-i-2] = ans[m-i-1] - tree.size(rx)*tree.size(ry);
            tree.unite(x, y);
        }
    }

    REP(i, m){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long ll;
const int MAXN = 0;

int main()
{
	//freopen("input.in", "r", stdin);
	ll N, M;
	cin >> N >> M;
	ll ans = 0;
	ll x = min(N, M/2);
	ans += x;
	N -= x;
	M -= 2 * x;
	ans += M / 4;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
using namespace std;
bool cmp(pair<int,int> &fir,pair<int,int> &las){
    if(fir.first<las.first)return true;
    else return false;
}
int32_t main(){
    int n,d,a;cin>>n>>d>>a;
    vector<pair<int,int>> arrmv;
    for(int i=0;i<n;i++){
        int x,y;cin>>x>>y;
        arrmv.push_back({x,(int)ceil((double)y/(double)a)});
    }
    sort(arrmv.begin(),arrmv.end());
    vector<int> dif(arrmv.size()+1,0);
    int ans=0;
    vector<int> sha;
    for(int i=0;i<(int)arrmv.size();i++)sha.push_back(arrmv[i].first);
    for(int i=0;i<(int)arrmv.size();i++){
        if(i)dif[i]+=dif[i-1];
        arrmv[i].second+=dif[i];
        if(arrmv[i].second<=0)continue;
        else{
            ans+=arrmv[i].second;
            int lpos=upper_bound(sha.begin(),sha.end(),arrmv[i].first+2*d)-sha.begin();
            dif[i]-=arrmv[i].second;
            dif[lpos]+=arrmv[i].second; 
        }
    }
    cout<<ans<<endl;
	return 0;
}

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

int main(void){
    char imp[100001];
    char five[5] = {0};
    char six[6] = {0};
    char seven[7] = {0};
    char dr[] = {'r','e','m','a','e','r','d'};
    char dm[] = {'m','a','e','r','d'};
    char ee[] = {'e','s','a','r','e'};
    char er[] = {'r','e','s','a','r','e'};
    int count = 0;
    fgets(imp,sizeof(imp),stdin);
    for (int i = 0; imp[i] != 0; ++i)count++;
    count -= 1;
    char str[count];
    for (int j = 0; j < count; ++j) {
        int index;
        index = count - 1 - j;
        str[j] = imp[index];
    }

    int before;
    before = count;

    do{
        if (count >= 7){
            for (int i = 0; i < 7; ++i){
                int temp;
                temp = i + before - count;
                seven[i] = str[temp];
            }
            if (strncmp(seven,dr,7) == 0){
                count -= 7;
                continue;
            }
        }

        if (count >= 6){
            for (int i = 0; i < 6; ++i){
                int temp;
                temp = i + before - count;
                six[i] = str[temp];
            }
            if (strncmp(six,er,6) == 0){
                count -= 6;
                continue;
            }
        }

        if (count >= 5){
            for (int i = 0; i < 5; ++i){
                int temp;
                temp = i + before - count;
                five[i] = str[temp];
            }
            if (strncmp(five,dm,5) == 0 || strncmp(five,ee,5) == 0){
                count -= 5;
                continue;
            }
        }
        break;
    }while (count > 0);

    if (count == 0){printf("YES");}
    else{printf("NO");}

    return 0;
}



Measured memory_bytes: 1816
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

N = int(input())
A = sorted(list(map(int, input().split())))
t = 0
for i in range(N-1):
    if 2*A[i] < A[i+1]:
        t = i+1
    A[i+1] += A[i]
print(N-t)


Measured memory_bytes: 15020
n=int(input())
a=list(map(int,input().split()))

l=[]
l.append(0)
l.append(0)
r=[]
r.append(a[n-1])
r.append(a[n-1])
g=[]

def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)


for i in range(1,n):
  l.append(gcd(l[i],a[i-1]))
  r.append(gcd(r[i],a[n-1-i]))
  
r[0]=l[n]

for j in range(0,n):
  g.append(gcd(l[j+1],r[n-j-1]))

print(max(g))    
  
  


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

int main() {
  int N;
  cin >> N;
  int i = 0;

  while (i < N) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    i++;
  }

  if (i == N) {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int digit(int a, int b){
  int d=0;
  int tmp = a+b;
  while(tmp > 0){
    tmp = tmp/10;
    d++;
  }
  return d;
}

int main(){
  int a,b;
  while(scanf("%d %d",&a,&b)!=EOF)
    printf("%d\n",digit(a,b));
  return 0;
}

Measured memory_bytes: 600
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let v: Vec<i32> = (0..n).map(|_| read()).collect();
    let c: Vec<i32> = (0..n).map(|_| read()).collect();
    let ans = v.iter().zip(c.iter())
        .map(|(x, y)| x - y)
        .filter(|&x| x > 0)
        .sum::<i32>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
// AOJ 2040 Sort the Panels
// 2018.3.13 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 300000
typedef struct { int s; char p; char t; } QUE;
QUE que[QMAX]; int qsize, qmax;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, char p)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].p = p;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define ABS(a)  ((a)>=0?(a):-(a))
char dist[1<<16][16];

int dijkstra(int n, int nb, int start, int goal)
{
	int i, j, k, m, s, t, p, ns, nt, nw;
	int pi, pj;

	memset(dist, 75, sizeof(dist));
	qsize = 0;
	t = -1, nw = n - nb;
	for (p = 0; p < n; p++) dist[start][p] = 0, enq(start, 0, p);
	while (qsize) {
		s = que[0].s, t = que[0].t, p = que[0].p, deq();
		if (s == goal) break;

		if (dist[s][p] < t) continue;

		for (k = i = 0; k < nb; i++) if (s & (1<<i)) { k++, pi = ABS(p-i);
			pi = ABS(p-i);
			for (m = j = 0; m < nw; j++) if (!(s & (1<<j))) { m++;
				ns = s ^ (1<<i) ^ (1<<j);
				if (pi < (pj=ABS(p-j))) {
					nt = t + pi + ABS(i-j);
					if (dist[ns][j] > nt) dist[ns][j] = nt, enq(ns, nt, j);
				} else {
					nt = t + pj + ABS(i-j);
					if (dist[ns][i] > nt) dist[ns][i] = nt, enq(ns, nt, i);
				}
			}
		}
	}
	return t;
}

int calc(char *s) { int res=0; while (*s > ' ') res = (res<<1)|(*s++ == 'B'); return res; }

int main()
{
	int n, nb, start, goal;
	char buf[20], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		fgets(p=buf, 20, stdin); nb = 0; while (*p > ' ') if (*p++ == 'B') nb++;
		start = calc(buf);
		fgets(buf, 20, stdin), goal = calc(buf);
		if (nb > n-nb) {
			nb = n-nb;
			start = ~start & ((1<<n)-1), goal = ~goal & ((1<<n)-1);
		}
		printf("%d\n", dijkstra(n, nb, start, goal));
	}
	return 0;
}


Measured memory_bytes: 4308
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///

void solve(){
	ll n; cin>>n;
	if(n>=30) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}

/****************ALHAMDULILLAH******************/


Measured memory_bytes: 3612
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, K;
lint arr[200000];
lint rev_arr[200000];

lint cnt_mul(lint a) {
	lint cnt = 0;
	REP(i, N) {
		if (arr[i] == 0) {
			if (a >= 0) cnt += (N - i - 1);
		}else if (arr[i] > 0) {
			lint num = a / arr[i];
			if ((a % (arr[i])) != 0 && a < 0) {
				num--;
			}
			cnt += (upper_bound(arr + i + 1, arr + N, num) - (arr + i + 1));
		}
		else {
			lint num = -a / arr[i];
			if (((-a) % (arr[i])) != 0 && a < 0) {
				num--;
			}
			cnt += (upper_bound(rev_arr, rev_arr + N - i - 1, num) - (rev_arr));
		}
	}
	return cnt < K;
}

int main() {
	cin >> N >> K;
	REP(i, N) {
		cin >> arr[i];
		rev_arr[i] = -arr[i];
	}
	sort(arr, arr + N);
	sort(rev_arr, rev_arr + N);
	lint lb = -1e18 - 1, ub = 1e18 + 1;
	while (ub - lb > 1) {
		lint mid = (lb + ub) / 2;
		if (cnt_mul(mid)) lb = mid;
		else ub = mid;
	}
	cout << ub << endl;
}

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

#define MOD ((int)1e9+7)

typedef vector <int> vi;

int main() {
    int li, co;
    cin >> li >> co;
    
    char m[li][co];
    for (int i = 0; i < li; i++) {
        for (int j = 0; j < co; j++) {
            cin >> m[i][j];
        }
    }
    
    int dp[li+1][co+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    
    for (int i = 0; i < li; i++) {
        for (int j = 0; j < co; j++) {
            if (m[i][j] != '#') {
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
                dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
            }
        }
    }
    
    // for (int i = 0; i < li; i++) {
    //     for (int j = 0; j < co; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    
    cout << dp[li-1][co-1] << endl;
}


Measured memory_bytes: 8476
A, B, C = [int(i) for i in input().split()]
ans = 0
a, b, c = A, B, C
while(a % 2 == 0 and b % 2 == 0 and c % 2 == 0):
    ans += 1
    ha = int(a / 2)
    hb = int(b / 2)
    hc = int(c / 2)
    a = hb + hc
    b = hc + ha
    c = ha + hb
    if a == A and b == B and c == C:
        ans = -1
        break
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 

 
const int N=2e5+100;
//ll a[200000];
 
 
map<int,int>mr[1200],mc[1200];
#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;

int dx[4] = {1 , 0 , 0 , -1} ;
int dy[4] = {0 , 1 , -1 , 0} ;
ll vis[70][60];

void finis(){cout<<-1;}

int main()
{  ios::sync_with_stdio(0);
    cin.tie(0);
  
     ll a[9];
      for(int i=0;i<5;i++){
        
         cin>>a[i];if(a[i]==0){cout<<i+1;return 0;}
        
         
      
      
   } 
        
       
   

      
   
  
 
 
 
 
 
 
}


Measured memory_bytes: 3728
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	string s,t;
	cin>>s;
	int l=s.length();
	s+='E';
	s+='E';
	LL ans=0;
	FOR(i,0,l){
		if(s[i]=='A'){
			int nw=i;
			FOR(j,i+1,l){
				nw=j;
				if(s[j]=='B'&&s[j+1]=='C'){
					j++;
					nw=j;
				}else if(s[j]=='A'){
					nw=j;
				}else{
					nw--;
					break;
				}
			}
			//cerr<<i<<" "<<nw<<endl;
			LL ac=0,bc=0;
			FORD(j,nw+1,i){
				if(s[j]=='C'&&s[j-1]=='B'){
					bc++;
				}else if(s[j]=='A'){
					ans+=bc;
				}
			}
			i=nw;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
N, M = gets.chomp.split.map(&:to_i)
keys = Array.new(M) do
  price, _num = gets.chomp.split.map(&:to_i)
  holes = gets.chomp.split.map(&:to_i).reduce(0) {|x, i| x | 2 ** i.pred}
  [price, holes]
end

infinity = 2 ** 31
m = Array.new(2 ** N, infinity).tap {|x| x[0] = 0}

keys.each do |cost, holes|
  m.size.times do |fill|
    m[fill | holes] = [m[fill] + cost,  m[fill | holes]].min
  end
end

puts m[-1] >= infinity ? -1 : m[-1]


Measured memory_bytes: 2172
#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>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
bool prime[51010];
int main()
{
  for(int i = 2;i <51011;i++){
    prime[i] = true;
  }
  prime[0] = false;
  prime[1] = false;
  for(int j = 2;j*j <51011;j++){
    if(prime[j]){
      for(int i =2*j;i <51011;i+=j){
	prime[i] = false;
      }
    }
  }
  int x;
  
  while(cin>>x){
 
    for(int i = x-1;i >1;i--){
      if(prime[i]){
	cout << i;
	break;
      }
    }
    bool flag = false;
    for(int i = x+1;i <51011;i++){
      if(prime[i]){
	cout <<" "<<i <<endl;
	flag = true;
	break;
      }
    }
    if(!flag){
      cout <<endl;
    }

  }
  return 0;
}

Measured memory_bytes: 1208
n = int(input())

for k in range(1,n + 2):
    if k * (k - 1)  == 2 * n:
        print("Yes")
        break
    if k * (k - 1) > 2 * n:
        print("No")
        exit()

print(k)
answer = [[] for _ in range(k)]

num = [[i,j] for i in range(k) for j in range(i+1,k)]

for i,st in enumerate(num):
    s,t = st
    answer[s].append(i + 1)
    answer[t].append(i + 1)

for ans in answer:
    print(k-1,*ans)


Measured memory_bytes: 24904
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

class Ope{
public:
    int y1,x1,y2,x2;
};
int a[500][500];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    REP(i,h)REP(j,w)cin>>a[i][j];
    vector<Ope> ope;

    REP(i,h)REP(j,w)
    {
        bool odd = a[i][j]%2 != 0;
        if(odd)
        {
            a[i][j]--;
            if(j != w-1)
            {
                Ope o;
                o.y1 = i + 1;
                o.x1 = j + 1;
                o.y2 = i + 1;
                o.x2 = j + 1 + 1;
                ope.PB(o);
                a[i][j+1]++;
            }
            else if(i != h-1)
            {
                Ope o;
                o.y1 = i + 1;
                o.x1 = j + 1;
                o.y2 = i + 1 + 1;
                o.x2 = j + 1;
                ope.PB(o);
                a[i+1][j]++;
            }
        }
    }

    PUTS(ope.size());
    REP(i,ope.size())
    {
        Ope o = ope[i];
        printf("%d %d %d %d\n", o.y1, o.x1, o.y2, o.x2);
    }
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
#define PI 3.14159265358979323846264338327950L
typedef unsigned long long uint64;
using namespace std;
using ll = long long;
int main(){
  int a;
  cin >> a;
  string s,t;
  cin >> s >> t;
  rep(i,s.length()){
    cout << s[i] << t[i] ;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3572
import bisect
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in iter(input,'0'):x=int(x);print(sum(a[x-d]>0 for d in p[:bisect.bisect(p,x//2)]))


Measured memory_bytes: 7796
#!/usr/bin/env python3

def main():
    A, B, K = map(int, open(0).read().split())
    if (A > K):
        print(A - K, B)
    elif (B - (K - A) >= 0):
        print(0, B - (K - A))
    else:
        print(0, 0)



main()

Measured memory_bytes: 2940
package main

import "fmt"

func main() {

	var r, c, a_ij, tot int
	tot = 0

	fmt.Scan(&r,&c)
	a := make([][]int, r)
	for i:=0; i<r; i++ {
		a[i] = make([]int, c)
	}
	rsum := make([]int, r)
	csum := make([]int, c)

	for i:=0; i<r; i++ {
		for j:=0; j<c; j++ {
			fmt.Scan(&a_ij)
			a[i][j] = a_ij
			rsum[i] += a_ij
			csum[j] += a_ij
			tot += a_ij
		}
	}
	for i:=0; i<r; i++ {
		for j:=0; j<c; j++ {
			fmt.Print(a[i][j]," ")
		}
		fmt.Print(rsum[i],"\n")
	}
	for j:=0; j<c; j++ {
		fmt.Print(csum[j]," ")
	}
	fmt.Print(tot,"\n")
}


Measured memory_bytes: 1800
#include<bits/stdc++.h>
using namespace std;
int main()
{
int A;
int B;
cin>>A;
cin>>B;
if(A<=13 && B<=13 && A!=1 && B!=1){
  if(A>B){
    cout<<"Alice";
  }
 else if(B>A){
     cout<<"Bob";
  }
  else if(A==B){
     cout<<"Draw";
  }

}
else if(A<=13 && A!=1 && B==1){
 cout<<"Bob";

}
else if(B<=13 && B!=1 && A==1){
 cout<<"Alice";
}
else{
 cout<<"Draw";
}
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void) {
	int x[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int out;
	scanf("%d", &out);

	printf("%d\n", x[out-1]);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main(){
  string str1,str2,str3;
  cin >> str1 >> str2 >> str3 ;
  if (str1[str1.size()-1]==str2[0]&&str2[str2.size()-1]==str3[0]){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
}


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        bool flag = true;
        for(int j = 0; j < i; j++) {
            if(h[i] < h[j]) {
                flag = false;
            }
        }
        if(flag) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	static double[] shou ={0.0, 0.5,0.25,0.125,0.0625};
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		label:while(true){
			double d = cin.nextDouble();
			if(d < 0.0){
				break;
			}
			int dd = (int)d;
			String seisuubu = Integer.toBinaryString(dd);
			if(seisuubu.length() > 8){
				System.out.println("NA");
				continue;
			}
			d = d - (double)dd;
			//System.out.println(d + " " + dd);
			for(int i = seisuubu.length();i<8;i++){
				seisuubu = "0"+seisuubu;
			}
			if(d==0.0){
				System.out.println(seisuubu + "."  + "0000");
				continue;
			}
			for(int i = 0;i<2;i++){
				for(int j = 0;j<2;j++){
					for(int k = 0;k<2;k++){
						for(int h = 0;h<2;h++){
							double value = 0.0;
							if(i==1){
								value+=shou[1];
							}
							if(j==1){
								value+=shou[2];
							}
							if(k==1){
								value+=shou[3];
							}
							if(h==1){
								value+=shou[4];
							}
							if(value==d){
								System.out.print(seisuubu + ".");
								System.out.println(i+""+j+""+k+""+h);
								continue label;
							}
						}
					}
				}
			}
			System.out.println("NA");
		}

	}

}

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

using namespace std;

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

  long long n, a;
  cin >> n;
  vector<long long> sum(n, 0);
  cin >> a; sum[0] = a;
  for (int i = 1; i < n; ++i) {
    cin >> a;
    sum[i] = sum[i-1] + a;
  }
  long long res = 1e18;
  for (long long i = 0; i < n-1; ++i) {
    long long tmp = abs(sum[n-1]-2*sum[i]);
    if (tmp < res) res = tmp;
  }
  cout << res << endl;


  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
const int N=1e6+10;
int n;
string s;

int main(){
  cin>>n;
  cin>>s;
  if(n%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
   else{
    for(int i=0;i<=((n/2)-1);i++){
        if(s[i]!=s[(n/2)+i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, tmp, ans = 1;
    cin >> N;
    vector<int> a(N);
    
    for(int i=0; i<N; i++){
	cin >> a[i];
    }
    tmp = a[0];
    for(int i=0; i<N+2; i++){
	if(tmp ==2)
	    break;
	ans ++;
	tmp = a[tmp-1];
	if(i == N+1)
	    ans = -1;	
    }
	

    cout << ans << endl;

}



Measured memory_bytes: 768
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N, A, B;
      cin >> A >> B;
     N=A*B;
      if (N%2==1) {
        cout << "Odd" << endl;
      }
      else{
        cout << "Even" <<endl;
      }
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i = 0; i < h; ++i)  cin >> s[i];

    int ans = 0;
    for(int bit = 0; bit < (1 << (h + w)); ++bit){
        int c = 0;
        for(int i = 0; i < h; ++i){
            if(bit >> i & 1)    continue;
            for(int j = 0; j < w; ++j){
                if((bit >> (h + j)) & 1)    continue;
                if(s[i][j] == '#')  ++c;
            }
        }
        if(c == k)  ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<stdio.h>
#pragma GCC optimize("O2")
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int A,B,C,N,Q,num[100000]={0};static long long sum=0;
  N=IN();
  while(N--){A=IN();num[A-1]++;sum+=A;}
  Q=IN();
  while(Q--)
  {
    B=IN()-1;C=IN()-1;
    sum+=1ll*num[B]*(C-B);
    num[C]+=num[B];num[B]=0;
    printf("%lld\n",sum);
  }
}

Measured memory_bytes: 1984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int K,X;
    cin >> K >> X;
    if(500 * K >= X) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int main(){
	int a,b,g;
	scanf("%d%d",&a,&b);
	g=gcd(a,b);
	a/=g,b/=g;
	printf("%d\n",1+(a+b-1)*g);
}

Measured memory_bytes: 1844
def digits_parade(S: str)->int:
    MOD = 10**9 + 7
    DIV = 13
    # dp[i][j] = S の i 桁目までを利用してできる整数で 13 で割ったあまりが j になる組み合わせ
    dp = [[0] * DIV for _ in range(len(S)+1)]
    dp[0][0] = 1

    # digit: 10^n % 13 を計算するための変数
    digit = 1

    for i, c in enumerate(reversed(S)):
        if c == '?':
            for n in range(10):
                d = (n * digit) % DIV
                for j in range(DIV):
                    dp[i+1][(j+d) % DIV] += dp[i][j]
                    dp[i+1][(j+d) % DIV] %= MOD
        else:
            d = (int(c) * digit) % DIV
            for j in range(DIV):
                dp[i+1][(j+d) % DIV] += dp[i][j]
                dp[i+1][(j+d) % DIV] %= MOD

        digit = (digit * 10) % DIV

    return dp[len(S)][5]


if __name__ == "__main__":
    S = input()
    ans = digits_parade(S)
    print(ans)


Measured memory_bytes: 61916
#include<stdio.h>
#include<string.h>
void mozi_sort(char str[], int length) {
	int tmp[10000] = {};
	int memo = 0;
	for (int i = 0; i < length; i++) {
		tmp[(int)str[i]]++;
	}
	for (int i = 0; i < 256; i++) {
		while (tmp[i] > 0) {
			str[memo] = (char)i;
			memo++;
			tmp[i]--;
		}
	}
}
//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}
int main() {
	long long int a, b, c, d, n, m, num[2000][2] = {}, result = 0;
	char str[200005];
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	if (b <= c || d <= a) { printf("0"); }
	else if (c <= a && b <= d) {
		printf("%lld", b - a);
	}
	else if (a <= c && d <= b) {
		printf("%lld", d - c);
	}
	else if(c<=b&&b<=d){
		printf("%lld", b-c);
	}
	else {
		printf("%lld", d-a);
	}
			
}



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

typedef pair<int, int> P;
typedef pair<P, int> pi;

int main() {
	vector<pi> data;
	for(int y = 1; y <= 150; ++y){
		for(int x = y + 1; x <= 150; ++x){
			data.push_back(pi(P(x * x + y * y, y), x));
		}
	}
	sort(data.begin(), data.end());
	int h, w;
	while(cin >> h >> w && (h || w)){
		int base = h * h + w * w;
		auto it = upper_bound(data.begin(), data.end(), pi(P(base, h), w));
		cout << (*it).first.second << " " << (*it).second << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
import sys
import numpy as np
n = int(input())
s = np.array([int(input()) for _ in range(n)])
if len(s[s % 10 == 0]) == n:
    print(0)
    sys.exit()
if s.sum() % 10:
    print(int(s.sum()))
else:
    t = s[~(s % 10 == 0)].min()
    print(int(s.sum() - t))

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

using namespace std;

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

int main(){
	int n,m;
	cin>>n>>m;
	multiset<int>s;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		s.insert(x);
	}
	while(m--){
		auto it=s.end();
		it--;
		int j=*it;
		s.erase(it);
		s.insert(j/2);
	}
	long long ans=0;
	for(auto i:s){
		ans+=i;
	}
	cout<<ans;
	
}
//1

Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
#N, K = (int(i) for i in input().split())
#B = [int(x) for x in input().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
N = int(input())
A = [int(x) for x in input().split()]

premin = A[0]
cur = 1000
for i in range(1, N):
    if A[i] > premin:
        cur = cur + (cur//premin)*(A[i]-premin)
        premin = A[i]
    premin = min(premin, A[i])

print(cur)


Measured memory_bytes: 61904
# -*- coding: utf-8 -*-

from sys import stdin
    
def calc(n, s):
    s2 = [ c == '#' for c in s]
    total = sum(s2)
    _min = min(total, n-total)
    tr = 0
    for i,c in enumerate(s2):
        if c:
            tr += 1
        op = 2*tr+n-(i+1)-total
        if op < _min:
            _min = op

    return _min

def main():
    n = int(stdin.readline().rstrip())
    s = stdin.readline().rstrip()
    ans = calc(n, s)
    print(ans)
    
if __name__=='__main__':
    main()

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

int main()
{
	int M[100][100];
	int n, u, k, v;
	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			M[i][j] = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> u >> k;
		u--;
		for(int i = 0; i < k; i++)
		{
			cin >> v;
			v--;
			M[u][v] = 1; 
		}
	}
	
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(j == 0)
			cout << M[i][j];
			else
			{
				cout << " " << M[i][j];
			}
		}
		cout << endl;
	}
} 



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

int main(){
    string O, E, password;
    cin>>O>>E;
    string::iterator o = O.begin();
    string::iterator e = E.begin();
    //char temp[2] = {'\0','\0'};
    while(o != O.end()){
        //temp[0] = *o;
        password.push_back(*o);
        //temp[0] = *e;
        if(*e == '\0')
            break;
        password.push_back(*e);
        o++;
        e++;
    }
    cout<<password;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	stack<int> S1;
	stack< pair<int, int> > S2;
	char ch;
	int sum = 0;
	for (int i=0; cin >> ch; i++) {
		if(ch == '\\') S1.push(i);
		else if(ch == '/' && S1.size()>0) {
			int j = S1.top();
			S1.pop();
			int a = i - j;
			sum += a;
			while (S2.size() > 0 && S2.top().first > j) {
				a += S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	
	vector<int> ans;
	while (S2.size() > 0) {
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(),ans.end());
	cout << sum << endl;
	cout << ans.size();
	for( int i = 0; i < ans.size(); i++) {
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
	
	return 0;
	
}

Measured memory_bytes: 3196
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    import fractions
    import math
    from collections import Counter
    n = int(readline())
    counter = Counter()
    a0, b0 = 0, 0
    lonely = 0

    for i in range(n):
        a, b = map(int, readline().split())
        if a == 0 and b == 0:
            lonely += 1
        elif a == 0:
            a0 += 1
        elif b == 0:
            b0 += 1
        else:
            fr = fractions.Fraction(a, b)
            counter[(fr.numerator, fr.denominator)] += 1

    ans = 1  # 最後に
    keys = list(counter.keys())
    for key in keys:
        nm1, dn1 = key[0], key[1]
        cnt1 = counter[(nm1, dn1)]
        nm2, dn2 = -(nm1 // abs(nm1)) * dn1, abs(nm1)
        cnt2 = counter[(nm2, dn2)]
        ans = ans * ((pow(2, cnt1, MOD) - 1) + (pow(2, cnt2, MOD) - 1) + 1)
        ans %= MOD
        counter[(nm1, dn1)] = 0
        counter[(nm2, dn2)] = 0

    ans *= ((pow(2, a0, MOD) - 1) + (pow(2, b0, MOD) - 1) + 1)
    ans %= MOD
    ans += lonely
    ans -= 1
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


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

int prime(int temp);

int main(void){
int n,data[10005],i,c=0;

scanf("%d",&n);
for(i=0;i<n;i++){scanf("%d",&data[i]);}
for(i=0;i<n;i++){
	c=c+prime(data[i]);
	}
printf("%d\n",c);
	return 0;
}

int prime(temp){
	int i;
	if(temp==2){return 1;}
	if(temp<2 || temp%2==0){return 0;}
	i=3;
	while( i <= (int)sqrt(temp)){
		if(temp%i==0){return 0;}
		i=i+2;
	}
	return 1;
}

Measured memory_bytes: 632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <functional>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <ctime>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <sstream>
typedef std::pair <int, int> pii;
typedef long long LL;
const int INF = (int)1e9;
std::string s;
long long res;
void calc (int idx, long long sum)
{
	if (idx == s.size())
	{
		res += sum;
		return;
	}
	long long val = 0;
	for (int i = idx; i < (int)s.size(); i++)
	{
		val *= 10;
		val += s[i] - '0';
		calc (i + 1, sum + val);
	}
}
int main()
{
	std::cin >> s;
	calc (0, 0);
	std::cout << res << std::endl;
}

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

const int N = 500009;
const int mod = 1000000007;

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

int r;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin>>r;
	cout<<(r*r)<<endl;
}	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
  
int main(){
    u_int a;    // width
    u_int b;    // height
    while(std::cin >> a >> b){
        if(a == 0 && b == 0){
            break;
        }
         
        // initialization
        std::vector<std::vector<u_int>> path(a+1, std::vector<u_int>(b+1, 1));
         
        // construction
        u_int n;
        std::cin >> n;
        for(u_int i = 0; i < n; ++i){
            u_int x, y;
            std::cin >> x >> y;
            path[x][y] = 0;
        }
         
        // out path
        for(u_int i = 0; i < a+1; ++i) path[i][0] = 0;
        for(u_int i = 0; i < b+1; ++i) path[0][i] = 0;
         
        // calc the number of path
        for(u_int x = 1; x <= a; ++x){
            for(u_int y = 1; y <= b; ++y){
                if(path[x][y] != 0 && !(x == 1 && y == 1)){
                    path[x][y] = path[x-1][y] + path[x][y-1];
                }
            }
        }
         
        std::cout << path[a][b] << std::endl;
          
    }
    return 0;
}

Measured memory_bytes: 3084
#include <iostream>

using namespace std;

int main()
{

	int h,w;
	cin >> h >> w;
	
	char picture[h][w];
	
	for(int i=0; i<h; i++){
		for (int j=0; j<w; j++){
			cin >>picture[i][j];
		}
	}
	
	for (int i=0; i<w+2; i++){
		cout << "#";
	}
	cout <<"\n";
	
	for (int i=0; i<h; i++){
		cout <<"#";
		for (int j=0; j<w; j++){
			cout << picture[i][j];
		}
		cout <<"#\n";
	}
	
	for (int i=0; i<w+2; i++){
		cout << "#";
	}
	cout <<"\n";
	
}

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

int main() {
	int a;
  	cin>>a;
  	string s;
  	cin>>s;
  
  if(a<3200){
  	cout<<"red"<<endl;
  }
  
  else{
  	cout<<s<<endl;
  }
  
  
}

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

int main() {
  int n; cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];
  
  int mi = 1e9;
  for (int p = 0; p <= 100; ++p) {
    int total = 0;
    for (int i = 0; i < n; ++i)
      total += (x[i]-p)*(x[i]-p);
    mi = min(mi, total);
  }
  
  cout << mi << endl;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int> > v(n+1, vector<int>(n+1, 0));
  int a, b;
  rep(i, m){
    cin >> a >> b;
    v[a][b] = 1;
  }
  vector<int> p(n);
  rep(i, n) p[i] = i + 1;
  int ans = 0;
  do {
    bool f = true;
    rep(i, n-1){
      if (v[p[i]][p[i+1]] == 0 &&
          v[p[i+1]][p[i]] == 0){
        f = false;
        break;
      }
    }
    if (f == true) ans++;
  } while (next_permutation(p.begin()+1, p.end()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep (i, n) cin >> h[i];
  sort(all(h));
  cout << accumulate(h.begin(), h.end() - min(n, k), 0LL) << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int64_t ans=0;
  for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0){
      ans += i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include  <iostream>
#include  <string>
#include  <vector>
#include  <algorithm>

using namespace std;

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

int main()
{
	int n;
	cin >> n;
	vector <string> s(n);
	rep(i, n)  cin >> s[i];

	rep(i, n)  sort(s[i].begin(), s[i].end());
	sort(s.begin(), s.end());

	ll cnt = 1;
	ll ans = 0;
	string z = s[0];
	for (int i = 1; i < n; i++) {
		if (z != s[i]) {
			z = s[i];
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
		else if (i == n - 1){
			if (s[n - 1] == z)  cnt++;
			ans += cnt * (cnt - 1) / 2;
		}
		else  cnt++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7296
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int N = nextInt(r);

        int sumA = 0;
        int sumB = 0;
        int sumC = 0;
        for (int i = 0; i < N; i++) {
            int tmpA = sumA;
            int tmpB = sumB;
            int tmpC = sumC;
            int Ai = nextInt(r);
            int Bi = nextInt(r);
            int Ci = nextInt(r);
            sumA = tmpB+Ai > tmpC+Ai ? tmpB+Ai : tmpC+Ai;
            sumB = tmpA+Bi > tmpC+Bi ? tmpA+Bi : tmpC+Bi;
            sumC = tmpA+Ci > tmpB+Ci ? tmpA+Ci : tmpB+Ci;
        }

        int ans = Math.max(sumA, Math.max(sumB, sumC));
        System.out.println(ans);
    }

    public static String nextString(InputStreamReader r) throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        return Integer.parseInt(nextString(r));
    }

    public static long nextLong(InputStreamReader r) throws Exception {
        return Long.parseLong(nextString(r));
    }
}


Measured memory_bytes: 60572
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

----------------------------------------

i番目から、j番目の前までを1つにするのにかかるコストの最小値をx[i, j]

x[i, j] = (sum[j] - sum[i]) + min(k; i .. j) (x[i, k] + x[k, j])

ただし　x[i, i] = 0

求めるものは　x[0, n]

----------------------------------------

上記だとメモ化再帰になってしまいやりづらい

長さがiで、左端がjである区間を1つにするのにかかるコストの最小値をx[i, j]
※先程のiは今のj、先程のjは今のj + i

x[i, j] = (sum[i + j] - sum[j]) + min(k; 1 .. i) (x[k, j] + x[i - k, j + k])

ただし　x[1, j] = 0

sum[i] はiの前までの和

求めるものは　x[n, 0]

*/

const long infty = 400 * 400 * 1_000_000_000 * 10;

void main(){
 int n = read.to!int;
 
 long[] as = readln.chomp.split.map!(to!long).array;
 
 long[] sums = [0];
 foreach(a; as) sums ~= sums[$ - 1] + a;
 
 long[][] xs = [[]];
 foreach(i; 1 .. n + 1){
	 xs ~= [[]];
	 foreach(j; 0 .. n + 1 - i){
		 if(i == 1) xs[i] ~= 0;
		 else{
			 long m = long.max;
			 foreach(k; 1 .. i){
				 m = min(m, xs[k][j] + xs[i - k][j + k]);
			 }
			debug writeln("i:", i, " j:", j, " m:", m);
			 xs[i] ~= sums[i + j] - sums[j] + m;
		 }
		debug writeln("i:", i, " xs[i]:", xs[i]);
	 }
 }
 
 xs[n][0].writeln;
 
 
}


Measured memory_bytes: 3836