akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <bitset>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define RPA(i,s,e) for(int i=s; i<=e; i++)
#define RPD(i,s,e) for(int i=s; i>=e; i--)
#define PB(a) push_back(a)
#define MP(i,s) make_pair(i,s)
#define ALL(a) (a).begin(), (a).end()
#define PRT(a) cout << (a) << endl

int f, t;
int L[101];
int M;

bool solve() {
	if(L[1] % 2 != 1 || L[2] % 2 != 1) return false;

	RPA(i,3,M) {
		if(L[i] % 2 != 0) {
			return false;
		}
	}
	return true;
}

void coding() {
	M = 0;
	memset(L, 0, sizeof(L));
	while(scanf("%d%d", &f, &t) != EOF) {
		if(f == 0 && t == 0) {
			printf(solve() ? "OK\n" : "NG\n");
			M = 0;
			memset(L, 0, sizeof(L));
		}

		L[f]++;
		L[t]++;
		M = max(M, f);
		M = max(M, t);
	}
}

// #define _LOCAL_TEST

int main() {
#ifdef _LOCAL_TEST
	freopen("a.in", "r", stdin);
#endif

	coding();

#ifdef _LOCAL_TEST
	cout << endl;
	cout << "This is local test" << endl;
	cout << "Do not forget to comment out _LOCAL_TEST" << endl;
#endif
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}

