akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define si size()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound

#define ask(i,m,n) for(lli i=m;i<n;i++)
#define anket ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
using namespace std;

#define prime1 1000000007
#define prime2 998244353

lli modadd(lli n,lli m , lli mod){
    lli sum = ((n+m)%mod+mod)%mod;
    return sum;
}

lli modsub(lli n,lli m,lli mod){
    lli diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}

lli modpro(lli n,lli m, lli mod){
    lli pro = ((n*m)%mod+mod)%mod;
    return pro;
}

lli powmod(lli x,lli y,lli mod){
    x %= mod;
    y %= mod;
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}

lli moddiv(lli n,lli m,lli mod){
    //return n/m mod (mod) or n*(m)^-1 mod (mod)
    lli a = powmod(m,mod-2,mod);
    //this is because of fermats thm i.e. a^-1 = a^p-2 mod(p) check
    //multiplying p on both sides
    lli res = modpro(a,n,mod);
    return res;
}




int main() {
	double a;
	cin>>a;
	double b = a*a*a/27;
	printf("%.13lf",b);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;
//素数判定　素数ならそのまま返す　合成数なら０を返す。
int sosu(int n) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) { return 0; }
	}
	return n;
}

int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
	long long int r, n, light[50][30] = {};
	while (1) {
		long long int r, n, light[50][30] = {};
		long double mi = 20.0;
		cin >> r >> n;
		if (r == 0) { return 0; }
		for (int i = 0; i < n; i++) {
			long long int xli, xri, hi;
			cin >> xli >> xri >> hi;
			for (int j = xli + 20; j < xri + 20; j++) {
				for (int k = 0; k < hi; k++) {
					light[j][k] = 1;
				}
			}
		}

		for (int i = 20-r; i < 20+r; i++) {
			for (int j = 0; j < 20; j++) {
				if (light[i][j] == 0) {
					if (i != 20 - r) {
						mi = min(mi, (long double)j + (long double)r - sqrt((long double)(r * r) - (long double)((i - 20) * (i - 20))));
					}
					if (i != 19 + r) {
						mi = min(mi, (long double)j + (long double)r - sqrt((long double)(r * r) - (long double)((i - 20 + 1) * (i - 20 + 1))));

					}
				}
			}
		}
		
		cout << mi << endl;

	}

}


Measured memory_bytes: 3232
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int ans = -1;
        int tmp = 7;
        for (int i = 1; i <= 1000000; i++) {
            if (tmp%K == 0) {
                ans = i;
                break;
            }
            tmp %= K;
            tmp *= 10;
            tmp += 7;
        }

        System.out.println(ans);
    }
}


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

using namespace std;

int main() {
	string s, t;
  	cin >> s >> t;
  	int mncost = 1e9;
  	for(int i = 0; i <= s.length() - t.length(); i++) {
    	int cost = 0;
      	for(int j = 0; j < t.length(); j++) {
        	if(s[i+j] != t[j]) cost++;
        }
      	mncost = min(mncost, cost);
    }
  	cout << mncost;
	return 0;
}

Measured memory_bytes: 3656
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
// int check(int i,int j){
// 	if(vec.size()<5){
// 		vec.pb(mp(i,j));
// 	}
// 	else{
// 		rep(k1,vec.size()){

// 		}
// 	}
// }
int gap,pos[500005],sa[500005],temp[500005],lcp[500005],n;
string s;
bool sufcmp(int a,int b){
	if(pos[a]!=pos[b]){
		return pos[a]<pos[b];
	}
	a+=gap;
	b+=gap;
	return (a<n&&b<n)?pos[a]<pos[b]:a>b;
}
void buildSA(){
	int i;
	n=s.length();
	rep(i,s.length()){
		sa[i]=i;
		pos[i]=s[i];
	}
	for(gap=1; ;gap*=2){
		sort(sa,sa+n,sufcmp);
		rep(i,n-1){
			temp[i+1]=temp[i]+sufcmp(sa[i],sa[i+1]);
		}
		rep(i,n){
			pos[sa[i]]=temp[i];
		}
		if(temp[n-1]==n-1){
			break;
		}
	}
}
void buildLCP(){
	int i,j,k=0;
	rep(i,n){
		if(pos[i]==n-1){
			//cout<<i<<endl;
			k=0;
			continue;
		}
		j=sa[pos[i]+1];
		while(i+k<n&&j+k<n&&s[i+k]==s[j+k]){
			k++;
		}
		lcp[pos[i]]=k;
		if(k){
			k--;
		}
	}
}
int main(){
	std::ios::sync_with_stdio(false);
	int k,i,j,val;
	cin>>s>>k;
	n=s.length();
	buildSA();	
	buildLCP();
	if(k<=n-sa[0]){
		rep(i,k){
			cout<<s[sa[0]+i];
		}
	}
	else{
		k-=(n-sa[0]);
		f(i,1,n){
			
			val=n-sa[i];
			val-=lcp[i-1];
			if(val>=k){
				rep(j,lcp[i-1]){
					cout<<s[sa[i]+j];
				}
				rep(j,k){
					cout<<s[sa[i]+lcp[i-1]+j];
				}
				return 0;
			}

			k-=val;
		}
	}
	// }
} 
	

