akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int X;
  	string s ;
  	cin >> s ;
  	X = 0	;
  	if ( s[0] == '1' ) X++	;  
  	if ( s[1] == '1' ) X++	;
  	if ( s[2] == '1' ) X++	;
  	cout << X << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>

int main(int argc, char const *argv[])
{
	int n, cnt = 0;
	std::string s;
	std::cin >> n;
	std::cin >> s;

	for (int i = 0; i + 2 < n; i++)
		if (s.substr(i, 3) == "ABC")
			cnt++;

	std::cout << cnt << std::endl;

	return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  for (int i = 0 ; i < N ; i++ ){
    
    string S;
    cin >> S;
    
    if (S == "Y"){
      cout <<  "Four" << endl;
      break;
    }
    
    else if (i == N-1){
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
long long int n,ans=0;
int main( )
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

int main(){
    int n,m; cin >> n >> m;
    vint k(m);
    vector<vint> s(m,vint());
    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            int kin;
            cin >> kin;
            --kin;
            s[i].push_back(kin);
        }
    }
    vint p(m); rep(i,m) cin >> p[i];
    
    int ans = 0;
    for(int bit = 0; bit < (1 << n); ++bit){
        bool flag = true;
        for(int i = 0; i < m; ++i){
            int on = 0;
            rep(j,k[i]){
                if(bit & (1<<s[i][j])) ++on;
            }
            if(on%2 != p[i]) flag = false;
        }
        if(flag) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    string s;
    cin>>s;
    int first=(s[0]-'0')*10+(s[1]-'0');
    int second=(s[2]-'0')*10+(s[3]-'0');
    
    string ans;
    if(first<=12 && first>0)
    {
        if(second<=12 && second>0)
        {
            ans="AMBIGUOUS";
        }
        else
        {
            ans="MMYY";
        }
        
    }
    else if(second<=12 && second>0)
    {
        ans="YYMM";
    }
    else
    {
        ans="NA";
    }
    cout<<ans;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
struct Xam{
	int a[26],par;
}xam[200010];int last[26];
char s[200010];
void addxam()
{
	int len=strlen(s+1);
	for(int i=0;i<26;i++) last[i]=1;
	for(int i=1;i<=len;i++)
	{
		int p=i+1,c=s[i]-'a';
		for(int j=0;j<26;j++)
			for(int k=last[j];k&&!xam[k].a[c];k=xam[k].par) xam[k].a[c]=p;
		xam[p].par=last[c];last[c]=p;
	}
}
int son[200010],len[200010];
void dfs(int x)
{
	if(son[x]!=-1) return;
	if(!x) {son[x]=0,len[x]=0;return;}
	for(int i=0;i<26;i++)
	{
		int y=xam[x].a[i];
		//printf("%d->%d\n",x,y);
		dfs(y);
		if(son[x]==-1||len[y]<len[xam[x].a[son[x]]]) son[x]=i,len[x]=len[y]+1;
	}
	//printf("%d %d %d\n",x,son[x],len[x]);
	//if(x==1) printf("fuck:%d\n",xam[1].a[1]);
}
void print(int x)
{
	if(!x) return;
	printf("%c",son[x]+'a');
	print(xam[x].a[son[x]]);
}
int main()
{
	scanf("%s",s+1);
	addxam();
	memset(son,-1,sizeof(son));
	dfs(1);print(1);
}

Measured memory_bytes: 23552
import java.util.Scanner;

public class Main {
	final int INF = Integer.MAX_VALUE;

	long mergeCount = 0;
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();
		mergeSort(a, 0, n);
		System.out.println(mergeCount);
	}
	
	void mergeSort(int[] a, int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(a, left, mid);
			mergeSort(a, mid, right);
			merge(a, left, mid, right);
		}
	}
	
	void merge(int[] a, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;

		int[] l = new int[n1 + 1];
		int[] r = new int[n2 + 1];
		for (int i = 0; i < n1; i++)
			l[i] = a[left + i];
		for (int i = 0; i < n2; i++)
			r[i] = a[mid + i];
		l[n1] = r[n2] = INF;
		
		int i = 0, j = 0;
		for (int k = left; k < right; k++) {
			if (l[i] <= r[j]) {
				a[k] = l[i++];
			} else {
				mergeCount += n1 - i;
				a[k] = r[j++];
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 100024
T = int(input())
ABCD = [[int(_) for _ in input().split()] for _ in range(T)]


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


for a, b, c, d in ABCD:
    if a < b or d < b:
        print('No')
    else:
        g = gcd(b, d)
        x = g * (c // g) + (a % g)
        if x <= c:
            x += g
        if x >= b:
            print('Yes')
        else:
            print('No')

# https://www.youtube.com/watch?v=eB0eT-948Vw


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n)cin>>l[i];
	SORT(l);
	ll ans = 0;
	rep(i,n){
		For(j,i+1,n){
			For(k,j+1,n){
				if(l[i] != l[j] && l[j] != l[k]){
					if(l[i] + l[j] > l[k]){
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <stack>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>
#include <tr1/unordered_map>
#include <cmath>
#include <map>
#include <bitset>
#include <set>
#include <iomanip>
#include <utility>    
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector< ii > vii;
///////////////////////////////UTIL/////////////////////////////////
#define ALL(x) (x).begin(),x.end()
#define CLEAR0(v) memset(v, 0, sizeof(v))
#define CLEAR(v, x) memset(v, x, sizeof(v))
#define COPY(a, b) memcpy(a, b, sizeof(a))
#define CMP(a, b) memcmp(a, b, sizeof(a))
#define REP(i,n) for(int i = 0; i<n; i++)
#define REPP(i,a,n) for(int i = a; i<n; i++)
#define REPD(i,n) for(int i = n-1; i>-1; i--)
#define REPDP(i,a,n) for(int i = n-1; i>=a; i--)
#define pb push_back
#define pf push_front
#define sz size()
#define mp make_pair
/////////////////////////////NUMERICAL//////////////////////////////
#define INF 0x3f3f3f3f
#define EPS 1e-9
/////////////////////////////BITWISE////////////////////////////////
#define CHECK(S, j) (S & (1 << j))
#define CHECKFIRST(S) (S & (-S)) 
#define SET(S, j) S |= (1 << j)
#define SETALL(S, j) S = (1 << j)-1  
#define UNSET(S, j) S &= ~(1 << j)
#define TOOGLE(S, j) S ^= (1 << j)
///////////////////////////////64 BITS//////////////////////////////
#define LCHECK(S, j) (S & (1ULL << j))
#define LSET(S, j) S |= (1ULL << j)
#define LSETALL(S, j) S = (1ULL << j)-1ULL 
#define LUNSET(S, j) S &= ~(1ULL << j)
#define LTOOGLE(S, j) S ^= (1ULL << j)
//__builtin_popcount(m)
//scanf(" %d ", &t);
//L[i]=L[i/2]+1;
 
#define PI 3.14159265359
 
int n, k;
vector<int> g[2100];
bitset<2100> vis;
 
ii dfs(int v, int depth){
	ii ans(0,0);
	
	if(depth <= k/2) ans.first++;
	else if((k%2) && depth <= (k+1)/2) ans.second++; 
	else return ans;
	
	vis[v] = true;
	REP(i, g[v].size()){
		if(!vis[g[v][i]]){
			ii x = dfs(g[v][i], depth+1);
			ans.first += x.first;
			ans.second += x.second;
		}
	}
	return ans;
}
 
int main(){
	while(cin >> n >> k){
		int u, v;
		REP(i, n) g[i].clear();
		REP(i, n-1){
			cin >> u >> v;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		int ans = 0;
		REPP(i, 1, n+1){
			vis.reset();
			int tot = 1, gex = 0;
			vis[i] = true;
			REP(j, g[i].size()){
				ii x = dfs(g[i][j], 1);
				tot += x.first; 
				gex = max(gex, x.second);
			}
			tot += gex;
			ans = max(ans, tot);
		}
		ans = n-ans;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>

int main(void){
	int N, X, Y, Z, i, buf, cnt;
	bool a[100]={}, b[100]={}, c[100]={};
	scanf("%d", &N);
	for(scanf("%d", &X), i=0; i<X; ++i){ 
		scanf("%d", &buf);
		a[buf-1]=true;
	}
	for(scanf("%d", &Y), i=0; i<Y; ++i){ 
		scanf("%d", &buf);
		b[buf-1]=true;
	}
	for(scanf("%d", &Z), i=0; i<Z; ++i){ 
		scanf("%d", &buf);
		c[buf-1]=true;
	}
	
	for(i=0, cnt=0; i<N; ++i){
		if((!a[i]||b[i])&&c[i]){ ++cnt; }
	}
	
	printf("%d\n", cnt);
	return(0);
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int K;
  cin >> N >> K;
  vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  if(K > N){
    K = N;}
  sort(vec.begin(), vec.end());
    for(int i = 0; i < K; i++){
      vec.at(N-1-i) = 0;}
  long j = 0;
  for(int i = 0; i < N; i++){
    j += vec.at(i);}
  cout << j << endl;
}

Measured memory_bytes: 1024
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
function lower_bound(d,e,a=0,b=d.length){for(var c;1<b-a;)d[c=a+b>>1]<e?a=c:b=c;return d[a]<e?b:a};

var ans, dp = [0];
var g,a;


function main(){
  var n = next();
  a = nexts(n);
  g = xArray("[]",n);
  for(var i = 1; i < n; i++){
    var u = next()-1, v = next()-1;
    g[u].push(v);
    g[v].push(u);
  }
  ans = xArray(0,n);
  dfs(0,-1);
  return ans.join("\n");
}

function dfs(v,p){
  var ix = lower_bound(dp,a[v]),iv;
  if(ix < dp.length){
    iv = dp[ix];
    dp[ix] = a[v];
  }else ix++,dp.push(a[v]);
  ans[v] = dp.length-1;
  for(var i = 0; i < g[v].length; i++){
    var V = g[v][i];
    if(V === p)continue;
    dfs(V,v);
  }
  if(ix === dp.length)dp.pop();
  else dp[ix] = iv;
}

if (process.argv[2] === "--stack-size=262144") require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=480000"] });
else {
  var myOut = main();
  if(myOut !== undefined)console.log(myOut);
}

Measured memory_bytes: 170964
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		long[] A = new long[N];
		String[] a = new String[N];
		int max = 42;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			// 二進数を42桁で左側を0で埋める
			a[i] = String.format("%42s", Long.toBinaryString(A[i])).replace(" ", "0");
		}
		sc.close();
		String k = String.format("%42s", Long.toBinaryString(K)).replace(" ", "0");

		long[] c = new long[max];
		int[] b = new int[max];
		for(int i = 0; i < max; i++) {
			if(k.charAt(i) == '1') {
				b[i]++;;
			}
		}
		for(String s : a) {
			for(int i = 0; i < max; i++) {
				if(s.charAt(i) == '1') {
					c[i]++;
				}
			}
		}
		long[][] dp = new long[max + 1][2];
		for(int i = 0; i <= max; i++) {
			dp[i][0] = -1;
			dp[i][1] = -1;
		}
		dp[0][0] = 0;
		for(int i = 0; i < max; i++) {
			long t = (long)Math.pow(2, max - 1 - i);
			long v0 = t * c[i];			// i桁目を0としたときの報酬
			long v1 = t * (N - c[i]);	// i桁目を1としたときの報酬
			if(dp[i][1] != -1) {
				dp[i + 1][1] = Math.max(dp[i + 1][1], dp[i][1] + Math.max(v0, v1));
			}

			if(dp[i][0] != -1) {
				if(b[i] == 1) {
					dp[i + 1][1] = Math.max(dp[i + 1][1], dp[i][0] + v0);
					dp[i + 1][0] = dp[i][0] + v1;
				}else {
					dp[i + 1][0] = dp[i][0] + v0;
				}
			}
		}
		long ans = Math.max(dp[max][0], dp[max][1]);
		System.out.println(ans);
	}
	static void disp(long[] a) {
		for(long i : a) {
			System.out.printf("%d ", i);
		}
		System.out.println();
	}
	static void disp(int[] a) {
		for(long i : a) {
			System.out.printf("%d ", i);
		}
		System.out.println();
	}
}

Measured memory_bytes: 171132
H,W=map(int,input().split())
S=[list(map(str,input().split())) for _ in range(H)]
#print(S)
asciiA=65
for i in range(H):
    for j in range(W):
        if S[i][j]=="snuke":
            print("".join((chr(j+asciiA),str(i+1))))

Measured memory_bytes: 38384
import numpy as np
from math import factorial
n,p=map(int,input().split())
l=np.asarray(list(map(int,input().split())))
l%=2
o=np.sum(l)
e=n-o
def comb(n,r):
    return factorial(n)//factorial(n-r)//factorial(r)
ans=0
for i in range(p,o+1,2):
    ans+=comb(o,i)*(2**e)
print(ans)

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

int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    
    int v=(n-m)*100+m*1900;
    for(int i=0;i<m;i++) v*=2;
    printf("%d\n",v);
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vi a(n);
    rep(i,n) cin>>a[i];
    cout<<1+(n-2)/(k-1)<<"\n";
    return 0;
}


Measured memory_bytes: 640
import sys

s = input().split(" ")
n = int(s[0])
m = int(s[1])
a = []
for i in range(n):
	s = input().split(" ")
	a.append([int(s[0]), int(s[1])])

a.sort()
cnt = 0
ans = 0
for i in range(n):
	d = min(m-cnt, a[i][1])
	ans += d*a[i][0]
	cnt += d
	if cnt == m:
		break

print(ans)


Measured memory_bytes: 20012
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]
result = 'No'
x, y = map(int, input().split())

if x in g1:
    if y in g1:
        result = 'Yes'
elif x in g2:
    if y in g2:
        result ='Yes'
print(result)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

constexpr int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }

const int mod = TEN(9) + 7;

int N, K;
int a[200010];
vi comp;

int idx(int v)
{
	return lower_bound(all(comp), v) - begin(comp);
}

struct SegTree { // 区間sum
	int n;
	vector<int> Sum;
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		Sum.resize(2 * n);
		for (int i = 0; i < 2 * n - 1; ++i) {
			Sum[i] = 0;
		}
	}
	void update(int idx, int val) {
		idx += n - 1;
		Sum[idx] += val;
		while (idx > 0) {
			idx = (idx - 1) / 2;
			Sum[idx] = Sum[idx * 2 + 1] + Sum[idx * 2 + 2];
		}
	}
	int get_sum(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)のmax
		if (r == -1) r = n;
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return Sum[k];
		int vl = get_sum(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_sum(a, b, k * 2 + 2, (l + r) / 2, r);
		return (vl + vr);
	}
};

SegTree seg;

signed main()
{
	cin >> N >> K;
	
	seg.init(N * 2);

	int ans = 0;

	rep1(i, N) {
		cin >> a[i];
	}

	rep1(i, N) {
		a[i] += a[i - 1];
	}

	rep(i, N + 1) {
		a[i] -= K * i;
		comp.PB(a[i]);
	}

	sort(all(comp));
	comp.erase(unique(all(comp)), end(comp));

	seg.update(idx(0), 1);

	rep1(i, N) {
		ans += seg.get_sum(0, idx(a[i]) + 1);
		seg.update(idx(a[i]), 1);
	}

	cout << ans << endl;
}



Measured memory_bytes: 12276
#include<bits/stdc++.h>
#define int ll
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
using namespace std;
const int mod=1e9+7;
const int N=2e5+5;
bool isprime[N];
vl v;ll sum,ans;
ll n,x,y;int cnt[N];
ll cal(ll a,ll b)
{
	if(a==0)return 1;
	ll res=cal(a/2,b);
	if(a%2==0)res=res*res%mod;
	else res=res*res%mod*b%mod;
	return res;
}
ll Minus(ll num)
{
	sum=1;
	ll chu=1;
	for(int i=1;i<=num;i++)
		chu=chu*i%mod;
	for(int i=n;i>n-num;i--)
		sum=sum*i%mod;
	return sum*cal(mod-2,chu)%mod;
}
signed main()
{
	cin>>n>>x>>y;
	ans=cal(n,2);
	ans=(ans-1+mod)%mod;
	sum=Minus(x);
	ans=(ans-sum+mod)%mod;
	sum=Minus(y);
	ans=(ans-sum+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::{self, BufRead, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let _ = lines.next();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let b: Vec<i32> = splited.map(|n| n.parse().unwrap()).collect();

    let mut ans = b[0] + b[b.len() - 1];
    for i in 0..b.len() - 1 {
        ans += if b[i] < b[i + 1] { b[i] } else { b[i + 1] };
    }

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let output = io::stdout();

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"3
2 5", br"9
",
        ),
        (
            br"2
3", br"6
",
        ),
        (
            br"6
0 153 10 10 23", br"53
",
        ),
    ];

    #[test]
    fn test_c() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

/**
 * Handshake
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int MAX = 100000;

            int N = sc.nextInt();
            long M = sc.nextLong();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }

            long[] C = new long[MAX + 2];
            for (int a : A) {
                C[a]++;
            }

            long[] CS = new long[MAX + 2];
            for (int i = MAX; i >= 0; i--) {
                CS[i] += CS[i + 1] + C[i];
            }

            long[] S = new long[MAX + 2];
            for (int i = MAX; i >= 0; i--) {
                S[i] = S[i + 1] + i * C[i];
            }

            int min = 0;
            int max = MAX * 2 + 1;

            while (max - min > 1) {
                int mid = (max + min) / 2;

                long K = 0;
                for (int a : A) {
                    if (mid - a > MAX) {
                        continue;
                    }

                    K += CS[Math.max(mid - a, 0)];
                }

                if (K < M) {
                    max = mid;
                } else {
                    min = mid;
                }
            }

            long H = 0;
            long K = 0;
            for (int a : A) {
                if (max - a > MAX) {
                    continue;
                }

                H += a * CS[Math.max(max - a, 0)] + S[Math.max(max - a, 0)];
                K += CS[Math.max(max - a, 0)];
            }

            H += min * (M - K);

            System.out.println(H);
        }
    }

}


Measured memory_bytes: 50944
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>

#define true 1
#define false 0

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)


int calculate(int *l_ABC, int N, int A, int B, int C, int *l);
int min(int min_sum, int sum);

int min(int min_sum, int sum){
  if(min_sum>=sum){
    return sum;
  }
  else{
    return min_sum;
  }
}

int calculate(int *l_ABC, int N, int A, int B, int C, int *l){
  int lengtha=0, lengthb=0, lengthc=0;
  int mp=0;
  //最低一つはないといけない。その検査用
  int flaga=0, flagb=0, flagc=0;

  rep(i,N){
    if(l_ABC[i]==0){
      lengtha=lengtha+l[i];
      mp=mp+10;
      flaga=1;
    }
    else if(l_ABC[i]==1){
      lengthb=lengthb+l[i];
      mp=mp+10;
      flagb=1;
    }
    else if(l_ABC[i]==2){
      lengthc=lengthc+l[i];
      mp=mp+10;
      flagc=1;
    }
    else{
      ;
    }
  }

  if(flaga!=1 || flagb!=1 || flagc!=1){
    return 100000;
  }

  mp=mp-30;//多く換算した分を引く

  mp=mp+abs(lengtha-A)+abs(lengthb-B)+abs(lengthc-C);

  return mp;
}


int main(){
  char buf[1024];
  int N, A, B, C;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d %d %d %d", &N, &A, &B, &C);

  //l[]長さ
  int *l=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    fgets(buf, sizeof(buf), stdin);
    sscanf(buf, "%d", &l[i]);
  }

  //0:A, 1:B, 2:C, 3:なし
  int *l_ABC=(int *)malloc(sizeof(int)*N);

  //求める最小値
  int min_sum=1000000;
  //途中経過
  int sum;

  rep(i,pow(4,N)){

    int quo=i;
    rep(j,N){
      l_ABC[j]=quo%4;
      quo=(quo-l_ABC[j])/4;
    }

    sum=calculate(l_ABC, N,A, B, C, l);

    min_sum=min(min_sum, sum);
  }

  printf("%d\n", min_sum);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int a[8], b[8], wa[8],i;
    for (i = 1; i <= 7; i++) {
        scanf("%d %d", &a[i], &b[i]);
        wa[i] = a[i] -b[i];
    }
    for (i = 1; i <= 7; i++) {
        printf("%d\n", wa[i]);
    }
}

Measured memory_bytes: 1028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int N=cin.nextInt();
        bool x = false;
        if(N<82)
        {
          for(int i=1;i<10;i++)
          {
            if(N%i==0&&N/i<10)x=true;
          }
        }
        if(x)Console.WriteLine("Yes");
        else Console.WriteLine("No");
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 11092
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n){
    ll A;
    cin >> A;
    A -= i + 1;
    a[i] = A;
  }
  sort(a.begin(), a.end());
  if(n % 2 == 0){
    ll ans = 0, ans2 = 0;
    ll num = a[n / 2];
    rep(i, n) ans += abs(a[i] - num);
    num = a[n / 2 - 1];
    rep(i, n) ans2 += abs(a[i] - num);
    ans = min(ans, ans2);
    cout << ans << endl;
  }else{
    ll num = a[n / 2];
    ll ans = 0;
    rep(i, n) ans += abs(a[i] - num);
    cout << ans << endl;
  }
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll N, D;
    cin >> N >> D;
    cout << ((N+2*D)/(2*D+1)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    long long int a,b;
    cin >> a >> b;
    long long int A = a,B = b;
    long long int r;
    while(a % b != 0)
    {
        long long int r;
        r = a % b;
        a = b;
        b = r;
    }
    cout << A * B / b << "\n";

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int dist[10];

ll INF=1e5+2;

void bfs(vector<pi> edges[]){
	dist[1]=0;
	queue<int> q;
	q.push(1);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto w : edges[x] )
			if(dist[w.F] > dist[x]+w.S){
				dist[w.F]=dist[x]+w.S;
				//error(dist[w.F],w.F);
				q.push(w.F);
			}
	}
}

int main(){
	startTime=clock();
	int h,w;
	int c[10][10];
	cin >> h >> w;
	std::vector<pi> edges[10];
	FOR(i,10)
		FOR(j,10){
			cin >> c[j][i];
			edges[j].eb(MP(i,c[j][i]));
		}
	int a[h][w];
	int cost=0;
	FOR(i,10) dist[i]=INF;
	
	bfs(edges);
	FOR(i,h)
		FOR(j,w){
			cin >> a[i][j];
			if(a[i][j]!=1){
				cost+=dist[a[i][j]];
			}
		}
	cout << cost;


	return 0;
}

Measured memory_bytes: 3784
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

int n, m, ans[N];
bool ac[N];

void test() {
    cin >> n >> m;
    int cnt = 0;
    while (m--) {
        int a;
        string b;
        cin >> a >> b;
        if (!ac[a]) {
            if (b[0] == 'A') {
                ac[a] = true;
                ++cnt;
            } else {
                ++ans[a];
            }
        }
    }
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        if (ac[i]) {
            res += ans[i];
        }
    }
    cout << cnt << " " << res << "\n";
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


Measured memory_bytes: 768
// https://atcoder.jp/contests/abc106/tasks/abc106_b
#include <bits/stdc++.h>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

bool f(int x){
	int cnt=0;
	for (int i = 1; i*i < x; i++){
		if(x%i==0)cnt+=2;
	}
	return cnt==8;
}

int main()
{
	int n;
	cin>>n;
	int cnt=0;
	repi(i,1,n+1) if(i%2!=0&&f(i)) cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3632
def main():
    n,m = map(int,input().split())
    s = list(input())
    sap = s.append
    _ = s.pop(-1)
    ans = []
    while True:
        x = []
        sl = len(s)
        xap = x.append
        f = False
        for i in range(m):
            if s:
                xap(s.pop(-1))
            else:
                f = True
                break
        if f:
            ans.append(sl)
            break
        lx = len(x)
        stop = 0
        g = False
        amari = []
        for i in range(lx):
            y = x.pop(-1)
            if y == "0":
                stop = m-i
                g = True
                break
            else:
                amari.append(y)
        if g:
            for i in range(len(amari)):
                sap(amari.pop(-1))
            ans.append(stop)
            if not s:
                break
        else:
            ans = -1
            break
    if ans == -1:
        print(ans)
    else:
        print(" ".join([str(i) for i in list(reversed(ans))]))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 52492
#define N 25
#include <stdio.h>

struct Node {
    int parent;
    int left;
    int right;
};

struct Node T[N];

void Preorder(int n) {
    if (n == -1) {
        return;
    }
    printf(" %d", n);
    Preorder(T[n].left);
    Preorder(T[n].right);
}

void Inorder(int n) {
    if (n == -1) {
        return;
    }
    Inorder(T[n].left);
    printf(" %d", n);
    Inorder(T[n].right);    
}

void Postorder(int n) {
    if (n == -1) {
        return;
    }
    Postorder(T[n].left);
    Postorder(T[n].right);
    printf(" %d", n);      
}

int main() {
    int n = 0;
    scanf("%d", &n);
    for (int i = 0; i <= N; i++) {
        T[i].parent = -1;
    }
    for (int i = 0; i < n; i++) {
        int id, l, r;
        scanf("%d %d %d", &id, &l, &r);
        T[id].left = l;
        T[id].right = r;
        if (l != -1) {
            T[l].parent = id;
        }
        if (r != -1) {
            T[r].parent = id;
        }
    }
    int root = 0;
    for (int i = 0; i < n; i++) {
        if (T[i].parent == -1) {
            root = i;
        }
    }
    printf("Preorder\n");
    Preorder(root);
    printf("\n");
    printf("Inorder\n");
    Inorder(root);
    printf("\n");
    printf("Postorder\n");
    Postorder(root);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
 
using namespace std;
using ll = long long;
 
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  double ans = a[0];
  rep(i, n-1) {
    ans = (ans + a[i+1]) / 2;
  }
  cout << fixed << setprecision(15) << ans << endl;
}

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

int main() {
	string n; cin >> n;
	int a, b; cin >> a >> b;

	int ans = 0;
	vector<int> v;
	for (int i = 0; i < stoi(n); i++) {
		for (auto & e : to_string(i + 1)) {
			v.push_back(e - '0');
		}

		int sum = 0;
		for (int j = 0; j < v.size(); j++) {
			sum += v[j];
		}

		if (a <= sum && sum <= b) ans += (i+1);
		v.clear();
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

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

string s = "";
char ch[10];
int n, a, b, c, d, x, m[5];

int main() {
	cin >> n >> a;
	cout << (n % 500 <= a ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
R = [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]
K = int(input())

print(R[K-1])

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

int main() {

    int a[6];

    int ans;

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

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


Measured memory_bytes: 3724
#!/usr/bin/env python3
import sys


def solve(N: int):
    a = N % 1000
    if a == 0:
        print(0)
    else:
        print(1000 - a)
    return


# Generated by 1.1.7.1 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
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def f(A):
    min_num = A[0] + A[-1]


def main():
    N, K, S = read_values()
    L = [S] * K
    L += ([S + 1] if S != 10 ** 9 else [1]) * (N - K)
    print(" ".join(map(str, L)))


if __name__ == "__main__":
    main()


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

const int N = 1000 * 1000 + 20;

int ans;
long long A, B, C;

int main() {
    cin >> A >> B >> C;
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0 && ans <= N) {
        int tmp[3];
        tmp[0] = (B + C) / 2;
        tmp[1] = (A + C) / 2;
        tmp[2] = (A + B) / 2;
        A = tmp[0];
        B = tmp[1];
        C = tmp[2];
        ans++;
    }

    if (ans >= N)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: i64
    };

    if n == 1 {
        println!("{}", 1);
        return;
    }
    let mut ans = 1_000_000_000_000_000_i64;
    for a in 1..n {
        if a * a > n {
            break;
        }
        if n % a == 0 {
            let mut b = n / a;
            let mut c = 0;
            while b > 0 {
                b /= 10;
                c += 1;
            }
            ans = std::cmp::min(ans, c);
        }
    }
    println!("{}", ans);
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

int f(int x,int y,char op)
{
        if(op=='+')return x+y;
        return x-y;
}

main()
{
        string s; cin>>s;
        int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
        vector<char> op={'+','-'};
        rep(i,2)
        {
                rep(j,2)
                {
                        rep(k,2)
                        {
                                int t=f(a,b,op[i]);
                                t=f(t,c,op[j]);
                                t=f(t,d,op[k]);
                                if(t==7)
                                {
                                        printf("%d%c%d%c%d%c%d=7\n",a,op[i],b,op[j],c,op[k],d);
                                        return 0;
                                }
                        }
                }
        }

}



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

const int MAXNODES = 300;

const int64_t INFTY = (1LL << 32);
int n;
int64_t df[MAXNODES][MAXNODES];
int64_t df2[MAXNODES][MAXNODES];


void floyd(int64_t df[][MAXNODES]) {
    for (int k  = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (df[i][k] == INFTY) continue;
            for (int j = 0; j < n; j++) {
                if (df[k][j] == INFTY) continue;
                df[i][j] = min(df[i][j], df[i][k] + df[k][j]);
            }
        }
    }
}

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

    for (int i = 0; i < MAXNODES; i++) {
        for (int j = 0; j < MAXNODES; j++) {
            df[i][j] = INFTY;
        }
    }

    int M, L;
    cin >> n >> M >> L;
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        df[a][b] = df[b][a] = c;
    }
    floyd(df);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (df[i][j] <= L) {
                df2[i][j] = 1;
            } else {
                df2[i][j] = INFTY;
            }
        }
    }
    floyd(df2);

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        if (df2[s][t] < INFTY) {
            cout << df2[s][t] - 1 << endl;
        } else {
            cout << -1 << endl;
        }
    } 

    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(n);
	makei(a);
	makei(b);
	int r1 = 0;
	int r2 = 0;
	int r3 = 0;
	rep(n) {
		makei(p);
		if (p <= a)r1++;
		else if (p <= b)r2++;
		else r3++;
	}
	say(min(r1, min(r2, r3)));
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool isprime(int n){
    if(n <= 1) return false;
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
int main(){
    int a, d, n;
    while(cin>>a>>d>>n && a){
        int ans;
        while(true){
            if(isprime(a)) n--;
            if(n <= 0){
                ans = a;
                break;
            }
            a += d;
        }
        cout<<ans<<endl;
    }
    return 0;
}
    

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<algorithm>

using namespace std;

int main(void) {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[0] + a[1] << endl;
	return 0;

}

Measured memory_bytes: 764
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int X = Integer.parseInt(sc.get());
		int Y = Integer.parseInt(sc.get());
		int[] ints = {
				Y < X ? Integer.MAX_VALUE : Y - X,
				-Y < X ? Integer.MAX_VALUE : -Y - X + 1,
				Y < -X ? Integer.MAX_VALUE : Y - (-X) + 1,
				-Y < -X ? Integer.MAX_VALUE : (-Y) - (-X) + 2
		};
		Arrays.sort(ints);
		for (int x : ints) {
			if (x >= 0) {
				System.out.println(x);
				return;
			}
		}
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			private StringTokenizer tokenizer;

			public String get() {
				try {
					return (tokenizer = tokenizer != null && tokenizer.hasMoreTokens() ? tokenizer : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}


Measured memory_bytes: 21460