akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const int MAX = 100010;
vll g[MAX];
bool used[MAX];
vll ans1;
vll ans2;
bool F;

template<class T>
void PrintVector(vector<T>& vec){
    int n = vec.size();
    cout << n << endl;
    for(int i = 0; i < n; i++){
        cout << vec[i]+1 << (i == n-1 ? "\n" : " ");
    }
}

void dfs(ll s){
    used[s] = true;
    if(F){
        ans1.emplace_back(s);
    }else{
        ans2.emplace_back(s);
    }
    for(auto&& e: g[s]){
        if(!used[e]){
            dfs(e);
            break;
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll a(m), b(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        g[a[i]].emplace_back(b[i]);
        g[b[i]].emplace_back(a[i]);
    }
    rep(i, n){
        if(SZ(g[i]) == 1){
            F = true;
            dfs(i);
            PrintVector(ans1);
            return 0;
        }
    }
    F = true;
    dfs(0);
    F = false;
    dfs(0);
    reverse(ALL(ans1));
    ans1.pop_back();
    for(auto&& e: ans2){
        ans1.emplace_back(e);
    }
    PrintVector(ans1);
    return 0;
}

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

int calcDigit(ll N){
  int digit = 0;
  while(N>0){
    N/= 10;
    digit++;
  }
  return digit;
}

int main(){
  ll N;
  cin >> N;
  int ans = calcDigit(N);
  for(ll A=1;A*A<=N;A++){
    if(N%A!=0){
      continue;
    }
    ll B = N /A;
    int tmp = max(calcDigit(A),calcDigit(B));
    if(ans > tmp){
      ans = tmp;
    }
  }
  printl(ans);
}


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

const int MAX = 25;
int A[MAX],B[MAX];

int main()
{
	int N,M,C;
	cin >> N >> M >> C;
	for (int i = 0; i < M; ++i)
	{
		cin >> B[i];
	}

	int temp = 0;
	int ans = 0;

	for (int i = 0; i < N; ++i)
	{
		temp = 0;
		for (int j = 0; j < M; ++j)
		{
			cin >> A[j];
			temp += B[j] * A[j];
		}
		temp += C;

		if (temp > 0) ans++;
	}

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

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int W, H;
char B[30][30];

int dfs(int y, int x) {
   int ret = 1;
   B[y][x] = '#';
   rep (i, 4) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H || B[ny][nx] == '#') continue;
      ret += dfs(ny, nx);
   }
   return ret;
}

void solve() {
   rep (i, H) {
      cin >> B[i];
   }
   rep (i, H) {
      rep (j, W) {
         if (B[i][j] == '@') {
            cout << dfs(i, j) << endl;
            return;
         }
      }
   }
}

int main() {
   while (1) {
      cin >> W >> H;
      if (H*W == 0) break;
      solve();
   }

   return 0;
}


Measured memory_bytes: 3000
#include <iostream>

int main()
{
        int N = 0;
        double ans = 0;
        double sum = 0;
        int res = 0;
        std::cin>>N;
        for (int i=0;i<N;i++)
        {
                std::cin>>res;
                sum+=(1/(double)res);
        }
        ans = 1/sum;
        std::cout<<ans;
        return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n;
    cin >> n;
    vi a(26, inf);
    rep(i, n) {
        string s;
        cin >> s;
        vi b(26);
        for (auto c : s) b[c - 'a']++;
        rep(j, 26) {
            chmin(a[j], b[j]);
        }
    }

    rep(j, 26) {
        while (a[j]--) cout << (char)('a' + j);
    }
    cout << endl;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "before", long, "after");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto a = aryread();
    auto cnt = new Pair[](n);
    foreach (i; iota(n))
    {
        foreach (j; iota(n))
        {
            if (a[i] > a[j])
            {
                if (i > j)
                    cnt[i].before++;
                else
                    cnt[i].after++;
            }
        }
    }
    long init, addition;
    foreach (e; cnt)
    {
        init += e.after;
        addition += e.before + e.after;
    }
    auto ans = k * init % MOD;
    ans += ((k * (k - 1)) / 2) % MOD * addition;
    writeln(ans % MOD);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2800
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int n;
void dfs(string s, char mx) {
  if (s.size() == n) {
    print(s);
    return;
  }
  for (char c = 'a'; c <= mx + 1; c++) {
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}

int main() {
  cin >> n;
  dfs("", 'a' - 1);
  return 0;
}

Measured memory_bytes: 1536
n = int(input())
ss = list(map(int,input().split()))
ss.sort()

if n == 2:
    print((ss[0] + ss[1]) / 2)
elif ss[0] == sum(ss) / n:
    print(ss[0])
else:
    for i in range(n - 1):
        if i == 0:
            tmp = (ss[i] + ss[i + 1]) / 2
        else:
            tmp = (tmp + ss[i + 1]) / 2
    print(tmp)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int x, t;

int main() {
	cin >> x >> t;
	cout << max(0, x - t) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 

void solve()
{
   string s,t;
   cin>>s>>t;
   ll ns = s.length();
   ll nt = t.length();
   pair<int,int> dp[ns+1][nt+1];
   f(i,0,ns+1)
   {
      dp[i][0].first = 0;
   }
   f(i,0,nt+1)
   {
      dp[0][i].first = 0;
   }
   f(i,1,ns+1)
   {
      f(j,1,nt+1)
      {
         if(s[i-1]==t[j-1])
         {
            dp[i][j].first = dp[i-1][j-1].first + 1;
            dp[i][j].second = 0;
         }
         else
         {
            dp[i][j].first = dp[i][j-1].first;
            dp[i][j].second = 3;
            if(dp[i-1][j].first>dp[i][j].first)
            dp[i][j].first = dp[i-1][j].first, dp[i][j].second = 1;
            if(dp[i-1][j-1].first>dp[i][j].first)
            dp[i][j].first = dp[i-1][j-1].first,dp[i][j].second = 2;
         }
         // cout<<dp[i][j]<<" ";
      }
      // cout<<"\n";      
   }
   string ans = "";
   ll l=ns,r=nt;
   while (l!=0&&r!=0)
   {
      if(dp[l][r].second==0)
      {
         string add(1,s[l-1]);
         ans+=add;
         l--,r--;
      }
      else if(dp[l][r].second==1)
      {
         l--;
      }
      else if(dp[l][r].second == 2)
      {
         l--,r--;
      }
      else
      r--;
   }
   reverse(ans.begin(),ans.end());
   cout<<ans;
}

int main()
{
   ll t;
   t=1;
//    cin>>t;
   while (t--)
   {
       solve();
   }  
}

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



ll N, K;
int H[305];



/*
  DP
    先頭からx列の間にk列操作すると、右端をy行塗った後にz行を塗る必要がある
    z(x,k,y) = ?
    
    列xを操作する場合 
      z(x,k,y) = z(x-1,k-1,y)
    列xを操作しない場合
      z(x,k,Hx) =
        if ( Hx >= y )
          z(x-1,k,y)
        else
          z(x-1,k,y) + (y-Hx)
    
    z(0,0,0) = 0
    
    
*/

struct yz {
	ll y;
	ll z;
};

vector<yz> dp[305][305];

// x : 列(1-300) 
void calc( int x ){
	for ( int k = 0; k <= K; k++ ){
		vector<yz> &d = dp[x][k];
		if ( k ){
			for ( auto it : dp[x-1][k-1] ){  // 列xを操作する場合
				d.push_back(it);
			}
		}
		
		ll min_z = LLONG_MAX;
		for ( auto it : dp[x-1][k] ){ // 列xを操作しない場合
			if ( H[x] >= it.y )
				min_z = min( min_z, it.z );
			else
				min_z = min( min_z, it.z+(it.y-H[x]) );
		}
		if ( min_z != LLONG_MAX ){
			yz c = {H[x],min_z};
			auto it = lower_bound( d.begin(), d.end(), c, [](const yz &l, const yz &r){return l.y<r.y;} );
			if ( it != d.end() && it->y == c.y )
				*it = c;
			else
				d.insert(it,c);
		}
		
		// zが、他のy+z よりも大きい場合は削除
		ll min_yz = LLONG_MAX;
		for ( auto it : d )
			min_yz = min( min_yz, it.y+it.z );
		
		int j = 0;
		for ( auto it : d ){
			if ( it.z > min_yz )
				;
			else
				d[j++] = it;
		}
		d.resize(j);
		
		
		//cout << endl;
		//cout << "calc x=" << x << " k=" << k << endl;
		//for ( auto it : dp[x][k] )
		//	cout << "paint right =" << it.y << " paint add =" << it.z << endl;
	}
}



int main(){
	cin >> N >> K;
	
	for ( int i = 0; i < N; i++ ){
		cin >> H[i+1];
	}
	
	dp[0][0].push_back({0,0});
	
	for ( int x = 1; x <= N; x++ ){
		calc( x );
	}
	
	ll result = LLONG_MAX;
	for ( auto it : dp[N][K] )
		result = min( result, it.y+it.z );
	
	cout << result << endl;
	
	return 0;
}



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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
using namespace std;
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    rrep(i, K) {
        if ((i + i) % K)continue;
        ll a = 0;
        for (int j = i; j <= N; j += K) {
            a++;
        }
        ans += a;
        ans += (a * (a - 1)) * 3;
        ans += a * (a - 1) * (a - 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int H = sc.nextInt(), N = sc.nextInt();
        while (N-->0)
            H-= sc.nextInt();
        out.println(H<=0?"Yes":"No");
        out.flush();
        out.close();
    }


    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        boolean ready() throws IOException {
            return br.ready();
        }


        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }

}

Measured memory_bytes: 33256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	var a []int
	for i := 0; i < n; i++ {
		var b int
		fmt.Scanf("%d", &b)
		a = append(a, b)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	var ans int

	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			ans += a[i]
		} else {
			ans -= a[i]
		}
	}

	fmt.Println(ans)
}


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

