akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};


template<typename T>
struct Combination {
private:
  int sz;
  vector<T> F, F_;
public:
  Combination(int sz) : sz(sz), F(sz+1), F_(sz+1) {
    F[0] = 1;
    for(int i = 0; i < sz; ++i) F[i+1] = F[i]*(i+1);
    F_.back() = (T)1/F.back();
    for(int i = sz-1; i >= 0; --i) F_[i] = F_[i+1]*(i+1);
  }
  T C(int n, int k){
    assert(n <= sz);
    if(n < 0 or k > n) return (T)0;
    return F[n]*F_[k]*F_[n-k];
  }
};

int main(){
  using mint = modint<(int)1e9+7>;

  int r1, r2, c1, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  //f(r,c) = (r+c)Cr
  //f(r+1,c) = (r+1+c)C(c) = (r+c)C(c) + (r+c)C(c-1)
  //(r+c)C(c-1) = (r-1)/c*(r+c)C(c)
  Combination<mint> comb((int)2e6+10);
  mint s = comb.C(r1+c1,c1);
  mint ans = s;
  int c_min = c1, c_max = c1;
  for(int r = r1+c1+1; r <= r2+c2; ++r){
    int c_min_ = max(c1,r-r2);// c_min_ >= c_min
    int c_max_ = min(c2,r-r1);// c_max_ >= c_max
    // sum(rCc | c_min <= c <= c_max)
    s *= 2;
    s -= comb.C(r-1,c_max);
    s += comb.C(r-1,c_min-1);
    for(int c = c_min; c < c_min_; ++c){
      s -= comb.C(r,c);
    }
    for(int c = c_max+1; c <= c_max_; ++c){
      s += comb.C(r,c);
    }
    ans += s;
    c_min = c_min_;
    c_max = c_max_;
  }
  cout << ans << endl;
}


Measured memory_bytes: 31488
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

template<class T>
inline bool ch2100(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;
}

ll fac[2100], finv[2100], inv[2100];
 
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < 2100; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int N, K;
int main () {
  cin >> N >> K;

  COMinit();

  rep(i, K) {
    ll int x = COM(N-K+1, i);
    ll int y = COM(K-1, i-1);
    cout << (x * y) % MOD << "\n";
  }
}

Measured memory_bytes: 256
#105 という数は, 非常に特殊な性質を持つ - 奇数なのに, 約数が 8 個もある.
#さて, 1 以上 N 以下の奇数のうち, 正の約数を ちょうど 8 個持つようなものの個数を求めよ.
# N は 1 以上 200 以下の整数
# 入力は奇数

N = int(input())
# 半分にして、割れるものをカウント
# 105の場合、[1, 3, 5, 7, 15, 21, 35, 105]


ans_num = 0


for a in range(1, N + 1):
  yakusuu = []
  if a % 2 == 0:
    continue
  for i in range(1, a+1):
    if a % i == 0:
      yakusuu.append(i)
  if len(yakusuu) == 8:
    ans_num = ans_num + 1

print(ans_num)

Measured memory_bytes: 3060
#include <stdio.h>

long long gcd(long long a, long long b){
    if(!b) return a;
    return gcd(b, a%b);
}

int main(){
    long long N, X;
    scanf("%lld%lld", &N, &X);
    printf("%lld", (N-gcd(N,X))*3);
    return 0;
}

Measured memory_bytes: 128
n,d = map(int,input().split())
data = [list(map(int,input().split())) for i in range(n)]

def ok(x,y):

    z = 0
    for i in range(d):
        z += (x[i]-y[i])**2
    if z**(0.5) == int(z**(0.5)):
        return True
    else:
        return False

ans = 0
for i in range(n):
    for j in range(i+1,n):
        if ok(data[i],data[j]):
            ans += 1

print(ans)

Measured memory_bytes: 3188
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

int dfs1(vector<vector<int>> &da, vector<int> &c, vector<bool> &used, vector<ll> &co, int now){
    rip(i, da[now].size(),0){
        if(used[da[now][i]]) continue;
        used[da[now][i]] = true;
        co[now] += dfs1(da, c, used, co, da[now][i]);
    }
    co[now]++;
    return co[now];
}

