akhauriyash/Code-Regression huggingface dataset:
# Aizu Problem 0009: Prime Number
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(10**6)

for line in sys.stdin:
    n = int(line)
    idx = bisect.bisect_right(primes, n)
    print(idx)

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

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

const int lim = 1000000007;
const int INF = 1000000000;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    int val = 0;
    rep(i, N){
        cin >> a[i];
        val += a[i];
    }
    vector<int> sum(N+1, 0);
    for(int i = 1; i < N+1; i++){
        sum[i] = sum[i-1] + a[i-1];
    }

    int ans = INF;
    for(int i = 1; i < N; i++){
        int l = sum[i];
        int r = val - sum[i];
        ans = min(ans, (int)fabs(l-r));
    }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define len(s) s.size()
#define all(v) v.begin(), v.end()
#define tr(it, v) for (auto &it : v)
#define bit(x) __builtin_popcount(x)
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
// =================
void impgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1e9;
const int N = 3e5 + 1;

vi g[N];
int a[N];

void solve()
{
    int n, m, ans = 0, k;
    cin >> n >> m;
    vector<ll> dp(m + 1, 0);
    f(i,0,n) {
        int w,v; cin>>w>>v;
        f(j,m-w,-1) {
            dp[j+w]=max(dp[j+w],dp[j]+v);
        }
    }
    auto it=max_element(all(dp));
    cout<<*it;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

void impgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (a[v])
        {
        }
        dfs(v, 0);
    }
}

Measured memory_bytes: 11128
#include <stdio.h>
#include <math.h>
#include <string.h>
#define rep(i,a,n) for(int i=a;i<n;i++)

char change(char c){
	char r=c;
	if('a'<=c && c<='z') r+='A'-'a';
	if('A'<=c && c<='Z') r+='a'-'A';
	return r;
}

int main(){
	int len;
	char s[1210];
	gets(s);
	len=strlen(s);
	rep(i,0,len){
		s[i]=change(s[i]);
	}
	printf("%s\n",s);
	return 0;
}

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

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 1000006;

//const int maxn = 15;

//int a[maxn][maxn];
char s[maxn];
int a[maxn];

int main()
{
	//for (int mask = 0; mask < (1 << maxn); mask++)
	//{
		//int n = maxn;
		//for (int i = 0; i < n; i++) a[0][i] = ((mask >> i) & 1);
		//int predict = 0;
		//for (int i = 0; i < n; i++)
		//{
			//// c_(n-1)^i
			//if (((n - 1) & i) == i) predict += a[0][i];
		//}
		//predict %= 2;
		//for (int i = 1; i <= n - 1; i++)
		//{
			//for (int j = 0; j < n - i; j++) a[i][j] = abs(a[i - 1][j] - a[i - 1][j + 1]);
		//}
		//cout << mask << ' ' << a[n - 1][0] << ' ' << predict << endl;
	//}
	
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	for (int i = 0; i < n - 1; i++) a[i] = abs(s[i] - s[i + 1]);
	n--;
	
	int predict = 0;
	for (int i = 0; i < n; i++)
	{
		// c_(n-1)^i
		if (((n - 1) & i) == i) predict += a[i];
	}
	predict %= 2;
	if (predict == 1)
	{
		cout << 1 << endl;
		return 0;
	}
	
	for (int i = 0; i < n; i++) if (a[i] == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	
	predict = 0;
	for (int i = 0; i < n; i++)
	{
		a[i] /= 2;
		// c_(n-1)^i
		if (((n - 1) & i) == i) predict += a[i];
	}
	predict %= 2;
	if (predict == 1)
	{
		cout << 2 << endl;
	} else cout << 0 << endl;
	
    return 0;
}


Measured memory_bytes: 5248
#include "bits/stdc++.h"
using namespace std;

const int maxn = 1e2 + 10;

int n, m, colors, a[maxn * maxn];

int grid[maxn][maxn];

int main() {
	scanf("%d %d %d", &n, &m, &colors);

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

	int row = 0, col = 0, dir = 1;
	for(int c = 0; c < colors; ++c) {
		while(a[c]) {
			grid[row][col] = c + 1;
			--a[c];
			col += dir;
			if(col == m || col < 0) {
				++row;
				if(col == m) dir = -1, col = m - 1;
				else dir = 1, col = 0;
			} 
		}
	}

	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j)
			printf("%d ", grid[i][j]);

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem2216 : Summer of KMC **/
int main()
{
	int a, b;
	while (cin>>a>>b, a||b) {
		int c = b - a;
		cout << c%500/100 << " " << c%1000/500 << " " << c/1000 << endl;
	}
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);

        if(a == b){
            System.out.println(c);
        } else if(b == c){
            System.out.println(a);
        } else {
            System.out.println(b);
        }
    }
}