int main(){
  ll x;
  cin >> x;

  ll i = 100;
  int y=0;
  while(1){
    y++;
    i = i + i/100;
    if(i>=x) break;
  }
  cout << y << endl; 
}


Measured memory_bytes: 3596
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long n = sc.nextLong();

        System.out.println(floor(a, b, Math.min(b-1, n)));
    }

    public static long floor(long a, long b, long x) {
        return (a * x / b) - a * (x / b);
    }
}


Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
const int DP_SIZE = 10001;
const int MOD = 1000000007;

int dp[DP_SIZE][DP_SIZE];

int main(){
	string t, b;
	cin >> t >> b;
	
	dp[0][0] = 1;
	
	for(int i=0; i<=(int)b.size(); i++){
		for(int j=0; j<(int)t.size(); j++){
			dp[i][j+1] += dp[i][j];
			if(b[i] == t[j]) dp[i+1][j+1] = dp[i][j];
			dp[i][j+1] %= MOD;
		}
	}
	cout << dp[b.size()][t.size()] % MOD << endl;
	
	return 0;
}


Measured memory_bytes: 11084
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back

const ll mod = 1000000007;

int main(){
	int N, X;
	int L;

	cin >> N >> X;

	int s = 0;
	int count = 1;

	for (int i = 0; i < N; i++) {
		cin >> L;
		s += L;
		if (s <= X) {
			count++;
		}
		else {
			break;
		}
	}

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807

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

  int amari = 0;
  int ans = 0;

  amari = N % 1000;

  if (amari != 0) {
    ans = 1000 - (N % 1000);
  }

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

  return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
	int n;
	cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    string ans = "second";
    rep(i,n) if(a[i]%2) ans = "first";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){

int n,count=0;

cin >> n;

std::vector<int> a(n);

for(int i=1;i<=n;i++){
  cin >> a.at(i-1);
  if(a.at(i-1)%2==1 && i%2==1){
    count++;
  }
}



cout << count << endl;

}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Vector;
 
