akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

template<int SZ> struct DSU {
    int par[SZ], sz[SZ];
    DSU() {
        F0R(i,SZ) par[i] = i, sz[i] = 1;
    }
    
    int get(int x) { // path compression
    	if (par[x] != x) par[x] = get(par[x]);
    	return par[x];
    }
    
    bool unite(int x, int y) { // union-by-rank
    	x = get(x), y = get(y);
    	if (x == y) return 0;
    	if (sz[x] < sz[y]) swap(x,y);
    	sz[x] += sz[y], par[y] = x;
    	return 1;
    }
};

DSU<MX> D;

int N,M;
vi v[MX];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    FOR(i,1,N+1) {
        int K; cin >> K;
        F0R(j,K) {
            int x; cin >> x;
            v[x].pb(i);
        }
    }
    FOR(i,1,M+1) F0R(j,sz(v[i])-1) D.unite(v[i][j],v[i][j+1]);
    FOR(i,2,N+1) if (D.get(i) != D.get(1)) {
        cout << "NO";
        exit(0);
    }
    cout << "YES";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 5376
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Prime prime = new Prime();
		prime.addPrime(n);
//		prime.printPrime(n);
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= n; i++) {
			list.addAll(prime.getPrimeFactor(i));
		}
		Map<Integer, List<Integer>> map = list.stream()
			.collect(Collectors.groupingBy(i -> i));
		List<Integer> list2 = map.keySet()
			.stream()
			.map(e -> map.get(e).size())
			.collect(Collectors.toList());
		long ans = 1l;
		for (Integer integer : list2) {
			ans = (ans * (integer + 1) ) % 1000000007;
		}
		System.out.println(ans);
	}
	
	public static class Prime {
		private List<Integer> list = new ArrayList<>();
		public Prime() {
			list.add(2);
			list.add(3);
		}

		/**
		 * リストにn未満の素数があるかを判定する
		 * @return trueであればリストされている
		 */
		public boolean isListed(int n) {
			return list.get(list.size() - 1) >= n;
		}

		/**
		 * n未満の素数を表示する
		 * @param n nの数字
		 */
		public void printPrime(int n) {
			if (!isListed(n)) {
				addPrime(n);
			}
			list.stream()
				.filter(e -> e < n)
				.forEach(System.out::println);
		}

		/**
		 * n未満の整数をリストに追加する
		 * @param n
		 */
		public void addPrime(int n) {
			if (n <= 2) {
				return;
			}
			for (int i = list.get(list.size() - 1) + 2; i < n; i += 2) {
				if (new Check() {
					@Override
					public boolean accept(int i) {
						for (Integer integer : list) {
							int sq = (int) Math.sqrt(i);
							if (integer > sq) {
								return true;
							}
							if (i % integer == 0) {
								return false;
							}
						}
						return true;
					}
				}.accept(i)) {
					list.add(i);
				}
				
			}
		}

		/**
		 * @param n 素因数分解する変数を代入する
		 * @return 素因数因子のリストを返却する
		 */
		public List<Integer> getPrimeFactor(int n) {
			if (!isListed(n + 1)) {
				addPrime(n + 1);
			}
			int a = n;
			List<Integer> list = new ArrayList<>();
			for (int i = 0; i < this.list.size(); i++) {
				int b = this.list.get(i);
				if (a % b == 0) {
					list.add(b);
					i--;
					a /= b;
				}
				if (a < b ) {
					break;
				}
			}
			return list;
		}
	}
	public static interface Check{
		public boolean accept(int i);
	}
}


Measured memory_bytes: 16332
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<int> p={2,5,5,4,5,6,3,7,6};
  vector<bool> q(9,false);
  rep(i,m){
    int x;
    cin>>x;
    q[x-1]=true;
  }

  vector<ll> keta(n+10,-1);
  keta[0]=0;
  rep(i,n){
    if(keta[i]==-1) continue;
    rep(j,9){
      if(q[j]) chmax(keta[i+p[j]],keta[i]+1);
    }
  }

  vector<int> ans;
  int now=n;
  while(now>0){
    for(int i=8;i>=0;i--){
      if(!q[i]) continue;
      if(now-p[i]>=0 && keta[now]==keta[now-p[i]]+1) {
        now-=p[i];
        ans.pb(i+1);
        break;
      }
    }
  }
  
  rep(i,ans.size()){
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

struct Puzzle{
  int f[N2], space, MD;
};

static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1,0,-1,0};
static const char dir[4] = {'r','u','l','d'};
int MDT[N2][N2];
Puzzle state;
int limit;
int path[LIMIT];

