akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

void solve(){

    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    
}

Measured memory_bytes: 256
local n=io.read("n")
local answer=1
local length=0
for i=1,n do
    a=io.read("n")
    length=length+math.log(a,10)
    answer=answer*a
end
if length>18 or answer>10^18 then
    print(-1)
else
    print(answer)
end    

Measured memory_bytes: 3044
N = int(input())
v = sorted([int(v) for v in input().split(" ")])

ans = 0.0
ans += (v[0] + v[1]) / 2
ans = round(ans,10)
for i in range(2,N):
    ans = ((ans + v[i]) / 2)
    ans = round(ans,10)

print(ans)

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

ll bucket[100001];

int main(){
    ll n,k;
    cin >> n >> k;
    ll a,b;
    
    for(int i=0;i<100001;i++)bucket[i]=0;
    
    for(int i=1;i<=n;i++){
        cin >> a >> b;
        bucket[a] += b;
    }
    for(int i=1;i<=100000;i++){
        k -= bucket[i];
        if(k<=0){
            cout << i << endl;
            break;
        }
    }
    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);
        int a = sc.nextInt();
        int b = a / 2;
        int c;
        if (a % 2 == 0) {
            c = b;
        } else {
            c = b + 1;
        }
        System.out.println(b * c);
    }
}

Measured memory_bytes: 23636
/* ファイル名：ITP1_2_C.c	*/
/* 内容：３つの整数を読み込み、それらを値が小さい順に並べて出力する	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:３つの整数を読み込み、それらを値が小さい順に並べて出力する	*/
int main( void )
{
	/* 内部変数定義	*/
	int a;	/* 読み込む整数1	*/
	int b;	/* 読み込む整数2	*/
	int c;	/* 読み込む整数3	*/
	
	int x;	/*入れ替え用変数	*/
	
	scanf("%d %d %d",&a,&b,&c);/* 整数を読み込む	*/
	
	/* 1番目と2番目の整数を比較	*/
	if( a > b ){
		/* 1番目の整数が大きければ入れ替え	*/
		x = a;
		a = b;
		b = x;
	}
	else{
		/* 1番目の整数が小さければ処理なし	*/
	}
	
	/* 2番目と3番目の整数を比較	*/
	if( b > c ){
		/* 2番目の整数が大きければ入れ替え	*/
		x = b;
		b = c;
		c = x;
	}
	else{
		/* 2番目の整数が小さければ処理なし	*/
	}
	
	/* 再び1番目と2番目の整数を比較	*/
	if( a > b ){
		/* 1番目の整数が大きければ入れ替え	*/
		x = a;
		a = b;
		b = x;
	}
	else{
		/* 1番目の整数が小さければ処理なし	*/
	}
	
	printf("%d %d %d\n",a,b,c);/* 結果を出力	*/

	return 0;
}



Measured memory_bytes: 2092
import fractions

n, m = map(int, input().split())
s = list(input())
t = list(input())