Measured memory_bytes: 4480
import std.stdio: writefln, readln, readf;
import std.algorithm: map, max, sum;
import std.array: array, split;
import std.conv: to;

void main() {
	int n, k;
	readf("%s %s\n", &n, &k);

	double[] a = readln.split.map!(a => (a.to!double + 1) / 2).array;

	double ans = sum(a[0..k]);
	int i = 0;
	double suma = ans;
	while (i+k < n) {
		suma += a[i+k] - a[i];
		if (suma > ans) ans = suma;
		i++;
	}
	"%.10f".writefln(ans);
}


Measured memory_bytes: 10536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int N; cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        cin >> B.at(i);
    }
    ll ans = 0;
    for(int i = N-1; i >= 1; i--)
    {
        if(A.at(i) % B.at(i) != 0)
        {
            ans += B.at(i) - A.at(i) % B.at(i);
        }
        A.at(i-1) += ans;
    }
    if(A.at(0)%B.at(0)!=0)
    {
        ans += B.at(0) - A.at(0) % B.at(0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> List.rev (s :: acc)
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  doit str []

let print_array a =
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ()

let insertion_sort a n =
  print_array a;
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j + 1) <- v
    else (a.(j + 1) <- a.(j); insert (j - 1) v)
  in
  let rec doit i =
    if i >= n then ()
    else (insert (i - 1) a.(i); print_array a; doit (i + 1))
  in
  doit 1

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (split (read_line ()) ' ')) in
  insertion_sort a n

Measured memory_bytes: 4056
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
typedef tuple<int,int,int> T;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<P> path[305];
LL dis[305];
priority_queue<LP,vector<LP>,greater<LP> > q1;
priority_queue<T,vector<T>,greater<T> > q2;

int t[305][305];

void queue_clear(priority_queue<LP,vector<LP>,greater<LP> > &q){
   priority_queue<LP,vector<LP>,greater<LP> > empty;
   swap( q, empty );
}

LL dijk(int p,int q){
	LL a,b,c;
	int i,j,k;
	bool flag=false;
	memset(dis,-1,sizeof(dis));
	queue_clear(q1);
	q1.push(make_pair(0,p));
	while(!q1.empty()){
		a=q1.top().first,b=q1.top().second,q1.pop();
		if(dis[b]!=-1)continue;
		dis[b]=a;
		if(b==q){
			flag=true;
			break;
		}
		for(i=0;i<path[b].size();i++){
			if(dis[path[b][i].first]!=-1)continue;
			q1.push(make_pair(a+path[b][i].second,path[b][i].first));
		}
	}
	if(flag)return a;
	return -1;
}

int main(){
	int n;
	int i,j,k;
	LL a,b,c,d;
	bool flag=true;
	LL s=0;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			cin>>t[i][j];
			if(i<j)q2.push(make_tuple(t[i][j],i,j));
		}
	}
	while(!q2.empty()){
		tie(a,b,c)=q2.top(),q2.pop();
		d=dijk(b,c);
		if(d==-1 || d>t[b][c]){
			path[b].push_back(make_pair(c,t[b][c]));
			path[c].push_back(make_pair(b,t[b][c]));
			s+=t[b][c];
			
		}else if(t[b][c]<d){
			flag=false;
			break;
		}
	}
	if(flag){
		for(i=0;i<n;i++){
			dijk(i,-1);
			for(j=0;j<n;j++){
				if(t[i][j]!=dis[j]){
					flag=false;
					break;
				}
			}
		}
	}
	if(!flag)s=-1;
	cout<<s<<endl;
	
}


Measured memory_bytes: 1276
use proconio::input;

const MOD: usize = 1e9 as usize + 7;

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let result = (k - 1..=n)
        .map(|i| (sum_int(n - i, n).wrapping_sub(sum_int(0, i)) + 1) % MOD)
        .fold(0 as usize, |sum, e| sum.wrapping_add(e) % MOD);
    println!("{}", result);
}

