akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int q;
  cin >> q;
  vector<int> v;
  for(int i=0; i<q; i++) {
      int a;
      cin >> a;
      if(a==0) {
        int b;
        cin >> b;
        v.push_back(b);
      }
      else if(a==1) {
          int b;
          cin >> b;
          cout << v[b] << endl;
      }
      else {
          v.pop_back();
      }
  }
}


Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#include<string.h>
#define inf 1000000000000000000
#define maxn 1000001
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<" "<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
void solve(int countu){
	int n,w;
	cin>>n>>w;
	ll dp[n][w+1];
	memset(dp,0,sizeof(dp));
	vector<pll> v;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		v.pb({a,b});
	}
	dp[0][v[0].fi]=v[0].se;
	repeat(i,1,n){
		rep(j,w+1){
			if(j-v[i].fi>=0)
				dp[i][j]=max(dp[i][j],dp[i-1][j-v[i].fi]+v[i].se);
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
		}
	}
	ll maxx=0;
	rep(i,n)
		rep(j,w+1)
			maxx=max(maxx,dp[i][j]);
	cout1(maxx);
}
int main(){
    int t=1;
	//cin>>t;
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}

Measured memory_bytes: 78336
module Weighted01DirectedGraph
  (* 頂点を添字，経路長を要素とした配列の実装 *)
  (Array : sig
    type t
    type key
    type elt = int (* 重みのない（=全ての重さが0か1な）グラフなので経路長は非負整数 *)
    val get : t -> key -> elt
    val set : t -> key -> elt -> unit
  end)
: sig
  type vertex = Array.key

  val shortest_path :
    (* 全ての頂点についての経路長が無限大で初期化された配列 *)
    Array.t ->
    (* 最短経路を求めたいグラフの，ある頂点から伸びる辺に対してのイテレータ
       重みが0の辺に対してはf0を，1の辺に対してはf1を用いる *)
    (vertex -> f0:(vertex -> unit) -> f1:(vertex -> unit) -> unit) ->
    (* 始点 *)
    vertex ->
    (* 終点を受け取って，始点からの最短距離を返す関数
       始点から辿り着けない場合，無限大を返す
       この関数を覚えておけば，呼び出しごとの途中までの計算結果がシェアされる *)
    (vertex -> int)
end =
struct
  type vertex = Array.key

  let shortest_path d es s =
    (* 始点への経路長を0にする *)
    Array.set d s 0;
    let w = ref 1 in
    let q = ref [s] in
    let rec bfs t =
      match !q with
      (* もう既に全ての頂点までの経路が分かっているので返す *)
      | [] -> Array.get d t
      | us ->
          match Array.get d t with
          (* 既に終点までの距離が分かっているので返す *)
          | x when x < !w -> x
          (* 終点までの距離が分かっていないので，BFSを続行 *)
          | _ ->
              q := [];
              List.iter dfs us;
              incr w;
              bfs t
    and dfs u =
      es u
        ~f0:(fun v ->
          if !w <= Array.get d v then
            (Array.set d v (!w - 1); dfs v))
        ~f1:(fun v ->
          if !w < Array.get d v then
            (Array.set d v !w; q := v :: !q)) in
    bfs
end

module G = Weighted01DirectedGraph (struct
  type t = (int, Bigarray.int_elt, Bigarray.c_layout) Bigarray.Array1.t
  type elt = int
  type key = int
  let get = Bigarray.Array1.get
  let set = Bigarray.Array1.set
end)

let () = Scanf.scanf "%d" @@ fun k ->
  Printf.printf "%d\n" @@
  succ @@
  G.shortest_path
    (let d = Bigarray.Array1.create Bigarray.int Bigarray.c_layout k in Bigarray.Array1.fill d max_int; d)
    (fun i ~f0 ~f1 -> f0 (i * 10 mod k); f1 ((i + 1) mod k)) 1 0


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

int n, k;

int tab[1000007];
vector <int> graf[1000007];

int wyn;

int dfs(int v)
{
    int najw=1;
    for (int i=0; i<graf[v].size(); i++)
    {
        najw=max(najw, dfs(graf[v][i])+1);
    }
    if (najw==k)
    {
        najw=0;
        if (tab[v]!=1)
            wyn++;
    }
    return najw;
}

int main()
{
    scanf("%d%d", &n, &k);
    scanf("%d", &tab[1]);
    if (tab[1]!=1)
        wyn++;
    tab[1]=1;
    for (int i=2; i<=n; i++)
    {
        scanf("%d", &tab[i]);
        graf[tab[i]].push_back(i);
    }
    dfs(1);
    printf("%d\n", wyn);
    return 0;
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B,C;
    cin >> A >> B >> C;
    int ans=min(C,B/A);
    cout << ans << endl;



}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    work_list = [tuple(map(int, input().split())) for i in range(n)]

    # dp = [[0] * 3 for i in range(n + 1)]
    # for i, work in enumerate(work_list):
    #     for i_now in range(3):
    #         for i_pre in range(3):
    #             if i_now == i_pre:
    #                 continue
    #
    #             dp[i + 1][i_now] = max(dp[i + 1][i_now], dp[i][i_pre] + work[i_now])
    dp_pre = [0] * 3
    dp_now = [0] * 3
    for i, work in enumerate(work_list):
        for i_now in range(3):
            for i_pre in range(3):
                if i_now == i_pre:
                    continue

                dp_now[i_now] = max(dp_now[i_now], dp_pre[i_pre] + work[i_now])

        dp_pre[0] = dp_now[0]
        dp_pre[1] = dp_now[1]
        dp_pre[2] = dp_now[2]

    print(max(dp_now))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20540