l = n * m // fractions.gcd(n, m)
ans = l
dic = {}
for i in range(n):
    j = (l // n) * i % l
    if j in dic and dic[j] != s[i]:
        ans = -1
        break
    dic[j] = s[i]
for i in range(m):
    j = (l // m) * i % l
    if j in dic and dic[j] != t[i]:
        ans = -1
        break
    dic[j] = t[i]
print(ans)

Measured memory_bytes: 85184
#include<iostream>
using namespace std;
  
int main(){
    int a, b;
      
    cin>> a >> b;
      
    if ( a < b ) cout << "a < b" << endl;
    else if ( a > b ) cout << "a > b" << endl;
    else cout << "a == b" << endl;
  
    return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100;
const int MAX_V = (int)1e3;
const long long INF = (long long)1 << 35;
long long DP[MAX_V*MAX_N+1];

int main(){
    int N, W;
    cin >> N >> W;
    DP[0] = 0;
    for(int i=1; i<MAX_V*MAX_N+1; ++i) DP[i] = INF;
    for(int i=0; i<N; ++i){
        int w, v;
        cin >> w >> v;
        for(int j=MAX_V*MAX_N; j-v>=0; --j){
            DP[j] = min(DP[j-v]+w, DP[j]);
        }
    } 
    //cout << endl;
    //for(int i=0; i<101; ++i) cout << DP[i] << " ";
    //cout << endl;
    int res =0;
    for(int i=0; i<MAX_V*MAX_N+1; ++i){
        if(DP[i]<=W) res = i;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(i%2 == 0){
            if(a[i]%2 == 1) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

const int maxn = 2e5 + 5;
int n, ccc;
int c[maxn], l[maxn], r[maxn], cnt[maxn], h[maxn], p[maxn];
int lz[maxn * 4], sum[maxn * 4];
vector <int> d[maxn], e[maxn], a;

void input(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> c[i];
        d[c[i]].push_back(i);
    }
    int u, v;
    for (int i = 1; i < n; i++){
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
}

void dfs(int u){
    l[u] = ++ccc;
    for (int v : e[u])
    if (v != p[u]){
        h[v] = h[u] + 1;
        p[v] = u;
        dfs(v);
        cnt[u] += cnt[v];
    }
    cnt[u]++;
    r[u] = ccc;
}

bool cmp(const int &a, const int &b){
    return h[a] > h[b];
}

void mdf(int id, int l, int r, int val){
    if (val == -1) return;
    lz[id] = val;
    sum[id] = (r - l + 1) * val;
}

void up(int id, int l, int r, int u, int v, int val){
    if (v < l || u > r) return;
    if (l >= u && r <= v){
        mdf(id, l, r, val);
        return;
    }
    int mid = (l + r) >> 1;
    mdf(id * 2, l, mid, lz[id]);
    mdf(id * 2 + 1, mid + 1, r, lz[id]);
    lz[id] = -1;
    up(id * 2, l, mid, u, v, val);
    up(id * 2 + 1, mid + 1, r, u, v, val);
    sum[id] = sum[id * 2] + sum[id * 2 + 1];
}

int get(int id, int l, int r, int u, int v){
    if (v < l || u > r) return 0;
    if (l >= u && r <= v) return sum[id];
    int mid = (l + r) >> 1;
    mdf(id * 2, l, mid, lz[id]);
    mdf(id * 2 + 1, mid + 1, r, lz[id]);
    return get(id * 2, l, mid, u, v) + get(id * 2 + 1, mid + 1, r, u, v);
}

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    input();
    dfs(1);
    for (int i = 1; i <= n; i++){
        sort(d[i].begin(), d[i].end(), cmp);
        up(1, 1, n, 1, n, 1);
        int64 nn = n, res = 0;
        for (int j = 0; j < d[i].size(); j++){
            int u = d[i][j];
            a.clear();
            int64 tsum = 0;
            for (int v : e[u])
            if (v != p[u]){
                a.push_back(get(1, 1, n, l[v], r[v]));
                tsum += a[a.size() - 1];
            }
            for (int64 t : a){
                res += t * (tsum - t);
                tsum -= t;
            }
            int64 tmp = get(1, 1, n, l[d[i][j]], r[d[i][j]]);
            up(1, 1, n, l[d[i][j]], r[d[i][j]], 0);
            nn -= tmp;
            res += tmp * (nn + 1);
        }
        cout << res << endl;
    }
    return 0;
}


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

int main(){
    long long int n, a, b;  cin >> n >> a >> b;
    if(a>b){
        cout << 0;  return 0;
    }
    if(n==1){
        if(a==b){
            cout << 1;  return 0;
        }
        cout << 0;  return 0;
    }
    cout << (n-2)*(b-a)+1;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

void addX(const int &node, const int &x, int *count, vector< vector<int> > &tree){
  count[node] += x;
  for(auto child:tree[node]){
    addX(child,x,count,tree);
  }
}

signed main() {
  int n,q;
  cin >> n >> q;
  vector< vector<int> > tree(n);
  int a,b;
  for(int i=0;i<n-1;i++){
    cin >> a >> b;
    a--;b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

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

  unordered_map<int,int> parent;
  queue<int> que;
  que.push(0);
  while(!que.empty()){
    int node = que.front();que.pop();
    for(auto ch:tree[node]) {
      if(ch!=parent[node]){
        parent[ch] = node;
        que.push(ch);
        count[ch] += count[node];
      }
    }
  }

  for(auto x:count){
    cout << x << " ";
  }
  cout << endl;
  return 0;
}




Measured memory_bytes: 24760
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m)
        for(int i=0;i<n;i++)
        cout<<m;
    else
        if(n>m)
        for(int i=0;i<n;i++)
        cout<<m;
    else
        for(int i=0;i<m;i++)
        cout<<n;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    string s; cin >> s;
    int n = s.size();
    bool ok = true;
    map<char, int> mp;
    rep(i, n) {
        mp[s[i]]++;
        if(mp[s[i]] == 2) ok = false;
    }
    if(ok) cout << "yes";
    else cout << "no";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,a,t=1,i,res;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    if(a==t) t++;
  }
  if(t==1)
    res=-1;
  else
    res=n-t+1;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
n,c=map(int,input().split())
d=[list(map(int,input().split()))for _ in range(c)]
l=[[i for i in[0]*c]for _ in range(3)]
for i in range(n):
  t=list(map(int,input().split()))
  for j in range(n):
    l[(i+j)%3][t[j]-1]+=1
a=10**18
for i in range(c):
  for j in range(c):
    for k in range(c):
      if i==j or j==k or k==i:continue
      a=min(a,sum(d[x][i]*l[0][x]+d[x][j]*l[1][x]+d[x][k]*l[2][x]for x in range(c)))
print(a)

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

using namespace std;

typedef long long ll;

const int c = 111111;

int main(){
    ll n, w;
    cin >> n >> w;

    ll u, v;
    vector<pair<long long,long long>> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> u >> v;
        a[i] = make_pair(u, v);
    }

    long long dp[111][c];

    for(int i = 1; i < c; i++){
        dp[0][i] = ll(1e18);
    }

    for(int i = 1; i <= n; i++){
        for(int j = 0; j < c; j++){
            dp[i][j] = dp[i-1][j];
            if(j - a[i].second >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j-a[i].second] + a[i].first);
            }
        }
    }

    long long ans = 0;
    for(int i = 0; i < c; i++){
        if(dp[n][i] <= w) ans = i;
    }
    cout << ans;

}


Measured memory_bytes: 89984
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int a[12];
    for(int i=0;i<12;i++) cin>>a[i];
    sort(a,a+12);
    if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3]&&
       a[4]==a[5]&&a[5]==a[6]&&a[6]==a[7]&&
       a[8]==a[9]&&a[9]==a[10]&&a[10]==a[11]) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
