akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int q = in();
  map<string, int> m;
  while (q--) {
    int t = in();
    if (t == 0) {
      string k;
      int x;
      cin >> k >> x;
      m[k] = x;
    }
    if (t == 1) {
      string s = in<string>();
      cout << (m.count(s) ? m[s] : 0) << endl;
    }
    if (t == 2) m.erase(in<string>());
    if (t == 3) {
      string l, r;
      cin >> l >> r;
      for (auto it = m.lower_bound(l), end = m.upper_bound(r); it != end; it++) cout << *it << endl;
    }
  }
}



Measured memory_bytes: 27876
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<array>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/
typedef tuple<int,int,int> tpl;


//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

    int N,M;
    cin >> N >> M;

    int v[5] = {};
    for (int i = 0; i < 5; i++)
    {
        v[i] = -1;
    }

    bool ok = true;
    for (int i = 0; i < M; i++)
    {
        int s,c;
        cin >> s >> c;
        if(v[s] == -1 || v[s] == c){
            v[s] = c;
        }else{
            ok = false;
        }
    }
    
    for (int i = 1; i <= N; i++)
    {
        if(v[i] == -1){
            if(i==1){

                if(N==1){
                    v[i] = 0;
                }else
                {
                    v[i] = 1;
                }
                
            }else{
                v[i] = 0;
            }
        }
    }

    if(N > 1 && v[1] == 0){
        ok = false;
    }
    
    if(ok){
        for (int i = 1; i <= N; i++)
        {
            cout << v[i];
        }
        cout << endl;
    }else{
        cout << "-1" << endl;
    }


	return 0;
}






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