public class Main {

    public static void main(String[] args) throws Exception{
        // 入力
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // カウント
        int count = Integer.parseInt(br.readLine());
        // 
        ArrayList<String> list = new ArrayList<String>();
        for(int i = 0; i < count; i++){
            String[] inputs = br.readLine().split(" ");
            
            if(inputs[0].equals("0")){
                // pushBack
                list.add(list.size(), inputs[1]);
            }
            else if(inputs[0].equals("1")){
                // randomAccess
                System.out.println(list.get(Integer.parseInt(inputs[1])));
            }
            else {
                // popBack
                list.remove(list.size() - 1);
            }
        }
    }
}


Measured memory_bytes: 84768
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

vector<string> ans;
int N;

void dfs(string s){
    if(s.size() == N){
        ans.push_back(s);
        return;
    }
    char mx = *max_element(s.begin(), s.end());
    for(int i=0; i<=(mx-'a')+1; i++){
        string t = s + string(1, 'a'+i);
        dfs(t);
    }
}

int main(){
    cin >> N;
    dfs("a");
    sort(ans.begin(), ans.end());
    for(auto x : ans)
        cout << x << endl;
    return 0;
}


Measured memory_bytes: 7796
#include <stdio.h>

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = (n) - 1; i >= 0; i--)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define STRS(i,str) for(int i = 0; (str)[i]; i++)
#define CHINO(a,n) int n, *a; scanf("%d", &n); a = (int *)malloc(sizeof(int) * n); for(int i = 0; i < n; i++) scanf("%d", a + i)