#define lb long double
using namespace std;
int s[20],ls;
inline ll get(){
	ll ans=0;
	for (int i=ls;i;--i) ans=ans*10ll+s[i];
	return ans;
}
inline void calc(ll x){
	ls=0;
	while (x) s[++ls]=x%10,x/=10;
}
inline int getsum(){
	int ans=0;
	for (int i=1;i<=ls;++i) ans+=s[i];
	return ans;
}
inline ll f(ll x){
	calc(x);
	lb mn=1e18;ll ans;
	for (int i=1;i<=ls;++i){
		for (;s[i]<=9;++s[i]){
			ll y=get();
			lb tmp=(lb)y/(lb)getsum();
			if (tmp<mn) mn=tmp,ans=y;
		}
		--s[i];
	}
	return ans;
}
int main(){
	int k;scanf("%d",&k);ll s=1;
	while (k--) printf("%lld\n",s),s=f(s+1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


void print_arr(int* arr, int len) {
    for (int i = 0; i < len; i++) {
        if (i > 0) cout << ' ';
        cout << arr[i];
    }
    cout << endl;
}

void swap(int* arr, int i, int j) {
    int tmp = arr[i];
    arr[i] = arr[j];
    arr[j] = tmp;
}

int bubbleSort(int* arr, int len) {
    int count = 0;
    int flag = 1;       // 比較対象が存在するフラグ

    while (flag) {
        flag = 0;

        for (int i = len - 1; i >= 1; i--) {
            if (arr[i] < arr[i - 1]) {
                swap(arr, i, i - 1);
                count++;
                flag = 1;
            }
        }
    }

    return count;
}

int main() {
    int N;
    int count;
    int arr[100];

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

    count = bubbleSort(arr, N);
    print_arr(arr, N);
    cout << count << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n; cin>>n;
    int digit=0, m=n;
    while(n>0){
        digit+=n%10;
        n/=10;
    }

    if(m%digit==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 1000005
#define db double
#define mod 1000000007
using namespace std;
void solve()
{
	ll x;
	cin >> x;
	db ans = (db)22/(db)7;
	ans = ans*2*(db)x;
	cout << ans;
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(6);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}

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

ll N, L;
string S[1000];

int main(void) {
  cin >> N >> L;
  REP(i, 0, N) cin >> S[i];

  sort(S, S + N);

  ll p[1000];
  REP(i, 0, N) p[i] = -1;
  REP(i, 0, N) if(p[i] == -1) {
    // string s = reverse(S[i].begin(), S[i].end());
    string s = "";
    REP(j, 0, S[i].size()) s += S[i][S[i].size() - j - 1];
    // cout << S[i] << " " << s << endl;
    REP(j, i + 1, N) if(p[j] == -1) {
      if(s == S[j]) {
        p[i] = j;
        p[j] = i;
        break;
      }
    }
  }

  string ans = "";
  vector<string> mid;
  REP(i, 0, N) if(p[i] >= 0) {
    ans += S[i];
    p[p[i]] = -2;
  } else if(p[i] == -1) {
    bool f = true;
    REP(j, 0, S[i].size()) f = f && S[i][j] == S[i][S[i].size() - j - 1];
    if(f) mid.push_back(S[i]);
  }
  sort(mid.begin(), mid.end());

  // cout << (ans + reverse(ans.begin(), ans.end())) << endl;
  cout << ans;
  if(mid.size() > 0) cout << mid[0];
  REP(i, 0, ans.size()) cout << ans[ans.size() - i - 1];
  cout << endl;
}

Measured memory_bytes: 3308
package main

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

func main() {
	sc := newScanner()
	N := sc.nextInt()
	M := sc.nextInt()
	K := sc.nextInt()
	ans := false
	// log.Println(N, M, K)
	for i := 0; i < N+1; i++ {
		for j := 0; j < M+1; j++ {
			black := 0
			black += i * M
			if j > 0 {
				black += j*N - i*j*2
			}
			if K == black {
				ans = true
				// log.Println(i, j)
			}
			// log.Println(i, j, black)
		}
	}
	for i := 0; i < M+1; i++ {
		for j := 0; j < N+1; j++ {
			black := 0
			black = i * N
			if j > 0 {
				black += j*M - (i * j * 2)
			}
			if K == black {
				// log.Println(i * N)
				// log.Println(j*M, i*2)
				// log.Println("a", i, j)
				ans = true
			}
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

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

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}
	return result
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
int a,b,c,d;
scanf("%d", &a);
  
  b=a%10;
  c=(a-a%10)/10%10;
  d=a/100;
  
  if(b==7||c==7){
    printf("Yes\n");
    return 0;
  }
    
  if(d==7){
    printf("Yes\n");
    return 0;
  }

printf("No\n");
return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[105];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	int dis=0;
	for(int i=0;i<n;i++)
	{
		dis+=min(a[i],abs(a[i]-k));
	}
	printf("%d\n",dis*2 );
}
/*int main()
{
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;

	double t=1000000;
	int ts,tw;
	if(a*100+c<=f&&a*e>=c)
	{
		
		int i=min(a*e/c,(f-a*100)/c);
		double t1=100.0*c*i/a*100+c*i;
		if(t>=t1)
		{
			t=t1;
			ts=c*i;
			tw=a*100+c*i;
		}

	}
	if(a*100+d<=f&&a*e>=d)
	{
		int i=min(a*e/d,(f-a*100)/d);
		double t1=100.0*d*i/a*100+d*i;
		if(t>=t1)
		{
			t=t1;
			ts=d*i;
			tw=a*100+d*i;
		}
	}
	if(b*100+c<=f&&b*e>=c)
	{
		int i=min(b*e/c,(f-b*100)/c);
		double t1=100.0*c*i/b*100+c*i;
		if(t>=t1)
		{
			t=t1;
			ts=c*i;
			tw=b*100+c*i;
		}

	}
	if(b*100+d<=f&&b*e>=d)
	{
		int i=min(b*e/d,(f-b*100)/d);
		double t1=100.0*d*i/b*100+d*i;
		if(t>=t1)
		{
			t=t1;
			ts=d*i;
			tw=b*100+d*i;
		}
	}
	printf("%d %d\n",tw,ts );
}*/

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]

M = 10**6+1
L = [0]*M

for a in A:
    if L[a] >= 1:
        L[a] = 2
        continue
    L[a] = 1
    i = 2
    while a*i < M:
        L[a*i] = 2
        i += 1

ans = 0
for a in A:
    if L[a] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 121560
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int get_id(char c){
	if(c>='a'&&c<='z')return c-'a';
	if(c>='A'&&c<='Z')return c-'A'+26;
	return c-'0'+52;
}
char rev(int x){
	if(x<26)return 'a'+x;
	if(x<52)return 'A'+x-26;
	return '0'+x-52;
}
int cnt[66],func[66],n,tot_ask;
string cmp="";
int dp[199][199];
int dist(string s){
	memset(dp,inf,sizeof dp);
	dp[0][0]=0;
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=cmp.size();j++){
			if(j)dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
			if(i)dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
			if(i&&j)dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(s[i-1]!=cmp[j-1]));
		}
	}
	return dp[s.size()][cmp.size()];
}
int ask(string s){
	tot_ask++; 
	#ifdef LOCAL
		return dist(s);
	#endif
	cout<<"? "<<s<<endl;
	fflush(stdout);int x;cin>>x;return x;
}
int Get(string ret,string s,int pos,char c){
	tot_ask++;
	int tot=ret.size()+1+s.size()-pos;
	string ss=ret+c+getstr(s,pos,s.size()-1);
	tot=ss.size();
	#ifdef LOCAL
		return dist(ss)==n-tot;
	#endif
	return n-tot==ask(ss);
}
string merge(string s1,string s2){
	int pos=0;
	string ret="";
	if(rand()&1)swap(s1,s2);
	for(int i=0;i<s1.size();i++){
		while(pos<s2.size()&&Get(ret,s2,pos,s1[i])==0)
		ret.push_back(s2[pos]),pos++;
		ret.push_back(s1[i]);
	}
	while(pos<s2.size())ret.push_back(s2[pos++]);
	return ret;
}
int main(){
	srand(time(0));
	for(int i=0;i<128;i++)cmp.push_back(rev(rand()%62));
	for(int i=0;i<62;i++){
		string s="";s.push_back(rev(i));
		for(int i=0;i<7;i++)s=s+s;
		int got=ask(s);
		cnt[i]=128-got;
	}
	for(int i=0;i<62;i++)n+=cnt[i];
	set<pair<int,string> >s;
	for(int i=0;i<62;i++){
		if(cnt[i]){
			string ins="";
			for(int j=0;j<cnt[i];j++)ins.push_back(rev(i));
			s.insert(make_pair(cnt[i],ins));
		}
	}
	while(s.size()>1){
		string s1=s.begin()->second;s.erase(s.begin());
		string s2=s.begin()->second;s.erase(s.begin());
		string s3=merge(s1,s2);
		s.insert(make_pair(s3.size(),s3));
	}
	cout<<"! "<<s.begin()->second<<endl;
	if(tot_ask>=850-128)assert(0);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

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

    vector<ll> x(n);
    rep(i,n) cin >> x[i];

    vector<ll> y(n);
    rep(i,n) y[i] = x[i];
    sort(all(y));
    ll cent1 = y[(n/2)-1];
    ll cent2 = y[n/2];

    for(int i=0; i<n; i++){
        if(x[i] <=cent1){
            cout << cent2 << endl;
        }
        else{
            cout << cent1 << endl;
        }
    }


}

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

using namespace std;

int dist(vector<int> a, vector<int> b){
    int res = 0;
    for(int i = 0; i < a.size(); i++) res += (a[i] - b[i]) * (a[i] - b[i]);
    return res;
}

bool isSq(int a){
    int rt = 1;
    while(rt * rt < a) rt++;
    return rt * rt == a;
}

int main(){
    int n, d;
    cin >> n >> d;
    vector<vector<int> > pos(n, vector<int>(d));
    for(auto& p: pos) for(auto& i: p) cin >> i;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(isSq(dist(pos[i], pos[j]))) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
//#include <intrin.h>
#include <ctime>
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	sort(A.begin(),A.end(),greater<int>());
	int AA = 0;
	int BB = 0;
	for(int i=0;i<N;++i){
		if( i&1 ){
			BB += A[i];
		}else{
			AA += A[i];
		}
	}
	cout << AA-BB << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

vector<int>E[100];
bool used[200];
int match[200];

bool dfs(int u) {
	used[u] = true;
	for (int v : E[u]) {
		int w = match[v];
		if (w == -1 || (!used[w] && dfs(w))) {
			match[u] = v; match[v] = u;
			return true;
		}
	}
	return false;
}
int x[100], y[100], z[100], a[100], b[100];
double d[100][100];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)scanf("%d%d%d", &x[i], &y[i], &z[i]);
		rep(i, m)scanf("%d%d", &a[i], &b[i]);
		rep(i, n)rep(j, m)d[i][j] = hypot(x[i] - a[j], y[i] - b[j]) / z[i];
		double l = 0, r = 15000;
		rep(i, 42) {
			double t = (l + r) / 2;
			rep(j, n) {
				E[j].clear();
				rep(k, m) {
					if (d[j][k] <= t)E[j].push_back(n + k);
				}
			}
			int cnt = 0;
			memset(match, -1, sizeof(match));
			rep(j, n) {
				if (match[j] == -1) {
					memset(used, 0, sizeof(used));
					cnt += dfs(j);
				}
			}
			if (cnt == m)r = t;
			else l = t;
		}
		printf("%.14lf\n", l);
	}
}