#include <stdio.h>

int main(){
	char input,input2;
	scanf("%c %c", &input, &input2);getchar();
	if(input=='H' && input2=='H'){
		printf("H\n");
	} else if(input=='H' && input2=='D'){
		printf("D\n");
	} else if(input=='D' && input2=='H'){
		printf("D\n");
	} else {
		printf("H\n");
	}
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int to, cost;
	edge (int to, int cost){
		this->to = to; this->cost = cost;
	}
};
 
int V,E;
typedef vector<P> edges;
vector<edges> G;

int n;
int visit[100005];//

void go(int v) {
	priority_queue<P> q;//
	q.push(P(0,0));
	ll ans = 0;
	while (q.size()) {
		P u = q.top(); q.pop();
		if (visit[u.second] == 1)
			continue;
		visit[u.second] = 1;
		ans += -u.first;
		for (auto w : G[u.second]) {
			if (visit[w.second] == 1)
				continue;
			q.push(w);
		}
	}
	cout << ans << endl;
}



int main(){
	scanf("%d ", &n);
	G.resize(n);
	vector<P> p1, p2;
	int a, b;
	rep(i, n) {
		scanf("%d %d ", &a, &b); a--; b--;
		p1.push_back(P(a, i));
		p2.push_back(P(b, i));
	}
	sort(p1.begin(), p1.end());
	sort(p2.begin(), p2.end());
	rep(i, n - 1) {
		G[p1[i].second].push_back(P(p1[i].first-p1[i+1].first, p1[i+1].second));
		G[p1[i+1].second].push_back(P(p1[i].first - p1[i + 1].first, p1[i].second));
		G[p2[i].second].push_back(P(p2[i].first - p2[i+1].first, p2[i+1].second));
		G[p2[i+1].second].push_back(P(p2[i].first - p2[i + 1].first, p2[i].second));
	}
	go(0);

	return 0;
}


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

// ある整数Nを(i*j)で表せた時、i+j-2の最小値?
// sqrt(N)まで見ればよい! -> ループで書いているが、sqrt(N)でとめるので
// O(N)より小さい計算量! 最小値は保持する方法で求める。
// いきなり、数学的に最適解を求めに行くのではない!! 

int main(){
    long long N;
    cin >> N;
    long long ans = N-1; // 解は最悪でも(1,N)には存在するつまり、最大N-1
    int i = 1;
    while (pow(i,2) <= N){
        long long M = N/i;
        if (i*M == N){
            ans = min(ans, M + i - 2);
        }
        i += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
int main(){
    int a,b;
    int cont=0;
    scanf("%d%d",&a,&b);
    for(int i=a;i<=b;i++){
        int c[5];
        c[0]=i/10000;
        c[1]=(i%10000)/1000;
        c[2]=((i%10000)%1000)/100;
        c[3]=(((i%10000)%1000)%100)/10;
        c[4]=(((i%10000)%1000)%100)%10;
        if(c[0]==c[4] && c[1]==c[3])
            cont+=1;
    }
    printf("%d\n",cont);
    return 0;
}


Measured memory_bytes: 128
L, R = map(int, input().split())
# もう少し全探索を疑うことが大切。
if R - L >= 2019:
    print(0)
else:
    # なぜprint(L*(L+1)%2019)が不可なのかというと、2019が2019=3*673の合成数であるから。
    # だから取りうる最小と最小+1の積の2019MODが最小になるわけではない。
    # 加えて、かけるものどうしの余剰が最小であれば、その積の余剰も最小になるという前提が間違っている。
    ans = float("inf")
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%2019)
    print(ans)

Measured memory_bytes: 65176
import copy
N=int(input())

t=[0 for i in range(13)]
T=[0 for i in range(25)]
T[0]=1
T[24]=1

D=list(map(int,input().split()))

for i in range(N):
    t[D[i]]+=1
    
#print(t)
if t[0]>=1 or t[12]>=2 or max(t)>=3:
    print(0)
else:
    for i in range(len(t)):
        if t[i]==2:
            T[i]=1
            T[24-i]=1
    T[12]=t[12]
    #print(T)
    A=[[]for i in range(11)]
    for i in range(1,12):
        if t[i]==1:
            A[i-1]=[i,24-i]
    for i in range(11):
        if A[i]==[]:
            A[i]=[0,0]
    #print(A)
    
    MAX=0
    for i in range(2**11+1):
        S=copy.deepcopy(T)
        I=i
        for j in range(11):
            if (I//(2**(10-j)))==1:
                S[A[j][1]]=1
            else:
                S[A[j][0]]=1
            I%=(2**(10-j))
        L=100
        P=0
        for k in range(1,25):
            if S[k]==1:
                if L>(k-P):
                    L=(k-P)
                P=k
        if L>MAX:
            MAX=L
            #print(L)
            #print(S)
    print(MAX)

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

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> d(n);
	for(int i = 0; i<n;i++){
		cin>>d[i];
		}
	sort(d.begin(),d.end());
	cout<<d[n/2] - d[n/2 -1];
	
	return 0;
	}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
long double ans,x[15];
string u[15];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>u[i];
		if(u[i]=="BTC") x[i]*=380000.0;
	}
	for(int i=1;i<=n;i++)
		ans+=x[i];
	cout<<setprecision(8)<<ans<<endl;
	return 0;
}


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

