akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXSIZE=10000020;
int bufpos;
char buf[MAXSIZE];
#define NEG 0
void init(){
	#ifdef LOCAL
		freopen("B.txt","r",stdin);
	#endif
	buf[fread(buf,1,MAXSIZE,stdin)]='\0';
	bufpos=0;
}
#if NEG
int readint(){
	bool isneg;
	int val=0;
	for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
	bufpos+=(isneg=buf[bufpos]=='-');
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return isneg?-val:val;
}
#else
int readint(){
	int val=0;
	for(;!isdigit(buf[bufpos]);bufpos++);
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return val;
}
#endif
char readchar(){
	for(;isspace(buf[bufpos]);bufpos++);
	return buf[bufpos++];
}
int readstr(char* s){
	int cur=0;
	for(;isspace(buf[bufpos]);bufpos++);
	for(;!isspace(buf[bufpos]);bufpos++)
		s[cur++]=buf[bufpos];
	s[cur]='\0';
	return cur;
}
bool use[30002];
int main(){
	init();
	int n=readint();
	if (n==3)
		return puts("2 5 63"),0;
	if (n==4)
		return puts("2 5 20 63"),0;
	int sum=0,cnt=0,lst=0;
	for(int i=1;i<=30000;i++){
		if (i%2==0 || i%3==0){
			use[i]=1;
			sum+=i;
			cnt++;
		}
		if (cnt==n){
			lst=i;
			break;
		}
	}
	if (sum%6==2){
		use[2]=0;
		use[lst/6*6+6]=1;
	}
	if (sum%6==3){
		use[3]=0;
		use[lst/6*6+6]=1;
	}
	if (sum%6==5){
		use[2]=0;
		use[(lst+3)/6*6+3]=1;
	}
	for(int i=1;i<=30000;i++)
		if (use[i])
			printf("%d ",i);
}

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

using namespace std;

typedef long long ll;

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

	int x, a, b;
	cin >> x >> a >> b;

	x -= a;
	x %= b;

	cout << x << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>_N;vect.resize(_N);REP(i,_N){cin>>vect[i];}}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}


int main() {
	int N;
	vi vec;
	cin >> N;
	REP(i, N) {
		int ai;
		cin >> ai;
		vec.pb(ai);
	}
	int cnt = 0;
	int next = 1;
	while (true) {
		next--;
		next = vec[next];
		cnt++;
		IfOut(cnt > N, "-1");
		if (next == 2) break;
	}
	out(cnt);
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){

    int m,n;
    cin>>m>>n;
    int a=0;
    for(int i=0;i<m;i++){
        int x=0;
        for(int i=0;i<n;i++){
            int y;
            cin>>y;
            x += y;
        }
        if(a<x)a=x;
    }
    cout<<a<<endl;

    return 0;

}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define f first
#define s second
#define y1 yasfasf
#define kz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILE "substring"
#define fr freopen(FILE".in", "r", stdin); freopen(FILE".out", "w", stdout);
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef struct node* treap;

const int N = 1e5 + 11, inf = 1e9;
const ll linf = 1e18, mod = 1e9 + 7;

ll a, b;


int main(){
	cin >> a >> b;
	cout << max(a - b, 0LL);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i = 0; i <= VMAX; i++) C[i] = 0;

  for(i = 0; i < n; i++){
      scanf("%hu",&A[i+1]);
      C[A[i+1]]++;
  }

  for(i = 1; i <= VMAX; i++) C[i] = C[i] + C[i-1];

  for(j = 1; j <= n; j++){
      B[C[A[j]]] = A[j];
      C[A[j]]--;
  }

  for(i = 1; i <= n; i++){
      if(i > 1) printf(" ");
      printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}


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

unordered_map<long, long> mp;