fn sum_int(from: usize, to: usize) -> usize {
    (to + from).wrapping_mul(to - from + 1).wrapping_div(2)
}


Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n; cin >> n;
  vector<int> b(n-1);
  rep(i, n-1) cin >> b[i];
  int ans = 0;
  rep(i, n) {
    if(i == 0) ans += b[0];
    else if(i == n-1) ans += b[n-2];
    else ans += min(b[i], b[i-1]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
const ll inf=0x3f3f3f3f;
const ld pi=acos(-1.0);
ll n,k;
ll vis[maxn];
string s;
void run(){
    char a;
    cin>>a;
    if(a<='z'&&a>='a'){
        cout<<'a'<<'\n';
    }else{
        cout<<'A'<<'\n';
    }
}

int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
#endif
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 2e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int n, a[MaxN];

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[a[i]] == i) {
      ans++;
    }
  }
  cout << ans / 2 << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = (int)(n); i >= 0; i--)

int main()
{
    int N;
    cin >> N;
    map<string, int> S;
    repi(i, N)
    {
        string tmp;
        cin >> tmp;
        S[tmp]++;
    }
    int M;
    cin >> M;
    map<string, int> T;
    repi(i, M)
    {
        string tmp;
        cin >> tmp;
        T[tmp]++;
    }
    int ans = 0;
    for (auto itr = S.begin(); itr != S.end(); itr++)
    {
        ans = max(itr->second - T[itr->first], ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int > t(n, 0);
  vector<string > s(n);
  vector<int > sum(n, 0);
  REP(i,n){
    cin >> s[i] >> t[i];
  }
  string x;
  cin >> x;
  int ind = 0;
  REP(i,n){
    if(s[i] == x){
      ind = i;
      break;
    }
  }

  sum[0] = t[0];
  REP(i,n - 1){
    sum[i + 1] = sum[i] + t[i + 1];
  }
  cout << sum[n - 1] - sum[ind] << endl;

}


Measured memory_bytes: 256
/*input
9 6 1
1 2
2 3
3 4
4 5
5 6
4 7
7 8
8 9
*/
#include "bits/stdc++.h"
using namespace std;
const int LG = 18;
long long up[100005][LG], tin[200005], tout[100005], CLK = 1, lvl[100005];
vector<int> v[100005];
void dfspre(int u, int dad, int depth){
	tin[u] = CLK++;
	lvl[u] = depth;
	up[u][0] = dad;
	for(int i = 1; i < LG; ++i)
		up[u][i] = up[up[u][i-1]][i-1];
	for(auto i : v[u]) if(i != dad)
		dfspre(i, u, depth+1);
	tout[u] = CLK++;
}
bool is_ancestor(int x, int y){
	return tin[x] <= tin[y] && tout[y] <= tout[x];
}
int lca(int x, int y){
	if(is_ancestor(x,y)) return x;
	if(is_ancestor(y,x)) return y;

	for(int i = LG; i--;){
		if(!is_ancestor(up[x][i], y))
			x = up[x][i];
	}
	return up[x][0];
}
int dist(int x, int y){
	return lvl[x] + lvl[y] - 2*lvl[lca(x, y)];
}
int x, y, RES;
void dfs(int u, int dad){
	if(dist(u, y) <= dist(u, x)){
		RES = max(RES, dist(u, x) - (dist(x,y)%2));
		return;
	}
	for(auto i: v[u]) if(i != dad){
		dfs(i, u);
	}
	RES = max(RES, max(dist(u,x), dist(u,y)) - (dist(x,y)%2));
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n; cin >> n >> x >> y;
	for(int x, y, i = n; --i;){
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfspre(x, x, 0);

	for(int i = 1; i <= n; ++i) if(dist(x, lca(i, y)) < dist(y, lca(i, y)) || (lca(i,y)==i && dist(x, lca(i, y)) == dist(y, lca(i, y)))){
		int ok = 0;
		for(int u: v[i]) if(dist(u, y) > dist(i, y)) ok = 1;
		if(!ok) continue;

		// cout << i << ' ' << dist(y, i) - dist(x, y)%2 << endl;
		RES = max(RES, dist(y, i));
	}
	cout << RES << endl;
}

Measured memory_bytes: 27008
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

long long num[100010];

int main()
{
    for(long long i=1;i<100010;i++)
        num[i]=i*i;
    long long N;
    while(cin >> N)
    {
        int tp=upper_bound(num,num+100010,N)-num;
        cout << num[tp-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#define MAX(A,B)((A)>=(B)?(A):(B))
int N,M,H[200],R[200],memo[200];
int solve(int x) {
	if(memo[x]>=0) return memo[x];
	int ans=0;
	for(int i=0;i<(N+M);i++) {
		if(H[x]>H[i]&&R[x]>R[i]) {
			ans=MAX(ans,1+solve(i));
		}
	}
	return memo[x]=ans;
}
int main() {
	while(scanf("%d",&N),N) {
		for(int i=0;i<N;i++) {
			scanf("%d %d",&H[i],&R[i]);
		}
		scanf("%d",&M);
		for(int i=0;i<M;i++) {
			scanf("%d %d",&H[i+N],&R[i+N]);
		}
		memset(memo,-1,sizeof(memo));
		int ans=0;
		for(int i=0;i<(N+M);i++) {
			ans=MAX(ans,1+solve(i));
		}
		printf("%d\n",ans);
	}
}

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



int main(){
	int d;
	int i;
	int ans;
	while(scanf("%d",&d)!=EOF){
		ans=0;
		for(i=1;;i++){
			ans+=i*d*i*d*d;
			if(i*d==600-d)break;
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

ll lucas(int n){
	vector<ll> a(n+1);
	a[0] = 2;
	a[1] = 1;
	int i = 2;
	for(int i = 2; i <= n; ++i){
		a[i] = a[i-1] + a[i-2];
	}
	return a[n];
}

int main(){
	int n; cin >> n;
	cout << lucas(n) << endl;

}


Measured memory_bytes: 256
N = int(raw_input())
num_list = map(int, raw_input().split())

print " ".join(map(str,num_list))
for i in range(1, N):
    v = num_list[i]
    j = i - 1
    while j >= 0 and num_list[j] > v:
       num_list[j+1] = num_list[j]
       j-=1
    num_list[j+1] = v
    print " ".join(map(str,num_list))

Measured memory_bytes: 6336
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    cumsum = np.cumsum(p)
    # print(cumsum)
    max_value = 0
    index_first = 0
    for i in range(N - K):
        if max_value < cumsum[i + K] - cumsum[i]:
            max_value = max(max_value, cumsum[i + K] - cumsum[i])
            index_first = i + 1

    # print(max_value)
    # print(index_first)
    result = 0
    for j in range(K):
        idm = (p[index_first + j] / 2) * (1 + p[index_first + j])
        idm = idm / p[index_first + j]
        result += idm

    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)


if __name__ == "__main__":
    main()


Measured memory_bytes: 36884
#include<iostream>
#include<string>
#include<cstdlib>
#include<math.h>
using namespace std;
int main(void){
    int ans=0,D,N;
    cin >> D >> N;
  	if(N==100){
    	N=101;
    }
    if(D==0){
        printf("%d",N);
    }else if(D==1){
        printf("%d",N*100);
    }else if(D==2){
        printf("%d",N*10000);
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

const long long INF = 1000000001LL;

struct Poly {
  int n;
  Poly(int n) : n(n) {}

  long long num (string s) {
    return s[0] - '0';
  }

  long long mono(string s) {
    long long a = num(s.substr(2));
    long long res = 1;
    rep (i, a) {
      res *= n;
      res = min(res, INF);
    }
    return res;
  }

  long long poly(string s) {
    rep (i, s.size()) if (s[i] == '+') return min(poly(s.substr(0, i)) + poly(s.substr(i + 1)), INF);
    return min(mono(s), INF);
  }
};

int main() {
  int n, t;
  cin >> n >> t;
  Poly poly(n);
  string str;
  cin >> str;
  long long res = poly.poly(str);
  res *= t;
  if (res >= INF) {
    cout << "TLE" << endl;
  } else {
    cout << res << endl;
  }
}

Measured memory_bytes: 1212
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007LL

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



ll inv[200005];
ll fact[200005];

void factor(ll a) {
	ll ret = 1LL;
	for (ll i = 1; i <= a; i++) {
		ret = ret*i%MOD;
		fact[i] = ret;
	}
	
}

ll beki(ll a, ll p) {
	ll ret = 1LL;
	while (p > 0) {
		if (p & 1) {
			ret = ret*a%MOD;
		}
		a = a*a%MOD;
		p >>= 1;
	}
	return ret;
}

ll comb(ll a, ll b) {
	if (a < 0 || b < 0 || a < b)return 0LL;
	if (a == b || b == 0)return 1LL;
	ll ret = fact[a]*inv[b]%MOD;
	ret = ret*inv[a - b] % MOD;
	return ret;

}
int h, w, a, b;
int main() {
	int n;
	cin >> h >> w >> a >> b;


	factor(h+w);
	FOR(i, 1, h+w) {
		inv[i] = beki(fact[i], MOD - 2);
	}
	ll ans = 0LL;
	for (int i = b; i < w; i++) {
		ans = (comb(h - a - 1 + i, i) * comb(a + w - 2 - i, a - 1) % MOD + ans) % MOD;
	}
	cout << ans << endl;
	return 0;
}


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

#define int long long int

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

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

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

void solve();

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

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

void solve()
{
	int i,j;
	int n;
	cin>>n;

	if(n&1)
	{
		int rem=0;
		set<int>s;

		int cnt=0;

		while(s.find(rem)==s.end())
		{
			cnt++;

			d(rem);

			s.insert(rem);

			int num=rem*10+7;

			int div = num/n;
			d(num,div);
			rem=num-div*n;

			if(rem==0)
			{
				cout<<cnt<<endl;
				return;
			}
			d(s);
		}
		cout<<-1<<endl;
		return;
	}
	else
	{
		cout<<-1<<endl;
	}

}

Measured memory_bytes: 50484
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int a[maxn];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    ll ans=0;
    for(int i=1;i<=k;i++)
        ans+=a[i];
    cout<<ans<<endl;

}


Measured memory_bytes: 3156
// Aizu 0270: Modular Query
// 2017.8.24 bal4u@uu

#include <stdio.h>

char tbl[300005];

int main()
{
	int N, Q, i, k, q, max;

	scanf("%d%d", &N, &Q);
	tbl[0] = 1, max = 0; while (N-- > 0) {
		scanf("%d", &k), tbl[k] = 1;
		if (k > max) max = k;
		tbl[k & 1] = 1, tbl[k & 3] = 1, tbl[k & 7] = 1;
	}
	while (Q-- > 0) {
		scanf("%d", &q);
		if (q > max) printf("%d\n", max);
		else {
			for (k = q-1; ; k--) {
				for (i = k; i <= max; i += q)
					if (tbl[i]) { printf("%d\n", k); goto Done; }
			}
			Done:;
		}
	}
	return 0;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << (A + B >= C ? "Yes" : "No") << endl;
}


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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll N;
vector<ll> A;
int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    // 桁ごとに計算する
    ll ans = 0;
    for (int i = 0; i < 60; i++) {
        // ビットが立っているかず

        ll cnt = 0;
        for (int j = 0; j < N; j++) {
            if (A[j] >> i & 1) cnt++;
        }

        ll pat = cnt * (N - cnt) % MOD;
        // cout << cnt << endl;
        // i 回2をかける
        for (int j = 0; j < i; j++) {
            pat *= 2;
            pat %= MOD;
        }
        ans += pat;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

const int Maxn = 100005;

int n, m;
int p[Maxn];
vector <int> neigh[Maxn];
vector <int> A, B;
bool tk[Maxn];
int res;

void Traverse(int v)
{
	if (tk[v]) return;
	tk[v] = true;
	A.push_back(v); B.push_back(p[v]);
	for (int i = 0; i < neigh[v].size(); i++)
		Traverse(neigh[v][i]);
}

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", &p[i]);
	for (int i = 1; i <= m; i++) {
		int a, b; scanf("%d %d", &a, &b);
		neigh[a].push_back(b);
		neigh[b].push_back(a);
	}
	for (int i = 1; i <= n; i++) {
		Traverse(i);
		sort(A.begin(), A.end()); sort(B.begin(), B.end());
		int l = 0, r = 0;
		while (l < A.size() && r < B.size())
			if (A[l] < B[r]) l++;
			else if (A[l] > B[r]) r++;
			else { res++; l++; r++; }
		A.clear(); B.clear();
	}
	printf("%d\n", res);
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cmath>

int main()
{
    double r, S, l;
    cin >> r;
 
    S = M_PI * r * r;
    l = 2 * M_PI * r;
    cout << fixed << setprecision(10) << S << " " << l << endl;
  
    return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
using namespace std; 
#define pb push_back 
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define sc(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	
	map<string,int>m;
	int n;
	cin>>n;
	int ans=0;
	rep(i,1,n)
	{
		string s;
		cin>>s;
		if(!m.count(s))
		{
			m[s]=1;
			ans++;
		}
		
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

int ab(int x){ return (x < 0)?-x:x; }

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

  int arr[200200];

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

  sort(arr, arr + n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += ab(arr[i] - arr[n / 2]);
  }

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

  return 0;
}


Measured memory_bytes: 1024
from math import factorial


def com(a, b):
    return factorial(a)//factorial(b)//factorial(a-b)


x = 10 ** 9 + 7
N, K = map(int, input().split())

for i in range(1, K + 1):
    if (i > N-K+1):
        print(0)
    else:
        print((com(N - K + 1, i) * com(K-1, i-1)) % x)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;

	
	
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

map<string,string> ans = {
  {"Sunny","Cloudy"},
  {"Cloudy","Rainy"},
  {"Rainy","Sunny"},
};
int main() {
  string s;
  cin >> s;
  cout << ans[s] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

const long long int MAX = 30000010;
const long long int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long int n,long long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){

    COMinit();
    long long int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    long long int result = 0;
    long long int tmp;
    FOR(i,r1,r2+1){
        tmp = i + 1;
        //cout << COM(tmp + c2, c2)<<" " << COM(tmp + c1 - 1, c1 - 1) << endl;
        result += COM(tmp + c2, c2) - COM(tmp + c1-1, c1-1);
        result %= mod;
    }
    if(result<0){
        result += mod;
    }
    cout << result << endl;



    return 0;
}


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

using namespace std;

long long solve(const vector<int>& a){
	long long res = 0;
	int value = 0;
	for(int i=a.size()-1;i>=0;i--){
		value = max(0, value - 1);
		if(a[i] < value) return -1;
		if(a[i] > value){
			res += a[i];
			value = a[i];
		}
	}
	if(value > 0) return -1;
	return res;
}

int main(){
	int N;
	while(cin >> N){
		vector<int> a(N);
		for(auto& t : a) cin >> t;
		cout << solve(a) << endl;
	}
}


Measured memory_bytes: 1152
import java.io.PrintStream;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        doit(args, new Scanner(System.in), System.out);
    }

    static void doit(String[] args, Scanner scanner, PrintStream out) {
        String str = scanner.next();
        StringBuilder sb = new StringBuilder();
        for (int i = str.length() - 1; i >= 0; i--) {
            sb.append(str.charAt(i));
        }
        out.println(sb.toString());
    }
}

Measured memory_bytes: 11000
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
long long modMult(long long a, long long b, long long m) {
  long long res = 0;
  long long exp = a % m;
  while (b) {
    if (b & 1) {
      res += exp;
      if (res > m) res -= m;
    }
    exp <<= 1;
    if (exp > m) exp -= m;
    b >>= 1;
  }
  return res;
}
long long powMod(long long a, long long b, long long m) {
  long long res = 1;
  long long exp = a % m;
  while (b) {
    if (b & 1) res = modMult(res, exp, m);
    exp = modMult(exp, exp, m);
    b >>= 1;
  }
  return res;
}
//powMod(a,b,MOD)
//O(log(b))?
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll combi(ll a,ll b){
    if(a<b)return 0;
    ll res=1;
    for(ll i=a;i>=a-b+1;i--){
        res*=i;
        res%=MOD;
    }
    rep3(i,1,b+1){
        res*=modinv(i,MOD);
        res%=MOD;
    }
    return res;
}
//a,m=MOD MOD逆元
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll temp=powMod(2,n,MOD);
    temp+=MOD;
    temp-=combi(n,a);
    temp%=MOD;
    temp+=MOD;
    temp-=combi(n,b);
    temp%=MOD;
    temp+=MOD;
    temp--;
    cout<<temp%MOD<<endl;
}


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

int main(){
    int ac=0,wasum=0,n,m,a;
    string s;
    cin >> n >> m;
    vector<bool> pro(n,false);
    vector<int> wa(n,0);
    for(int i=0;i<m;i++){
        cin >> a;
        cin >> s;
        if(pro.at(a-1)==false){
            if(s=="AC"){
                ac++;
                wasum+=wa.at(a-1);
                pro.at(a-1)=true;
            }else{
                wa.at(a-1)++;
            }
        }
        
    }
    cout << ac <<" "<< wasum << endl;
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/abc165/tasks/abc165_a

#include <cstdio>

using namespace std;

const int B_MAX = 1000;
const int K_MAX = 1000;

int K;
int A, B;

bool judge() {
  if ( K > B ) return false;
  for(int i=A; i<=B; i++) {
    if ( i % K == 0 )return true;
  }
  return false;
}

void solve() {
  bool cond = judge();
  puts(cond ? "OK" : "NG");
}

void input() {
  scanf("%d", &K);
  scanf("%d%d", &A, &B);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3156
# include <bits/stdc++.h>
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		int t;scanf("%s%d",in,&t);
		string tmp=in;
		p[i]=make_pair(make_pair(in,-t),i);
	}
	std::sort(p,p+a);
	for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    int A[N];

    
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort( A, A+N );
    long long ans = fabs(A[N-1] - A[0]); 
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.HashMap;

class Util {
	public static int pow10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000};
	public static int find0(int puz) {
		for (int i = 0; i < 8; ++i) {
			if (puz % 10 == 0)
				return 7 - i;
			puz /= 10;
		}
		return -1;
	}
	public static int piece(int puz, int i) {
		return (puz / pow10[7 - i]) % 10;
	}
	public static int swap(int puz, int i, int j) {
		int pi = piece(puz, i);
		int pj = piece(puz, j);
		return puz + pow10[7 - i] * (pj - pi) + pow10[7 - j] * (pi - pj);
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// ↓, →, ↑, ←
		int dx[] = {1, 0, -1, 0};
		int dy[] = {0, 1, 0, -1};
		HashMap<Integer, Integer> memo = new HashMap<Integer, Integer>();
		while (sc.hasNext()) {
			Queue<Integer> que = new ArrayDeque<>();
			int init = 0;
			for (int i = 0; i < 8; ++i)
				init = init * 10 + sc.nextInt();
			que.add(init);
			memo.put(init, 0);
			while (que.size() != 0) {
				int now = que.poll();
				if (now == 1234567) break;
				int idx = Util.find0(now);
				for (int i = 0; i < 4; ++i) {
					int x = idx / 4; int y = idx % 4;
					int nx = x + dx[i]; int ny = y + dy[i];
					if ((0 <= nx && nx <= 1) && (0 <= ny && ny <= 3)) {
						int ni = nx * 4 + ny;
						int adj = Util.swap(now, ni, idx);
						if (memo.containsKey(adj)) continue;
						memo.put(adj, memo.get(now) + 1);
						que.add(adj);
					}
				}
			}
			System.out.println(memo.get(1234567));
			memo.clear();
		}
	}
}


Measured memory_bytes: 314728
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int kai=gcd(c,d);
   kai=c*d/kai;
   int e,f,g,h;
   e=b/c-(a-1)/c;
   f=b/d-(a-1)/d;
   g=b/kai-(a-1)/kai;
   h=e+f-g;
   cout<<b-a+1-h<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll p,q,r;
    cin>>p>>q>>r;
    cout<<min(p+q,min(q+r,p+r));
    
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


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

    ll N;
    cin >> N;
    
    if (N == 0) {
        print(0);
        return 0;
    }

    vector<pair<ll, ll>> v;

    ll l = 0, r = 0;
    ll c = 1;
    REP(i, 50) {
        v.eb(l, r);
        if (l <= N && N <= r) break;
        (i % 2 ? l : r) += c;

        c *= -2;
    }

    string S(v.size() - 1, '0');

    c /= -2;
    REVFOR(i, 1, v.size()) {
        if (v[i].fi <= N && N <= v[i].se && (v[i-1].fi > N || v[i-1].se < N)) {
            S[i - 1] = '1';
            N -= c;
        }

        c /= -2;
    }

    reverse(ALL(S));
    print(S);
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  ll ans=0;
  int N,B[110];
  cin>>N;
  for(int i=0;i<N-1;i++){
    cin>>B[i];
  }
  ans=B[0];
  for(int i=0;i<N-2;i++){
    ans+=min(B[i],B[i+1]);
    //cout<<ans<<endl;
  }
  ans+=B[N-2];
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N;
    cin >> N;

    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    sort(A.begin(), A.end(), greater<int>());
    map<ll, ll> m;
    rep(i,N) {
        if (m.find(A[i]) != m.end()) m[A[i]]++;
        else m.insert(make_pair(A[i], 1));
    }

    ll ans = 0;

    rep(i,N) {
        if (m[A[i]] <= 0) continue;
        ll d = 2;
        while (d <= A[i]) d *= 2;
        if (m.find(d - A[i]) == m.end()) continue;
        ll c = (d - A[i] != A[i] ? min(m[A[i]], m[d - A[i]]) : m[A[i]] / 2);
        ans += c;
        m[A[i]] -= c;
        m[d - A[i]] -= c;
    }

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

Measured memory_bytes: 14336
#include<stdio.h>

using namespace std;

int main()
{
	long long a, b;
	long long ans;
	char op;
	scanf("%lld %c %lld", &a, &op, &b);
	if(op == '+')
		ans = a + b;
	else
		ans = a - b;
	printf("%lld\n", ans);
	return 0;
}

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

dp = [float('inf')] * (n + 1)
dp[0] = 0


for i in range(n):
    dp[i + 1] = min(dp[i + 1], dp[i] + 1)
    for j in range(n):
        if i + 6 ** (j + 1) <= n:
            dp[i + 6 ** (j + 1)] = min(dp[i + 6 ** (j + 1)], dp[i] + 1)
        else:
            break
        for k in range(n):
            if i + 9 ** (k + 1) <= n:
                dp[i + 9 ** (k + 1)] = min(dp[i + 9 ** (k + 1)], dp[i] + 1)
            else:
                break

print(dp[n])

Measured memory_bytes: 49100
//{
#include<bits/stdc++.h>
using namespace std;
 
// #define DEBUG

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif
//}


ll solve(ll x) {
    for(int i = 1; i < 179; i++) {
        if((360*i) % x == 0)
            return (360*i) / x;
    }
}

void Input() {
    rd1(ll, x);
    cout << solve(x);
}

int main() {
	
	fastio;

    // rd1(ll, t);
	ll t = 1;

    while(t--) {
        Input();
    }
    
	return 0;
}

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

int check(int n);

int main()
{
	int n,flag;
	cin>>n;
	flag=0;
	while(flag!=1)
	{
		flag=check(n);
		n++;
	}
	cout<<n-1;
	return 0;
	
}
int check(int n)
{
	int i,flag=0;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(flag==0) return 1;
	else return 0;
	
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val (N,K) = readLine()!!.split(" ").map{ it.toLong()}
    var A = readLine()!!.split(" ").map{it.toInt()}
    var preOK = LongArray(N.toInt()) {0}
    var afterOK = LongArray(N.toInt()) {0}
    var wholeOK = LongArray(N.toInt()) {0}
    val MOD = 1000000007


    for(i in 0 until A.size){
        for(j in 0 until A.size){
            if(i > j && A[i] > A[j]){
                preOK[i]++
            }  else if(i < j && A[i] > A[j]) {
                afterOK[i]++
            }
        }
        wholeOK[i] = preOK[i] + afterOK[i]
    }
    var ans =0L

    for(i in 0 until A.size){
        ans += afterOK[i]*K
        ans %= MOD
        ans += ((K*(K-1)/2L) % MOD)  * wholeOK[i]
        ans %= MOD
    }


    while(ans<0) ans += MOD



    println(ans)
}

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

li1 = [0]* 20
li2 = [0]* 20
count = 1

for i in range(19):
    li1[i+1] = li1[i] + 4 ** i
    li2[i+1] = li2[i] - 2 * 4 ** i

if n == 0:
    s = [0]
elif n > 0:
    for i in range(20):
        if li1[i] < n and li1[i+1] >= n:
            a = i
            s = [0] * (2*i+1)
            s[0] = 1
            n -= (-2) ** (2*i)
            #print(n)
            break
    while a > 0:
        a -= 1
        if li2[a] > n and li2[a+1] <= n:
            s[count] = 1
            n -= (-2) ** (2*a+1)
            count += 1
            #print(n)
        else:
            s[count] = 0
            count += 1
            #print(n)
        if li1[a] < n and li1[a+1] >= n:
            s[count] = 1
            n -= (-2) ** (2*a)
            count += 1
            #print(n)
        else:
            s[count] = 0
            count += 1
            #print(n)
    #print(s)
else:
    for i in range(20):
        if li2[i] > n and li2[i+1] <= n:
            a = i
            s = [0] * (2*(i+1))
            s[0] = 1
            n -= (-2) ** (2*i+1)
            #print(n)
            break
    if li1[a] < n and li1[a+1] >= n:
        s[count] = 1
        n -= (-2) ** (2*a)
        count += 1
        #print(n)
    else:
        s[count] = 0
        count += 1
        #print(n)
    while a > 0:
        a -= 1
        if li2[a] > n and li2[a+1] <= n:
            s[count] = 1
            n -= (-2) ** (2*a+1)
            count += 1
            #print(n)
        else:
            s[count] = 0
            count += 1
            #print(n)
        #print(li[a],li[a+1])
        if li1[a] < n and li1[a+1] >= n:
            s[count] = 1
            n -= (-2) ** (2*a)
            count += 1
            #print(n)
        else:
            s[count] = 0
            count += 1
            #print(n)
    #print(s)

ans = ''

for i in range(len(s)):
    ans = ans + str(s[i])

print(ans)


Measured memory_bytes: 3192
using System.Linq;
using System;
using static System.Math;

public class hello
{
	public static void Main()
	{
		var pmax = 1000000;
		var a = new bool[pmax + 1];
		GeneratePrime(a);
		var b = new int[pmax + 1];
		b[2] = 1;
		for (int i = 3; i <= pmax; i++)
			b[i] = a[i] ? b[i - 1] + 1 : b[i - 1];
		while (true)
		{
			var n = int.Parse(Console.ReadLine().Trim());
			if (n == 0) break;
			var ans = 0;
			for (int i = 0; i < n; i++)
			{
				string[] line = Console.ReadLine().Trim().Split(' ');
				var p = int.Parse(line[0]);
				var m = int.Parse(line[1]);
				var nfrom = Max(0, p - m);
				var nto = Min(pmax, p + m);
				var tt = nfrom >= 1 ? b[nto] - b[nfrom - 1] : b[nto];
				ans += tt - 1;
			}
			Console.WriteLine(Max(0, ans));
		}
	}
	public static void GeneratePrime(bool[] p)
	{
		int prime;
		var m = p.Length;
		var sqrtMax = Math.Sqrt(m);
		var searchList = Enumerable.Range(2, m - 1).ToList();
		do
		{
			prime = searchList.First();
			p[prime] = true;
			searchList.RemoveAll(n => n % prime == 0);
		}
		while (prime < sqrtMax);
		foreach (var x in searchList)
			if (x < m) p[x] = true;
	}
}



Measured memory_bytes: 30820
#include<iostream>
#include<string>
#include<iomanip>
#include<stdio.h>
#include<sstream>

using namespace std;

int main(void){
	int a;
	int K;
	long ans;
	ostringstream ss;
	cin >> a;
	if(a < 1000){
		puts("ABC");
	}else{
		int b = a - 1000 + 1;
		printf("ABD");
	}
	
	return 0;
}

Measured memory_bytes: 256