int main(void)
{
    int k, x;
    cin >> k >> x;
    if (k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
//============================================================================
// Name        : Calc.cpp
// Author      : Roman
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <fstream>

using namespace std;


int main() {
	// ifstream cin ("/Users/shuffler/Documents/workspace/Calc/src/input.txt");
	// ofstream cout ("/Users/shuffler/Documents/workspace/Calc/src/output.txt");

	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);

	long long n;
	long long x;
	cin >> n;
	cin >> x;
	long long ans = 1000000001 * n;
	vector < long long > a(2*n);
	for (long long i = 0; i < n; ++i) {
		cin >> a[i];
		a[i + n] = a[i];
	}
	vector < vector < int > > mns(n, vector < int > (n, 0));
	for (long long i = n; i < a.size(); ++i) {
		long long mn = 1000000001;
		for (int j = 0; j < n; ++j) {
			mn = min(mn, a[i - j]);
			mns[i - n][j] = mn;
		}
	}
	//cout << "sdds" << endl
	for (int i = 0; i < n; ++i) {
		long long res = 0;
		for (int j = 0; j < n; ++j) {
			res += mns[j][i];
		}
		res += i* x;
		ans = min(ans, res);
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 16000
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <sstream>
#include <set>
#include <map>
#include <complex>
#include <deque>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define inf 999999999
#define ll long long
#define sort(a,n) sort(a,a+n)
#define fi  first
#define se second
#define pb(a) push_back(a)

const ll MOD = 1000000007;
const double PI = 3.141592653589793238;

//--------------------------------------------------------------------------------------------//
char a, b;
int main() {
	cin >> a >> b;
	if (a == b) {
		cout << 'H' << endl;
	}
	else {
		cout << 'D' << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll allscore(int i, int d, vector<vector<int>>s, vector<vector<int>>t, vector<int>c) {
	ll res = 0;
	int fury = 0;
	for (int j = 0; j < d; j++) {
		if (t.at(i).at(j) == 1) {
			res += s.at(j).at(i);
			fury = 0;
		}
		else {
			fury++;
			res -= fury * c.at(i);
		}
	}
	return res;
}
ll fastscore(vector<int>bl, int date, int fury) {
	int l = -1;
	int r = bl.size();
	for (int i = date - 1; i >= 0; i--) {
		if (bl.at(i) == 1) {
			l = i;
			break;
		}
	}
	for (int i = date + 1; i < r; i++) {
		if (bl.at(i) == 1) {
			r = i;
			break;
		}
	}
	ll ans = (r - date) * (date - l) * fury;
	return ans;
}
vector<int>greedy(int d, vector<vector<int>>s) {
	vector<int>ans(d);
	for (int i = 0; i < d; i++) {
		int res = 0;
		int tmp = -1;
		for (int j = 0; j < 26; j++) {
			if (res < s.at(i).at(j)) {
				res = s.at(i).at(j);
				tmp = j;
			}
		}
		ans.at(i) = tmp;
	}
	return ans;
}
int main() {
	//input
	int d; cin >> d;
	vector<int>c(26);
	for (int i = 0; i < 26; i++)cin >> c.at(i);
	vector<vector<int>>s(d, vector<int>(26));
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < 26; j++)cin >> s.at(i).at(j);
	}
	vector<int>td = greedy(d, s);
	for (int i = 0; i < d; i++) {
		cout << td.at(i)+1 << endl;
	}
}

Measured memory_bytes: 3712
#include <stdio.h>
int main() {
int a,b,c,d,e,f;scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);printf("%d\n",(a+b*5+c*10+d*50+e*100+f*500 >= 1000));
}

Measured memory_bytes: 1028
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <regex>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define pq priority_queue
#define ll long long
#define MOD 1000000007
#define INF 9999999999
#define F first
#define S second

using namespace std;

typedef pair<int, int> pi;

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

ll x, y, z, add, ans, A[1010101], Q[1010101];
int main() {
	cin >> x >> y >> z;
	add = z;
	while (1) {
		add += y;
		add += z;
		if (add <= x) {
			ans++;
		}
		else
			break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;
ll a[10010],b[10010];

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

    cin>>N;
    for(int i=0;i<N;i++) cin>>a[i];
    for(int i=0;i<N;i++) cin>>b[i];

    ll bal=0;
    for(int i=0;i<N;i++) {
      if (a[i]>b[i]) bal-= a[i]-b[i]; else bal += (b[i]-a[i])/2;
    }

    cout << (bal>=0 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 384
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

D = defaultdict(int)
S = 0

for i in A:
  D[i] += 1
  S += i

for _ in range(Q):
  B, C = map(int, input().split())
  r = D[B]
  D[B] = 0
  D[C] += r
  S += (C - B)*r
  print(S)

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define EPS 1e-9

typedef pair<double, string> pds;
typedef vector<pds> vpds;

bool comp(pds a, pds b)
{
	if (abs(a.first - b.first) < EPS)
		return a.second < b.second;
	else
		return a.first > b.first;
}

int main()
{
	while (1)
	{
		int N; cin >> N;
		if (N == 0) return 0;

		vpds eff(N);
		rep(i, 0, N)
		{
			string L;
			int P, A, B, C, D, E, F, S, M;
			cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;

			double income = M * F * S - P;
			double time = A + B + C + (D + E) * M;
			eff[i] = make_pair(income / time, L);
		}

		sort(eff.begin(), eff.end(), comp);

		rep(i, 0, N)
			cout << eff[i].second << endl;

		cout << "#" << endl;
	}
}

Measured memory_bytes: 3020
use proconio::input;

fn main() {
    input! {
        k: usize,
        t: usize,
        aa: [usize; t],
    }

    let max = aa.into_iter().max().unwrap();
    let rem = k - max;

    if max - 1 <= rem {
        println!("0");
        return;
    }

    let ans = max - 1 - rem;

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


Measured memory_bytes: 2160
#include<stdio.h>
int main()
{
	int a,b,c[3];
	scanf("%d",&a);
	while(1){
		b=a;
		c[0]=b%10; b/=10;
		c[1]=b%10; b/=10;
		c[2]=b%10; b/=10;
		if(c[0]==c[1] && c[1]==c[2]) break;
		a++;
	}
	printf("%d%d%d\n",c[0],c[1],c[2]);
}

Measured memory_bytes: 128
N,M = map(int,input().split())
L,R = map(int,input().split())
for i in range(M-1):
  L_ans,R_ans = map(int,input().split())
  if L < L_ans:
    L = L_ans
  if R > R_ans:
    R = R_ans
print(len(list(range(L,R+1))))

Measured memory_bytes: 6900
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const data = n.split("\n").filter(x => x != "");
    judge(data);
});


function S(dice) {


    [dice[0], dice[1], dice[2], dice[3], dice[4], dice[5]] = [dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]]

    return dice;
}

function N(dice) {

    [dice[0], dice[1], dice[2], dice[3], dice[4], dice[5]] = [dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]]

    return dice;

}

function W(dice) {

    [dice[0], dice[1], dice[2], dice[3], dice[4], dice[5]] = [dice[2], dice[1], dice[5], dice[0], dice[4], dice[3]]

    return dice;
}

function E(dice) {

    [dice[0], dice[1], dice[2], dice[3], dice[4], dice[5]] = [dice[3], dice[1], dice[0], dice[5], dice[4], dice[2]]

    return dice;
}

function judge(data) {
    let ans = "";
    const all = data.map(x => x.split(" "));
    const material = Array.prototype.concat.apply([], all);
    const dice = material.slice(0, 6);
    const strleng = material.length;
    const strall = material.slice(6, strleng);
    const strre = strall.map(x => x.split(""));
    const str = Array.prototype.concat.apply([], strre);
    for (let i = 0; i < str.length; i++) {
        if (str[i] === "N") {
            ans = N(dice);
        } else if (str[i] === "S") {
            ans = S(dice);
        } else if (str[i] === "W") {
            ans = W(dice);
        } else {
            ans = E(dice);
        }
    }
    const ko = Array.prototype.concat.apply([], ans);
    const num = ko.map(x => Number(x));
    console.log(num[0]);
}


Measured memory_bytes: 16240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
struct player{
   ll l,r,comfort;
   player(ll left, ll right){
      l=left;
      r=right;
      comfort=min(l,r);
   }
   bool operator<(const player& x) const{
      return comfort<x.comfort;
   }
};
ll n,a[200005],ans;
priority_queue<player> q;
int main(){
   cin>>n;
   for(ll i=0;i<n;i++) cin>>a[i];
   sort(a,a+n);
   reverse(a,a+n);
   q.push(player(a[0],a[1]));
   ans=a[0];
   for(ll i=2;i<n;i++){
      player p=q.top();
      if(q.size()>1) q.pop();
      ans+=p.comfort;
      q.push(player(a[i],p.l));
      q.push(player(a[i],p.r));
   }
   cout<<ans;
   return 0;
}

Measured memory_bytes: 11092
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        int ans = 0;
        for(int i = a; i <= b; i++){
                if(c % i == 0){
               ans++;
            }
        }
        System.out.println(ans);
    }
}


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

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    int A[100][100] = {0};
    int B[100][100] = {0};
    long long C[100][100] = {0};

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> B[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < l; k++) {
                C[i][k] += A[i][j] * B[j][k];
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            cout << C[i][j];
            if (j != l-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3232
import os, sys, re, math

N = int(input())
S = []
for i in range(N):
    S.append(input())

d = {}
for s in S:
    if not s in d:
        d[s] = 0
    d[s] += 1

d = sorted(d.items(), key=lambda x:x[1], reverse=True)
names = [v[0] for v in d if v[1] == d[0][1]]

for name in sorted(names):
    print(name)


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

int main(){
	long long int test=1;
	//cin>>test;
	while(test--){
	    int a,b,c,d;
	    cin>>a>>b>>c>>d;
	    for(int i=1;i<=100;i++){
	        if(i&1){
	            c=c-b;
	        }
	        else{
	            a=a-d;
	        }
	        if(a<=0 || c<=0)break;
	    }
	    if(a<=0)cout<<"No\n";
	    else cout<<"Yes\n";
	}
	return 0;
}


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

int main( int argc, char *argv[] )
{
  long long n;
  long long nn;

  long long a;
  long long b;
  long long aa;
  long long l;

  scanf( "%lld %lld %lld", &n, &a, &b );
  aa = a + b;
  l = n / aa;
  nn= l * a;

  if( a < (n-(a+b)*l) ) nn += a;
  else nn += (n-(a+b)*l);

  printf( "%lld\n", nn );

}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

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

    int p[10];
    int q[10];

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

    int v[10];
    for(int i = 0; i < n; i++) {
        v[i] = i + 1;
    }

    int cnt, p_cnt, q_cnt;
    cnt = 1;
    do {
        for(int i = 0; i < n; i++) {
            if(p[i] == v[i]) {
                if(i == n - 1) {
                    p_cnt = cnt;
                }
            } else {
                break;
            }
        }

        for(int i = 0; i < n; i++) {
            if(q[i] == v[i]) {
                if(i == n - 1) {
                    q_cnt = cnt;
                }
            } else {
                break;
            }
        }
        cnt++;
    } while(next_permutation(v, v + n));

    cout << abs(p_cnt - q_cnt) << endl;

    return 0;
}

Measured memory_bytes: 3588
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    typedef pair<string,ll> node;
    queue<pll> q;
    ll n,t;
    cin>>n>>t;
    vector<node> dp(n);
    for(int i=0;i<n;i++){
        string s;
        ll a;
        cin>>s>>a;
        q.push({i,a});
        dp[i].F=s;
    }
    ll count=0;
    while(!q.empty()){
        pll N=q.front();
        q.pop();
        if(N.S<=t){
            count+=N.S;
            dp[N.F].S=count;
            cout<<dp[N.F].F<<" "<<dp[N.F].S<<endl;
        }
        else{
            count+=t;
            N.S-=t;
            q.push(N);
        }
    }
    
    return 0;
}



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

