akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int32_t main() { 
	
	setIO();

    int n; cin >> n;

    ll mx = -1, res = 0;
    F0R(i,n) {
        ll x; cin >> x;

        if (mx > x) {
            res += mx-x;
        } else mx = x;
    }

    cout << res << "\n";
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> w(n);
    rep(i, n) cin >> w[i];
    vector<ll> dp(n + 1, 0);
    rep(i, n) dp[i + 1] = dp[i] + w[i];
    ll ans = LONG_LONG_MAX;
    rep(i, n) {
        ans = min(ans, abs(dp[n] - dp[i] - dp[i]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
  int a, b, c;
  int count = 0;
  std::cin >> a >> b >> c;
  for(int i=a; i<=b; i++){
    if(c%i==0){
      count++;
    }
  }
  std::cout << count << std::endl;
  
  return 0;
}

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
 int n,r;
  cin>>n;
  r=n%10;
  if(r==3)
  {
    cout<<"bon"<<"\n";
  }
  else if(r==0||r==1||r==6||r==8)
  {
    cout<<"pon"<<"\n";
  }
  else
   {
    cout<<"hon"<<"\n";
  } 
  return 0;
}

Measured memory_bytes: 3104
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        int K = sc.nextInt();
        int[] arr = new int[N];
        for (int i=0; i < N; i++) {
            arr[i]=sc.nextInt();
        }
        Arrays.sort(arr);
        for(int i=1;i<=K;i++){
            ans+=arr[N-i];
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 22996
MOD = 10 ** 9 + 7
K = int(input())
M = len(input())
N = M + K
 
pow25 = [1] * (N + 1)
fac = [1] * (N + 1)
inv = [1] * (N + 1)
for x in range(1, N + 1):
    fac[x] = fac[x - 1] * x % MOD
    pow25[x] = pow25[x - 1] * 25 % MOD
inv[N] = pow(fac[N], MOD-2, MOD)
for x in range(N - 1, -1, -1):
    inv[x] = inv[x + 1] * (x + 1) % MOD
 
def binom(n, k):
    return fac[n] * inv[n - k] % MOD * inv[k] % MOD
 
ans = 0
for k in range(M, N + 1):
    ans += binom(N, k) * pow25[N - k] % MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 150868
<?php

$line = trim(fgets(STDIN));

$words = explode(' ', $line);

foreach ($words as $i => &$w) {
	// カンマ、ピリオドは取り除く
	$w = str_replace(',', '', $w);
	$w = str_replace('.', '', $w);
	if(strlen($w) < 3 || 6 < strlen($w)) {
		unset($words[$i]);
	}
}

echo implode(' ', $words) . "\n";

Measured memory_bytes: 6604
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<long long, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;
struct edge {
	ll from, to, cost;
};

int n;
ll dp[4005][6005] = { 0 };
ll a[6005] = { 0 };

ll dfs(int l, int r) {
	if (dp[l][r] != -1) return dp[l][r];
	int cnt = r - l - 1;
	if (cnt == n) return dp[l][r] = 0;
	else if (cnt % 2 == 1) {
		if (a[l] < a[r]) return dp[l][r] = dfs(l, r + 1);
		else return dp[l][r] = dfs(l - 1, r);
	}
	else {
		return dp[l][r] = max(dfs(l - 1, r) + a[l], dfs(l, r + 1) + a[r]);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = n; i < 2 * n; i++) {
		a[i] = a[i - n];
	}
	for (int i = 2 * n; i < 3 * n; i++) {
		a[i] = a[i - n];
	}
	rep(i, 4005) {
		rep(j, 6005) {
			dp[i][j] = -1;
		}
	}
	ll res = 0;
	for (int i = n; i < 2 * n; i++) {
		res = max(dfs(i - 1, i + 1) + a[i], res);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 191136
#include<bits/stdc++.h>
using namespace std;
int a[1314520];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
	}
	sort(a,a+n);
	int ans1=0,ans2=0;
	for(int i=0;i<n;i++){
		if(i%2==0){
			ans1+=a[i];
		}
		else{
			ans2+=a[i];
		}
	}
	printf("%d\n",abs(ans1-ans2));
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H, W, sh, sw, gh, gw;
bool Grid[1010][1010];
int id[1010][1010];

int64_t INF = (1LL << 62);
int64_t MAXN = 1000010;
vector<vector<pair<int, int>>> Graph(MAXN);

int64_t dijkstra(int64_t start, int64_t goal)
{
  priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>, greater<pair<int64_t, int64_t>>> PQ;
  vector<int64_t> Color(MAXN, 0), D(MAXN, INF);

  D.at(start) = 0;
  PQ.push(make_pair(0, start));
  Color.at(start) = 1;

  while (!PQ.empty())
  {
    pair<int64_t, int64_t> f = PQ.top();
    PQ.pop();
    int64_t u = f.second;
    Color.at(u) = 2;
    if (D.at(u) < f.first)
      continue;
    for (int i = 0; i < (int)(Graph.at(u).size()); i++)
    {
      int64_t v = Graph.at(u).at(i).first;
      if (Color.at(v) == 2)
        continue;
      if (D.at(v) > D.at(u) + Graph.at(u).at(i).second)
      {
        D.at(v) = D.at(u) + Graph.at(u).at(i).second;
        PQ.push(make_pair(D.at(v), v));
        Color.at(v) = 1;
      }
    }
  }
  return D.at(goal);
}

void initId()
{
  int cnt = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      id[i][j] = cnt;
      cnt++;
    }
  }
}

int main()
{
  cin >> H >> W >> sh >> sw >> gh >> gw;
  char c;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> c;
      Grid[i][j] = (c == '.');
    }
  }
  initId();
  vector<int> dh = {-2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2};
  vector<int> dw = {-2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2};
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (!Grid[i][j])
        continue;
      int cur = id[i][j];
      for (int k = 0; k < 25; k++)
      {
        if (dh[k] == 0 && dw[k] == 0)
          continue;
        int nexth = i + dh[k], nextw = j + dw[k];
        if (nexth < 0 || nexth >= H || nextw < 0 || nextw >= W)
          continue;
        if (!Grid[nexth][nextw])
          continue;
        int nextv = id[nexth][nextw];
        if (abs(dh[k]) + abs(dw[k]) == 1)
        {
          Graph.at(cur).push_back({nextv, 0});
        }
        else
        {
          Graph.at(cur).push_back({nextv, 1});
        }
      }
    }
  }
  int64_t ans = dijkstra(id[sh - 1][sw - 1], id[gh - 1][gw - 1]);
  cout << (ans == INF ? -1 : ans) << endl;
}