Measured memory_bytes: 20564
/*
ask how many 5 in n(n - 2)(n - 4)(n - 6)(n - 8)...


*/

#include <cstdio>

typedef long long int64;

int main() {
	int64 n, res = 0;
	int64 k;
	
	scanf("%lld", &n);
	if(n % 2 == 0){
		for(k = 10; k <= n; k *= 5) 
			res += n / k;
		printf("%lld\n", res);
	}
	else 
		printf("0\n");
	return 0;
}

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

int main(){

long long x, cnt = 0;
  cin >> x;
  
  if(x > 10){
    cnt = x / 11;
    x %= 11;
  }
  
  if(x == 0) cout << cnt * 2 << endl;
  else if((x < 7) && (x > 0)) cout << 1 + cnt * 2 << endl;
  else if((x < 11) && (x > 6)) cout << 2 + cnt * 2 << endl;
  return 0;
  
}
 

Measured memory_bytes: 256
use std::cmp::min;
use std::cmp::max;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

fn main() {
    let nk: Vec<usize> = read_vec();
    let (n, k) = (nk[0], nk[1]);
    let ab: Vec<Vec<usize>> = read_vec2(n);
    let mut B = vec![0; 200000];
    for i in 0..n {
        B[ab[i][0]] += ab[i][1];
    }

    let mut counter = 0;
    let mut index = 1;
    loop {
        counter += B[index];
        if counter < k {
            index += 1;
            continue
        } else {
            break
        }
    }

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

Measured memory_bytes: 11768
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        char a = s[i];
        ans++;
        while(i + 1 < n && s[i + 1] == a){
            ++i;
        }
    }
    cout << ans;
}

Measured memory_bytes: 512
var N,a,maxa,premaxa,i,maxNo:int64;
begin
read(N);
maxa:=0;
premaxa:=0;
maxNo:=0;
for i := 1 to N do
 begin
  read(a);
  if a >= maxa then begin 
   premaxa:=maxa; maxa:=a; maxNo:=i end
  else if a >= premaxa then premaxa:=a;
 end;
for i := 1 to n do
if i= maxNo then writeln(premaxa) 
else writeln(maxa);
end.

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

int main() {
  ll n;
  ll k;
  cin >> n >> k;
  vector<ll> telepo(n);
  vector<ll> a(n);
  map<ll, ll> mp;
  rep(i, n){
    cin >> a[i];
  }
  telepo[0] = 1;
  for (int i = 0; i < n-1; i++){
    telepo[i + 1] = a[telepo[i]-1];
  }
  ll loop_point = 0;
  ll loop_point_last = 0;
  rep(i,n){
    mp[telepo[i]]++;
    if(mp[telepo[i]] > 1){
      loop_point = i;
      break;
    }
  }
  loop_point_last = loop_point - 1;
  for (ll i = loop_point_last; i >= 0; i--){
    if(telepo[i] == telepo[loop_point]){
      loop_point = i;
      break;
    }
  }
  ll loop_range = loop_point_last - loop_point + 1;
  if (k < loop_point_last){
    cout << telepo[k] << endl;
    return 0;
  }
  k -= loop_point;
  cout << telepo[loop_point + (k % loop_range)] << endl;
}

