akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const int mod = 998244353;
//const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
int mygcd(int a, int b){
	if(b == 0){
		return a;
	}
	return mygcd(b, a % b);
}
int mypow(int a, int b, int mod) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = (res * a) % mod;
		a = ( a * a ) % mod;
		b >>= 1;
	}
	return res;
}
void solve(){
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	vi dp(n, infl);
	dp[0] = 0;
	for(int i = 0 ; i < n - 1; i++){
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		if(i != n - 2){
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
		}
	}
	cout << dp[n - 1] << '\n';

}
signed main(){
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include <iomanip>
using namespace std;
const int total=120*60;
void print(int x){
	int h=x/3600,m=x%3600/60,s=x%60;
	cout << setw(2) << setfill('0') << h << ":" << setw(2) << m << ":" << setw(2) << s << endl; 
}
int main(){
	int h,m,s;
	while (cin >> h >> m >> s){
		if (h==-1 && m==-1 && s==-1) break;
		int counter=h*3600+m*60+s;
		int left=total-counter;
		print(left);
		print(left*3); 
	}
	return 0;
} 

Measured memory_bytes: 1168
N = int(input())
A = []
counter = {}
for ele in input().split():
    ele = int(ele)
    if not ele in counter:
        counter[ele] = 1
    else:
        counter[ele] += 1
    A.append(ele)

variation_count = {}
base_sum = 0
for key in counter.keys():
    count = counter[key]
    variation_count[key] = count*(count-1)//2
    base_sum += count*(count-1)//2

for k in range(N):
    tmp = base_sum
    count = counter[A[k]] - 1
    tmp = tmp - variation_count[A[k]] + count*(count-1)//2
    print(tmp)


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

int main()
{
  int N; cin >> N;
  vector<int> t(N+1, 0), x(N+1, 0), y(N+1, 0);
  for (int i = 1; i <= N; ++i) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 1; i <= N; ++i) {
    int manhattan = (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]));
    int diff = (t[i] - t[i-1]);

    if (manhattan > diff) {
      cout << "No" << endl;
      return 0;
    }
    if (diff%2 != manhattan%2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
# ABC119B - Digital Gifts
def main():
    _, *XU = open(0).read().split()
    ans, RATE = 0, 380000
    for x, u in zip(*[iter(XU)] * 2):
        x = float(x)
        ans += x if u == "JPY" else x * RATE
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String u, nl = System.getProperty("line.separator");
		StringBuilder 
			p = new StringBuilder(2000),
		  	d = (new StringBuilder(100)).append("."),
		  	s = (new StringBuilder(100)).append("#"),
		  	k = new StringBuilder(100);
		Scanner r = new Scanner(System.in);
		int h, w, ww = 0;
		while (4 != ww++) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while (0 != ((h = r.nextInt()) | (w = r.nextInt()))) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww += ww;
			}
			p.append(u = s.substring(0, w)).append(nl);
			k.setLength(0);
			k.append(d.substring(0, w)).append(nl)
			.replace(0, 1, "#").replace(w - 1, w, "#");
			while (2 != h--) {
				p.append(k);
			}
			p.append(u).append(nl).append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 18576
import numpy as np

def shift(xs, n):
    e = np.empty_like(xs)
    if n > 0:
        e[:n] = xs[-n:]
        e[n:] = xs[:-n]
    elif n < 0:
        e[n:] = xs[:-n]
        e[:n] = xs[-n:]
    else:
        return xs
    return e

d = {chr(x):x for x in range(ord('a'), ord('z')+1)}
n = int(input())
stemp = ''
temp = []
for i in range(n):
    s = input()
    for c in s:
        stemp+=str(d[c])+' '
    stemp = stemp[:-1] + ';'

m = np.matrix(stemp[:-1])
for i in range(n):
    temp.append(shift(m, i))

ans = 0
for matrix in temp:
    if np.all(matrix == matrix.T):
        ans += 1


print(ans*n)
"""
2
ab
ca


4
aaaa
aaaa
aaaa
aaaa


5
abcde
fghij
klmno
pqrst
uvwxy


"""

Measured memory_bytes: 226104
#include <stdio.h>

typedef struct {
	int id;
	float time;
} PLAYER;

int cmp(PLAYER *a, PLAYER *b)
{
	if (a->time < b->time) return (-1);
	if (a->time == b->time) return (0);
	return (1);
}

int main(void)
{
	int i, j, k = 0, n;
	PLAYER player[8];
	PLAYER rank3[18];
	
	for (i = 0; i < 3; i++){
		for (j = 0; j < 8; j++){
			scanf("%d %f", &player[j].id, &player[j].time);
		}
		
		qsort(player, 8, sizeof(PLAYER), cmp);
		
		printf("%d %.2f\n%d %.2f\n", player[0].id, player[0].time, player[1].id, player[1].time);
		
		for (j = 2; j < 8; j++){
			rank3[k].id = player[j].id;
			rank3[k++].time = player[j].time;
		}
	}
	
	qsort(rank3, 18, sizeof(PLAYER), cmp);
	
	printf("%d %.2f\n%d %.2f\n", rank3[0].id, rank3[0].time, rank3[1].id, rank3[1].time);
	
	return (0);
}

