akhauriyash/Code-Regression huggingface dataset:
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())

mn = 1001001001001
a = 1
while a*a <= N:
    if N % a == 0:
        mn = min(mn, a + N//a - 2)
    a += 1
print(mn)
    

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


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

int Binary(int a[],int sizea,int b[],int sizeb){
  int num=0;
  int j=0;
  int i=0;
  do{
    if(i>=sizea||j>=sizeb){
      break;
    }

    if(a[i]==b[j]){
      num++;
      i++;
      j++;
    }else if(a[i]>b[j]){
      j++;
      if(j>=sizeb){
        break;
      }
    }else if(a[i]<b[j]){
      i++;
      if(i>=sizea){
        break;
      }
    }
  }while(i<=sizea||j<=sizeb);
  return num;
}

int main(){
  int n;
  cin>>n;
  int S[n];
  for(int i=0;i<n;i++){
    cin>>S[i];
  }

  int q;
  cin>>q;
  int T[q];
  for(int i=0;i<q;i++){
    cin>>T[i];
  }

  sort(T,T+q);

  cout<<Binary(S,n,T,q)<<endl;
}



Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  
  if (N <= A) {
  	cout << "Yes" << endl;
  	return 0;
  }
  
  if (N % 500 <= A) {
  	cout << "Yes" << endl;
  	return 0;
  } else {
  	cout << "No" << endl;
  	return 0;
  }
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  string color, ans;
  ans = "Three";
  
  for(int i =0; i < N; i++){
    cin >> color;
    
    if(color == "Y"){
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    string S;
    cin >> S;

    if (S[0] == S[1] && S[1] == S[2]) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0LL;i<n;i++)
int main(){
    ll n,tmp,count=0,m=0,l=0;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i,n)cin >> a.at(i);
    rep(i,n)cin >> b.at(i);
    rep(i,n)cin >> c.at(i);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    rep(i,n){
        m = lower_bound(a.begin(),a.end(),b.at(i))-a.begin();
        l = c.end()-upper_bound(c.begin(),c.end(),b.at(i));
        count += m*l;
    }
    cout << count << endl;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    int x[N];
    int mine = 1000000000;
    int time,time1,time2;
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    for(int i = 0; i <= N-K; i++){
        time1 = abs(x[i]) + x[i+K-1] - x[i];
        time2 = abs(x[i+K-1]) + x[i+K-1] - x[i];
        time = min(time1,time2);
        if(time <= mine) mine = time;
    }

    cout << mine << endl;
    return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1e5+5;

int a[N];

int main()
{
	int n,m,s,i;
	scanf("%d%d%d",&n,&m,&s);
	if(s==1e9){
		for(i=1;i<=m;i++)a[i]=s;
		for(;i<=n;i++)a[i]=1;
	}
	else{
		for(i=1;i<=m;i++)a[i]=s;
		for(;i<=n;i++)a[i]=s+1;
	}
	for(i=1;i<=n;i++)
		printf("%d ",a[i]);
	return 0;
}

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

typedef long long ll;

int main() {
    int A, B, K, ans = 101;
    cin >> A >> B >> K;
    while (K > 0) {
        ans--;
        if (A % ans == 0 && B % ans == 0) K--;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
def not_card(li, c_type):
    for i in range(1, 14):
        if i not in li:
            print('{} {}'.format(c_type, i))

n = int(input())
card_s = []
card_h = []
card_c = []
card_d = []
for i in range(n):
    card_type, num = input().split()
    num = int(num)
    if   card_type == 'S':
        card_s.append(num)
    elif card_type == 'H':
        card_h.append(num)
    elif card_type == 'C':
        card_c.append(num)
    else:
        card_d.append(num)
card = [card_s, card_h, card_c, card_d]
for array, w in zip(card, 'SHCD'):
    not_card(array, w)

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

int main() {
	int t,h,m,s;
	cin >> t;
	m = t / 60;
	s =t % 60;
	h = m /60;
	m = m % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3104
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 16 20:49:48 2018
ABC100C
@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))

cnt = 0
for x in a:
    while True:
        if x % 2 == 0:
            cnt += 1
            x = x/2
        else:
            break

print(cnt)
        


Measured memory_bytes: 4148
def CountingSort(A,k):
    C=[0]*(k+1)
    for a in A:
        C[a]+=1
    for i in range(k):
        C[i+1]+=C[i]
    ret=[0]*len(A)
    for a in A[::-1]:
        ret[C[a]-1]=a
        C[a]-=1
    return ret
n=int(input())
A=list(map(int,input().split()))
print(*CountingSort(A,max(A)))


Measured memory_bytes: 224380
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int m;cin>>m;
  ll power = -10;
  ll ans = 0;
  REP(i,m){
    ll d,c;cin>>d>>c;
    power += (d+9) * c;
    ans += power/9;
    power %= 9;
  }

  cout<<ans<<endl;

 

  return 0;
}

Measured memory_bytes: 256
import static java.lang.System.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		B(sc);
	}
	
	public static void A(Scanner sc) {
		int left =  0;
		int right = 0;
		for(int i=0;i<2;i++) {
			left += sc.nextInt();
		}
		for(int i=0;i<2;i++) {
			right += sc.nextInt();
		}
		if(left==right) out.println("Balanced");
		else if(left>right) out.println("Left");
		else out.println("Right");
	}
	
	
	//各桁の和を計算
	public static int calcsumo(int x) {
		String s = String.valueOf(x);
		int sum = 0;
		for(int i=0;i<s.length();i++) {
			sum += Character.getNumericValue((s.charAt(i)));
		}
		return sum;
	}
	public static void B(Scanner sc) {
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int sum = 0;
		for(int i=1;i<=N;i++) {
			int temp = calcsumo(i);
			if(temp>=A && temp<=B) sum+=i;
		}
		out.println(sum);
	}
}