int main(){
  int n,a,b,cnt=1; cin>>n;
  vector<int> p(n);
  vector<int> q(n);
  vector<int> data;

  for(int i=0; i<n; i++) cin>>p[i];
  for(int i=0; i<n; i++) cin>>q[i];
  for(int i=0; i<n; i++) data.push_back(i+1);

  do{
    vector<int> tmp;
    for(int i=0; i<n; i++){
      tmp.push_back(data[i]);
    }

    bool flag1,flag2;
    flag1=flag2=true;
      for(int i=0; i<n; i++){
        if(tmp[i] != p[i]) flag1 = false;
        if(tmp[i] != q[i]) flag2 = false;
      }

    if(flag1) a = cnt;
    if(flag2) b = cnt;
    cnt++;
  }while(next_permutation(data.begin(),data.end()));

  cout<<abs(a-b)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int a;
	double ans;
	cin>>a;
	ans=a*2*3.141592;
	cout<<ans;
	return 0;
}


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


int main()
{
    int h,w;
    std::cin >> h >> w;
    std::vector<std::vector<bool>> map(h,std::vector<bool>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char tmp;
            std::cin >> tmp;
            map[i][j] = tmp == '.';
        }
    }
    

    std::vector<std::vector<bool>> mp2(2*h,std::vector<bool>(w));

    for(int i = 0; i < 2*h; i++){
        for(int j = 0; j < w; j++){
            mp2[i][j] = map[i / 2][j];
        }
    }
    for(int i = 0; i < 2*h; i++){
        for(int j = 0; j < w; j++){
            std::cout << (mp2[i][j] ? '.' : '*');
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>

long long euclid(long long x, long long y){
	if(x<y){
		long long tmp= x;
		x= y;
		y= tmp;
	}

	if(y==0)
		return x;

	return euclid(y, x%y);

}


int main(){
	long long a, b, c, d;
	std::cin>>a>>b>>c>>d;

	long long ans= b-a+1;



	long long cd= c* d /euclid(c, d);

	long long mod=0;

	long long modAC= (a-1)/c;
	long long modAD= (a-1)/d;
	long long modACD= (a-1)/cd;

	long long modBC= b/c;
	long long modBD= b/d;	
	long long modBCD= b/cd;

	mod+= (modBC)-(modAC);
	mod+= (modBD)-(modAD);

	mod-= (modBCD)-(modACD);

	std::cout<<ans- mod<<std::endl;

	return 0;
	
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

int n, m;
vector<pair<int, int>> E[101010];
string ans[101010];

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

	rep(i, m) {
		int p, y; cin >> p >> y;
		E[p].push_back({ y,i });
	}
	for (int i = 1; i < n + 1; i++) {
		sort(all(E[i]));
		int n = E[i].size();
		for (int j = 0; j < n; j++) {
			char buf[13];
			sprintf(buf, "%06d%06d", i, j + 1);
			ans[E[i][j].second] = string(buf);
		}
	}
	//rep(i,m)printf("%s\n", ans[i].c_str());
	//↑も↓もおんなじっぽい
	rep(i, m)cout << ans[i] << endl;
}



Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl;
#define deb2(x,y)cout<<"> "<<#x<<"->"<<x<<"  "<<#y<<"->"<<y<<endl;
#define LINE   cout << "--- LINE NO : " << __LINE__ <<"  ---"<< endl;
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}
#define   pi       2*acos(0.0)
#define   inf      (int)1e18
const int mod =    1e9 + 7, mxn =    2e5 + 5;

#define   vt       vector
#define   ff       first
#define   ss       second
#define   int      long long
#define   db       long double
#define   pii      pair<int,int>
#define   Maxpq(x) priority_queue<x>
#define   Minpq(x) priority_queue<x,vt<x>,greater<x>>

#define   pb       push_back
#define   si(x)    (int)x.size()
#define   all(x)   x.begin(),x.end()
#define   mem(a,x) memset(a,x,sizeof(a))
#define   rep(n)    for(int i =0 ; i<n ; i++)
#define   forr(i,n) for(int i=0;i<n;i++)
#define   FOR(a)   for(auto& x :  a )

int mainx() {
    int n;
    cin >> n;


    int sum[n], sub[n], a, b;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        sum[i] = a + b;
        sub[i] = a - b;
    }
    sort(sum, sum + n);
    sort(sub, sub + n);
    cout << max(abs(sum[0] - sum[n - 1]), abs(sub[n - 1] - sub[0])) << endl;
    return 0;
}