Measured memory_bytes: 3252
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, _, C = map(int, input().split())
    B = tuple(map(int, input().split()))

    ans = 0
    for _ in range(N):
        A = map(int, input().split())
        if sum([i * j for i, j in zip(A, B)]) + C > 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	static int n, m;
	static int[][] node;


	public static void main(String[] args) {
		while(read()){
			solve();
		}

	}

	static boolean read(){
		n = sc.nextInt();
		m = sc.nextInt();
		if(n == 0 && m == 0)  return false;

		node = new int[n][n];  //£sñ

		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(i==j) node[i][j] = 0;
				else     node[i][j] = -1;
			}
		}

		for(int i=0; i<m; i++){
			int node1 = sc.nextInt();
			int node2 = sc.nextInt();
			int cost = sc.nextInt();

			node[node1][node2] = cost;
			node[node2][node1] = cost;
		}

		return true;
	}


	//v@
	static void solve(){
		int sum =0;
		HashSet<Integer> X = new HashSet<Integer>();  //èÏÝW
		HashSet<Integer> Y = new HashSet<Integer>();  //¢èW

		//WÌú»
		X.add(0);
		for(int i=1; i<n; i++){
			Y.add(i);
		}

		//¢èÌWªóÉÈéÜÅ
		while(!Y.isEmpty()){

			//Å¬RXgÌ×Úm[hð²×é
			int min = Integer.MAX_VALUE;
			int min_num = -1, min_num2 = -1;

			for(Iterator<Integer> i1 = X.iterator(); i1.hasNext();){
				int n1 = i1.next();
				for (Iterator<Integer> i2 = Y.iterator(); i2.hasNext();){
					int n2 = i2.next();
					if(node[n1][n2] == -1)  continue;

					if(min > node[n1][n2]){
						min = node[n1][n2];
						min_num = n1;
						min_num2 = n2;
					}
				}
			}

			sum += node[min_num][min_num2];
			Y.remove(min_num2);
			X.add(min_num2);
		}

		System.out.println(sum);  //oÍ
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int a, b; cin >> a >> b;
    if ((a*b) % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

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

template<typename T>
class LazySegmentTree{
    //[l, r)半開区間を扱う
private:
    std::vector<T> node, lazy;
    std::function<T(T, T)> f; // 取得の演算
    std::function<T(T, T)> g; // 更新の演算
    std::function<T(T, int)> pow; // 更新の演算をk回作用させたときの結果

    T f_ide; //演算fの単位元
    T g_ide; //演算gの単位元

    int size;
public:
    LazySegmentTree(int n, std::function<T(T, T)> f, std::function<T(T, T)> g, T f_ide, T g_ide) : 
    f(f),
    g(g),
    f_ide(f_ide),
    g_ide(g_ide)
    {
        init(n);
        pow = [=](T a, int k){
            T ans = g_ide;
            while(k > 0){
                if(k & 1)ans = g(ans, a);
                a = g(a, a);
                k >>= 1;
            }
            return ans;
        };
    }
    LazySegmentTree(int n, std::function<T(T, T)> f, std::function<T(T, T)> g, std::function<T(T, int)> pow, T f_ide, T g_ide) : 
    f(f),
    g(g),
    pow(pow),
    f_ide(f_ide),
    g_ide(g_ide)
    {
        init(n);
    }
    void init(int n){
        size = 1;
        while(size < n)size *= 2;
        node = std::vector<T>(2 * size - 1, f_ide);
        lazy = std::vector<T>(2 * size - 1, g_ide);
    }
    void eval(int k, int l, int r){
        node[k] = g(node[k], pow(lazy[k], r - l));

        if(r - l >= 2){
            lazy[2 * k + 1] = g(lazy[2 * k + 1], lazy[k]);
            lazy[2 * k + 2] = g(lazy[2 * k + 2], lazy[k]);
        }

        lazy[k] = g_ide;
    }
    void update(int a, int b, T x, int k = 0, int l = 0, int r = -1){
        if(r < 0)r = size;
        if(r <= a || b <= l)return;
        
        if(a <= l && r <= b){
            lazy[k] = g(lazy[k], x);
            eval(k, l, r);
        }else{
            update(a, b, x, 2 * k + 1, l, (l + r) / 2);
            update(a, b, x, 2 * k + 2, (l + r) / 2, r);
            eval(2 * k + 1, l, (l + r) / 2);
            eval(2 * k + 2, (l + r) / 2, r);

            node[k] = f(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    T get(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0)r = size;
        if(r <= a || b <= l)return f_ide;

        eval(k, l, r);

        if(a <= l && r <= b){
            return node[k];
        }else{
            T result_left = get(a, b, 2 * k + 1, l, (l + r) / 2);
            T result_right = get(a, b, 2 * k + 2, (l + r) / 2, r);
            return f(result_left, result_right);
        }
    }
};

int main(){
    int n,q;std::cin >> n >> q;
    std::function<long long(long long, long long)> f = [](long long a, long long b){
        return a + b;
    };
    auto g = f;
    LazySegmentTree<long long> Seg(n, f, g, 0, 0);
    while(q--){
        int a;std::cin >> a;
        if(a == 0){
            int s,t,x;
            std::cin >> s >> t >> x;
            Seg.update(s - 1, t, x);
        }else{
            int s,t;
            std::cin >> s >> t;
            std::cout<<Seg.get(s - 1, t)<<std::endl;
        }
    }
}


Measured memory_bytes: 7080
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007



int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(N);

  rep(i, M) {
    int a, b;
    cin >> a >> b;
    v.at(a - 1).push_back(b - 1);
    v.at(b - 1).push_back(a - 1);
  }

  rep(i, N) {
    cout << v.at(i).size() << endl;
  }


}


Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
maze=[['#' for i in range(w+2)]]+[['#']+[x=='#' for x in input()]+['#'] for i in range(h)]+[['#' for i in range(w+2)]]
f=0
for i in range(1,h+1):
  for j in range(1,w+1):
    if maze[i][j]:
	    f+=1
z=0
pos=deque([(1,1,0)])
while pos:
    x,y,c=pos.popleft()
    if (x,y)==(h,w):
        print(h*w-f-c-1)
        z=1
        break
    elif maze[x][y]:
        continue
    pos.append((x-1, y, c+1))
    pos.append((x+1, y, c+1))
    pos.append((x, y-1, c+1))
    pos.append((x, y+1, c+1))
    maze[x][y] = True
if z==0:
	print(-1)

Measured memory_bytes: 3316
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

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

	string S;
	while(cin>>S){
		auto SS = split_naive(S,',');
		int index;
		double h,w;
		sscanf(SS[0].c_str(),"%d",&index);
		sscanf(SS[1].c_str(),"%lf",&w);
		sscanf(SS[2].c_str(),"%lf",&h);
		if(w/h/h>=25){
			out(index);
		}
	}
	return 0;
}


Measured memory_bytes: 3264
d = [0, 0, 0, 0]
for i in range(3):
    a, b = map(int, input().split())
    d[a-1] += 1
    d[b-1] += 1
if d[0] <= 2 and d[1] <= 2 and d[2] <= 2 and d[3] <= 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9132
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    to = [[None]*n for _ in range(60)]
    double = 1
    i = 0
    to[0] = a[:]
    for i in range(1, 60):
        for j in range(n):
            to[i][j] = to[i-1][to[i-1][j]-1]
    num = 2**59
    p = 1
    for i in range(59, -1, -1):
        if k >= num:
            k -= num
            p = to[i][p-1]
        num //= 2
    print(p)
        
    

if __name__ == "__main__":
    main()

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

int main() {
  int X, Y;
  cin >> X >> Y;
  if(Y - 2 * X >= 0 && 4 * X - Y >= 0 && (Y - 2 * X) % 2 == 0 && (4 * X - Y) % 2 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            int a = Integer.parseInt(sl[0]);
            int b = Integer.parseInt(sl[1]);
            int c = Integer.parseInt(sl[2]);

            System.out.println(b - a == c - b ? "YES" :"NO");
        }
    }
}


Measured memory_bytes: 21076
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint 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)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;
typedef pair<plint, lint> tlint;