ll cal(ll x){
    return x*(x+1)/2;
}

void dfs2(vector<vector<int>> &da, vector<int> &c, vector<bool> &used, vector<ll> &ans, vector<ll> &lam, vector<ll> &co, int now){
    ll tmp = lam[c[now]];
    lam[c[now]] = 0;
    rip(i, da[now].size(),0){
        if(used[da[now][i]]) continue;
        used[da[now][i]] = true;
        dfs2(da, c, used, ans, lam, co, da[now][i]);
        ans[c[now]] += cal(co[da[now][i]]-lam[c[now]]);
        // cout  << co[da[now][i]] MM lam[c[now]] << endl;
        lam[c[now]] = 0;
    }
    lam[c[now]] = tmp + co[now];
    return;
}

int main(){
    ll n; cin >> n;
    vector<int> c(n);
    rip(i,n,0) cin >> c[i], --c[i];
    vector<vector<int>> da(n, vector<int>(0));
    rip(i,n-1,0){
        int a,b; cin >> a >> b;
        --a;--b;
        da[a].push_back(b);
        da[b].push_back(a);
    }
    vector<bool> used(n, false);
    vector<ll> co(n);
    vector<ll> ans(n), lam(n);
    used[0] = true;
    dfs1(da, c, used, co, 0);
    rip(i,n,1) used[i] = false;
    // used[0] =true;
    dfs2(da, c, used,ans,lam, co, 0);
    // vdeb(lam);
    // vdeb(co);
    // vdeb(ans);
    rip(i,n,0){
        ans[i] += cal(n - lam[i]);
    }
    rip(i,n,0){
        printf("%lld\n", n*(n+1)/2 - ans[i]);
    }
}

Measured memory_bytes: 44628
#include<cstdio>
#include<algorithm>
#include<functional>
#define MM 2000000000
using namespace std;
int main(void)
{
	int n,i,j,p[4],t[4],dp[201],mn;
	scanf("%d",&n);
	for(i=0;i<4;i++)	scanf("%d",&p[i]);
	for(i=0;i<4;i++)	scanf("%d",&t[i]);
	for(i=0;i<=200;i++)	dp[i]=MM;
	dp[0]=0;
	for(i=0;i<4;i++)	{
		for(j=0;j<=n;j++)	{
			if(dp[j]!=MM)	{
				dp[j+t[i]]=min(dp[j+t[i]],dp[j]+p[i]);
			}
		}
	}
	mn=MM;
	for(i=n;i<=200;i++)	mn=min(mn,dp[i]);
	printf("%d\n",mn);
	return 0;
}


Measured memory_bytes: 2764
///==================================================///
///                HELLO WORLD !!                    ///
///                  IT'S ME                         ///
///               BISHAL GAUTAM                      ///
/// [ bsal.gautam16@gmail.com, bishal@devskill.com ] ///
///==================================================///
#include<bits/stdc++.h>
#define X first
#define Y second
#define mpp make_pair
#define nl printf("\n")
#define SZ(x) (int)(x.size())
#define pb(x) push_back(x)
#define pii pair<int,int>
#define pll pair<ll,ll>
///---------------------
#define S(a) scanf("%d",&a)
#define P(a) printf("%d",a)
#define SL(a) scanf("%lld",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
///------------------------------------
#define all(v) v.begin(),v.end()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define fr(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
typedef long long ll;
///==========CONSTANTS=============///
///  Digit     0123456789012345678 ///
#define MX     500012
#define inf    10000000000
#define MD     1000000007
#define eps    1e-9
///===============================///