int get(Puzzle pz){
  int sum = 0, i;
  for(i = 0; i < N2; i++){
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i] -1];
  }
  return sum;
}
bool isSolved(){
  for(int i = 0; i < N2; i++)
    if(state.f[i] != i + 1) return false;
  return true;
}

bool dfs(int depth, int prev){
  if(state.MD == 0) return true;
  if(depth + state.MD > limit) return false;
  int sx = state.space / N;
  int sy = state.space % N;
  Puzzle tmp;
  for(int r = 0; r < 4; r++){
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
    if(max(prev, r) - min(prev, r) == 2) continue;
    tmp = state;
    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
    swap(state.f[tx * N + ty], state.f[sx * N + sy]);
    state.space = tx * N + ty;
    if(dfs(depth + 1, r)){
      path[depth] = r;
      return true;
    }
    state = tmp;
  }
  return false;
}

string iterdeep(Puzzle in){
  in.MD = get(in);

  for(limit = in.MD; limit <= LIMIT; limit++){
    state = in;
    if(dfs(0, -100)){
      string ans = "";
      for(int i = 0; i <limit; i++)
        ans += dir[path[i]];
      return ans;
    }
  }
  return "unsolvable";
}
int main(){
  for(int i = 0; i < N2; i++){
    for(int j = 0; j < N2; j++){
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
    }
  }
  Puzzle in;
  for(int i = 0; i < N2; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = iterdeep(in);
  cout << ans.size() << endl;

  return 0;
}

Measured memory_bytes: 3188
/* 
Rohit645
Rohit Kumar 
*/

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end() 
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
	fastIo();
	ll a, b, c; cin >> a >> b >> c;
	cout << max(c - (a - b), 0ll) << endl;
	return 0;
}

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

using namespace std;

int main(){
    float A, B;
    cin >> A >> B;
    int A_min = A / 0.08;
    if(A_min * 0.08 < A) A_min += 1;
    int A_max = (A+1) / 0.08;
    if(A_max * 0.08 == A+1) A_max -= 1;
    int B_min = B / 0.1;
    if(B_min * 0.1 < B) B_min += 1;
    int B_max = (B+1) / 0.1;
    if(B_max * 0.1 == B+1) B_max -= 1;
    if(A_max < B_min || A_min > B_max){
        cout << -1 << endl;
        return 0;
    }
    if(A_min < B_min) cout << B_min <<endl;
    else cout << A_min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int m; cin >> m;
    cout << (24-m)+24 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    // long[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
    static void solve(Scanner scanner) {
        String s = scanner.nextLine();
        int N = s.length();
        long[][] dp = new long[N + 1][2];
        dp[0][0] = 1;

        for (int i = 0; i < N; i++) {
            int n = s.charAt(i) - '0';
            dp[i + 1][1] += 3 * dp[i][1];
            dp[i + 1][1] %= MOD;
            if (n == 1) {
                dp[i + 1][0] += 2 * dp[i][0];
                dp[i + 1][0] %= MOD;
                dp[i + 1][1] += dp[i][0];
                dp[i + 1][1] %= MOD;
            } else {
                dp[i + 1][0] = dp[i][0];
            }
        }

        System.out.println((dp[N][0] + dp[N][1]) % MOD);
    }

}


