akhauriyash/Code-Regression huggingface dataset:
import sys

K = int(input())


def hoge(Num, X, K):
    if Num == K:
        print(X)
        sys.exit()


if K < 10:
    print(K)
else:
    num1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    num2 = []
    num = 9
    while (True):

        for i in range(len(num1)):  # 桁数
            if num1[i] % 10 != 0:
                num2.append(num1[i] * 10 + ((num1[i] % 10) - 1))
                num += 1
                hoge(num, num1[i] * 10 + ((num1[i] % 10) - 1), K)

            num2.append(num1[i] * 10 + (num1[i] % 10))
            num += 1
            hoge(num, num1[i] * 10 + (num1[i] % 10), K)

            if num1[i] % 10 != 9:
                num2.append(num1[i] * 10 + ((num1[i] % 10) + 1))
                num += 1
                hoge(num, num1[i] * 10 + ((num1[i] % 10) + 1), K)

        num1 = num2[:]
        num2 = []


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    double f=1/n,ans1,ans=0;

    rep(i,n){
        ans1=i+1;
        while(ans1<m){
            f/=2;
            ans1*=2;
        }
        ans+=f;
        f=1/n;
    }

    cout<<fixed<<setprecision(12)<<ans<<endl;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);
    int Q;
    cin >> Q;
    vector<int> M(Q);
    for(int i=0; i<Q; i++) cin >> M.at(i);

    vector<bool> mp(20005, false);
    for(int bit=0; bit < (1<<N); bit++)
    {
        int sun = 0;
        for(int i=0; i<N; i++)
        {
            if(bit & (1<<i))
            {
                sun += A[i];
            }
        }
        mp[sun] = true;
    }

    for(int i=0; i<Q; i++)
    {
        if(mp[M[i]]) cout << "yes\n";
        else cout << "no\n";
    }

    return 0;
}


Measured memory_bytes: 3196
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {
		int[] e = new int[10000];
		int[] e2 = new int[10000];
		String[] s = new String[10000];
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < e.length; i++) {
			String line = sc.nextLine();
			String[] k = line.split(" ");

			e[i] = Integer.parseInt(k[0]);
			e2[i] = Integer.parseInt(k[2]);
			s[i] = k[1];
			if (s[i].equals("?")) {
				break;
			}
		}

		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("?")) {
				break;
			}
			if (s[i].equals("+")) {
				System.out.println(e[i] + e2[i]);
			}
			if (s[i].equals("-")) {
				System.out.println(e[i] - e2[i]);
			}
			if (s[i].equals("*")) {
				System.out.println(e[i] * e2[i]);
			}
			if (s[i].equals("/")) {
				System.out.println(e[i] / e2[i]);
			}
		}
	}
}

Measured memory_bytes: 26300
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int N, K, Q, A[2000], a[2001], res;