map<int,int>Mp;
vector<ll>v;
int main() {
    int n,q,k,i,j,x,y;
    S(n);

    fr(i,1,n){
        S(x);
        Mp[x]++;
        if( Mp[x]==2 ){
            v.pb( (ll)x );
            Mp[x]=0;
        }
    }

    sort( all(v) );
    reverse( all(v) );
    ll ans=0;
    if( SZ(v)>=2 ){
        ans=(ll)(v[0]*v[1]);
    }

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

    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
int main() {
	int n = 0;
	while (std::cin >> n, n) {
		int A = 0, B = 0;
		for (int i = 0; i < n; ++i) {
			int a, b;
			std::cin >> a >> b;
			if (a > b) {
				A = A + a + b;
			}
			else if (a < b) {
				B = B + a + b;
			}
			else if (a == b) {
				A = A + a;
				B = B + b;
			}
		}
		std::cout << A <<" "<< B << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11
#define ASK 7

int sum_or_dif(int a, int b, char op); 
int calc(Vec<int> array, string op, int posi); 
bool check_seven(string num, string op); 
string make_op(string num, int index);

int main(void) {
    string num;
    cin >> num;
    int num_len = (int)num.length();

    FOR (i, 0, pow(2, num_len - 1)) {
        string op = make_op(num, i);
        if (check_seven(num, op) == true) {
            FOR (k, 0, num_len - 1) {
                cout << num[k] << op[k];
            }
            cout << num[num_len - 1] << "=" << ASK << endl;
            break;
        }
    }
    return 0;
}

string make_op(string num, int index) {
    string ans = "";
    int len = (int)num.length() - 1;
    FOR (i, 0, len) {
        if ((index & (1 << i)) != 0)  {
            ans += '-';
        } else {
            ans += '+';
        }
    }
    return ans;
}

int sum_or_dif(int a, int b, char op) {
    if (op == '+') {
        return a + b;
    } else if (op == '-') {
        return a - b;
    } else {
        return 0;
    }
}

int calc(Vec<int> array, string op, int posi) {
    if (posi == 0) {
        return sum_or_dif(array[0], array[1], op[0]);
    } else {
        return sum_or_dif(calc(array, op, posi - 1), array[posi + 1], op[posi]);
    }
}

bool check_seven(string num, string op) {
    Vec<int> array((int)num.length());
    FOR (i, 0, (int)num.length()) {
        array[i] = (int)(num[i] - '0');
    }

    if (calc(array, op, (int)num.length() - 2) == ASK) { // 2 は 配列の長さ-2
        return true;
    } else {
        return false;
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


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

  c_fac();
  ll result = 0;
  rep(i,min(n,k+1)) { result += nck(n,i)*nck(n-1,i); result %= MOD; }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N=0;
  	cin >> N;
  	
  	string Arare;
  	int j = 0;
	while (j < N) {
      cin >> Arare;
      if (Arare=="Y"){
      	cout << "Four" <<endl;
        break;
      }
      j++;
      if (j==N){
        cout << "Three" <<endl;
      }
  	}
}

Measured memory_bytes: 256
/*
ID:dyx_6661
TASK:
LANG:
*/
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
#include<deque>
#include<set>
#include<map>
#include<vector>
#include<iostream>
using namespace std;
typedef long long int ll;
typedef double db;
typedef string str;
typedef pair<int,int> pa;
typedef vector<int> vec;

int n;
db a[105];

int main(){
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf",&a[i]);
		a[i]=a[i-1]+1/a[i];
	}
	printf("%.7lf",1/a[n]);
	return 0;
}


Measured memory_bytes: 256
def pare_exist(ST_pare_lst, Si, Ti):
    if (Si, Ti) in ST_pare_lst:
        return True
    else:
        for Sj, Tj in ST_pare_lst:
            if (Sj == Si and Tj != Ti) or (Sj != Si and Tj == Ti):
                return False
        
        ST_pare_lst.append((Si, Ti))
        return None

def exchanging(S, T):
    ST_pare_lst = []
    length = len(S)

    for i in range(length):
        judge = pare_exist(ST_pare_lst, S[i], T[i])
        if judge is None:
            pass
        elif judge == True:
            pass
        else:   #   judge == False
            return False
    return True

def same_chr_contain(S, T):
    S_chr_lst = []
    T_chr_lst = []
    for i in range(len(S)):
        if not S[i] in S_chr_lst:
            S_chr_lst.append(S[i])
        if not T[i] in T_chr_lst:
            T_chr_lst.append(T[i])

    if len(S_chr_lst) == len(T_chr_lst):
        return True
    else:
        return False

S = input()
T = input()

ST_pare_lst = []
length = len(S)

if not same_chr_contain(S, T):
    print("No")
elif exchanging(S, T):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final String s = scanner.next();
        if (s.charAt(1) == 'R') {
            System.out.println("ABC");
        } else {
            System.out.println("ARC");
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

Measured memory_bytes: 32536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << (H2*60 + M2)-(H1*60 + M1)-K << endl;
}

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

using namespace std;

using ll = long long;

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

    ll x, y;
    cin >> x >> y;

    ll len = 0;
    for (ll n = x; n <= y; n *= 2) ++len;

    cout << len << endl;

    return 0;
}


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

using namespace std;
using LLI = long long int;

//struct UnionFind {
//	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//		for (int i = 0; i < N; i++) par[i] = i;
//	}
//
//	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//		if (par[x] == x) return x;
//		return par[x] = root(par[x]);
//	}
//
//	void unite(int x, int y) { // xとyの木を併合
//		int rx = root(x); //xの根をrx
//		int ry = root(y); //yの根をry
//		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//	}
//
//	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//		int rx = root(x);
//		int ry = root(y);
//		return rx == ry;
//	}
//};

int main(void) {
	LLI N, K;
	cin >> N >> K;
	if (N%K == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
}

Measured memory_bytes: 256
f [a,b] c k = if c==0 then [a,b] else if k==0 then if mod a 2 ==1 then f [div(a-1)2,b+div(a-1)2] (c-1) 1 else f [div a 2,b+div a 2] (c-1) 1
               else if mod b 2 == 1 then f [a+div(b-1)2,div(b-1)2] (c-1) 0 else f [a+div b 2,div b 2] (c-1) 0
main=do
 [a,b,c]<-map read.words<$>getLine
 putStrLn$unwords$map show$f [a,b] c 0

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

using namespace std;

uint64_t g(uint64_t a, uint64_t b) {
  if (a % b == 0)
    return b;
  auto x = a - b;
  if (x < b)
    swap(x, b);
  return g(x, b);
}

void solve() {
  uint64_t a, b;
  cin >> a >> b;
  if (a < b) {
    swap(a, b);
  }
  cout << (a / g(a, b) * b) << endl;
}

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


Measured memory_bytes: 256
def calc(a):
  ret = 0
  while a != 0:
    ret += a % 10
    a //= 10
  return ret

def resolve():
  n = int(input())
  ans = 1000000000
  for a in range(1, n):
    b = n - a
    ans = min(ans, calc(a) + calc(b))
  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

    int a, b;
    cin>>a>>b;
    cout<<gcd(a, b)<<endl;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int fuka=0;
  int N,M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  for (int i=0; i<M; i++){
  	cin >> s.at(i) >> c.at(i);
  }
  
  //1keta no toki
  if (N==1 && M==0){
   cout << 0 << endl;
  }
  if (N==1&&M>0){
 
  	sort(c.begin(), c.end());
    if (c.at(0)!=c.at(M-1)){
    	fuka=1;
    } 
    
    if (fuka==1){
      cout << -1 << endl;
    } else {
    	cout << c.at(0) << endl;
    }
    
    
  } else {
    
  //2,3 keta no toki
  
   for (int i=0; i<M; i++){
  	 if (s.at(i)==1 && c.at(i)==0){
       fuka=1;
     }
   }
    
    for (int i=0; i<M; i++){
      for (int j=0; j<M; j++){
        if (s.at(i)==s.at(j) && c.at(i)!=c.at(j)){
          fuka=1;
        }
      }
    }
    
    //kokomade reigai shori
    
    int r1,r2,r3;
    int flag1=0;
    int flag2=0;
    int flag3=0;
    
    if (N==3){
    
      
      for (int i=0; i<M; i++){
    	if (s.at(i)==1){
        	r1=c.at(i);
          	flag1=1;
        }
    }
   if (flag1==0){
   	r1=1;
   }
   
    for (int i=0;i<M; i++){
    	if (s.at(i)==2){
        	r2=c.at(i);
          flag2=1;
        }
    }
    if (flag2==0){
    	r2=0;
    }
    
        for (int i=0;i<M; i++){
    	if (s.at(i)==3){
        	r3=c.at(i);
          flag3=1;
        }
    }
    if (flag3==0){
    	r3=0;
    }
      
     if (fuka==0){
    cout << r1*100+r2*10+r3 << endl;
 } else {
   cout << -1 << endl;
 }  
      

      // N=3 no kakko
    }
      
    
    if (N==2){
      
   for (int i=0; i<M; i++){
    	if (s.at(i)==1){
        	r1=c.at(i);
          	flag1=1;
        }
    }
   if (flag1==0){
   	r1=1;
   }
   
    for (int i=0;i<M; i++){
    	if (s.at(i)==2){
        	r2=c.at(i);
          flag2=1;
        }
    }
    if (flag2==0){
    	r2=0;
    }
    
 if (fuka==0){
  cout << r1*10+r2 << endl;
 } else {
   cout << -1 << endl;
 }
      
    }
      
    // N=2,3 no kakko
  }
  
}

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

int main(){
	long int da, we, ta;
	long int ans;
	cin>>da>>we>>ta;

	long int to_we;
	to_we=da*7+we;
	
	long int ex_we;
	long int re_we;
	ex_we=ta/to_we;
	re_we=ta%to_we;
	
	if(ex_we*to_we>ta)
	{
		ans=ex_we*7;
	}
	else
	{
		long int ad_da;
		ad_da=re_we/da;
		if(ad_da>=7)
			ans=ex_we*7+7;
		else
		{
			ans=ex_we*7+ad_da;
			if(ex_we*to_we+da*ad_da<ta)
				ans++;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> g(n);
  while (m--) {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    g[x].emplace_back(y, z);
    g[y].emplace_back(x, z);
  }
  vector<int> d(n, INT_MAX);
  vector<set<int>> s(n);
  priority_queue<pair<int, int>> pq;
  // priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
  pq.emplace(d[0] = 0, 0);
  while (!pq.empty()) {
    int expected, v;
    tie(expected, v) = pq.top();
    pq.pop();
    if (-expected != d[v]) {
      continue;
    }
    // if (expected != d[v]) {
    //   continue;
    // }
    for (const auto& e : g[v]) {
      int to, c;
      tie(to, c) = e;
      int dist = d[v] + !s[v].count(c);
      if (dist < d[to]) {
        s[to].clear();
        s[to].insert(c);
        pq.emplace(-(d[to] = dist), to);
        // pq.emplace(d[to] = dist, to);
      } else if (dist == d[to]) {
        s[to].insert(c);
      }
    }
  }
  cout << (d[n - 1] == INT_MAX ? -1 : d[n - 1]) << '\n';
  return 0;
}

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


int main(){

	string s;
	cin>>s;
	int cg = 0,cp = 0;
	int res = 0;
	for(int i=0;i<(int)s.length();i++){
		if(s[i]=='g' && cg>0 && cg>cp){
			res++;
			cp++;
			continue;
		}
		if(s[i]=='p' && cp>0 && cp==cg){
			res--;
			cg++;
			continue;
		}
		if(s[i]=='p') cp++;
		if(s[i]=='g') cg++;
	}
	cout<<res;
}

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

int main() {
	string A, B, S;
	cin >> A >> B >> S;
	if (regex_match(S, regex("\\d{" + A + "}-\\d{" + B + "}"))) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
typedef long long ll;
using namespace std;
int n;
 
void solve(string s, char m){
    for(int i=0; i<=m-'a'; i++){
        char p='a'+i;
        if(s.length()==n-1) cout << s+p << endl;
        else{
            int b=max(m-'a',i+1);
            solve(s+p,b+'a');
        }
    }
}

 
int main(){
    cin >> n;
    solve("",'a');
return 0;
}

Measured memory_bytes: 1536
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define M 1000000007

int main()
{
  ll n;
  cin>>n;
  ll mid=n/500;
  n=n-mid*500;
  ll mid2=n/5;
  cout<<mid*1000+mid2*5<<endl;
}

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

#define LL long long

using namespace std;

const int N = 200010;
int n, D, A;

struct T {
	int x, h;
}a[N];

LL tot[N];

int main() {
	scanf("%d%d%d", &n, &D, &A);

	for (int i = 1; i <= n; i++)
		scanf("%d%d", &a[i].x, &a[i].h);

	sort(a + 1, a + 1 + n, [](const T &p, const T &q) {
		return p.x < q.x;
	});

	LL ans = 0, sum = 0;
	for (int i = 1, j = 1; i <= n; i++) {
		while (j <= n && a[j].x - a[i].x <= 2 * D)
			j++;

		sum += tot[i];
		LL t = a[i].h - sum * A;
		if (t > 0) {
			LL c = t / A + (bool)(t % A);
			ans += c;

			sum += c;
			tot[j] -= c;
		}
	}

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

	return 0;
}

Measured memory_bytes: 6844
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		string a, b;
		cin >> a >> b;
		string l, s;
		a.size() >= b.size() ? (l = a, s = b) : (l = b, s = a);
		reverse(l.begin(), l.end());
		reverse(s.begin(), s.end());
		string sum;
		
		int sizel = l.size();
		int sizes = s.size();
		int buf = 0;
		for(int i = 0; i < sizes; ++i)
		{
			sum += (l[i] + s[i] - '0' - '0' + buf) % 10 + '0';
			buf = (l[i] + s[i] - 2 * '0' + buf) / 10;
		}
		for(int i = sizes; i < sizel; ++i)
		{
			sum += (l[i] - '0' + buf) % 10 + '0';
			buf = (l[i] - '0' + buf) / 10;
		}
		if(buf > 0)
		{
			sum += buf + '0';
		}
		int size = sum.size();
		if(size > 80)
		{
			cout << "overflow" << endl;
			continue;
		}
		for(int i = size - 1; i >= 0; --i)
		{
			cout << sum[i];
		}
		cout << endl;
	}
}

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

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

#define ran 303

int n, m, lim;
vector<pair<int, int> > e[ran];

int ans[ran][ran];
int q[ran*ran*ran], l, r;
pair<int, int> d[ran];

bool need_update(pair<int, int> cur, pair<int, int> candidate) {
	if (cur.first<0) return true;
	if (cur.first != candidate.first)
		return cur.first > candidate.first;
	return cur.second < candidate.second;
}

void bfs(int st) {
	for(int i=1;i<=n;i++)
		d[i] = make_pair(-1, -1);
	l = r = 0;
	q[r++] = st;
	d[st] = make_pair(0, lim);
	
	while(l<r) {
		int cur = q[l++];
		pair<int, int> cur_d = d[cur];
		for(int i=0;i<(int) e[cur].size();i++) {
			int nxt = e[cur][i].first, todo = e[cur][i].second;
			pair<int, int> nxt_d = (cur_d.second >= todo) 
				? make_pair(cur_d.first, cur_d.second - todo)
				: make_pair(cur_d.first+1, lim - todo);
			if (need_update(d[nxt], nxt_d)) {
				d[nxt] = nxt_d;
				q[r++] = nxt;
			}
		}
	}
	
	for(int i=1;i<=n;i++)
		ans[st][i] = d[i].first;
}

int main() {
	scanf("%d%d%d", &n, &m, &lim);
	for(int i=0;i<m;i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		if (c>lim) continue;
		e[a].push_back(make_pair(b, c));
		e[b].push_back(make_pair(a, c));
	}
	
	memset(ans, -1, sizeof ans);
	for(int i=1;i<=n;i++) bfs(i);
	
	int T;
	for(scanf("%d", &T); T--;) {
		int fr, to;
		scanf("%d%d", &fr, &to);
		printf("%d\n", ans[fr][to]);
	}
	
	return 0;
}

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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*input*/
int n;
int s[101];

/*funcs*/


/*main*/
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int sum=0;
    int min=100000;
    for(int i=0;i<n;i++){
        if(i==0){
            sum=s[0];
            if(s[0]<min&&s[0]%10!=0){
                min=s[0];
            }
        }else{
            sum=sum+s[i];
            if(s[i]<min&&s[i]%10!=0){
                min=s[i];
            }
        }
    }
    if(sum%10==0){
        if(min>100){
            cout<<0;
        }else{
            cout<<sum-min;
        }
    }else{
        cout<<sum;
    }
}

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

int main() {

  char c;
  cin >> c;

  if( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' )
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
count=0
while True:
  temp=0
  for i in range(0,n):
    if a[i]%2==0:
      temp=temp+1
      a[i]=int(a[i]/2)
  if temp==n:
    count=count+1
  else:
    break
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    queue<int> que;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        que.push(a);
    }

    vector<vector<int>> ans(h,vector<int>(w));

    int now = 1;
    int cnt = que.front();
    que.pop();
    for(int i = 0;i < h;i++){
        if(i % 2 == 0){
            for(int j = 0;j < w;j++){
                ans[i][j] = now;
                cnt--;
                if(cnt == 0 && que.size()){
                    now++;
                    cnt = que.front();
                    que.pop();
                }
            }
        }
        else{
            for(int j = w-1;j >= 0;j--){
                ans[i][j] = now;
                cnt--;
                if(cnt == 0 && que.size()){
                    now++;
                    cnt = que.front();
                    que.pop();
                }
            }
        }
    }

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
def main():
    n, m, x = map(int, input().split())
    num_list = list(map(int, input().split()))
    
    square_list = [0] * (n + 1)
    
    for n in num_list:
        square_list[n-1] = 1
    
    left = sum(square_list[0:x-1])
    right = sum(square_list[x:])
    
    print(min(left, right))


if __name__ == '__main__':
    main()


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    pair<int, int> init = {1, 1};
    int n;
    cin >> n;

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

        //ax >= init and bx >= init
        int newX = max(init.first/a + (init.first % a > 0), init.second/b + (init.second % b > 0));
        init = {a * newX, b * newX};
    }
    cout << init.first + init.second << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{	
	int num,i,j,x;
	int answer=0;
	int c[201];
	scanf("%d",&num);
	for(i=0;i<num;i++){
		scanf("%d",&c[i]);
	}

	while(1){
		for(i=0;i<num;i++){
			//printf("%d\n",c[i]);
			answer++;
			if(c[i]%2==0){
				c[i]=c[i]/2;
			}
			else{
				answer=answer/num;
				printf("%d\n",answer);
				return 0;			
			}
		}
	}
}

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

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

int main(){
  long long N,M;
  string S,T;
  string subS="",subT="";
  long long g,l;
  cin >> N >> M >> S >> T;
  g=gcd(N,M);
  l=N*M/g;
  for(auto itr=S.begin();itr<S.end();itr+=N/g)
    subS+=*itr;
  for(auto itr=T.begin();itr<T.end();itr+=M/g)
    subT+=*itr;
  while( (!subS.empty()) || (!subT.empty()) ){
    if( subS[0]!=subT[0] ){
      l=-1;
      break;
    }else{
      subS.erase(0,1);
      subT.erase(0,1);
    }
  }
  cout << l << endl;
}

Measured memory_bytes: 512
#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto &
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline int size(const T& a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

int main() {
    string s;
    cin >> s;
    int x = 0;
    int n = s.size();
    for(char c: s){
        if(c == 'T'){
            if(x > 0){
                n -= 2;
                x--;
            }
        } else {
            x++;
        }
    }
    cout << n << endl;
}



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

int gcd(int x, int y){
    if (x < y)
        swap(x, y);
    if (y == 0)
        return x;
    return gcd(x % y, y);
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());
    vector<int> L(N), R(N);
    rep(i, N - 1){
        L[i + 1] = gcd(L[i], A[i]);
    }
    
    for (int i = N - 1; i >= 1; i--){
        R[i - 1] = gcd(R[i], A[i]);
    }
    
    int Max = 1;
    rep(i, N){
        Max = max(Max, gcd(L[i], R[i]));
    }
    cout << Max << endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
int main(){
  long x[2],y[2],max,i,j;
  
  scanf("%ld %ld %ld %ld",&x[0],&x[1],&y[0],&y[1]);
  
  max=x[0]*y[0];
  for(i=0;i<=1;i++){
    for(j=0;j<=1;j++){
      if(max<x[i]*y[j]){
        max=x[i]*y[j];
      }
    }
  }
  
  printf("%ld",max);
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
int place[105];
int n;


int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        cin >>place[i];
    }
    sort(&place[0], &place[n]);
    cout<<place[n-1]-place[0];
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		if(a * b == 15)System.out.println('*');
		else if(a + b == 15)System.out.println('+');
		else System.out.println('x');
	}
}


Measured memory_bytes: 23764
n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

parents = [i for i in range(n)]
ranks = [0 for _ in range(n)]


def root(x):
    return x if x == parents[x] else root(parents[x])


def is_same(x, y):
    return root(x) == root(y)


def unite(x, y):
    x, y = root(x), root(y)
    if x == y:
        return
    if ranks[x] < ranks[y]:
        parents[x] = y
    else:
        parents[y] = x
        if ranks[x] == ranks[y]:
            ranks[x] += 1


for x_, y_ in xy:
    unite(x_, y_)

count = 0
for i, p_ in enumerate(p):
    count += 1 if is_same(i, p_) else 0
print(count)


Measured memory_bytes: 36044
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc089/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int N;
    cin >> N;
    vector<string> v(N);
    rep(i, N){
        cin >> v[i];
    }
    ll cnt[5];
    ll ans = 0;
    rep(i, 5){
        cnt[i] = 0;
    }
    rep(i, N){
        if(v[i][0] == 'M') cnt[0]++;
        else if(v[i][0] == 'A') cnt[1]++;
        else if(v[i][0] == 'R') cnt[2]++;
        else if(v[i][0] == 'C') cnt[3]++;
        else if(v[i][0] == 'H') cnt[4]++;
    }
    ans = cnt[0]*cnt[1]*cnt[2]+cnt[0]*cnt[1]*cnt[3]+cnt[0]*cnt[1]*cnt[4];
    ans += cnt[0]*cnt[2]*cnt[3]+cnt[0]*cnt[2]*cnt[4]+cnt[0]*cnt[3]*cnt[4];
    ans += cnt[1]*cnt[2]*cnt[3]+cnt[1]*cnt[2]*cnt[4]+cnt[1]*cnt[3]*cnt[4]+cnt[2]*cnt[3]*cnt[4];
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
   
char a[3];
   cin>>a[0]>>a[1]>>a[2];
   for(int i=0;i<3;i++)

   {
       if(a[i]=='1') a[i]='9';
       else a[i]='1';
   }
   cout<<a[0]<<a[1]<<a[2];


   return 0;
}