using namespace std;

void SelectionSort(int A[], int N, int &cnt){
  for(int i = 0; i < N-1; i++){
    int minj = i;
    for(int j = i; j < N; j++){
      if(A[j] < A[minj]){
	      minj = j;
      }
    }
    if(i != minj){
      swap(A[i], A[minj]);
      cnt++;
    }
  }
}

int main(){
  int A[100], N, cnt = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  SelectionSort(A, N, cnt);

  for(int i = 0; i < N; i++){
    if(i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl << cnt << endl;
  
  return 0;
}



Measured memory_bytes: 3108
N, K = gets.chomp.split(" ").map(&:to_i)
X = gets.chomp.split(" ").map(&:to_i)

Xp = X.select{|x| x >= 0}
Xm = X.select{|x| x < 0}.reverse.map{|x| -x}
ans = 10 ** 9
ans = Xp[K-1] if Xp.size >= K
(1...K).each{|i|
  next if Xp.size < i
  next if Xm.size < K - i
  wk = Xp[i-1] + 2 * Xm[K-i-1]
  ans = wk if ans > wk
}
(1...K).each{|i|
  next if Xm.size < i
  next if Xp.size < K - i
  wk = Xm[i-1] + 2 * Xp[K-i-1]
  ans = wk if ans > wk
}
ans = Xm[K-1] if Xm.size >= K && ans > Xm[K-1]

puts ans


Measured memory_bytes: 11796
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    map<int,int> ma,mb;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        ma[temp]++;
    }
    int m;
    cin>>m;
    rep(i,m){
        int temp;
        cin >> temp;
        mb[temp]++;
    }
    for(auto x:mb){
        if(ma[x.first]<x.second)return NO,0;
    }
    YES;
}


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

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#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 SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}

bool IsPrime(LL N){
  if(N >= 1) return false;
  for(int i = 2; i*i <= N; ++i){
    if(N%i == 0) return false;
  }
  return true;
}

bool ComPaiSec(PII a, PII b){
  if(a.SE != b.SE){
    return a.SE < b.SE;
  }else{
    return a.FI < b.FI;
  }
}

int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  VI a(n);
  REP(i,n){
    cin >> a.at(i);
  }
  
  SORT(a);
  
  int k = a.at(n-1), t=INF, r=0;
  
  REP(i,n-1){
    if(abs((k+1)/2 -a.at(i)) < t){
      r = a.at(i);
      t = abs((k+1)/2 -r);
    }
  }
  
  cout << k << " " << r << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>


int max (int x,int y)
{
    if(x>y) return x;
    else return y;
}
int main (void)
{
    int a,b,ans;
    scanf("%d %d",&a,&b);
    if(a == b)  printf("%d",a * 2);
    else    printf("%d",max(a,b) * 2 - 1);
}

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

int main() {
  int N;
  cin >> N;
  
  int a = 0;
  
  for(int i; i<N; i++){
    int l,r;
    cin >> l >> r;
    a = a + r - l + 1;
  }
  
  cout << a << endl;
}

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

typedef long long int ll;

#define MAX 1005
#define MAX2 1000005

vector<int> primes;
bool isprime[MAX];

int max_freq = 0;

int freq[MAX2];

void sieve(int n){
	memset(isprime, true, sizeof(isprime));
	isprime[0] = isprime[1] = false;
	int p;
	for( p=2; p*p<=n; p++){
		if(isprime[p]){
			primes.push_back(p);
			for(int i=p*2; i<=n;i+=p){
				isprime[i] = false;
			}
		}
	}
	for(int i=p; i<=n;i++){
		if(isprime[i]) primes.push_back(i);
	}
}

set<int> facteurs(int n){
	set<int> ret;
	for(auto x : primes){
		if(n%x==0) {
			ret.insert(x);
			while(n%x==0) n/=x;
		}
	}
	if(n>1) ret.insert(n);
	return ret;
}