bool cmp(pii &a , pii &b) {
    if (a.ff < b.ff)return true;
    if (a.ff == b.ff )return a.ss < b.ss;
    return false;
}
inline void INCLUDE() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
}
int32_t main() {

    //INCLUDE();

    ios::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    //cout << fixed << setprecision(20);

    int tt = 1;
    //cin>>tt;
    for (int t = 1 ; t <= tt ; t++ )
    {
        // cout<<"Case #"<<t<<": ";
        mainx();
    }
    return 0 ;
}



Measured memory_bytes: 6708
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    map<int, int> mp;
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            mp[a]++;
        }
    }
    cout << N - mp.size() << endl;
    return 0;
}

Measured memory_bytes: 3628
<?php
/**
 * Created by PhpStorm.
 * User: ramia
 * Date: 2016/09/24
 * Time: 21:00
 */
class STD {
	static function input(){
		$line = trim(fgets(STDIN));
		return $line;
	}

	static function output( $text ){
		echo $text."\n";
	}
}
$input = STD::input();
$codefestival = 'CODEFESTIVAL2016';

$count = 0;
for( $i=0;$i<16;$i++ ){
	if( $input[$i] != $codefestival[$i] ){
		$count++;
	}
}

STD::output($count);


?>

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

int main()
{
string a,b;
cin>>a>>b;
int m=a.length(); int n=b.length();
int dp[m+1][n+1];
for(int i=0;i<=m;i++)
{
	for(int j=0;j<=n;j++)
	{
		if(i==0 || j==0) dp[i][j]=0;
		else if(a[i-1]==b[j-1]) dp[i][j]=dp[i-1][j-1]+1;
		else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	}
}
//cout<<dp[m][n];

int index=dp[m][n];
char v[index+1]; 
v[index] = '\0';
int i=m,j=n;

while(i>0 && j>0)
{
if(a[i-1]==b[j-1]){v[index-1]=a[i-1]; i--; j--; index--;}
else if(dp[i-1][j]>dp[i][j-1]) i--;
else j--;
}

 cout<<v;

}

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;

  L = A + B;
  R = C + D;

  if (L == R) {
    cout << "Balanced" << endl;
  }
  else if (L > R){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> hw(m);
  for(int i=0;i<m;i++) cin >> hw[i];
  int day =0;
  for(int i=0;i<hw.size();i++) day += hw[i];
  if(n>=day) cout << n-day << endl;
  else cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int n, ans = 0, mx = -1;
int a[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if(a[i] >= mx)
			ans++;
		mx = max(mx, a[i]);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100;
struct Point{int x, y;};

int N;
Point r[MAX_N], b[MAX_N];
bool used[MAX_N];

bool comp1(const Point &a, const Point &b){
	return (a.y == b.y) ? (a.x < b.x) : (a.y > b.y);
}
bool comp2(const Point &a, const Point &b){
	return (a.x == b.x) ? (a.y < b.y) : (a.x < b.x);
}
int main() {
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d %d", &r[i].x, &r[i].y);
	for(int i = 0; i < N; i++) scanf("%d %d", &b[i].x, &b[i].y);
	sort(r, r + N, comp1);
	sort(b, b + N, comp2);
	fill(used, used + N, false);
	int ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(!used[j] && (r[j].x < b[i].x) && (r[j].y < b[i].y)){
				used[j] = true;
				ans++;
				break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    long long A;
    string B;
    cin >> A >> B;
    //cout << A << " " << B << endl;
    long long C = (B[0] - '0') * 100 + (B[2] - '0') * 10 + (B[3] - '0');
    cout << A * C / 100LL << endl;
    return 0;
}

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

bool solve(int N, vector<ll> k, vector<ll> n) {
    if ( k.size() == 1 ) {
        if ( k[0] == 0 ) {
            return true;
        }
    } else if ( k.size() == 2 ) {
        if ( N % 3 != 0 ) return false;
        if ( k[0] == 0 ) {
            if ( 2 * n[0] == n[1] ) {
                return true;
            }
        } else if ( k[1] == 0 ) {
            if ( 2 * n[1] == n[0] ) {
                return true;
            }
        }
    } else if ( k.size() == 3 ) {
        if ( N % 3 != 0 ) return false;
        if ( (k[0] ^ k[1]) == k[2] && n[0] == n[1] && n[1] == n[2] ) {
            return true;
        }
    }
    return false;
}


int main() {
    ll N;
    cin >> N;
    ll a;
    map<ll, int> c;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        c[a]++;
    }
    vector<ll> k, n;
    for ( auto p : c ) {
        k.push_back(p.first);
        n.push_back(p.second);
    }

    string ans = solve(N, k,n) ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7580
read*,i,j,k
if(j<i)then
n=i;i=j;j=n
endif
if(k<j)then
n=j;j=k;k=n
endif
if(j<i)then
n=i;i=j;j=n
endif
n=(k-i)/2+(k-j)/2;i=i+2*((k-i)/2);j=j+2*((k-j)/2);k=i+j-k-k
if(k==-1)then
n=n+2
else if(k==-2)then
n=n+1
endif
print"(i0)",n
end

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

int main(){
    int K; cin >> K;
    int right;
    long long j=0;
    vector<long long> l;
    for(int i=1; i<10; i++){
        l.push_back(i);
    }
    while(j != K-1){
        right = l[j]%10;
        if(right != 0) l.push_back(l[j]*10+right-1);
        l.push_back(l[j]*10+right);
        if(right != 9) l.push_back(l[j]*10+right+1);
        j++;
    }
    cout << l[j] << endl;
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  
  int sumA = 0, sumB = 0;
  
  for (int i = 0; i < N; i +=2){
    sumA += v.at(i);
  }
  
  for (int i = 1; i < N; i += 2){
    sumB += v.at(i);
  }
  
  cout << sumA - sumB << endl;
  
}
      
  

Measured memory_bytes: 256
n,m = map(int,input().split())
input_lines = [[int(j) for j in input().split()]for i in range(m)]

start=1
end=n
for line in input_lines:
    if line[0]>start:
        start=line[0]
    if line[1]<end:
        end=line[1]
print(len([i for i in range(start,end+1)]))

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

int main(){
    int a,b,c,d = 0;
    cin >> a >> b >> c;

    for(int i = a; i <= b; i++){
        if(c % i == 0) d += 1;
    }
    cout << d << endl;
    return 0;
}

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

void swap(int a, int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main(void) {
	int l,r,d;
	cin >>l>>r>>d;

	int ans = 0;

	for (int i = l; i <= r ;i++) {
		if (i%d==0) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3592
package main

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

func main() {
	a := ReadInts(3)
	for i := 0; i < 3; i++ {
		if a[i]%2 == 0 {
			fmt.Println(0)
			return
		}
	}
	sort.Ints(a)
	fmt.Println(a[0] * a[1])
}

var reader = bufio.NewReader(os.Stdin)

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


Measured memory_bytes: 1840
#include <stdio.h>

int main(void)
{
    int month[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
    int m, d;
    int days;
    
    while (1){
        scanf("%d%d", &m, &d);
        if (m == 0 || d == 0)   break;
        days = 0;
        while (m-- > 0){
            days += month[m];
        }

        days += d;
        days %= 7;
        //printf("%d\n", days);

        switch (days){
        case 1:
            printf("Thursday\n");
            break;
        case 2:
            printf("Friday\n");
            break;
        case 3:
            printf("Saturday\n");
            break;
        case 4:
            printf("Sunday\n");
            break;
        case 5:
            printf("Monday\n");
            break;
        case 6:
            printf("Tuesday\n");
            break;
        case 0:
            printf("Wednesday\n");
            break;
        default:
            break;
        }
    }

    return (0);
}


Measured memory_bytes: 2032
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  for(int i=0; i<num; i++){ cout << v[i].first << v[i].second; if(i!=num-1) cout << " ";}
  cout << endl;
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
  using P = pair<int, int>;
  stack<int> st_left;// '\'の位置
  stack<P> st_lrs;//left(\), right(/), square(水平方向の水たまり)

  string input;
  cin >> input;
  for(int i=0; i<(int)input.size(); i++){
    if(input[i]=='\\') st_left.push(i);
    // if(input[i]=='\\') cout << " i: " << i << " \\ " << endl;
    else if(input[i]=='/'){
      if(st_left.empty()) continue;
      int left = st_left.top();
      st_left.pop();
      int right = i;
      int square = right - left;
      st_lrs.push(P(left, right));
    }
  }

  vector<int> puddles;//水たまり
  int sum_size = 0;
  while(!st_lrs.empty()){
    int left = st_lrs.top().first;
    int right = st_lrs.top().second;
    st_lrs.pop();
    int size = right - left;

    while(!st_lrs.empty()){//結合できる水たまりは結合する
      int left2 = st_lrs.top().first;
      int right2 = st_lrs.top().second;
      if(left < left2  &&  right2 < right){//水たまりを包括していたら
        size += right2 - left2;        
        st_lrs.pop();
      }
      else break;
    }
    puddles.push_back(size);
    sum_size += size;
  }

  // cout << sum_size << endl;
  // cout << (int)puddles.size(); if(sum_size!=0)cout<<" ";
  // print_vec(puddles, true);

  if(sum_size==0){//0のときはsizeの後に空白なしで改行入れる
    cout << sum_size << endl;
    cout << (int)puddles.size() << endl;
  }
  else{
    cout << sum_size << endl;
    cout << (int)puddles.size() << " ";
    print_vec(puddles, true);
  }
  return 0;
}




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

ll k;

ll pow10(int x) {
    ll ret = 1;
    rep(i,x) ret *= 10;
    return ret;
}

int main() {
    cin >> k;
    ll now = 1;
    ll cnt = 1;
    int r = 0;
    while (k > 0) {
        cout << now << endl;
        double best = 1000000000000000000000.0;
        ll nxt;
        rep(i,20) {
            ll p = pow10(i);
            ll tmp = now+p;
            ll _tmp = tmp;
            ll cnt2 = 0;
            while (_tmp) {
                cnt2 += _tmp%10;
                _tmp /= 10;
            }
            if (best > tmp/(double)cnt2) {
                best = tmp/(double)cnt2;
                cnt = cnt2;
                nxt = tmp;
            }
        }
        now = nxt;
        k--;
    }
}



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

int main() {
  int N;
  cin>>N;
  vector<int64_t> vec(N);
  for(int i=0; i<N;i++){
    int64_t A;
    cin>>A;
    vec.at(i) =A;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int64_t a=vec.at(0);
  if(N%2==0){
    for(int i=1; i<=(N-2)/2; i++){
      a+=vec.at(i);
      a+=vec.at(i);
    }
  }
  else{
    int i=1;
    for(; i<=(N-2)/2; i++){
      a+=vec.at(i);
      a+=vec.at(i);
    }
    a+=vec.at(i);
  }
  cout<<a<<endl;
}



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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
    int N, d[100005], i;
    scanf("%d", &N);
    for (i=0; i<N; i++) {
        scanf("%d", &d[i]);
    }
    qsort(d, N, sizeof(int), compare_int);
    printf("%d", d[N/2]-d[N/2-1]);
    
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int arith_sum1(long long int,long long int,long long int);
long long int arith_sum2(long long int,long long int,long long int);
long long int series_sum(long long int);

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    ll x,sum=0;
    vec_input(a);
    rep(i,m){
        cin>>x;
        sum+=x;
        b[i]=sum;
    }
    sum=0;
    ll ans=(ll)(upper_bound(all(b),k)-b.begin());
    ll hikaku;
    rep(i,n){
        sum+=a[i];
        if(sum<=k){
            hikaku=i+1+(ll)(upper_bound(all(b),k-sum)-b.begin());
            ans=max(ans,hikaku);
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int N, M, a, b;
  cin >> N >> M;
  vector<int> roadc(N);
  
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    
    roadc.at(a - 1) += 1;
    roadc.at(b - 1) += 1;
  }
  
  for (int i = 0; i < roadc.size(); i++) cout << roadc.at(i) << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	other := 0
	flags := make([]bool, 8)
	for i := 0; i < n; i++ {
		var t int
		fmt.Scan(&t)
		if t >= 3200 {
			other++
		} else {
			flags[t/400] = true
		}
	}
	min := 0
	for i := 0; i < 8; i++ {
		if flags[i] {
			min++
		}
	}
	fmt.Println(max(1, min), min+other)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ll n,m;cin>>n>>m;
    vector<ll> d;
    for(ll i=1;i*i<=m;i++){
        if(m%i==0){d.push_back(i);d.push_back(m/i);}
    }
    sort(d.begin(),d.end());
    ll ans=0;
    for(int i=0;i<d.size();i++){
        ll yay=d[i];
        if(yay*n<=m)ans=yay;
    }
    cout<<ans;
    
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        long x = sc.nextLong();
        
        long[] len = new long[51];
        len[0] = 1L;
        long[] ps = new long[51];
        ps[0] = 1L;
        
        for(int i=0; i<50; i++){
            len[i+1] = len[i]*2+3;
            ps[i+1] = ps[i]*2+1;
        }
        
        long ans = 0L;
        
        for(int i=n; i>=0; i--){
            if(x>=len[i]){
                ans += ps[i];
                x -= len[i];
                if(x > 0){
                    x--;
                    ans++;
                    i++;
                }
            }else{
                x--;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int main(){
	int N,K,x,y;
	cin>>N>>K;
	for(int i=0;i<K;i++){
		cin>>x>>y;
		  x=min(x,N-x+1);
       		  y=min(y,N-y+1);
      		  x=min(x,y);
		  if(x%3==0){
			cout<<3<<endl;
		}
		  else{
			  cout<<x%3<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#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 n; string s; cin >> n >> s;
  int a = 0, b = 0;
  rep(i, n) if (s[i] == 'R') ++a;
  int ans = max(a,b);
  rep(i, n){
    if (s[i] == 'R') --a;
    else ++b;
    int now = max(a,b);
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
int main(){
	while(1){
		int hit=0,blow=0;
		std::vector<int> a(4);
		std::vector<int> b(4);
		for(int i=0;i<4;i++)std::cin>>a[i];
		for(int i=0;i<4;i++)std::cin>>b[i];
		if(std::cin.eof())break;
		for(int i=0;i<4;i++){
			if(a[i]==b[i])hit++;
			else{
				for(int j=0;j<4;j++){
					if(a[i]==b[j])blow++;
				}
			}
		}
		std::cout<<hit<<" "<<blow<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include<cstdio>
long long int a,b,x;
int main() {
    scanf("%lld",&x);
    for (a=-1000; a<=1000; ++a) {
        for (b=-1000; b<=1000; ++b) {
            if (a*a*a*a*a-b*b*b*b*b == x) {
                printf("%lld %lld",a,b);
                return 0; 
            }
        }
    }
}

Measured memory_bytes: 1728
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long

using namespace std;

int x;
LL ans=0;

int main() {
	cin>>x;
	ans+=1000*(x/500);
	x%=500;
	ans+=5*(x/5);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 384
# encoding:utf-8
import sys
 
def main():
	n = int(input())
	vers = [list(map(int, input().split())) for _ in range(n - 1)]
	q, k = list(map(int, input().split()))
	queries = [list(map(int, input().split())) for _ in range(q)]
 
	#n = 10 ** 5
	#vers = [[i + 1, i + 2, 10 ** 9] for i in range(n - 1)]
 
	new_vers = mapping(n, vers)
	dist = calcMinDist(n, new_vers, k, queries)
	calcQueries(dist, queries, k)
	
def mapping(n, vers):
	new_vers = {i :[] for i in range(n)}
	for ver in vers:
		new_vers[ver[0] - 1].append((ver[1], ver[2]))
		new_vers[ver[1] - 1].append((ver[0], ver[2]))
	return new_vers
 
def calcMinDist(n, new_vers, k, queries):
	dist = [- 1 for _ in range(n)]
	flag = [False for _ in range(n)]
	dist[k - 1] = 0
	flag[k - 1] = True
	dfs(new_vers, dist, flag, k)
	return dist
 
def dfs(new_vers, dist, flag, frm):
	flag[frm - 1] = True
	vs = new_vers[frm - 1]
	for v in vs:
		if flag[v[0] - 1] == False:
			dist[v[0] - 1] = dist[frm - 1] + v[1]
			new_ver, dist, flag, _ = dfs(new_vers, dist, flag, v[0])
 
	return [new_vers, dist, flag, frm]
 
def calcQuery(dist, query, k):
	print(dist[query[0] - 1] + dist[query[1] - 1])
 
def calcQueries(dist, queries, k):
	for query in queries:
		calcQuery(dist, query, k)
 
if __name__ == '__main__':
	sys.setrecursionlimit(1000000)
	main()

Measured memory_bytes: 181772
import java.util.Scanner

object Main extends App { 
  val sc = new Scanner(System.in)
  val N, M = sc.nextInt()
  val coins = (for (i <- 1 to M) yield sc.nextInt()).sorted.toArray
  
  class DP(n:Int, m:Int, coins:Array[Int]) {
    val inf = Int.MaxValue >> 1
    val memo = Array.fill(M)(Array.fill(n+1)(inf))
    for (row <- memo) row(0) = 0
    for (i <- 0 until n+1) memo(0)(i) = i

    def solver():Int = {
      for (i <- 1 until m; j <- 1 until n+1) {
        val c0 = memo(i-1)(j)
        val c1 = if (j < coins(i)) inf else memo(i)(j-coins(i))+1
        memo(i)(j) = if (c0 < c1) c0 else c1
      }
      memo(m-1)(n)
    }
  }

  val dp = new DP(N, M, coins)
  println(dp.solver())

}


Measured memory_bytes: 65228
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e8;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

typedef struct Data {
  int tm, src, dst;
  bool operator<(const Data &o) const { return tm < o.tm; }
} data;

signed main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 0 && m == 0) break;
    set<int> virus;
    virus.insert(1);
    vector<data> d(m);
    rep(i, m) cin >> d[i].tm >> d[i].src >> d[i].dst;
    sort(all(d));
    rep(i, m) {
      if (virus.count(d[i].src)) {
        virus.insert(d[i].dst);
      }
    }
    cout << virus.size() << endl;
  }

  return 0;
}



Measured memory_bytes: 4308
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
using namespace std;
typedef long long int llint;
const llint big=((llint)1<<(llint)30);
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pub push_back
#define res resize
//JOI 2017 semiexp O(NlogN)
//3:25~4:40
//Tmin 
int main(void){
	string a,b;
	int i=0;
	cin>>a>>b;
	for(i=0;i<b.size();i++){
		cout<<a[i];
		cout<<b[i];
	}
	if(a.size()>b.size()){
		cout<<a.back()<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    long long n;
    cin >> n;
    vector<int> nums;
    while(n--)
    {
        int x;
        cin >> x;
        nums.push_back(x);
    }
    long long ans=0;
    for(int i=0; i < nums.size(); i++)
    {
        for(int j= i+1; j< nums.size(); j++)
        {
            ans += nums[i]*nums[j];
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
using namespace std;

const int N = 3e3+10;
string s,t;
vector <char> V;

int DP[N][N];

int main(){
  boost;
  cin >> s >> t;
  int a = s.size();
  int b = t.size();
  for(int i=1; i<=a; i++){
    for(int j=1; j<=b; j++){
      if(s[i-1] == t[j-1])DP[i][j] = DP[i-1][j-1] + 1;
      else DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
    }
  }
  int x = a;
  int y = b;
  while(x && y){
    if(s[x-1] == t[y-1]){
      V.pb(s[x-1]);
      x--, y--;
    }
    else{
      if(DP[x-1][y]>DP[x][y-1])x--;
      else y--;
    }
  }
  for(int i = V.size()-1; i>=0; i--)cout << V[i];
  cout << "\n";

  return 0;
}


Measured memory_bytes: 35584