set<tlint> st;
lint N, Q, s, t, x, d;
int main() {
	cin >> N >> Q;
	REP(i, N) {
		cin >> s >> t >> x;
		if (t - x < 0) continue;

		st.insert({ {max(0ll, s - x) , x}, 0 });
		st.insert({ {t - x, x }, 1 });
	}
	vector<lint> vec;
	multiset<lint> curr;
	map<lint, lint> mp;
	curr.insert(INF);
	vec.push_back(-1);
	mp[-1] = INF;
	for (auto itr : st) {
		if (itr.second == 0) {
			curr.insert(itr.first.second);
			vec.push_back(itr.first.first);
			if (mp.find(itr.first.first) == mp.end()) {
				mp[itr.first.first] = *curr.begin();
			}
			else {
				mp[itr.first.first] = min(mp[itr.first.first], *curr.begin());
			}
		}
		else {
			curr.erase(curr.find(itr.first.second));
			vec.push_back(itr.first.first);
			if (mp.find(itr.first.first) == mp.end()) {
				mp[itr.first.first] = *curr.begin();
			}
			else {
				mp[itr.first.first] = *curr.begin();
				if (*curr.begin() == INF) mp[itr.first.first] = INF;
			}
		}
	}
	REP(i, Q) {
		cin >> d;
		auto itr = upper_bound(vec.begin(), vec.end(), d);
		itr--;
		cout << (mp[*itr] != INF ? mp[*itr] : -1) << endl;

	}
}