Measured memory_bytes: 648
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}
 
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e4 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(x);
	int ans = (x/500) * 1000;
	x = x%500;
	ans += (x/5) * 5;
	cout << ans;
}









Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

func main() {
	var n int
	var s string

	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &s)

	if n <= 1 {
		fmt.Println(0)
		return
	}

	black := make([]int, n)
	white := make([]int, n)

	black[0] = 0
	white[0] = 0

	bByte := "#"[0]

	ans := n

	for i := 0; i < n; i++ {
		prev := i - 1
		if i <= 0 {
			prev = 0
		}
		if s[i] == bByte {
			black[i] = black[prev] + 1
			white[i] = white[prev]
		} else {
			white[i] = white[prev] + 1
			black[i] = black[prev]
		}
	}

	for i := 0; i < n; i++ {
		ans = min(ans, black[i]+(white[n-1]-white[i]))
	}
	ans = min(ans, black[n-1])
	ans = min(ans, white[n-1])

	fmt.Println(ans)
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
//#define pu push_back
//#define po pop_back
#define pi (acos(-1))
#define fast ios::sync_with_stdio(false); cin.tie(0)
//#define pii pair<int,int>
//#define pll pair<ll,ll>
//#define vec vector
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> P;
const int INF = 1001001001;

// Gcd & Lcm
ll gcd (ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}
ll lcm (ll a, ll b) {
  return a/gcd(a,b)*b;
}

int main(void) {
  char s;
  cin >> s;
  if (isupper(s)) {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
  return 0;
}
  







  








  



Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int H_1, M_1, H_2, M_2, K;
    cin >> H_1 >> M_1 >> H_2 >> M_2 >> K;
    int M;
    M = (H_2-H_1)*60+(M_2-M_1);
    cout << M-K;
}

Measured memory_bytes: 3588
#include <stdio.h>
 