Measured memory_bytes: 23124
/****************** 			***********************/
     /****************BSMRSTU*****************/
/***********BISMILLAHIR RAHMANIR RAHIM*************/
/*.................Mohammad Imran................*/
/*..................Dept Of CSE.................*/

#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define pi acos(-1.0)
#define dd double
const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;
const int mod        = (int)1e9 + 7 ;
using namespace std;
int main(){
	ll a,b;
	ll m=1,n=2,o=3;
	cin>>a>>b;
	
	if(((a==m)&&(b==n))|| ((a==n)&&(b==m))){
		cout<<o;
	}
	else if(((a==m)&&(b==o))|| ((a==o)&&(b==m))){
		cout<<n;
	}
	else if(((a==n)&&(b==o))|| ((a==o)&&(b==n))){
		cout<<m;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long k = sc.nextLong();

//		int n = sc.nextInt();


		String string = sc.next();
		String[] s = string.split("");
		String string2 = sc.next();
		String[] t = string2.split("");

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

		for(int i = 0; i < s.length; i++) {
			if(!s[i].equals(t[i])) {
				ans++;
			}
		}

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

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}



}

Measured memory_bytes: 65740
from collections import deque

N, M = map(int, input().split())
A = [int(input()) for i in range(M)]

comb_stairs = [1]
D = deque(A)

for i in range(1, N + 1):
    if i == 1:
        if len(D) == 0:
            comb_stairs.append(1)
        elif D[0] == 1:
            comb_stairs.append(0)
            D.popleft()
        else:
            comb_stairs.append(1)
    else:
        if len(D) == 0:
            comb_stairs.append(comb_stairs[i - 1] + comb_stairs[i - 2])
        elif D[0] == i:
            comb_stairs.append(0)
            D.popleft()
        else:
            comb_stairs.append(comb_stairs[i - 1] + comb_stairs[i - 2])

print(comb_stairs[-1] % 1000000007)


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

