akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int ans;
  if(n <= 111) {
    ans = 111;
  } else if(n <= 222) {
    ans = 222;
  } else if(n <= 333) {
    ans = 333;
  } else if(n <= 444) {
    ans = 444;
  } else if(n <= 555) {
    ans = 555;
  } else if(n <= 666) {
    ans = 666;
  } else if(n <= 777) {
    ans = 777;
  } else if(n <= 888) {
    ans = 888;
  } else {
    ans = 999;
  }

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


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

ll l(ll n){
  vector<ll> dp(100);
  dp[0] = 2;
  dp[1] = 1;
  for(ll i = 2;i <= n ;++i){
    dp[i] = dp[i-1] + dp[i-2];
  }
  return dp[n];
}

int main(){
  ll i,ans;
  cin >> i;
  ans = l(i);
  cout << ans << endl;
  return 0;
}


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

long N,M;vector<vector<long>> g;

void color(long b,vector<long> &c) {
  for (long x:g[b]) {
    if (c[x]==0L) {
      if (c[b]==1L) c[x]=2L;
      else if (c[b]==2L) c[x]=1L;
      color(x,c);
    }
  }
}

long hantei(vector<long> &c,vector<pair<long,long>> p) {
  long result=0L;
  for (pair<long,long> x:p) {
    long a=x.first;long b=x.second;
    if (c[a]==c[b])  {
      result=-1L;
      break;
    }
  }
  if (result!=-1L) {
    long s=0L,t=0L;
    for (int i=0;i<N;i++) {
      if (c[i]==1L) s++;
      else if(c[i]==2L) t++;
    }
    result=s*t;
  }
  return result;
}

int main() {
  cin >> N >> M;vector<long> c(N,0);
  g.resize(N);vector<pair<long,long>> P(M);
  for (int i=0;i<M;i++) {
    long a,b;cin >> a >> b;a--;b--;
    g[a].push_back(b);g[b].push_back(a);
    P[i]=make_pair(a,b);
  }
  c[0]=1L;
  color(0,c);
  long res=hantei(c,P);
  if (res!=-1L) {
    cout << res-M << endl;
  }
  else {
    cout << N*(N-1L)/2L-M << endl;
  }
}

Measured memory_bytes: 10880
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>

#define MAXN 105
#define MAXV 100001
#define INF 10000000000000
#define fst first
#define snd second

using namespace std;

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

pii arr[MAXN];
ll dp[MAXN][MAXV];

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

    for(int i = 0; i < MAXN; i++) {
        for(int j = 0; j < MAXV; j++) {
            dp[i][j] = -1;
        }
    }

    int n, tot_val = 0;
    ll w;
    cin >> n >> w;
    for(int i = 0; i < n; i++) {
        cin >> arr[i].fst >> arr[i].snd;
        tot_val += arr[i].snd;
    }

    for(int i = 0; i < MAXN; i++) {
        for(int j = 0; j < MAXV; j++) {
            dp[i][j] = INF;
        }
    }
    for(int i = 0; i <= n; i++) {
        dp[i][0] = 0;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= tot_val; j++) {
            dp[i][j] = dp[i - 1][j];
            if(arr[i - 1].snd <= j) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - arr[i - 1].snd] + arr[i - 1].fst);
            }
        }
    }

    int ans = 0;
    for(int v = tot_val; v > 0; v--) {
        if(dp[n][v] <= w) {
            ans = max(ans, v);
        }
    }

    cout << ans << '\n';

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  map<long long,long long> cnt;
  set<long long> s;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    cnt[a[i]]++;
    s.insert(a[i]);
  }

  string ret = "Yes";

  if(s.size() > 3){
    ret = "No";
  }else if(s.size() == 3){
    auto itr = s.begin();
    long long p = *itr,q = *(++itr),r = *(++itr);
    if(n % 3 != 0)ret = "No";
    if(cnt[p] != n/3)ret = "No";
    if(cnt[q] != n/3)ret = "No";
    if(cnt[r] != n/3)ret = "No";
    if((p^r) != q)ret = "No";
    if((q^p) != r)ret = "No";
    if((r^q) != p)ret = "No";
  }else if(s.size() == 1){
    long long p = *(s.begin());
    if((p^p) != p)ret = "No";
  }else if(s.size() == 2){
    auto itr = s.begin();
    long long p = *itr,q = *(++itr);
    if(n%3 != 0)ret = "No";
    if(cnt[p] > cnt[q])swap(p,q);
    if(cnt[p] != n/3)ret = "No";
    if(cnt[q] != n/3*2)ret= "No";
    if((p^q) != q)ret = "No";
    if((q^q) != p)ret = "No";
  }
  cout << ret << endl;
}