Measured memory_bytes: 30016
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(array[k-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[n-1]-a[0];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    if (n%2==1){
        cout << "No" << endl;
        return 0;
    }
    bool ok=true;
    for(int i=0; i<=(n-1)/2; i++){
        if(s[i]!=s[i+n/2]){
            ok=false;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N, A; cin >> N >> A;

    ll tmp = N % 500;

    if(tmp <= A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[5][5],f[5][5];
int main()
{
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			cin>>a[i][j];
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int k;
		cin>>k;
		for(int j=1;j<=3;j++)
			for(int l=1;l<=3;l++)
				if(a[j][l]==k)
					f[j][l]=1;
	}
	if((f[1][1]&&f[1][2]&&f[1][3])||(f[2][1]&&f[2][2]&&f[2][3])||(f[3][1]&&f[3][2]&&f[3][3])||(f[1][1]&&f[2][1]&&f[3][1])||(f[1][2]&&f[2][2]&&f[3][2])||(f[1][3]&&f[2][3]&&f[3][3])||(f[1][1]&&f[2][2]&&f[3][3])||(f[1][3]&&f[2][2]&&f[3][1]))cout<<"Yes";
	else cout<<"No";
}

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

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

    long long count1 = 0; long long count2 = 0; long long count = 0;
    long long N, K; cin >> N >> K;

    if (K % 2 == 1){
        for (int i = 1; i <= N; ++i) {
            if (i % K == 0){
                ++count;
            }
        }
        cout << count * count * count << endl;
    }
    else if (K % 2 == 0){
        for (int i = 1; i <= N; ++i) {
            if (i % K == 0){
                ++count1;
            }
            else if (i % K == K / 2){
                ++count2;
            }
        }
        cout << count1 * count1 * count1 + count2 * count2 * count2 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	char s[11];
	int i;

	while (scanf(" %10s ", s) != EOF) {
		while (s[1] != '\0') {
			for (i = 0; s[i] != '\0'; i++) {
				s[i] = (s[i] + s[i + 1] - '0' - '0') % 10 + '0';
			}
			s[i - 1] = '\0';
		}
		puts(s);
	}
	return 0;
}

Measured memory_bytes: 524
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

max_ = -1
max_2 = -1
for i in range(n):
    if i == 0:
        tmp = a[i]
        a[i] = 0
        max_ = max(a)
        print(max_)
        a[i] = tmp
        if a[0]>=max_:
            max_ = a[0]
        continue
    else:
        if max_<=a[i]:
            if max_2 == -1:
                tmp = a[i]
                a[i] = 0
                max_2 = max(a)
                print(max_2)
                a[i] = tmp
            else:
                print(max_2)
        else:
            print(max_)

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

int main(){
  int d, n; cin >> d >> n;
  if (n != 100) {
    int ans = 1;
    for (int i = 0; i < d; i++) {
      ans *= 100;
    }
    cout << ans * n << endl;
  } else {
    int ans = 1;
    for (int i = 0; i < d; i++) {
      ans *= 100;
    }
    cout << ans * 101 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    
    scanf("%d %d",&a,&b);
    
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    
    printf("%d %d %f\n",d,r,f);
    
    return 0;
}

Measured memory_bytes: 636
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { //
		Scanner input = new Scanner(System.in);
		long A = input.nextLong();
		String S = input.next();
		String whole = S.substring(0,1);
		String decimal = S.substring(2,4);
		long B = Long.parseLong(whole);
		long C = Long.parseLong(decimal);
		long D = B*100+C;
		long ans = A*D;
		ans/=100;
		System.out.println(ans);
	}	
}

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

using namespace std;

int main()
{
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int money = min(x, y) * min(a+b, 2*c);
	money += abs(x-y) * min(x > y ? a : b, 2*c);
	cout << money << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
struct EDGE { int v,w,nx; }lb[N<<3]; int tot=1,top[N],cur[N];
void add (int u,int v,int w)
{
	lb[++tot]=(EDGE){v,w,top[u]},top[u]=tot;
	lb[++tot]=(EDGE){u,0,top[v]},top[v]=tot;
}
int s,t,dep[N];
bool bfs ()
{
	memcpy (cur,top,sizeof (int)*(t+1));
	memset (dep,0,sizeof (int)*(t+1));
	queue <int> q;
	dep[s]=1,q.push (s);
	while (q.size ())
	{
		int u=q.front (); q.pop ();
		for (int kb=top[u]; kb; kb=lb[kb].nx)
		{
			int v=lb[kb].v,w=lb[kb].w;
			if (w&&!dep[v]) dep[v]=dep[u]+1,q.push (v);
		}
	}
	return dep[t];
}
int dinic (int u,int flow)
{
	if (u==t) return flow;
	int rest=flow;
	for (int &kb=cur[u]; kb; kb=lb[kb].nx)
	{
		int v=lb[kb].v,w=lb[kb].w;
		if (w&&dep[v]==dep[u]+1)
		{
			int k=dinic (v,min (rest,w));
			if (!k) dep[v]=1;
			rest-=k;
			lb[kb].w-=k,lb[kb^1].w+=k;
			if (!rest) break;
		}
	}
	return flow-rest;
}
int n,pos[N],x[N],y[N];
bool vis[N];
void dfs (int u)
{
	int nx=0;
	for (int kb=top[u]; kb; kb=lb[kb].nx)
	{
		int v=lb[kb].v;
		if (v< s&&!vis[v])
		{
			nx=v,vis[v]=1;
			x[nx-n]=u;
			for (int kb=top[nx]; kb; kb=lb[kb].nx)
			{
				int v=lb[kb].v,w=lb[kb].w;
				if (w&&v<=n) { y[nx-n]=v; break; }
			}
			dfs (y[nx-n]);
		}
	}
	

}
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n); s=n<<1,t=s+1;
	for (int i=1; i< n; i++)
	{
		int m,x; sc(m); add (n+i,t,1);
		for (int j=1; j<=m; j++)
			sc(x),add (x,n+i,1);
	}
	for (int i=1; i<=n; i++)
		add (s,i,1),pos[i]=tot;
	int ans=0,flow=0;
	while (bfs ())
		while ((flow=dinic (s,oo))) ans+=flow;
	if (ans!=n-1) return pr(-1),0;
	int rt=0;
	for (int i=1; i<=n; i++)
		if (!lb[pos[i]].w) { rt=i; break; }
	dfs (rt);
	for (int i=1; i< n; i++)
		if (!x[i]) return pr(-1),0;
	for (int i=1; i< n; i++)
		printf ("%d %d\n",x[i],y[i]);

    return 0;
}


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

int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  pair<int, int> a[n];
  for(int i = 0;i < n;i++)
    cin >> a[i].first, a[i].second = i;
  sort(a, a + n);
  int ans[n];
  for(int i = 0;i < n;i++){
    if(i >= n / 2)
      ans[a[i].second] = a[n / 2 - 1].first;
    else{
      ans[a[i].second] = a[n / 2].first;
    }
  }
  for(int i = 0;i < n;i++)
    cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    VL A;
    while(true){
        ll a;
        cin >> a;
        if(a == 0) break;
        A.pb(a);
    }

    rep(i, 0, A.size()) cout << "Case " << i + 1 << ": " << A[i] << endl;

    return 0;
}



Measured memory_bytes: 3152
'use strict'

const main = (input) => {
    input = input.split('\n')
    const h = parseInt(input[0].split(' ')[0])
    const arr = input.slice(1, h + 1)
    const arrC = arr.slice()

    for(let i = 0; i < arr.length; i++){
        console.log(arr[i])
        console.log(arrC[i])
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 9388
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>

using namespace std;

typedef unsigned uint;
typedef long long Int;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }

/*
 無駄をなくしたい！ので，前と横から見て同じ高さの所は同じブロックでまかなうようにする
 それぞれで共通している数字の時は1度だけ足すようにすると OK
*/
int main()
{
	int w, d;
	while (cin >> w >> d, w && d){
		vector <int> c, r;
		int a;
		for (int i = 0; i < w; i++){
			cin >> a;
			c.push_back(a);
		}
		for (int i = 0; i < d; i++){
			cin >> a;
			r.push_back(a);
		}

		int ret = 0;
		for (int i = 0; i < w; i++){
			int now = c[i];
			ret += now;
			for (int j = 0; j < d; j++){
				if (now == r[j]){
					r[j] = 0;
					break;
				}
			}
		}
		// pv(c.begin(), c.end());
		// pv(r.begin(), r.end());
		for (int i = 0; i < d; i++){
			ret += r[i];
		}
		cout << ret << endl;
	}

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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


int main(){
	int A;
	cin>>A;
	cout<<"ABC"<<A<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<numeric>
#include<map>
using namespace std;

#define R(i,s,n) for(int i=s;i<n;i++)
#define D(i,n,s) for(int i=n-1;i>=s;i--)
typedef pair<int,int> P;

const int MAX_M = 1e+2;
const int MAX_N = 5e+5;
const int TAKE = 7368792; //約8e+6;

int M,N;
bool bamboo[TAKE];

void solve();

int main() {

  while(cin>>M>>N && (M || N)) { solve(); }

  return 0;
}

void solve() {
  memset(bamboo,false,sizeof(bamboo));

  R(i,M,TAKE) {
    if(bamboo[i] == true) continue;
    bamboo[i] = true;
    for(int j=i*2;j<TAKE;j+=i) bamboo[j] = true;
    N--;
    if(N==0) break;
  }

  R(i,M,TAKE){
    if(bamboo[i] == false) { cout<<i<<endl; return ; }
  }

  return ;
}



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

long long max1(long long a,long long b){
    if(a>b) return a;
    else return b;
}
int main(void){
    long long a,b,k;
    cin>>a>>b>>k;
    long long temp=a;
    a=max1(0,a-k);
    k=max1(0,k-temp);
    b=max1(0,b-k);
    cout<<a<<" "<<b;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define nax 200009LL
#define mod 1000000009LL
#define FOR(i,m,n) for(int i = (m); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

/*ll power(ll a, ll b, ll mo){
    int ans = 1;
    while(b){
        if (b&1) ans = (ans*a) % mo;
        b /= 2;
        a = (a*a) % mo;
    }
    return ans;
}*/


int main(){
	
	fastio;

	string s;

	cin>>s;
	int n;
	n=s.size();

	for(int i=0; i<n; i++){
		if(s[i] != s[n-1-i]){
			cout<<"No";
			return 0;
		}
	}

	for(int i=0; i<(n-1)/2; i++){
		//si y solo si: s[i]=s[(n-1)/2-i-1];
		if(s[i] != s[(n-1)/2-1-i]){
			cout<<"No";
			return 0;
		}
	}

	for(int i=0; i<(n-1)/2; i++){
		if(s[i+(n+1)/2] != s[(n-1)/2-1-i+(n+1)/2]){
			cout<<"No";
			return 0;
		}
	}

	cout<<"Yes";


	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        bool[][] F = new bool[N][].Select(_ => Console.ReadLine().Split().Select(x => x == "1").ToArray()).ToArray();

        int[][] P = new int[N][].Select(_ => Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray()).ToArray();
        int maxBenefit = int.MinValue;
        for (long i = 1; i < 1024; i++)
        {
            int[] timeCount = new int[N];
            string bitmask = Convert.ToString(i, 2).PadLeft(10,'0');
            for (int j = 0; j < 10; j++)
            {
                if (bitmask[j] == '1')
                {
                    for (int k = 0; k < F.Length; k++)
                    {
                        if (F[k][j])
                        {
                            timeCount[k]++;
                        }
                    }
                }
            }
            int benefit = 0;
            for (int j = 0; j < timeCount.Length; j++)
            {
                benefit += P[j][timeCount[j]];
            }
            maxBenefit = Math.Max(benefit, maxBenefit);
        }
        Console.WriteLine(maxBenefit);
    }
}

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

int main() {
  int l,r,d;
  cin >> l >> r >>d;
  
  int c=0;
  for(int i=l;i<r+1;i++){
    if(i%d==0)	c++;
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define LL long long 
using namespace std;
int dp[1234][1234];
int main(){  
	string s;
	cin>>s;
	printf("%c%d%c\n",s[0],s.size()-2,s[s.size()-1]);
    return 0;  
}  


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

ll solve() {
    ll N, m = 1;
    cin >> N;
    for ( ll i = 1; i*i <= N; i++ ) {
        if ( N % i == 0 ) m = i;
    }
    ll ans = m + N/m - 2;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main(){
    long long a,b,c,d=0,e=0;
    cin>>a>>b>>c;
    while(b>=a){
        b=b-a;
        d++;
    }
    if(d>=c){cout<<c;}
    if(d<c){cout<<d;}
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    string S;
    cin >> S;
    vector<char> T(q), D(q);
    rep(i, q) cin >> T[i] >> D[i];

    int left = -1, right = n;
    int t;
    while (left + 1 < right) {
        t = (left + right) / 2;

        int cur = t;
        bool check = false;
        rep(i, q) {
            if (T[i] == S[cur]) {
                if (D[i] == 'L') --cur;
                else ++cur;
            }
            if (cur == -1) {
                check = true;
                break;
            }
            if (cur == n) {
                break;
            }
        }

        if (check) left = t;
        else right = t;
    }

    int ans1 = right;

    left = -1, right = n;
    while (left + 1 < right) {
        t = (left + right) / 2;

        int cur2 = t;
        bool check = false;
        rep(i, q) {
            if (T[i] == S[cur2]) {
                if (D[i] == 'L') --cur2;
                else ++cur2;
            }
            if (cur2 == n) {
                check = true;
                break;
            }
            if (cur2 == -1) {
                break;
            }
        }

        if (check) right = t;
        else left = t;
    }

    int ans2 = left;

    cout << ans2 - ans1 + 1 << endl;

    return 0;
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()

int main() {
    string s;
    cin >> s;
    int f1 = stoi(s.substr(0, 2)), f2 = stoi(s.substr(2, 2));
    string ans;
    if ((0 < f1 && f1 <= 12) || (0 < f2 && f2 <= 12)) {
        if ((0 < f1 && f1 <= 12) && (0 < f2 && f2 <= 12)) ans = "AMBIGUOUS";
        else if (0 < f1 && f1 <= 12) ans = "MMYY";
        else ans = "YYMM";
    } else ans = "NA";
    printf("%s\n", ans.c_str());
}

Measured memory_bytes: 256
using System;

namespace atcoder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int n = int.Parse(str[0]), k = int.Parse(str[1]);
            if (n % k == 0) Console.WriteLine(0);
            else Console.WriteLine(1);
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
 
/*
struct SegmentTree{
   
  vector<lol> SumV(1000005,0);
  vector<lol> MaxV(1000005,0);
  vector<lol> MinV(1000005,0);
  int N;
   
  void update(int i,int x){
    i += N - 1;
    minv[i] = x;
    maxv[i] = x;
    sumv[i] = x;
    while(i > 0){
      i = (i - 1)/2;
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
    }
  }
   
  void add(int i,int x){
    i += N - 1;
    sumv[i] += x;
    maxv[i] += x;
    minv[i] += x;
    while(i > 0){
      i = (i - 1)/2;
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
    }
  }
   
  int getmax(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return -INF;
    if(a <= l && r <= b) return maxv[k];
    else{
      int c1 = getmax(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmax(a,b,2*k+2,(l+r)/2,r);
      return max(c1,c2);
    }
  }
   
  int getmin(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return minv[k];
    else{
      int c1 = getmin(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmin(a,b,2*k+2,(l+r)/2,r);
      return min(c1,c2);
    }
  }
   
  int getsum(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return sumv[k];
    else{
      int c1 = getsum(a,b,2*k+1,l,(l+r)/2);
      int c2 = getsum(a,b,2*k+2,(l+r)/2,r);
      return c1+c2;
    }
  }
}
*/
 
//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  vector<tuple<string, int, int> > ans;
  int n; cin >> n;
  string s; int num;
  rep(i, n){
    cin >> s >> num;
    ans.emplace_back(s, -num, i + 1);
  }
  sort(all(ans));
  rep(i, n){
    cout << get<2>(ans[i])  << '\n';
  }
  return 0;
}


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong(), d = sc.nextLong();
        long x = b/c + b/d - b/lcm(c, d);
        long y = (a-1)/c + (a-1)/d - (a-1)/lcm(c, d);

        System.out.println((b-a+1)-(x-y));
    }

    private static long lcm(long c, long d) {
        return c * d / gcd(c, d);
    }

    private static long gcd(long a, long b) {
        if (b == 0) return a;
        else return gcd(b, a%b);
    }
}


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

int main(){
    string s;
    cin >> s;
    vector<char> c(4);
    rep(i, 4){
        c[i] = s[i];
    }
    sort(c.begin(), c.end());
    // rep(i, 4){
    //     cout << c[i] << endl;
    // }
    if(c[0]==c[1] && c[1]!=c[2] && c[2]==c[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li h, w;
    cin >> h >> w;

    vector<vector<li>> red(h, vector<li>(w, 0)), blue(h, vector<li>(w, 0));
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            if (s[j] == '#') {
                red[i][j] = 1;
                blue[i][j] = 1;
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        red[i][0] = 1;
        blue[i][w - 1] = 1;
    }

    for (int i = 0; i < h; i += 2) {
        for (int j = 1; j < w - 1; ++j) {
            red[i][j] = 1;
        }
    }

    for (int i = 1; i < h; i += 2) {
        for (int j = 1; j < w - 1; ++j) {
            blue[i][j] = 1;
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << (red[i][j] ? "#" : ".");
        }
        cout << endl;
    }
    cout << endl;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << (blue[i][j] ? "#" : ".");
        }
        cout << endl;
    }
    return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 2 * 1e5;
  int a[max_n + 1], b[max_n + 1];
  pair<int, int> task[max_n + 1];
  cin >> n;
  for(int i = 0; i < n; i++) {
    int a,b;
    cin >> a >> b;
    task[i] = make_pair(b,a);
  }
  sort(task, task+n);
  // for(int i = 0; i < n; i++) cout << task[i].first << "," << task[i].second << endl;

  int now = 0;
  string ans = "Yes";
  for(int i = 0; i < n; i++){
    now += task[i].second;
    if(now > task[i].first) ans = "No";
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5180
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	b := readInt()
	k := (a + b) / 2
	if (a + b) == (k * 2) {
		fmt.Println(k)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

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

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    int inf = 1000000000;
    vector<int> dp(h + 1, inf);
    dp[0] = 0;
    for (int i = 0; i < h; i++) {
        if (dp[i] < inf) {
            for (int j = 0; j < n; j++) {
                dp[min(i + a[j], h)] = min(dp[min(i + a[j], h)], dp[i] + b[j]);
            }
        }
    }

    cout << dp[h] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string S;
    int m, h;
    while(1){
        cin >> S;
        if(S == "-") break;
        cin >> m;
        for(int i=0;i<m;i++){
            cin >> h;
            S = S.substr(h) + S.substr(0, h);
        }
        cout << S << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long int;
using pll = pair<ll,ll>;

ll dist(pll a, pll b){
  return max(abs(a.first-b.first),abs(a.second-b.second));
}

int main(){
  int n,m; cin >> n >> m;
  vector<pll> stu,chk;
  for(int i=0;i<n;i++){
  	ll a,b; cin >> a >> b;
    stu.emplace_back(a-b,a+b);
  }
  for(int i=0;i<m;i++){
  	ll a,b; cin >> a >> b;
    chk.emplace_back(a-b,a+b);
  }
  vector<int> ans;
  for(int i=0;i<n;i++){
    vector<pll> dsc;
    for(int j=0;j<m;j++){
      dsc.emplace_back(dist(stu[i],chk[j]),j+1);
    }
    auto itr = min_element(dsc.begin(),dsc.end());
    ans.push_back(itr->second);
  }
  for(auto a:ans) cout << a << "\n";
  return 0;
}


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

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

  char X; cin >> X;
  ll x = X - 'A';
  string ans = "a";
  if (0 <= x && x <= 25) {
    ans = "A";
  }
  cout << ans << '\n';
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b,k;
    cin >> a >> b >> k;
    rep(i,k){
        if(i % 2 == 0){ 
            if(a % 2 == 1){ 
                a--;
                a /= 2;
                b += a;
            }
            else{
                a /= 2;
                b += a;
            }
        }
        else{
            if(b % 2 == 1){ 
                b--;
                b /= 2;
                a += b;
            }
            else{
                b /= 2;
                a += b;
            }
        }
    }   
    cout << a << ' ' << b << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <complex>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

int main(){
  int n;
  cin >> n;
  while(n--){
    int rec, count = 0, depth = 0;
    int vs[10000], unopen[10000];
    vector<int> G[10000];

    cin >> rec;
    vs[++depth]	  = ++count;
    unopen[depth] = rec;
    
    while(cin >> rec && rec != 0){
      while(depth > 0 && unopen[depth] == 0) depth--;      
      unopen[depth]--;
      if(rec > 0){
	vs[++depth]   = ++count;
	unopen[depth] = rec - 1;
	G[count].push_back(vs[depth-1]);
	G[vs[depth-1]].push_back(count);
      }else{
	G[vs[depth + rec]].push_back(vs[depth]);
	G[vs[depth]].push_back(vs[depth + rec]);
	unopen[depth + rec]--;
      }
    }
    
    REP2(i, 1, count + 1){
      cout << i;
      sort(ALL(G[i]));
      REP(j, G[i].size()) cout << " " << G[i][j];
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1480
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
	ll x, y;
	cin >> x >> y;

	if (y % 2 == 1)
	{
		println("No");
	}
	else
	{
		if (2 * x <= y && y <= 4 * x)
		{
			println("Yes");
		}
		else
		{
			println("No");
		}
	}
}


Measured memory_bytes: 3536
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

void warshallFloyd(vector<vector<ll>> &dp,const int n){
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,m,l;
    cin >> n >> m >> l;
    
    vector<vector<ll>> dp1(n+1,vector<ll>(n+1,INF)),dp2(n+1,vector<ll>(n+1,INF));

    for(int i = 0; i < m; i++){
        ll a,b,c;
        cin >> a >> b >> c;
        dp1[a][b] = c;
        dp1[b][a] = c;
    }

    ll q;
    cin >> q;

    vector<ll> s(q),t(q);
    for(int i = 0; i < q; i++){
        cin >> s[i] >> t[i];
    }

    warshallFloyd(dp1,n);

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(dp1[i][j] <= l){
                dp2[i][j] = 1;
            }
        }
    }

    warshallFloyd(dp2,n);

    for(int i = 0; i < q; i++){
        if(dp2[s[i]][t[i]] >= INF){
            cout << -1 << endl;
        }else{
            cout << dp2[s[i]][t[i]] - 1<< endl;
        }
    }
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;


int main() {
    string s; cin >> s;
    int len = s.length();
    bool flag = true;
    if(s[0] == 'A'){
        int cnt = 0;
        for(int i = 2; i < len - 1; i++){
            if(s[i] == 'C') cnt++;
        }
        if(cnt == 1){
            for(int i = 1; i < len; i++){
                if(s[i] == 'C'){
                    if(cnt == 1){
                        cnt--;
                        continue;
                    }else{
                        flag = false;
                        break;
                    }
                }
                if('a' <= s[i] && s[i] <= 'z'){
                    continue;
                }else{
                    flag = false;
                    break;
                }
            }
        }else{
            flag = false;
        }
    }else{
        flag = false;
    }
    if(flag) cout << "AC" << endl;
    else cout << "WA" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t; cin>>s>>t;
  string ns;
  s += s;
  bool is_match =false;
  for(int i=0; i<s.size()/2; ++i){
    string ns;
    ns = s.substr(i,s.size()/2);
    if( ns == t) {
      is_match = true; break;
    }
  }
  if( is_match) cout<<"Yes";
  else cout<<"No";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) cout << "+" << endl;
	else if (a*b == 15) cout << "*" << endl;
	else cout << "x" << endl;
}

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

int main(){
  ll n,x;
  ll a[100006];
  ll ans = 0;
  ll t;

  scanf("%lld %lld", &n, &x);

  int i;
  for(i = 0;i < n;i++) scanf("%lld", &a[i]);

  for(i = 0;i < n - 1;i++){
    if(a[i] + a[i + 1] <= x) continue;

    t = a[i] + a[i + 1] - x;
    ans += t;

    if(a[i + 1] >= t) a[i + 1] -= t;

    else {
      t -= a[i + 1];
      a[i + 1] = 0;
      a[i] -= t;
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define LEN 1000000
using namespace std;
const int mod=1e9+7;

int n,m,ans=0;
int jc[LEN+5];

int quick_power(int a,int b)
{
	int res=1;
	for (;b;b=b>>1,a=(a*a)%mod)
	{
		if (b&1)  res=(res*a)%mod;
	}
	return res%mod;
}

int ny(int n)
{
	return quick_power(n,mod-2); 
}

int C(int n,int k)
{
	if (k==0||n==k)  return 1;
	if (2*k>n)  k=n-k;
	
	int first=jc[n];
	int second=ny((jc[n-k]*jc[k])%mod);
	
	return (first*second)%mod;
}

int init()
{
	jc[0]=1;
	for (int i=1;i<=LEN;i++)  jc[i]=(jc[i-1]*i)%mod;
}

signed main()
{
	cin>>n>>m;
	init();
	
	for (int tim1=n%2;tim1<=n;tim1+=2)
	{
		int tim2=(n-tim1)/2;
		if (tim1*2+tim2!=m)  continue;
		else ans=(ans+C(tim1+tim2,tim1))%mod;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 8064