int put(int *a, int n){
	REP(i, n - 1) printf("%d ", a[i]);
	printf("%d\n", a[n - 1]);
}

int main(){
	int a[120];
	int n;
	scanf("%d", &n);
	REP(i, n) scanf("%d", a + i);
	REP(i, n){
		int tmp = a[i];
		RREP(j, i){
			if(a[j] > tmp){
				a[j+1] = a[j];
				a[j] = tmp;
			}else break;
		}
		put(a, n);
	}
}

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

int main()
{
    int a, b;
    
    cin >> a >> b;
    
    if((a % 3 == 0) || (b % 3 == 0) || ((a+b) % 3 == 0)) {
        cout << "Possible\n";
    } else {
        cout << "Impossible\n";
    }
    
    return 0;
}

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

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

bool judge(const std::string &S) {
  return S == std::string(S.rbegin(), S.rend());
}

int main() { 
  std::string S;
  std::cin >> S;
  std::cout << (judge(S) && judge(S.substr(0, (S.size() - 1) / 2)) ? "Yes" : "No") << '\n'; 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>
 
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;
 


int main(){
  char c;
  cin >> c;
  cout << (isupper(c) ? 'A' : 'a') << endl;
}
 

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

#define SENTINEL 1000000001

int *array;
int cnt = 0;

void mergeSort(int begin, int end);

int main(void)
{
    int i;

    int n;
    scanf("%d", &n);
    array = malloc(sizeof(int) * n);
    if (array == NULL) {
        printf("ERROR! Cannot allocate memory in main().\n");
        return 1;
    }

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

    mergeSort(0, n);

    for (i = 0; i < n; i++) {
        if (i != 0) {
            printf(" ");
        }
        printf("%d", array[i]);
    }
    printf("\n");
    printf("%d\n", cnt);

    free(array);

    return 0;
}

void merge(int begin, int mid, int end);

void mergeSort(int begin, int end)
{
    if (begin + 1 < end) {
        int mid = (begin + end) / 2;
        mergeSort(begin, mid);
        mergeSort(mid, end);
        merge(begin, mid, end);
    }
}

void merge(int begin, int mid, int end)
{
    int i, j, k;

    int n_left = mid - begin;
    int n_right = end - mid;
    int *left, *right;
    left = malloc(sizeof(int) * (n_left + 1));
    right = malloc(sizeof(int) * (n_right + 1));
    if (left == NULL || right == NULL) {
        printf("ERROR! Cannot allocate memory in merge().\n");
        exit(1);
    }

    for (i = 0; i < n_left; i++) {
        left[i] = array[begin + i];
    }
    left[n_left] = SENTINEL;

    for (i = 0; i < n_right; i++) {
        right[i] = array[mid + i];
    }
    right[n_right] = SENTINEL;

    i = j = 0;
    for (k = begin; k < end; k++) {
        if (left[i] <= right[j]) {
            array[k] = left[i++];
        } else {
            array[k] = right[j++];
        }
        cnt++;
    }

    free(left);
    free(right);
}

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

using namespace std;

int main(){
  int r, g, b;
  scanf("%d%d%d", &r, &g, &b);
  int tempAns = r * 100 + g * 10 + b;
  puts(tempAns % 4 ? "NO" : "YES");
  return 0;
}


Measured memory_bytes: 256
import re
[print(re.sub(r'0.','',''.join([str(10000+sum([eval(i[0]+'0'*'ixcm'.find(i[1]))for i in['1'+i for i in''.join(re.split(r'\d\w',s))]+re.findall(r'\d\w',s)]))[i]+'1mcxi'[i]for i in range(5)]).replace('1','')))for s in[input().replace(" ","")for i in range(int(input()))]]

Measured memory_bytes: 6876
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(long long i=0;i<n;i++)
using namespace std;

#define rep(i,n) for(long long i=0;i<n;i++)
using namespace std;

int main() {
 int N;
 cin >> N;
 vector<int> x(N), y(N);
 
 if(N==1) { // Nが1のときは，コスト1で確定．
   cout << 1 << endl;
   return 0;
 }
 
 rep(i, N) {
   cin >> x[i] >> y[i];
 }
 
 // ベクトルの集合を得る．
 int tmpx = 0;
 int tmpy = 0;
 priority_queue<pair<int, int>> vec;

 for(int i=0; i<N; i++) {
   for(int j=i+1; j<N; j++) {
     tmpx = x[i] - x[j];
     if(tmpx>0) { // xが正
       vec.push(make_pair(tmpx, y[i]-y[j]));
     } else if(tmpx==0){ // tmpx がゼロ なら y が正になるようにする．
       tmpy = y[i]-y[j];
       if(tmpy>0) vec.push(make_pair(tmpx, tmpy));
       else vec.push(make_pair(-tmpx, -tmpy));
     } else { // tmpx が負: xが正になるようにする．
       vec.push(make_pair(-tmpx, -y[i]+y[j]));
     }
   }
 }
 
 // 出現したベクトルから最頻数を求める
 int cnt = 0;
 int maxcnt = 0;
 pair<int, int> tmp_p = make_pair(0, 0);
 int vecsize = N*(N-1)/2;
 rep(i, vecsize) {
   pair<int, int> p = vec.top();
   vec.pop();
   if(tmp_p.first==p.first && tmp_p.second==p.second){
     cnt++; // 同じものが連続で現れたらカウントプラス
   } 
   else { //違うものが現れたら，maxか判定し，tmp_pを更新, cntをリセット
     if(cnt>maxcnt) maxcnt = cnt;
     tmp_p.first = p.first;
     tmp_p.second = p.second;
     cnt = 0;
   }
 }
 if(cnt>maxcnt) maxcnt = cnt; // 最後のベクトルがmaxか確認．
 cout << N-maxcnt-1 << endl;
 
 return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n - 1));
  rep(i, n) rep(j, n - 1) cin >> a[i][j];
  rep(i, n) rep(j, n - 1)-- a[i][j];

  vector<int> opponent_idx(n, 0);
  vector<bool> chkbox(n);
  int minidx = 0;
  int day = 0;

  vector<int> target_players;
  vector<int> matched_players;
  while(minidx < n - 1) {
    chkbox.assign(n, false);
    ++day;

    if(day == 1) {
      rep(i, n) target_players.push_back(i);
    } else {
      target_players = matched_players;
      matched_players.clear();
    }

    rep(k, target_players.size()) {
      int i = target_players[k];
      if(chkbox[i]) continue;
      if(opponent_idx[i] == n - 1) continue;
      int j = a[i][opponent_idx[i]];
      if(chkbox[j]) continue;
      if(a[j][opponent_idx[j]] != i) continue;
      matched_players.push_back(i);
      matched_players.push_back(j);
      ++opponent_idx[i];
      chkbox[i] = true;
      ++opponent_idx[j];
      chkbox[j] = true;
    }

    bool ok = false;
    rep(i, n) ok = ok || chkbox[i];
    if(!ok) {
      cout << -1 << endl;
      return 0;
    }

    minidx = opponent_idx[0];
    rep(i, n) minidx = min(minidx, opponent_idx[i]);
  }
  cout << day << endl;
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = int64_t;

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