int main()
{
    int N;
    int D1, D2;
    int count = 0;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> D1;
        cin >> D2;
        if (D1 == D2)
        {
            count++;
        }
        else
        {
            count = 0;
        }
        if (count >= 3)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

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

		int a[] = new int[40];
		int b[] = new int[40];
		
		for (int i = 0; i < S.length(); i++) {
			int cs = S.charAt(i) - 'a' + 1;
			int ct = T.charAt(i) - 'a' + 1;
			
			if (a[cs] == 0) {
				a[cs] = ct;
			} else if (a[cs] != ct){
				System.out.println("No");
				return;
			}
			
			if (b[ct] == 0) {
				b[ct] = cs;
			} else if (b[ct] != cs){
				System.out.println("No");
				return;
			}
			
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 28436
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

n = int(input())
li = [int(input()) for _ in range(n)]


def lcm(a, b):
    return a * b // gcd(a, b)



ret = li[0]
if len(li) != 1:
    for i in range(1, n):
        ret = lcm(ret, li[i])
print(ret)

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std; 
const int MAX = 1000001; 
struct Query 
{ 
	int l, r, idx; 
}; 

bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
	int n,q,x,y;
	cin >> n >> q;
	int a[n];
	for(int i = 0 ; i < n ; i++) cin >> a[i];
	Query queries[q]; 
	for( int i = 0 ; i < q ; i++)
	{
	    cin >> x >> y;
	    --x,--y;
	    queries[i].l = x;
	    queries[i].r = y;
	    queries[i].idx = i;
	}
	int Q = sizeof(queries)/sizeof(queries[0]); 
    sort(queries, queries+Q, cmp); 
    answeringQueries(a, n, queries, Q);
	return 0; 
} 


Measured memory_bytes: 19388
//***Faithless is he that says farewell when the road darkens***

#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[100001],b[100001];
int main()
{
   ll n,s=0;
   cin>>n;
   forn(i,n+1) cin>>a[i];
   forn(i,n) cin>>b[i];

   for(ll i=0;i<n;i++){
      if(a[i]>=b[i]){
         s+=b[i];
         a[i]-=b[i];
         continue;
      }
      s+=a[i];
      b[i]-=a[i];
      if(a[i+1]>=b[i]){
         s+=b[i];
         a[i+1]-=b[i];
      }
      else{
         s+=a[i+1];
         a[i+1]=0;
      }
   }
   cout<<s;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり
 
int main() {
  string S;
  cin >> S;
  if (S.at(0) != 'A') {
    cout << "WA" << endl;
  }
  else {
    int SS = S.size();
    int C = 0;
    int B = 0;
    for (int i = 2; i < SS - 1; i++) {
      if (S.at(i) == 'C') {
        C++;
      }
      for (int j = 0; j < 26; j++) {
        if (S.at(i) == ABC.at(j)) {
          B++;
        }
      }
    }
    for (int j = 0; j < 26; j++) {
      if (S.at(1) == ABC.at(j)) {
        B++;
      }
      if (S.at(SS - 1) == ABC.at(j)) {
        B++;
      }
    }
    if (C != 1) {
      cout << "WA" << endl;
    }
    else if (B != C) {
      cout << "WA" << endl;
    }
    else {
      cout << "AC" << endl;
    }
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define ll unsigned long long
#define mset(s, _) memset(s, _, sizeof s)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main(void) {
  ll n;
  cin >> n;
  if (n < 2) {
    cout << 0 << endl;
    return 0;
  }
  map<ll, ll> M;
  ll tmp = n;
  ll num = 2;
  while (n > 1) {
    if (n % num == 0) {
      n /= num;
      M[num]++;
    } else {
      num++;
    }
    if (num > sqrt(n)) break;
  }
  if (tmp == n)
    M[n]++;
  else if (tmp % n == 0)
    M[n]++;

  int ans = 0;

  for (auto m : M) {
    // cout << m.first << " " << m.second << endl;
    int cnt = m.second;
    rep(i, 1, m.second) {
      cnt -= i;
      if (cnt >= 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

void chmin(int &a,int b){if(a>b)a=b;}
int N,A,B,C;
vector<int>L;
int INF=100000;

int rec(int i,int a,int b,int c){
    if(i==N){
        if(!a || !b || !c)return INF;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }

    int res=rec(i+1,a,b,c);

    chmin(res,rec(i+1,a+L[i],b,c)+(a? 10:0));
    chmin(res,rec(i+1,a,b+L[i],c)+(b? 10:0));
    chmin(res,rec(i+1,a,b,c+L[i])+(c?10:0));
    return res;
}

int main(){
    cin>>N>>A>>B>>C;
    L.resize(N);
    for(int i=0;i<N;i++)cin>>L[i];

    cout<<rec(0,0,0,0)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

int n, d;


int main(){

    cin >> n >> d;

    int jo = d * 2 + 1;

    cout << (n + jo - 1) / jo << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
INF = 500000
mod = 10**9+7

N, A, B = map(int, input().split())
C = A+B
x = N//C
print(x*A+min(N-x*C, A))


Measured memory_bytes: 3316
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#n = ip()                              #入力整数1つ
t,x= (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意


print(t/x)

Measured memory_bytes: 5772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    vint dp(n + 1, INT32_MAX);
    for (int i = n - 1; i >= 0; --i)
    {
        auto in = upper_bound(dp.begin(), dp.end(), a[i]);
        in[0] = a[i];
    }

    int ans = 0;
    while (dp[ans] != INT32_MAX)
    {
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
A, B, K = map(int,input().split())

count = 0
for i in range(K):
    if(count % 2 == 0):
        # Aが奇数個所持
        if(A % 2 == 1):
            # 1個減らす
            A -= 1
        B += int(A/2)
        A /= 2
    else:
        # Bが奇数個所持
        if(B % 2 == 1):
            # 1個減らす
            B -= 1
        A += int(B / 2)
        B /= 2
    count +=1

print("{} {}".format(int(A), int(B)))

Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<bool> res(n, false);
    vector<ll> was(n, 0);
    ll nac = 0;
    ll npen = 0;
    for (ll i = 0; i < m; ++i) {
        ll p;
        string result;
        cin >> p >> result;
        --p;
        //cerr << p << "," << result << endl;
        if (res[p]) {
            // do nothing
        } else {
            if (result == "AC") {
                ++nac;
                npen += was[p];
                res[p] = true;
            } else {
                ++was[p];
            }
        }
    }
    cout << nac << " " << npen << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int n;
    scanf("%d",&n);
    while(n>=0)
    {
        if(n%4==0)
        {
            printf("Yes");
            return 0;
        }
        else
            n-=7;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    map<string,int>mp;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}


Measured memory_bytes: 3660
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize, k: i64,
        a: [usize1; n],
    }
    const B: usize = 60;
    let mut dp = vec![vec![0; n]; B];
    for i in 0..n {
        dp[0][i] = a[i];
    }
    for j in 0..B - 1 {
        for i in 0..n {
            dp[j + 1][i] = dp[j][dp[j][i]];
        }
    }
    let mut x = 0;
    for i in 0..B {
        if (k & 1 << i) != 0 {
            x = dp[i][x];
        }
    }
    puts!("{}\n", x + 1);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 96472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int A,B;
    cin >> A >> B;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9) cout << A * B << endl;
    else cout << "-1" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n;
    cin >> n;
    if( n % 1000 == 0) cout << 0 << endl;
    else cout << 1000 - (n % 1000) << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n, sum = 0;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();

		int[] S = new int[100001];
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}

		int q, key = 0;
//		Scanner sc1 = new Scanner(System.in);
		q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			key = sc.nextInt();
			if (linearSearch(S, n, key))
				sum++;
		}
		System.out.println(sum);
	}

	private static boolean linearSearch(int[] S, int n, int key) {
		int i = 0;
		boolean boo = false;
		S[n] = key;
		while (S[i] != key)
			i++;
		if (i != n)
			boo = true;
		return boo;
	}

}



Measured memory_bytes: 40504
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 1000000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<vector<int>> fvec;
    vector<vector<int>> pvec;
    rep(i,n){
        vector<int> fv;
        rep(j,10){
            int f;
            cin >>f;
            fv.push_back(f);
        }
        fvec.push_back(fv);
    }
    rep(i,n){
        vector<int> pv;
        rep(j,11){
            int p;
            cin >>p;
            pv.push_back(p);
        }
        pvec.push_back(pv);
    }
    int ans = -INF;
    for(int bit=1;bit<(1<<10);bit++){
        int cc = 0;
        rep(i,n){
            int c=0;
            for(int j=0;j<10;j++){
                if (((bit>>j)&1) && (fvec[i][j]==1)){
                    c += 1;
                }
            }
            cc += pvec[i][c];
        }
        ans = max(ans,cc);
    }
    cout << ans << endl;



}

Measured memory_bytes: 256
X = int(input())
if X >= 400 and X<600:
    print(8)
elif X >= 600 and X<800:
    print(7)
elif X >= 800 and X<1000:
    print(6)
elif X >= 1000 and X<1200:
    print(5)
elif X >= 1200 and X<1400:
    print(4)
elif X >= 1400 and X<1600:
    print(3)
elif X >= 1600 and X<1800:
    print(2)
elif X >= 1800 and X<2000:
    print(1)

Measured memory_bytes: 9072
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')
MOD = 10 ** 9 + 7


n, m = LI()
if abs(n - m) > 1:
    print(0)
    sys.exit()

ans = 1
for i in range(1, n + 1):
    ans = ans * i % MOD
for i in range(1, m + 1):
    ans = ans * i % MOD
if n == m:
    ans = ans * 2 % MOD
print(ans % MOD)


Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b - b) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int A, B; cin >> A >> B;
  if (B == 1) {
    cout << 0 << endl;
    return 0;
  }
  int cnt = 1;
  B -= A;

  while (B > 0) {
    B -= A - 1;
    ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3564
#include <stdio.h>

int main(){
    char s1[10], s2[10], s3[10];

    scanf("%s", s1);
    scanf("%s", s2);
    scanf("%s", s3);

    printf("%c%c%c\n", s1[0]-32, s2[0]-32, s3[0]-32);

    return 0;
}

Measured memory_bytes: 128
//WA
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;

int main(){
    LL x,k,d; cin>>x>>k>>d;
    x=abs(x);
    if (k>(x/d)){
        LL z= k-x/d;
        if (z%2) cout << d-x%d;
        else cout << x%d;  
    }
    else cout<< x-(d*k);
}

Measured memory_bytes: 3652
'use strict';
(function(stdin) {
  var inputs  = stdin.toString();
  var fline = inputs.split('\n')[0];
  var flines = inputs.split('\n')[0].split(' ').map(Number);
  var a = flines[0];
  var b = flines[1];
  var area = a*b;
  var periphery = 2*(a+b);


  console.log(area,periphery); 
  
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string n;
  cin>>n;
  if(n.at(0)==n.at(2)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
    int k, s;
    cin >> k >> s;

    int cnt = 0, x;
    REP(i, 0, k + 1) {
        REP(j, 0, k + 1) {
            x = s - i - j;
            if (x >= 0 && x <= k) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}

fn main() {
    let S = get!(String).chars().collect::<Vec<_>>();
    let mut newS = Vec::new();
    let mut prev_c = S[0];
    let mut count = 1;
    for &c in S.iter().skip(1) {
        if c == prev_c {
            count += 1;
        } else {
            newS.push((prev_c, count));
            count = 1;
            prev_c = c;
        }
    }
    newS.push((prev_c, count));
    for (k, &(c, count)) in newS.iter().enumerate() {
        for i in 0..count {
            if i == 0 && c == 'L' {
                let prev_count = newS[k-1].1;
                print!("{} ", count - (count >> 1) + (prev_count >> 1));
            } else if i == count - 1 && c == 'R' {
                let next_count = newS[k+1].1;
                print!("{} ", count - (count >> 1) + (next_count >> 1));
            } else {
                print!("0 ");
            }
        }
    }
}


Measured memory_bytes: 4476
#include <stdio.h>


int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>b)
    printf("a > b\n");
  if(a<b)
    printf("a < b\n");
  if(a==b)
    printf("a == b\n");

  return 0;
}

Measured memory_bytes: 580
#include <cstdio>

int n;

int main() {
	scanf("%d", &n);
	int _xor = 0;
	for (int i = 0, ai; i < n; i++) {
		scanf("%d", &ai);
		_xor ^= ai;
	}

	puts(_xor ? "No" : "Yes");
	return 0;
}


Measured memory_bytes: 128
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

ans = 700
point = 0
for i in range(n):
    tem = t - 0.006 * h[i]
    c = abs(a - tem)
    if c < ans:
        ans = c
        point = i + 1

print(point)




    







        



Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>

using namespace std;

const int CMax = 200002;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int a, b, c, d, e, n;

int gcd(int a, int b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}

string baseConverter(int base, int num) {
    string tNum = "";
    while (num > 0) {
        tNum = (char)('0' + num%base) + tNum;
        num /= base;
    }
}

bool isPalindrom(string tS) {
    int sn = (int)tS.length();
    for (int i = 0; i < sn / 2; i++) {
        if (tS[i] != tS[sn - i - 1]) return false;
    }
    return true;
}

int dist(int i, int j) {
    return  (j < i ? n + j : j) - i;
}

int main()
{
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);

    int sum = 0;
    int minMod = 10;

    sum += a % 10 > 0 ? ((a / 10) + 1) * 10 : (a / 10) * 10;
    if (a % 10 > 0 && a % 10 < minMod) minMod = a % 10;
    sum += b % 10 > 0 ? ((b / 10) + 1) * 10 : (b / 10) * 10;
    if (b % 10 > 0 && b % 10 < minMod) minMod = b % 10;
    sum += c % 10 > 0 ? ((c / 10) + 1) * 10 : (c / 10) * 10;
    if (c % 10 > 0 && c % 10 < minMod) minMod = c % 10;
    sum += d % 10 > 0 ? ((d / 10) + 1) * 10 : (d / 10) * 10;
    if (d % 10 > 0 && d % 10 < minMod) minMod = d % 10;
    sum += e % 10 > 0 ? ((e / 10) + 1) * 10 : (e / 10) * 10;
    if (e % 10 > 0 && e % 10 < minMod) minMod = e % 10;

    if (minMod < 10) {
        sum -= 10;
        sum += minMod;
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

int main(){
	int n;
	cin >> n;
	if (n == 1){
		cout << "Hello World" << endl;
	}else{
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]

AB.sort(key=lambda a: (a[1], a[0]))

mx = 10**18
ans = 0
for a, b in AB:
    if a >= mx:
        ans += 1
        mx = 10**18
    mx = min(mx, b)
print(ans + 1)


Measured memory_bytes: 24600
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Text;

namespace cswork
{
    class Program
    {
        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);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

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

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

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            long A = cin.nextLong();
            long B = cin.nextLong();

            for (int i = 1; i <= 1000; i++)
            {
                Decimal x = i * 8 / 100;
                x = Math.Floor(x);
                Decimal y = i * 10 / 100;
                y = Math.Floor(y);

                if (x > 0 && x == A && y == B)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define int long long
#define all(a) (a).begin(),(a).end()
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0);
    char a;
    cin >> a;
    if(a>='a') cout << 'a' << endl ;
    else cout << 'A' << endl;
    return 0;
}



Measured memory_bytes: 3660
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 998244353;
const long long int INF = 1e18;

long long int N,X,Y,res=INF,A[2005],fin[2005]={};
string t;

bool used[2005]={};
queue<long long int>que;
vector<long long int> Edge[20005];


int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>X>>Y;
    for(long long int i =1; i <= N; i++){
        for(long long int j = i+1; j <= N; j++){
            fin[min(j-i,abs(i-X)+abs(j-Y)+1)]++;
        }
    }
    
    for(long long int i = 1; i < N; i++){
        cout<<fin[i]<<endl;
    }
}


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

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

    int N;
    cin >> N;

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

    ll d = *max_element(a.begin(), a.end());
    ll s = *min_element(a.begin(), a.end());

    int count = 0;
    vector<pair<int, int> > ans;

    if(abs(d) >= abs(s)) {
        for(int i = 1; i < N; i++) {
            while(a[i] < a[i - 1]) {
                int p = max_element(a.begin(), a.end()) - a.begin();
                ll x = a[p];
                for(int j = 0; j < N; j++) {
                    if(a[j] >= a[i - 1] - a[i]) {
                        if(a[j] < x) {
                            p = j;
                            x = a[j];
                        }
                    }
                }
                count++;
                ans.push_back(make_pair(p + 1, i + 1));
                a[i] += x;
            }
        }
    } else {
        for(int i = N - 2; i >= 0; i--) {
            while(a[i] > a[i + 1]) {
                int p = min_element(a.begin(), a.end()) - a.begin();
                ll x = a[p];
                for(int j = 0; j < N; j++) {
                    if(a[j] <= a[i + 1] - a[i]) {
                        if(a[j] > x) {
                            p = j;
                            x = a[j];
                        }
                    }
                }
                count++;
                ans.push_back(make_pair(p + 1, i + 1));
                a[i] += x;
            }
        }
    }

    cout << count << endl;

    for(int i = 0; i < count; i++) cout << ans[i].first << " " << ans[i].second << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;

int n;
string ans;
signed main(){
  cin >> n;
  if(n==0){
    cout << n <<endl;
    return 0;
  }
  int now = 1;
  while(n!=0){
    now *= -2;
    if(n%now == 0){
      ans = '0' + ans;
    }
    else{
      ans = '1' + ans;
      n -= now/-2;
    }
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

    a *= n;
    if(a>b){
        printf("%d\n",b);
    }else
    {
        printf("%d\n",a);
    }
    

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stack>
#include <queue>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    
    int tmp;
    stack<int> s;
    queue<int> q;
    
    while(cin >> tmp) {
        if(tmp == 0) {
            q.push(s.top());
            s.pop();
        } else {
            s.push(tmp);
        }
    }
    
    while(!q.empty()) {
        cout << q.front() << endl;
        q.pop();
    }
    
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+10;
const int mod=1e9+7;
map<ll,ll> mp,flag;
ll a[N],cnt[N],b[N];
int k;
string s;
int main() {;
   //freopen("../in.in", "r", stdin);
//    freopen("../out.out","w",stdout);
    ios::sync_with_stdio(false);
    int t,i,j=0;
    int m,x,n,y;
    cin>>s;
    ll ans=0;
    for(i=0;i<s.length();i++) ans+=(s[i]-'0');
    if(ans%9) cout<<"No";
    else cout<<"Yes";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3764
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) { //WOOOOOOO AtCoder is HELPING!!!!!!!!!!
		//Arraylist cheese for the win
		Scanner input = new Scanner(System.in);
		PriorityQueue<Long> subs = new PriorityQueue<Long>(Collections.reverseOrder());
		int N = input.nextInt();
		int M = input.nextInt();
		long ans = 0;
		for (int i = 0; i < N; i++) {
			long x = input.nextLong();
			ans+=x;
			while (x>0) {
				long sub = x-x/2;
				subs.add(sub);
				x/=2;
			}
		}
		int cnt = 0;
		while (cnt < M) {
			ans-=subs.poll();
			cnt++;
			if (subs.isEmpty()) break;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 147700
#include <iostream>
#include <string>
int main(){
    int a,b;
    std::cin >> a >> b;

    std::string s;
    if (a > b){
        for (int i = 0;i < a;i++){
            s += std::to_string(b);
        }
    }else{
        for (int i = 0;i < b;i++){
            s += std::to_string(a);
        }
    }
    std::cout << s << "\n";
}


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

void Main()
{
  int n,x; cin >> n >> x;
  while (n != 0 or x != 0) {
    //cout << n << "," << x << endl;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i+1; j <= n; j++) {
        if (x-i-j > 0 and x-i-j <= n 
            and x-i-j > j) {
          cnt++;
        }
      }
    }
    cout << cnt << endl;
    cin >> n >> x;
  }
}

int main()
{
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}



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

int main()
{
  int N; cin >> N;
  string s[N]; rep(i,N) cin >> s[i];
  int M; cin >> M;
  string t[M]; rep(i,M) cin >> t[i];
  
  int ans = 0;
  rep(i, N)
  {
    int count = 0;
    rep(j, N){
      if(s[i] == s[j]) count++;  
    }
    rep(j, M){
      if(s[i] == t[j]) count--;  
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
}

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

#define MOD 1000000007
#define lli long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define endl "\n"

using namespace std;

void solve(){
    ///start solving
	double a,b,c,d;
	cin >> a >> b >> c >> d;
	lli time1 = ceil(a / d);
	lli time2 = ceil(c / b);
	//cout << time1 << " " << time2 << endl;
	if(time1 >= time2){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
}

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    
solve();//In case of problems without test case

	return 0;
}




Measured memory_bytes: 3868
/*
Submitted With (^^) by -> Hossam ^_^
 _____________________
|     ___     ___     |
|    (^_^)   (^_^)    |
|   /( | )\_/( | )\   |
|_____|_|_____|_|_____|
*/

#include <bits/stdc++.h>

using namespace std;

inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define X first
#define Y second
#define ll long long
#define inf (0x7fffffffffffffff)
#define all(x) x.begin(), x.end()
#define ZXC cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl;

const int mod = (int)1e9 + 7;
const int MX = (int)2e5 + 5;

vector<int> g[MX];
vector<bool> vis(MX);
vector<int> stk;
set<int> st;
int at[MX];

void dfs(int x){

    stk.push_back(x);
    st.insert(at[x]);   
    vis[x] = true; 

    for (auto y : g[x])
    {
        if(vis[y]) continue;
        dfs(y);
    }
}

int main()
{
    prep();

    int n, m;
    cin >> n >> m;

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

    while(m--){
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int res = 0;
    for(int i = 0; i < n; ++i){
        if(!vis[i]){
            dfs(i);
            for(auto x : stk){
                res += st.find(x) != st.end();
            }
            stk.clear();
            st.clear();
        }
    }

    cout << res << endl;

    // ZXC
    return 0;
}

Measured memory_bytes: 16632