int main(){
  ll n;
  ll total = 0;
  cin >> n;
  vector<ll> A(n);
  rep(i,n) cin >> A[i];
  rep(i,n) total += A[i];
  ll l = 0;
  ll k = total;
  ll a;
  for(ll j = 0;2*l<=total;++j){
    l += A[j];
    a = min(k,abs(total-2*l));
    k = abs(total - 2*l);
    k = min(k,abs(total - 2*l));
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 1792
n = int(input())
an = list(map(int,input().split()))

mod = 10**9 + 7
total =sum(an)
ans = 0
z = an[0]

for x in range(n-1):
  nokori = total-z
  ans += an[x] * nokori % mod
  z += an[x+1]

    
ans = ans % mod    
print(ans)
    

Measured memory_bytes: 31592
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int AS = 500000;
int dat[2 * AS];
void modify(int p, int c, int value) {
	p += AS;
	if (value) {
		int tmp = 1 << c;
		dat[p] = dat[p] | tmp;
	}
	else {
		int tmp = ~(1 << c);
		dat[p] = dat[p] & tmp;
	}
	for (; p > 1; p >>= 1) {
		dat[p >> 1] = dat[p] | dat[p ^ 1];
	}
}

int query(int l, int r) {
	int ret = 0;
	for (l += AS, r += AS; l < r; l >>= 1, r >>= 1) {
		if (l & 1) ret |= dat[l++];
		if (r & 1) ret |= dat[--r];
	}
	return ret;
}

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


	int N;
	string S;
	cin >> N;
	cin >> S;

	rep(i, S.size()) {
		modify(i, S[i] - 'a', 1);
	}

	int Q;
	cin >> Q;

	rep(j, Q) {
		int q;
		cin >> q;
		if (q == 1) {
			int i;
			char c;
			cin >> i;
			cin >> c;
			i--;
			modify(i, S[i] - 'a', 0);
			modify(i, c - 'a', 1);
			S[i] = c;
		}
		else {
			int l, r;
			cin >> l >> r;
			co(__builtin_popcount(query(l - 1, r)));
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 4892
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, ans = 0;
    cin >> n;
    int b[n - 1];
    rep(i, n - 1) cin >> b[i];

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]) 
        cout << "Yes\n";
    else cout << "No\n";
}

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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int a[101];
	int n; cin >> n;
	rep(i, n) cin >> a[i + 1];
	int cnt = 0;
	rep(i, n) if (a[i + 1] % 2 && (i + 1) % 2) cnt++;
		cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#define llint long long

using namespace std;

struct BTNode{
	llint size;
	llint next[2];
	BTNode(){
		size = 0;
		next[0] = next[1] = -1;
	}
};

struct BinaryTrie{
	llint len;
	vector<BTNode> trie;
	BinaryTrie(llint l){
		len = l;
		trie.push_back(BTNode());
	}
	void clear(){
		trie.clear();
		trie.push_back(BTNode());
	}
	llint size(){
		return trie[0].size;
	}
	void insert(llint x, llint num = 1){
		llint p = 0;
		for(int i = len-1; i >= 0; i--){
			trie[p].size += num;
			int e = (x>>i) & 1;
			if(trie[p].next[e] == -1){
				trie.push_back(BTNode());
				trie[p].next[e] = trie.size()-1;
			}
			p = trie[p].next[e];
		}
		trie[p].size += num;
	}
	llint count(llint x){
		llint p = 0;
		for(int i = len-1; i >= 0; i--){
			int e = (x>>i) & 1;
			if(trie[p].next[e] == -1) return 0;
			p = trie[p].next[e];
		}
		return trie[p].size;
	}
	void erase(llint x, llint num = 1){
		num = min(num, count(x));
		llint p = 0;
		for(int i = len-1; i >= 0; i--){
			trie[p].size -= num;
			int e = (x>>i) & 1;
			if(trie[p].next[e] == -1){
				trie.push_back(BTNode());
				trie[p].next[e] = trie.size()-1;
			}
			p = trie[p].next[e];
		}
		trie[p].size -= num;
	}
	llint lower_bound(llint x){ //x以上の最小要素が小さい方から何番目か(k = 0が最小)
		llint p = 0, ret = 0;
		for(int i = len-1; i >= 0; i--){
			int e = (x>>i) & 1;
			if(e == 1 && trie[p].next[0] != -1) ret += trie[trie[p].next[0]].size;
			if(trie[p].next[e] == -1 || trie[trie[p].next[e]].size == 0) break;
			p = trie[p].next[e];
		}
		return ret;
	}
	llint getMin(llint k = 0, llint x = 0){ //xとのXORのうちk番目に小さい値(k = 0が最小)
		if(trie[0].size <= k) return -1;
		llint p = 0, ret = 0, sum = 0;
		for(int i = len-1; i >= 0; i--){
			int e = (x>>i) & 1;
			if(trie[p].next[e] == -1 || sum + trie[trie[p].next[e]].size <= k){
				if(trie[p].next[e] != -1) sum += trie[trie[p].next[e]].size;
				e = 1 - e;
			}
			p = trie[p].next[e];
			ret |= ((llint)e) << i;
		}
		return ret;
	}
};

llint n;
llint a[100005], b[100005], c[100005];
BinaryTrie bt(30), bt2(30);

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	for(int i = 1; i <= n; i++) cin >> c[i];
	
	for(int i = 1; i <= n; i++) bt.insert(a[i]), bt2.insert(c[i]);
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		ans += bt.lower_bound(b[i]) * (n-bt2.lower_bound(b[i]+1));
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, k, q, out;
V g[ohara], kae[ohara];
ll cou[ohara];
ld dp_mae[1000][1000], he[1000];
ld ans;
ll dat[1000];

void uku() {
  ld dp[n + 10] = {};
  rrrep(j, n - 2, 0) {
    rep(k, Size(g[j])) {
      ll to = g[j][k];
      dp[j] += dp[to];
    }
    dp[j] /= (ld)Size(g[j]);
    dp[j] += 1.0;
  }
  ans = dp[0];
}

int main(void) {
#pragma target("avx")
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    g[a[i]].p_b(b[i]);
  }

  uku();

  rep(i, n - 1) {
    if (Size(g[i]) == 1) continue;
    ld dp[n + 10] = {};
    rrrep(j, n - 2, 0) {
      ld usitapunikiakunwara = -1.0;
      rep(k, Size(g[j])) {
        ll to = g[j][k];
        dp[j] += dp[to];
        if (usitapunikiakunwara <= dp[to]) usitapunikiakunwara = dp[to];
      }
      if (i == j) {
        dp[j] -= usitapunikiakunwara;
        dp[j] /= (ld)(Size(g[j]) - 1.0);
      } else {
        dp[j] /= (ld)Size(g[j]);
      }
      dp[j] += 1.0;
    }
    if (ans >= dp[0]) {
      ans = dp[0];
    }
  }
  doublecout(ans);
  return 0;
}


