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

//諸機能
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion


ll gcd(ll x, ll y) { if (y == 0) return x; gcd(y, x% y); }




int main() {
	int n; put n;
	vector<ll> t; t.resize(n);
	vector<ll> a; a.resize(n);
	rep(i, n) {
		put t[i] >> a[i];
	}
	ll x, y;
	x = t[0]; y = a[0];
	REP(i,1 ,n) {
		ll xmod = x % t[i];
		ll ymod = y % a[i];
		x += xmod == 0 ? 0 : ( t[i] - xmod );
		y += ymod == 0 ? 0 : ( a[i] - ymod );
		ll xdiv = x / t[i];
		ll ydiv = y / a[i];
		ll div = max(xdiv, ydiv);
		x = div* t[i];
		y = div* a[i];
		dbg2(x, y);
	}

END:
	putans(x + y);
	return 0;
}

//int x, y, e; put x >> y >> e;
//int s = x + y;
//int t = s + 1;
//rep(i, x) {
//	addEdge(s, i, 1);
//}
//rep(i, y) {
//	addEdge(x + i, t, 2);
//}
//rep(i, e) {
//	int xi, yi;
//	put xi >> yi;
//	addEdge(xi, x + yi, 5);
//}
//cout << maxFlowDinic(s, t) << endl;

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}


int main(){
    ll a,b,c,x,y,n,m,h,k,max=-10000000,min=1000000000,ans=0,sum=0;
    string s,t;
    //VI a(n);
    cin >> n;
    for(int i=1; i<n;i++){
        int j=n-i;
        if(i!=j && i<j)
            ans++;
    }
    cout << ans << endl;
    return 0;
}
  


Measured memory_bytes: 256
def fin *res
  puts res.flatten.join ' '
  exit
end

num, price, = gets.split.map(&:to_i)
price /= 1000
fin(num, 0, 0)   if price == num * 10
fin(0, 0, num)   if price == num
fin(-1, -1, -1)  if price < num + 4 || num * 10 - 5 < price
num.step(0, -1) do |b10|
  next  if price < b10 * 10
  (num - b10).step(0, -1) do |b5|
    b1 = num - b10 - b5
    fin b10, b5, b1  if b10 * 10 + b5 * 5 + b1 == price
  end
end
fin(-1, -1, -1)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, Q;
vector<vector<int>> G(200000);
int p[200000] = { 0 };
int x[200000] = { 0 };
ll ans[2000000] = { 0 };
void dfs(int S, int P) {
    for(int i : G[S]) {
        if(i != P) {
    ans[i] += ans[S];
    dfs(i, S); 
        }
    }
}


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

     for(int i = 0; i < N - 1; i++) {
         int a, b;
         cin >> a >> b;
        G[a - 1].push_back(b - 1);
        G[b - 1].push_back(a - 1);

     }
    for(int i = 0; i < Q; i++) {
        cin >> p[i] >> x[i];
    }

    for(int i = 0; i < Q; i++) {
        ans[p[i] - 1] += x[i];
    }

    dfs(0, -1);
    for(int i = 0; i < N; i++) cout << ans[i] << " ";
    
    return 0;
}



Measured memory_bytes: 27136
def main():
	N, X = map(int, input().split())
	x = list(map(int, input().split()))
	x.append(X)
	x.sort()
	diff = [0]*N
	for i in range(N):
		diff[i] = x[i+1] - x[i]

	def gcd(a, b):
		if (b == 0):
			return a
		else:
			return gcd(b, a%b)
	ans = diff[0]
	for c in diff[1:]:
		ans = gcd(ans, c)

	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 15020
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

class Edge {
    int to;
    int cost;
    this(int to, int cost) {
        this.to = to;
        this.cost = cost;
    }
    override string toString() {
        return "Edge(" ~ to.to!string ~ ", " ~ cost.to!string ~ ")";
    }
}

string swapchar(in string s, int x, int y) {
    char[] ret = cast(char[])s.dup;
    swap(ret[x], ret[y]);
    return cast(string)ret;
}