int main(){
  int r, c, i, j, s[128][128] = {};
  scanf("%d%d", &r, &c);
  for(i = 0;i < r;i++){
    for(j = 0;j < c;j++){
      scanf("%d", &s[i][j]);
      s[i][c] += s[i][j]; s[r][j] += s[i][j]; s[r][c] += s[i][j];
    }
  }
 
  for(i = 0;i <= r;i++){
    for(j = 0;j <= c;j++)
      printf(j != 0 ? " %d" : "%d", s[i][j]);
    puts("");
  }
  return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define fr first
#define sc second
using namespace std;

int d,n;
int tem[201],dp[201][101];
typedef pair<int,int> P;
typedef pair<P,int> iP;
iP clt[201];

int rec(int idx,int prev){
  if(idx == d) return 0;
  if(dp[idx][prev] != -1) return dp[idx][prev];
  int res = 0;
  for(int i=0;i<n;i++){
    if(clt[i].fr.fr <= tem[idx] && tem[idx] <= clt[i].fr.sc){
      res = max(res,rec(idx+1,clt[i].sc) + abs(clt[i].sc - prev));
    }
  }
  return dp[idx][prev] = res;
}
  

int main(){
  memset(dp,-1,sizeof(dp));
  cin >> d >> n;
  for(int i=0;i<d;i++) cin >> tem[i];
  for(int i=0;i<n;i++) cin >> clt[i].fr.fr >> clt[i].fr.sc >> clt[i].sc;
  int ans = 0;  
  for(int i=0;i<n;i++){
    if(clt[i].fr.fr <= tem[0] && tem[0] <= clt[i].fr.sc){ 
      ans = max(ans,rec(1,clt[i].sc));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1260
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X,K,Q;
ll A,B,C,D;

ll ans;
bool F=false;

int main(){
    cin>>X;
    ll temp=100;
    while (temp<X) {
        ans++;
        temp=(double)temp*1.01;

    }



    cout<<ans<<endl;
}


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

int compare_int(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}

int main() {

	
	int i, n, *d, count=0;

	scanf("%d", &n);

	d = (int*)malloc(n * sizeof(int));

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

	qsort(d, n, sizeof(int), compare_int);


	count = d[n/2] - d[n/2-1];
	
	printf("%d\n", count);


	return 0;
}

Measured memory_bytes: 892
module mod_rgb_coloring
  implicit none
  integer(8), parameter :: m = 998244353_8
  integer(8) :: f(0:300000), invf(0:300000)
contains
  subroutine init(n)
    implicit none
    integer, intent(in) :: n
    integer :: i
    f = 0_8
    invf = 0_8
    f(0) = 1_8
    invf(0) = 1_8
    do i = 1, n
      f(i) = mod(f(i-1)*int(i,8),m)
      invf(i) = inv(f(i))
    end do
    return
  end subroutine init
  recursive function gcd(x,y) result(z)
    implicit none
    integer(8), intent(in) :: x,y
    integer(8) :: z
    if (mod(x,y).eq.0) then
      z = y
      return
    end if
    z = gcd(y,mod(x,y))
    return
  end function gcd
  integer(8) function comb(n,k)
    implicit none
    integer(8), intent(in) :: n, k
    if ((n.lt.0_8).or.(k.lt.0_8).or.(n-k.lt.0_8)) then
      comb = 0_8
      return
    end if
    if ((n.eq.0_8).and.(k.eq.0_8)) then
      comb = 1_8
      return
    end if
    if (n.eq.0_8) then
      comb = 0_8
      return
    end if
    comb = mod(f(int(n))*mod(invf(int(k))*invf(int(n-k)),m),m)
    return
  end function comb
  integer(8) function inv(n)
    implicit none
    integer(8), intent(in) :: n
    integer(8) :: k(50), a, b, c, y0, y1, y2
    integer :: u, i
    if (n.eq.1_8) then
      inv = 1_8
      return
    end if
    k = 0_8
    a = m
    b = n
    u = 50
    do i = 1, 50
      k(i) = a/b
      c = a
      a = b
      b = mod(c,b)
      if (b.eq.0_8) then
        u = i-1
        exit
      end if
    end do
    y0 = 1_8
    y1 = -k(1)
    if (u.gt.1) then
      do i = 2, u
        y2 = y0-k(i)*y1
        y0 = y1
        y1 = y2
      end do
    end if
    do while (y1.lt.0_8)
      y1 = y1 + m
    end do
    inv = mod(y1,m)
    return
  end function inv
end module mod_rgb_coloring
program rgb_coloring
  use mod_rgb_coloring
  implicit none
  integer(8) :: n, a, b, k, c, x, i, j, l
  read(*,*) n, a, b, k
  if (k.eq.0_8) then
    write(*,'(i0)') 1
    stop
  end if
  call init(int(n))
  if (a.gt.b) then
    c = a
    a = b
    b = c
  end if
  c = gcd(b,a)
  if ((mod(k,c).ne.0_8).or.(k.lt.a).or.(k.gt.n*(a+b))) then
    write(*,'(i0)') 0
    stop
  end if
  a = a/c
  b = b/c
  k = k/c
  x = 0_8
  do i = min(n,k/b), 0_8, -1_8
    if ((mod(k-i*b,a).ne.0).or.((k-i*b)/a.gt.n)) cycle
    j = (k-i*b)/a
    x = mod(x+mod(comb(n,i)*comb(n,j),m),m)
  end do
  write(*,'(i0)') x
  stop
end program rgb_coloring

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
typedef long long ll;
 
int main() {
  ll a;cin>>a;
  if(a==3||a==5||a==7) cout<<"YES";
  else cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void dfs(int node,int parent,vector<int>ar[],int depth[]){
	if(depth[node]||ar[node].empty())
		return;
	int m=0;
	for(int child:ar[node]){
		if(child==parent)
			continue;
		dfs(child,node,ar,depth);
		m=max(m,depth[child]+1);
	}
	depth[node]=m;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int> ar[n+1];
	while(m--){
		int a,b;
		cin>>a>>b;
		ar[a].push_back(b);
	}
	int depth[n+1];
	for(int i=0;i<=n;i++)
		depth[i]=0;
	for(int i=1;i<=n;i++)
		dfs(i,-1,ar,depth);
	int ans=0;
	for(int i=0;i<=n;i++)
		ans=max(ans,depth[i]);
	cout<<ans<<"\n";
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll N;
	cin >> N;
	--N;
	
	string ans = "";
	while ( N >= 0) {
		ans += (N % 26) + 'a';
		N /= 26;
		--N;
	}
	reverse(ALL(ans));
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

#define MAX_V 100
#define INF 10000000

using namespace std;

typedef pair<int, int> P;

struct edge {
	int to, info;
	edge(int _to, int _info) { to = _to, info = _info; };
};

vector<edge> Gc[MAX_V];
vector<edge> Gt[MAX_V];
int V, E;
int c[MAX_V];
int t[MAX_V];

void solve();
void dijkstra(int s, int g, int r);

int main()
{
	while (cin>>E>>V, E != 0 && V != 0) {
		for (int i = 0; i < V; i++) {
			Gc[i].clear(), Gt[i].clear();
		}
		for (int i = 0; i < E; i++) {
			int fr, to, co, ti;
			cin>>fr>>to>>co>>ti;
			Gc[fr - 1].push_back(edge(to - 1, co));
			Gc[to - 1].push_back(edge(fr - 1, co));
			Gt[fr - 1].push_back(edge(to - 1, ti));
			Gt[to - 1].push_back(edge(fr - 1, ti));
		}
		solve();
	}
}

void solve()
{
	int k,p,q,r;
	cin>>k;
	for (int i = 0; i < k; i++) {
		cin>>p>>q>>r;
		dijkstra(p - 1, q - 1, r);
	}
}

void dijkstra(int s, int g, int r)
{
	priority_queue<P, vector<P>, greater<P> > que;
	switch (r) {
			case 0:
			que.push(P(0,s));
			fill(c, c + V, INF);
			c[s] = 0;
			while (!que.empty()) {
				P p = que.top();
				que.pop();
				int v = p.second;
	
				if (c[v] < p.first) continue;
				for (int i = 0; i < Gc[v].size(); i++) {
					edge e = Gc[v][i];
					if (c[e.to] > c[v] + e.info) {
						c[e.to] = c[v] + e.info;
						que.push(P(c[e.to], e.to));
					}
				}
			}
			cout<<c[g]<<endl;
			
			break;
			
			case 1:
			que.push(P(0,s));
			fill(t, t + V, INF);
			t[s] = 0;
			while (!que.empty()) {
				P p = que.top();
				que.pop();
				int v = p.second;
				
				if (t[v] < p.first) continue;
				for (int i = 0; i < Gt[v].size(); i++) {
					edge e = Gt[v][i];
					if (t[e.to] > t[v] + e.info) {
						t[e.to] = t[v] + e.info;
						que.push(P(t[e.to], e.to));
					}
				}
			}
			cout<<t[g]<<endl;
			
			break;
	}
}

Measured memory_bytes: 1324
def get_bomb_num(i, j):
    cnt = 0
    for p in range(-1,2):
        for s in range(-1,2):
            l = i + p
            m = j + s
            if (p == 0 and s == 0) or (l < 0) or (l >= H) or (m < 0) or (m >= W):
                continue
            if b[l][m] == '#':
                cnt += 1
    return cnt

H,W = list(map(int, input().split()))
b =[]
for i in range(H):
    b.append(str(input()))

for i in range(H):
    for j in range(W):
        if b[i][j] == '#':
            print('#', end ='')
        else:
            print(get_bomb_num(i,j), end='')
    print('')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int x1,x2,n;
	int g=0;
	sd(n);
	sd(x1);
	for(int i = 1; i <= n; i++){
		sd(x2);
		x2=abs(x2-x1);
		g=gcd(g,x2);
	}
	pd(g);
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int main()
{
    string s;
    getline(cin, s);
    int n = s.length();
    for (int i = 0; i < n; i++)
    {
        if ('a' <= s[i] && s[i] <= 'z')
        {
            int idx = s[i] - 'a';
            cout << (char)('A' + idx);
        }
        else if ('A' <= s[i] && s[i] <= 'Z')
        {
            int idx = s[i] - 'A';
            cout << (char)('a' + idx);
        }
        else
        {
            cout << s[i];
        }
    }
    cout << endl;
}



Measured memory_bytes: 3172
n,m=map(int,input().split())
a=[]
for _ in range(m):
  s,c=input().split()
  s=int(s)-1
  a.append([s,c])
ans=-1
for i in range(pow(10,n)):
  s=str(i).zfill(n)
  flag=True
  for b in a:
    if not (s[b[0]]==b[1]):
      flag=False
  if flag and len(str(i))==n:
    ans=i
    break
print(ans)

Measured memory_bytes: 38896
using System;

namespace Sample
{
    class Program
    {
        static void Main()
        {
            var count7 = 0;
            var count5 = 0;
            foreach (var str in Console.ReadLine().Split(' '))
            {
                if (str == "5") { count5++; }
                if (str == "7") { count7++; }
            }

            if (count5 == 2 && count7 == 1)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)

int main(){
  LL n,ans=0;
  cin >> n;
  VLL a(n);
  REP(i,0,n){
    cin >> a.at(i);
  }
  
  REP(i,1,n){
    if(a.at(i-1) <= a.at(i)){continue;}
    ans += a.at(i-1) - a.at(i);
    a.at(i) = a.at(i-1);
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX 10000005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
vector<int> primes;
ll sumprime[MAX];
bool is_prime[MAX];
void sieve(){
    is_prime[0]=is_prime[1]=true;
    for(int i=4;i<MAX;i+=2){
        is_prime[i]=true;
    }
    for(int i=3;i*i<MAX;i+=2){
        if(!is_prime[i]){
            for(int j=i*i;j<MAX;j+=i){
                is_prime[j]=true;
            }
        }
    }
    for(int i=0;i<MAX;i++){
        if(!is_prime[i]){
            sumprime[i]=sumprime[i-1]+i;
        }else{
            sumprime[i]=sumprime[i-1];
        }
    }
}
*/
/*
void lcs(char s1[],char s2[]){
    int n=strlen(s1);
    int m=strlen(s2);
    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int sum=0;
            if(s1[i-1]==s2[j-1]){
                sum=1+dp[i-1][j-1];
            }
            else{
                sum=max(dp[i-1][j],dp[i][j-1]);
            }
            dp[i][j]=sum;
        }
    }
    
    int index=dp[n][m];
    //cout<<index<<endl;
    char ans[index+1];
    ans[index]='\0';
    index--;
    int x=n;
    int y=m;
    while(x>0 and y>0){
        if(dp[x-1][y]==dp[x][y-1] and dp[x-1][y]!=dp[x][y]){
            ans[index]=s1[x-1];
            index--;
            x--;
            y--;
        }else if(dp[x-1][y]>dp[x][y-1]){
            x--;
        }else{
            y--;
        }

    }
    //reverse(ans.begin(),ans.end());

    cout<<ans;
    return;
}
*/

int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    //cin>>t;
    for(int tc=1;tc<=t;tc++){
        int r,g,b,k;
        cin>>r>>g>>b>>k;
        int ans=0;
        int i;
        for(i=g;i<=r;i*=2){
            ans++;
        }
        for(int j=b;j<=i;j*=2){
            ans++;
        }
        if(k>=ans){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
        

    }
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 3624
{-# LANGUAGE TypeApplications #-}

import           Control.Monad
import           Control.Applicative
import           Data.List
import           Data.Char
import           Control.Arrow
import           Data.Bits


main = do
  getLine
  print
    .   fromRational
    .   recip
    .   sum
    .   map (recip . toRational . (read @Int))
    .   words
    =<< getLine


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define name(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int N=(int)1e6+7;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int l= 1 , r = n;
    while(m--){
        int x, y;
        cin >> x >> y;
        l = max(l , x);
        r = min(y , r);
    }
    if(r < l){
        cout << 0 << '\n';
    }
    else cout << r - l  + 1 << '\n';

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forab(i, a, b) for(int i=(int)a; i<(int)b; ++i)

const int inf = (int)1e6+5;
const int nax = (int)3e5+5;

void compute(){
    int a, b, k;
    cin>>a>>b>>k;
    int res;
    vi v;
    forab(i, 1, min(a,b)+1){
        if(a%i == 0 && b%i == 0) v.pb(i);
    }
    sort(v.begin(), v.end(), greater<int>());
    res = v[k-1];
    cout<<res<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //    int t;
    //    cin>>t;
    //    while(t--)
    compute();
    return 0;
}


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

int main(void){
    string s;cin>>s;reverse(s.begin(), s.end());
    string words[4]={"dream", "dreamer", "erase", "eraser"};
    for(int i=0;i<4;i++)reverse(words[i].begin(), words[i].end());
    bool can=true;
    for(int i=0;i<s.size();){
        bool can2=false;
        for(int j=0;j<4;j++){
            string d=words[j];
            if(s.substr(i, d.size())==d){
                can2=true;
                i+=d.size();
            }
        }
        if(!can2){
            can=false;
            break;
        }
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    

}

Measured memory_bytes: 512
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 11-Jul-2020 19:04:25
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void INT(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void INT(T &x, W &y) {INT(x), INT(y);}
template <TN T, TN W, TN Q> inline void INT(T &x, W &y, Q &z) {INT(x, y), INT(z);}

const int N = 2e5 + 7;
const int inf = 1e9 + 7;

int dp[N];

int call(int x) {
    if (x == 0) {
        return 0;
    }
    if (~dp[x]) {
        return dp[x];
    }
    return dp[x] = 1 + call(x % __builtin_popcount(x));
}

int solve() {
    mem(dp, -1);

    int n; cin >> n;
    string s; cin >> s;
    int one = 0;
    for (char d : s) {
        one += (d == '1');
    }

    vector<int> pwp(n + 1);
    vector<int> pwm(n + 1);
    pwp[0] = 1 % (one + 1);

    for (int i = 1; i <= n; ++i) {
        pwp[i] = (pwp[i - 1] * 2) % (one + 1);
    }

    if (one > 1) {
        pwm[0] = 1 % (one - 1);

        for (int i = 1; i <= n; ++i) {
            pwm[i] = (pwm[i - 1] * 2) % (one - 1);
        }
    }

    int resp = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1') {
            resp += pwp[n - i - 1];
            resp %= (one + 1);
        }
    }

    int resm = 0;
    if (one > 1) {
        for (int i = 0; i < n; ++i) {
            if (s[i] == '1') {
                resm += pwm[n - i - 1];
                resm %= (one - 1);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        char d = s[i];
        int modu = 0;
        if (d == '1') {
            if (one > 1) {
                modu = (resm - pwm[n - i - 1]) % (one - 1);
                modu = (modu + (one - 1)) % (one - 1);
            } else {
                cout << 0 << endl;
                continue;
            }
        } else {
            modu = (resp + pwp[n - i - 1]) % (one + 1);
        }
        cout << call(modu) + 1 << endl;
    }

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // INT(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 5864
#include<cstdio>
int n,a[110],ans;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for (int i=1;i<=n;i+=2) if (a[i]%2) ans++;
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 1720
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n; cin >> n;
  vector<double> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i);
  }
  vector<double> y(n);
  for (int i = 0; i < n; i++) {
    cin >> y.at(i);
  }

  double p1;
  for (int i = 0; i < n; i++) {
    p1 += abs(x.at(i) - y.at(i));
  }
  cout << fixed << setprecision(6) << p1 << endl;

  double p2;
  for (int i = 0; i < n; i++) {
    // p2 += abs(x.at(i) - y.at(i)) * abs(x.at(i) - y.at(i));
    p2 += pow(abs(x.at(i) - y.at(i)), 2);
  }
  cout << fixed << setprecision(6) << sqrt(p2) << endl;

  double p3;
  for (int i = 0; i < n; i++) {
    p3 += pow(abs(x.at(i) - y.at(i)), 3);
  }
  cout << fixed << setprecision(6) << pow(p3, 1.0 / 3) << endl;

  double inf = -1;
  for (int i = 0; i < n; i++) {
    inf = max(inf, abs(x.at(i) - y.at(i)));
  }
  cout << fixed << setprecision(6) << inf << endl;


}



Measured memory_bytes: 3428
A,B,C,K = map(int,input().split())
answer = 0
if K <= A:
    print(K)
    K = 0
elif K > A:
    answer = A
    K = K - A
if K <= B and K > 0 :
    print(answer)
    K = 0
elif K > B:
    K = K - B
if K <= C and K > 0:
    answer = answer - K
    print(answer)

Measured memory_bytes: 9204
N, Q = map(int, input().split())
in_str = input()
AC_count = []
r = [0]*(N+1)
for i in range(N):
    r[i+1] = r[i] + (1 if in_str[i:i+2] == "AC" else 0) 
    
    
for i in range(Q):
    in1, in2 = map(int, input().split())
    print(r[in2-1]-r[in1-1])


Measured memory_bytes: 9284
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int minB = 10*B;
    int maxB = minB+9;
    int minA = 0;
    int maxA = 0;
    if(A%2==0){
      minA = (25*A)/2;
      maxA = minA + 12;
    }else{
      minA = (25*A)/2+1;
      maxA = (25*(A+1)/2)-1;
    }
    if(minA>maxB||minB>maxA){
      System.out.println(-1);
    }else if(minA<=minB){
      System.out.println(minB);
    }else{
      System.out.println(minA);
    }
    
    
      
      
  }
  

  
}

Measured memory_bytes: 25044
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            if (input.Length != 6 || input[2] != input[3]
                || input[4] != input[5])
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;

char a[110];
bool check1[110],check2[110];

int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",a+1);
	int maxx=-1;
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=0;
		memset(check1,0,sizeof check1);
		memset(check2,0,sizeof check2);
		for(int j=1;j<=i;j++){
			check1[a[j]-'a']=1;
		}
		for(int j=i+1;j<=n;j++){
			check2[a[j]-'a']=1;
		}
		for(int j=0;j<26;j++){
			if(check1[j]&&check2[j])
				ans++;
		}
		maxx=max(ans,maxx);
	}
	printf("%d",maxx);
 } 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

int main() {
    ios :: sync_with_stdio(false);
    char aa, bb, cc, dd;
    int a, b, c, d;
    cin>>aa>>bb>>cc>>dd;
    a = aa - '0';
    b = bb - '0';
    c = cc - '0';
    d = dd - '0';
    if(a+b+c+d==7){
        cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7";
    }
    else if(a+b+c-d==7){
        cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7";
    }
    else if(a+b-c+d==7){
        cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7";
    }
    else if(a-b+c+d==7){
        cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7";
    }
    else if(a-b-c+d==7){
        cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7";
    }
    else if(a-b+c-d==7){
        cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7";
    }
    else if(a+b-c-d==7){
        cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,p;
P w[100010];
bool func(P a,P b){
	return a.first*(100-p)+a.second*p>b.first*(100-p)+b.second*p;
}
signed main(){
	cin>>n>>p;
	int sumw=0,sumb=0;
	rep(i,n){
		cin>>w[i].first>>w[i].second;
		sumw+=w[i].first;
		sumb+=w[i].second;
	}
	sort(w,w+n,func);
	int nw=0,nb=0;
	rep(i,n){
		nw+=w[i].first;
		nb+=w[i].second;
		if((double)nw/(sumb-nb+nw)*100>=p){
			cout<<i+1<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
n=int(input())
m=1
inf=10**18
lol=0
l=list(map(int,input().split()))
if 0 in l:
    print(0)
else:

    for i in l:
      m=m*i
      if(m>inf):
        lol=1
        break
    if(lol):
      print(-1)
    else:
      print(m)

Measured memory_bytes: 84604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        boolean[][] l = new boolean[4][13];
        char[] card = new char[] {'S', 'H', 'C', 'D'};

        for(int i = 0; i < a; i++) {
        	char cardType = sc.next().charAt(0);
        	int cardNum = sc.nextInt();

        	switch(cardType) {
        	case 'S':
        		l[0][cardNum-1] = true;
        		break;
        	case 'H':
        		l[1][cardNum-1] = true;
        		break;
        	case 'C':
        		l[2][cardNum-1] = true;
        		break;
        	case 'D':
        		l[3][cardNum-1] = true;
        		break;
        	}
        }

        for(int i = 0; i < 4; i++) {

        	for(int j = 0; j < 13; j++) {

        		if(!l[i][j]) {
        			System.out.println(card[i] + " " + (j+1));
        		}
        	}
        }
	}
}



Measured memory_bytes: 26380
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 15;
int sum[1<<N], dp[1<<N][N], cost[N][N];

int main() {
    int n, m;
    cin >> n >> m;
    int all = 0;
    while (m--) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        cost[a][b] = c;
        cost[b][a] = c;
        all += c;
    }

    REP(mask,1<<n){
        REP(i,n) REP(j,i){
            if ((mask >> i) & (mask >> j) & 1) sum[mask] += cost[i][j];
        }
    }

    REP(mask,1<<n) REP(i,n) dp[mask][i] = -1;

    FOR(mask,1,(1<<(n-1))-1){
        if (mask % 2) dp[mask][0] = sum[mask];
    }

    FOR(mask,1,(1<<n)-1) REP(i,n) {
        if (dp[mask][i] == -1) continue;
        int x = 0;
        REP(j,n) x += (mask >> j) & 1;
        int y = n - x;
        REP(next,1<<y){
            int mask_next = 0;
            int b = 0;
            REP(j,y){
                while ((mask >> b) & 1) b++;
                if ((next >> j) & 1) mask_next += 1 << b;
                b++;
            }
            REP(j,n){
                if ((mask_next >> j) & 1 && cost[i][j] > 0){
                    dp[mask | mask_next][j] = max(dp[mask | mask_next][j], dp[mask][i] + sum[mask_next] + cost[i][j]);
                }
            }
        }
    }

    // REP(i,(1<<n)-1){
    //     cout << i << "   ";
    //     REP(j,n){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << all - dp[(1<<n)-1][n-1] << endl;

    return 0;
}


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

int greatestCommonDivisor(int a, int b);

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	
	int n = greatestCommonDivisor(a, b);
	
	printf("%d\n", n);
	
	return 0;
}

int greatestCommonDivisor(int a, int b){
	while(a != b){
		a > b ? a %= b : b %= a;
		if(a % b == 0 || b % a == 0) break;
	}
	return a < b ? a : b;
}

Measured memory_bytes: 1020
o = raw_input()
e = raw_input()
password = ''

j, k = 0, 0
for i in range(len(o)+len(e)):
	if i % 2 == 0:
		password += o[j]
		j += 1
	if i % 2 == 1:
		password += e[k]
		k += 1

print password


Measured memory_bytes: 2568
#include <iostream>
using namespace std;

int main(){
	int N,max,min,tmp;
	cin >> N;
	for(int i=0; i<N;i++){
		cin >> tmp;
		if(i==0){
			min = tmp;
		}
		if(i==1){
			max = tmp - min;
		}
		if(max < (tmp-min)){
			max = tmp-min;
		}
		if(tmp < min){
			min = tmp;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1164
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3945703
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int MOD;
vector<int> adj[111111];
int F[111111];
int G[111111];
int sub[111111];
int H[111111];
int pow2[111111];

int add(int a, int b){
    a += b;
    a %= MOD;
    if(a < 0) a += MOD;
    return a;
}

int mult(int a, int b){
    return (a * 1LL * b) % MOD;
}

void prep(int u, int p = -1){
    sub[u] = 1;
    for(int v : adj[u]){
        if(v == p) continue;
        prep(v, u);
        sub[u] += sub[v];
    }
}

void dfs(int u, int p){
    F[u]=1;
    vector<LL> pre;
    for(int v : adj[u]){
        if(v == p) continue;
        dfs(v, u);
        F[u] = mult(F[u], add(F[v], 1));
        pre.push_back(add(F[v], 1));
    }
    vector<LL> suf = pre;
    for(int i = int(suf.size()) - 1; i >= 0; i--){
        if(i + 1 < suf.size()) suf[i] = mult(suf[i], suf[i+1]);
    }
    for(int i = 1; i < pre.size(); i++) pre[i] = mult(pre[i], pre[i - 1]);
    int c = 0;
    for(int v : adj[u]){
        if(v == p) continue;
        H[v] = 1;
        if(c > 0)              H[v] = pre[c - 1];
        if(c + 1 < suf.size()) H[v] = mult(H[v], suf[c + 1]);
        c++;
    }
}

void dfs2(int u, int p){
    for(int v : adj[u]){
        if(v == p) continue;
        G[v] = 1;
        G[v] = add(G[v], mult(G[u], H[v]));
        dfs2(v, u);
    }
}

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d %d", &N, &MOD);
    pow2[0] = 1;
    for(int i = 1; i <= N; i++) pow2[i] = add(pow2[i - 1], pow2[i - 1]);
    for(int i = 0; i < N - 1; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    // 2. dp更新.
    prep(0, -1);
    dfs(0, -1);
    G[0] = 1;
    dfs2(0, -1);
    
    // 3. 出力.
    for(int i = 0; i < N; i++) printf("%d\n", mult(G[i], F[i]));
    return 0;
}

Measured memory_bytes: 18048
n,k = map(int,input().split())
d = list(map(int,input().split()))
nd = list()
for i in range(10):
    if i not in d:
        nd.append(i)
a = n

for i in range(10*n):
    if set([int(m) for m in list(str(a+i))]) == set(list(set([int(m) for m in list(str(a+i))]) & set(nd))):
        print(a+i)
        break

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
  n,m=map(int,input().split())
  uf=UnionFind(n)
  now=n*(n-1)//2
  g=[]
  ans=[now]
  now=n*(n-1)//2
  for i in range(m):
    a,b=map(int,input().split())
    g.append((a-1,b-1))
  #print(g)
  g=g[::-1]
  for a,b in g:
    now-=uf.size(a)*uf.size(b)*(1-uf.same(a,b))
    ans.append(now)
    uf.union(a,b)
  ans=ans[:-1][::-1]
  print(*ans,sep="\n")
  
  
  
  
  
  
  
  
  
  
  
  
  
  
if __name__ == "__main__":
	main()

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<LL,LL>;
using Pdd = P<double,double>;
using Psi = P<string,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T>
T SUM(V<T> v, T init_val=0){return accumulate(ALL(v),T(init_val));}

int main(){
    LL n,m;
    cin>>n>>m;
    V<Pll> ab(n);
    REP(i,n) cin>>ab[i].fi>>ab[i].se;
    
    sort(ALL(ab));

    LL price = 0;
    LL num = 0;
    REP(i,n){
        LL nokori = m-num;
        if(nokori>ab[i].se){
            price += ab[i].fi*ab[i].se;
            num += ab[i].se;
        }else{
            price += ab[i].fi*nokori;
            num += nokori;
        }
    }

    cout<<price<<endl;

    return 0;
}

Measured memory_bytes: 1792
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

a,b,k=input2()
MAX=max(a,b)
count=0
ans=0
for i in range(MAX,0,-1):
	if a%i==0 and b%i==0:
		count+=1
		if count==k:
			print(i)
			break

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

int main(){
int A,B,C,D;

cin>>A>>B>>C>>D;
  while(A>0||C>0){
  	C-=B;
    if(C<=0){
    break;
    }
    A-=D;
	if(A<=0){
    break;
    }
  }
  if(A>0){
  cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
    
}

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

int main(){
  int N;
  cin >> N;
  
  int A;
  int n = 30;	//nを順々に小さくする(10^9 < 2^30 から)
  
  for(int i = 0; i < N; i++){
    cin >> A;
    int j = 0;	//A_iを2で割れる回数	
    
    while(true){
      if(A%2 == 0){
        A = A/2;
        j++;
      }
        
      else{
        break;
      }
      
    }
    
    if(n > j){
      n = j;
    }
  }
  
  cout << n << endl;
    
}
  

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val X, Y = sc.next
    if (X == Y) {
      println("=")
    } else if (X < Y) {
      println("<")
    } else {
      println(">")
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25488
#include<bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<n;i++)
int main(){
  int n;cin>>n;
  if(n==3) {
    cout<<"2 5 63"<<endl;
    return 0;
  }
  vector<int> numbers;
  REP(i,6,30001) if(i%2==0 || i%3==0) numbers.emplace_back(i);
  while(true){
    vector<int> num = numbers;
    random_shuffle(num.begin(), num.end());
    REP(i,2,5)num.emplace_back(i);
    reverse(num.begin(), num.end());
    long sum=0;
    REP(i,0,n) sum+=num[i];
    if(sum%6==0){
      REP(i,0,n) cout<<num[i]<<" ";
      cout<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 656