Measured memory_bytes: 55808
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);    

    ll n,d;
    cin>>n>>d;
    d=d*d;
    ll ans=0;
    for (int i = 0; i < n; ++i)
    {
        ll x,y;
        cin>>x>>y;
        ll dis = (x*x)+(y*y);
        if(dis<=d){
            ans++;
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <cassert>

using namespace std;
typedef long long ll;

int n,k;
char s[105];
int main(){
//  freopen("c.in","r",stdin);
//  freopen("c.out","w",stdout);
  scanf("%d",&n);
  if(n == 0){
    puts("0");
    return 0;
  }
  for(k = 0;n;k++){
    if(n % 2){
      s[k] = '1';
      if(k % 2) n++;
      else n--;
    }else{
      s[k] = '0';
    }
    n /= 2;
  }
  for(k = k - 1;k >= 0;k--) printf("%c",s[k]);
  printf("\n");
  return 0;
}


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

int main()
{
	int N,Y,x,y,z;
	cin>>N>>Y;
	
	for(x=0;x<=Y/10000;x++)
		for(y=0;y<=Y/5000;y++){
			z=N-x-y;
			if (z>=0 && x*10000+y*5000+z*1000==Y){
				cout<<x<<" "<<y<<" "<<z;
				return 0;
			}
		}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e6 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll INF = 1e18;
using namespace std;

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	int n, m;
	cin >> n >> m;
	ll total = 0, a;
	for (int i = 0; i < m; ++i) {
		cin >> a;
		total += a;
	}
	if(total > n) {
		cout << -1;
	} else {
		cout << n - total;
	}
	return 0;
}


Measured memory_bytes: 3640
var
  tong:array[1..100] of longint;
  a,b,c,i,s:longint;
begin
  readln(a,b,c);
  inc(tong[a]);
  inc(tong[b]);
  inc(tong[c]);
  for i:=1 to 100 do if tong[i]>0 then inc(s);
  writeln(s);
end.

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

using namespace std;

int a,b,c,d,e,f;
vector<int> water,suger;

int main(){
  cin >> a >> b >> c >> d >> e >> f;
  //water a<b
  for(int i=0;;i++){
    for(int j=0;;j++){
      if(i==0 && j==0) continue;
      if(100*b*i+100*a*j>f) break;
      water.push_back(100*b*i+100*a*j);
    }
    if(100*b*i>f) break;
  }
  //suger c<d
  for(int i=0;;i++){
    for(int j=0;;j++){
      if(d*i+c*j>f) break;
      suger.push_back(d*i+c*j);
    }
    if(d*i>f) break;
  }
  double max=0;
  pair<int,int> p;
  for(int i=0;i<water.size();i++){
    for(int j=0;j<suger.size();j++){
      //cout << water[i] << " " << suger[j] << endl;
      int suger_water=suger[j]+water[i];
      if(suger[j]>(water[i]*e)/100 || suger_water>f) continue;
      double con=(double)suger[j]/(double)(suger_water);
      if(max<=con){
        max=con;
        p=make_pair(suger_water,suger[j]);
      }
    }
  }
  cout << p.first << " " << p.second << endl;
}

Measured memory_bytes: 1400
d = gets.split[0].to_i
n = Array.new(d, nil)
while a = gets
  ai = a.split[0].to_i
  an = a.split[1]
  if d > 1 && ai == 1 && an == "0"
    puts -1
    exit
  end
  if n[ai-1] && n[ai-1] != an
    puts -1
    exit
  else
    n[ai-1] = an
  end
end
n[0] = 1 if d > 1 && n[0] == nil
n.map!{|x| x == nil ? 0 : x}
puts n.join

Measured memory_bytes: 1788
from functools import lru_cache
n = int(input())
s = list(map(int, input().split()))


@lru_cache(maxsize=None)
def cost_e():
    res = 0
    sum = 0
    for j, y in enumerate(s, 1):
        tmp = sum + y
        if j & 1 and tmp >= 0:
            sum = -1
            res += abs(tmp) + 1
        elif not j & 1 and tmp <= 0:
            sum = 1
            res += abs(tmp) + 1
        else:
            sum = tmp
    return res


@lru_cache(maxsize=None)
def cost_o():
    res = 0
    sum = 0
    for j, y in enumerate(s, 1):
        tmp = sum + y
        if j & 1 and tmp <= 0:
            sum = 1
            res += abs(tmp) + 1
        elif not j & 1 and tmp >= 0:
            sum = -1
            res += abs(tmp) + 1
        else:
            sum = tmp
    return res


print(min(cost_e(), cost_o()))


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<vector<int64_t>> adjs(n);
    for (auto _ : irange(0L, m)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    vector<int64_t> p(n, -1L);
    queue<int64_t> q;
    q.push(0);
    p[0] = 0;
    while (!q.empty()) {
        auto v = q.front();
        q.pop();

        for (auto u : adjs[v]) {
            if (p[u] >= 0) {
                continue;
            }

            p[u] = v + 1;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    for (auto v : irange(1L, n)) {
        cout << p[v] << "\n";
    }
}

Measured memory_bytes: 13024
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	ll n, m;

	cin >> n >> m;

	if (abs(n - m) > 1) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;

	for (ll i = 1; i <= n; i++) {
		ans *= i;
		ans %= MOD;
	}

	for (ll i = 1; i <= m; i++) {
		ans *= i;
		ans %= MOD;
	}

	if (n == m)ans = ans * 2 % MOD;

	//ans %= MOD;

	cout << ans << endl;


	return 0;
}

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

int main(){
    int INF = 1e8;
    int ans = INF;
    int c[10][1005];
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    rep(div,1<<(h-1)){
        int g=0;
        vector<int> id(h);
        rep(i,h){
            id[i]=g;
            if(div>>i&1)g++;
        }
        g++;
        
        int num = g-1;
        rep(i,g)rep(j,w) c[i][j]=0;
        rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');
        vector<int> now(g);
        
        auto add = [&](int j){
            rep(i,g) now[i] += c [i][j];
            rep(i,g) if(now[i]>k) return false;
            return true;
        };
        rep(j,w){
            if(!add(j)){
                num++;
                now = vector<int>(g);
                if(!add(j)){
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans,num);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    cout<<max({a+a-1,a+b,b+b-1})<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h>
#include <bits/stdc++.h>
#include <math.h>

#define DEBUG 0;
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){

#ifdef DEBUG
//    std::ifstream in("resource/input.txt");
//    std::cin.rdbuf(in.rdbuf());
#endif

    string S,T;
    cin >> S >> T;
    int res = 0;

	REP(i,3)
	{
		if(S[i] == T[i])++res;
	}
    cout << res << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
#include <cstdint>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  std::sort(A.begin(), A.end(), std::greater<>());
  std::int64_t comfort = A[0];
  for (int i = 2, j = 1; i < N; j += i & 1, ++i) {
    comfort += A[j];
  }
  std::cout << comfort << std::endl;
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	int N;
	cin >> N;

	if(N%2 == 1){ cout << "No" << "\n"; return 0;}
	else{
		string S;
		cin >> S;

		REP(i,N/2){
			if(S[i] != S[N/2 + i]){
				cout << "No" << "\n"; return 0;
			}
		}

		cout << "Yes" << "\n";
	}


return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    string S;
    cin >> S;
    if(S == "ABC") {
        cout << "ARC" << endl;
    }
    else if(S == "ARC") {
        cout << "ABC" << endl;
    }
}

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

int main(){
  int a,b,c,k;cin>>a>>b>>c>>k;
  int s=a+b+c,m=max({a,b,c});s-=m;
  for(int i=0;i<k;i++)m*=2;
  cout<<s+m<<endl;
} 


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    for(;;){
        int w, h, t, p;
        cin >> w >> h >> t >> p;
        if(w == 0)
            return 0;

        vector<vector<int> > v(h, vector<int>(w, 1));
        while(--t >= 0){
            int d, c;
            cin >> d >> c;

            int h2 = h;
            int w2 = w;
            int cy = 0;
            int cx = 0;
            if(d == 1){
                w2 = max(c, w - c);
                cx = c;
            }
            else{
                h2 = max(c, h - c);
                cy = c;
            }

            vector<vector<int> > v2(h2, vector<int>(w2, 0));
            for(int y=0; y<h; ++y){
                for(int x=0; x<w; ++x){
                    int y2 = abs(y * 2 - cy * 2 + 1) / 2;
                    int x2 = abs(x * 2 - cx * 2 + 1) / 2;
                    v2[y2][x2] += v[y][x];
                }
            }
            v = move(v2);
            h = h2;
            w = w2;
        }

        while(--p >= 0){
            int x, y;
            cin >> x >> y;
            cout << v[y][x] << endl;
        }
    }
}



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

signed main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int ta = false;
  while(true){
    if(ta)A -= D;
    else C -= B;
    ta = !ta;
    if(A <= 0){cout << "No";break;}
    if(C <= 0){cout << "Yes";break;}
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  int cnt[3][10];
  bool flag = true;
  for(int i = 0; i < 3; ++i){
    for(int j = 0; j < 10; ++j){
      cnt[i][j] = 0;
    }
  }
  for(int i = 0, q1, q2; i < m; ++i){
    cin >> q1 >> q2;
    q1 = n - q1;
    cnt[q1][q2]++;
  }
  int index[3];
  for(int i = 0; i < 3; ++i) index[i] = 0;
  for(int i = 0; i < n; ++i){
    flag = true;
    for(int j = 0; j < 10; ++j){
      if(cnt[i][j] > 0){
        if(!flag){
          cout << "-1" << endl;
          return 0;
        }
        else{
          flag = false;
          index[i] = j;
        }
      }
    }
  }
  if(n > 1 && cnt[n - 1][0] > 0){
    cout << "-1" << endl;
    return 0;
  }
  int ans = 0;
  if(n > 1 && index[n - 1] == 0) index[n - 1] = 1;
  for(int i = 0, base = 1; i < n; ++i, base*= 10){
    ans += index[i] * base;
  }
  cout << ans << endl;
}


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

#define MAX_STACKS 102
#define MAX_DEQUE 100001

struct Data{
  int time;
  char name[16];
};

class Deque{
  Data* addrs[MAX_DEQUE] = { 0 };

  int head = 0;
  int tail = 0;
public:
  void printDeque(){
    int idx = head;
    for( idx; idx >tail; idx-- ){
      std::cout << idx << ": " << addrs[idx]->time << "    " << addrs[idx]->name << std::endl;
    }
  }

  void enque( Data& d ){
    if( head >= MAX_DEQUE-1 ){
      head = 0;
    } else {
      head++;
    }
    addrs[head] = new Data;
    *addrs[head] = d;
    return;
  }

  Data deque(){
    tail++;
    if( tail >= MAX_DEQUE ) tail = 0;
    Data ret = *addrs[tail];
    delete addrs[tail];
    return ret;
  }

  bool isEmpty(){
    return head == tail;
  }

};

class Stack{
  int* addrs[MAX_STACKS];
  unsigned int top = 0;
public:
  int pop(){
    if( top <= 0 ){
      std::cerr << "No stacks" << std::endl;
      exit(0);
    }

    int n = *(addrs[top]);
    delete addrs[top];
    top--;
    return n;
  }
  void push( int num ){
    if( top >= MAX_STACKS - 1 ){
      std::cerr << "Stacks max" << std::endl;
      exit( 0 );
    }
    top++;
    addrs[top] = new int;
    *(addrs[top]) = num;
    return;
  }
};

int main(){
  Deque que;
  int N, Q;
  int time = 0;
  std::cin >> N >> Q;
  for( int i = 0; i < N; i++ ){
    Data d;
    std::cin >> d.name >> d.time;
    que.enque( d );
  }

  while( !que.isEmpty() ){
    Data d = que.deque();
    time += std::min( d.time, Q );
    d.time -= Q;
    if( d.time <= 0 ){
      std::cout << d.name << " " << time << std::endl;
    } else {
      que.enque( d );
    }
  }
}



Measured memory_bytes: 5432
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1000000007;

int main(){
  long long n,ans=1;cin>>n;
  map<int,int> mp;
  
  for(int i=2;i<=n;i++){
    int num=i;
    for(int j=2;j<=i;j++){
      while(!(num%j)){
        mp[j]++;
        num/=j;
      }
    }
  }
  mp[1]=0;
  
  for(auto p:mp){
    ans*=(long long)(p.second+1);
    ans%=MOD;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
using namespace std;
int main(){
	int n,l;
  cin >> n >> l;
  int arr[n];
  // taking into array
  for (int i = 0; i < n; i++)
  {	arr[i] = l;
    arr[i] += i;
  }
  if (l > 0) cout << accumulate(arr+1, arr+n, 0)<< '\n';
  else if (l > -n) cout << accumulate(arr, arr + n , 0) <<'\n';
  else cout << accumulate(arr, arr + n -1, 0) <<'\n';
	    
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import math
import sys


def solve(values, nb, max_jump_size):
    max_jump_size = min(nb, max_jump_size)
    cost_to = [0]
    for i in range(1, nb):
        j = max(0, i - max_jump_size)
        value_i = values[i]
        new_cost = min(
            prev_cost + abs(value_i - prev_value)
            for prev_cost, prev_value in zip(cost_to[j:i], values[j:i])
        )
        cost_to.append(new_cost)
    return new_cost


def do_job():
    "Do the work"
    # first line is number of test cases
    R = int(input().strip())
    result = 2 * math.pi * R
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {:f}".format(testcase + 1, result))


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


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


int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
char arr[n][n];
char arr1[m][m];
    for(int i=0; i<n; i++)
        scanf("%s",arr[i]);

    for(int i=0; i<m; i++)
        scanf("%s",arr1[i]);


    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int cnt=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        cnt++;
                }

            }
            if(cnt==(m*m))
            {
                printf("Yes\n");
                return 0;
            }

        }
    }
    printf("No\n");

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long w[200];
long long v[200];
long long f[100010];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=m;j>=w[i];j--)
		{
			f[j]=max(f[j],f[j-w[i]]+v[i]);
		}
	}
	cout<<f[m];
}

Measured memory_bytes: 1152
a1_1, a1_2, a1_3 = map(int, input().split())
a2_1, a2_2, a2_3 = map(int, input().split())
a3_1, a3_2, a3_3 = map(int, input().split())
a_list=[a1_1, a1_2, a1_3, a2_1, a2_2, a2_3, a3_1, a3_2, a3_3]
n = int(input())
b=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j, a_j in enumerate(a_list):
    if a_j == b_i:
      a_list[j] = -1
    
if ((a_list[0]==-1 and a_list[1] == -1 and a_list[2] == -1) or
    (a_list[3]==-1 and a_list[4] == -1 and a_list[5] == -1) or
    (a_list[6]==-1 and a_list[7] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[3] == -1 and a_list[6] == -1) or
    (a_list[1]==-1 and a_list[4] == -1 and a_list[7] == -1) or
    (a_list[2]==-1 and a_list[5] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[4] == -1 and a_list[8] == -1) or
	(a_list[2]==-1 and a_list[4] == -1 and a_list[6] == -1)):
  print("Yes")
else:
  print("No")

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

int main(){
	string S;
	cin >> S;
	int a1 = 0, a2 = 0;
	for(int i = 0; i < S.size(); i++){
		if(i%2 == 0){
			if(S.at(i) == '1') a1++;
			if(S.at(i) == '0') a2++;
		}
		else{
			if(S.at(i) == '0') a1++;
			if(S.at(i) == '1') a2++;
		}
	}
	cout << min(a1,a2) << endl;
	return 0;
}

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

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

        int ans=0;
        for(int i=0; i<n; i++){
                cin >> a;
                while(a%2==0){
                        a/=2;
                        ans++;
                }
        }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define pf push_front
#define popf pop_front
#define popb pop_back
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)
#define mll map<ll,ll>
#define mint map<int,int>
#define mll_it map<ll,ll>::iterator
#define mint_it map<int,int>::iterator

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"