Measured memory_bytes: 18708
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . ___
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         ·ð×æ±£ÓÓ       ÓÀÎÞBUG
*/
//use readint!
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize(5)
#pragma GCC optimize(6)
#pragma GCC optimize(7)
#pragma GCC optimize(8)
#pragma GCC optimize(9)
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<assert.h>
#include<time.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
#define ll long long
#define all(v) v.begin(),v.end()
#define memset(a,b) memset(a,b,sizeof(a))
using namespace std;
const int INF=1e9;
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
inline int readint(){
    int x=0;
    int f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline int fd(string a,string b){
	char c;
	int i,j,rt=0;
	for(c='a';c<='z';c++){
		bool ok=0;
		for(i=0;i<a.size();i++) if(a[i]==c){
			ok=1;
			break;
		}
		if(!ok) continue;
		ok=0;
		for(i=0;i<b.size();i++) if(b[i]==c){
			ok=1;
			break;
		}
		rt+=ok;
	}
	return rt;
}
int main(){
	int i,j,n,ans=0;
	string s;
	cin>>n>>s;
	for(i=0;i<s.size()-1;i++){
		ans=max(ans,fd(s.substr(0,i+1),s.substr(i+1)));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;


void solve(long long N){
  cout << pow(N,3) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int dfs(int i, int k, string &S) {
    if (i + K - k > S.size())
        return 0;
    if (k == K)
        return 1;
    int res = 0;
    int now = S[i] - '0';
    if (now == 0) {
        res += dfs(i + 1, k, S);
    } else {
        res += dfs(i + 1, k + 1, S);
        int n = S.size() - 1 - i;
        //0
        if (n >= K - k) {
            int tmp = 1;
            REP(i, K - k) {
                tmp *= 9 * (n - i);
                tmp /= (i + 1);
            }
            res += tmp;
        }
        //0以外
        if (n >= K - k - 1) {
            int tmp = 1;
            REP(i, K - k - 1) {
                tmp *= 9 * (n - i);
                tmp /= (i + 1);
            }
            res += (now - 1) * tmp;
        }
    }
    return res;
}

signed main() {
    cin >> S >> K;
    cout << dfs(0, 0, S) << endl;
}

Measured memory_bytes: 3676
from numpy import*
k,A,F=[int64(t.split())for t in open(0)]
l=-1
r=10**12
while~l+r:
 m=l+r>>1
 if sum(A-minimum(sort(A),m//sort(F)[::-1]))>k[1]:l=m
 else:r=m
print(r)

Measured memory_bytes: 37252
import copy
N,L = map(int,input().split())
flaver = []
for i in range(1,N + 1):
    flaver.append(L + i - 1)
flaver_sum = sum(flaver)
for i in range(len(flaver)):
    c_flaver = copy.deepcopy(flaver)
    del c_flaver[i]
    if i == 0:
        tmp_min = abs(flaver_sum - sum(c_flaver))
        index = i
    if abs(flaver_sum - sum(c_flaver)) < tmp_min:
        tmp_min = abs(flaver_sum - sum(c_flaver))
        index = i
del flaver[index]
print(sum(flaver))


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

int main() 
{
	int n,m; cin>>n>>m;
	map<int,int>mp;
	for(int i=0;i<m;i++)
	{
		int q; cin>>q;
		for(int k=0;k<q;k++)
		{
			int p; cin>>p;
			mp[p]++;
		}
	}
	int ct=0;
	for(int i=1;i<=n;i++){if(!mp[i]){ct++;}}
	cout<<ct;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn=10000000;

int prime[2000005];
bool check[maxn+5];

void pre() {
  check[1]=1;
  int tot=0;
  for(int i=2;i<=maxn;i++) {
  	if (!check[i]) prime[++tot]=i;
  	for(int j=1;j<=tot&&i*prime[j]<=maxn;j++) {
  	  check[i*prime[j]]=1;
  	  if (i%prime[j]==0) break;
    }
  }
}

bool in[maxn+5];
int num1[105],num2[105],s1,s2;
bool e[105][105];

bool vis[105];
int link[105];

bool dfs(int x) {
  for(int i=1;i<=s2;i++)
    if (e[x][i]&&!vis[i]) {
    	vis[i]=1;
    	if (!link[i]||dfs(link[i])) {
    		link[i]=x;
    		return 1;
		}
	}
  return 0;
}

int match() {
  int ans=0;
  for(int i=1;i<=s1;i++) {
  	memset(vis,0,sizeof(vis));
  	ans+=dfs(i);
  }
  return ans;
}

int main() {
  pre();
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
  	int x;
  	scanf("%d",&x);
  	in[x]^=1;
  }
  for(int i=1;i<=maxn+2;i++)
    if (in[i]!=in[i-1]) {
    	if (i&1) num1[++s1]=i;
    	else num2[++s2]=i;
	}
  for(int i=1;i<=s1;i++)
    for(int j=1;j<=s2;j++)
      if (!check[abs(num1[i]-num2[j])]) e[i][j]=1;
  int sum=match(); 
  printf("%d\n",sum+((s1-sum)>>1<<1)+((s2-sum)>>1<<1)+((s1-sum)&1)*3);
  return 0;
}

Measured memory_bytes: 20736
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int n;
    cin>>n;
    vi p(n);
    cin>>p;
    vi b(n);
    b[p[0]-1]=1;
    REP(i,1,n){
        if(b[p[i]-2]){
            b[p[i]-1]=b[p[i]-2]+1;
        }else{
            b[p[i]-1]=1;
        }
    }
    int ma=*max_element(all(b));
    dprint(b);
    //chmax(ma,c);
    cout<<n-ma<<endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, S[100];
  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> S[i];

  int sum_ = 0;
  int min_ = INT_MAX;
  for (int i = 0; i < N; ++i) {
    sum_ += S[i];
    if (S[i] % 10)
      min_ = min(min_, S[i]);
  }
  if (min_ == INT_MAX)
    cout << "0";
  else if (sum_ % 10)
    cout << sum_;
  else
    cout << sum_ - min_;
  cout << endl;
}


Measured memory_bytes: 256
A,B,C=map(int,input().split())
initial = list([A, B, C])
initial.sort()
n=0
while True:
    if A%2==0 and B%2==0 and C%2==0:
        n+=1
        A_half = A//2
        B_half = B//2
        C_half = C//2
        A = B_half + C_half
        B = C_half + A_half
        C = A_half + B_half
        now = list([A, B, C])
        now.sort()
        if now == initial:
            n = -1
            break
    else:
        break

print(n)


Measured memory_bytes: 61680
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	std::string s;
	in >> s;
	if (s <= "2019/04/30") {
		out << "Heisei" << endl;
	}
	else {
		out << "TBD" << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int N,M;
    cin>>N>>M;
    vector<int>A(M);
    int sum=0;
    rep(i,M){
        cin>>A[i];
        sum+=A[i];
    }
    if(N>=sum){
        cout<<N-sum<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i = l;i < r;i++)
#define de(x) cout<<#x<<" = "<<x<<endl
int main()
{
	char c;
	rep(i,0,10){
		cin>>c;
		if(i == 3) cout<<'8';
		else cout<<c; 
	}
	return 0;
} 

Measured memory_bytes: 256
ans = []
alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
k = int(input())
l = ['']*k
def recur(l, ind, newChar):
    if ind == k:
        ans.append(''.join(l))
        return
    for i in range(newChar):
        l[ind] = alp[i]
        recur(l, ind+1, newChar)
    l[ind] = alp[newChar]
    recur(l, ind+1, newChar+1)

recur(l,0,0)
for a in ans:
    print(a)

Measured memory_bytes: 12656
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

template <typename T>
class segmenttree
{
private:
    int n;

public:
    using F = function<T(T, T)>;

    T dif;
    F f;
    vector<T> st;

    segmenttree(int size, T init, F f) : f(f)
    {
        n = 1;

        while (n < size)
        {
            n *= 2;
        }

        st.assign(2 * n - 1, init);
    }

    void set(int i, T x)
    {
        st[i + n - 1] = x;
    }

    void build()
    {
        for (int i = n - 2; i >= 0; i--)
        {
            st[i] = f(st[i * 2 + 1], st[i * 2 + 2]);
        }
    }

    void update(int i, T x)
    {
        i += n - 1;
        st[i] = x;

        while (i > 0)
        {
            i = (i - 1) / 2;
            st[i] = f(st[2 * i + 1], st[2 * i + 2]);
        }
    }

    T query_(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
        {
            return dif;
        }

        if (a <= l && r <= b)
        {
            return st[k];
        }
        else
        {
            T x = query_(a, b, 2 * k + 1, l, (l + r) / 2);
            T y = query_(a, b, 2 * k + 2, (l + r) / 2, r);

            return f(x, y);
        }
    }

    T query(int a, int b)
    {
        return query_(a, b, 0, 0, n);
    }
};

int main(void)
{
    int n, q;
    string s;
    int i, j;
    vector<int> ans;

    cin >> n >> s >> q;

    segmenttree<bitset<26>> seg(n, 0, [](bitset<26> a, bitset<26> b) { return a | b; });
    seg.dif = 0;

    rep(i, 0, n)
    {
        bitset<26> bit = 1 << (s[i] - 'a');
        seg.set(i, bit);
    }

    seg.build();

    rep(i, 0, q)
    {
        int x;

        cin >> x;

        if (x == 1)
        {
            int iq;
            char c;
            bitset<26> bit;

            cin >> iq >> c;
            iq--;

            s[iq] = c;
            bit = 1 << (s[iq] - 'a');

            seg.update(iq, bit);
        }
        else
        {
            int l, r;
            int an = 0;

            cin >> l >> r;
            l--;

            bitset<26> bit = seg.query(l, r);

            an = bit.count();

            ans.push_back(an);
        }
    }

    for (auto &z : ans)
    {
        cout << z << endl;
    }
}

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

int main(){
    int H,N;
    cin >> H >> N;
    int sum = 0;
    int save;
    rep(i,N){
        cin >> save;
        sum += save;
    }
    if(H <= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a=0;
  int  b =0;
  scanf("%d" , &a);
  scanf("%d" , &b);
  
  if(a<=12&&a>=6)
{b=b/2;}
else if(a<=5)
{b =0;}

printf("%d" , b);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

e = 0
for i in range(N):
    e = e+B[A[i]-1]
    if i < N-1:
        if A[i]+1==A[i+1]:
            e = e+C[A[i]-1]

print(e)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
   int a,b,c;
    while(~scanf("%d %d %d",&a,&b,&c))
    {
         int num[12];
        num[5]=2;
        num[7]=1;
        num[a]--;
        num[b]--;
        num[c]--;
        if(num[5]==0&&num[7]==0)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	ll x; cin >> x;
	bool used[200005] = {};
	vector<ll> pr;
	for (ll i = 2; i <= 200000; i++) {
		if (used[i]) continue;
		pr.push_back(i);
		ll w = i;
		while (w <= 200000) {
			used[w] = true;
			w += i;
		}
	}
	for (ll a : pr) {
		if (a >= x) {
			cout << a << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

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

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> next(N);
    for (int i = 0; i < N; ++i) cin >> next[i];

    int prev = 1;
    set<int> prevs;
    int count = 0;
    for (;;)
    {
        prevs.insert(prev);
        ++count;
        prev = next[prev - 1];
        if (prev == 2)
        {
            cout << count << endl;
            break;
        }
        if (prevs.find(prev) != prevs.end())
        {
            cout << -1 << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	bool b;
	int w, h, x, y, r;

	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h)
		b = true;
	else
		b = false;

	printf("%s\n", b ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
#define NUMDATA 100
#define LEN_NAME 10

typedef struct d{
    int num;
    char name[LEN_NAME + 1];
    int point;
}Data;

int strcompare(const char *a, const char *b){
    while(*a == *b){
        if(*a == '\0'){
            //最後まで一致
            return 0;
        }
        a++;
        b++;
    }
    /*
        aが辞書順で先行(小さい)なら負の値
        bが辞書順で先行(小さい)なら正の値
    */
    return *a - *b;
}

void insertionsort(Data data[], int start, int end){
    int i,j;
    Data tmp;
    for(i = start + 1; i <= end; i++){
        tmp = data[i];
        if(strcompare(data[i-1].name, tmp.name) > 0){//data[i - 1] > tmp
            j = i;
            do{
                data[j] = data[j - 1];
                j--;
            }while(j > start && strcompare(data[j-1].name, tmp.name) > 0);//data[j - 1] > tmp
            data[j] = tmp;
        }
    }
}

void insertionsort_desc(Data data[], int start, int end){
    int i,j;
    Data tmp;
    for(i = start + 1; i <= end; i++){
        tmp = data[i];
        if(data[i - 1].point < tmp.point){
            j = i;
            do{
                data[j] = data[j - 1];
                j--;
            }while(j > start && data[j - 1].point < tmp.point);
            data[j] = tmp;
        }
    }
}

int main(void){
    int n;
    Data d[NUMDATA];
    int i,j,flag = -1;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %d", &(d[i].name), &(d[i].point));
        d[i].num = i + 1;
    }
    
    insertionsort_desc(d, 0, n - 1);
    insertionsort(d, 0, n - 1);
    
    for(i = 0; i < n; i++){
        printf("%d\n", d[i].num);
    }
    
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<vector>
#define MAXN 100000
using namespace std;
typedef pair<int,int> PII;
queue<PII> que;
set<int> st[MAXN+5];
map<PII,int> mp;
int N,setfa[MAXN+5];
vector<int> vec;
PII Work(int x,int y)
{
	if(x>y)
		swap(x,y);
	return PII(x,y);
}
void AddEdge(int u,int v)
{
	st[u].insert(v);
	st[v].insert(u);
	mp[Work(u,v)]++;
	if(mp[Work(u,v)]==2)
		que.push(Work(u,v));
}
void Init()
{
	for(int i=0;i<=MAXN;i++)
		setfa[i]=i;
}
int Findfa(int x)
{
	if(x==setfa[x])
		return x;
	return setfa[x]=Findfa(setfa[x]);
}
void Union(int x,int y)
{
	int fx=Findfa(x),fy=Findfa(y);
	if(fx==fy)
		return;
	setfa[fx]=fy;
}
int main()
{
//	freopen("bluered.in","r",stdin);
//	freopen("bluered.out","w",stdout);
	Init();
	scanf("%d",&N);
	int u,v;
	for(int i=1;i<=2*N-2;i++)
	{
		scanf("%d %d",&u,&v);
		AddEdge(u,v);
	}
	set<int>::iterator it;
	for(int i=1;i<=N-1;i++)
	{
		int spu,spv;
		while(true)
		{
			if(que.empty()==true)
			{
				printf("NO\n");
				exit(0);
			}
			u=Findfa(que.front().first);
			v=Findfa(que.front().second);
			que.pop();
			if(Findfa(u)==Findfa(v))
				continue;
			spu=u,spv=v;
			break;
		}
		if(st[spu].size()>st[spv].size())
			swap(spu,spv);
		Union(spu,spv);
		mp.erase(Work(spu,spv));
		st[spv].erase(spu);
		vec.clear();
		for(it=st[spu].begin();it!=st[spu].end();it++)
			vec.push_back(*it);
		for(int i=0;i<vec.size();i++)
		{
			int poi=vec[i];
			poi=Findfa(poi);
			if(poi==spv)
				continue;
			mp.erase(Work(spu,poi));
			st[poi].erase(spu);
			st[spu].erase(poi);
			AddEdge(poi,spv);
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 36608
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll n;
	cin>>n;
    ll a[n];
    map<ll,ll> mp;
    for(ll i=0;i<n;i++){
    	cin>>a[i];
        mp[a[i]]++;
    }
     ll ans =0;
    for(auto x : mp){
    	ans += x.second*(x.second-1)/2;
    }
   for(ll i=0;i<n;i++){
   	  cout<<(ans - (mp[a[i]]-1)) <<endl;
   }
   return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<double, P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)10000000000000000

int main() {
  ll N,Q;
  cin>>N>>Q;
  priority_queue<event>pq;
  set<ll>st;
  //eventはP(P(a,b),c)で書き、
  //aに時刻をもち,b=0→工事開始,1→終了,2→歩行者とする
  rep(i,N){
    double s,t;
    ll x;
    cin>>s>>t>>x;
    s=(double)x-s+0.5;
    t=(double)x-t+0.5;
    pq.push(event(s,P(0ll,x)));
    pq.push(event(t,P(1ll,x)));
  }
  rep(i,Q){
    double g;
    cin>>g;
    pq.push(event(-1*g,P(2ll,0ll)));
  }
  while(!pq.empty()){
    auto t=pq.top();
    pq.pop();
    if(t.second.first==0){
      st.insert(t.second.second);
    }
    if(t.second.first==1){
      st.erase(t.second.second);
    }
    if(t.second.first==2){
      if(st.empty()){cout<<-1<<endl;}
      else{
        cout<<*begin(st)<<endl;
      }
    }
  }
}

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


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

    // 入出力
    int h,w,n; cin >> h >> w >> n;
    int a[n]; rep(i,n) cin >> a[i];
    int c[h][w];

    // グリッド一筆書きを作る
    vector<pair<int,int>> road;
    rep(i,h){
        if(i%2) rep(j,w) road.emplace_back(i,w-j-1);
        else rep(j,w) road.emplace_back(i,j);
    }

    // 辿る
    int nc = 0;
    rep(i,h*w){
        int y = road[i].first, x = road[i].second;
        if(a[nc] == 0) nc++;
        c[y][x] = nc+1;
        a[nc]--;
    }

    // 出力
    rep(i,h){
        rep(j,w) cout << c[i][j] << " ";
        cout << "\n";
    }
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int s, c;
	int ans[3] = { -1, -1, -1 };

	if (m == 0 && n != 1) {
		ans[0] = 1;
	}
	if (m == 0 && n == 1) {
		ans[0] = 0;
	}

	for (int i = 0; i < m; i++) {
		cin >> s >> c;

		if (n !=1 && s == 1 && c == 0) {
			cout << -1 << endl;

			return 0;
		}
		if (ans[s - 1] != -1 && ans[s - 1] != c) {
			cout << -1 << endl;

			return 0;
		}
		ans[s - 1] = c;
	}
	ans[0] = ((ans[0] == -1) ? 1 : ans[0]);
	for (int i = 1; i < 3; i++) {
		ans[i] = ((ans[i] == -1) ? 0 : ans[i]);
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long int
using namespace std;










void solve() {
    LL n;
    cin >> n;
    LL ans = 0;
    LL v = 100;
    LL count = 0;
    while (1)

    {
        v = v * 1.01;
        if (v >= n)
            break;
        else
            count++;
    }
    cout << count + 1 << "\n";







}




int main()
{


    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


/*int n, q;
   cin >> n >> q;
   string s;
   cin >> s;
   transform(s.begin(), s.end(), s.begin(), ::tolower);
   int a[26] = {0};
   for (int i = 0; i < s.length(); i++)
   {
       a[s[i] - 'a']++;
   }
   int maxOcc = 0;
   for (int i = 0; i < 26; i++)
       maxOcc = max(maxOcc, a[i]);*/

Measured memory_bytes: 3520
#from collections import deque
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#from decimal import Decimal
#mod = 1000000007
#mod = 998244353
N = int(input())
#N, K = map(int, input().split())
#A = list(map(int, input().split()))
#flag = True
#for k in range(N):
ans = N*N*N
print(ans)
#print('Yes')
#print('No')

Measured memory_bytes: 61724
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

#define REP( i, n) for( int i = 0; i < (n); ++i)
#define FOR( i, a, b) for( int i = (a); i < (b); ++i)

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){

  int n;
  vector<int> a;

  cin >> n;
  a.resize(n);
  REP( i, n){
    cin >> a[i];
  }

  int minj;
  int count = 0;
  int tmp;


  for( int i = 0; i < n; ++i){
    minj = i;
    for( int j = i; j < n; ++j){
      if( a[j] < a[minj]){
        minj = j;
      }
    }
    if( i != minj){
      ++count;
    }
    swap( a[i], a[minj]);
  }

  REP( i, n-1){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  cout << count << endl;

}

Measured memory_bytes: 3092
def jump(i):
    memo[0] = 0
    memo[1] = abs(arr[1]- arr[0])               
    for i in range(2, n):
        memo[i] = min(memo[i-1] + abs(arr[i-1]- arr[i]) ,
                      memo[i-2] + abs(arr[i-2]- arr[i]))
    return memo[-1]    

n = int(input())
arr = list(map(int, input().split()))
memo = [-1] * n 
                   
result = jump(n)
print(result)


Measured memory_bytes: 13928
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			long a = scan.nextLong();
			long b = scan.nextLong();
			
			long max = Math.max(a, b);
			long min = Math.min(a, b);
			
			long yakusu = 0;
			long cal = 0;
			
			for(;true;){
				cal = max % min;
				max = min;
				min = cal;
				
				if(min==0){ 
					yakusu = max;
					break;
				}
			}
			
			long baisu = 0;
			baisu = a * b / yakusu;
			
			System.out.println(yakusu+" "+baisu);
		}			
	}
}

Measured memory_bytes: 26264
#! /usr/bin/env python
# -*- coding: utf-8 -*-

x_list = []
y_list = []
while True:
    x, y = map(int, raw_input().split())
    if x == 0 and y == 0:
        break
    else:
        x_list.append(x)
        y_list.append(y)

for i, num in enumerate(x_list):
    if x_list[i] == y_list[i]:
        print("%d %d") % (x_list[i], y_list[i])
    elif x_list[i] < y_list[i]:
        print("%d %d") % (x_list[i], y_list[i])
    else:
        print("%d %d") % (y_list[i], x_list[i])

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll a,b,k,tmp=0; cin>>a>>b>>k;
    for(int i=min(a,b); i>=1; i--){
        if(a%i==0 && b%i==0) tmp++;
        if(tmp==k){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3544
#include "bits/stdc++.h"
using namespace std;

struct dat {
	int x, y, z;
};

int main() {
	int N;
	cin >> N;
	vector<int>A(3 * N + 2);
	for (int i = 0; i < 3 * N; ++i) {
		int n;
		cin >> n;
		n--;
		A[i] = n;
	}
	A[3 * N] = N;
	A[3 * N + 1] = N;
	vector<vector<int>> dp(N + 1, vector<int>(N + 1, -1e9));
	vector<int> dp2(N + 1, -1e9);
	dp[A[0]][A[1]] = 0;
	dp[A[1]][A[0]] = 0;
	dp2[A[0]] = 0;
	dp2[A[1]] = 0;

	int add = 0;
	int premax = 0;

	for (int i = 0; i < 3 * N; i += 3) {
		vector<dat>upd;
		vector<int>B{ A[i + 2],A[i + 3],A[i + 4] };
		sort(B.begin(), B.end());
		if (B[0] == B[2]) {//aaa
			add++;
			continue;
		}
		if (B[0] == B[1]) {//aab
			for (int j = 0; j < N; ++j) {
				upd.push_back({ j,B[2] , dp[B[0]][j] + 1 });
			}
			upd.push_back({ B[0],B[1] , dp[B[2]][B[2]] + 1 });
		}
		else if (B[1] == B[2]) {//abb
			for (int j = 0; j < N; ++j) {
				upd.push_back({ j,B[0] , dp[B[1]][j] + 1 });
			}
			upd.push_back({ B[1],B[2] , dp[B[0]][B[0]] + 1 });
		}
		else {
			//abc
			upd.push_back({ B[1],B[2] , dp[B[0]][B[0]] + 1 });
			upd.push_back({ B[0],B[2] , dp[B[1]][B[1]] + 1 });
			upd.push_back({ B[0],B[1] , dp[B[2]][B[2]] + 1 });
		}
		for (int j = 0; j < N; ++j) {
			upd.push_back({ j, B[0], dp2[j] });
			upd.push_back({ j, B[1], dp2[j] });
			upd.push_back({ j, B[2], dp2[j] });
		}
		upd.push_back({ B[0],B[1] , premax });
		upd.push_back({ B[0],B[2] , premax });
		upd.push_back({ B[1],B[2] , premax });
		for (int i = 0; i < upd.size(); ++i) {
			int x = upd[i].x;
			int y = upd[i].y;
			int z = upd[i].z;
			dp[x][y] = max(dp[x][y], z);
			dp[y][x] = max(dp[y][x], z);
			premax = max(premax, z);
			dp2[x] = max(dp2[x], z);
			dp2[y] = max(dp2[y], z);
		}
	}
	cout << premax + add << endl;
	return 0;
}


Measured memory_bytes: 19456
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
/*********head**********/
const int MAXN=105;
char buf[MAXN];
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",buf+1);
    int k;
    scanf("%d",&k);
    rep(i,1,n){
        if(buf[i]!=buf[k]){
            buf[i]='*';
        }
    }
    puts(buf+1);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,a=0,w=0,t=0,r=0;
  cin >> n;
  string s[n];
  for(int i=0;i<n;++i) {
    cin >> s[i];
    if(s[i]=="AC") a++;
    if(s[i]=="WA") w++;
    if(s[i]=="TLE") t++;
    if(s[i]=="RE") r++;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
}

Measured memory_bytes: 6720
N = int(input())

Dishes  = list(map(int, input().split(" ")))
Scores  = list(map(int, input().split(" ")))
Bonuses = list(map(int, input().split(" ")))

#print(Dishes)
#print(Scores)
#print(Bonuses)

TotalScore = sum(Scores)
for i in range(N-1):
    if Dishes[i] + 1 == Dishes[i+1]:
        BonusIdx = Dishes[i] - 1
        TotalScore = TotalScore + Bonuses[BonusIdx]
print(TotalScore)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "YES" << endl;}
void no(){ cout << "NO" << endl;}

//-----------------------------------------
void bfs(ll s, vvll &graph, vll &d, ll &n, vll &c){
  vll seen(n,0);
  queue<ll> que;

  seen[s] = 1;
  que.push(s);
  ll j = 0;
  d[s] = c[j];
  j++;

  while(!que.empty()){
    ll t = que.front(); que.pop();
    seen[t] = 1;
    for(ll i = 0; i < graph[t].size(); i++){
      ll u = graph[t][i];
      if(seen[u] == 0){
        que.push(u);
        d[u] = c[j];
        j++;
      }
    }
  }
}
//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;

  vvll graph(n);
  REP(i,n-1){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  vll c(n);
  REP(i,n) cin >> c[i];
  sort(ALL(c));
  reverse(ALL(c));

  ll ans = 0;
  vll d(n);

  bfs(0,graph,d,n,c);

  REP(i,n){
    if(i) ans += c[i];
  }

  cout << ans <<endl;

  REP(i,n){
    if(i) cout << " ";
    cout << d[i];
  }
  cout << endl;



  return 0;
}



Measured memory_bytes: 4260
#include<iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
    long long n,l,ans;
    cin >> n >> l;
    if(l >= 0)
    {
        ans = (((n+l+l-1)*n)/2)-l;
        cout << ans; 
    }
    else if (l+n > 0)
    {
        ans = (((n+l+l-1)*n)/2);
        cout << ans;
    }
    else
    {
        ans = (((n+l+l-1)*n)/2)-(n+l-1);
        cout << ans;
    }
    
    return 0;
}

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

int main() {
    int a, b;
    cin>>a>>b;
    
    if (a == b)cout<<"Draw"<<endl;
    else if (a == 1)cout<<"Alice"<<endl;
    else if (b == 1)cout<<"Bob"<< endl;
    else a > b ? cout<<"Alice"<<endl : cout<<"Bob"<<endl;
}


Measured memory_bytes: 3164
import copy

S = list(input())
T = list(input())

c = {}
for i in range(len(S)):
    if S[i] in c:
        if c[S[i]] != T[i]:
            print('No')
            exit()
    elif T[i] in c.values():
        ct = copy.copy(c)
        ct[S[i]] = T[i]
        keys = [k for k, v in ct.items() if v == T[i]]
        if len(set(keys)) != 1:
            print('No')
            exit()
    else:
        c[S[i]] = T[i]
    
print('Yes')

Measured memory_bytes: 6960