int main() {
	cin >> N >> K >> Q;
	for (int i = 0; i != N; ++i) {
		cin >> A[i];
		a[i] = A[i];
	}
	a[N] = intmax;
	sort(a, a + N);
	res = intmax;
	for (int i = 0; i != N - Q + 1; ++i) {
		int l = i + Q - 2;
		int r = N;
		while (l + 1 != r) {
			int k = (l + r) / 2;
			int E869120 = 0, square1001 = 0, Segtree = 0;
			for (int j = 0; j != N; ++j) {
				if (a[i] <= A[j] && A[j] <= a[k])
					++square1001;
				else if (a[k] < A[j])
					++Segtree;
				else {
					E869120 += max(0, square1001 + min(0, Segtree - K + 1));
					square1001 = Segtree = 0;
				}
			}
			E869120 += max(0, square1001 + min(0, Segtree - K + 1));
			if (E869120 >= Q)
				r = k;
			else
				l = k;
		}
		res = min(res, a[r] - a[i]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n;
    int i, j, k;
    int t, f;
    //int l, r, b;
    int field[100][100][100];
    int left[6][6] = {{0, 4, 2, 5, 3, 0}, {3, 0, 6, 1, 0, 4}, {5, 1, 0, 0, 6, 2}, {2, 6, 0, 0, 1, 5}, {4, 0, 1, 6, 0, 3}, {0, 3, 5, 2, 4, 0}};
    //int dice[6][2] = {{5, 4}, {6, 4}, {6, 5}, {6, 5}, {6, 4}, {5, 4}};
    // u = 0, r = 1, d = 2, l = 3
    int dice[6][6][2] = {{{-1, -1}, {0, 3}, {1, 0}, {3, 2}, {2, 1}, {-1, -1}}, {{0, 1}, {-1, -1}, {3, 0}, {1, 2}, {-1, -1}, {2, 3}}, {{0, 3}, {1, 0}, {-1, -1}, {-1, -1}, {3, 2}, {2, 1}}, {{0, 1}, {3, 0}, {-1, -1}, {-1, -1}, {1, 2}, {2, 3}}, {{0, 3}, {-1, -1}, {1, 0}, {3, 2}, {-1, -1}, {2, 1}}, {{-1, -1}, {0, 1}, {3, 0}, {1, 2}, {2, 3}, {-1, -1}}}; 
    int result[6];
    int tmp2;
    while (1) {
	scanf("%d", &n);
	if (n == 0) {
	    break;
	}
	for (i = 0; i < 100; i++) {
	    for (j = 0; j < 100; j++) {
		for (k = 0; k < 100; k++) {
		    field[i][j][k] = 0;
		}
	    }
	}
	for (i = 0; i < 6; i++) {
	    result[i] = 0;
	}

	for (i = 0; i < n; i++) {
	    int x, y, z;
	    x = y = 50;
	    z = 99;
	    scanf("%d %d", &t, &f);
	    // b = 7 - f;
	    // l = left[t-1][f-1];
	    // r = 7 - l;
	    while (1) {
		fail: ;
		while (z > 0 && field[x][y][z-1] == 0) {
		    z--;
		    //field[x][y][z+1] = 0;
		    //field[x][y][z] = t;
		}
		
		for (j = 0; j < 2; j++) {
		    if (z == 0) {
			goto fallend;
		    }
		    int tmp = dice[t-1][f-1][j];
		    if (tmp == 0) {
			if (field[x][y+1][z-1] == 0) {
			    //field[x][y][z] = 0;
			    //field[x][y+1][z-1] = f;
			    y++;
			    z--;
			    tmp2 = f;
			    f = 7 - t;
			    t = tmp2;
			    goto fail;
			}
		    } else if (tmp == 1) {
			if (field[x+1][y][z-1] == 0) {
			    //field[x][y][z] = 0;
			    t = left[t-1][f-1];
			    //field[x+1][y][z-1] = t;
			    x++;
			    z--;
			    goto fail;
			}
		    } else if (tmp == 2) {
			if (field[x][y-1][z-1] == 0) {
			    //field[x][y][z] = 0;
			    //field[x][y+1][z-1] = 7 - f;
			    y--;
			    z--;
			    tmp2 = t;
			    t = 7 - f;
			    f = tmp2;
			    goto fail;
			}
		    } else {
			if (field[x-1][y][z-1] == 0) {
			    //field[x][y][z] = 0;
			    t = 7 - left[t-1][f-1];
			    //field[x-1][y][z-1] = t;
			    x--;
			    z--;
			    goto fail;
			}
		    }
		}
		break;
	    } fallend: field[x][y][z] = t;
	    //printf("%d %d %d %d\n", x, y, z, t);
	}

	for (i = 0; i < 100; i++) {
	    for (j = 0; j < 100; j++) {
		for (k = 0; k < 100; k++) {
		    if (k == 99 || field[i][j][k+1] == 0) {
			int tmpres = field[i][j][k];
			result[tmpres-1]++;
		    }
		}
	    }
	}
	for (i = 0; i < 6; i++) {
	    printf("%d", result[i]);
	    if (i != 5) {
		printf(" ");
	    }
	}
	printf("\n");

    }

    return 0;
}

Measured memory_bytes: 4512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

/*-----------------------------------------------------------------*/


int main(){
  string a, b;
  cin >> a >> b;
  if(a.size() > b.size()) cout << "GREATER" << endl;
  else if(a.size() < b.size()) cout << "LESS" << endl;
  else{
    if(a == b) cout << "EQUAL" << endl;
    else if(a > b) cout << "GREATER" << endl;
    else if(b > a) cout << "LESS" << endl;
  }
}



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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector <int> dp(3, 0);
    for (int i=0;i<n;i++){
        vector <int> new_dp(3, INT_MIN);
        vector <int> c(3);
        for (int i=0;i<3;i++){
            cin >> c[i];
        }

        for (int i=0;i<3;i++){
            for (int j=0;j<3;j++){
                if (i!=j){
                    new_dp[j] = max(new_dp[j], dp[i]+c[j]);
                }
            }
        }
        dp = new_dp;
    }
    cout << max({dp[0], dp[1], dp[2]}) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let q: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans = 1usize << 30;
    for i in 0..n {
        let mut cand1: Vec<Vec<usize>> = Vec::new();
        let mut cand2: Vec<usize> = Vec::new();
        cand1.push(Vec::new());
        for j in 0..n {
            if a[i] > a[j] {
                cand1.push(Vec::new());
            } else {
                cand1.last_mut().unwrap().push(a[j]);
            }
        }

        for mut v in cand1 {
            v.sort();
            if v.len() < k {
                continue;
            }
            for j in 0..v.len() - k + 1 {
                cand2.push(v[j]);
            }
        }
        if cand2.len() >= q {
            cand2.sort();
            ans = std::cmp::min(ans, cand2[q - 1] - a[i]);
        }
    }

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


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

int main() {
  ll N,H;
  cin >> N >> H;
  vector<ll> a(N);
  vector<ll> b(N);
  rep(i,N){
      cin >> a[i];
      cin >> b[i];
  }
  vector<pair<ll,ll>> p(N);
  rep(i,N){
      p[i].first = a[i];
      p[i].second = b[i];
  }

  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());

  ll aMAX = p[0].first;
  ll bm = p[0].second;//aMAXの相方

  ll count = 0;
  
  //先に刀を投げる攻撃を行っておく
  int i = 0;
  while(H > 0 && b[i] >= aMAX){   
        H -= b[i];
        count++; 
        i++;
      }
 if(H > 0){
      count += (H+aMAX-1)/aMAX;
 }
 cout << count << endl;
}

Measured memory_bytes: 3328
n, m = [int(i) for i in input().split()]

foods = [0] * (m + 1)
for i in range(0, n):
    a = [int(i) for i in input().split()]
    for j in range(1, len(a)):
        foods[a[j]] = foods[a[j]] + 1

cnt = 0
for k in range(0, m + 1):
    if foods[k] == n:
        cnt = cnt + 1
print(cnt)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int dfs(string s){
  string t = s.substr(1, s.length()-2);
  if(t[0] != '['){
    int tmp = stoi(t);
    return tmp/2+1;
  }
  int layer = 0;
  int st = 0;
  int ret = 0;
  vector<int> cands;
  for(int i = 0; i < t.length(); i++){
    if(t[i] == '['){
      if(layer == 0){
        st = i;
      }
      layer++;
    }
    if(t[i] == ']'){
      layer--;
      if(layer == 0){
        string sub = t.substr(st, i - st + 1);
        cands.push_back(dfs(sub));
      }
    }
  }
  sort(cands.begin(), cands.end());
  for(int i = 0; i < cands.size()/2 + 1; i++){
    ret += cands[i];
  }
  return ret;
}

void solve(){
  string s;
  cin >> s;
  cout << dfs(s) << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  for(int i = 0; i < n; i++){
    solve();
  }
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



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

int main() {
  int A,B,C;
  scanf("%d %d %d", &A,&B,&C);

  if(A<C && B>C) cout << "Yes" << endl;
  

  else if(A>C && B<C) cout << "Yes" << endl;

  else cout << "No" << endl;



}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;

int main() {
    ll n;
    cin >> n;
    vector<vector<int>> dp(100, vector<int>(2));

    vector<int> digits;
    while (n > 0) {
        digits.push_back(n % 10);
        n /= 10;
    }
    reverse(digits.begin(), digits.end());

    dp[0][0] = digits[0];
    dp[0][1] = digits[0] - 1;

    for (size_t i = 1; i < digits.size(); i++)
    {
        // 元と同じ数
        dp[i][0] = dp[i-1][0] + digits[i];

        // 元より小さい数
        if (digits[i] == 0){ 
            dp[i][1] = dp[i-1][1] + 9;
        } else {
            dp[i][1] = max(dp[i-1][1] + 9, dp[i-1][0] + digits[i] - 1);
        }
    }
    cout << max(dp[digits.size() - 1][0], dp[digits.size() - 1][1]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<bool> red(n,false);
    vector<int> bowl(n,1);
    red[0]=true;
    rep(i,m)
    {
        int x,y;
        cin>>x>>y;
        if(red[x-1])
        {
            red[y-1]=true;
            bowl[x-1]--;
            bowl[y-1]++;
            if(bowl[x-1]==0)red[x-1]=false;
        }
        else
        {
            bowl[x-1]--;
            bowl[y-1]++;
        }
        
    }
    int ans=0;
    rep(i,n)
    {
        if(red[i])
        {
            ans++;
        }
    }
    cout<<ans;

}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << n / 3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
int main() {
 	ll a, b, k;
  cin >> a >> b >> k;
  
  if(a >= k) {
   	cout << a - k << " " << b << endl;
  }
  else if(a + b >= k) {
   cout << 0 << " " << a + b - k << endl; 
  }
  else {
   	cout << 0 << " " << 0 << endl; 
  }
  return 0;
}

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

public class Main{
    public static void main(String[]args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      sc.close();
      int ans = 0;
      ans = (n - m)*100 + 1900*m;
      ans *= kakuritsu(m);
      System.out.println(ans);
    }  
    static int kakuritsu(int m){
        int n = 1;
        for(int i = 1;i <= m;i++){
            n *= 2;
        }
        return n;
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

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

using namespace std;

int main(){
    int n, k;

    cin >> n >> k;

    double ans = 0.0;

    for(int i = 1; i <= n; i++){
        int a = i;
        double b = 1.0;
        while( a < k ){
            a *= 2;
            b /= 2.0;
        }
        ans += b/n;
    }
    printf("%.12lf\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
name = []
time = []
for i in range(n):
    tmp = input().split()
    name.append(str(tmp[0]))
    time.append(int(tmp[1]))
    
total = 0
result = []
while True:
    try:
        if time[0] > q:
            total += q
            time[0] = time[0] - q
            tmp = time.pop(0)
            time.append(tmp)
            tmp = name.pop(0)
            name.append(tmp)
        elif q >= time[0] and time[0] > 0:
            total += time[0]
            time.pop(0)
            a = name.pop(0)
            print(a,total)
        else:
            break
    except:
        break

Measured memory_bytes: 11572
import java.util.Arrays;
import java.util.Scanner;
//B - 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition)

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next()); //StringをIntに変換する
		int l = Integer.parseInt(sc.next());

		String[] ans = new String[n];
		for (int i=0; i< n; i++) {
			ans[i] = sc.next();
		}

		Arrays.sort(ans); //昇順で並べ替え

		for (int i = 0; i < ans.length; i++) {
			System.out.print(ans[i]);
		}
	}
}


Measured memory_bytes: 24276
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

using namespace std;
//-------------------------------------

#define ll long long
#define ull unsigned long long
#define sc(x) scanf("%lld",&x)
#define sc2(x,y) scanf("%lld%lld",&x,&y)
#define sci(x) scanf("%d",&x)
#define sci2(x,y) scanf("%d%d",&x,&y)

#define rep(i,a,n) for(int i=a;i<n;i++)
#define mem(x) memset(x,0,sizeof x)
#define all(x) x.begin(),x.end()
#define xx first
#define yy second
#define inf 999999999999999
#define mkp(x,y) make_pair(x,y)
#define pii pair<ll,ll>
#define pb(x)  push_back(x);

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

#define MX 200007

#define pi 2*acos(0.00)

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)


int main()
{
    ll i, j, l, u, v, w, x, y, z, a, b, c, d, e, f, t = 1, tc;
    ll flg, sz, cnt, gt, ans, mx, mn;
    ll m, k, n;
    ll low, hi, md, inp[MX], sm, ff;

    sc2(n,x);

    a = n-x;
    b = x;
    ans = 0;

    while(b)
    {
        if(a>b) swap(a,b);
        ll bari = b/a;
        ans+=(bari*3*a);
        b = b%a;
    }
    printf("%lld\n",ans);





    return 0;

}
/*








*/



Measured memory_bytes: 256
import collections
N, M = map(int, input().split())
a = [0]*M
b = [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())
table = collections.defaultdict(int)

for i in range(M):
    table[a[i]] += 1
    table[b[i]] += 1

odd = []
for x in table:
    if table[x] % 2 == 1:
        odd.append(x)

if len(odd) > 0:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 16500
import math

def get_distance(x,y):
    d = math.sqrt(x**2+y**2)
    return d

n,d = map(int,input().split())
L=[list(map(int, input().split())) for i in range(n)]
cnt=0

for x, y in L:
    if get_distance(x,y)<=d:
        cnt += 1

print(cnt)

Measured memory_bytes: 45456
#include<bits/stdc++.h>
namespace imzzy{
	#define endl '\n'
	#define rgi register int
	#define rgl register long long
	#define ll long long
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL);
	#endif
}}using namespace imzzy;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=5000004;
const int /*mod=1000000007,*/inf=1201201201;

ll k;
inline ll powmod(ll a,ll b) {
	ll res=1;
	while(b>0) {
		if(b&1) (res*=a)%=k;
		(a*=a)%=k,b>>=1;
	} return res;
}
signed main()
{P_INIT();
	// freopen("tt.in","r",stdin);
	// freopen("tt.out","w",stdout);
	fin>>k;
	if(k%2==0||k%5==0) return puts("-1"),0;
	ll t=0;
	for(rgi i=1;i<=k+10;++i) {
		(t+=7*powmod(10,i))%=k;
		if(t==0) return fout<<i,0;
	}
	return 0;
}
// ----------------------------
// by imzzy

Measured memory_bytes: 3592
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t M = 1e6 + 5;
const int MOD = 998244353;

void inc(int &dp, int val) {
    dp += val;
    if (dp >= MOD) {
        dp -= MOD;
    }
}

void dec(int &dp, int val) {
    dp -= val;
    if (dp < 0) {
        dp += MOD;
    }
}

int inv[M], cnt[M], f[M], g[M];

int main() {
    inv[0] = inv[1] = 1;
    for (unsigned i = 2; i < M; ++i) {
        inv[i] = MOD - (LL) (MOD / i) * inv[MOD % i] % MOD;
    }
    int n = read(), ans = 0;
    for (int i = 0; i < n; ++i) {
        int a = read();
        inc(cnt[a], a);
        dec(ans, a);
    }
    for (unsigned i = M - 1; i; --i) {
        for (unsigned j = i; j < M; j += i) {
            inc(f[i], cnt[j]);
        }
    }
    for (unsigned i = M - 1; i; --i) {
        g[i] = (LL) f[i] * f[i] % MOD;
        for (unsigned j = i << 1; j < M; j += i) {
            dec(g[i], g[j]);
        }
    }
    for (unsigned i = 1; i < M; ++i) {
        ans = (ans + (LL) g[i] * inv[i]) % MOD;
    }
    if (ans & 1) {
        ans += MOD;
    }
    ans >>= 1;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 16384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define all(a) a.begin(), a.end()

int N, M;
vector<int> x, y;

int input() {
    int a;
    cin>>a;
    return a;
}

bool check() {
    return *max_element(all(x)) >= *min_element(all(y));
}

int main() {
    
    cin >> N >> M;
    x.pb(input());
    y.pb(input());
    for( int i=0; i < N; ++i)x.pb(input());
    for( int i=0; i < M; ++i)y.pb(input());

    if(check())cout << "War" << endl;
    else cout << "No War" <<endl;

    return 0;
}

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

namespace TYC
{
	typedef long long ll;
	const int N = 605, mod = 1e9 + 7;

	int n, A[N], P[N], F[2][N][N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	inline void add(int &a, const int b) { a = (a + b) % mod; }

	void work()
	{
		n = read() << 1;
		for (int i = 1; i <= n; i++)
			if (~(A[i] = read()))
				P[A[i]] = 1;
		int cnt = 0;
		for (int i = 1; i <= n; i += 2)
			if (~A[i] && ~A[i + 1])
				P[A[i]] = P[A[i + 1]] = 2;	
			else if (A[i] == -1 && A[i + 1] == -1)
				cnt++;
		F[n & 1][0][0] = 1;
		for (int i = n, c[2] = {0}; i; i--)
		{
			int d = i & 1;
			if (P[i] == 2)
				memcpy(F[d ^ 1], F[d], sizeof(F[d]));
			else
			{
				memset(F[d ^ 1], 0, sizeof(F[d ^ 1]));
				for (int j = 0, v; j <= c[1]; j++)
					for (int k = 0; k <= c[0]; k++)
						if ((v = F[d][j][k]))
						{
							if (P[i] == 0)
							{
								if (j)
									add(F[d ^ 1][j - 1][k], int((ll)v * j % mod));
								if (k)
									add(F[d ^ 1][j][k - 1], v);
								add(F[d ^ 1][j][k + 1], v);	
							}
							else if (P[i] == 1)
							{
								add(F[d ^ 1][j + 1][k], v);
								if (k)
									add(F[d ^ 1][j][k - 1], v);
							}
						}
				c[P[i]]++;
			}
		}
		int ans = F[0][0][0];
		for (int i = 1; i <= cnt; i++)
			ans = int((ll)ans * i % mod);
		printf("%d\n", ans);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    int nn;
    nn = n * 100;
    int tax = 108;
    int x;
    x = nn / tax;
    if(x * 108 / 100 == n){
        cout << x << endl;
    }
    else if((x + 1) * 108 / 100 == n){
        cout << x + 1 << endl;
    }
    else{
        cout << ":(" << endl;
    }
    

}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;
vector<int> bs;

vector<ll> ss_a;
vector<ll> ss_b;

int main(void) {
    int N, M;
    ll K;
    cin >> N >> M >> K;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    bs.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> bs[i];
    }

    ss_a.resize(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        ss_a[i] = ss_a[i - 1] + as[i - 1];
    }

    ss_b.resize(M + 1, 0);
    for (int i = 1; i <= M; i++) {
        ss_b[i] = ss_b[i - 1] + bs[i - 1];
    }

    int ans = 0;

    for (int num_a = 0; num_a <= N; num_a++) {
        const ll acc_a = ss_a[num_a];
        ll rem = K - acc_a;
        if (rem >= 0) {
            int left = 0, right = M + 1, mid;
            while (right - left > 1) {
                mid = left + (right - left) / 2;
                if (ss_b[mid] <= rem) {
                    left = mid;
                } else {
                    right = mid;
                }
            }
            chmax(ans, num_a + left);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef long double lb;
#define ri register int
const lb PI=3.141592653589793238462643383279;
const ll inf=1000000000000000000ll;
const int N=100005,M=1000000007;
int n,i,j,k,l,x,m;
long long f[505][505][505],a[505],inv[505],ans,fac[505];
long long qpow(long long a,long long b)
{
	long long s=a,ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*s%M;
		s=s*s%M;
		b>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d %d",&n,&x);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&m);
		++a[m];
	}
	fac[0]=inv[0]=1;
	for(i=1;i<=x;++i)
	{
		inv[i]=inv[i-1]*qpow(i,M-2)%M;
		fac[i]=fac[i-1]*i%M;
	}
	f[x+1][0][0]=1;
	for(i=x;i>=1;--i)
	{
		for(j=0;j<=x;++j)
			for(k=0;x-k+1>=j;++k)
				for(l=0;l*i<=k&&l<=j;++l)
					f[i][j][k]=(f[i][j][k]+f[i+1][j-l][k-l*i]*inv[l])%M;
		if(a[i])
		{
			for(j=0;j<=x;++j)
				for(k=0;k<=x;++k)
					f[i][j][k]=f[i][j][k]*qpow(k-(i-1)*j,a[i])%M;
		}
	}
	for(i=0;i<=x;++i)
		for(j=0;j<=x;++j)
			if(x-j+1>=i)
				ans=(ans+f[1][i][j]*fac[x-j+1]%M*inv[x-j+1-i]*((x-j)&1?-1:1))%M;
	cout<<(ans%M+M)%M;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n,k,s;
	cin>>n>>k>>s;

	vector<ll> a(n,0);
	if(s==1e9){
		rep(i,n){
			if(i<k){
				a[i]=1e9;
			}else{
				a[i]=1;
			}
		}
	}else{
		rep(i,n){
			if(i<k){
				a[i]=s;
			}else{
				a[i]=1e9;
			}
		}	
	}

	for(auto x:a)cout<<x<<" ";
	cout<<endl;

	return 0;
}

Measured memory_bytes: 2048
def main():
    N, Q = (int(i) for i in input().split())
    S = input()
    LR = [[int(i) for i in input().split()] for j in range(Q)]
    AC = [0]*N
    for i, s in enumerate(S):
        AC[i] = AC[i-1]
        if i > 0 and S[i-1] == "A" and s == "C":
            AC[i] += 1
    S = list([0] + AC)
    for le, ri in LR:
        print(S[ri] - S[le])


if __name__ == '__main__':
    main()


Measured memory_bytes: 25200
#include "omp.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <random>
#include <bitset>
#include <unordered_set>
#include <cassert>
#include <list>


using namespace std;

typedef long long ll;
typedef long double ld;


const int sze = 51, M = 5e3 + 1, psze = 15;
const ll INF = 1e15;

vector<ll> cnt;
int n;


ll get(int l, int r)
{
	if (!l)
		return cnt[r];
	else
		return cnt[r] - cnt[l - 1];
}


ll count(int l1, int r1, int l2, int r2, int l3, int r3, int l4, int r4)
{
	ll a = get(l1, r1), b = get(l2, r2), c = get(l3, r3), d = get(l4, r4);
	return max(max(max(a, b), c), d) - min(min(min(a, b), c), d);
}


signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n;
	vector<int> values(n);
	for (int i = 0; i < n; ++i)
		cin >> values[i];

	cnt.resize(n);
	cnt[0] = values[0];
	for (int i = 1; i < n; ++i)
		cnt[i] += cnt[i - 1] + values[i];

	ll ans = INF;
	for (int i = 1; i + 2 < n; ++i)
	{
		int l = 0, r = i - 1;
		while (r - l > 1)
		{
			int m = (l + r) >> 1;
			if (cnt[m] <= cnt[i] - cnt[m])
				l = m;
			else
				r = m;
		}

		int ind1 = l, ind2 = r;

		l = i + 1, r = n - 2;
		while (r - l > 1)
		{
			int m = (l + r) >> 1;
			if (cnt[m] - cnt[i] <= cnt[n - 1] - cnt[m])
				l = m;
			else
				r = m;
		}

		ans = min(ans, count(0, ind1, ind1 + 1, i, i + 1, l, l + 1, n - 1));
		ans = min(ans, count(0, ind1, ind1 + 1, i, i + 1, r, r + 1, n - 1));
		ans = min(ans, count(0, ind2, ind2 + 1, i, i + 1, l, l + 1, n - 1));
		ans = min(ans, count(0, ind2, ind2 + 1, i, i + 1, r, r + 1, n - 1));
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 2560
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] d = GetInts(N);
		
		int ans = 0;
		for(int i = 0; i < N; i++)
			for(int j = i + 1; j < N; j++)
				ans += d[i] * d[j];

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstring>
#include <vector>
#include <cctype>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    double a, b, C;
    cin >> a >> b >> C;
    C = C * M_PI / 180;
    double S = a*b*sin(C)/2;
    if( S < 0 ) S *= -1;
    double c = (sqrt)(a*a + b*b - 2.0*a*b*cos(C));
    double h = c*(sqrt)(1.0 - (pow)((a*a+c*c-b*b)/(2.0*a*c), 2.0));

    printf("%.5f\n%.5f\n%.5f\n", S, a+b+c, h);
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T >
void warshall_floyd(Matrix< T > &g, T INF) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

ll pw2(ll n){
  ll res=1;
  ll tmp=2;
  while(n>0){
    if(n&1) res*=tmp;
    tmp*=tmp;
    n = n>>1LL;
  }
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;  
  Matrix< int > mat(n, vector< int >(n, INT_MAX/8));
  map<pair<int,int>, int> edge;
  for(int i = 0; i < n; i++) mat[i][i] = 0;
  for(int i = 0; i < n-1; i++) {
    int a,b;
    cin >> a >> b;
    --a;--b;
    if(a>b) swap(a,b);
    edge[{a,b}]=i;
    mat[a][b] = 1;
    mat[b][a] = 1;
  }
  warshall_floyd(mat, INT_MAX/8);
      
  int m;
  cin >> m;
  vector<set<int>> s(m);
  rep(i,m){
    int u,v;
    cin >> u >> v;
    --u;--v;
    rep(j,n){
      rep(l,n){
	if(mat[u][j] + mat[j][l] + mat[l][v] == mat[u][v] && mat[j][l]==1){
	  if(j<l){
	    s[i].insert(edge[{j,l}]);
	  }
	  else{
	    s[i].insert(edge[{l,j}]);
	  }
	}
      }
    }    
  }
  ll ans = 0;
  for(int i=1; i <(1LL << m); i++){
    ll pm=0;
    if(__builtin_popcount(i)%2==0) pm=1;
    else pm = -1;
    ll cnt=0;
    rep(j,n-1){
      rep(l,m){
	if((1LL<<l) & i){
	  if(s[l].count(j)){
	    cnt++;
	    break;
	  }
	}
      }
    }
    ans += pm * pw2(n-1-cnt);
    //    cout << "i cnt ans " << bitset<8>(i) << endl;
    //    cout << cnt << " " << ans << endl;
  }
  cout << pw2(n-1) + ans << endl;

  
  //  cout << endl << endl;
  //  cout << static_cast<double>(clock()) / CLOCKS_PER_SEC << "s"<<endl;
  return 0;
    

}


Measured memory_bytes: 256
S = input()
Q = int(input())
bs = ''
fs = ''
hanten = 0
for i in range(Q):
    query = list(input().split())
    if query[0] == '1':
        hanten += 1
    else:
        if query[1] == '1':
            if hanten % 2 == 0:
                fs += query[2]
            else:
                bs += query[2]
        else:
            if hanten % 2 == 0:
                bs += query[2]
            else:
                fs += query[2]
if hanten % 2 == 0:
    print(fs[::-1]+S+bs)
else:
    print(bs[::-1]+S[::-1]+fs)

Measured memory_bytes: 225672
import sys 
input = lambda : sys.stdin.readline().strip()
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    ok = True
    for i in range(n):
        ans*=a[i]
        if ans>(10**18):
            ok = False
            break
    if ok:
        print(ans)
    else:
        print('-1')

Measured memory_bytes: 21600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e6+6;
const int mod = 1e9+7;
const int inf = 1e8;
ll cnt[N];
void f(int x){
    for(int i=2;i<=x;i++){
        while(x%i==0){
            cnt[i]++;
            x/=i;
        }
    }
}
void solve(){
    int n;
    cin>>n;
    for(int i=2;i<=n;i++)f(i);
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans*=(cnt[i]+1);
        ans%=mod;
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        A = list(map(int, input().split()))
        F = list(map(int, input().split()))

        A.sort()
        F.sort(reverse=True)

        l, r = -1, 10 ** 12
        while l + 1 < r:
            mid = (l + r) // 2

            s = 0
            for i in range(N):
                s += max(0, A[i] - mid // F[i])
            if s <= K:
                r = mid
            else:
                l = mid
        print(r)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 106956
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""


# ABC 101 C Minimization
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K))
    A = getIntList()
    d.dmp(A)
    count = (N-1+K-2)//(K-1)
    return count


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w,a,b;
	cin>>w>>a>>b;
	if(a>b){
		if(a-(b+w)<=0){
			cout<<0<<endl;
		}else{
			cout<<a-(b+w)<<endl;
		}
	}else if(a<b){
		if(b-(a+w)<=0){
			cout<<0<<endl;
		}else{
			cout<<b-(a+w)<<endl;
		}
	}else{
		cout<<0<<endl;
	}
}


Measured memory_bytes: 256
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
chomp $n;
my @a;
{
    my $in = <STDIN>;
    @a = split(" ", $in);
}
@a = grep { $_ % 2 == 0 } @a;

my $ans = "APPROVED";
for my $b (@a)
{
    $ans = "DENIED" if $b % 3 > 0 & $b % 5 > 0;
}
print "$ans\n";

Measured memory_bytes: 640
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 10
typedef long long LL;
int L,R;
int main(){
    int ans=2020;
	scanf("%d%d",&L,&R);
	if(L/2019<R/2019) {
        puts("0");
        return 0;
	}
    for(int i=L%2019;i<R%2019;i++)
        for(int j=i+1;j<=R%2019;j++)
            ans=min(ans,i*j%2019);
    printf("%d",ans);
}


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

int main() {
  string S,T, Stmp; cin >> S >> T;
  if (T.length()>S.length()) {cout << "UNRESTORABLE" << "\n"; return 0;}
  int len = S.length() - T.length()+1;
  bool flg=true;
  vector<string> Sarray(0);
  for (int i=0; i<len; i++) {
    Stmp = S;
    flg = true;
    for  (int j=0; j<T.length(); j++) if (Stmp[i+j]!=T[j]&&Stmp[i+j]!='?') flg=false;
    if (flg) {
      for  (int j=0; j<T.length(); j++) Stmp[i+j]=T[j];
      for  (int j=0; j<Stmp.length(); j++) if (Stmp[j]=='?') Stmp[j]='a';
      Sarray.push_back(Stmp);
    }
  }
  if (Sarray.size()==0) {cout << "UNRESTORABLE" << "\n"; return 0;}
  sort(Sarray.begin(),Sarray.end());
  cout << Sarray[0] << "\n";
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

int main(){
	int a[2];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);

	cout<<a[0]+a[1]<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);

#define int long long

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    ll n;
    cin>>n;
    string ans;
    
    //Simple tc:
    //  1 : a 
    //  27: aa

    while(n>0)
    {
        n-=1;
        ll r = (n%26);//0 to 25
        n/=26;
        char c = r+'a';
        ans.push_back(c);
    }
    reverse(all(ans));
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int a[100];
int b[100];

int main () {
  cin >> N >> M;
  for (auto i = 0; i < M; ++i) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  int ans = 0;
  for (auto k = 0; k < M; ++k) {
    vector<int> V[100];
    for (auto i = 0; i < M; ++i) {
      if (i == k) continue;
      V[a[i]].push_back(b[i]);
      V[b[i]].push_back(a[i]);
    }
    bool visited[100];
    fill(visited, visited+N, false);
    stack<int> S;
    S.push(0);
    int cnt = 0;
    while (!S.empty()) {
      int now = S.top();
      S.pop();
      if (!visited[now]) {
        ++cnt;
        visited[now] = true;
        for (auto x : V[now]) {
          if (!visited[x]) {
            S.push(x);
          }
        }
      }
    }
    if (cnt < N) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

vector<vector<pair<int, int>>> graph;
vector<int> res;

void dfs(int p, int id, int c) {
  res[id] = c;
  for (auto tmp : graph[id]) {
    if (tmp.first == p)
      continue;

    if (tmp.second & 1)
      dfs(id, tmp.first, 1 - c);
    else
      dfs(id, tmp.first, c);
  }
}

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

  int n;
  cin >> n;

  graph.assign(n, vector<pair<int, int>>());
  rep (i, 0, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;

    u -= 1;
    v -= 1;
    graph[u].push_back(make_pair(v, w));
    graph[v].push_back(make_pair(u, w));
  }

  res.assign(n, 0);
  dfs(-1, 0, 0);

  rep (i, 0, n)
    cout << res[i] << endl;

	return 0;
}


Measured memory_bytes: 8960
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a1 = scan.nextInt();
        int a2 = scan.nextInt();
        int a3 = scan.nextInt();
        if (21 < a1 + a2 + a3) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}


Measured memory_bytes: 23636