#define mem(a,n) memset(a, n, sizeof(a)); // n = 0 OR -1 only

#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define MOD 1000000007
#define MOD2 998244353

using namespace std;

int *ans;
vector<char> Sieve(ll n)
{
    vector<char> prime (n+1, true);
    prime[0] = prime[1] = false;
    
  	ll fact = 1;
    for (int i=2; i*i<=n; i++)
    {
      int ct = 0;
      
        if (prime[i])
        {    
            if (i * 1ll * i <= n)               // To avoid Overflow
            {
                for (int j=i*i; j<=n; j+=i)     // We begin to move from i ^ 2, since all smaller                                              
                    prime[j] = false;           // numbers that are multiples of i necessarily have a simple divisor less i,
            }                                   // which means that all of them have already been eliminated earlier
        }
    }
    return prime;
}

void factorise(int n)
{
    vector<char> primes = Sieve(n);
    map<int, int> factors;
    
    for01(0, primes.size())
    {
        if(primes[i])
        {
            int temp = n;
            int ct = 0;
            
            while(temp % i == 0)
            {
                temp = temp/i;
                ct++;
            }
            if(ct > 0)
            {
                factors.insert(mp(i,ct));
                ans[i] += ct;
            }
        }
    }
    
}


int main()
{
    int n;
    cin >> n;
    
    ans = new int[n+1];
    mem(ans, 0);
    
    for(int i = 1; i <= n; i++)
    {
        factorise(i);
    }
   
    ll ct = 1;
    for01(1,n+1)
    {
       ct = (ct * (ans[i]+1)) % MOD;
       //p0(i);
       //p1(ans[i]);
    }
    
   // p1("");   
    p1(ct);
    return 0;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtheleteProgramming3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] lArray = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(lArray);
            Array.Reverse(lArray);
            int lengthSum = 0;
            for(int i = 0; i < nk[1]; i++)
            {
                lengthSum += lArray[i];
            }
            Console.WriteLine(lengthSum);
        }
    }
}