int main(){
  int k; cin>>k;
  ll res = 0;
  rep1(a,k){
    for(int b = a; b <= k; b++){
      for(int c = b; c <= k; c++){
        int tmp = gcd(a,gcd(b,c));
        if(a!=b&&b!=c&&c!=a)res+=6*tmp;
        else if(a==b&&b==c&&c==a)res+=tmp;
        else res+=3*tmp;
      }
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 3648
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	string S;
	cin >> S;

	int ans = 0;
	for (int i = 0; i < S.size() / 2; i++) {
		int j = S.size() - i - 1;
		if (S[i] != S[j]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
H=int(input())
ans = 0

while H > 1:
    if H%2 == 0:
        H = H/2
        ans += 1
    else:
        H = (H-1)/2
        ans += 1
N = 2**ans
def fight(k):
    if k == 1:
        return 1
    else:
        return 2*fight(k/2)+1
    
        
print(fight(N))

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

typedef struct omaru {
    ll l, r, id;
} polka;

#define FENWICK_NMAX 500010
struct fenwick_tree{
    ll N;
    ll bit[FENWICK_NMAX];
    fenwick_tree(ll n){
        N = n;
        for(ll x = 1; x <= N; x++){
            bit[x] = 0;
        }
    }
    void add(ll a, ll w){
        for(ll x = a; x <= N; x += x & -x){
            bit[x] += w;
        }
    }
    ll sum(ll a){
        ll ret = 0;
        for(ll x = a; x > 0; x -= x & -x){
            ret += bit[x];
        }
        return ret;
    }
    ll range_sum(ll l, ll r) { // [l, r]
        return sum(r) - sum(l-1);
    }
};

int main(){
    // input
    ll n, Q;
    cin >> n >> Q;
    vector<ll> c(n);
    rep(i, 0, n) cin >> c[i];
    vector<polka> q(Q);
    rep(i, 0, Q){
        cin >> q[i].l >> q[i].r;
        q[i].id = i;
    }

    // sort with right pos
    sort(q.begin(), q.end(), [](polka l, polka r) {
        if(l.r < r.r) return true;
        else return false;
    });

    // query
    fenwick_tree t(n+1);
    vector<ll> a(n+1, -1), res(Q);
    ll itr = 0;
    rep(i, 0, n) {
        if(a[c[i]] > -1) t.add(a[c[i]], -1);
        t.add(i+1, 1);
        a[c[i]] = i+1;
        while(q[itr].r == i+1) {
            res[q[itr].id] = t.range_sum(q[itr].l, i+1);
            itr++;
        }
    }

    // print ans
    rep(i, 0, Q) cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 31120
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut ans: &str = &"Yes";
    for i in 0..s.len() {
        let si = s[i];
        if i == a {
            if si != '-' {
                ans = "No";
            }
        } else {
            if si == '-' {
                ans = "No"
            }
        }
    }

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


Measured memory_bytes: 4352
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}

double max(double a, double b) {
	if (a < b) return b;

	return a;
}

ll N;
priority_queue<pair<ll, pint>> q;
vector<pair<pll, ll>> d;


class DisjointSet {
public:
	vector<int> p, rank, num;


	DisjointSet() {}

	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		num.resize(size, 0);
		rep(i, size) { p[i] = i; rank[i] = 0; num[i] = 1; }
	}

	bool same(int x, int y) {

		return findSet(x) == findSet(y);

	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {

			p[y] = x;
			num[x] += num[y];

		}

		else {
			p[x] = y;
			num[y] += num[x];
			if (rank[x] == rank[y]) {

				rank[y]++;
			}

		}


	}


	ll NumberOfElements(int x) {

		return num[findSet(x)];

	}


	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
			num[x] = 1;
		}

		return p[x];
	}



};



bool compare_b(pair< pint,ll> a, pair<pint, ll> b) {
	if (a.first.second > b.first.second)
		return true;

	return false;
}

ll vis[100005];

int main() {
	
	cin >> N;
	d.resize(N);
	rep(i, N) {
		cin >> d[i].first.first >> d[i].first.second;
		d[i].second = i;
	}

	sort(d.begin(), d.end());
	rep(i, d.size()-1) {
		q.push({ -abs(d[i].first.first - d[i + 1].first.first), {d[i].second, d[i + 1].second} });

	}

	sort(d.begin(), d.end(), compare_b);
	reverse(d.begin(), d.end());

	rep(i, d.size() - 1) {
		q.push({ -abs(d[i].first.second - d[i+1].first.second), {d[i].second, d[i + 1].second} });

	}

	ll honsu = 0;
	ll sum = 0;
	DisjointSet ds = DisjointSet(N);

	for (int i = 0; i < 2 * N - 2; i++) {
		if (!ds.same(q.top().second.first, q.top().second.second)) {
			sum += -q.top().first;
			ds.unite(q.top().second.first, q.top().second.second);
		}

		q.pop();
	}

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

Measured memory_bytes: 8560
///////////////////////////////////////////////////
/* __                                       __   */
/*|  |--.-----.---.-.----.----.-----.-----.|  |_ */
/*|  _  |  -__|  _  |  __|  __|  -__|  _  ||   _|*/
/*|_____|_____|___._|____|____|_____|   __||____|*/
/*                                  |__|         */
///////////////////////////////////////////////////
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
#define INF 1000000000000
#define MOD 10000007
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  string a,b,w;
  cin>>a>>b;
  w=a+b;
  int n=atoi(w.c_str());
  int ans1=0;
  double ans2=0;
  ans1=sqrt(n);ans2=sqrt(n);
  if(ans1!=ans2){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		for(int i = 1 ; i <= B ; i++) {
			if(A * i % B == C) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}


Measured memory_bytes: 23508
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
//#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

ll n;vector<pair<ll,ll>> vw;vector<vector<ll>> dp;
ll c1,c2;

void dfs(ll i){
    if(i==1){
        dp[i-1][vw[i-1].S]=vw[i-1].F;
    }else{
        ll j=i/2;
        FORD(k,c2,0){
            if(dp[j-1][k]!=0 or k==0){
                ll ne=k+vw[i-1].S;
                if(ne<=c2)dp[i-1][ne]=max(dp[j-1][k]+vw[i-1].F,dp[i-1][ne]);
            }
            dp[i-1][k]=dp[j-1][k];
        }
    }
    if(i*2<=c1 and i*2<=n)dfs(i*2);
    if(i*2+1<=c1 and i*2+1<=n)dfs(i*2+1);
}

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    cin>>n;
    vw.resize(n);
    REP(i,n)cin>>vw[i].F>>vw[i].S;
    c1=1<<9;c2=100000;
    dp.resize(c1);REP(i,c1)dp[i].resize(c2+1);
    dfs(1);//cout << 1 << endl;
    REP(i,c1)REP(j,c2)dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
    ll q;cin>>q;
    REP(i,q){
        ll v,l;cin>>v>>l;
        vector<ll> cand;
        while(v>c1){
            cand.PB(v);
            v=v/2;
        }
        ll r=SIZE(cand);//cout << r << endl;
        ll ans=0;
        REP(j,1<<r){
            ll v_sub=0;ll w_sub=0;
            REP(k,r){
                if((j>>k)&1){
                    v_sub+=vw[cand[k]-1].first;
                    w_sub+=vw[cand[k]-1].second;
                }
            }
            if(w_sub<=l)ans=max(ans,dp[v-1][l-w_sub]+v_sub);
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 408688
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int l,r;
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> l >> r;
    ans+=r-l+1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char[] s1 = sc.nextLine().toCharArray();
		char[] s2 = sc.nextLine().toCharArray();
        boolean flag = true;
        for(int i=0;i<3;i++){
            flag &= s1[i]==s2[2-i];
        }
        System.out.println(flag?"YES":"NO");
	}
}

Measured memory_bytes: 21972
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

//  B Kagami Mochi

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    List<Integer> list = new ArrayList();

    for(int i = 0; i < N ; i++) {
    	list.add(Integer.parseInt(sc.next()));
    }

    Collections.sort(list);
    Collections.reverse(list);

    int layer = 0;
    int l2 = 0;

    for(Integer l : list) {
    	if(l != l2) {
    		layer++;
    	}
    	l2 = l;
    }

    System.out.println(layer);
  }
}

Measured memory_bytes: 22868
n = int(input())

b6 = 6
b9 = 5

dp = [[0] * (n + 1) for _ in range(1 + 1 + b6 + b9)]

for i in range(1, n + 1):
    dp[1][i] = i
    
for i in range(1, n + 1):
    for j in range(1, b6 + 1):
        dp[j + 1][i] = dp[j][i]
        if i >= 6 ** j:
            dp[j + 1][i] = min([
                dp[j + 1][i], 
                dp[j + 1][i - (6 ** j)] + 1
            ])

for i in range(1, n + 1):
    for j in range(1, b9 + 1):
        dp[j + b6 + 1][i] = dp[b6 + j][i]
        if i >= 9 ** j:
            dp[j + b6 + 1][i] = min([
                dp[j + b6 + 1][i], 
                dp[j + b6 + 1][i - (9 ** j)] + 1
            ])

print(dp[-1][n])



Measured memory_bytes: 53084
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
A = sorted([X[i][0] for i in range(N)])
B = sorted([X[i][1] for i in range(N)])
if N%2==1:
    k = (N+1)//2
    a = A[k-1]
    b = B[k-1]
    print(b-a+1)
else:
    a2 = A[N//2-1]+A[N//2]
    b2 = B[N//2-1]+B[N//2]
    print(b2-a2+1)

Measured memory_bytes: 136808
import sys
input = sys.stdin.readline
from operator import itemgetter

X, Y, N = map(int, input().split())
U = []
D = []
R = []
L = []

def mustconsider(x, y):
    return (x in [0, X]) or (y in [0, Y])

def divide(x, y, i):
    if x == 0 and y != Y:
        L.append((y, i))
    if x == X and y != 0:
        R.append((y, i))
    if y == 0 and x != 0:
        D.append((x, i))
    if y == Y and x != X:
        U.append((x, i))

for i in range(N):
    x1, y1, x2, y2 = map(int, input().split())
    if mustconsider(x1, y1) and mustconsider(x2, y2):
        divide(x1, y1, i)
        divide(x2, y2, i)

D.sort()
R.sort()
U.sort(reverse=True)
L.sort(reverse=True)

Arounds = []
for _, ind in D:
    Arounds.append(ind)
for _, ind in R:
    Arounds.append(ind)
for _, ind in U:
    Arounds.append(ind)
for _, ind in L:
    Arounds.append(ind)

stack = []
for a in Arounds:
    if not stack:
        stack.append(a)
    else:
        if stack[-1] == a:
            stack.pop()
        else:
            stack.append(a)

print("YES" if not stack else "NO")

Measured memory_bytes: 29568
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
const char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


const int MAX_SIZE = 1e5 + 1;
Vint number_balls(MAX_SIZE, 1);
vector<bool> Pexit(MAX_SIZE, false);


int main(void){
  Pexit.at(0) = true;
  int n, m, x, y; cin >> n >> m;
  REP(i, m){
    cin >> x >> y;
    x--; y--;
    number_balls.at(x)--;
    number_balls.at(y)++;
    if(Pexit.at(x)){
      Pexit.at(y) = true;
      if(number_balls.at(x) == 0){
        Pexit.at(x) = false;
      }
    }
  }
  cout << std::count(Pexit.begin(), Pexit.end(), true) << BR;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

int main(){
  int n,m;
  cin >> n >> m;
  vi result(n);
  REP(i,n)result[i]=0;

  int num = (int)(n/2)+1;
  REP(i,num)result[i]=m;

  REP(i,n-1)cout<<result[i]<<" ";
  cout<<result[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
     int N,K,a;
     int l[55];
  cin >>N >>K;
  for(int i=0;i<N;i ++)cin >> l[i];
  
  sort(l,l+N,greater<int>());
  
  for(int i=0;i<K;i ++){
     
      a += l[i];
  }
  cout <<a<<endl;
}
  
    


Measured memory_bytes: 256
import sys
n = int(sys.stdin.readline().strip())

# A * B + C, make sure A * B <= N, if A == B, it is (N-A*B) + 1, else ((N-A*B) + 1) * 2
res = 0
"""
for i in range(1, n//2+1):
    if i ** 2 < n:
        res += 1
    for j in range(i+1, n//i+1):
        if i*j >= n:
            break
        res +=  2

print(res)
"""

# A==B, from 1 to square root
res += int(n**0.5)
upperbound = int(n**0.5) + 1
if int(n**0.5) ** 2 == n:
    # n has int square root
    res -= 1
    upperbound = int(n**0.5)

# Assuming A < B
# A = 1, B=2...N-1
# A = 2, B=3...N/2 or N/2-1

for i in range(1, upperbound):
    if n % i == 0:
        half = n // i - 1 - i
    else:
        half = n//i - i
    res += half * 2
print(res)

Measured memory_bytes: 62564
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long H,a,ans;
  ans = 0;
  a = 1;
  cin >> H;
  while (true) {
    ans+=a;
    H = H/2;
    a = a*2;
    if (H==0){
      break; 
    };
  };
  cout << ans << endl;
}

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

int main(){

int n,k;
cin >> n >> k;

string s;
cin >> s;

if(s[k-1] == 'A') s[k-1] = 'a';
else if(s[k-1]=='B')s[k-1] = 'b';
else s[k-1]='c';

cout << s << endl;



  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

int N,M;
vi a;
ll match[9]={2,5,5,4,5,6,3,7,6};

bool stringMax(string &a,string b){
  if(a == "LOWEST"){
     a=b;
  }else if(a.size() < b.size()){
      a=b;
  }else if(a.size() == b.size()){
      //桁が同じなら単純にstringの辞書順比較でいい
      if(a<b) a=b;
  }else{
      //aはそのまま
  }
}

int main() {
   

   cin >> N >> M;
   
   rep(i,M){
       ll x;
       cin >> x;
       a.push_back(x);
   }

   string dp[10010];//N本までいったときに作れた数字
   rep(i,10010){
       dp[i] = "LOWEST";
   }
   dp[0]="";
   rep(i,N){
       if(dp[i] == "LOWEST") continue;

      for(auto x:a){
          //使えるのはaにある数字だけなので
          stringMax(dp[i+match[x-1]],dp[i]+(char)('0'+x));
      }
   }

   fin(dp[N]);
    
}
    



Measured memory_bytes: 44800
#include <stdio.h>
int main(void){
	int a,b,c,d;
  	scanf("%d%d%d%d",&a,&b,&c,&d);
  	if(a+b>c+d){
      	printf("Left\n");
    }else if(a+b<c+d){
      	printf("Right\n");
    }else{
      	printf("Balanced\n");
    }
  	return 0;
}

Measured memory_bytes: 128
import sys
from math import floor,ceil,sqrt,factorial,log
from heapq import heapify, heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from decimal import Decimal
inf = float('inf')
MOD = 1000000007


n, m = map(int, input().split())
h = list(map(int, input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
    x,y = map(int, input().split())
    g[y-1].append(x-1)
    g[x-1].append(y-1)


def dfs(v):
    for i in range(len(g[v])):
        if h[g[v][i]] >= h[v]:
            return False
    
    return True


ans = 0
for i in range(n):
    if dfs(i):
        ans += 1

print(ans)

Measured memory_bytes: 96092
import collections
A= int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
primelist=make_divisors(A)
S = primelist[-1]
G = int(A/S)

print((G-1)+(S-1))

Measured memory_bytes: 3572
#include<cstdio>
#include<algorithm>
#include<cstring>
#define LL long long
using namespace std;
const int N=55;
int n,f[N],a[N],b[N];
LL ans;
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
bool check(LL x)
{
	for(int i=1;i<=n;i++)
	{
		memset(f,0,sizeof(f));
		f[a[i]]=true;
		for(int j=50;j>=1;j--)
			if(x&(1ll<<j))
				for(int k=0;k<=50;k++)
					if(f[k])f[k%j]=true;
		if(!f[b[i]])return false;
	}
	return true;
}			
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)b[i]=read();
	ans=(1ll<<51)-2;
	if(!check(ans)){printf("-1");return 0;}
	for(int i=50;i>=1;i--)
	{
		ans^=1ll<<i;
		if(!check(ans))ans^=1ll<<i;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

vector<vector<bool>> Edge(10,vector<bool>(10));

int main() {
    int N,M;cin >> N >> M;
    for(int i = 0;i<M;i++){
        int a,b;cin >> a >> b;
        a--;b--;
        Edge.at(a).at(b) = true;
        Edge.at(b).at(a) = true;
    }
    vector<int> permutation(N);
    vector<bool> V(N,false);
    bool ok = true;
    int ans = 0;
    for(int i = 0;i<N;i++) permutation.at(i) = i;
    do{
        V.assign(N,false);
        V.at(0) = true;
        if(permutation.at(0) != 0) continue;
        for(int i = 0;i<N-1;i++){
            int from = permutation.at(i);
            int to = permutation.at(i+1);
            if(V.at(to) || !Edge.at(from).at(to)) ok = false;
            else V.at(to) = true;
            //cout << from << " " << to << " " << ok << endl;
        }
        if(ok) ans++;
        ok = true;
    }while(next_permutation(permutation.begin(),permutation.end()));

    cout << ans << endl;
}

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

int main() {
    int n, i;
    cin >> n >> i;
    cout << n-i+1;
    
    cout << endl;
    return 0;
}

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

int main(){
  int n ;
  cin >> n ;
  vector<int> a(n) ;
  vector<int> b(n) ;
  for(int i =0 ; i < n ; i++){
    cin >> a.at(i) ;
    b.at(i) = a.at(i) ;
  }
  sort( b.begin() ,b.end() ) ;
  int m1 = b.at(n/2-1) ;
  int m2 = b.at(n/2) ;
  if(m1 == m2){
    for(int i = 0 ; i < n ; i++){
      cout << m1 << endl ;
    }
  }else{
    for(int i = 0 ; i < n ; i++){
      if(a.at(i) <= m1){
        cout << m2 <<endl ;
      }else{
      	cout << m1 << endl ;
      }
    }
  }
  
}

Measured memory_bytes: 3712
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b==c){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(a+c==b){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(c+b==a){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
N , W = map(int , input().split())
value = []
weight = []
dp = [[0] * (N + 1) for _ in range(N)]
for _ in range(N):
    v , w = map(int ,input().split())
    value.append(v)
    weight.append(w)

def knapsack(i , j):
    dp = [[-1] * (W + 1) for _ in range(N + 1)]
    def solve(i , j):
        if dp[i][j] != -1:
            return dp[i][j]
        if i == N:
            retval = 0
        elif j < weight[i]:
            retval = solve(i + 1 , j)
        else:
            retval = max(solve(i + 1 , j) , solve(i + 1 , j - weight[i]) + value[i])
        dp[i][j] = retval
        return retval
    ans = solve(0,W)
    return ans

if __name__ == "__main__":
    print(knapsack(0 , W))


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

ll pow64(ll a,ll n) {
	ll ans = 1;
	rep(_,n) ans *= a;
	return ans;
}

const int range = 1000;

int main() {
	ll x;
	cin >> x;
	for (ll a=-range;a<=range;a++) 
		for (ll b=-range;b<=range;b++)
			if (pow64(a,5LL) - pow64(b,5LL) == x) {
				printf("%lld %lld\n", a, b);
				return 0;
			}
}


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

int main() {
	int h = 0;
	int m = 0;
	int s,rm,rs;
	cin >> s;
	if(s >= 60) {
		m = s / 60;
		rs = s - (m * 60);
	} else {
		rs = s;
	}
	if(m >= 60) {
		h = m / 60;
		rm = m - (h * 60);
	} else {
		rm = m;
	}
	cout << h << ":" << rm << ":" << rs << endl;
	return 0;
}


Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  cin >> x;

  int a = ceil(x / 105.0);

  if(105 * a - 5 * a <= x && 105 * a >= x){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int L = sc.nextInt();

        System.out.println(solve(L));

        sc.close();
    }

    static String solve(int L) {
        Graph graph = new Graph();
        search(graph, L);

        return String.format("%d %d\n%s", graph.vertexNum, graph.edges.size(),
                graph.edges.stream().map(edge -> String.format("%d %d %d", edge.from, edge.to, edge.weight))
                        .collect(Collectors.joining("\n")));
    }

    static void search(Graph graph, int pathNum) {
        if (pathNum == 1) {
            return;
        }

        int currentVertex = graph.vertexNum;

        ++graph.vertexNum;
        graph.edges.add(new Edge(currentVertex, graph.vertexNum, 0));
        graph.edges.add(new Edge(currentVertex, graph.vertexNum, pathNum / 2));

        search(graph, pathNum / 2);

        if (pathNum % 2 != 0) {
            graph.edges.add(new Edge(currentVertex, graph.vertexNum, pathNum - 1));
        }
    }
}

class Graph {
    int vertexNum = 1;
    List<Edge> edges = new ArrayList<>();
}

class Edge {
    int from;
    int to;
    int weight;

    Edge(int from, int to, int weight) {
        this.from = from;
        this.to = to;
        this.weight = weight;
    }
}

Measured memory_bytes: 36296
#include "iostream"
#include "algorithm"
#include "math.h"
using namespace std;

long long int sx, sy, gx, gy, dx, dy;
long long int w,box;
long long int x, y;
long long int ans;

int main() {
	cin >> sx >> sy >> gx >> gy;
	dx = abs(sx - gx);
	dy = abs(sy - gy);
	x = max((long long int)1,dx);
	y = max((long long int)1,dy);
	while (1) {
		if (x < y) {
			box = x;
			x = y;
			y = box;
		}
		if (x%y == 0) {
			w = min(x, y);
			break;
		}
		x = x%y;
	}
	//cout << w << "\n";
	ans = (dx / w + dy / w - 1)*w;
	cout << ans << "\n";
	return 0;
}

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

int main() {
  int T;
  cin >> T;
  while (T--) {
    int N, ans = 0;
    cin >> N;
    vi A(N), B(0);
    for (int i = 0; i < N; i++) cin >> A[i];
    string S;
    cin >> S;
    for (int i = N - 1; i >= 0; i--) {
      for (ll b : B) A[i] = min(A[i], A[i] ^ b);
      if (A[i] == 0) continue;
      if (S[i] == '0') B.push_back(A[i]);
      else ans = 1;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

vector<vector<int>> to;
vector<int> num;

queue<pair<int,int>> que;

int main() {
	int n, m;
	cin >> n >> m;
	num.resize(n);
	rep(i, n) num[i] = -10000;
	to.resize(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	que.push({0,-1});
    while(que.size()){
      int a=que.front().first;
      int b=que.front().second;
      que.pop();
      if(num[a]==-10000){
        num[a]=b;
        rep(i,to[a].size()){
          que.push({to[a][i],a});
        }
      }
    }
        
	cout << "Yes" << endl;
	rep(i, n - 1) cout << num[i + 1] + 1 << endl;
}

Measured memory_bytes: 12288
from collections import defaultdict

n = int(input())
d = defaultdict(int)
for i in range(n):
	s = input()
	d[s] += 1
l = sorted(d.items(), key=lambda x: (-x[1], x[0]))
m = l[0][1]

for i in range(len(l)):
	if l[i][1] == m:
			print(l[i][0])
	else:
		break


Measured memory_bytes: 115848
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;

typedef pair<int,int> P;

signed main(){
	vector<P> vec;
	int n,cnt = 0,ans = 1;
	cin >> n;
	for(int i = -1;i <= 1;i += 2){
		for(int j = 0;j < n;j++){
			int a;
			cin >> a;
			vec.push_back(P(a,i));
		}
	}
	sort(vec.begin(),vec.end());
	for(int i = 0;i < n * 2;i++){
		if(cnt * vec[i].second < 0) ans = ans * abs(cnt) % MOD;
		cnt += vec[i].second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6384
/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 200 * 1001;
int n, p[N], x[N], q;
long long dp[N];
vector<int> adj[N];
bool mark[N];

void dfs(int u, int par, long long sum) {
	mark[u] = true;
	dp[u] = sum;
	for (auto v : adj[u]) {
		if (!mark[v]) {
			dfs(v, u, sum + dp[v]);
		}
	}
}

int main() {
	cin >> n >> q;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 0; i < q; i++) {
		cin >> p[i] >> x[i];
		p[i]--;
		dp[p[i]] += x[i];
	}
	dfs(0, -1, dp[0]);
	for (int i = 0; i < n; i++)
		cout << dp[i] << " ";
}
	
	

Measured memory_bytes: 25984
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int ll;
#define MOD (1000000007);
#define INF (2e9)



int main(void) {
    int n;
    cin >> n;
    int *a = new int[n];
    for (int i = 0; i<n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);

    for (int i = 0; i<n; i++) {
        if (a[i] != (n % 2 == 0 ? i / 2 * 2 + 1 : (i + 1) / 2 * 2)) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for (int i = 0; i<n / 2; i++) {
        ans = (ans * 2) % MOD;
    }
    cout << ans << endl;
    delete(a);
    return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    vector<ll> B(N);
    FOR(i, 0, N){
        cin >> B.at(i);
    }

    // 高さ確定の部分にはその値を入れる
    // 未確定部分には「h以下」という情報として -h を入れる
    vector<ll> C(N);
    ll height = 0;
    FOR(i, 0, N){
        if(height!=A[i]){
            C[i] = A[i];
        }else{
            C[i] = -height;
        }
        height = A[i];
    }

    // 逆方向から
    vector<ll> D(N);
    height = 0;
    for(int i=N-1; i>=0; i--){
        if(height!=B[i]){
            D[i] = B[i];
        }else{
            D[i] = -height;
        }
        height = B[i];
    }
    
    // vprint(C);
    // vprint(D);

    // マージ
    vector<ll> E(N);
    FOR(i, 0, N){
        if(C[i]<0 && D[i]>0){
            if(-C[i] < D[i]){
                p(0);
                return 0;
            }
            E[i] = D[i];
        }
        else if(D[i]<0 && C[i]>0){
            if(-D[i] < C[i]){
                p(0);
                return 0;
            }
            E[i] = C[i];
        }
        else if(C[i]<0 && D[i]<0){
            E[i] = max(C[i], D[i]);
        }
        // 以降は正
        else if(C[i]>0 && D[i]>0 && C[i]!=D[i]){
            // 矛盾
            p(0);
            return 0;
        }
        else if(C[i]>0 && D[i]>0 && C[i]==D[i]){
            E[i] = C[i];
        }
        else{
            //p("考慮漏れ");
        }
    }
    // vprint(E);

    ll answer = 1;
    height = E[0];
    FOR(i, 1, N-1){
        if(E[i]<0){
            answer *= -E[i];
            answer %= mod;
        }
    }

    p(answer);

    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

string s[1000];
int pd[1010];
int depth[1000];

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

	int n;
	while(cin >> n, n) {
		for(int i = 0; i < n; i++) {
			cin >> s[i];
			depth[i] = count(s[i].begin(), s[i].end(), '.');
		}

		for(int i = 0; i < n; i++) {
			if(depth[i] == 0) {
				fill(pd, pd + 1010, -1);
			}
			else {
				for(int j = 0; j < depth[i] - 1; j++) {
					s[i][j] = ' ';
				}
				s[i][depth[i] - 1] = '+';
			}
			if(pd[depth[i]] != -1) {
				for(int j = pd[depth[i]] + 1; j < i; j++) {
					s[j][depth[i] - 1] = '|';
				}
			}
			for(int j = depth[i]; j < 1010; j++) {
				pd[j] = -1;
			}
			pd[depth[i]] = i;
		}

		for(int i = 0; i < n; i++) {
			cout << s[i] << endl;
		}
	}

}

Measured memory_bytes: 3704
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

int N,M,a,b,c;
string str;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    vector<int> A;
    A.push_back(a);
    A.push_back(b);
    A.push_back(c);
    VSORT(A);

    cout << A[2]-A[0] << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;

	if (K % 2 == 0)
	{
		cout << A - B << endl;
	}
	else
	{
		cout << B - A << endl;
	}

	



	return 0;
}

Measured memory_bytes: 256
///
// File:  2018.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 10 07:57:38 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t N, M, P;
    cin >> N >> M >> P;
    if (N == 0) break;

    vector<uint32_t> nums;
    uint32_t num = 0;
    for (uint32_t i = 0; i < N; i++) {
      uint32_t val;
      cin >> val;
      nums.push_back(val);
      num += val;
    }

    uint32_t total = num * 100 * (100 - P) / 100;
    if (nums[M - 1] == 0) {
      cout << 0;
    } else {
      cout << total / nums[M - 1];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int ans = 0;
  if(s.at(0) == '1'){
    ans++;
  }
  if(s.at(1) == '1'){
    ans++;
  }
  if(s.at(2) == '1'){
    ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
#define NIL -1
static const int MAX = 500;
static const int INFTY = (1<<21);
main(){
  int n, i, j, e, v, sum, u , minV, A[MAX];
  /*your code*/
  int M[MAX][MAX], key[MAX], p[MAX];
  
  scanf("%d", &n);
  
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
  /*
    your code
  */
  for(i = 0; i < n; i++){
    key[i] = INT_MAX;
    p[i] = NIL;
    A[i] = NIL;
  }
  
  key[0]=0;
  
  while(1){
    
    u = NIL;
    
    minV = INT_MAX;
    
    for(i = 0;  i < n; i++){
      
      if(key[i] < minV && A[i] == NIL){
	
	u = i;
	
	minV = key[i];
	
      }
      
    }  
    if(u == NIL)break;
    
    A[u] = u; 
    
    for(v = 0; v < n; v++){
      if(M[u][v] < key[v] && A[v] == NIL){
	key[v] = M[u][v];
	p[v] = u;
      }
    }
  }
  
  sum = 0;
  
  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum +=M[p[i]][i];
  }
  
  printf("%d\n", sum);
  
  
  return 0;
}

Measured memory_bytes: 1232
n = int(input())

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

neg = sum(1 for x in a if x<0)

ans = 0

if neg%2:
	for i in range(len(a)):
		if i == 0:
			exc = abs(a[i])
		else:
			exc = min(exc, abs(a[i]))
	ans = sum(abs(x) for x in a)-exc*2
else:
	ans = sum(abs(x) for x in a)

print(ans)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int p1 = 0, p2 = 0, p3 = 0;
    rep (i, n) {
        int p;
        cin >> p;
        if (p <= a) p1++;
        else if (p >= b + 1) p3++;
        else p2++;
    }
    cout << min(p1, min(p2, p3)) << endl;
    
    return 0;
}



Measured memory_bytes: 256