Measured memory_bytes: 117224
h, w = map(int, input().split())
s = [input().split() for _ in range(h)]
a = [[] for i in range(h)]
dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(h):
    for j in range(w):

        num = 0
        for d in range(8):
            ni = i + dy[d]
            nj = j + dx[d]
            if ni < 0 or h <= ni:
                continue
            if nj < 0 or w <= nj:
                continue
            if s[ni][0][nj] == '#':
                num += 1
        a[i].append(str(num))

for i in range(h):
    for j in range(w):
        if s[i][0][j] == '#':
            a[i][j] = '#'

for i in range(h):
    print(''.join(a[i]))


Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
    void bubbleSort(char a[][3],int n);
    void selectSort(char a[][3],int n);

    void sw(char a[],char b[]);

    char A[200][3];
    char B[200][3];

int main()
{

    int n ;
    scanf("%d",&n);
    for(int i= 0;i<n;i++){
        scanf("%s",A[i]);
        strcpy(B[i],A[i]);
    }


    for(int i= 0;i<n;i++){//バブルソートで変換を行っている
        for(int j=n-1;j>i;j--){
            if(A[j][1] < A[j-1][1]){
                sw(A[j],A[j-1]);
            }
        }
    }

    for(int i = 0;i<n-1;i++){//挿入ソートで変換を行っている
        int ss = i;
        for(int j=i+1;j<n;j++){
            if(B[j][1]<B[ss][1]){
                ss = j;
            }
        }
        if(ss != i){
            sw(B[ss],B[i]);
        }
    }




        for(int i= 0;i<n;i++){
            printf("%s%s",A[i],(i == n-1)? "\n": " ");
            //if(i == n-1) printf("\n");
        }
        printf("Stable\n");

        for(int i= 0;i<n;i++){
            printf("%s%s",B[i],(i == n-1)? "\n": " ");
            //if(i == n-1) printf("\n");
        }

        int stable = 1;
        for(int i= 0;i<n;i++){
            if(strcmp(A[i],B[i])){
                stable = 0;
            }
        }
        printf("%s\n",stable?"Stable":"Not stable");

    return 0;
}

    void sw(char a[],char b[]){
        char tmp[3] = "";
        strcpy(tmp,a);
        strcpy(a,b);
        strcpy(b,tmp);
    }


    void selectSort(char a[][3],int n){

    }