int main(){
	sieve(MAX);
	//~ printf("sieve termine\n");
	for(int i=0;i<MAX2;i++){
		freq[i]= 0;
	}
	int n; scanf("%d",&n);
	int tab[n];
	
	int ans = 0;
	
	for(int i=0;i<n;i++){
		scanf("%d",&tab[i]);
		set<int> d = facteurs(tab[i]);
		//~ printf("facteurs[%d]:",tab[i]);
		for(auto x : d){
			freq[x]++;
			//~ printf("%d ",x);
			ans = max(ans, freq[x]);
		}
	}
	
	//~ printf("max = %d\n",ans);
	if (ans == n) printf("not coprime");
	else if(ans>1) printf("setwise coprime");
	else printf("pairwise coprime");
}


Measured memory_bytes: 11528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, a, b;
	cin>>n>>a>>b;
	int mode = 1;
	while (a < b-1)
	{
		if (mode == 1)
			a++;
		else
			b--;
		mode *= -1;
	}

	if (mode == 1)
		cout<<"Borys\n";
	else
		cout<<"Alice\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int X, Y;
  cin >> X >> Y;
  for (int crane = 0; crane <= X; crane++) {
    int turtle = X - crane;
    if ((crane*2 + turtle*4) == Y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int A, B, C;
    cin >> A >> B >>C;
    

    string ans="No";

    if((A+B)==C) ans="Yes";
    if((A+C)==B) ans="Yes";
    if((C+B)==A) ans="Yes";
    
    cout << ans << endl;



   return 0;
}

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



int main() {
  int x, y;
  cin >> x >> y;
  bool can = false;
  rep(i, x + 1){
    if(i * 2 + (x - i) * 4 == y){
      can = true;
      break;
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define maxn 1000005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
int n, l;
int t[maxn];
const db ppi = acos(-1.0);
int main() {
	cin >> n >> l;
	for (int i = 0; i < n; i++)
		cin >> t[i];
	sort(t, t + n);
	db ax = 0, ay = 0;
	ll fn = 1ll * n * (n - 1) * (n - 2) / 6;
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++) {
			int ed = 2 * (j - i - 1) - (n - 2);
			db nr = 1.0 * ppi * (t[i] + t[j]) / l;
			ax += cos(nr) * ed, ay += sin(nr) * ed;
		}
	ax /= fn, ay /= fn;
	printf("%.15lf %.15lf\n", -ax, -ay);
	return 0;
}


Measured memory_bytes: 640
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		private static long max = long.MaxValue - (long)1e12 * (16 + 1);

		static void Main(string[] args)
		{
			var firstLine = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
			var h = firstLine[0];
			var w = firstLine[1];

			var picture = new List<string>();

			var sharp = "";
			for(var i = 0; i < w + 2; i++)
			{
				sharp += "#";
			}

			picture.Add(sharp);

			for(var i = 0; i < h; i++)
			{
				picture.Add("#" + ReadLine() + "#");
			}

			picture.Add(sharp);

			picture.ForEach(s => WriteLine(s));
		}
	}
}


Measured memory_bytes: 13268
#include <stdio.h>
 
//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0, c = getchar_unlocked();
    do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
    return n;
}
 
#define MAX_N 102
 
int a[MAX_N];
 
void dump(int n)
{
    int i;
 
    printf("%d", a[0]);
    for (i = 1; i < n; i++) printf(" %d", a[i]);
    putchar('\n');
}
 
void insertion_sort(int n)
{
    int i, j, key;
 
    dump(n);
    for (i = 1; i < n; i++) {
        key = a[i];
        j = i-1;
        while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
        a[j+1] = key;
        dump(n);
    }
}
 
int main()
{
    int N, i;
 
    N = in();
    for (i = 0; i < N; i++) a[i] = in();
    insertion_sort(N);
    return 0;
}


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

