akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func min(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func main() {
	A, B, K := nextInt(), nextInt(), nextInt()
	result := 0
	r := 0

	for i := min(A, B); ; i-- {
		if A%i == 0 && B%i == 0 {
			r++
			if K == r {
				result = i
				break
			}
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

#define dist(x1, y1, x2, y2) sqrtl((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))

int main() {
    init();

    int n; cin >> n;
    vector<ld> X(n), Y(n);
    FOR(i, 0, n)cin >> X[i] >> Y[i];

    function<ld(ld, ld)> calcDist = [&](ld x, ld y) {
        ld ret = 0;
        FOR(i, 0, n)chmax(ret, dist(x, y, X[i], Y[i]));
        return ret;
    };

    function<ld(ld)> solve = [&](ld x) {
        ld l = -1000, r = 1000;
        FOR(loop, 0, 100) {
            ld m1 = (l * 2 + r) / 3, m2 = (l + r * 2) / 3;
            if (calcDist(x, m1) < calcDist(x, m2))r = m2;
            else l = m1;
        }
        return calcDist(x, r);
    };

    ld l = -1000, r = 1000;
    FOR(loop, 0, 100) {
        ld m1 = (l * 2 + r) / 3, m2 = (l + r * 2) / 3;
        if (solve(m1) < solve(m2))r = m2;
        else l = m1;
    }

    cout << solve(r) << "\n";
}

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

typedef long long ll;

inline void solve3(ll *a, ll *b, ll &n){
	ll tmp(0);
	for(int i(0); a[0]*i <= n; ++i){
		ll lef = n - a[0]*i;
		for(int j(0); a[1]*j <= lef; ++j){
			ll lef1 = lef - a[1]*j, t = lef1 / a[2];
			tmp = max(tmp, i*(b[0] - a[0]) + j*(b[1] - a[1]) + t*(b[2] - a[2]));
		}
	}
	n += tmp;
}
	
inline void solve2(ll *a, ll *b, ll &n){
	ll tmp(0);
	for(int i(0); a[0]*i <= n; ++i){
		ll lef = n - a[0]*i, t = lef / a[1];
		tmp = max(tmp, i*(b[0] - a[0]) + t*(b[1] - a[1]));
	}
	n += tmp;
}

inline void solve1(ll *a, ll *b, ll &n){
	ll t = n / a[0];
	n += t*(b[0] - a[0]);
}

signed main(){
	ll n; scanf("%lld", &n);
	ll a[3], b[3];
	for(int i(0); i < 3; ++i){
		scanf("%lld", &a[i]);		
	}
	for(int i(0); i < 3; ++i){
		scanf("%lld", &b[i]);		
	}
	ll t1_0[4], t1_1[4], siz1(0);
	ll t2_0[4], t2_1[4], siz2(0);
	for(int i(0); i < 3; ++i){
		if(a[i] < b[i]) t1_0[siz1] = a[i], t1_1[siz1] = b[i], ++siz1;
		else if(b[i] < a[i]) t2_0[siz2] = b[i], t2_1[siz2] = a[i], ++siz2;
	}
	
	switch(siz1){
	case 1:
		solve1(t1_0, t1_1, n);
		break;
	case 2:
		solve2(t1_0, t1_1, n);
		break;
	case 3:
		solve3(t1_0, t1_1, n);
		break;
	}
	
	switch(siz2){
	case 1:
		solve1(t2_0, t2_1, n);
		break;
	case 2:
		solve2(t2_0, t2_1, n);
		break;
	case 3:
		solve3(t2_0, t2_1, n);
		break;
	}

	printf("%lld\n", n);
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define Rep(i,a) for(int i=0;i<a;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
const int N = (2e5 + 10) * 4, mod = 924844033;
int rev[N], w[2][N], L;
int pow(int a, int b){
	int w = 1;
	for(;b;b >>= 1, a = 1LL * a * a % mod) if (b & 1) w = 1LL * w * a % mod;
	return w;
}
void init(int &n){
	int m = 1, l = 0;
	while (m < n) m <<= 1, l++;
	n = m;
	rep(i,1,n - 1)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (l - 1));
	w[1][n] = pow(5, (mod - 1) >> l);
	dep(i,l - 1,1) w[1][1 << i] = (1LL * w[1][1 << (i + 1)] * w[1][1 << (i + 1)]) % mod;
	w[0][n] = pow(w[1][n], mod - 2);
	dep(i,l - 1,1) w[0][1 << i] = (1LL * w[0][1 << (i + 1)] * w[0][1 << (i + 1)]) % mod;
}
void fft(int *a, int l, int f){
	if (f == -1) f = 0;
	Rep(i,l) if (rev[i] < i) swap(a[i], a[rev[i]]);
	for(int n = 2; n <= l; n <<= 1){
		int mid = n >> 1, wn = w[f][n];
		for(int i = 0; i < l; i += n){
			int w = 1;
			Rep(j,mid){
				int t1 = a[i + j], t2 = 1LL * a[i + j + mid] * w % mod;
				a[i + j] = (t1 + t2) % mod;
				a[i + j + mid] = (t1 - t2) % mod;
				w = 1LL * w * wn % mod;
			}
		}
	}
	int invl = pow(l, mod - 2);
	if (!f) Rep(i,l) a[i] = 1LL * a[i] * invl % mod;
}
int n, a[N], ta[N], b[N], c[N], ans = 0;

struct edge{ int to, pre; } e[N << 1]; int u[N], l = 0;
void ins(int a, int b) { e[++l] = (edge){b, u[a]}, u[a] = l; }
#define v e[i].to
#define reg(i,a) for(int i = u[a]; i; i = e[i].pre)

int sz[N];
void dfs(int x, int f) {
	sz[x] = 1;
	reg(i,x) if (v != f) dfs(v, x), sz[x] += sz[v];
	if (x != 1) a[min(sz[x], n - sz[x])]++;
}

int pw(int a, int b) {
	int w = 1; 
	for(;b;b >>= 1, a = 1LL * a * a % mod) if (b & 1) w = 1LL * w * a % mod; 
	return w; 
}

int fac[N], inv[N];
void init() {
	fac[0] = 1; rep(i,1,n) fac[i] = 1LL * fac[i - 1] * i % mod;
	inv[n] = pw(fac[n], mod - 2); dep(i,n - 1,0) inv[i] = 1LL * (i + 1) * inv[i + 1] % mod;
}

int C(int n, int m) { 
	if (n < m) return 0;
	else return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {
	scanf("%d",&n);
	rep(i,1,n - 1) { int x, y; scanf("%d%d",&x,&y); ins(x, y), ins(y, x); }
	init();
	dfs(1, 0);
	L = n * 2 + 2; init(L);
	rep(i,1,n) ta[i] = 1LL * fac[i] * a[i] % mod, b[i] = inv[n - i];
	fft(ta, L, 1), fft(b, L, 1);
	Rep(i,L) b[i] = 1LL * ta[i] * b[i] % mod;
	fft(b, L, -1);
	memset(ta, 0, sizeof(ta));
	rep(i,1,n) ta[i] = 1LL * fac[i] * a[n - i] % mod, c[i] = inv[n - i];
	fft(ta, L, 1), fft(c, L, 1);
	Rep(i,L) c[i] = 1LL * ta[i] * c[i] % mod;
	fft(c, L, -1);
	rep(k,1,n) {
		int ans = C(n, k) * 1LL * n % mod;
		ans = (ans - 1LL * inv[k] * b[n + k]) % mod;
		ans = (ans - 1LL * inv[k] * c[n + k]) % mod;
		if (ans < 0) ans += mod;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 40320
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<math.h>
using namespace std;

char s[52][52], d[52][52];
int H, W;

int main() {
	cin >> H >> W;
	for (int i = 0; i < H + 2; i++) {
		s[i][0] = '.';
		s[i][W] = '.';
	}
	for (int i = 0; i < W + 2; i++) {
		s[0][i] = '.';
		s[H][i] = '.';
	}
	for (int i = 1; i <= H; i++)for(int j=0;j<W;j++){
		cin >> s[i][j];
	}

	int sw=0;
	for (int i = 1; i <= H; i++)for (int j = 1; j <= W; j++) {
		if (s[i][j] == '#') {
			if (s[i + 1][j] == '.' && s[i][j + 1] == '.' && s[i - 1][j] == '.' && s[i][j - 1] == '.') {
				sw = 1;
				break;
			}
		}
	}
	if (sw == 0)cout << "Yes";
	else cout << "No";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
bool compare(const pair<string,pair<int,int>> &a, const pair<string,pair<int,int>> &b)
{
    if(a.first<b.first)
    return true;
    if(a.first==b.first)
    return a.second.first>b.second.first;
    
    return false;
}
signed main()
{
    int n;
    cin>>n;
    vector<pair<string,pair<int,int>>> v;
    string name;
    int val;
    for(int i=0;i<n;i++)
    {
        cin>>name>>val;
        v.push_back(make_pair(name,make_pair(val,i)));
    }
    sort(v.begin(),v.end(),compare);
    for(int i=0;i<v.size();i++)
        cout<<v[i].second.second+1<<endl;
    
    return 0;
}

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

int main() {
    long long N;
    cin >> N;

    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 0, num = 10;
    while (num <= N) {
        ans += N / num;
        num *= 5;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include<queue>
#include<list>
#include<bits/stdc++.h>

int main()
{

    int n,q,ope,tmp,left,right;

    std::cin>>n;

    std::vector<int> a;

    for(int i = 0; i < n; i++)
    {
        std::cin>>tmp;
        a.push_back(tmp);
    }

    std::cin>>q;

    for(int i = 0; i < q; i++)
    {
        std::cin>>ope>>left>>right;
        if(ope==0)
        {
            std::cout<<*min_element(a.begin()+left,a.begin()+right)<<std::endl;
        }else
        {
            std::cout<<*max_element(a.begin()+left,a.begin()+right)<<std::endl;
        }
    }
    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x>>y;
	cout<<(x-1)*(y-1)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
n = int(input())
L = [0]*(n+1)
mod = 10**9+7
for i in range(2,n+1):
    for j in range(2,int(i**(0.5))+1):
        while i % j == 0:
            L[j] += 1
            i //= j
    if i != 1:
        L[i] += 1
ans = 1
#print(L)
for i in range(2,n+1):
    ans *= 1+L[i]
    ans %= mod
print(ans)

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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;
const int MAX_H = 1e5 + 5;
const int MAX_N = 3e3 + 5;

ll fastExpo(int base, int e) {
    if (e == 0) return 1;
    if (e == 1) return base;
    ll ans = fastExpo(base, e / 2);
    ans = ans * ans % MOD;
    if (e % 2 == 1) ans = ans * base % MOD;
    return ans;
}

namespace modOp {
    int add(int a, int b, int mod = MOD) { return (a + b) % mod; }
    int sub(int a, int b, int mod = MOD) { return (a - b + mod) % mod; }
    int mul(int a, int b, int mod = MOD) { return (ll)a * b % mod; }
    int divide(int a, int b, int mod = MOD) { return (ll)a * fastExpo(b, mod - 2) % mod; }
}
using namespace modOp;

int H, W, N;
pi walls[MAX_N];
int dp[MAX_N];
ll fac[2 * MAX_H], inv[2 * MAX_H];

int f(int a, int b) {
	a += b;
	if (a < 0 || b < 0 || b > a) return 0;
	return mul(fac[a], mul(inv[b], inv[a - b]));
}

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

	fac[0] = inv[0] = 1;
	for (int i = 1; i < 2 * MAX_H; ++i) {
		fac[i] = mul(fac[i - 1], i);
		inv[i] = divide(1, fac[i]);
	}

	cin >> H >> W >> N;
	for (int i = 0; i < N; ++i) {
		cin >> walls[i].ff >> walls[i].ss;
	}
	walls[N] = {H, W};

	sort(walls, walls + N + 1, [](pi a, pi b) {return a.ff + a.ss < b.ff + b.ss;});

	for (int i = 0; i <= N; ++i) {
		dp[i] = f(walls[i].ff - 1, walls[i].ss - 1);
		for (int j = 0; j < i; ++j) {
			if (walls[i].ff >= walls[j].ff && walls[i].ss >= walls[j].ss) {
				dp[i] = sub(dp[i], mul(dp[j], f(walls[i].ff - walls[j].ff, walls[i].ss - walls[j].ss)));
			}
		}
	}

	cout << dp[N] << '\n';

	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  bool ans = a+b+c > 21;
  cout << (ans?"bust":"win") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};



typedef tuple<ll, ll, ll> T;


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

    int N, M; cin >> N >> M;
    UnionFind uni(N);
 
    for(int i=0; i<M; i++){
        int x,y,z; cin >> x >> y >> z;
        x--; y--;
        uni.connect(x, y);
    }
 
    map<int, int> mp;
    for(int i=0; i<N; i++) mp[uni.root(i)]++;
    cout << mp.size() << endl;

	return 0;
}

Measured memory_bytes: 5376
N = int(input())

ans = 0
m = 0
a = 0
r = 0
c = 0
h = 0
mb = False
ab = False
rb = False
cb = False
hb = False

for i in range(N):
    s = input()
    if s[0] == 'M':
        m += 1
        mb = True
    if s[0] == 'A':
        a += 1
        ab = True
    if s[0] == 'R':
        r += 1
        rb = True
    if s[0] == 'C':
        c += 1
        cb = True
    if s[0] == 'H':
        h += 1
        hb = True

num = 0
if mb:
    num += 1
if ab:
    num += 1
if rb:
    num += 1
if cb:
    num += 1
if hb:
    num += 1

if num < 3:
    print(0)
else:
    ans += m*a*r
    ans += m*a*c
    ans += m * a * h
    ans += m*r*c
    ans += m * r * h
    ans += m*c*h
    ans += a*r*c
    ans += a*c*h
    ans += a * r * h
    ans += r*c*h

    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

int main(void) {
  int N; cin >> N;

  vector<int> W(N);
  vector<int> S(N);

  rep(i, N) cin >> W[i];

  S[0] = W[0];
  REP(i, 1, N) {
    S[i] = S[i-1] + W[i];
  }

  int ans = 1 << 30;
  rep(i, N-1) {
    ans = min(ans, abs(S[i] - S[N-1] + S[i]));
  }
  cout << ans << endl;
}


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

using namespace std;

vector<long> Sum(vector<long> array)
{
	long N = array.size()+1;
	vector<long> result(N);
	result[0] = 0;
	for (int i = 1; i < N; i++)
	{
		result[i] = result[i - 1] + array[i-1];
	}
	return result;
}
int main()
{
	long  X, Y, A, B, C, value;
	
	cin >> X >> Y >> A >> B >> C;
	vector<long> Sa(A), Sb(B), Sc(C);
	vector<long> Avalue(A), Bvalue(B), Cvalue(C);
	for (long& a : Avalue) {
		cin >> a;
	}
	for (long& b : Bvalue) {
		cin >> b;
	}
	for (long& c : Cvalue) {
		cin >> c;
	}
	sort(Avalue.begin(), Avalue.end());
	sort(Bvalue.begin(), Bvalue.end());
	sort(Cvalue.begin(), Cvalue.end());
	reverse(Avalue.begin(), Avalue.end());
	reverse(Bvalue.begin(), Bvalue.end());
	reverse(Cvalue.begin(), Cvalue.end());

	Sa = Sum(Avalue);
	Sb = Sum(Bvalue);
	Sc = Sum(Cvalue);
	queue<long> Aq, Bq, Cq,dummy;
	for (int i = 0; i < X; i++)
	{
		Aq.push(Avalue[X - 1 - i]);
	}
	for (int i = 0; i < Y; i++)
	{
		Bq.push(Bvalue[Y - 1 - i]);
	}
	for (int i = 0; i < C; i++)
	{
		Cq.push(Cvalue[i]);
	}
	//しゃくとり累積和
	int s =0, t=0,u=0;
	for (int i = 0; i < C; i++)
	{
		if (Aq.empty() && Bq.empty()) {
			break;
		}

		queue<long>* ref = &Aq;
		if (!Aq.empty() && !Bq.empty()) {
			ref = (Aq.front() <= Bq.front()) ? &Aq : &Bq;
		}
		else if (Aq.empty()) {
			ref = &Bq;
		}
		else if (Bq.empty()) {
			ref = &Aq;
		}
		if ((*ref).front() <= Cq.front()) {
			(*ref).pop();
			Cq.pop();
			u++;
		}

		
	}
	cout << Sa[Aq.size()]+Sb[Bq.size()]+Sc[u];
	return 0;
}

Measured memory_bytes: 7232
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;
#define matrix(T) vector<vector<T>>
#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define pqueue priority_queue
#define pushb push_back
#define fi first
#define se second
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define ABS(x) ( (x)>0 ? (x) : -(x) )
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define init(v) for(auto &a_: v) cin>>a_
#define out(n) cout<<n<<endl

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

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

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

ll nPr(ll n, ll r) {
	if(n<r) return 0;

	ll result=1LL;
	for(ll i=0; i<r; i++) result*=n-i;
	return result;
}

ll nPrP(ll n, ll r, ll p) { // mod pにおけるnPr
	if(n<r) return 0;

	ll result=1LL;
	for(int i=0; i<r; i++) {
		result*=n-i;
		result%=p;
	}
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}


ll N;

void input() {
	cin>>N;
}

void solve() {
	for(ll h=1; h<=3500; h++)for(ll n=1; n<=3500; n++) {
		if(4*h*n-N*n-N*h==0 || (N*h*n)%(4*h*n-N*n-N*h)!=0) continue;
		ll w=(N*h*n)/(4*h*n-N*n-N*h);
		if(w<=0) continue;
		cout<<h<<" "<<n<<" "<<w<<endl;
		return;
	}
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


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

int main(){

  ll n;
  cin>>n;
  ll a[n],i,sum=0;
  for(i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  for(i=0;i<n-1;i++)
    sum+=a[i];
  if(a[n-1]>=sum)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Node {
	int i, id, left, right, parent = -1, sibling = -1, degree = 0, depth = 0, height = 0;

	public Node(int Id, int l, int r) {
		id = Id;
		left = l;
		right = r;
	}
}

public class Main {

	public static void preorder(int i,Node[] node) {
		System.out.print(" " + node[i].id);
		if (node[i].left != -1) {
			preorder(node[i].left,node);
		}
		if (node[i].right != -1) {
			preorder(node[i].right,node);
		}
	}
	public static void inorder(int i,Node[] node) {
        if (node[i].left != -1) {
            inorder(node[i].left,node);
            }
        System.out.print(" " + node[i].id);
        if (node[i].right != -1) {
            inorder(node[i].right,node);
        }
    }
 
    public static void postorder(int i,Node[] node) {
        if (node[i].left != -1) {
            postorder(node[i].left,node);
            }
        if (node[i].right != -1) {
            postorder(node[i].right,node);
        }
        System.out.print(" "+node[i].id);
    }
 

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i, n, id, l, r;
		n = scan.nextInt();
		Node[] node = new Node[n];
		for (i = 0; i < n; i++) {
			id = scan.nextInt();
			l = scan.nextInt();
			r = scan.nextInt();
			node[id] = new Node(id, l, r);
		}
		for (i = 0; i < n; i++) {
			if (node[i].left != -1) {
				node[node[i].left].parent = node[i].id;
				node[node[i].left].sibling = node[i].right;
			}
			if (node[i].right != -1) {
				node[node[i].right].parent = node[i].id;
				node[node[i].right].sibling = node[i].left;
			}
		}
		for (i = 0; i < n; i++) {
			if (node[i].parent == -1) {
				System.out.println("Preorder");
				preorder(i,node);
				System.out.println("\nInorder");
                inorder(i,node);
                System.out.println("\nPostorder");
                postorder(i,node);
				System.out.println("");
				break;
			}
		}
		scan.close();
	}
}


Measured memory_bytes: 26432
n=int(input())
ls=[]
lt=[]
for i in range(n):
    s,t=input().split()
    ls.append(s)
    lt.append(int(t))
x=input()
ans=sum(lt)
tmp=0
for i in range(n):
    tmp+=lt[i]
    if ls[i]==x:
        ans-=tmp
        print(ans)
        exit()






Measured memory_bytes: 3060
using System;

namespace bla2
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split();
            int r = 0;
            for (int i = 0; i < s.Length; i++)
            {
                int c = int.Parse(s[i]);
                while(c % 2 == 0)
                {
                    c /= 2;
                    r++;
                }
            }
            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 13792
num = int(input(''))

maxnum = 1
for i in range(2, int(num ** (1/2) + 1)):
    j = 2
    while True:
        if i ** j > num:
            break
        if i ** j > maxnum:
            maxnum = i ** j
            j += 1
        else:
            j += 1

print(maxnum)

Measured memory_bytes: 2940
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int M, N, K;
  while (cin >> N >> M >> K) {
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> dp = A;
    for (int i = 2; i <= K; i++) {
      vector<ll> ndp(N);
      deque<int> deq = {i - 2};
      for (int j = i - 1; j < N; j++) {
        while (deq.front() < j - M) {
          deq.pop_front();
        }
        ndp[j] = i * A[j] + dp[deq.front()];
        while (!deq.empty() && dp[deq.back()] <= dp[j]) {
          deq.pop_back();
        }
        deq.push_back(j);
      }
      dp = ndp;
    }
    ll res = *max_element(dp.begin(), dp.end());
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 2560
N, M = list(map(int, input().split()))
NList = [0] * N
ACSum = 0
WASum = 0
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s == 'WA' and NList[p-1] != -1:
    NList[p-1] += 1
  elif s == 'AC' and NList[p-1] != -1:
    ACSum += 1
    WASum += NList[p-1]
    NList[p-1] = -1
    
print(str(ACSum) + ' ' + str(WASum))

Measured memory_bytes: 3828
import sys
def input(): return sys.stdin.readline().strip()
S = input()
Q = int(input())
flag = True
f = ''
b = ''
for i in range(Q):
    q = list(input().split())
    if q[0] == '1':
        flag = not flag
    else:
        if flag:
            if q[1] == '1':
                f = q[2] + f
            else:
                b += q[2]
        else:
            if q[1] == '1':
                b += q[2]
            else:
                f = q[2] + f
S = f + S + b
if not flag:
    S = S[::-1]
print(S)

Measured memory_bytes: 4396
import sys
input = sys.stdin.buffer.readline
N = int(input())
T = [0] + list(map(int, input().split()))
sum_T = sum(T)
M = int(input())
# print('sum_T', sum_T)
for _ in range(M):
    p, x = map(int, input().split())
    # print('p, x', p, x)
    t = sum_T - T[p] + x
    print(t)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  char c;cin>>c;
  if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
    P("vowel");
  }else{
    P("consonant");
  }
  return 0;
}


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const string c4[4] = {
	"aabc",
	"ddbc",
	"efgg",
	"efhh"
};

const string c5[5] = {
	"..abc",
	"..abc",
	"ddeef",
	"ggh.f",
	"iihjj"
};

const string c7[7] = {
	"aabbcc.",
	"ddeef..",
	"gg..fhh",
	"..ij..k",
	"..ij..k",
	"....lmn",
	"....lmn"
};

int main() {
	cout.sync_with_stdio(false);

	int n = nxt();
	if (n == 2) {
		puts("-1");
	} else if (n == 7 || n == 11) {
		for (int i = 0; i < 7; ++i) {
			string s(n, '.');
			for (int j = 0; j < 7; ++j) {
				s[j] = c7[i][j];
			}
			cout << s << "\n";
		}
		for (int i = 7; i < n; ++i) {
			string s(n, '.');
			for (int j = 0; j < 4; ++j) {
				s[7 + j] = c4[i - 7][j];
			}
			cout << s << "\n";
		}
	} else if (n % 3 == 0) {
		for (int i = 0; i < n; ++i) {
			string s(n, '.');
			if (i % 3 == 0) {
				s[i] = s[i + 1] = 'a';
			} else {
				s[i - i % 3 + 2] = 'b';
			}
			cout << s << "\n";
		}
	} else {
		int a = n / 4;
		while ((n - a * 4) % 5) {
			a -= 1;
		}
		assert(a >= 0);
		int b = (n - a * 4) / 5;
		int cur = 0;
		for (int i = 0; i < a; ++i) {
			for (int j = 0; j < 4; ++j) {
				string s(n, '.');
				for (int k = 0; k < 4; ++k) {
					s[cur + k] = c4[j][k];
				}
				cout << s << "\n";
			}
			cur += 4;
		}
		for (int i = 0; i < b; ++i) {
			for (int j = 0; j < 5; ++j) {
				string s(n, '.');
				for (int k = 0; k < 5; ++k) {
					s[cur + k] = c5[j][k];
				}
				cout << s << "\n";
			}
			cur += 5;
		}
	}

	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;
int n, ans = 0;
set<pair<int,pair<int,int>>> paths;

int sho[305][305];

main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int a = 1; a <= n; ++a)
    {
        for(int b = 1; b <= n; ++b)
        {
            cin >> sho[a][b];
            if(a != b)paths.insert(mp(sho[a][b],mp(min(a,b),max(a,b))));
        }
    }
    for(int a = 1; a <= n; ++a)
        for(int b = 1; b <= n; ++b)
            for(int z = 1; z <= n; ++z)
                if(sho[a][b] > sho[a][z]+sho[z][b])
                {
                    cout << -1 << endl; exit(0);
                }

    for(auto &path:paths)
    {
        int a = path.dd.ff; int b = path.dd.dd;
        int dist = path.ff;
        int best = dist;
        for(int z = 1; z <= n; ++z)
        {
            if(sho[a][z] < dist and sho[z][b] < dist and sho[a][z]+sho[z][b] == dist)
            {
                best = 0; continue;
            }
        }
        ans += best;
    }
    cout << ans;
}



Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     int a,b,c,d,e,f,g,h,i,j;
     map<string ,int>m;
     map<string,int>m1;
     map<string,int>::iterator it;
     string s;
     string s1;
     cin>>a;
     while(a--)
     {
         cin>>s;
         m[s]++;
     }
     cin>>b;
     while(b--)
     {
         cin>>s;
         m1[s]++;
         m[s]--;
     }
     c=0;d=0;int cnt=0;int ans=INT_MIN;
     for(it=m.begin();it!=m.end();it++)
     {
         c=(*it).second;
         ans=max(c,ans);
     }
     if(ans<0)
     {
         cout<<0<<endl;
     }
     else{cout<<ans<<endl;}

 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100;
const int MAX_W = 10000;

int dp[MAX_N + 1][MAX_W + 1], v[MAX_N], w[MAX_N], N, W;

int main(void) {
  cin >> N >> W;

  for (int j = 0; j <= W; j++)
    dp[0][j] = 0;

  for (int i = 0; i < N; i++)
    cin >> v[i] >> w[i];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j - w[i] < 0) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 7048
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-22 07:16:37
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  vector<int64> a(n + 1), b(n);
  cin >> a >> b;

  int64 ans = 0;

  for (int i = 0; i < n; ++i) {
    if (a[i] > b[i]) {
      ans += b[i];
      a[i] -= b[i];
    } else {
      ans += a[i];
      int64 res = b[i] - a[i];
      a[i] = 0;
      ans += min(res, a[i + 1]);
      a[i + 1] = max(0LL, a[i + 1] - res);
    }
    debug(a);
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)

ll gcd(ll a, ll b){
  ll x;
	while(a!=b){
    if(b==0)break;
    a=a%b;
    x=b;
    b=a;
    a=x;
  }
  return a;
}


int main(){
  int T;
  cin>>T;
  vector<vector<ll>> vec= vector<vector<ll>> (T,vector<ll>(4,0));

  ll A,B,C,D;
  ll a;
  ll g;
  FOR(i,0,T){
    cin>>A>>B>>C>>D;
    if(A<B || D<B){
      cout<<"No"<<endl;
    }
    else if(B<=C){
      cout<<"Yes"<<endl;
    }
    else{
      g = gcd(B,D);
      a=B-g+(A%g);
      if(a<=C) cout <<"Yes"<<endl;
      else cout <<"No"<<endl;

      }
    }
  }


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

int main(){
  int64_t a,b,k;
  cin >> a >> b >> k;
  if (a<k){
    if (a+b-k > 0){
    cout << "0 " << a+b-k << endl;}
    else{cout << "0 0" << endl;}
  }else{
    cout << a-k << " " << b << endl;
  }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[3005], DP[3005][3005];
bool visited[3005][3005];

ll Solve(int L, int R, bool turn){
  if (L > R) return 0;
  if (visited[L][R]) return DP[L][R];

  visited[L][R] = true;
  if (turn){
    ll ans = Solve(L+1, R, false) + A[L];
    ans = max(ans, Solve(L, R-1, false) + A[R]);
    return DP[L][R] = ans;
  }else{
    ll ans = Solve(L+1, R, true) - A[L];
    ans = min(ans, Solve(L, R-1, true) - A[R]);
    return DP[L][R] = ans;
  }
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  cout << Solve(0, N-1, true) << endl;

  return 0;
}


Measured memory_bytes: 58756
import sys
input = sys.stdin.readline
import numpy as np
s = int(input())
L = [s]
n = 1
while True:
    n += 1
    if s % 2 == 0:
        s //= 2
        if s in L:
            print(n)
            sys.exit()
        L.append(s)
    else:
        s = 3 * s + 1
        if s in L:
            print(n)
            sys.exit()
        L.append(s)

Measured memory_bytes: 12420
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1001001001;

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> ans;
	int mina = INF, maxa = -INF, minidx, maxidx;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a < mina) {
			mina = a;
			minidx = i;
		}
		if (a > maxa) {
			maxa = a;
			maxidx = i;
		}
	}
	if (abs(maxa) > abs(mina)) {
		for (int i = 0; i < n; i++) {
			if (i == maxidx) continue;
			ans.emplace_back(maxidx, i);
		}
		for (int i = 0; i < n-1; i++) {
			ans.emplace_back(i, i+1);
		}
	} else {
		for (int i = 0; i < n; i++) {
			if (i == minidx) continue;
			ans.emplace_back(minidx, i);
		}
		for (int i = n-1; i > 0; i--) {
			ans.emplace_back(i, i-1);
		}
	}
	cout << ans.size() << endl;
	for (auto e : ans) {
		cout << e.first+1 << ' ' << e.second+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

const int MAXN = 100010;

int n, x[MAXN], a[MAXN], w[MAXN], L, T;
LL cur;

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d%d%d", &n, &L, &T );
	for( int i = 0 ; i < n ; i++ )
	{
		scanf( "%d%d", &a[ i ], &w[ i ] );
		if( w[ i ] == 1 )
		{
			x[ i ] = ( a[ i ] + T ) % L;
			cur += ( a[ i ] + T ) / L;
		}
		else
		{
			x[ i ] = ( a[ i ] - T ) % L;
			cur += ( a[ i ] - T ) / L;
			if( x[ i ] < 0 ) x[ i ] += L, cur--;
		}
	}
	cur = ( cur % n + n ) % n;
	sort( x, x + n );
	for( int i = cur ; i < n ; i++ ) printf( "%d\n", x[ i ] );
	for( int i = 0 ; i < cur ; i++ ) printf( "%d\n", x[ i ] );
}


Measured memory_bytes: 2432
function main(input) {
const a = input.split(" ").map(Number);
  console.log(a[0]==a[1]-a[2] || a[0]==a[2]-a[1] || a[0]==a[1]+a[2]?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29532
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<math.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)

#define INF 1050000000

//cout << fixed << setprecision(15) << sum << endl; 実数の出力


int main() {

	int N;

	

	cin >> N;

	vector<int> A(N);

	rep(i, N) {
		cin >> A[i];
	}

	vector<int> X(N);

	long int sum = 0;

	rep(i, N) {
		sum += pow(-1, i) * A[i];
	}

	X[0] = sum;

	repr(i, 1, N) {
		X[i] = 2 * A[i - 1] - X[i - 1];
	}

	rep(i, N) {
		cout << X[i] << ' ';
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 2048
N = gets.to_i
as = gets.split.map(&:to_i)
N.times do |i|
    as[i] -= i+1
end

as.sort!

if N%2==0
    med = (as[N/2-1] + as[N/2])/2
else
    med = as[N/2]
end

ans = 10**20
(-10..10).each do |d|
    sum = 0
    b = med+d
    N.times do |j|
        sum += (b-as[j]).abs
    end
    ans = sum if ans > sum
end
puts ans


Measured memory_bytes: 17544
S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(i + 1, N + 1):
        ss = S[i:j]
        for c in ss:
            if not c in ("A", "C", "G", "T"):
                break
        else:
            ans = max(ans, len(ss))
print(ans)

Measured memory_bytes: 8892
#include <cstdio>
#include <numeric>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <array>
using i64 = long long;
using namespace std;

const int mod = 1e9 + 7;
const int maxh = 1e5;
const int maxw = 1e5;
array<int, 2> r[3002];
int dp[3002];
int f[maxh + maxw + 1];
int fi[maxh + maxw + 1];

int pow_mod(int b, int e) {
  int r = 1;
  while (e) {
    if (e & 1) r = (i64) r * b % mod;
    e >>= 1;
    b = (i64) b * b % mod;
  }
  return r;
}

void precompute_factorials() {
  f[0] = 1;
  for (int i = 1; i <= maxh + maxw; i++) {
    f[i] = (i64) f[i - 1] * i % mod;
  }
  fi[maxh + maxw] = pow_mod(f[maxh + maxw], mod - 2);
  for (int i = maxh + maxw - 1; i >= 0; i--) {
    fi[i] = (i64) fi[i + 1] * (i + 1) % mod;
  }
}

int ways(array<int, 2> &a, array<int, 2> &b) {
  int dx = b[0] - a[0];
  int dy = b[1] - a[1];
  if (dy < 0) {
    return 0;
  }
  return (i64) f[dx + dy] * fi[dx] % mod * fi[dy] % mod;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  precompute_factorials();  

  int H, W, N;
  cin >> H >> W >> N;
  r[0][0] = 1;
  r[0][1] = 1;
  r[N + 1][0] = H;
  r[N + 1][1] = W;
  for (int i = 1; i <= N; i++) {
    cin >> r[i][0] >> r[i][1];
  }

  sort(r + 1, r + (N + 1));
  // cout << r[1][0] << " " << r[1][1] << "\n";
  dp[0] = 1;
  for (int i = 1; i <= N + 1 ; i++) {
    dp[i] = ways(r[0], r[i]);
    for (int j = 1; j < i; j++) {
      dp[i] = (dp[i] + mod - (i64) dp[j] * ways(r[j], r[i]) % mod) % mod;
    }
  }

  cout << dp[N + 1] << '\n';
}

Measured memory_bytes: 1920
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
using namespace std;
const long long mod = 1000000007;
bitset<1000001> bs;
vector<long long> primes;
vector<long long> factors[1000001];
void sieve() {
	bs.set();
	bs[0] = bs[1] = 0;
	for (long long i = 2; i <= 1000000; ++i) {
		if (bs[i]) {
			primes.push_back(i);
			for (long long j = i; j <= 1000000; j += i) bs[j] = 0, factors[j].push_back(i);
		}
	}
}
long long mp(long long b, long long e) {
	if (e == 0) return 1;
	long long a = mp(b, e / 2);
	a = a * a % mod;
	if (e % 2) a = a * b % mod;
	return a;
}
int main() {
	sieve();
	int N;
	scanf("%d", &N);
	long long A, p2 = 0, mp1 = 1;
	map<long long, long long> p1;
	for (int i = 0; i < N; ++i) {
		scanf("%lld", &A);
		for (long long j: factors[A]) {
			long long k = 0;
			for (long long ta = A; ta % j == 0; ++k) ta /= j;
			p1[j] = max(p1[j], k);
		}
		p2 = (p2 + mp(A, mod - 2)) % mod;
	}
	for (pair<long long, long long> i: p1) mp1 = (mp1 * mp(i.first, i.second)) % mod;
	printf("%lld", (mp1 * p2) % mod);
	return 0;
}

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

    divisors.sort()
    return divisors
div = make_divisors(N)
tmp = []
if len(div)%2 == 0:
    tmp.append(div[int(len(div)/2)])
    tmp.append(div[int(len(div)/2-1)])
else:
    tmp.append(div[len(div)//2])
    tmp.append(div[len(div)//2])
ans = 0
ans = sum(tmp)-2
print(ans)

Measured memory_bytes: 3296
n, m = map(int, input().split())

num_list = []
for i in range(n):
    num_list.append(list(map(int,input().split())))
    
allpoint = 0
retu_point = []

for i in range(n):
    print(*num_list[i], end="")
    print(" ", end ="")
    print(sum(num_list[i]))
    

for i in range(m):
    tmp = 0
    for j in range(n):
        tmp += num_list[j][i]
        
    retu_point.append(tmp)
    
print(*retu_point, end ="")
print(" ", end ="")
print(sum(retu_point))



Measured memory_bytes: 6220
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long N[5];
	for (long long i = 0; i < 5; i++)
	{
		cin >> N[i];
	}

	string s;
	//cin >> s;

	//int A[5]
	//sort(A, A + 5);
	for (long long i = 0; i < 5; i++)
	{
		if (N[i] == 0)
		{
			cout << i + 1 << endl;
			break;
		}
	}


}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

const long long int MAX_N = 10000, MAX_A = 1000000000;

int main(int argc, char const *argv[]) {
  long long int n, a[MAX_N];
  cin >> n;
  for (size_t i = 0; i < n; i++) cin >> a[i];
  long long int bi[30];
  bi[0] = 1;
  for (size_t i = 1; i < 30; i++) bi[i] = bi[i-1] * 2;
  vector<long long int> vec;
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 29; j > 0; j--) {
      if (a[i]%2 != 0) {
        vec.push_back(0);
        break;
      }
      else if (a[i] % bi[j] == 0) {
        vec.push_back(j);
        break;
      }
    }
  }
  long long int ans = accumulate(vec.begin(), vec.end(), 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
S = list(input())
form = "0"+str(len(S)-1)+"b"
ans = 0
if len(S)==1:
    print(int(S[0]))
else:
    for i in range(2**(len(S)-1)):
        b = format(i, form)
        eq = [S[0]]
        for j in range(len(b)):
            if b[j] == "1":
                sign = "+"
            else: sign = ""
            eq.append(sign)
            eq.append(S[j+1])
        eqstr = str("".join(eq))
        ans += eval(eqstr)
    print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,X;
cin>>N>>X;
vector<int>M(N);
for(int i=0;i<N;i++){
    cin>>M[i];
    X-=M[i];
}
sort(M.begin(),M.end());
cout<<X/M[0]+N;
return 0;
}


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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

int n, A[MAX], B[MAX];

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

	cin>>n;
	for(int i=1; i<=n; i++) cin>>A[i];
	for(int i=1; i<=n; i++) cin>>B[i];

	lint p=0, q=0;
	for(int i=1; i<=n; i++){
		int x = max(0, (B[i]-A[i])/2);
		int y = max(0, A[i]-B[i]);
		p += x;
		q += y;
	}
	cout<<(p>=q ? "Yes" : "No")<<'\n';

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;

int main()
{
    string s;
    char tmp;
    int n, k;
    cin >> n >> s >> k;

    tmp = s[k - 1];
    for(int i = 0;i < n;i++){
        if(s[i] == tmp){
            ;
        }
        else{
            s[i] = '*';
        }
    }

    cout << s;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int h, a;
  readf("%s %s\n", &h, &a);
  writeln(h/a+(h%a>0));
}


Measured memory_bytes: 256
def main():
    U, D, L, R = "U", "D", "L", "R"
    sx, sy, tx, ty = map(int, input().split())
    dx = tx - sx
    dy = ty - sy
    print(R * dx + U * dy
    +  L * dx + D * dy
    + D * 1
    +  R * (dx + 1) + U * (dy + 1 )
    + L
    + U
    + L * (dx + 1) + D * (dy + 1 )
    + R)
    return


main()


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

#define ll long long

const int MOD = 1e9 + 7;

int main(int argc, char **argv) {
	int d, t, s;
	cin >> d >> t >> s;
	double time = (double) d / s;
	if (time <= t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <math.h>

int main(void) {
	int a,b,c,d;
	scanf("%d",&a);
	b = pow(a,2.0);
	c = pow(a,3.0);
	d = a+b+c;
	printf("%d",d);
	return 0;
}

Measured memory_bytes: 2532
n = input()

if(len(n)%2==1):
  print ("No")
  exit()
i=0
while (i<len(n)):
  if i % 2 == 0:
    if n[i] != 'h':
      print('No')
      exit()
  else:
    if n[i] != 'i':
      print('No')
      exit()
  i = i+1
print('Yes')


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007


//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}


int main(){
	int k, n;
	scanf("%d%d", &n, &k);
	int pro[n];
	for(int i=0; i<n; i++){
		scanf("%d", &pro[i]);
	}

	int sum=0;
	for(int i=0; i<k; i++){
		sum += pro[i];
	}
	int max = sum;
	for(int i=k; i<n; i++){
		sum = sum+ pro[i]-pro[i-k];
		if(max<sum) max = sum;
	}
	max += k;
	double ans = (double)max/2;
	
	printf("%lf\n", ans);
	
	return 0;
}

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

long long n,t=1,ans=0;
int main(){
scanf("%lld",&n);
while (n!=1){
	n=n/2;
	ans=ans+t;
	t=t*2;
}
ans=ans+t;
printf("%lld",ans);
return 0;
}

Measured memory_bytes: 256