Measured memory_bytes: 2100
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#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 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 FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, M, X;
    cin >> N >> M >> X;

    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    REP(i, N)
    {
        cin >> C[i];
        REP(j, M)
        cin >> A[i][j];
    }

    ll ans = 10000000;

    //どの本を選ぶかを示すフラグ
    REP(i, 1 << N)
    {
        ll sum = 0;
        vector<ll> a(M);
        REP(j, N)
        {
            if (i >> j & 1)
            {
                sum += C[j];
                REP(k, M)
                a[k] += A[j][k];
            }
        }

        bool understand = true;
        REP(j, M)
        {
            if (a[j] < X)
            {
                understand = false;
                break;
            }
        }

        if (understand && (ans > sum))
            ans = sum;
    }

    cout << (ans != 10000000 ? ans : -1) << endl;

    return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsgned ll
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,a[MAXN],b[MAXN];ll ans;
inline void Solve(int l,int r){
	if(l==r){ans+=a[l];return;}
	int mid=l+r>>1,tmp=1e9,i,j;
	Red(i,mid,l)tmp=min(tmp,a[i]),b[i]=tmp;tmp=1e9;
	Rep(i,mid+1,r)tmp=min(tmp,a[i]),b[i]=tmp;
	for(i=mid,j=mid+1;l<=i&&j<=r;){
		if(b[i]>b[j])ans+=1ll*b[i]*(j-mid-1),i--;
		else ans+=1ll*b[j]*(mid-i),j++;
	}for(;i>=l;i--)ans+=1ll*b[i]*(r-mid);for(;j<=r;j++)ans+=1ll*b[j]*(mid-l+1);
	Solve(l,mid),Solve(mid+1,r);
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();Rep(i,1,n)a[i]=read();
	Solve(1,n),cout<<ans<<'\n';
	return 0;
}





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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
    int X,A;
    cin>>X>>A;

    if(X<A)
    {
        cout<<0<<endl;
    }

    else
    {
        cout<<10<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,dis[202020];
set<int>st;
multiset<int>sstt;
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		st.insert(i);
		sstt.insert(0);
	}
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		set<int>::iterator it=st.lower_bound(a),it1;
		int mn=1e9+1e5;
		while(it!=st.end() && *it<=b)
		{
			int x=*it;
			mn=min(mn,dis[x]+b-x);
			it1=it;
			it1++;
			st.erase(it);
			it=it1;
			sstt.erase(sstt.find(dis[x]));
			dis[x]=1e9+1e5;
		}
		if(b!=m && mn!=1e9+1e5)
		{
			dis[b]=mn;
			st.insert(b);
			sstt.insert(mn);
		}
		if(st.empty())
		{
			cout<<"-1\n";
		}
		else
		{
			cout<<*sstt.begin()+i+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 23156
#include <cstdio>
#include <iostream>
#include <cmath>

int main(int argc, char const* argv[]) {
	int N;
	int t[100010], x[100010], y[100010];
	scanf("%d", &N);
	t[0] = 0;
	x[0] = y[0] = 0;
	for (int i = 1; i <= N; i++) {
		scanf("%d %d %d", &t[i], &x[i], &y[i]);
	}
	bool ans = true;
	for (int i = 1; i <= N; i++) {
		int difft = abs(t[i] - t[i - 1]);
		int diffx = abs(x[i] - x[i - 1]);
		int diffy = abs(y[i] - y[i - 1]);
		if (diffx + diffy > difft) {
			ans = false;
		}
		if ((diffx + diffy + difft) % 2 != 0) {
			ans = false;
		}
	}

	printf(ans ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 4860
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#include <complex>

using namespace std;

const int SIZ = 100000;

vector<int> getPrimes() {
    vector<int> primes;
    int sieve[SIZ];
    fill_n(sieve, SIZ, true);
    sieve[0] = sieve[1] = false;
    primes.push_back(2);
    for (int i=4; i<SIZ; i+=2) {
        sieve[i] = false;
    }
    for (int i=3; i*i<SIZ; i+=2) {
        if ( ! sieve[i]) continue;
        for (int j=i*2; j<SIZ; j+=i) {
            sieve[j] = false;
        }
    }
    for (int i=3; i<SIZ; i+=2) {
        if (sieve[i]) primes.push_back(i);
    }
    return primes;
}

int main() {
    ios::sync_with_stdio(false);
    vector<int> primes = getPrimes();
    int m, a, b;
    while (1) {
        cin >> m >> a >> b;
        if (!m && !a && !b) break;
        int tp, tq, p = 0, q = 0, max_m = 0;
        for (int i=0; i<(int)primes.size(); ++i) {
            for (int j=i; j<(int)primes.size(); ++j) {
                tp = primes[i];
                tq = primes[j];
                if (tp * tq < 0) break;
                if (m < tp * tq || b * tp < a * tq) {
                    break;
                }
                if (max_m < tp * tq) {
                    p = tp;
                    q = tq;
                    max_m = tp * tq;
                }
            }
        }
        cout << p << " " << q << endl;
    }
    return 0;
}

Measured memory_bytes: 1716
def main():
    import sys
    input = sys.stdin.readline

    X = int(input())

    i = 0
    var = 100
    while True:
        i += 1
        var *= 1.01
        var = int(var)
        if var >= X:
            print(i)
            exit()


if __name__ == "__main__":
    main()


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

int main()
{
    ll N, K;
    cin >> N;
    vector<ll> P(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }

    ll res = 1;
    ll mi=P[0];
    for (int i = 1; i < N; i++)
    {
        mi = min(mi, P[i]);
        if(P[i] == mi)res++;
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int main(){
 LL an=0, lt=0;
 DRI(N);
 REP(i,N){
  DRI(x);
  if(lt&&x)an++,x--;
  an+=x/2;lt=x%2;
 }cout<<an<<endl;
 return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	static long dp[][][] = new long[3001][3001][2];

	public static void main(String[] args) {
		FastScanner in = new FastScanner();
		int n = in.nextInt();
		int a[] = in.readArray(n);
		long sum = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i];
		}
		long ans = deque(a, 0, n - 1, 0);
		long finalans = 2 * ans - sum;
		System.out.println(finalans);
	}

	public static long deque(int a[], int i, int j, int turn) {
		if (i > j)
			return 0;

		if (dp[i][j][turn] > 0)
			return dp[i][j][turn];

		if (turn == 0) {
			long ans = Math.max(a[i] + deque(a, i + 1, j, 1), a[j] + deque(a, i, j - 1, 1));
			dp[i][j][turn] = ans;
			return ans;
		} else {
			long ans = Math.min(deque(a, i + 1, j, 0), deque(a, i, j - 1, 0));
			dp[i][j][turn] = ans;
			return ans;
		}
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}

Measured memory_bytes: 362636
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  if (a%2 == 0) {
    cout << 0.5 << endl;
  } else {
    double b = a-1;
    b /= 2;
    b += 1;
    cout << b/a << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;
    unsigned int A,B,i = 0;
    cin >> A >> B >> S;
    if(S.size() != (A + B + 1)){cout << "No";return 0;}
    if(S[A] != '-'){cout << "No";return 0;}
    
    for(auto c : S){
        if(i != A && !isdigit(c)){
            cout << "No";return 0;
        }
        i++;
    }
    cout << "Yes";
}


Measured memory_bytes: 256
x,y  = map(int,input().split())

g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]

if x in g1 and y in g1:
  print('Yes')
elif x in g2 and y in g2:
  print('Yes')
elif x in g3 and y in g3:
  print('Yes')
else:
  print('No')

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

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

vector<int> pf;

ll pow_mod(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return pow_mod(x * x % m, n / 2, m);
  else
    return x * pow_mod(x, n - 1, m) % m;
}


void factorization(int x){
    for(int i=2;i*i<=x;++i){
        int tmp=0;
        while(x%i==0){
            x/=i;
            tmp++;
        }
        pf.push_back(tmp);
    }
    if(x!=1)pf.push_back(1);
    return;
}



ll combination_mod(ll x,ll y,ll mod){
    ll res1,res2,res3;
    res1=res2=res3=1;
    ll z=x-y;
    rep(i,1,x+1){
        res1*=i;
        res1%=mod;
    }
    rep(i,1,y+1){
        res2*=i;
        res2%=mod;
    }
    res2=pow_mod(res2,mod-2,mod);
    rep(i,1,z+1){
        res3*=i;
        res3%=mod;
    }
    res3=pow_mod(res3,mod-2,mod);
    res1*=res2;
    res1%=mod;
    res1*=res3;
    res1%=mod;

    return res1;
}

int main(){
    ll n,m;
    ll mod=1000000007;
    cin>>n>>m;
    factorization(m);
    ll ans=1;
    rep(i,pf.size()){
        if(pf[i]==0)continue;
        ans*=combination_mod(pf[i]+n-1,n-1,mod);
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// URL: https://atcoder.jp/contests/abc133/tasks/abc133_b

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int n, d; io.getV(n, d);
  int[][] x; io.getM(n, d, x);

  auto r = 0;
  foreach (i; 0..n)
    foreach (j; i+1..n) {
      auto l = zip(x[i], x[j]).map!(xij => (xij[0]-xij[1])^^2).sum;
      if (l.nsqrt^^2 == l) ++r;
    }

  io.put(r);
}

  pure auto nsqrt(T)(T n)
{
  import std.algorithm, std.conv, std.math, std.range;
  if (n <= 1) return n;
  T m = T(1) << (n.ilogb/2+1);
  return iota(1, m).map!"a*a".assumeSorted!"a <= b".lowerBound(n).length.to!T;
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, ref T v)
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


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

using namespace std;

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

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define present(i, c) ((c).find(i) != (c).end())

#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define fora(i, a, b) for(int i = (a); i < (b); i++)
#define ford(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
	
#define INF 0x3F3F3F3F

//=========================

int H[100001];
int dp[100001];

void run_test() {
	int N; cin >> N;
    for0(i, N) cin >> H[i];
    dp[0] = 0, dp[1] = abs(H[1]-H[0]);
    fora(i, 2, N) dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2]));
    cout << dp[N-1] << endl;
}

//=========================

ifstream infile;
clock_t start__;
void open_func();
void close_func();

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	open_func();
	//int t; cin >> t; while(t--) run_test();
	run_test();
	close_func();
	return 0;	
}