Measured memory_bytes: 256
s = [w for w in input()]
length = len(s)
sum = 0

for i in range(2 ** (length-1)):
    start = 0
    b = format(i, 'b')[::-1]
    for end, flag in enumerate(b):
        if flag == '1':
            extract_s = ''.join(s[start: end + 1])
            sum += int(extract_s)
            start = end + 1
    if start != length:
        extract_s = ''.join(s[start:])
        sum += int(extract_s)

print(sum)


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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

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

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(intmax_t, N);

    if (N & 1) {
        output(2 * N);
    } else {
        output(N);
    }

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    vec<lint> P_list(N), Q_list(N);
    range(i, 0, N) cin >> P_list.at(i);
    range(i, 0, N) cin >> Q_list.at(i);
    vec<lint> perm = P_list;
    sort(perm.begin(), perm.end());
    lint order_P, order_Q;
    lint order = 0;
    do {
        if (perm == P_list) order_P = order;
        if (perm == Q_list) order_Q = order;
        order += 1;
    } while (next_permutation(perm.begin(), perm.end()));
    cout << abs(order_P - order_Q) << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int c[11][11],hw[205][205];
int main()
{
    int h,w,a,i,j,k,t;
    long long res=0;
    scanf("%d%d",&h,&w);
    for(i=0;i<10;i++)
    for(j=0;j<10;j++)
    scanf("%d",&c[i][j]);
    for(t=0;t<10;t++)
    for(i=0;i<10;i++)
    for(j=0;j<10;j++)
    for(k=0;k<10;k++)
    if(c[i][j]>c[i][k]+c[k][j])
    c[i][j]=c[i][k]+c[k][j];
    for(i=0;i<10;i++)
    c[i][i]=0;
    for(i=0;i<h;i++)
    for(j=0;j<w;j++)
    {
        scanf("%d",&a);
        if(a!=-1&&a!=1)
        res+=c[a][1];
    }
    printf("%lld",res);
    return 0;
}

Measured memory_bytes: 128