akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
long long int Max(long long int a,long long int b){
    if(a>=b)return a;
    else return b;
}
long long int comb(long long int n,long long int r){
    vector<vector<long long int> > v(n+1,vector<long long int>(n+1,0));
    long long int i,j;
    rep(i,0,n+1){
        v.at(i).at(0)=1;
        v.at(i).at(i)=1;
    }
    rep(i,0,n+1){
        rep(j,0,i)v.at(i).at(j)=v.at(i-1).at(j-1)+v.at(i-1).at(j);
    }
    return v.at(n).at(r);
}
int main(void){
    int N,M;
    cin>>N>>M;
    if(N==M)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;
 
typedef long long ll;
typedef long double ld;

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

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

//#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define loop(x,n) for(int x = 0; x < n; ++x)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

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

string get_str() {
    string temp;
    cin >> temp;
    return temp;
}
int get_int() {
    int temp;
    cin >> temp;
    return temp;
}

void solve() {



}

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

    loop(i, x+1) {
        if((i*2+(x-i)*4) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;


}


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

using namespace std;

const int NMAX = 2010;
long long a[NMAX];
long long dp[NMAX][NMAX];

int main() {
    int n;
    long long x;
    cin >> n >> x;

    for (int i = 0; i < n; ++i) cin >> a[i];
    
    for (int i = 0; i < n; ++i) {
        dp[i][0] = a[i];
        for (int k = 1; k < n; ++k) {
            int diff = (i - k + n) % n;
            dp[i][k] = min(dp[i][k - 1], a[diff]);
        }
    }

    long long ans = INT64_MAX;
    for (int k = 0; k < n; ++k) {
        long long tmp = k * x;
        for (int i = 0; i < n; ++i) {
            tmp += dp[i][k];
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31616
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}

// 二項係数計算
long long 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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	long long int n;
	long long int a, b;
	cin >> n >> a >> b;
	long long int c = a + b;
	long long int ans = 0;
	long long int wari = n / c;
	n = n % c;
	ans = ans + wari * a;
	
	if (n >= a) {
		ans = ans + a;
	}
	else if (n <= a) {
		ans = ans + n;
	}
	cout << ans;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        Set<Integer> map = new HashSet<Integer>();
        for (int i = 0; i < N; i++) {
            int A = scanner.nextInt();
            if (map.contains(A)) {
                map.remove(A);
            } else {
                map.add(A);
            }
        }
        System.out.println(map.size());
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 42832
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(int, n);
    VEC(int, v, n);
    int ans = INF;
    REP(i, n){
        int c = 0;
        while(v[i] % 2 == 0){
            c++;
            v[i] /= 2;
        }
        ans = min(ans, c);
    }
    OUTL(ans);
RET;}

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

int main(void){
	int n = 0;
	cin >> n;

	const double inter = 0.05;
	double debt = 100000.0;
	int a = 0;

	for(int i = 0;i < n;i++){
		debt += debt * inter;
		a = (int)debt%1000;
		if(a != 0){
			debt += 1000.0 - (double)a;
		}
	}

	cout << (int)debt << endl;

	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int M1 = sc.nextInt();
        int D1 = sc.nextInt();
        int M2 = sc.nextInt();
        int D2 = sc.nextInt();

        System.out.println(M1 != M2 ? 1 : 0);
    }
}


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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<pair<int,int>> vpi;

const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);
int par[N+5];

int find(int a){
    if(par[a]==a) return a;
    
    return par[a] = find(par[a]);
    
}

void un(int a,int b){
    a =find(a);
    b = find(b);
    if(a!=b){
        par[b]=a;
        
    }
    
}

void solve(){
    int n,m;
    cin>>n>>m;
    FOR(i,1,n+1){
        par[i]=i;
    }
    while(m--){
        
        int x,y;
        cin>>x>>y;
        un(x,y);
    }
    
    FOR(i,1,n+1){
        int x = find(i);
    }
    
    map<int,int> mp;
    FOR(i,1,n+1){
        mp[par[i]]++;
    }
    
    int mx=0;
    for(auto i:mp){
        //cout<<i.ff<<" "<<i.ss<<"\n";
        mx=max(mx,i.ss);
    }
    
    cout<<mx<<"\n";
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 13716
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    # k<=10**18 < 2**60
    r = 60
    import math
    r = math.ceil(math.log2(k))
    idx = 0
    a = [a[i]-1 for i in range(n)]
    for i in range(r):
        if (k>>i)&1 == 1:
            idx = a[idx]
        a = [a[a[j]] for j in range(n)]
    print(idx+1)    

if __name__ == '__main__':
    main()

Measured memory_bytes: 170256
# -*- coding: utf-8 -*-
import math
import sys
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())

    result = 0
    if n < k:
        for i in range(1, n + 1):
            x = math.ceil(math.log(k / i, 2))
            result += (1 / n) * (0.5 ** x)
    else:
        for i in range(1, k):
            x = int(math.log(k / i, 2)) + 1
            result += (1 / n) * (0.5 ** x)
        result += (n - k + 1) / n
    print(result)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<ll, ll> p64;
typedef vector<ll> v420;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define mem(x, y) memset(x, y, sizeof(x))
#define DANGER                        \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

int main()
{
    int n;
    cin >> n;
    v420 v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    for (int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i - 2] + abs(v[i] - v[i - 2]), dp[i - 1] + abs(v[i] - v[i - 1]));
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 21:27:49 2020

@author: arute
"""


from sys import stdin

import time
import numpy as np


############################################

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])

data = []
write = stdin.readline().split()
for i in range(N-1):
    data.append(int(write[i]))

data = np.asarray(data)

out = np.zeros(N)
for d in data:
    out[d-1] += 1

o = ""
for l in out:
    o+=str(int(l))+"\n"

print(o)

Measured memory_bytes: 52552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
char s[10];
int main()
{
	scanf("%s", s);
	if(s[0] == '7' || s[1] == '7' || s[2] == '7')
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 3696
#include<cstdio>

using namespace std;

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    int ans = 0;
    n--;
    while (n > 0){
        n -= k - 1;
        ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))

A.sort()
B = list(set(A))

total = 1
flag = 9
for i in range(len(B)):
  total *= B[i]**A.count(B[i])
  if total > 10**18:
    flag = 0
    break
  elif min(A) == 0:
    flag = 1
    break
  
if flag == 0:
  print(-1)
elif flag == 1:
  print(0)
else:
  print(total)
    

Measured memory_bytes: 21652
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
int n;
vector<int>an(200020);
int cnt;
int brk;

void solve(){
    cnt = 1;
    brk = 0;
    for(int i = 0; i < n; i++){
        if(an.at(i) == cnt){//壊さなくていいとき
            cnt++;
        }
        else{//壊すとき
            brk++;
        }
    }
    if(brk != n){
        cout << brk << endl;
    }
    else{
        cout << -1 << endl;
    }

}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> an.at(i);
    }
    solve();
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static int span; // 何日間のスケジューリングをするか
	public static int minus[]; // 26種類のコンテストの飽きやすさ
	public static int plus[][]; // 26種類のコンテストの満足感

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		span = Integer.parseInt(sc.next()); // 何日間のスケジューリングをするか
		minus = new int[26]; // 26種類のコンテストの飽きやすさ
		for (int i = 0; i < 26; i++) {
			minus[i] = Integer.parseInt(sc.next());
		}
		plus = new int[span][26]; // 26種類のコンテストの満足感
		for (int d = 0; d < span; d++) {
			for (int i = 0; i < 26; i++) {
				plus[d][i] = Integer.parseInt(sc.next());
			}
		}

		// 提出用配列を初期化しておく（初期値はまぁ適当に26種類のコンテストをローテーション開催で）
		int teishutu[] = new int[span];
		for (int d = 0; d < span; d++) {
			teishutu[d] = (d % 26) + 1;
		}

		// ３日目を変えて満足度最大のものを探す
		int bestKaisai = 1;
		long bestScore = -99999;
		for (int i = 0; i < 26; i++) {

			teishutu[2] = i + 1;
			long score = calc(teishutu);
			// System.out.println(Arrays.toString(teishutu) + "\t" + score);

			if (score > bestScore) {
				bestKaisai = i + 1;
				bestScore = score;
			}
		}
		teishutu[2] = bestKaisai;

		// 提出
		for (int d = 0; d < span; d++) {
			System.out.println(teishutu[d]);
		}

	}

	public static long calc(int[] input) {

		int last[] = new int[26]; // 各コンテストが最終開催日から何日経過しているか
		long result = 0; // ユーザ満足度

		for (int d = 0; d < input.length; d++) {

			// lastの更新
			for (int i = 0; i < 26; i++) {
				if (i == input[d] - 1) {
					last[i] = 0;
				} else {
					last[i]++;
				}
			}

			// 開催による満足度アップ
			result += plus[d][input[d] - 1];

			// 日数経過による満足度ダウン
			for (int i = 0; i < 26; i++) {
				result -= (minus[i] * last[i]);
			}
		}

		return result;
	}
}


Measured memory_bytes: 42424
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int hasNext;
		while ((hasNext = in.nextInt()) != 0) {
			while (hasNext-- > 0) {
				char rank;
				int pm = in.nextInt();
				int pe = in.nextInt();
				int pj = in.nextInt();
				int all = pm + pe + pj;
				if (pm == 100 || pe == 100 || pj == 100 || all >= 240
						|| (all - pj) >= 180) {
					System.out.println('A');
				} else if (all >= 210 || (all >= 150 && (pm >= 80 || pe >= 80))) {
					System.out.println('B');
				} else {
					System.out.println('C');
				}
			}
		}
	}
}

Measured memory_bytes: 28248
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 a, b, n;
    cin >> a >> b >> n;

    s64 ans = 0;
    rep (k, a + 1)
    {
        s64 x1 = (b * k) / a;
        s64 x2 = CEIL(b * k, a);
        if (x1 <= n) ans = MAX(ans, (x1 * a) / b - a * (x1 / b));
        if (x2 <= n) ans = MAX(ans, (x2 * a) / b - a * (x2 / b));
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3616
using System;

namespace ConsoleApp1
{
    class ABC178A
    {
        static void Main(string[] args)
        {
            int x = Int32.Parse(Console.ReadLine());

            if (x > 0)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine("1");
            }
        }
    }
}


Measured memory_bytes: 27520
def a(s,i):
    if i == l-1:
        if eval(s) == 7:
            print(s+"=7")
            exit()
        return
    a(s+"+"+N[i+1],i+1)
    a(s+"-"+N[i+1],i+1)

N = input()
l = len(N)
a(N[0],0)

Measured memory_bytes: 8972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int t, a;
		long A = 1, B = 1, x, y, z;
		for (int i = 0; i < n; i++) {
			t = sc.nextInt();
			a = sc.nextInt();
			if (A % t != 0) {
				x = A / t + 1;
			} else {
				x = A / t;
			}
			if (B % a != 0) {
				y = B / a + 1;
			} else {
				y = B / a;
			}
			z = Math.max(x, y);
			A = z * t;
			B = z * a;
		}
		System.out.println(A + B);
	}
}

Measured memory_bytes: 25276
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;

int main(){
    vector<int> num(pow(10,5)+1);

    int n,q;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    long int sum=0;
    for (int i = 0; i < n; i++)
    {
        sum=sum+a[i];
    }
    
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; i < pow(10,5)+1; j++)
        {
            if (a[i]==j)
            {
                num[j]++;
                break;
            } 
        }
    }
    
    
    cin>>q;
    for (int i = 0; i < q; i++)
    {
        long int b,c;
        cin>>b>>c;
        sum=sum+(c-b)*num[b];
        cout<<sum<<endl;
        num[c]=num[c]+num[b];
        num[b]=0;

    }
    
return 0;
}

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

int main() {
    ll h,w,k;
    std::cin >> h>>w>>k;
    
    vector<string> a(h);
    pair<ll,ll> s;
    for (int i = 0; i < h; i++) {
        std::cin >> a[i];
        for (int j = 0; j < w; j++) {
            if(a[i][j]=='S')s = {i,j};
        }
    }
    
    set<pair<ll,ll>> se;
    
    queue<tuple<ll,ll,ll>> q;
    q.push({s.first,s.second,k});
    vector<vector<bool>> used(h,vector<bool>(w,false));
    used[s.first][s.second] = true;
    // se.insert({s.first,s.second});
    while(q.size()){
        auto [xx,yy,rem] = q.front();q.pop();
        if(rem==0)continue;
        for (int x = -1, y = 0, iii = 0; iii < 4; x += y, y = x - y, x = y - x, ++iii) {
            if(xx+x<0||xx+x>h-1||yy+y<0||yy+y>w-1)continue;
            if(a[xx+x][yy+y]=='.'){
                if(used[xx+x][yy+y])continue;
                if(rem-1>0)q.push({xx+x,yy+y,rem-1});
                // se.insert({xx+x,yy+y});
                used[xx+x][yy+y] = true;
            }
        }
    }
    ll ans = 1e15;
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            if(!used[i][j])continue;
            auto e = make_pair(i,j);
            auto minx = min(e.first,h-1-e.first);
            auto miny = min(e.second,w-1-e.second);
            ans = min(ans, (min(minx,miny)+k-1)/k);
        }
    }
    // for (auto e : se) {
        
    // }
    std::cout << 1+ans << std::endl;
}


Measured memory_bytes: 4536
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

const int N = 3e5 + 5;


struct SegTree {
  struct TreeNode {
    int max;
  };
  int n;
  vector<TreeNode> st;
  void build(int cur, int s, int e) {
    if(s == e) {
      st[cur] = { 0 };
      return;
    }
    int mid = (s + e) / 2;
    int l = 2 * cur + 1, r = 2 * cur + 2;
    build(l, s, mid);
    build(r, mid + 1, e);
    st[cur] = merge(st[l], st[r]);
  }
  void init(int n) {
    this->n = n;
    st.resize(n << 2);
    build(0, 0, n - 1);
  }
  TreeNode merge(TreeNode a, TreeNode b) {
    return { max(a.max, b.max) };
  }
  void update(int cur, int s, int e, int idx, int val) {
    if(s > idx || e < idx) return;
    if(s == e) {
      st[cur].max = max(st[cur].max, val);
      return;
    }
    int mid = (s + e) / 2;
    int l = 2 * cur + 1;
    int r = 2 * cur + 2;
    update(l, s, mid, idx, val);
    update(r, mid + 1, e, idx, val);
    st[cur] = merge(st[l], st[r]);
  }
  void update(int idx, int val) {
    update(0, 0, n - 1, idx, val);
  }
  TreeNode query(int cur, int s, int e, int i, int j) {
    if(s > j || e < i) return {0};
    if(s >= i && e <= j) return st[cur];
    int mid = (s + e) / 2;
    int l = 2 * cur + 1;
    int r = 2 * cur + 2;
    return merge(query(l, s, mid, i, j), query(r, mid + 1, e, i, j));
  }
  int query(int i, int j) {
    return query(0, 0, n - 1, i, j).max;
  }
};

int n, k;
SegTree st;
int a[N];

int main()
{
  cin >> n >> k;
  st.init(N);

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

  int ans = 0;

  for(int i = n - 1; i >= 0; i--) {
    int v = a[i];
    int l = max(0, v - k), r = min(N - 1, v + k);
    int m = st.query(l, r);
    ans = max(ans, 1 + m);
    st.update(v, 1 + m);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9024
n = gets
array_cook = gets.chomp.split.map(& :to_i)
array_satisfaction = gets.chomp.split.map(& :to_i)
array_addsatisfaction = gets.chomp.split.map(& :to_i)

x = ""
total = 0
array_cook.each{|item|
    if x == (item - 1)
        total += array_addsatisfaction[x -1] + array_satisfaction[item -1]
    else
        total += array_satisfaction[item -1]
    end

    x = item
}

puts total

Measured memory_bytes: 1788
def dfs(i,x):
 if i==0:return 1 if x>0else 0       
 if x<=1+l[i-1]:return dfs(i-1,x-1) 
 return 1+p[i-1]+dfs(i-1,x-2-l[i-1])
n,x=map(int,input().split())
l,p=[1],[1]
for i in range(n):
 l.append(l[i]*2+3)
 p.append(p[i]*2+1)
print(dfs(n,x))

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

const int N = 100 + 10;
double a[N];

int main() {
  	int n;
  	cin >> n;
  	for (int i = 0; i < n; i++)
      	cin >> a[i];
  	double sum = 1, ans = 0;
  	for (int i = 0; i < n; i++)
      	sum *= a[i];
  	for (int i = 0; i < n; i++)
		ans += sum / a[i];
  	ans /= sum;
  	ans = 1 / ans;
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    t = 'keyence'
    for i in range(7):
        if s[:i] + s[-(7-i):] == t:
            return 'YES'

    return 'NO'



print(main())




Measured memory_bytes: 6088
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
   cin.tie(0);  
   ios::sync_with_stdio(false);
   int n,a,b,c;
   cin>>a>>b;
   if(a<b) printf("0\n");
   else printf("10\n");
   return 0;
}



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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m>>k;

	cout<<min((n*m),k)<<endl;



}


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


int main(){
	long long a,b,c,x,y,MX=0,MX2=0,MX3=0,MX4=0;
	cin >> a >> b >> c >> x >> y;
	c*=2;
	MX=a*x+b*y;
	MX2=c*x;
	if(x<y) MX2+=(y-x)*b;
	
	MX3=c*y;
	if(x>y) MX3+=(x-y)*a;
	
	x=max(x,y);
	MX4=x*c;
	cout << (min(MX,min(MX2,min(MX3,MX4)))) << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
int main(void){
  int win[10],comdata[10];
  int n;
  char table[10][11];
  int i,j,k,com,max=0,play;
  int sum,r,super=0;
 
  for(i=0;i<10;i++) win[i]=comdata[i]=0;
  scanf("%d%*c",&n);
  for(i=0;i<n;i++) scanf("%s%*c",table[i]);
 
  for(j=0;j<n;j++){
    win[j]=0;
    for(k=0;k<n;k++){
      switch(table[j][k]){
      case 'o':
	win[j]+=3;
	break;
      case '-':
	win[j]+=1;
	break;
      }
    }
    if(win[j]==3*n-2) super=j+1;
  }
  srand(time(NULL));
 
  for(i=0;i<1000;i++){
    play=((super)?(super):(rand()%n+1));
    printf("%d\n",play);
    fflush(stdout);
    scanf("%d",&com);
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << "\n";
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,m;cin>>n>>m;
  vector<map<ll,ll> >Mvec(n);
  rep(i,m){
    ll s,c;cin>>s>>c;
    Mvec[s-1][c]++;
  }
  vector<ll>vec(n);
  vec[0]=1;
  if(n==1)vec[0]=0;
  bool ans=true;
  rep(i,n){
    ll count=0;
    for(auto p:Mvec[i]){
      if(n!=1&&i==0&&p.first==0){
        if(p.second!=0)ans=false;
      }
      vec[i]=p.first;
      count++;
    }
    if(count>1)ans=false;
  }
  
  if(ans){
    rep(i,n)cout<<vec[i];
    cout<<endl;
  }
  else cout<<-1<<endl;
}
      


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
//#include<bits/stdc++.h>
#include <iostream>
#include<vector>
#include<set>
#include<iterator>
#include<string>
#include<map>
#include<stack>
#include<cmath>
#include<algorithm>
#include <cstdio>
#include<cstdlib>
#include <cstring>
#include <unordered_map>
#include <iomanip>
#include <queue>
#include<numeric>
#define baap_coder17 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define   lli long long int
#define ld long double
#define  endl "\n"
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define ui unsigned int
#define mt make_tuple
#define t_(t)[(i)]  get<(i)>((t))
#define vsort(v) sort((v).begin(), (v).end())
#define vsortr(v) sort((v).rbegin(), (v).rend())
#define all(v)  (v).begin(), (v).end()
#define rall(v)  (v).rbegin(), (v).rend()
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
const ld EPSILON=0.000000001;
const ld mod=1e9+7;
const lli AM=2e5+5;
const ld pi=3.14159265358979323846;
lli max(lli a,lli b){if(a>b)return a;else return b;}
using namespace std;
lli fact(lli n) {lli ans=1; for(lli i=1;i<=n;i++) ans*=i; return ans;}
lli powm(lli a, lli b, lli n){lli x=1, y=a; while (b > 0) {if (b%2 == 1) {x = (x*y) % n; } y = (y*y) % n; b /= 2;}return x % n;}
lli pow(lli x, lli y) { lli res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); y = y >> 1; x = ((x) * (x)); } return res; }
lli min(lli a,lli b) {if(a>b)return b;else return a;}
bool cmp(ld x,ld y){if(abs(x-y)<=EPSILON)return 1;return 0;}
 bool checkprime(lli n){ for(lli i=2;i*i<=n;i++) if(n%i==0)return false;   return true;}
//lli gcd(lli a, lli b){return b ? gcd (b, a % b) : a;}
 int fun(pair<lli,lli> p1,pair<lli,lli> p2)
{
    if(p1.X<=p2.X)
        return 1;
    return 0;
}
//lli lcm(lli a, lli b) { return (a * b) / gcd(a, b); }
//lli modInverse(lli a, lli m) { lli g = gcd(a, m); return powm(a, m - 2, m); }

int gcd(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g) {
    g = gcd(abs(a), abs(b), x0, y0);
    if (c % g) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}





int main()
{
    int x;cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3124
using System;

namespace AtCoder0621
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string input = Console.ReadLine();
            char inpc = input[0];
            if (char.IsUpper(inpc))
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }
        }
    }
}


Measured memory_bytes: 25872
d = int(input())
c = list(map(int,input().split()))
s = []
for i in range(d):
  si = list(map(int,input().split()))
  s.append(si)
lastd = [-1 for _ in range(26)]
ans = 0
for i in range(d):
  di = int(input())
  lastd[di-1] = i
  ans += s[i][di-1]
  for j in range(26):
    ans -= (i-lastd[j])*c[j]
  print(ans)

Measured memory_bytes: 69924
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int N = in.nextInt();
        ArrayList<ArrayList<int[]>> edge = new ArrayList<ArrayList<int[]>>();
        for (int i=0;i<N;i++) {
            ArrayList<int[]> add = new ArrayList<int[]>();
            edge.add(add);
        }
        for (int i=0;i<N-1;i++) {
            int a = in.nextInt()-1;
            int b = in.nextInt()-1;
            int c = in.nextInt();
            int[] add_1 = {b, c};
            int[] add_2 = {a, c};
            edge.get(a).add(add_1);
            edge.get(b).add(add_2);
        }

        int Q = in.nextInt();
        int K = in.nextInt();
        ArrayDeque<long[]> queue = new ArrayDeque<long[]>();
        int[] flag = new int[N];
        long[] cost = new long[N];
        long[] init = {(long)K-1, 0};
        queue.add(init);
        while(!queue.isEmpty()) {
            long[] rem = queue.poll();
            if (flag[(int)rem[0]]==1) {
                continue;
            }
            flag[(int)rem[0]]=1;
            cost[(int)rem[0]]=rem[1];

            for (int[] tmp : edge.get((int)rem[0])) {
                long[] add = {(long)tmp[0], rem[1]+(long)tmp[1]};
                queue.add(add);
            }
        }
        for (int i=0;i<Q;i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            out.println((cost[x-1]+cost[y-1]));
        }

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);

vector<ll> get_divisor(ll n){
  vector<ll> ret;

  for(ll i = 1; i*i <= n; i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i != n) ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int main(){
  ll n;
  cin >> n;

  int ans = get_divisor(n-1).size() -1;

  vector<ll> l = get_divisor(n);

  for(auto &v: l){
    if(v==1)continue;
    ll m = n;
    while(m > 1 && m >= v){
      if(m%v==0){
        m/=v;
      }else{
        m%=v;
      }
    }
    if(m==1)ans++;
  }

  cout << ans << endl;
}



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


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;


const int IINF = INT_MAX;
const int MAX_V = 60;
int V,initial_Aaron,initial_Bruce,memo[MAX_V][MAX_V][2];
vector<int> G[MAX_V];

#define REPEAT -1

void compute(){
  rep(i,V) rep(j,V) rep(k,2) memo[i][j][k] = REPEAT;
  rep(i,V) memo[i][i][0] = memo[i][i][1] = 0;
  
  bool update = true;
  while( update ){
    update = false;
    rep(Aaron,V){
      rep(Bruce,V){
	rep(phase,2){
	  if( phase ) { // Bruce
	    int mini = IINF;
	    rep(i,(int)G[Bruce].size()+1){
	      int next = ((i==G[Bruce].size())?Bruce:G[Bruce][i]);
	      if( memo[Aaron][next][!phase] != REPEAT ) { mini = min(mini,memo[Aaron][next][!phase]); }
	    }
	    if( mini != IINF && ( memo[Aaron][Bruce][phase] == REPEAT || memo[Aaron][Bruce][phase] > mini + 1 ) ) memo[Aaron][Bruce][phase] = mini + 1, update = true;
	  } else {      // Aaron
	    bool escape = false;
	    int maxi = -IINF;
	    rep(i,(int)G[Aaron].size()+1){
	      int next = ((i==G[Aaron].size())?Aaron:G[Aaron][i]);
	      if( memo[next][Bruce][!phase] == REPEAT ) { escape = true; }
	      if( memo[next][Bruce][!phase] != REPEAT ) { maxi = max(maxi,memo[next][Bruce][!phase]); }
	    }
	    if( !escape && maxi != -IINF && ( memo[Aaron][Bruce][phase] == REPEAT || memo[Aaron][Bruce][phase] < maxi + 1 ) ) {
	      memo[Aaron][Bruce][phase] = maxi + 1, update = true;
	    }
	  }
	}
      }
    }
  }
  if( memo[initial_Aaron][initial_Bruce][0] == REPEAT ) puts("infinity");
  else printf("%d\n",(int)ceil(memo[initial_Aaron][initial_Bruce][0]/2.0));
}

int main(){
  int T;
  cin >> T;
  while( T-- ){
    cin >> V;
    rep(i,V) G[i].clear();
    rep(cur,V) {
      rep(next,V) {
	int edge;
	cin >> edge;
	if( edge ) G[cur].push_back(next);
      }
    }
    cin >> initial_Aaron >> initial_Bruce;
    compute();
  }
  return 0;
}

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

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    rep(i, n){
        cout << s[i]<< t[i];
    }

    return 0;
}

Measured memory_bytes: 256
S = gets.chomp
x = S.to_i
N = S.length

# nと同じ桁までの七五三数をすべて列挙して、そのあとx以下のものの数を判定することにする

# 2桁ならなし
if N < 3
  puts 0
  exit
end

ans = 0

3.upto(N) do |d|
  # 3や5だけのものもすべて列挙して、3,5,7すべてあるものだけ保存する
  ['3', '5', '7'].repeated_permutation(d) do |arr|

    next unless arr.include?('3')
    next unless arr.include?('5')
    next unless arr.include?('7')
    
    ans += 1 if arr.join.to_i <= x
  end
end

p ans



Measured memory_bytes: 2044
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

struct Node {
    bool vis;
    vector<int> edges;
} nodes[100005];

void dfs(int x) {
    Node cur = nodes[x];
    for (int to : cur.edges) {
        if (!nodes[to].vis) {
            nodes[to].vis = true;
            dfs(to);
        }
    }
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        nodes[x].edges.push_back(y);
        nodes[y].edges.push_back(x);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!nodes[i].vis) {
            ans++;
            nodes[i].vis = true;
            dfs(i);
        }
    }
    printf("%d", ans);
    
}


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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t) cout << "Yes";
  else cout << "No";
  return 0;
}

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

int main() {
	int n; cin >> n;
	int a[110];

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

	printf("%d", a[n - 1]);
	for (int i = n - 2; i >= 0; --i) printf(" %d", a[i]);
	cout << endl;
}


Measured memory_bytes: 3208
#include <stdio.h>

int main(void)
{
	int N;
	int i, j, x,min,count=0, flag=1;
	scanf("%d", &N);
	int a[N];
	for(i=0; i<N; i++){
		scanf("%d", &a[i]);
	}
	
	while(flag==1){
		flag=0;
		for(i=0;i<N;i++){
			min=i;
			for(j=i; j<N; j++){
				if(a[j]<a[min]){
					min=j;
					flag=1;
				}
			}
			x=a[i];
			a[i]=a[min];
			a[min]=x;
			if(a[i]!=a[min]) count++;
		}
	}
			
	for(i=0; i<N-1; i++){
		printf("%d ", a[i]);
		}
	printf("%d\n", a[N-1]);
	printf("%d\n", count);
	
	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int MAX_N=3000;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[MAX_N];
    rep(i,n){
        cin >> a[i];
    }
    ll ans=0;
    rep(i,n){
        ans+=a[i]-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

long long matrix[310][310];
long long fuel[310][310];
int p[310][310];
long long result = 0;
long long gas;
long long full;


int main()
{
	int n;
	int m;
	long long l;
	const long long INF = (long long)1e17;
	
	for (int i = 0; i < 310; i++)
	{
		for (int j = 0; j < 310; j++)
		{
			matrix[i][j] = INF;
			fuel[i][j] = INF;
			p[i][j] = -1;
		}
		matrix[i][i] = 0;
		fuel[i][i] = 0;
	}

	cin >> n >> m >> l;
	
	int a, b, c;
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b >> c;
		if (c > l) continue;
		fuel[a][b] = c;
		fuel[b][a] = c;
	}

	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
			{
				if (fuel[i][j] > fuel[i][k] + fuel[k][j])
				{
					fuel[i][j] = fuel[i][k] + fuel[k][j];
					
				}
			}
		}
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (i == j) continue;
			if (fuel[i][j] <= l)
			{
				matrix[i][j] = 1;
				
			}
		}
	}
	

	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
			{
				if (matrix[i][j] > matrix[i][k] + matrix[k][j])
				{
					matrix[i][j] = matrix[i][k] + matrix[k][j];
				}
			}
		}
	}
	

	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> a >> b;
		if (fuel[a][b] >= INF)
		{
			cout << -1 << "\n";
		}
		else
		{
			cout << matrix[a][b] - 1 << "\n";
		}
		//cout << a << ' ' << b << ' ' << matrix[a][b] << "\n";
	}
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ull unsigned long long
#define pii pair<int,int>
#define X first
#define Y second
#define mod ((ll)1e9+7)
#define pb push_back
//#define mp make_pair
//#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
#define sz(a) ((int)a.size())
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
#define bit_count(x) __builtin_popcount((x))
//#define LOCAL
#ifdef LOCAL
#define debug(a) cerr<<#a<<" "<<a<<endl;
#else
#define debug(a)
#endif
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int min(int a,int b){return (a>b?b:a);}
int a,b,c,d,n,lim;
int abss(int x){int s=(x>0?x:-x);return s;}
map<int,int> mp;
int calc(int x){
	if(!x)return 0;
	if(x==1)return d;
	if(mp.count(x))return mp[x];
	int l2=(x/2)*2ll,u2=ceiling(x,2)*2ll,l3=(x/3)*3ll,u3=ceiling(x,3)*3ll,l5=(x/5)*5ll,u5=ceiling(x,5)*5ll;
	int ret=(x<lim?x*d:1e18);
	ret=min(ret,calc(l2/2)+a+d*abss(x-l2));
	ret=min(ret,calc(u2/2)+a+d*abss(x-u2));
	ret=min(ret,calc(l3/3)+b+d*abss(x-l3));
	ret=min(ret,calc(u3/3)+b+d*abss(x-u3));
	ret=min(ret,calc(l5/5)+c+d*abss(x-l5));
	ret=min(ret,calc(u5/5)+c+d*abss(x-u5));
	mp[x]=ret;
	return ret;
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		mp.clear();
		cin>>n>>a>>b>>c>>d;
		//cout<<d<<endl;
		lim=(1e18)/d;
		cout<<calc(n)<<endl;
	}
return 0;
}


Measured memory_bytes: 4452