void open_func() {
	//infile = ifstream("input.in"); if(infile.good()) cin.rdbuf(infile.rdbuf());
	start__ = clock();
	cerr << "---" << endl;
}

void close_func() {
	clock_t elapsed = clock()-start__;
	cerr << "---" << endl << "(time " << fixed << setprecision(2) << elapsed * (1.0/CLOCKS_PER_SEC) << "s)" << endl;	
	//if(infile.good()) infile.close();
}


Measured memory_bytes: 1024
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let x: usize = iterator.next().unwrap().parse().unwrap();
    let t: usize = iterator.next().unwrap().parse().unwrap();

    let ans = if n % x == 0 {
        n / x * t
    } else {
        (n / x + 1) * t
    };
    ans.to_string()
}


Measured memory_bytes: 2088
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int n, k;
double tmp, point, ans;

int main() {
    scanf("%d %d", &n, &k);
    ans = (double)0.0;

    for ( int i = 1; i <= n; i++ ) {
        tmp = 1.0 / n;
        point = i;

        while ( point < k ) {
            point *= 2;
            tmp /= 2.0;
        }

        ans += tmp;
    }

    printf("%.10lf\n", ans);
    return 0;
}


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

int main(void){
    int N;
    cin >> N;
    vector<ll> L(N);
    for(int i = 0; i < N; i++) cin >> L[i];
    sort(L.begin(), L.end());
    ll ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            for(int k = j + 1; k < N; k++){
                if(L[i] == L[j] || L[j] == L[k]) continue;
                if(L[k] < L[i] + L[j]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
a = [int(item) for item in input().split()]
ans = a[1]

# Make 2 group at first 
pata = 0
pata += a[3] // 2 * 2
pata += a[4] // 2 * 2
if a[0] % 2 == 1 and a[3] % 2 == 1 and a[4] % 2 == 1:
    pata += 3
pata += a[0] // 2 * 2

# Make 3 group at first 
patb = 0
if a[0] > 0 and a[3] > 0 and a[4] > 0:
    patb += 3
    a[3] -= 1
    a[4] -= 1
    a[0] -= 1
patb += a[3] // 2 * 2
patb += a[4] // 2 * 2
patb += a[0] // 2 * 2

print(ans + max(pata, patb))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define For(i , a , b) for (int i = (a) ; i <= (b) ; i++)
#define Rep(i , n) for (int i = 0 ; i < (n) ; i++)
#define Ford(i , a , b) for (int i = (a) ; i >= (b) ; i--)
 
const int maxn = 506;
const int maxm = 20000 + 123;
int n , m;
int p[maxm];
int cap[maxn] , cost[maxn];
 
void ReadData() {
    scanf("%d%d" , &m , &n); // cakes and boxed
    For(i , 1 , m) scanf("%d" , &p[i]);
    For(i , 1 , n) scanf("%d%d" , &cap[i] , &cost[i]);
}
 
int dp[maxn][maxm];
 
bool maximize(int &a , const int &b) {
    if (a < b) {a = b; return true;} return false;
}
 
bool minimize(int &a , const int &b) {
    if (a > b) {a = b; return true;} return false;
}
 
void Update(int pos , int sum , int val) {
    if (dp[pos][sum] == -1) dp[pos][sum] = val; else minimize(dp[pos][sum] , val);
}
 
void Process() {
    memset(dp , -1 , sizeof(dp));
    dp[0][0] = 0;
    For(i , 0 , n - 1) For(sum , 0 , 20000) if (dp[i][sum] != -1) {
        Update(i + 1 , sum , dp[i][sum]);
        if (sum + cap[i] <= 20000) Update(i + 1 , sum + cap[i + 1] , dp[i][sum] + cost[i + 1]);
    }
 
    Ford(sum , 19999 , 0) if (dp[n][sum + 1] != -1) Update(n , sum , dp[n][sum + 1]);
     
    sort(p + 1 , p + 1 + m); reverse(p + 1 , p + 1 + m);
    long long res = 0;
    long long collect = 0;
    For(i , 1 , m) {
        collect += p[i];
        if (dp[n][i] != -1) {
            res = max(res , collect - dp[n][i]);
        } 
    }
    cout << res << endl;
    //For(i , 1 , m) cout << p[i] << endl; 
}
 
int main() {
   // ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //freopen("./manju.inp" , "r" , stdin); 
 
    ReadData();
    Process();
 
    return 0;   
}

Measured memory_bytes: 41056
#include <stdio.h>
#define N 5

void main()
{
    int x[N];
    scanf("%d %d %d %d %d", &x[0], &x[1], &x[2], &x[3], &x[4]);
    for (int i = 0; i < N; i++)
    {
        if (x[i] == 0)
        {
            printf("%d", i+1);
            break;
        }
    }
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 2001;
int n;
vector<int> adj[mxN];
int val[mxN];
ll sz[mxN];
ll sumd[mxN];
ll best[mxN];
void dfs(int u, int p) {
    sz[u] = val[u];
    ll tot = 0;
    if(p!=u&&adj[u].size()==1)return;
    for(int v:adj[u]) {
        if(v^p) {
            dfs(v, u);
            sz[u]+=sz[v];
            best[v]+=sz[v];
            sumd[v]+=sz[v];
            sumd[u]+=sumd[v];
            tot+=sumd[v];
        }
    }
    ll mx = -1;
    for(int v:adj[u]) {
        if(v^p) {
            mx = max(mx, best[v] - (tot-sumd[v]));
        }
    }
    if(mx<=0) {
        best[u] = tot%2;
    }else {
        best[u] = mx; 
    }
    //cout<<u<<" "<<mx<<" "<<tot<<" "<<best[u]<<" "<<sumd[u]<<"\n";
}
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    string s;
    cin>>s;
    owo(i, 0, n) {
        val[i] = s[i]=='1';
    }
    int a, b;
    owo(i, 0, n-1) {
        cin>>a>>b;
        a--; b--;
        adj[a].senpai(b);
        adj[b].senpai(a);
    }
    ll ans = INF;
    owo(i, 0, n) {
        memset(sz, 0, sizeof(sz));
        memset(best, 0, sizeof(best));
        memset(sumd, 0, sizeof(sumd));
        dfs(i, i);
        if(best[i]==0) {
            ans = min(ans, sumd[i]/2);
        }
    }
    cout<<(ans==INF ? -1 : ans)<<"\n";
    return 0;
}

Measured memory_bytes: 3968
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Bouquet
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

int nck(int n, int k) {
  int f = 1, g = 1;
  for (int i = 1; i <= k; i++) {
    f = (ll)f * (n + 1 - i) % MOD;
    g = (ll)g * i % MOD;
  }

  return (ll)f * powmod(g, MOD - 2) % MOD;
}

/* main */

int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);

  int e = powmod(2, n);
  int ca = nck(n, a), cb = nck(n, b);

  int r = (((e + (MOD - ca)) % MOD + (MOD - cb)) % MOD + (MOD - 1)) % MOD;
  printf("%d\n", r);
  return 0;
}


Measured memory_bytes: 256
while True:
	n=int(input())
	if not n: break
	a=[list(map(int,input().split())) for _ in range(n)]
	t=[[0 for _ in range(n+1)] for _ in range(n+1)]
	for i in range(n):
		for j in range(n):
			t[i][j]=a[i][j]
			t[i][n]+=a[i][j]
			t[n][j]+=a[i][j]
			t[n][n]+=a[i][j]
	for i in range(n+1):
		print("".join(map("{0:>5}".format,t[i])))

Measured memory_bytes: 6720
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int res = 0;
            for (int i = 0; i < s.length() / 2; i++) {
                if (s.charAt(i) != s.charAt(s.length() - 1 - i))
                    res++;
            }
            out.println(res);
        }

    }
}