Measured memory_bytes: 13396
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut count = 0;
    for i in 1..n + 1 {
        let p: usize = scan(tokens);
        if p != i {
            count += 1;
        }
    }
    if count <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int year,month,day;
    char c1,c2;
    
    cin >> year >> c1 >> month >> c2 >> day;

    if(month <= 4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}

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

int main() {
    int n,k;  cin>>n>>k;
    int arr[n+1];

    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }

    int dp[n+1];
    dp[1]=0;
    for(int i=2;i<=n;i++){
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++){
            if(i-j>=1){
                dp[i]=min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);
            }
        }
    }

    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long ans,n;
int main(){
	cin>>n;
	for(long long i=1;i<=n;i++)ans+=i*(i+1)/2;
	for(int i=1;i<n;i++){
		long long u,v;scanf("%lld%lld",&u,&v);
		if(u>v)swap(u,v); 
		ans-=1ll*u*(n-v+1); 
	}
	cout<<ans;
}

Measured memory_bytes: 3680
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    let ans = a * b - a - b + 1;
    return ans.to_string();
}


Measured memory_bytes: 2092
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        
        String ans;
        if(str.equals("ABC")){
            ans = "ARC";
        }else{
            ans = "ABC";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35632
#include <stdio.h>

int main(void) {
	int A, B;
	int need, gain;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	need = B - 1;
	gain = A - 1;
	printf("%d\n", (need + gain - 1) / gain);
	return 0;
}


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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n+1){
        if(i % 3 == 0 || i % 5 == 0)continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll t, n, x;
    scl(n);
    scl(x);
    scl(t);
    ll sum = 0;
    ll ans = 0;
    while (sum < n)
    {
        sum += x;
        ans += t;
    }
    pcl(ans);
    return 0;
}

Measured memory_bytes: 3724
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    string n;
    cin >> n;
    if(n[0] == n[1] && n[0] >= n[2]){ cout << n[0]<< n[0]<< n[0]<<endl; return 0;}
    if(n[0] > n[1]){ cout << n[0]<< n[0]<< n[0]<<endl; return 0;}
    n[0]++;
    cout << n[0]<< n[0]<< n[0]<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256