void solve(){
    int a[3], cost = 0;
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    cost += abs(a[1] - a[2]) + abs(a[0] - a[1]);
    cout << cost << endl;
}

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

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

using namespace std;
typedef long long ll;
int main(int argc, char const *argv[]){
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   printf(a+b==c+d?"Balanced\n":(a+b)>(c+d)?"Left\n":"Right\n");
}

Measured memory_bytes: 256
import std.stdio,std.regex;

void main(){
	auto next = readln().chomp().to!size_t;

	auto list = [111,222,333,444,555,666,777,888,999];
	foreach( val; list ){
		if( next <= val ){
			writeln(val);
			break;
		}
		continue;
	}

	return;
}

import std.string,std.conv;

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

#define ll long long

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll n, k;
    cin >> n >> k;

    ll cur=n;

    if(n>k) cur %=k;

	cout << min(cur, abs(cur-k)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
 
 
 
 
 
 
 







int last[200005];
int main(){
    int n;
    cin>>n;
   vector<pair<int,int>> adj;
    int d=n/2*2;
    int ct=0;
    for(int i=1;i<=n;i++){
         for(int j=i+1;j<=n;j++){
              if(i+j==d+1)continue;
              adj.push_back({i,j});
         }
    }
    cout<<adj.size()<<"\n";
    for(auto it:adj){
         cout<<it.fi<<" "<<it.se<<"\n";
    }
}






































Measured memory_bytes: 3644
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const ll M = 1000000007;

int N;
int A[100010];
int X[100010];
int Y[3];

int main () {
  cin >> N;
  for (auto i = 0; i < N; i++) {
    cin >> A[i];
  }
  fill(X, X+100010, 0);
  for (auto i = 0; i < N; i++) {
    X[A[i]]++;
  }
  for (auto i = 0; i < 100010; i++) {
    if (X[i] >= 3) {
      if (X[i]%2 == 0) {
        X[i] = 2;
      } else {
        X[i] = 1;
      }
    }
  }
  fill(Y, Y+3, 0);
  for (auto i = 0; i < 100010; i++) {
    Y[X[i]]++;
  }
  int ans = 0;
  if (Y[2]%2 == 0) {
    ans = Y[1] + Y[2];
  } else {
    ans = Y[1] + Y[2] - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<int,ll> mp;
  rep(i,n){
    mp[a[i]]++;
  }
  ll ans=0;
  for(auto c:mp){
    ans+=c.second*(c.second-1)/2;
  }
  rep(i,n){
    cout << ans-(mp[a[i]])*(mp[a[i]]-1)/2+(mp[a[i]]-1)*(mp[a[i]]-2)/2 <<endl;
  }
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
int main()
{
  int n, y;
  cin >> n >> y;

  int a = -1, b = -1, c = -1;
  re(i, n+1) {
    re(j, n+1) {
      if (10000 * i + 5000 * j + 1000 * (n - (i + j)) == y && n >= i + j) {
        a = i; b = j; c = n - (i + j);
        break;
      }
    }
  }

  cout << a << ' ' << b << ' ' << c << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq; 

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
string str=Console.ReadLine();
      int N=str.Length;
      if(str.Substring(N-1,1)=="s"){
        Console.WriteLine(str+"es");
      }else{
        Console.WriteLine(str+"s");
      }
    }
    
  }

}

Measured memory_bytes: 25868
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Base2Number | diff Base2Number.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Base2Number.cpp && ./a.out

/*
 
 4/14/2020
 
 8:49-9:35 give up
 10:05 read editorial
 
 https://img.atcoder.jp/abc105/editorial.pdf
 https://youtu.be/7bbIZTIeDZM?t=1553
 
 */

int N;

void solve() {
  string res;
  int i=0;
  while(N!=0) {
//    dump(N,res);
    res.push_back('0'+abs(N%2));
    N-=abs(N%2);
    N/=-2;
    ++i;
  }
  reverse(ALL(res));
  if(res.empty()) res="0";
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm> 
#include<queue>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
cout<<(a-b)%c;
system("pause"); 
return 0;
}


Measured memory_bytes: 504
// in the name of Allah
// and begin ... 

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, cnt = 0;
	cin >> n;
	int a[n+1];
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=1; i<=n; i++) {
		if(a[i] == i) {
			if(i < n) swap(a[i], a[i+1]);
			else swap(a[i], a[i-1]);
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main()
{
    int N;
    std::vector<int> v;

    // input
    std::cin >> N;
    for (int i = 0; i < N; i++)
    {
        int tmp_in;
        std::cin >> tmp_in;
        v.push_back(tmp_in);
    }

    // find answer
    int v_diff[N - 1];
    for (int i = 0; i < N - 1; i++)
    {
        v_diff[i] = v[i] - v[i + 1];
    }

    int cnt = 0;
    int cnt_max = 0;
    for (int i = 0; i < N - 1; i++)
    {
        if (v_diff[i] >= 0)
        {
            cnt++;
            if (cnt_max < cnt)
            {
                cnt_max = cnt;
            }
        }
        else
        {
            cnt = 0;
        }
    }

    // 10 4 8 7 5 3 10 9 8
    std::cout << cnt_max << std::endl;
}


Measured memory_bytes: 1144
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <utility>
#define MAXN 100005
using namespace std;
typedef long long ll;
typedef pair<ll,int> pi;
ll read()
{
	ll ans=0;
	char c=getchar();
	while (!isdigit(c)) c=getchar();
	while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
	return ans;
}
pi p[MAXN];
int siz[MAXN],fa[MAXN];
ll d[MAXN];
int main()
{
	int n=read();
	for (int i=1;i<=n;i++) p[i]=make_pair(read(),i),siz[i]=1;
	sort(p+1,p+n+1);
	ll sum=0;
	for (int i=n;i>1;i--)
	{
		ll t=p[i].first-n+2*siz[p[i].second];
		int k=lower_bound(p+1,p+n+1,make_pair(t,0))-p;
		if (p[k].first!=t) return puts("-1"),0;
		fa[p[i].second]=p[k].second,siz[p[k].second]+=siz[p[i].second];
		sum+=siz[p[i].second];
	}
	if (sum!=p[1].first) return puts("-1"),0;
	for (int i=1;i<=n;i++) if (fa[i]) printf("%d %d\n",fa[i],i);
	return 0;
}

Measured memory_bytes: 3712
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	_, A, B, C, D := ReadInt(), ReadInt()-1, ReadInt()-1, ReadInt()-1, ReadInt()-1
	S := ReadString()

	// A -> C
	preBlock := false
	for i := A; i <= C; i++ {
		if S[i] == '#' {
			if preBlock {
				fmt.Println("No")
				return
			}
		}
		preBlock = S[i] == '#'
	}

	// B -> D
	preBlock = false
	for i := B; i <= D; i++ {
		if S[i] == '#' {
			if preBlock {
				fmt.Println("No")
				return
			}
		}
		preBlock = S[i] == '#'
	}

	if C < D {
		fmt.Println("Yes")
		return
	}

	// B -> D
	seq := 0
	for i := B - 1; i <= D+1; i++ {
		if S[i] == '.' {
			seq++
			if seq >= 3 {
				fmt.Println("Yes")
				return
			}
		} else {
			seq = 0
		}
	}
	fmt.Println("No")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 2952
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int[] a= new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		int m=scan.nextInt();
		while(m-->0) {
			int p=scan.nextInt();
			int x=scan.nextInt();
			int sum=0;
			for(int i=0;i<n;i++) {
				if(a[i]==a[p-1]) {
					continue;
				}
				sum+=a[i];
			}
			System.out.println(sum+x);
		}

	}

}