void main() {
    int N; scanf("%d\n", &N);
    int[][] C = new int[][](N, N);
    foreach (i; 0 .. N) {
        foreach (j; 0 .. N) {
            scanf("%d", &C[i][j]);
        }
    }
    const X = "012345678";
    string x = X[0 .. N];

    struct S {
        string v;
        int cost;
    }
    BinaryHeap!(Array!S, "a.cost > b.cost") PQ;
    int[string] D; D[x] = 0;
    PQ.insert(S(x, 0));
    while (!PQ.empty) {
        S s = PQ.front; PQ.removeFront;
        foreach (i; 0 .. N) {
            foreach (j; i + 1 .. N) {
                string to = swapchar(s.v, i, j);
                if (to in D && s.cost + C[i][j] >= D[to]) continue;
                D[to] = s.cost + C[i][j];
                PQ.insert(S(to, D[to]));
            }
        }
    }
    //writeln(G);
    writeln(D.reduce!max);
}

Measured memory_bytes: 19340
#include <stdio.h>
int main(){
	int Pos[12];
	int *p;
	int car;
	int i;

	p=Pos;
	for(i=0;i<12;i++){
		Pos[i]=-1;
	}

	while(scanf("%d",&car)!=EOF){
//printf("car--%d\n",car);
		if(car){
			p++;
			*p=car;
		}
		if(!car){
			printf("%d\n",*p);
			p--;
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	list<int> B;
	bool HasAns = true;
	vector<int> Ans(N + 1);
	for (int i = 1; i <= N; i++) {
		int b;
		cin >> b;
		B.push_back(b);
	}
	for (int j = N; j >= 1; j--) {
		auto itr = B.end();
		HasAns = false;
		for (int i = B.size(); i >= 1; i--) {
			itr--;
			if (*itr == i) {
				Ans[j] = i;
				HasAns = true;
				B.erase(itr);
				break;
			}
		}
		if (!HasAns) break;
	}
	if (HasAns) for (int i = 1; i <= N; i++) cout << Ans[i] << endl;
	else cout << -1 << endl;
}

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

int main(){
    
  int a;
  cin>>a;
  string s;
  cin>>s;
  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
  
  
  
  
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int a, b;
    cin >> a >> b;

    if(a < b){
        for(int i = 0; i < b; i++){
            cout << a;
        }
    } else {
        for(int i = 0; i < a; i++){
            cout << b;
        }
    }
    cout << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, m;
    cin >> n >> m;
    vector<string> strs;
    string s;
    for(int i = 0; i < n; i++) {
        cin >> s;
        strs.push_back(s);
    }
    vector<int> dir = {-1, 0, 1, 0, -1};
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if (strs[i][j] == '#') {
                bool single = true;
                for(int d = 0; d < 4; d++) {
                    int ii = i + dir[d];
                    int jj = j + dir[d+1];
                    if (ii >= 0 && ii < n && jj >= 0 && jj < m) {
                        if (strs[ii][jj] == '#')
                            single = false;
                    }
                }
                if (single) {
                    cout << "No" << endl;
                    return 0;
                }
            }

        }
    }
    cout << "Yes" << endl;
    return 0;
}




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