int main() {
    int N,K;
    cin >> N >> K;
    if(K > N * (N - 1) / 2 - (N - 1)) {
        cout << -1 << endl;
    }
    else {
        vector<P> ret;
        for(int i = 0;i < N - 1;i++) {
            for(int j = i + 1;j < N;j++) {
                ret.push_back(P(i,j));
            }
        }
        cout << N * (N - 1) / 2 - K << endl;
        vector<bool> ret2(N * (N - 1) / 2,true);
        int cnt = 0;
        int cnt3 = 0;
        for(int i = 0;i < N;i++) {
            bool cnt2 = true;
            for(int j = 0;j < N - 1 - (i + 1);j++) {
                if(cnt3 == K) {
                    cnt2 = false;
                    break;
                }
                ret2.at(cnt) = false;
                cnt++;
                cnt3++;
            }
            cnt++;
            if(cnt2 == false) {
                break;
            }
        }
        for(int i = 0;i < N * (N - 1) / 2;i++) {
            if(ret2.at(i) == true) {
                cout << ret.at(i).first + 1 << " " << ret.at(i).second + 1 << endl;
            }
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
void factorization(long long n,map<long long ,long long>& mp){
    for(long long i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n /= i;
        }
     }
     if(!(n == 1)) mp[n]++;
}
int main() {
    ll n;
    cin >> n;
    map<ll, ll> mp;
    for (ll i = 1; i <= n; i++) factorization(i, mp);
    ll over4 = 0;
    ll over2 = 0;
    ll over14 = 0;
    ll over24 = 0;
    ll over74 = 0;
    for (auto i : mp) {
        if (i.second >= 4) over4++;
    }
    for(auto i:mp){
        if (2 <= i.second && i.second <= 3) over2++;
    }
    for(auto i:mp){
        if (i.second >= 14) over14++;
    }
    for(auto i:mp){
        if (i.second >= 24) over24++;
    }
    for(auto i:mp){
        if (i.second >= 74) over74++;
    }
    ll ans = max(0LL,over4 * (over4 - 1) * (over4 + over2 - 2)/2);
    ans += max(0LL,over24 * (over4 + over2 - 1));
    ans += max(0LL,over14 * (over4 - 1));
    ans += over74;
    cout << ans << endl;
}


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

int main(int argc, char *argv[]){
    int a,b,r;
	while(cin>>a>>b){
		int a0=a,b0=b;
		r=a%b;
		while(r!=0){
			a=b;
			b=r;
			r=a%b;
		}
	    
		cout <<b<<" "<< a0*(b0/b) << endl;
	}
    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;

int main()
{
    int64_t n, k;
    cin >> n >> k;
    vector<pair<int64_t, int64_t>> vs(n);
    for (auto& v : vs)
    {
        cin >> v.second >> v.first;
        v.second--;
    }
    sort(vs.begin(), vs.end(), greater<>());

    vector<int64_t> count(n, 0);
    int64_t out_count = 0;
    int64_t sum = 0;
    int64_t typesum = 0;

    stack<pair<int64_t, int64_t>> s;

    int64_t max_sum = 0;

    for (auto v : vs)
    {
        int64_t d, t;
        tie(d, t) = v;
        if (out_count + s.size() < k)
        {
            if (count[t] == 0)
            {
                typesum++;
            }
            count[t]++;
            sum += d;
            s.push(v);
        }
        else if (count[t] == 0)
        {
            while (!s.empty())
            {
                auto nv = s.top();
                s.pop();
                int64_t nd, nt;
                tie(nd, nt) = nv;

                if (count[nt] == 1)
                {
                    out_count++;
                }
                else
                {
                    sum -= nd;
                    typesum++;
                    count[nt]--;

                    count[t]++;
                    sum += d;
                    s.push(v);
                    break;
                }
            }
            if (s.empty())
            {
                break;
            }
        }
        max_sum = max(max_sum, sum + typesum * typesum);
    }
    cout << max_sum << endl;
}

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

class dsu {
  int N;
  vector<int> PS;
public:
  dsu() : N(0) {}
  dsu(int n) : N(n), PS(n, -1) {}
  int merge(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    int x = leader(a), y = leader(b);
    if (x == y) return x;
    if (-PS.at(x) < -PS.at(y)) swap(x, y);
    PS.at(x) += PS.at(y);
    PS.at(y) = x;
    return x;
  }
  bool same(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    return leader(a) == leader(b);
  }
  int leader(int a) {
    assert(0 <= a && a < N);
    if (PS.at(a) < 0) return a;
    return PS.at(a) = leader(PS.at(a));
  }
  int size(int a) {
    assert(0 <= a && a < N);
    return -PS.at(leader(a));
  }
  vector<vector<int>> groups() {
    vector<int> B(N), S(N);
    for (int i = 0; i < N; i++) {
      B.at(i) = leader(i);
      S.at(B.at(i))++;
    }
    vector<vector<int>> ret(N);
    for (int i = 0; i < N; i++) {
      ret.at(i).reserve(S.at(i));
    }
    for (int i = 0; i < N; i++) {
      ret.at(B.at(i)).push_back(i);
    }
    ret.erase(
      remove_if(ret.begin(), ret.end(), [&](const vector<int>& v) { return v.empty(); }),
      ret.end()
    );
    return ret;
  }
};

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  dsu D(N);
  for (int i = 0; i < Q; i++) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t)
      cout << D.same(u, v) << "\n";
    else
      D.merge(u, v);
  }
}

Measured memory_bytes: 3944
#include <iostream>
#include <string>

using namespace std;

int main(void){
    
    int n;
    cin >> n;
    
    int a;
    int j = 100000000;
    for(int i=0;i<n;i++){
        cin >> a;
        int k = 0;
        while(a%2 == 0){
            k += 1;
            a /= 2;
        }
        if(k < j){
            j = k;
        }
    }
    
    cout << j << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>
long long int dp[101][21];
int main(void)
{
	int n,m[101],i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&m[i]);
	for(i=1;i<=n;i++){
		for(j=0;j<=20;j++) dp[i][j]=0;
	}
	dp[1][m[1]]=1;
	for(i=1;i<n-1;i++){
		for(j=0;j<=20;j++){
			if(dp[i][j]!=0){
				if(j-m[i+1]>=0) dp[i+1][j-m[i+1]]+=dp[i][j];
				if(j+m[i+1]<=20) dp[i+1][j+m[i+1]]+=dp[i][j];
			}
		}	
	}
	printf("%lld\n",dp[n-1][m[n]]);
	return 0;
}	

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <assert.h>
#include <string>