Measured memory_bytes: 65524
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 100

void bubbleSort(int A[], int N);

static int count = 0;

int main()
{
    int A[MAX];
    int N;

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

    int flag = 1;
        while (flag) {
            flag = 0;
            for(int j = N - 1; j >= 1; j--) {
                if (A[j] < A[j-1]) {
                    int temp = A[j];
                    A[j] = A[j-1];
                    A[j-1] = temp;
                    flag = 1;
                    ::count++;
                }
            }
        }

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

    cout << ::count << endl;

    return 0;
}



Measured memory_bytes: 3132
N, M = map(int, input().split())

ans = 0
if N == 1 and M == 1:
    ans = 1
elif N == 1 and M > 1:
    ans = M - 2
elif N > 1 and M == 1:
    ans = N - 2
else:
    ans = (N - 2) * (M - 2)

print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
#include<limits.h>
int A[500005],N,c=0,i,tmp[2][250005];
void marge(int l,int m,int r)
{
	int i,j,c1=m-l,c2=r-m;
	for(i=0;i<c1;i++)tmp[0][i]=A[l+i];
	for(i=0;i<c2;i++)tmp[1][i]=A[m+i];
	tmp[0][c1]=tmp[1][c2]=INT_MAX;
	for(i=j=0;i<c1||j<c2;c++)
	{
		if(tmp[0][i]<tmp[1][j])
		{
			A[l+i+j]=tmp[0][i];
			i++;
		}
		else
		{
			A[l+i+j]=tmp[1][j];
			j++;
		}
	}
}