Measured memory_bytes: 9344
w, h, n = map(int, input().split())
y0 = 0
y1 = h
x0 = 0
x1 = w
for i in range(n):
    x, y, a = map(int, input().split())
    if a==1:
        x0 = max(x0, x)
    elif a==2:
        x1 = min(x1, x)
    elif a==3:
        y0 = max(y0, y)
    elif a==4:
        y1 = min(y1, y)
if (x1-x0>0) and (y1-y0>0):
    print((x1-x0)*(y1-y0))
else:
    print(0)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class Main {
    public static void main(String []args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver=new Task();
        solver.solve(1,in,out);
        out.close();
    }
    static class Task{
        public void solve(int testnumber,InputReader in,PrintWriter out){
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int Max = Math.max(a,Math.max(b,c));
            int Min = Math.min(a,Math.min(b,c));
            int Mid = a+b+c-Max-Min;
            if(Min == 5 && Mid == 5 && Max == 7){
                out.println("YES");
            } else {
                out.println("NO");
            }
        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 22996
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;

/*** MOD CALCULATION ***/

const int MOD = 1e9+7;
const int MAX = 510000;

ll addM(ll a, ll b){
	ll temp = (a + b) % MOD;
	while(temp<0) temp += MOD;
	return temp;
}

ll mulM(ll a, ll b){
	ll temp = (a * b) % MOD;
  	while(temp<0) temp += MOD;
  	return temp;
}

ll powM(ll a, ll b){
	if(b == 0) return 1;
  	else if(b == 1) return a%MOD;
  	else if(b%2==0) return mulM(powM(a,b/2),powM(a,b/2));
  	else return mulM(a,mulM(powM(a,(b-1)/2),powM(a,(b-1)/2)));
}

// b^{-1} = b^{p-2} (mod p)
// a/b = a*b^{p-2} (mod p)
ll divM(ll a, ll b){ 
  	return mulM(a,powM(b,MOD-2));
}

// n!, (n!)^{-1} のテーブル作成
ll fac[MAX], finv[MAX], inv[MAX];
void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep3(i,2,MAX-1){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

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

/*** MOD CALCULATION ここまで ***/

void Main() {
	int n;
	cin >> n;
    vll a(n), b(n);
    vector<Pll> data;
    ll anstemp = 0;
    
    rep(i, n) {
        cin >> a[i] >> b[i];
        if(a[i] == 0 && b[i] == 0) {
            anstemp++;
            continue;
        }
        if(a[i] == 0) data.pb(Pll(0, 1));
        else if(b[i] == 0) data.pb(Pll(1, 0));
        else {
            ll g = gcd(a[i], b[i]);
            if(a[i]/g > 0) data.pb(Pll(a[i]/g, b[i]/g));
            else data.pb(Pll(-a[i]/g, -b[i]/g));
        }
    }
    
    /*
    for(auto i : data) cout << i.fi << " " << i.se << endl;
    cout << endl;
    //*/
    
    ll ans = 1;
    map<Pll, ll> mp;
    
    rep(i, data.size()){
        mp[data[i]]++;
    }
    
    map<Pll, bool> seen;
    
    for(auto k : data){
        if(seen[k]) continue;
        ll temp;
        auto [x, y] = k;
        Pll l;
        if (y == 0) l = Pll(0, 1);
        else if (x == 0) l = Pll(1, 0);
        else if(y > 0) l = Pll (y, -x);
        else l = Pll(-y, x);
        temp = addM( powM(2, mp[k]), powM(2, mp[l]) - 1 );
        ans = mulM(ans, temp);
        //cout << "k = " << x << "," << y << ": " << seen[k] << ", ans = " << ans << endl;
        //cout << "l = " << l.fi << "," << l.se << ": " << seen[l] << endl;
        seen[k] = true;
        seen[l] = true;
    }
    
    cout << addM( ans - 1, anstemp ) << endl;
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

int main (void)
{
	ll n, m, x, a = 0, p = 0;
	string s;
	cin >> n >> m;
	vector<ll> v(n, 0), w(n, 0);
	for (ll i = 0; i < m; ++i)
	{
		cin >> x >> s;
		if(s == "WA" && v[x-1] == 0)
			w[x-1]++;
		else if(s == "AC" && v[x-1] == 0)
		{
			v[x-1] = 1;
			a++;
		}
	}

	for (int i = 0; i < n; ++i)
		if(v[i] == 1)
			p += w[i];

	cout << a << ' ' << p;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 59;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N>>K;
    ll ans = N - K + 1;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll last = a[0], lid = 0;
    vector<bool> so(N,false);
    reps(i,1,N){
        if(last > a[i]){
            lid = i;
        }else if(i - K + 1 >= lid){
                so[i - K + 1] = true;
        }
        last = a[i];
    }
    set<ll> sub;
    reps(i,1,K) sub.insert(a[i]);
    reps(i,K,N){
        if((*sub.begin() > a[i-K]) && (sub.lower_bound(a[i]) == sub.end()) && (!so[i-K])){
            --ans;
        }
        sub.erase(a[i-K+1]);
        if(i != N-1) sub.insert(a[i]);
    }
    bool first = true;
    rep(i,N) {
        if(so[i]){
            //cout<<i<<endl;
            if(first) first = false;
            else --ans;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11264
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;


pair <int,char> card[9];


bool iswin(void){
	int s=0;
	sort(card,card+9);
	do{
		int rec=0;
		rep(i,3){
			if(card[3*i].second==card[3*i+1].second&&card[3*i+1].second==card[3*i+2].second){
				if(card[3*i].first==card[3*i+1].first&&card[3*i+1].first==card[3*i+2].first)
					rec++;
				if(card[3*i].first+1==card[3*i+1].first&&card[3*i+1].first+1==card[3*i+2].first)
					rec++;
			}
		}
		s=max(s,rec);
	}while(next_permutation(card,card+9));
	
	if(s==3)
		return true;
	else
		return false;
}

int main(void){
	int t;
	cin >> t;
	rep(i,t){
		rep(j,9) cin >> card[j].first;
		rep(j,9) cin >> card[j].second;	
		cout << iswin() << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

enum {
	X, Y, H
};

int main(void) {
	LL N;
	cin >> N;

	vector<vector<LL> > coordinate(N, vector<LL>(3));
	rep(i, N) cin >> coordinate[i][X] >> coordinate[i][Y] >> coordinate[i][H];


	for (LL x = 0; x <= 100; x++) {
		for (LL y = 0; y <= 100; y++) {
			set<LL> st;
			for (LL i = 0; i < N; i++) {
				if (coordinate[i][H] >= 1) {
					st.insert(coordinate[i][H] + abs(coordinate[i][X] - x) + abs(coordinate[i][Y] - y));
				}
			}
			
			if (st.size() == 1) {
				for (LL i = 0; i < N; i++) {
					//すべての点で条件を満たしたなら出力して終了
					if (i == N - 1) {
						cout << x << " " << y << " " << *st.begin() << endl;
						return 0;
					}

					if (coordinate[i][H] != 0) {
						continue;
					}

					//条件を満たさないなら別の点を探索
					if (*st.begin() - abs(coordinate[i][X] - x) - abs(coordinate[i][Y] - y) > 0) {
						break;
					}
				}
			}
		}

	}

	return 1;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc076/tasks/abc076_b

N = int(input())
K = int(input())

min_ans = -1

def dfs(n, count):
    global min_ans

    if count == N:
        if n < min_ans or min_ans < 0:
            min_ans = n
        return

    dfs(n * 2, count + 1)
    dfs(n + K, count + 1)

dfs(1, 0)
print(min_ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>

using namespace std;

int main() {
	int A, B;

	cin >> A >> B;

	if (A <= 8 && B <= 8)cout << "Yay!" << endl;
	else cout << ":(" << endl;

	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int k, string s) {
    int n = cast(int)s.length;
    int score = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i+1]) score++;
    }
    int ans = min(score + 2 * k, n - 1);
    return ans;
}

void main() {
    int n, k; scan(n, k);
    string s = read!string;
    writeln(calc(k, s));
}


Measured memory_bytes: 508
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>

using namespace std;

int main() {
	int i, j, k;
	int n;

	cin >> n;

	if (n > 999) {
		cout << "ABD" << endl;
	}
	else {
		cout << "ABC" << endl;
	}













	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
# -*- coding: UTF-8 -*-
import math 
import sys
     
for line in sys.stdin:
    N = int(line.rstrip())
    count = 0
    for a in range(10):
       for b in range(10):
          for c in range(10):
             for d in range(10):
                 if sum([a,b,c,d]) == N:
                     count += 1
                     break
    print(count)


Measured memory_bytes: 5648
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
  while( 1 ) {
    int r, c;
    cin >> r >> c;
    if( !r && !c ) { return EXIT_SUCCESS; }
    cout << ( ( r % 2 && c % 2 ) ? "no" : "yes" ) << endl;
  }
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
int lst[Max];
int n;

bool check()
{
	for (int i = 1; i <= n; i++)
	{
		if (lst[i] % 2 != 0) return false;
		else lst[i] /= 2;
	}
	return true;
}

int main()
{

	cin >> n;
	for (int i = 1; i <= n; i++)scanf("%d", &lst[i]);
	int g = 0;
	while (check())
	{
		g++;
	}
	cout << g;
}

Measured memory_bytes: 3204
#include <stdio.h>
 
int main(void)
{
    int i, j = 0, num[26];
    char moji;
     
    for(i = 0; i < 26; i++) num[i] = 0;
     
    while(scanf("%c", &moji) != EOF)
    {
        for(i = 0; i < 26; i++)
        if(i == (moji - 'a') || i == (moji - 'A')) num[i]++;
    }
     
    for(i = 0; i < 26; i++) printf("%c : %d\n", i + 'a', num[i]);
     
    return 0;
}
 

 

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B;
    cin >> A >> B;

    int count = 0;

    for (int i = A; i <= B; i++){
        int a = i / 10000;
        int b = (i - 10000 * a) / 1000;
        int c = (i - 10000 * a - 1000 * b) / 100;
        int d = (i - 10000 * a - 1000 * b - 100 * c) / 10;
        int e = i % 10;
        if( a == e && b == d){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int N;
ll table[300000][60];

int main() {
	cin >> N;

	vector<ll> a;
	ll sum = 0;
	
	for (int i = 0; i < N; i++) {
		ll x; cin >> x;
		a.push_back(x);

		for (int j = 0; j < 60; j++) {
			if (i == 0) {
				table[i][j] = x % 2;
			}
			else {
				table[i][j] = table[i - 1][j] + x % 2;
			}
			x /= 2;
		}
	}
	for (ll i = N - 1; i > 0; i--) {
		for (int j = 0; j < 60; j++) {
			if (a[i] % 2 == 1) {
				sum += (i - table[i-1][j]) * ((1LL << j) % 1000000007);
				sum %= 1000000007;
			}
			else {
				sum += table[i - 1][j] * ((1LL << j) % 1000000007);
				sum %= 1000000007;
			}
			a[i] /= 2;
		}
	}

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

Measured memory_bytes: 144876
n=int(input())
L=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[2])
for cx in range(101):
	for cy in range(101):
		H=L[-1][2]+abs(L[-1][0]-cx)+abs(L[-1][1]-cy)
		if all([L[i][2]==max(H-abs(L[i][0]-cx)-abs(L[i][1]-cy),0) for i in range(n-1)]):
				print(cx,cy,H)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 210000000
#define int long long

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
    int h,w;
    cin >> h >> w;
    for(int i=0;i<w+2;i++){
        cout << '#';
    }
    cout << "\n";
    for(int i=0;i<h;i++){
        cout << '#';
        for(int j=0;j<w;j++){
            char tmp;
            cin >> tmp;
            cout << tmp;
        }
        cout << '#' << endl;
    }
    for(int i=0;i<w+2;i++){
        cout << '#';
    }
    cout << "\n";
}



Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = int;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][4], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v;
map<string, vector<LL>>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	ma["あ"].push_back(0);
	rep(i, n) {
		LL x,y,z,w;
		string s1, s2;
		cin >> x;
		if (x == 0) {
			cin >> s1;
			cin >> y;
			ma[s1].push_back(y);
		}
		if (x == 1) {
			cin >> s1;
			if (ma[s1].size()) {
				rep(j, ma[s1].size()) {
					cout << ma[s1][j];
					cout << endl;
				}
			}
			
		}
		if (x == 2) {
			cin >> s1;
			ma[s1].clear();
		}
		if (x == 3) {
			cin >> s1 >> s2;
			s2.push_back(0);
			auto it1 = ma.lower_bound(s1), it2 = ma.upper_bound(s2);
			for (auto itr = it1; itr != it2; itr++) {
				if (itr->second.size() > 0) {
					rep(j, itr->second.size()) {
						cout << itr->first << " " << itr->second[j] << endl;
					}

				}
			}
		}
	}
	return 0;
}


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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>
const int mod=1e9+7;

int lowbit(int x) {return x&(-x);}
pii node[3010];
ll frac[200010],inv[200010];
ll f[3010];

ll power(ll base,int d) {
	ll res=1ll;
	while (d) {
		if (d&1) (res*=base)%=mod;
		(base*=base)%=mod;
		d>>=1;
	}
	return res;
}

void init() {
	frac[0]=inv[0]=1ll;
	for (int i=1;i<200000;i++) {
		frac[i]=(frac[i-1]*(ll)i)%mod;
		inv[i]=power(frac[i],mod-2);
	}
}

ll getC(int x,int y) {
	ll res=(frac[x]*inv[x-y])%mod;
	(res*=inv[y])%=mod;
	return res;
}

int main(){
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	init();
	for (int i=0;i<q;i++) {
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		node[i].fi=x,node[i].se=y;
	}
	node[q].fi=n-1,node[q++].se=m-1;
	sort(node,node+q);
	for (int i=0;i<q;i++) {
		f[i]=getC(node[i].fi+node[i].se,node[i].fi);
//		cout<<f[i]<<" ";
		for (int j=0;j<i;j++) {
			int x=node[i].fi-node[j].fi,y=node[i].se-node[j].se;
			if (y<0) continue;
			ll tmp=getC(x+y,x);
			(tmp*=(ll)f[j])%=mod;
//			cout<<i<<" "<<j<<" "<<tmp<<endl;
			f[i]=(f[i]+mod-tmp)%mod;
		}
//		cout<<f[i]<<endl;
	}
	cout<<f[q-1]<<endl;
	return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[200001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = h->size;
	data tmp;
	h->obj[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->obj[i].key < h->obj[(i-1)/2].key) {
			tmp = h->obj[(i-1)/2];
			h->obj[(i-1)/2] = h->obj[i];
			h->obj[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 0, j;
	data output = h->obj[0], tmp;
	h->obj[0] = h->obj[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->obj[i*2+1].key < h->obj[i*2+2].key) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, Q, S[200001], T[200001], X[200001], D[200001];
	scanf("%d %d", &N, &Q);
	for (i = 1; i <= N; i++) scanf("%d %d %d", &(S[i]), &(T[i]), &(X[i]));
	for (i = 1; i <= Q; i++) scanf("%d", &(D[i]));
	
	int j, l[2], r[2], m;
	data d;
	min_heap h[2];
	for (i = 1, h[0].size = 0; i <= N; i++) {
		d.key = S[i] - X[i];
		d.id = i;
		push(d, &(h[0]));
	}
	for (i = 1, h[1].size = 0; i <= Q; i++) {
		while (h[0].size > 0 && h[0].obj[0].key <= D[i]) {
			d = pop(&(h[0]));
			j = d.id;
			d.key = X[j];
			d.id = T[j] - X[j];
			push(d, &(h[1]));
		}
		while (h[1].size > 0 && h[1].obj[0].id <= D[i]) pop(&(h[1]));
		if (h[1].size > 0) printf("%d\n", h[1].obj[0].key);
		else printf("-1\n");
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7920
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define MOD (LL)pow(10,9) + 7


int main(){
    string a;
    cin >> a;
    bool fa = false,fb = false;

    for(int i = 0;i < 3; ++i){
        if(a[i] == 'B'){
            fb = true;
        }else{
            fa = true;
        }
    }

    if(fa && fb){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, a[200010];
ll ans;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = 1; i <= n; i++) {
		if (a[i - 1] > a[i])ans += a[i - 1] - a[i], a[i] = a[i - 1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

#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 debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N,M;
    while((cin>>N>>M,N|M)){
        int r;cin>>r;
        vector<vector<int>> imos(N,vector<int>(750,0));
        rep(i,r){
            int t,n,m,s;cin>>t>>n>>m>>s;
            t-=540;n--;
            if(s==1){
                imos[n][t]+=m;
            }else imos[n][t]-=m;
        }
        rep(i,N)
            rep(j,730)imos[i][j+1]+=imos[i][j];
        int q;cin>>q;
        while(q--){
            int ts,te,m;cin>>ts>>te>>m;
            ts-=540;te-=540;
            int res=0;
            for(int i=ts;i<te;i++)rep(j,N)if(imos[j][i]==m){res++;break;}
            cout<<res<<endl;
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int n = N;
  int sum = 0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  if(N%sum == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}

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

void solve()
{
	int n, a, b;
	cin >> n >> a >> b;
	
	int s = 0;
	while(s<a)
	{
		s += n;
	}
	if(s <= b) cout << "OK";
	else cout << "NG";
	
}

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


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr ll INF = 1e18;
constexpr double PI = 3.14159265358979;

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

  string s;
  long long k, ans = 0, cnt = 0;
  cin >> s >> k;
  string t = s+s+s;
  int n = (int)s.size();
  if(n == 1){
    cout << k/2 << endl;
    return 0;
  }
  for(int i = 1; i < n; i++){
    if(s[i] == s[i-1]){
      s[i] = '.';
      cnt++;
    }
  }
  if(s[0] == s[n-1]){
    int cnt1 = 0, cnt2 = 0;
    for(int i = 1; i < n+n+n; i++){
      if(t[i] == t[i-1]){
        if(i < n){
          t[i] = '.';
          ans++;
        }else if(n <= i and i < n+n){
          t[i] = '.';
          cnt1++;
        }else{
          t[i] = '.';
          cnt2++;
        }
      }
    }
    k--;
    if(cnt1 != cnt2){
      ans += cnt1*(k/2+k%2);
      ans += cnt2*(k/2);
    }else{
      ans += cnt1*k;
    }
  }else{
    ans += cnt*k;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int a, b, t;
  cin >> a >> b >> t;
  cout << t / a * b << endl;
}


Measured memory_bytes: 256
//exawiz2019_b.cpp
//Sat Mar 30 20:43:01 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int N;
	cin >> N;
	string s;
	cin >> s;

	int red = 0;
	int blue = 0;
	for (int i=0;i<s.length();i++){
		if (s[i]=='R'){
			red++;
		}else {
			blue++;
		}
	}

	if (red>blue){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn digit(n: u64) -> u64 {
    if n == 0 {
        return 1;
    }
    for i in 0..20u32 {
        if n < 10u64.pow(i) {
            return i as u64;
        }
    }
    20u64
}

fn main() {
    let (a, b) = input_tuple();
    let n = a * 10u64.pow(digit(b) as u32) + b;
    // println!("{}", n);
    let mut i = 1;
    while i * i < n {
        i += 1;
    }
    if i * i == n {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2156
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	adivs, bdivs := enumPrime(A), enumPrime(B)
	ans := 0
	for ak, _ := range adivs {
		if _, ok := bdivs[ak]; ok {
			ans++
		}
	}
	fmt.Println(ans)
}

func enumPrime(P int) (dividers map[int]int) {
	dividers = make(map[int]int)
	for i := 2; i*i <= P; i++ {
		tmp := 0
		_P := P
		_pow := i
		for _P%i == 0 {
			_pow *= i
			tmp++
			_P /= i
		}
		if tmp > 0 {
			dividers[i] = tmp
			P /= (_pow / i)
		}
	}
	if P > 0 {
		dividers[P] = 1
	}
	dividers[1] = 1
	return
}


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

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
#define tmp template<class t>

tmp void chmax(t&a,t b){if(a<b)a=b;}
tmp void chmin(t&a,t b){if(a>b)a=b;}

tmp using vc=vector<t>;
tmp using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

tmp ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

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

tmp void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll read(){ll i;cin>>i;return i;}

using ld=long double;
using cm=complex<ld>;
#define x real()
#define y imag()
const ld eps=1e-12;
int sgn(ld a){return a<-eps?-1:(a>eps?1:0);}
auto cmcmp=[](const cm&a,const cm&b){
	if(sgn(a.x-b.x))return a.x<b.x;
	else return sgn(a.y-b.y)<0;
};

struct ln{
	cm a,b;
	cm dir(){return b-a;}
};
ld dot(cm a,cm b){return a.x*b.x+a.y*b.y;}
ld crs(cm a,cm b){return a.x*b.y-a.y*b.x;}
int ccw(cm a,cm b){return sgn(crs(a,b));}
int ccw(cm a,cm b,cm c){return ccw(b-a,c-a);}
int ccw(ln a,cm b){return ccw(a.a,a.b,b);}

//(-2)[a,-1](0)[b,1](2)
int bet(cm a,cm b,cm c){
	cm d=b-a;
	ld e=dot(d,c-a);
	if(sgn(e)<=0)return sgn(e)-1;
	return sgn(e-norm(d))+1;
}

ld tri2(cm a,cm b,cm c){
	return crs(b-a,c-a);
}

cm readcm(){
	ld a,b;
	cin>>a>>b;
	return cm(a,b);
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	while(1){
		cm a=readcm();
		cm b=readcm();
		cm c=readcm();
		cm d=readcm();
		if(cin.eof())break;
		if(ccw(a,b,c)==-1)
			swap(b,c);
		if(min({ccw(a,b,d),ccw(b,c,d),ccw(c,a,d)})==1)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
}



Measured memory_bytes: 3168
<?php
$sc = new Scanner();

$card_count = $sc->nextInt();

$num_arr = array($sc->nextInt());
while ($sc->hasNext()) {
    array_push($num_arr, $sc->nextInt());
}

rsort($num_arr);

$alice = 0;
$bob = 0;
for ($i = 0; count($num_arr) > $i; $i++) {
    if ($i % 2 === 0) {
        $alice += $num_arr[$i];
    } else {
        $bob += $num_arr[$i];
    }
}

out::println($alice - $bob);


class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function println($str = "")
    {
        echo $str . PHP_EOL;
    }
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if( ( A + B ) > ( C + D ) ){
    cout << "Left" << endl;
  }
  else if( ( A + B ) == ( C + D ) ){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  auto cdiv = [&](auto a, auto b) {
    return (a + b - 1) / b;
  };
  cout << cdiv(N, X) * T << "\n";
}

Measured memory_bytes: 3560
/*input
7
nikoandsolstice
*/

#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() {
  int k;
  string s;
  cin >> k >> s;
  int mi = min(k, (int)s.size());
  rep(i, mi) cout << s[i];
  if (s.size() > k) cout << "...";
  cout << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

bool cmp(pair<int, pair<string, int> > a, pair<int, pair<string, int> > b){
    if(a.second.first < b.second.first){
        return true;
    }else if(a.second.first == b.second.first){
        return a.second.second > b.second.second;
    }
    return false;
}

int main(){
    int n;
    cin >> n;
    vector<pair<int, pair<string, int> > > v;
    for(int i = 0; i < n; i++){
        int p;
        string s;
        cin >> s >> p;
        v.push_back(make_pair(i, make_pair(s, p)));
    }
    sort(v.begin(), v.end(), cmp);

    for(int i = 0; i < n; i++){
//        cout << v[i].second.first << " " << v[i].second.second << endl;
        cout << v[i].first+1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <cstring>
#include <algorithm> 
#include <cmath> 
#include <cstdio> 
typedef long long ll;
#define size 500050
using namespace std;
int a[size];
struct node {
	int x,y;
}p[size];
bool cmp(node a,node b) {
	if(a.x==a.x) {
		return a.y<b.y;
	}
	return a.x<a.x;
}
int main()
{
	int n;
	cin >> n;
	for(int i=1; i<=n; i++) {
		cin >> p[i].x >> p[i].y;
	}
	sort(p+1,p+1+n,cmp);
	
	int l=0;
	for(int i=1; i<=n; i++) {
		if(l+p[i].x > p[i].y) {
			cout<<"No"<<endl;
			return 0;
		}
		l += p[i].x;
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  int t,a,b;
  int tp=0,ap=0,bp=0;
  
  for(int i=0; i<n; i++){
    cin >> t >> a >> b;
    if(t-tp >= a - ap + b - bp && (t-tp)%2 == (a - ap + b - bp)%2){
      continue;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

namespace _20191021
{
    class Program
    {
        static void Main(string[] args)
        {
            int r = int.Parse(Console.ReadLine());

            Console.WriteLine(3 * (r * r));
        }
    }
}


Measured memory_bytes: 13140
from functools import reduce

mod = 10 ** 9 + 7
def madd(x, y):
    ret = x + y
    return ret if ret < mod else ret - mod
def msub(x, y):
    ret = mod + x - y
    return ret if ret < mod else ret - mod
def mmul(x, y):
    return (x * y) % mod
def mpow(x, n):
    ret = 1
    while n > 0:
        if n & 1 > 0:
            ret *= x
            ret %= mod
        x = (x * x) % mod
        n >>= 1
    return ret

def msum(a):
    return reduce(madd, a, 0)

n, k = map(int, input().split())
INF = - (2**60)
dp = [-INF] * (k + 1)

for g in range(k, 0, -1):
    dp[g] = msub(mpow(k // g, n), msum(dp[2 * g::g]))

print(msum([mmul(g, dp[g]) for g in range(1, k + 1)]))

Measured memory_bytes: 15860
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

void solve(){
    int n;
    cin>>n;
    ll ans=0;
    vector<pair<int,int>> l, r;
    rep(i,n){
        int k,x,y;
        cin>>k>>x>>y;
        if(x>=y){
            ans += y;
            l.emplace_back(x-y, k - 1);
        } else {
            ans += x;
            r.emplace_back(y-x, k - 1);
        }
    }
    set<int> L, R;
    rep(i,l.size())L.insert(i);
    rep(i,r.size())R.insert(i + l.size());
    sort(l.rbegin(),l.rend());
    sort(r.rbegin(),r.rend());
    for(auto e : l){
        auto itr = L.upper_bound(e.second);
        if (itr != L.begin()) {
            --itr;
            ans += e.first;
            L.erase(itr);
        }
    }
    for(auto e : r){
        auto itr = R.upper_bound(e.second);
        if (itr != R.end()) {
            ans += e.first;
            R.erase(itr);
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}

Measured memory_bytes: 14276
n = gets.chomp.to_i
array = gets.split.map(&:to_i)
negative_count = 0
array.each do |num|
  negative_count += 1 if num < 0
end
may_ans = 0
array.each do |num|
  may_ans += num.abs
end
if negative_count.even?
  ans = may_ans
else
  abs_array = array.map{ |num| num.abs }
  ans = may_ans - 2 * abs_array.min
end
puts ans

Measured memory_bytes: 9348
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long x;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>x;
	for(long long a=-120;a<=120;a++){
		for(long long b=-120;b<=120;b++){
			if(a*a*a*a*a - b*b*b*b*b ==x){
				cout<<a<<' '<<b<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3656
import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List
import Text.Parsec
import Text.Parsec.String

main :: IO ()
main = do
  s <- getLine
  unless (s == ".") $ do
    print $ solve s
    main

solve :: String -> Int
solve s = length . filter f $ ls
  where
    f :: (Char, Char, Char) -> Bool
    f x = '2' == either (const ' ') id (parse formula "" (tr s x))
    ls = [(p,q,r)|p <- "012", q <- "012", r <- "012"]

minus :: Char -> Char
minus '0' = '2'
minus '1' = '1'
minus _ = '0'

mul :: Char -> Char -> Char
mul '2' '2' = '2'
mul '0' _ = '0'
mul _ '0' = '0'
mul _ _ = '1'

add :: Char -> Char -> Char
add '0' '0' = '0'
add '2' _ = '2'
add _ '2' = '2'
add _ _ = '1'

addmul :: Char -> Char -> Char -> Char
addmul x '*' y = mul x y
addmul x _ y = add x y

formula :: Parser Char
formula = num <|> ht <|> skwa

num :: Parser Char
num = char '0' <|> char '1' <|> char '2'

ht :: Parser Char
ht = char '-' *> (minus <$> formula)

skwa :: Parser Char
skwa = char '(' *> (addmul <$> formula <*> (char '*' <|> char '+') <*> formula) <* char ')'

tr :: String -> (Char, Char, Char) -> String
tr expr (x,y,z) = map g expr
  where
    g 'P' = x
    g 'Q' = y
    g 'R' = z
    g w = w

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >> a[i];
	
	ll ans = 1LL<<60;
	rep2(i, 1, 101){
		ll sm =0;
		rep(j, n){
			sm += (a[j] - i) * (a[j] - i);
		}
		//dbg("dd", i, sm);
		ans = min(ans, sm);
	}
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
void main() {
  int N=to!int(chomp(readln()));
  string[] input=split(readln());
  int ans=1<<30;
  foreach(item;input) {
    int A=to!int(item);
    int cnt=0;
    while(A%2==0) A/=2,cnt++;
    ans=min(ans,cnt);
  }
  writeln(ans);
}


Measured memory_bytes: 256