using namespace std;

int tempmarge[1000100];

int N, A[10000000];

int preorder[1000], inorder[1000];

bool bsearch(const int array[], int left, int right, int value) {
	while (left + 1 < right) {
		int med = (left + right) / 2;
		if (array[med] > value)right = med;
		else left = med;
	}
	return left < right  && array[left] == value;
}

long long int MargeSort(int x[], int left, int right) {
	long long int mid, i, j, k, cl, cr, c;

	if (left >= right)
		return 0;

	mid = (left + right) / 2;
	cl = MargeSort(x, left, mid);
	cr = MargeSort(x, mid + 1, right);


	for (i = left; i <= mid; i++)
		tempmarge[i] = x[i];
	for (i = mid + 1, j = right; i <= right; i++, j--)
		tempmarge[i] = x[j];

	i = left;
	j = right;
	c = 0;
	for (k = left; k <= right; k++)
		if (tempmarge[i] <= tempmarge[j])
			x[k] = tempmarge[i++];
		else {
			c += mid + 1 - i;
			x[k] = tempmarge[j--];
		}

	return c + cl + cr;
}

void recover(int fp, int lp, int fi, int li) {
	int root, i;
	for (i = fi; i < li + 1; i++) {
		if (preorder[fp] == inorder[i]) break;
	}
	root = i;
	if (fi < root) {
		recover(fp + 1, fp + root - fi, fi, root - 1);
		cout << " ";
	}
	if (root < li) {
		recover(fp + root - fi + 1, lp, root + 1, li);
		cout << " ";
	}
	cout << inorder[root];
}

void koch(double p1[2], double p2[2], double tol) {
	double s[2], t[2], u[2];
	
	if (sqrt(pow((p1[0] - p2[0]), 2.0) + pow((p1[1] - p2[1]), 2.0)) > tol ){
		s[0] = (p1[0] * 2 + p2[0]) / 3;
		s[1] = (p1[1] * 2 + p2[1]) / 3;
		t[0] = (p1[0] + p2[0] * 2) / 3;
		t[1] = (p1[1] + p2[1] * 2) / 3;
		u[0] = s[0] + (t[0] - s[0])*0.5 - (t[1] - s[1])*sqrt(3.0) / 2;
		u[1] = s[1] + (t[0] - s[0])*sqrt(3.0) / 2 + (t[1] - s[1])*0.5;

		koch(p1, s, tol);

		cout << s[0] << " " << s[1] << endl;

		koch(s, u, tol);

		cout << u[0] << " " << u[1] << endl;

		koch(u, t, tol);

		cout << t[0] << " " << t[1] << endl;

		koch(t, p2, tol);
	}
}

int main() {
	
	cin >> N;
	
	double tol = 100/pow(3,N)+0.0001;

	double p1[2] = { 0,0 };
	double p2[2] = { 100,0 };

	cout << p1[0] << " " << p1[1] << endl;

	koch(p1, p2, tol);

	cout << p2[0] << " " << p2[1] << endl;

	cin >> N;

	return 0;
}