int main(){
    ll n,r; cin >> n >> r;
    if(n>=10){
        cout << r << endl;
    }else{
        cout << r + (100*(10-n)) << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY (1<<30)
using namespace std;

int h,heap[22000001];

void maxheap(int i){
  int l,r,lage;
  
  l=i*2;
  r=i*2+1;
  lage=i;

  if(l<=h&&heap[l]>heap[lage])lage=l;
  if(r<=h&&heap[r]>heap[lage])lage=r;
  
  if(lage!=i){
    swap(heap[i],heap[lage]);
    maxheap(lage);
  }
  
  return;
}

void increasekey(int i,int key){
  if(key<heap[i])return ;
  
  heap[i]=key;
  while(i>1&&heap[i/2]<heap[i]){
    swap(heap[i/2],heap[i]);
    i=i/2;
  }
}

void insert(int key){
  h++;
  heap[h]=-INFTY;
  increasekey(h,key);
}

int extract(){
  int maxv;
  if(h<1) return -INFTY;
  maxv=heap[1];
  heap[1]=heap[h];
  h--;
  maxheap(1);
  return maxv;
}
  
int main(){
  int key;
  string com;
  
  cin >> com;
  while(com!="end"){
    if(com=="insert"){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
    
    cin >> com;
  }
  
  return (0);
}



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


int main(){
    long long X, Y, Z;
    cin >> X >> Y;

    if(X >= Y){
        if(X%Y == 0){
            cout << -1 << endl;
        } else cout << X << endl;
    } else {
        cout << X << endl;
    } 
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define inf 1e18
#define int long long int 
#define pb push_back
#define mp make_pair
#define pq priority_queue<int> 
#define pqs priority_queue<int,vector<int>, greater<int>>
#define setbits(x) __builtin_popcountll(x)  // no of ones in setbit
#define zrobits(x) __builtin_ctzll(x)       //101000 here 3..no of 0 aftrer 1sr right one 
#define mod 1000000007
#define ps(x,y)  fixed<<setprecision(y)<<x  // ans upto 5 decimal place 
#define mk(ar,n,type) type *arr=new type[n];
#define w(x) int x; cin>>x;while(x--)
#define MAX 3000 
int dp[MAX+1][MAX+1] ;  



void getLCS(string& s1, string &s2, int len )
{
	vector<char> v;
	int i=0 ; 
	int j=0 ; 

	while(len> 0)
	{
		if(s1[i]== s2[j]) 
		{
			v.push_back(s1[i]); 
			i++;
			j++;
			len-- ; 
		}
		else
		{
			if(dp[i][j+1]> dp[i+1][j])
			{
				j++; 
			}
			else
			{
				i++ ; 
			}

		}
	}

	// for(int k=0 ; k<len; k++)
	// {
	// 	cout<<v[k]; 
	// }

	// cout<<v[0]<<v[1]<<v[2]; 
	for(auto &i : v)
	{
		cout<<i; 
	}


}




int fn(string&  s1, string& s2, int i, int j)
{

	if(i>=s1.length()  || j>=s2.length())
	{
		return 0 ; 
	}

	if(dp[i][j] != -1)
	{
		return dp[i][j] ; 
	}

	if(s1[i]==s2[j])
	{
		return dp[i][j] = 1+fn(s1,s2,i+1, j+1); 
	}
	else
	{
		return  dp[i][j]=  max( fn(s1, s2, i+1, j), fn(s1, s2, i,j+1)) ; 
	}

}




int32_t main()
{
	string s1, s2; 
	cin>>s1>>s2; 
	memset(dp, -1, sizeof(dp)) ; 
	int z= fn(s1, s2, 0, 0); 
	getLCS(s1,s2,z) ; 
}


Measured memory_bytes: 70912
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn gcd(x: i64, y: i64) -> i64 {
  if y == 0 {
    x
  } else {
    gcd(y, x % y)
  }
}

fn f(a: i64, c: i64, d: i64) -> i64 {
  let g = gcd(c, d);
  let m = c * d / g;
  a - a / c - a / d + a / m
}

fn main() {
  input! {
    a: i64,
    b: i64,
    c: i64,
    d: i64,
  }

  println!("{}", f(b, c, d) - f(a - 1, c, d));
}


Measured memory_bytes: 4352
#1-3 queue
from collections import deque
n,q=map(int,input().split())
queue = deque([])
for i in range(n):
    a,b=input().split()
    queue.append([a,int(b)])

clock=0
while len(queue)>0:
    now=queue.popleft()
    if now[1]>q:
        queue.append([now[0],now[1]-q])
        clock+=q
    else:
        print(now[0],clock+now[1])
        clock+=now[1]


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll K;
VL d;

signed main() {
    cin >> K;
    d.assign(K, LINF);
    PQG<PL> pqg;
    FOR(i, 1, 10) {
        d[i % K] = min(d[i % K], i);
        pqg.emplace(d[i % K], i % K);
    }
    while(pqg.size()) {
        PL t = pqg.top();
        pqg.pop();
        if(t.fi != d[t.se]) continue;
        REP(i, 10) {
            ll nx = (t.se * 10 + i) % K;
            ll nc = t.fi + i;
            if(d[nx] > nc) {
                d[nx] = nc;
                pqg.emplace(nc, nx);
            }
        }
    }
    cout << d[0] << "\n";
}


Measured memory_bytes: 7152
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a<b){
    for(int i=0;i<b;i++){
      printf("%d",a);
    }
  }
  else{
    for(int i=0;i<a;i++){
      printf("%d",b);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define mod 1000000007
#define ll long long
ll n,k;
ll ans[100010];
ll quickpow(ll a,ll b){
	ll ans=1;
	while(b!=0){
		if(b%2==1)ans=(ans%mod*a%mod)%mod;
		b=b/2;
		a=(a%mod*a%mod)%mod;
	} 
	return ans;
}
int main(){
	scanf("%lld %lld",&n,&k);
	for(ll i=k;i>=1;i--){
		ans[i]=quickpow(k/i,n);
		for(ll j=(ll)2*i;j<=k;j=j+i){
			ans[i]=(ans[i]-ans[j]+mod)%mod;
		}
	}
	ll res=0;
	for(ll i=1;i<=k;i++){
		res=(res+i*ans[i])%mod;
	}
	printf("%lld\n",res);
}


Measured memory_bytes: 2428
#include <stdio.h>

int gcd(int x, int y) 
{
	int smaller, bigger, divisor, mod_num;
	int i;

	if(x < y) {
		smaller = x;
		bigger = y;
	} else {
		smaller = y;
		bigger = x;
	}
	mod_num = bigger % smaller;
	if(mod_num == 0)
			return smaller;
	for(i = 1; i < mod_num; i++) {
		if(smaller % i == 0 && mod_num % i == 0) 
			divisor = i;
	}
	return divisor;
}

int main(void) 
{
	int x, y;

	scanf("%d", &x);
	scanf("%d", &y);
	printf("%d\n", gcd(x, y));

	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <tuple>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
int n,m;
int x[100];

int main(){
  int a = 0,b = 0,c,d;
  cin >> n;
  rep(i,0,n){
    cin >> c >> d;
    if(a < c){
      a = c;
      b = d;
    }
  }
  print(a + b);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const int maxn = 1e9+5;
const dd eps = 1e-6;
const ll mod = 1e9+7;
int n;
ll k;
ll a[N];
ll g(ll now,ll lim){
  ll v = a[now];
  if(!v) return (lim >= 0) ? n-1:0;
  int l = 1,r = n,ans = (v<0)?n+1:0;  
  while(l <= r){
    ll mid = (l+r)/2;
    if(v*a[mid] <= lim){
      ans = mid;
      if(v < 0) r = mid-1;
      else l = mid + 1;
    }
    else{
      if(v < 0) l = mid + 1;
      else r = mid - 1;
    }
  }
  ll cnt = 0;
  if(v < 0){
    if(now >= ans) cnt = -1;
    cnt += (ll)(n - ans + 1);
  }
  else{
    if(ans >= now) cnt = -1;
    cnt += (ll)ans;
  }
  return cnt;
}

ll check(ll lim){
  ll ans = 0;
  for(int i = 1;i <= n;i++){
    ans += g(i,lim);
  }
  return ans/2;
}

int main(){
  // freopen("input.txt","r",stdin);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  for(int i = 1;i <= n;i++) cin>>a[i];
  sort(a+1,a+1+n);
  ll l = -1000000000000000009,r = -l,ans;
  while(l <= r){
    ll mid = (l+r)/2;
    if(k <= check(mid)){
      ans = mid;
      r = mid-1;
    }
    else l = mid + 1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll n;
mat a(20,vec(2));
ll dfs(set<ll> odd, ll res, ll id) {
  ll ans=inf;
  if(id==n) {
    vector<pll> od,ev;
    for(ll i=0;i<n;i++) {
      if(odd.count(i)) {
        ll tmp=a[i][(i+1)%2];
        od.push_back({tmp,i});
      }
      else {
        ll tmp=a[i][i%2];
        ev.push_back({tmp,i});
      }
    }
    sort(od.begin(),od.end());
    sort(ev.begin(),ev.end());
    vector<pll> so;
    for(ll i=0;i<n;i++) {
      if(i%2) {
        so.push_back(od[i/2]);
      }
      else {
        so.push_back(ev[i/2]);
      }
    }
    ll f=0;
    for(ll i=0;i<n-1;i++) {
      if(so[i].first>so[i+1].first) f=1;
    }
    if(f) return ans;
    ans=0;
    vec num(n);
    for(ll i=0;i<n;i++) {
      num[i]=i;
    }
    for(ll i=0;i<n;i++) {
      ll tmp=i;
      while(num[tmp]!=so[i].second) {
        tmp++;
      }
      for(ll j=tmp;j-1>=i;j--) {
        ll ch=num[j];
        num[j]=num[j-1];
        num[j-1]=ch;
        ans++;
      }
    }
  }
  else {
    if(res<n-id) ans=min(ans,dfs(odd,res,id+1));
    if(res!=0) {
      odd.insert(id);
      res--;
      ans=min(ans,dfs(odd,res,id+1));
    }
  }
  return ans;
}
 
int main() {
  cin >> n;
  for(ll i=0;i<2;i++) for(ll j=0;j<n;j++) cin >> a[j][i];
  set<ll> b;
  ll ans=dfs(b,n/2,0);
  if(ans==inf) ans=-1;
  cout << ans << endl;
}

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

int main() {
  double a,b,H,M,pi;
  cin >> a >> b >> H >> M ;
  pi=acos(-1);
 

  
  cout << fixed << setprecision(20)
    <<sqrt((a*a)+(b*b)-(a*b*2*cos((H*pi/6) - (M*pi*11/360))))<<endl;
  
}


Measured memory_bytes: 4252
/*
 * drish1001
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>  
#include <iostream> 
using namespace __gnu_pbds; 
using namespace std;
#define     pb                 push_back
#define     mp                 make_pair
#define     ff                 first
#define     ss                 second
#define    MOD                1000000007
#define     pll                pair<ll,ll>
void        sorta(auto &v)     {sort(v.begin(),v.end());} 
void        sortd(auto &v)     {sort(v.begin(),v.end(), greater<>());} 
void        fast()            {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef        long long        ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> magic; 

//all variables and functions be1ow this ..
vector<vector<ll>> v;
vector<ll> vis;
ll cnt;

ll dfs(ll i)
{
	vis[i]=1;
	cnt++;
	for(auto x : v[i])
	{
		if(!vis[x])
			dfs(x);
	}
	return cnt;
}

int main()
{
     fast();
	ll n, e;
	cin >> n >> e;
	v.resize(n+1);
	ll ans=-1;
	vis.resize(n+1, 0);
	for(ll i=0;i<e;i++)
	{
		ll x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	for(ll i=1;i<=n;i++)
	{
		cnt=0;
		if(!vis[i])
		{
			cnt = dfs(i);
		}
		if(ans<cnt)
			ans = cnt;
	}
	cout << ans << endl;
	
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  string S;
  cin >> S;
  vector<int> cnt(4, 0);
  REP(i,S.length()) {
    if(S[i] == 'N') cnt[0]++;
    else if(S[i] == 'W') cnt[1]++;
    else if(S[i] == 'S') cnt[2]++;
    else cnt[3]++;
  }
  if(cnt[0] + cnt[2] > 0 && cnt[0] * cnt[2] == 0) {
    cout << "No" << endl;
  }else if(cnt[1] + cnt[3] > 0 && cnt[1] * cnt[3] == 0) {
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}



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

using namespace std;

const long long INF=1000000000005;

int main()
{
	int N,M,R;
	cin >> N >> M >> R;
	vector<int> r;
	for(int i=0;i<R;i++)
	{
		int tmp;
		cin >> tmp;
		r.push_back(--tmp);
	}


	vector<vector<long long> > dist(N,vector<long long>(N,INF));

	for(int i=0;i<N;i++)
		dist[i][i]=0;

	for(int i=0;i<M;i++)
	{
		int a,b,c;
		cin >> a >> b >> c;
		dist[a-1][b-1]=c;
		dist[b-1][a-1]=c;
	}
	
	for(int k=0;k<N;k++)
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
			{
				if(dist[i][j]>dist[i][k]+dist[k][j])
					dist[i][j]=dist[i][k]+dist[k][j];
			}
	
	vector<int> conb;
	for(int i=0;i<R;i++)
		conb.push_back(i);

	long long ans=INF;
	do
	{
		long long tmp=0;
		for(int i=1;i<R;i++)
		{
			tmp+=dist[r[conb[i-1]]][r[conb[i]]];
		}
		if(tmp<ans)
			ans=tmp;
	
	}while(next_permutation(conb.begin(),conb.end()));

	cout << ans << endl;
}




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

using namespace std ;

const long long inf = 1e18 ;
const int MAX = 1e5 + 10 ;

int arr[MAX] ;
long long x , k , d ;

long long ans = inf ;

void check(long long a)
{
	long long b = (x - a) / d ;
	if(b > k || b % 2 != k%2)
		return ;
	ans = min(ans , abs(a)) ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>x>>k>>d ;
	if(x < 0)
		x *= -1ll ;
	check(x % d) ;
	check(x % d - d) ;
	if(ans == inf)
		ans = x - k*d ;
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll N,C,K; cin>>N>>C>>K;
    vec d;
    rep(i,N){
        ll x; cin>>x;
        d.pb(x);
    }
    sort(ALL(d));
    //cout<<"arrived"<<endl;

    ll H=0, ans=0;
    while(true){
        
        ll B=d.at(H)+K;
        ll M=upper_bound(ALL(d),B)-d.begin(); M--;
        H=min(H+C,M+1);
        ans++;
        if(H==N) break;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6;
ll a[N],sum,n,m;
int main() {
    cin>>n>>m;
    ll x;
    for(int i=1;i<=m;i++) cin>>x,sum+=x;
    n-=sum;
    if(n<0) printf("-1");
    else printf("%lld\n",n);

}


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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());                   //昇順
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());    //降順
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper); 
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define SetPre(x) setprecision(x)

int main(void){
    string S,T;
    cin >> S;
    cin >> T;
    ll count=0;
    
    REP(i,S.length())
    {
        if( S.at(i) != T.at(i) ) count++;
    }
    cout << count;
    
    return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
	optimizar_io

	int x;
	map<int,int> cnt;

	for (int i = 0; i < 3; i++) {
		cin >> x;
		cnt[x]++;
	}
	if (cnt.size() == 2)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func bsearch(a []int, k int) bool {
	left, right := 0, len(a)-1
	for left <= right {
		mid := left + (right-left)/2
		if a[mid] == k {
			return true
		} else if a[mid] < k {
			left = mid + 1
		} else {
			right = mid - 1
		}
	}
	return false
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt(sc)
	}
	wtr := bufio.NewWriter(os.Stdout)
	q := nextInt(sc)
	for i := 0; i < q; i++ {
		k := nextInt(sc)
		if bsearch(a, k) {
			fmt.Fprintln(wtr, "1")
		} else {
			fmt.Fprintln(wtr, "0")
		}
	}
	wtr.Flush()
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    string S;
    cin >> S;
    bool front = true;
    deque<ll> X;
    rep(i, S.size()) {
        X.push_back(S[i]);
    }
    ll Q;
    cin >> Q;
    rep(q, Q) {
        ll t;
        cin >> t;
        if (t == 1) {
            front ^= true;
        } else {
            ll f;
            cin >> f;
            char c;
            cin >> c;
            if (f == 1 == front) {
                X.push_front(c);
            } else {
                X.push_back(c);
            }
        }
    }
    string ans;
    while (!X.empty()) {
        ans += X.front();
        X.pop_front();
    }
    if (!front) reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------



///--------------------------

int main()
{
    Phuong_;
    int h,n;
    cin >> h >> n;
    vector<int> a(h+1);
    const int inf = 1e9;
    for(int i=1; i<=h; ++i) a[i] = inf;
    a[0]=0;
    for(int i=1; i<=n; ++i)
    {
        int u,v;
        cin >> u >> v;
        for(int j=0; j<=h; ++j)
        {
            int id = min (j+u,h);
            a[id] = min(a[id],a[j]+v);
        }
    }
    cout << a[h];
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int p;
    int money[4];
    int cp[4];
    int k=0;
    while(cin>>p,p){
        if(k!=0) cout<<endl;
        k++;
        for(int i=0;i<4;i++) cin>>money[i],cp[i]=money[i];
        int sum=0;
        sum+=money[0]*10;
        sum+=money[1]*50;
        sum+=money[2]*100;
        sum+=money[3]*500;
        sum-=p;
        money[3]=sum/500;
        sum%=500;
        money[2]=sum/100;
        sum%=100;
        money[1]=sum/50;
        sum%=50;
        money[0]=sum/10;
        if((cp[0]-money[0])>0){
            cout<<"10 "<<cp[0]-money[0]<<endl;
        }
        if((cp[1]-money[1])>0){
            cout<<"50 "<<cp[1]-money[1]<<endl;
        }
        if((cp[2]-money[2])>0){
            cout<<"100 "<<cp[2]-money[2]<<endl;
        }
        if((cp[3]-money[3])>0){
            cout<<"500 "<<cp[3]-money[3]<<endl;
        }
        
    }
    return 0;
}



Measured memory_bytes: 2988
#include <stdio.h>
#include <stdlib.h>

int uf_table[100];

void uf_init(void) {
	int i;
	for(i=0;i<100;i++)uf_table[i]=0;
}

void uf_merge(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	if(a!=b)uf_table[a]=b+1;
}

int uf_issame(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	return a==b;
}

typedef struct {
	int a,b;
	int weight;
} connect_t;

int qsort_comp(const void* x,const void* y) {
	const connect_t* a=(const connect_t*)x;
	const connect_t* b=(const connect_t*)y;
	if((a->weight)>(b->weight))return 1;
	if((a->weight)<(b->weight))return -1;
	return 0;
}

int choten_num;
int connection_num;
connect_t connections[100*(100-1)/2];

int main(void) {
	int i,j;
	int count;
	int result,now_result;
	while(1) {
		scanf("%d%d",&choten_num,&connection_num);
		if(choten_num==0 && connection_num==0)break;
		for(i=0;i<connection_num;i++) {
			scanf("%d%d%d",&connections[i].a,&connections[i].b,
				&connections[i].weight);
			connections[i].a--;
			connections[i].b--;
		}
		qsort(connections,connection_num,sizeof(connect_t),qsort_comp);
		result=0x7fffffff;
		for(j=0;j<connection_num;j++) {
			count=1;
			uf_init();
			for(i=j;i<connection_num && count<choten_num;i++) {
				if(!uf_issame(connections[i].a,connections[i].b)) {
					uf_merge(connections[i].a,connections[i].b);
					count++;
				}
			}
			if(count>=choten_num) {
				now_result=connections[i-1].weight
					-connections[j].weight;
				if(now_result<result)result=now_result;
			} else break;
		}
		if(result==0x7fffffff)puts("-1"); else printf("%d\n",result);
	}
	return 0;
}

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

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
 
namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) {int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) {  for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0;}
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void gp (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::gp;
 
void scan() {
	return;
}
 
template<class T, typename... Args>
void scan(T &a, Args&&... args) {
	gi(a);
	scan(args...);
	return;
}

template<typename T>
void scann(T a, T b) {
	for (auto it = a; it != b; ++it)
		scan(*it);
}
 
template<typename T>
void scerr(T a, T b) {
	for (auto it = a; it != b; ++it)
		cerr << *it << " ";
	cerr << '\n';
}

void print() {
	return;
}
 
template<class T, typename... Args>
void print(T a, Args... args) {
	gp(a);
	pc(' ');
	print(args...);
	return;
}
 
void cer() {
	return;
}
 
template<class T, typename... Args>
void cer(T a, Args... args) {
	cerr << " " << a;
	cer(args...);
	return;
} 
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 2;
const int M = 4e6 + 2;
const int mod = 998244353;
const ll inf = 1e6;
const ll INF = 1e18;

void data() {
	#ifdef PC
		freopen("d.in", "r", stdin);
		freopen("d.out", "w", stdout);
	#endif
}

ll x;

int main() {
	data();
	scan(x);
	for (ll a = -300; a <= 300; ++a) {
		for (ll b = -300; b <= 300; ++b) {
			if (a * a * a * a * a - b * b * b * b * b == x) {
				print(a, b);
				return 0;
			}
		}
	}
}		

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(x.first<y.first)
        return true;
    else if(x.first==y.first)
        return x.second>y.second;
    else
        return false;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}

void solve()
{   
    int m,n;
    cin>>n>>m;
    if(m-2*n>=0 && 4*n-m>=0 && (m-2*n)%2==0 && (4*n-m)%2==0)
        cout<<"Yes";
    else
        cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 3648
# https://atcoder.jp/contests/abc127/tasks/abc127_d

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    changes = []
    for _ in range(M):
        b, c = map(int, input().split())
        changes.append((b, c))

    A.sort()
    changes.sort(key=lambda x: x[1], reverse=True)
    # print(A)
    # print(changes)

    ai = 0
    for b, c in changes:
        if A[ai] > c:
            break
        for _ in range(b):
            if A[ai] > c:
                break
            if A[ai] < c:
                A[ai] = c
                ai += 1

                if ai >= len(A):
                    break

        if ai >= len(A):
            break
    print(sum(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 75416
#include <algorithm>
#include <cstdio>
struct edge
{
	int u, v, w; 
	edge(int _u = 0, int _v = 0, int _w = 0)
	{
		u = _u; 
		v = _v; 
		w = _w; 
	}
	inline bool operator <(const edge &a) const
	{
		return w < a.w; 
	}
} arr[400005]; 
int fa[400005], w[400005]; 
int getfa(int u)
{
	if (u == fa[u])
		return u; 
	return fa[u] = getfa(fa[u]); 
}
int main()
{
	// freopen("CF16-final-G.in", "r", stdin); 
	int n, m; 
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < n; i++)
	{
		fa[i] = i; 
		w[i] = w[i + n] = 2e9; 
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d%d", &arr[i].u, &arr[i].v, &arr[i].w); 
		w[arr[i].u] = std::min(w[arr[i].u], arr[i].w + 1); 
		w[arr[i].v] = std::min(w[arr[i].v], arr[i].w + 2); 
	}
	for (int i = 1; i < n << 1; i++)
		w[i] = std::min(w[i - 1] + 2, w[i]); 
	for (int i = 0; i < n; i++)
		arr[m++] = edge(i, (i + 1) % n, std::min(w[i], w[i + n]));
	std::sort(arr, arr + m); 
	long long ans = 0; 
	for (int i = 0; i < m; i++)
	{
		int u = getfa(arr[i].u), v = getfa(arr[i].v); 
		if (u != v)
		{
			fa[u] = v; 
			ans += arr[i].w; 
		}
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, a, b);

  if (sz(a) > sz(b)) {
    puts("GREATER");
    return 0;
  }
  if (sz(a) < sz(b)) {
    puts("LESS");
    return 0;
  }

  // sz(a) == sz(b)
  for (int i = 0; i < sz(a); ++i) {
    if (a[i] > b[i]) {
      puts("GREATER");
      return 0;
    }
    if (a[i] < b[i]) {
      puts("LESS");
      return 0;
    }
  }
  puts("EQUAL");

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x[100];
	int y[100];
	
	int i;
	
	for(i=1;i<=5;i++)
	{
		x[i]=i;
	}
	
	for(i=1;i<=5;i++)
	{
		scanf("%d",&y[i]);
	}
	
	for(i=1;i<=5;i++)
	{
		if(x[i]!=y[i])
		{
			printf("%d",i);
		}
	}
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n;
  ll a[n],m=1000;
  for(int i=0; i<n; i++) cin >>a[i];
  for(int i=0; i<n-1; i++){
    if(a[i+1]>a[i]) m+=m/a[i]*(a[i+1]-a[i]);
  }
  cout <<m;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3664
// Author: Tyler Wang

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.precision(12);
  std::cerr.precision(12);
  std::mt19937 rng((std::uint_fast32_t)std::chrono::high_resolution_clock::now()
                       .time_since_epoch()
                       .count());
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  vector<int> dp(n, 2e9);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    if (i + 1 < n) {
      dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    }
    if (i + 2 < n) {
      dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
int main(){
	int k,a,b;
	cin>>k>>a>>b;
	if(k==1){
		cout<<"OK";
		return 0;
	}
	else if(a>k){
		int h=a%k;
		if(h!=0){
		    if((a+k-h)<=b){
			    cout<<"OK";
			    return 0;
	      	}
		    else {
			    cout<<"NG";
			    return 0;
		    }
		}
		else {
			cout<<"OK";
			return 0;
		}
	}
	else if(a<=k && k<=b){
		cout<<"OK";
		return 0;
	}
	else{
		cout<<"NG";
		return 0;
	}
}

Measured memory_bytes: 3648
/*


*/
#include <cstdio>
#include <algorithm>
typedef long long LL;
const int N=505,M=8100;

int P[1005];
LL A[N][N];

void Init()
{
	static bool notP[M];
	for(int cnt=0,i=2; cnt<1000; ++i)
	{
		if(!notP[i]) P[++cnt]=i;
		for(int j=1,v; j<=cnt&&(v=i*P[j])<M; ++j)
		{
			notP[v]=1;
			if(!(i%P[j])) break;
		}
	}
}
inline LL LCM(LL x,LL y)
{
	return x/std::__gcd(x,y)*y;
}

int main()
{
	Init();
	int n; scanf("%d",&n);
	if(n==2) return printf("4 7\n23 10\n"),0;
	for(int i=0; i<=n+1; ++i) A[0][i]=1, A[n+1][i]=1, A[i][n+1]=A[i][0]=1;
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=n; ++j)
			if(!(i+j&1)) A[i][j]=P[i+j>>1]*P[(i-j+n+1)/2+n];
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=n; ++j)
			if(i+j&1) A[i][j]=LCM(LCM(A[i-1][j],A[i][j-1]),LCM(A[i+1][j],A[i][j+1]))+1;
	for(int i=1; i<=n; ++i,putchar('\n'))
		for(int j=1; j<=n; ++j) printf("%lld ",A[i][j]);

	return 0;
}

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

ll solve() {
    ll N, H;
    cin >> N >> H;
    vector<ll> A(N), B(N);
    ll a_max = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i] >> B[i];
        a_max = max(a_max, A[i]);
    }
    sort(B.begin(), B.end(), greater<>());
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( H <= 0 ) break;
        if ( B[i] <= a_max ) break;
        H -= B[i];
        ans++;
    }
    if ( H > 0 ) {
        ans += (H + a_max - 1) / a_max;
    }
    return ans;
}

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

Measured memory_bytes: 1792