Measured memory_bytes: 27512
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
-- import Control.Lens

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)

readTuple4 :: IO (Int, Int, Int, Int)
readTuple4 = do
    [a, b, c, d] <- readInts
    return (a, b, c, d)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las



main :: IO ()
main = do
  (a, b, h, m) <- readTuple4
  let toRad  = (*pi) . (/180)
  let hourRad = toRad $ 30 * fromIntegral h + 30 * (fromIntegral m / 60)
  let minRad = toRad $  fromIntegral m * 6
  let hourX = fromIntegral a * sin hourRad
  let hourY = fromIntegral a * cos hourRad
  let minX = fromIntegral b * sin minRad
  let minY = fromIntegral b * cos minRad
  let ans = sqrt $ (hourX - minX) ^ 2 + (hourY - minY) ^ 2 :: Double
  print $ ans


Measured memory_bytes: 4356
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

class TaskB {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int N;
    in >> N;
    vector<pair<int, int>> A;

    int mx_rank = 0;
    for (int i=0; i<N; i++) {
      int a, b;
      in >> a >> b;
      mx_rank = max(mx_rank, a);
      A.push_back({a, b});
    }

    sort(A.begin(), A.end());

    int ans = mx_rank;
    //ans += A.begin()->first - 1;
    ans += A.rbegin()->second;

    out << ans;
  }
};


int main() {
  TaskB solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 1400