Measured memory_bytes: 3404
#include<stdio.h>
int main(){
  int a[10],b,i,j;
  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(a[i]>a[j]){
        b=a[i];
        a[i]=a[j];
        a[j]=b;
      }
    }
  }
  for(i=9;i>6;i--){
    printf("%d\n",a[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,max=1;
  cin >> n;
  vector<int> moti(n);
  for(int i=0;i<n;i++){
    cin >> moti.at(i);
  }
  for(int i=0;i<n-1;i++){
    int memo;
    for(int j=0;j<n-i-1;j++){
      if(moti.at(j)<moti.at(j+1)){
        memo = moti.at(j+1);
        moti.at(j+1) = moti.at(j);
        moti.at(j)=memo;
      }
    }
  }
  int now=moti.at(0);
  for(int i=0;i<n;i++){
    if(now>moti.at(i)){
      max++;
      now=moti.at(i);
    }
  }
  cout << max << endl;
}

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

int d[3][4]={{0,4,5,1},{0,2,5,3},{4,2,1,3}};//d,u,l,r

void dice(int a[6], int n){
	int tmp = a[d[n][0]];
	a[d[n][0]] = a[d[n][1]];
	a[d[n][1]] = a[d[n][2]];
	a[d[n][2]] = a[d[n][3]];
	a[d[n][3]] = tmp;
}

int check(int a[6], int b[6]){
	for(int i = 0;i < 6;i++)if(a[i] != b[i])return 0;
	return 1;
}

int func(int a[6], int b[6]){
	for(int i = 0;i < 6;i++){
		for(int j = 0;j < 4;j++){
			dice(b, 0);
			if(check(a, b))return 1;
		}
		if(i%2 == 0)dice(b, 1);
		else dice(b, 2);
	}
	return 0;
}

int calc(int a[100][6], int n){
	for(int i = 0;i < n-1;i++){
		int b[6], c[6];
		for(int j = 0;j < 6;j++)b[j] = a[i][j];
		for(int j = i+1;j < n;j++){
			for(int k = 0;k < 6;k++)c[k] = a[j][k];
			/*for(int t = 0;t < 6;t++)cout << b[t] << " ";
			cout << endl;
			for(int t = 0;t < 6;t++)cout << c[t] << " ";
			cout << endl << endl;*/
			if(func(b, c))return 1;
		}
	}
	return 0;
}

int main(){
	int a[100][6];
	int n;cin >> n;
	for(int j = 0;j < n;j++)
	for(int i = 0;i < 6;i++)cin >> a[j][i];
	
	
	if(calc(a, n))cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 3096
N = list(map(int, input().split()))[0]

a = float(N) / 1.08
# a = N / 1.08
# print(a)

result = ":("
for i in range(3):
    b = int(a) + i
    c = b * 1.08
    d = int(c)
    # print(i, b, c, d)
    if d == N:
        result = str(b)

print(result)

Measured memory_bytes: 3060
N = int(input())
a = [int(i) - 1 for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    ans += b[a[i]]
    if i >= 1 and a[i] - a[i - 1] == 1:
        ans += c[a[i] - 1]

print(ans)



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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,k;cin >> n>>k;
    vector<lint> v(n);
    REP(i, n) {
        cin >> v[i];
    }
    
    lint ans=1000000000;

    REP(i,n-k+1){
        lint l = v[i],r=v[i+k-1];

        /*
        if((i>0&&v[i-1]>0)||((i+k-1)<n&&v[i+k]<0)){
                continue;
        }
        */
        lint ans1;
        if(l*r>=0){
            ans1 = max(abs(l), abs(r));
        }else{
            ans1 = -l + r + abs(min(abs(l), abs(r)));
        }
        ans = min(ans, ans1);
    }


    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 文字の入力
        String s = sc.next();
        // 出力用
        String answer = "No";
        if (s.contains("A")) {
            if (s.contains("B")) {
                answer = "Yes";
            }
        }
        // 出力
        System.out.println(answer);
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int N;
    cin>>N;
    string s;
    cin>>s;
    int x = 0,m = 0;
    for(int i = 0; i<N; i++){
        if(s[i]=='I')x+=1;
        else if(s[i]=='D')x-=1;
        m = max(x,m);
    }
    cout<<m;
    return 0;
}


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

typedef pair<int, int> event;
const int DEPTH = 30, WIDTH = 100, HEIGHT = 50;
const int INF = 10000000;

struct tank{
	int l, r, in, pre, w, amount;
	tank(int l, int r, int w):l(l), r(r), in(0), pre(0), w(w), amount(0){}

	void update(int time) {
		amount += (time - pre) * in;
		pre = time;
	}

	// thisが左(原点側)，引数tが右側とする
	void merge(const tank& t) {
		amount += t.amount;
		r = t.r;
		in += t.in;
		w += t.w;
	}

	bool full() {
		const int capacity = min(l, r) * w * DEPTH;
		return capacity == amount;
	}

	bool over() {
		const int capacity = min(l, r) * w * DEPTH;
		return capacity < amount;
	}

	double getH() {
		return min<double>(50.0, (double)amount / (w * DEPTH));
	}

	int overAmount() {
		const int capacity = min(l, r) * w * DEPTH;
		return capacity >= amount ? 0 : amount - capacity;
	}
};

inline int getIdx(const vector<tank>& tanks, int pos) {
	int idx = 0, sum = tanks[0].w;
	while(sum < pos)
		sum += tanks[++idx].w;

	return idx;
}

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

	int D;
	cin >> D;

	while(D--) {
		int n;
		cin >> n;

		vector<tank> tanks;
		tanks.reserve(n + 1);

		int prevB = 0, prevH = HEIGHT;
		for(int i = 0; i < n; ++i) {
			int b, h;
			cin >> b >> h;

			tanks.push_back(tank(prevH, h, b - prevB));
			prevH = h;
			prevB = b;
		}

		tanks.push_back(tank(prevH, HEIGHT, WIDTH - prevB));

		int m;
		cin >> m;

		for(int i = 0; i < m; ++i) {
			int f, a;
			cin >> f >> a;

			tanks[getIdx(tanks, f)].in += a;
		}

		int l;
		cin >> l;

		int rest = l;
		priority_queue<event, vector<event>, greater<event> > que;
		vector<int> p(l);

		for(int i = 0; i < l; ++i) {
			int t;
			cin >> p[i] >> t;
			que.push(event(t, i));
		}

		vector<double> ans(l, -1);

		while(!que.empty()) {
			const int time = que.top().first, id = que.top().second;
			que.pop();

			for(int i = 0; i < (int)tanks.size(); ++i)
				tanks[i].update(time);

			int j = 0;
			while(tanks.size() > 1 && j < (int)tanks.size()) {
				if(tanks[j].over()) {
					if(tanks[j].l < tanks[j].r) {
						if(tanks[j - 1].full() && tanks[j - 1].l > tanks[j - 1].r) { // merge
							tanks[j - 1].merge(tanks[j]);
							tanks.erase(tanks.begin() + j);
							--j;
						}
						else {
							const int transfer = tanks[j].overAmount();
							tanks[j - 1].amount += transfer;
							tanks[j].amount -= transfer;
							--j;
						}
					}
					else {
						if(tanks[j + 1].full() && tanks[j + 1].l < tanks[j + 1].r) { // merge
							tanks[j].merge(tanks[j + 1]);
							tanks.erase(tanks.begin() + j + 1);
						}
						else {
							const int transfer = tanks[j].overAmount();
							tanks[j + 1].amount += transfer;
							tanks[j].amount -= transfer;
							++j;
						}
					}
				}

				else
					++j;
			}

			const int idx = getIdx(tanks, p[id]);
			ans[id] = tanks[idx].getH();
		}

		for(int i = 0; i < l; ++i)
			cout << ans[i] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    int a = stoi(S.substr(0,2));
    int b = stoi(S.substr(2));
    bool ok[2] = {};
    if(a <= 12 && a != 0)ok[0] = 1;
    if(b <= 12 && b != 0)ok[1] = 1;
    if(ok[0] && ok[1])cout << "AMBIGUOUS" << endl;
    else if(!ok[0] && !ok[1])cout << "NA" << endl;
    else if(ok[0])cout << "MMYY" << endl;
    else cout << "YYMM" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	          ll x;
	          cin >> x;

	          if(x<=6) cout << 1 << endl;
	          else if(x<=11) cout << 2 << endl;
	          else{
	        	  ll a=2*(x/11);
	        	  if(x%11==0) cout << a << endl;
	        	  else if(x%11>6){
	        		  cout << a+2 << endl;
	        	  }
	        	  else{
	        		  cout << a+1 << endl;
	        	  }
	          }

	          return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stack>
#include <map>

using namespace std;

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

    int a[n];
    int mini=(1<<30);
    int s=0;
    for(int i=0; i<n;i++)
    {
        cin>>a[i];

        if(a[i]<mini && a[i]%10!=0)
        {
            mini=a[i];
        }

        s+=a[i];
    }

    if(mini==(1<<30))
    {
        cout<<0<<endl;
        return 0;
    }

    if(s%10==0)
        cout<<max(0, s-mini)<<endl;
    else
        cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string S;
  cin >> S;
  mll m;

  rep(i, S.size()) {
    char c = S[i];
    if (m[c] != 0) {
      COUT("no");
      return 0;
    } else {
      m[c]++;
    }
  }
  COUT("yes");
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, H);
    CIN(int, W);
    CIN(int, N);

    CIN(int, sr);
    CIN(int, sc);

    CIN(string, S);
    CIN(string, T);


    int x1 = 1, y1= 1, x2 = W, y2 = H;

    for (int i = N-1; i >= 0; i--) {
        if ( T[i] == 'L' ) x2++;
        if ( T[i] == 'R' ) x1--;
        if ( T[i] == 'U' ) y2++;
        if ( T[i] == 'D' ) y1--;

        x1 = max(x1, 1);
        x2 = min(x2, W);
        y1 = max(y1, 1);
        y2 = min(y2, H);

        if ( S[i] == 'L') x1++;
        if ( S[i] == 'R') x2--;
        if ( S[i] == 'U') y1++;
        if ( S[i] == 'D') y2--;

        if ( x1 > x2 || y1 > y2 ) {
            cout << "NO" << "\n";
            return 0;
        }
    }

    string ans = "NO";
    if ( x1 <= sc && sc <= x2 && y1 <= sr && sr <= y2  ) {
        ans = "YES";
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 776
import queue
import sys

q = queue.Queue()
K = int(input())

for i in range(1,10):
    q.put(i)

n = 0
while True:
    n += 1
    val = q.get()
    if n == K:
        print(val)
        sys.exit()

    mod = val%10
    if mod != 0:
        q.put(val*10+mod-1)
    q.put(val*10+mod)
    if mod != 9:
        q.put(val*10+mod+1)

Measured memory_bytes: 57172
#include<bits/stdc++.h>
using namespace std ;
int main(){
    int a , b , c ;
    cin >> a >> b >> c ;
    int k ;
    cin >> k ;
    int x = max( max( a , b ) , c ) ;
    int sum = a + b + c ;
    sum += x * ( 1 << k ) - x ;
    cout << sum << endl ;
    return 0 ;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        doit(args, new Scanner(System.in), System.out);
    }

    static void doit(String[] args, Scanner scanner, PrintStream out) {
        List<Integer> heights = new ArrayList<Integer>();
        for (int i = 0; i < 10; i++) {
            int h = scanner.nextInt();
            heights.add(h);
        }
        Collections.sort(heights, new Comparator<Integer>() {

            @Override
            public int compare(Integer o1, Integer o2) {
                return o2.compareTo(o1);
            }
        });
        for (int i = 0; i < 3; i++) {
            out.println(heights.get(i));
        }
    }
}

Measured memory_bytes: 12000