Measured memory_bytes: 22996
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define cmdMax 10

typedef struct node *link;
struct node{
	int key;
	link left,right;
};

link insert(link head,link z){
	link y=NULL;
	link x=head;
	
	while(x!=NULL){
		y=x;
		if(z->key < x->key)x=x->left;
		else x=x->right;
	}
	
	if(y==NULL)head=z;
	else if(z->key < y->key)y->left=z;
	else y->right=z;
	return head;
}

void preorder(link u){
	if(u==NULL)return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

void inorder(link u){
	if(u==NULL)return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

int find(link u,int key){
	if(u==NULL)return 0;
	if(u->key==key)return 1;
	if(u->key>key)return find(u->left,key);
	return find(u->right,key);
}

int search(link u){
	if(u->left==NULL)return u->key;
	return search(u->left);
}

link delete(link u,int key){
	if(u==NULL)return NULL;
	if(u->key==key){
		if(u->left==NULL && u->right==NULL)return NULL;
		else if(u->right==NULL){
			return u->left;
		}else if(u->left==NULL){
			return u->right;
		}else{
			u->key=search(u->right);
			u->right=delete(u->right,u->key);
		}
	}else if(u->key >key){
		u->left=delete(u->left,key);
	}else{
		u->right=delete(u->right,key);
	}
	return u;
}

int main(void){
	int m,i,key;
	char cmd[cmdMax];
	link head=NULL,z;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%s",cmd);
		if(!strcmp(cmd,"insert")){
			scanf("%d",&key);
			z = malloc(sizeof(*z));
			z->key=key;z->left=NULL;z->right=NULL;
			head=insert(head,z);
		}else if(!strcmp(cmd,"print")){
			inorder(head);
			printf("\n");
			preorder(head);
			printf("\n");
		}else if(!strcmp(cmd,"find")){
			scanf("%d",&key);
			if(find(head,key)!=0)printf("yes\n");
			else  printf("no\n");
		}else if(!strcmp(cmd,"delete")){
			scanf("%d",&key);
			head=delete(head,key);
		}
	}
	return 0;
}

Measured memory_bytes: 14220
import numpy as np
import sys
# from numba import njit


def solve(A, K, div):
    for d in range(div.shape[0] - 1, 0, -1):
        res = div[d]
        B = np.sort(A % res)
        if B[B.shape[0] - 1] == 0:
            return res
        i = 0
        j = B.shape[0] - 1
        cost = res - B[j]
        scost = 0
        while j - i > 0:
            for n in range(i, j):
                scost += B[n]
                if scost >= cost:
                    while scost > cost:
                        j -= 1
                        cost += res - B[j]
                    i = n + 1
                    break
            else:
                i = j
        if K >= cost:
            return res
    return 1


def divisor(d, div):
    r = int(d ** 0.5 - 0.0000001) + 1
    ind = 0
    for i in range(1, r):
        if d % i == 0:
            div[ind] = i
            ind += 1
            div[ind] = d // i
            ind += 1
    if d % r == 0:
        div[ind] = r
        ind += 1
    return ind


line = sys.stdin.readline
N, K = map(int, line().split())
A = np.fromstring(line(), dtype=np.int64, sep=' ')
d = A.sum()
div = np.empty(10 ** 6, dtype=np.int64)
num = divisor(d, div)
div = np.sort(div[:num])
print(solve(A, K, div))


Measured memory_bytes: 12504
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#define N 100000
const int INF = 1 << 30; // > 10^9
int n;
using namespace std;
struct edge : vector<pair<int, int> > {
    void add_edge(int to, int cost) {
        push_back(pair<int, int>(to, cost));
    }
} info[N];
void bfs();
int hoge[N];
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        while (k--) {
            int v, c;
            cin >> v >> c;
            info[u].add_edge(v, c);
        }
    }
    bfs();
    for (int i = 0; i < n; i++) {
        cout << i << " " << hoge[i] << endl;
    }
}
void bfs() {
    fill_n(hoge, n, INF); //hoge ~ hoge + v <- INF
    queue<int> que;
    que.push(0);
    hoge[0] = 0;
    while (!que.empty()) {
        int p = que.front();
        que.pop();
        for (int i = 0; i < info[p].size(); i++) {
            if (info[p][i].second + hoge[p] < hoge[info[p][i].first]) {
                que.push(info[p][i].first);
                hoge[info[p][i].first] = info[p][i].second + hoge[p];
            }
        }
    }
    
}



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

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

    int ans = 0;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1]) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
	int n;

	cin >> n;

	rep(loop, n) {
		string messengers;
		string message;

		cin >> messengers >> message;

		rep(i, messengers.size()) {
			switch (messengers[messengers.size() - 1 - i]) {
			case 'J':
				message = message.substr(message.size() - 1, 1) + message.substr(0, message.size() - 1);
				break;
			case 'C':
				message = message.substr(1) + message.substr(0, 1);
				break;
			case 'E':
				if (message.size() % 2 == 0) {
					message = message.substr(message.size() / 2, message.size() / 2) + message.substr(0, message.size() / 2);
				}
				else {
					message = message.substr(message.size() / 2 + 1, message.size() / 2) + message.substr(message.size() / 2, 1) + message.substr(0, message.size() / 2);
				}
				break;
			case 'A':
				rep(j, message.size() / 2) {
					swap(message[j], message[message.size() - 1 - j]);
				}
				break;
			case 'P':
				rep(j, message.size()) {
					if (message[j] == '0') {
						message[j] = '9';
					}
					else if (message[j] >= '1'&&message[j] <= '9') {
						message[j]--;
					}
				}
				break;
			case 'M':
				rep(j, message.size()) {
					if (message[j] == '9') {
						message[j] = '0';
					}
					else if (message[j] >= '0'&&message[j] <= '8') {
						message[j]++;
					}
				}
				break;
			}
		}

		cout << message << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main(){
	int n;
	cin >> n;
	int a[2*n], b[n], xori = 0, xora = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i], a[i+n] = a[i];
		xora ^= a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
		xori ^= b[i];
	}
	int preA[2*n+10];
	preA[0] = a[0];
	for(int i = 1; i < 2*n; i++){
		preA[i] = preA[i-1] ^ a[i];
	}
	vector<pair<int,int>> ans;
	for(int i = 0; i < n; i++){
		int res = xora ^ xori;
		int w = 100;
		unordered_map<int,int> m;
		while(w--){
			int p = rng() % n;
			m[a[i+p]^b[p]]++;
			if(m.size() >= 2)
				break;
		}
		if(m.size() == 1 && res == 0){
			ans.push_back(make_pair(i,(*(m.begin())).F));
		}
		else if(m.size() == 1 && (*(m.begin())).F == res){
			ans.push_back(make_pair(i,res));
		}
	}
	for(auto x : ans)
		cout << x.F << " " << x.S << endl;

	return 0;
}



Measured memory_bytes: 15084
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

int main()
{
    int a,b;
    cin >> a >> b;
    if(a > b){
        cout << a + a - 1 << endl; 
    }else if (b > a){
        cout << b + b - 1 << endl;
    }else{
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int l, r, d;
    cin >> l >> r >> d;
    int cnt = 0;
    rep(i, l, r + 1) {
        if(i % d == 0) cnt++;
    }
    output(cnt);
    
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		if (X == 7 || X == 5 || X == 3)
			System.out.println("YES");
		else
			System.out.println("NO");
		scanner.close();
	}
}

Measured memory_bytes: 21844