void margeSort(int l,int r)
{
	int m;
	if(l+1<r)
	{
		m=(l+r)/2;
		margeSort(l,m);
		margeSort(m,r);
		marge(l,m,r);
	}
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d",A+i);
	margeSort(0,N);
	for(i=0;i<N;i++)
		printf("%d%c",A[i],i==N-1?'\n':' ');
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  using D = double;
  D l;
  cin>>l;
  vector<D> ts(n),vs(n);
  for(int i=0;i<n;i++) cin>>ts[i]>>vs[i];

  // x, y
  using P = pair<D, D>;
  deque<P> ps;

  D sx=0,sy=0;
  auto get=
    [&](int i){
      return P(ps[i].first+sx,ps[i].second+sy);
    };
  auto put_front=
    [&](P v){
      ps.emplace_front(v.first-sx,v.second-sy);
    };
  auto put_back=
    [&](P v){
      ps.emplace_back(v.first-sx,v.second-sy);
    };
  put_front(P(0,0));
  put_back(P(l,ts[0]*l));

  for(int i=0;i<n;i++){
    while(!ps.empty()){
      D ax=get(ps.size()-1).first;
      D ay=get(ps.size()-1).second;
      assert(ax+vs[i]>=l);
      if(ax+vs[i]==l) break;
      if(ax+vs[i]>l){
        ps.pop_back();
        D bx=get(ps.size()-1).first;
        D by=get(ps.size()-1).second;
        if(bx+vs[i]>=l) continue;
        D p=l-(bx+vs[i]);
        D q=(ax+vs[i])-l;
        D cx=l-vs[i];
        D cy=by+(ay-by)*p/(p+q);
        put_back(P(cx,cy));
      }
    }
    sx+=vs[i];
    sy+=ts[i]*vs[i];
    cout<<get(ps.size()-1).second/l<<"\n";
    while(ps.size()>1){
      P a=get(0),b=get(1);
      if(a.first*b.second-a.second*b.first>=0)
        ps.pop_front();
      else
        break;
    }
    put_front(P(0,0));
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 27540
#include <iostream>
#include <math.h>
using namespace std;
 
int main(void){
    double A,B,N,X,ANS;
  long long int x,a,b,n,ans;
  	scanf("%lf%lf%lf",&A,&B,&N);
  a = A;
  b = B;
  n = N;
  if(B>N){
    X=N;
    ANS = A*X/B;
    ans = ANS;
    printf("%lld",ans);
  }else{
  	X=B-1;
    ANS = A*X/B;
    ans = ANS;
    printf("%lld",ans);
  }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<ll> lucas(100);
    lucas[0] = 2; lucas[1] = 1;
    for(int i = 2; i < 100; i++) {
        lucas[i] = lucas[i - 1] + lucas[i - 2];
    }
    cout << lucas[N] << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
  int x;
  int num[10000];
  for(x= 0;x < 10000;x++){
    scanf("%d", &num[x]);
    if(num[x] == 0) break;
  }
  for(x= 1;x <= 10000;x++){
    if(num[x-1] == 0) break;   
    printf("Case %d: %d\n", x, num[x-1]);
  }
  return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
#define mp make_pair
// #define pb push_back
#define ll long long
#define endl "\n"
using namespace std;


int main() {
	ll h,w;
	cin>>h>>w;
	string s[h];
	ll dp[h][w];
	for(ll i=0;i<h;i++){
		cin>>s[i];
	}
	dp[0][0]=1LL;
	for(ll i=1;i<w;i++){
		if(dp[0][i-1]==1&&s[0][i]=='.'){
			dp[0][i]=1LL;
		}
		else{
			dp[0][i]=0LL;
		}
	}
	for(ll i=1;i<h;i++){
		if(dp[i-1][0]==1&&s[i][0]=='.'){
			dp[i][0]=1LL;
		}
		else{
			dp[i][0]=0LL;
		}
	}
	for(ll i=1;i<h;i++){
		for(ll j=1;j<w;j++){
			if(s[i][j]=='#'){
				dp[i][j]=0LL;
			}
			else{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}









Measured memory_bytes: 13384
#include <bits/stdc++.h>
using namespace std;
int f[200007], have[200007], siz[200007], ans = 1;
int find(int x){
	if(f[x] == x) return x;
	return f[x] = find(f[x]);
}
void merge(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	siz[x] += siz[y];
	ans = max(siz[x], ans);
	f[y] = x; 
}
int main(){
	for(int i = 0; i < 200007; i++) f[i] = i, siz[i] = 1;
	int n, m;
	cin >> n >> m;
	for(int x, y, i = 0; i < m; i++){
		cin >> x >> y;
		merge(x, y);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5148