akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
// long long const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            // res = res*a;
            res = (res*a)%m;
        }
        a=(a*a)%m;
        // a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 1e5+5;
int const inf = 2e18;

void solve(){  
    int i,j;
    int n,k;
    cin >> n >> k;
    int a[n];
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    int lb = 1;
    int ub = 1e9;
    int ans = 0;

    while(lb <= ub){
        int mid = (lb+ub)/2;
        int cnt = 0;
        for(i=0;i<n;i++){
            int x = a[i];
            x -= mid;
            x = max(0LL , x);
            cnt = cnt + (x+mid-1)/mid;
        }
        if(cnt <= k){
            ans = mid;
            ub = mid - 1;
        }
        else{
            lb = mid + 1;
        }
    }
    cout<<ans<<endl;
}           



int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;  
    for(int tt=1;tt<=t;tt++){
        // cout << "Case #"<<tt<<": ";
        solve();
    }
    return 0;
}


/*


*/

Measured memory_bytes: 5192
#include <cmath>
#include <vector>
#include <iostream>

int main() {
    int N;
    double s = 0;

    std::cin >> N;

    std::vector<int> X(N);

    // O(n)
    for (int i = 0; i < N; ++i) {
        std::cin >> X.at(i);
        s += X.at(i);
    }

    int P = std::round(s / N);

    // O(n)
    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += pow(X.at(i) - P, 2);
    }
    
    std::cout << ans << std::endl;

    return 0;
}

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

int main() {
    long a, b, k;
    cin >> a >> b >> k;
    if(k <= a){
        cout << a-k << " " << b << endl;
    }
    else if(k > a && k<=a+b){
        cout << 0 << " " << a+b-k << endl;
    }
    else{
        cout << 0 << " " << 0 << endl;
    }
}

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

int main()
{    
  int n=26;
  long long int i,amari;
  int j,count;
  int z=0;
  scanf("%lld",&i);
  int str[20000];
  /*char buff[20000];
  char ss[20000];*/
  
  count = -1;
  while(i > 0)
  {
    i = i-1;
    count++;
    amari=i % n;
    str[count] = amari;
    i=i/n;
  }
  
  for(j=count;j>=0;j--){
    printf("%c",(str[j]+'a'));
  }
  printf("\n");
  
  return 0; 
}

Measured memory_bytes: 1644
#include<iostream>
#include<cstring> 
using namespace std;
int main()
{
	char a[20];
	int n,A=0,B=0,C=0,ans=0;
	cin>>n;
	while(n--)
	{
		cin>>a;
		int len = strlen(a);
		if(a[0]=='B')
		B++;
		if(a[len-1]=='A')
		A++;
		if(a[0]=='B'&&a[len-1]=='A')
		C++;
		for(int i=0;i<len;i++)
		{
			if(a[i]=='A'&&a[i+1]=='B')
			ans++;
		}
	}
	int t;
	if(A>B) t = B;
	else
	t = A;
	if(A == C&&B == C&&C!=0)
		ans--;
	cout<<ans+t<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    string str[9];
    int a[9],b[9],i,ab[9];
    long long sum[9];
    for(i=0;i<9;i++){
        cin>>str[i]>>a[i]>>b[i];
    }
    for(i=0;i<9;i++){
        ab[i]=a[i]+b[i];
        sum[i]=a[i]*200+b[i]*300;
    }
    for(i=0;i<9;i++){
        cout<<str[i]<<" "<<ab[i]<<" "<<sum[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> B(n-1,0);
    int sum = 0;
    for (int i = 0; i < n-1; i++) {
        cin >> B.at(i);
        if (i == 0) {
            sum += B.at(0);
        }
        else {
            sum += min(B.at(i-1), B.at(i));
        }
    }
    sum += B.at(n-2);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s;
    while (cin >> s){
        REP(i,s.length()){
            if (s[i] != '@'){
                cout << s[i];
            }else{
                i++;
                int x = s[i] - '0';
                i++;
                while (x--) cout << s[i];
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3160
#include <stdio.h>

int main(void) {
    char S[4];
    int n=0;
    scanf("%s",S);
    for(int i=0;i<4;i++){
       // printf("%c ",S[i]);
        if(S[i] == '+'){
            n++;
        }else {
            n--;
        }
    }
    printf("%d",n);
    
    return 0;
}

Measured memory_bytes: 128
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cumA = [0] * (N + 1)

for i in range(N):
    cumA[i + 1] += cumA[i] + A[i]

cntA = Counter(cumA)

ans = sum([c * (c - 1) // 2 for c in cntA.values()])

print(ans)

Measured memory_bytes: 115784
n=int(input())
c=0
dic={}
for i in range(n):
    x=input()
    if x not in dic:
        dic[x]=1
    else:
        dic[x]+=1
m=int(input())
for i in range(m):
    x=input()
    if x in dic:
        dic[x]-=1

print(max([max(dic.values()),0]))


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

int main(){
    long long n, a, b, sum1, sum2;
    cin>>n>>a>>b;
//    scanf("%d%d%d", &n, &a, &b);
    if((n<2 && a!=b) || a>b){
        cout<<'0';
    }else if(n==1 && a==b){
        cout<<'1';
    }else{
        sum1 = a*(n-1) + b;
        sum2 = a + (n-1)*b;
        cout<<sum2-sum1+1;
    }

//    sum1 = a*(n-1) + b;
//    sum2 = a + (n-1)*b;
//    if(a>b){
//        cout<<'0';
//    }else if(a==b){
//        cout<<'1';
//    }else{
//        if(n==1)
//            cout<<'0';
//        else{
//            cout<<sum2-sum1+1;
//        }
//    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX=3e5+5;
int east[MAX];
int west[MAX];
int ans,n;
string s;
int main(){
    cin>>n;
    cin>>s;
    if(s[0]=='W')
        west[0]++;
    for(int i=1;i<n;i++)
        if(s[i]=='W')
        west[i]=west[i-1]+1;
        else
            west[i]=west[i-1];
    if(s[n-1]=='E')
        east[n-1]=1;
    for(int i=n-2;i>=0;i--)
            if(s[i]=='E')
                east[i]=east[i+1]+1;
            else
                east[i]=east[i+1];

       //     cout<<"EEEEE"<<endl;
    ans=east[1];
    ans=min(ans,west[n-1]);
   // cout<<ans<<endl;
    for(int i=1;i<n-1;i++)
        ans=min(ans,west[i-1]+east[i+1]);
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int modpow(ll a, ll n, ll p){
  if(n==0) return 1;
  if(n==1) return a%p;
  if(n%2 == 1) return (a*modpow(a,n-1,p))%p;
  ll t = modpow(a,n/2, p);
  return (t*t)%p;
 }

ll modnCa(ll n, ll a, ll p){
  ll upper = 1;
  ll lower = 1;
  for(ll i = 1; i <= a; i++){
    upper *= n-i+1;
    upper %= p;
    lower *= i;
    lower %= p;
  }
  ll inv_lower = modpow(lower, p-2, p);
  return (upper * inv_lower)%p;
}

int main(){
  ll n,a,b;
  cin >> n >> a >> b;

  ll p = 1000000007;
  ll tot = modpow(2, n, p)-1;
  ll atot = modnCa(n, a, p);
  ll btot = modnCa(n, b, p);

  ll ans = (tot - atot - btot+p+p)%p;
  cout << ans << endl;

}


Measured memory_bytes: 3596
N, K, Q = map(int,input().split())
point_list = [0 for i in range(N+1)]
for i in range(Q):
    A = int(input())
    point_list[A]+=1
for i in range(1,N+1):
    if point_list[i]+K-Q<=0:
        print("No")
    else:
        print("Yes")

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

int main() {
  int a;
  cin >> a;
  cout << a + a*a + (a*a)*a <<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

ll modadd(ll a,ll b,ll mod=MOD){
    return (a%mod+b%mod)%mod;
}

ll modsub(ll a,ll b,ll mod=MOD){
    a%=mod;
    b%=mod;
    if(a>=b) return a-b;
    else return mod-b+a;
}

ll modmul(ll a,ll b,ll mod=MOD){
    return ((a%mod)*(b%mod))%mod;
}

ll modpow(ll a, ll n,ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll moddiv(ll a,ll b,ll mod=MOD) {
    return modmul(a, modpow(b, mod-2));
}

vll fac, finv, inv;

void COMinit(ll MAX) {
    if(MAX<1) return;
    fac.resize(MAX);
    finv.resize(MAX);
    inv.resize(MAX);
    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;
    }
}

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




int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    
    vvll P;
    ll i_max=sqrt(M);
    ll COM_MAX=0;
    for(ll i=2;i<=i_max;i++){
        ll count=0;
        while(M%i==0){
            count++;
            M/=i;
        }
        if(count>0){
            P.push_back(vll{i,count});
            if(count>COM_MAX)COM_MAX=count;
        }
    }
    
    if(M!=1) P.push_back(vll{M,1});
    
    COMinit(N+COM_MAX);
    
    ll ans=1;
    for(ll i=0;i<P.size();i++){
        ans=modmul(ans,COM(P[i][1]+N-1,P[i][1]));
    }
    cout<<ans<<endl;
    
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > 9 || b > 9) cout << -1 << endl;
    else cout << a * b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cctype>
#include<algorithm>
using namespace std;
int main(){
  int A,B;
  string S,s1,s2;
  char c1;
  cin >> A >> B;
  int i;
  cin >> S;
  s1 = S.substr(0,A);
  c1 = S[A];
  s2 = S.substr(A+1);
  bool b = true;
  for(int i=0;i<A;i++){
  	if(s1[i] == '-') b = false; 
  }
  for(int i=0;i<B;i++){
  	if(s2[i] == '-') b = false; 
  }
  if(b && c1 == '-'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		if (in.matches(".*9.*")){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}



}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s << endl;
    }
    else {
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}

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

const ll INF = 1LL << 60;

int A, B, C;
int main() {
    cin >> A >> B >> C;

    ll tmp = 0;
    for (int i = 0; i < 6000; i++) {
        tmp = A * i;
        if (tmp % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

N=int(input())
edge = [[] for _ in range(N+1)]

for _ in range(N-1):
    u,v,w=[int(x) for x in input().split()]
    if w&1:
        edge[u].append((v,-1))
        edge[v].append((u,-1))
    else:
        edge[u].append((v,1))
        edge[v].append((u,1))
    
color = [None]*(N+1)

def set_color(v,c):
    color[v]=c
    for x,sgn in edge[v]:
        if color[x] is None:
            set_color(x,sgn*c)
set_color(1,1)

for x in color[1:]:
    print((x+1)//2)

Measured memory_bytes: 76380
n = int(input())
a = list(map(int,input().split()))
dp_table = [0, -10 ** 10]
temp = [0,0]
for i in range(n):
    temp[0] = dp_table[0]
    temp[1] = dp_table[1]
    dp_table[0] = max(temp[0]+a[i],temp[1]-a[i])
    dp_table[1] = max(temp[0]-a[i],temp[1]+a[i])
    
print(dp_table[0])

Measured memory_bytes: 14224
#include <stdio.h>
#define SIZE 100
int main (void)
{
  int n, m, c;
  int i, j;
  int a[SIZE][SIZE] = {{0},{0}},  b[SIZE] = {0};

  scanf("%d%d", &n, &m);

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

  for (i = 0; i < n; i++) {
    c = 0;
    for(j = 0; j < m; j++)
      c += a[i][j] * b[j];
    printf("%d\n", c);
  }

  return 0;
}

  

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


// 数列dp：i番目の項は足場iへ行くために必要最低限のコスト
int h[100001];
int memo[100001];
int solve(int i, int k){
	if(i == 0) return 0;
	if(i == 1) return 0;
	if(memo[i] != -1) return memo[i];
	int m = INT_MAX;
	for(int d = 1; d <= k; d++){
		if(i - d < 0) break;
		m = min(solve(i-d, k)+abs(h[i]-h[i-d]), m);
	}
	return memo[i] = m;
}

// L_n = min(L_n-2 + |h_n-2 - h_n|, L_n-1 + |h_n-1 - h_n|)
// L_2 = |h_2|
// L_1 = 0
// (L_0 = 0)

int main(){

	int n, k;
	cin >> n >> k;
	/*
	int dp[100001];
	dp[0] = 0;
	dp[1] = 0;*/
	
	for(int i = 1; i <= n; i++){
		cin >> h[i];
		memo[i] = -1;
	}
	h[0] = h[1];

	/*for(int i = 2; i <= n; i++){
		dp[i] = min(
			dp[i-2] + abs(h[i] - h[i-2]),
			dp[i-1] + abs(h[i] - h[i-1]));
	}

	cout << dp[n];*/

	cout << solve(n, k) << endl;

    return 0;
}


Measured memory_bytes: 8832
H, W = map(int, input().split())

n_list = []
v_table = {}
for y in range(H):
	for x in range(W):
		n = (x, y)
		n_list.append(n)
		v_table[n] = []

prev = None
ns = None
for y in range(H):
	cur = input()
	for x in range(W):
		if cur[x] == ".":
			nc = (x, y)
			ns = nc
			if y > 0 and prev[x] == ".":
				np = (x, (y - 1))
				v_table[np].append(nc)
				v_table[nc].append(np)
			if x > 0 and cur[x - 1] == ".":
				np = (x - 1, y)
				v_table[np].append(nc)
				v_table[nc].append(np)
	prev = cur

def calc_dists(x, n_list, edges):
	dists = { x: 0 }
	queue = [ x ]
	
	while queue:
		cur = queue.pop(0)
		dist = dists[cur] + 1
		for v2 in edges[cur]:
			if (not v2 in dists) or (dists[v2] > dist):
				dists[v2] = dist
				queue.append(v2)
	
	return dists

max_dist = 0
for n in n_list:
	dists = calc_dists(n, n_list, v_table)
	for n2, dist in dists.items():
		if dist > max_dist:
			max_dist = dist
print(max_dist)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int D;
vector<int> C;
vector<vector<int>> S;

long long getTime() {
	timespec ts;
	clock_gettime(CLOCK_REALTIME_COARSE, &ts);
	long long r = ts.tv_sec;
	r *= 1000000000;
	r += ts.tv_nsec;
	return r;
}

ll calcScore(const vector<int>& T) {
	vector<int> last(26);
	ll score = 0;
	for (int d = 1; d <= D; ++ d) {
		int i = T[d-1];
		last[i] = d;
		score += S[d-1][i];
		for (int j = 0; j < 26; ++ j) {
			score -= C[j] * (d - last[j]);
		}
	}
	return score;
}

int main() {
	auto startTime = getTime();

	cin >> D;
	C.resize(26);
	for (auto& x : C) cin >> x;
	S = vector<vector<int>>(D, vector<int>(26));
	for (auto& x : S) for (auto& y : x) cin >> y;

	ll maxScore = -(1LL<<60);
	vector<int> ans;
	{
		vector<int> res(D);
		for (auto& x : res) x = rand() % 26;
		auto s = calcScore(res);
		if (s > maxScore) { maxScore = s; ans = res; }
		for (int tt = 0; ; ++ tt) {
			if (tt % 1024 == 0 && getTime() - startTime >= 1900000000) break;
			int i = rand() % D;
			int tmp = res[i];
			res[i] = rand() % 26;
			auto s1 = calcScore(res);
			if (s1 > s) { s = s1; }
			else { res[i] = tmp; }
			if (s1 > maxScore) { maxScore = s1; ans = res; }
		}
	}
	for (auto x : ans) cout << x + 1 << endl;
}


Measured memory_bytes: 3696
N, M = map(int, input().split())

p = [0] * N
p[0] = 1
ball = [1] * N

for i in range(M):
    x, y = map(int, input().split())
    
    if p[x-1] == 0:
        ball[x-1] -= 1
        ball[y-1] += 1
    elif p[x-1] == 1:
        if ball[x-1] == 1:
            p[x-1] = 0
            p[y-1] = 1
        else:
            p[y-1] = 1
        ball[x-1] -= 1
        ball[y-1] += 1

ans = 0
for i in range(N):
    if p[i] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 4596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();

		int makeNum = 0;
		int num = 0;

		while(makeNum < n){
			makeNum = makeNum + x;
			num = num + t;
		}

		System.out.println(num);

		sc.close();
	}
}

Measured memory_bytes: 35600
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			
			int N = sc.nextInt();
			int check = sc.nextInt();
			int tall = 0;
			long cnt = 0;
			
			
			for(int i=0;i<N-1;i++) {
				tall = sc.nextInt();
				if( tall<check) {
					cnt=cnt+(check-tall);
				}else {
					check=tall;
				}
			}
			
						
			System.out.println(cnt);
	}	
}

Measured memory_bytes: 58880
#include<bits/stdc++.h>
#define SWAP(type, A, B){type tmp = A; A = B; B = tmp;}
using namespace std;

long gcd(long A, long B){
    if(A < B) SWAP(long, A, B);
    if(B == 0) return A;
    return gcd(B, A%B);
}

int main(){
    int N;
    long A[100002];
    long ans;

    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    ans = gcd(A[0], A[1]);
    for(int i=2;i<N;i++) ans = gcd(ans, A[i]);
    cout << ans << endl;
    return 0;
}

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

int n,m;
pair<char, char> p[100];
char ch[100000];

int find_change(char *a) {
	for (int i = 0; i < n; i++) {
		if (p[i].first == *a) {
			*a = p[i].second;
			return 0;
		}
	}
	return 1;
}

int main(){

	while (cin >> n && n > 0) {
		for (int i = 0; i < n; i++) {
			cin >> p[i].first >> p[i].second;
		}
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> ch[i];
			find_change(ch + i);
		}
		for (int i = 0; i < m; i++)
			cout << ch[i];
		cout << endl;
	}
	return 0;
}

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;

    long long n;
    cin>>n;

    vector<long long> arr;
    vector<long long> count(n+1);

    for(int i=0;i<n;i++) {
        long long num;
        cin>>num;

        arr.push_back(num);
        count[num]++;
    }

    long long total=0;
    for(int i=1;i<=n;i++) {
        if(count[i]!=0) {
            total+=(count[i]*(count[i]-1))/2;
        }
    }

    for(int i=0;i<n;i++) {
        if(arr[i]!=0) {
            cout<<total-(count[arr[i]]-1)<<endl;
        }
    }





    
}


Measured memory_bytes: 6880
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    if a == b && a == 1 {
        println!("Draw");
    } else if a == 1 {
        println!("Alice");
    } else if b == 1 {
        println!("Bob");
    } else if a > b {
        println!("Alice");
    } else if a < b {
        println!("Bob");
    } else {
        println!("Draw");
    }
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
int cnt = 0, n;
int A[500000];

int merge(int f, int l);

int main() {
	cin >> n;
	REP(i, n) cin >> A[i];
	merge(0, n - 1);
	cout << A[0];
	REP(i,n-1) cout << " " << A[i+1];
	cout << endl << cnt << endl;
}

int merge(int f, int l) {
	if (f == l)return 0;
	int mid = (f + l) / 2;
	merge(f, mid);merge(mid + 1, l);
	int lptr = f, rptr = mid + 1;
	int  i = 0;
	vector<int> B;
	while (lptr != mid + 1 || rptr != l+1) {
		if (lptr != mid + 1 && rptr != l + 1) {
			if (A[lptr] > A[rptr]) {
				B.push_back(A[rptr]);
				rptr++;
			}
			else {
				B.push_back(A[lptr]);
				lptr++;
			}
		}
		else if (lptr == mid + 1) {
			B.push_back(A[rptr]);
			rptr++;
		}
		else {
			B.push_back(A[lptr]);
			lptr++;
		}
		cnt++;
	}
	for (int i = f;i <= l;i++) A[i] = B[i-f];
	return 0;
}

Measured memory_bytes: 7812
#include <bits/stdc++.h>
#define ONE_DIGIT(x) 0 < x && x < 10
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if ( ONE_DIGIT(a) && ONE_DIGIT(b) ) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    LL k;cin>>k;

    VL a(n);
    REP(i,n){
        cin>>a[i];
        a[i]--;
    }
    VL c(n,INF);
    int result=0;
    int now = 0;
    int dist = 0;

    while(true){


        if(c[now] == INF){
            c[now] = dist;
        }
        else{
            k%=(dist-c[now]);
        }

        if(k==0){
            result = now;
            break;
        }
        k--;
        now = a[now];
        dist++;
    }

    cout<<result+1<<endl;




	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 6368
from fractions import gcd

N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]
def lcm(a, b):
    g = gcd(a, b)
    return a * b // g

for i in range(1, N):
    ans = lcm(ans, T[i])
print(ans)


Measured memory_bytes: 5560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <deque>
using namespace std;
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
#define ford(i,a,b) for(int i=(a);i>=(b);--i)
#define min(x,y) ((x) < (y) ? (x) : (y))
#define max(x,y) ((x) < (y) ? (y) : (x))
#define swap(x,y) ((x)^=(y),(y)^=(x),(x)^=(y))
#define abs(x) ((x) < 0 ? -(x) : (x)) 
const int maxn=1e6+7;
typedef long long ll;
const int inf=1<<25;
int read(){
    int s=0,f=1;
    char c=getchar();
    while(c<'0' || c>'9') {if(c=='-') f=-1; c=getchar();}
    while(c>='0' && c<='9') {s=s*10+c-48;c=getchar();}
    return s*f;
}
void write(int x){
    if(x<0) {putchar('-');x=-x;}
    if(x>9) write(x/10);
    putchar(x%10+48);
}
const int N = 1e3 + 5;
 
int a[N], b[N];
int n, m, c, flag;
char s[45];
 
 
int main(){
 
    scanf("%d", &n);
    c = 0;
 
    fors(i, 1, n){
        scanf("%d%d", a + i, b + i);
        if ((a[i] + b[i]) & 1) ++c;
        else --c;
    }
 
    if (abs(c) != n) return 0 * puts("-1");
 
    m = 31 + (c < 0);
 
    printf("%d\n", m);
    fors(i, 0, 30) printf("%d ", 1 << i);
    if (c < 0) putchar(49);
    putchar(10);
 
    fors(i, 1, n){
        int x = a[i], y = b[i];
        if (c < 0) s[31] = 'R', --x;
        flag = 0;
        ford(j, 30, 0){
            if (abs(x) < abs(y)) swap(x, y), flag ^= 1;
            if (x > 0) x -= 1 << j, s[j] = flag ? 'U' : 'R';
            else x += 1 << j, s[j] = flag ? 'D' : 'L';
        }
 
        puts(s);
    }
 
    return 0;
}
 

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

int main(){
    string s;
    cin >> s;
    bool ans = true;
    
    if(s.at(2)!=s.at(3))
        ans =!ans;
    else if(s.at(4)!= s.at(5))
        ans =!ans;
    
    if(ans)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
}


Measured memory_bytes: 256
/*
بسم الله الرحمن الرحيم
اللہ کے نام سے شروع جو بڑا مہربان اور نہایت رحم والا ہے
Allah in the name of The Most Affectionate, the Merciful
अल्लाह के नाम से जो दयालु और कृपाशील है

							|		MD BAHAUDDIN aka Mujahid	|
							|			NIT JAMSHEDPUR			|	
							|		linkedin.com/in/bahau/		|
*/

//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<stack>
#include<queue>
#include<cstring>
#include<ctime>

using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ull unsigned ll
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(t,val) memset(t,val,sizeof(t));
#define f first
#define s second
#define FOR(i,k,n) for(int i=k; i<n; i++)
#define ROF(i,k,n) for(int i=k; i>=n; i--)
#define endl '\n'
#define mod (1000*1000*1000+7) 


ll poww(ll x, ll n)
{
	ll ans=1;
	// while(n>0)
	// {
	// 	if(n%2==0)
	// 	{
	// 		x=x*x%mod; n=n/2;
	// 	}
	// 	else{
	// 		ans=ans*x%mod; n--;
	// 	}
	// }
	// return ans%mod;
	for(int i=1; i<=n; i++)
	{
		ans=ans*x%mod;
	}
	return ans;
}
ll f(ll n)
{
	ll ten = poww(10,n)%mod;
	ll nin = poww(9,n)%mod;
	ll eig = poww(8,n)%mod;
	return (( ((((ten-nin)%mod+mod)%mod-nin)%mod+mod)%mod+eig)%mod+mod)%mod;
}

int main()
{
	fastio;

	#ifndef ONLINE_JUDGE
	// input from input.txt
	freopen("input.txt", "r", stdin);
	// output to output.cpp
	freopen("output.cpp", "w", stdout);
	#endif

	int t=1; //cin>>t;
	while(t--)
	{
		ll n; cin>>n;

		cout<<f(n);

	}
	return 0;
} 







Measured memory_bytes: 3640
a, b, c = gets.split.map(&:to_i)
sorted_abc = [a, b, c].sort
count = 0
max = sorted_abc.last
min = sorted_abc.first
count += max - sorted_abc[1]
min += count
diff = max - min
if diff % 2 == 0
  count += diff / 2
else
  count += (diff + 1) / 2 + 1
end
puts count


Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

int main() {
  int a,b;
  cin>>a>>b;

  cout<<a*b<<endl;
  
  
  
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
	char str1[100];
	int length, i;
	scanf("%d %d", &length, &i);
		getchar();
	scanf("%s", str1);
	str1[i-1] = str1[i-1] + 32;
	printf("%s", str1);
	
	return 0;
}

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

const int N = 3005;
int n;
vector<ll> arr;
ll cache[N][N];

ll dp(int i, int j){
	if( i >= n or j >= n ){ return 0; }
	if( i < 0 or j < 0 ){ return 0; }
	if( i == j ){
		cache[i][j] = arr[i];
		return arr[i];
	}
	ll &ans = cache[i][j];
	if( ans != -1 ){ return ans; }
	ans = max( arr[i] - dp(i+1,j), arr[j] - dp(i,j-1));
	return ans;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>n;
	arr.resize(n);
	for(int i=0; i<n; ++i){
		cin>>arr[i];
	}
	memset(cache,-1,sizeof(cache));
	ll ans = dp(0,n-1);
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 70912
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sum = 0;
    for(int i = 0;i < N;i++){
      int a = sc.nextInt();
      sum += a;
    }
    System.out.println(sum-N);
  }
}


Measured memory_bytes: 27480
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,m,c[200010][2];
string s;
vector<int> G[200010];
queue<int> que;
bool erased[200010];

void solve(){
  cin >> n >> m;
  cin >> s;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    if (s[b]=='A') c[a][0]+=1;
    else c[a][1]+=1;
    G[b].push_back(a);
    if (s[a]=='A') c[b][0]+=1;
    else c[b][1]+=1;
  }
  rep(i,n){
    if (c[i][0]==0 || c[i][1]==0) {
      que.push(i);
      erased[i]=true;
    }
  }
  while(!que.empty()){
    int t=que.front();que.pop();
    int co;
    if (s[t]=='A') co=0;
    else co=1;
    for(int l:G[t]){
      c[l][co]-=1;
      if (c[l][co]==0 && !erased[l]) {
        que.push(l);
        erased[l]=true;
      }
    }
  }
  rep(i,n){
    if (!erased[i]) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

int main () {
	int n;
	int k;
	cin >> n >> k;
	bool flag[n + 1];
	for(int i = 0; i <= n; i++) flag[i] = false;
	for(int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for(int j = 0; j < d; j++) {
			int cur;
			cin >> cur;
			flag[cur] = true;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if(flag[i] == false) ans += 1;
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

int main(void) {

  int N;
  cin >> N;
  int X, T;
  cin >> X >> T;

  int count = 0;
  int min = 0;
  while (X * count < N) {
    count++;
    min += T;
  }
  cout << min << endl;  

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc168/abc168_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string N;
  cin >> N;

  char last = N[N.size() - 1];
  string ans;
  if (last == '2' || last == '4' || last == '5' || last == '7' || last == '9') {
    ans = "hon";
  } else if (last == '0' || last == '1' || last == '6' || last == '8') {
    ans = "pon";
  } else if (last == '3') {
    ans = "bon";
  }

  cout << ans << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

struct abc {ll a, b, c;};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, ma, mb;
  cin >> N  >> ma >> mb;
  vector<abc> med(N);
  for (ll i = 0; i < N; ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    med.at(i) = {a, b, c};
  }
  vector<vector<ll>> dp(401, vector<ll>(401, INF));
  dp.at(0).at(0) = 0;
  for (ll i = 0; i < N; ++i) {
    vector<vector<ll>> temp = dp;
    ll a = med.at(i).a, b = med.at(i).b, c = med.at(i).c;
    for (ll j = 0; j + a < 401; ++j) {
      for (ll k = 0; k + b < 401; ++k) {
        if (dp.at(j).at(k) == INF) {
          continue;
        }
        temp.at(j + a).at(k + b) = min(dp.at(j).at(k) + c, dp.at(j + a).at(k + b));
      }
    }
    dp = temp;
  }
  ll ans = INF;
  for (ll i = 1; i < 401; ++i) {
    for (ll j = 1; j < 401; ++j) {
      if (i * mb == j * ma) {
        ans = min(ans, dp.at(i).at(j));
      }
    }
  }
  if (ans == INF) {
    cout << -1 << "\n";
  }
  else {
    cout << ans << "\n";
  }
}


Measured memory_bytes: 5848
while True:
    H,W= list(map(int, input().split()))
    if H == 0 and W == 0:
        break
    x = "#" * W
    y = "#" + "." * (W-2) + "#"
    print(x)
    for i in range(H-2):
        print(y)
    print(x)
    print()


Measured memory_bytes: 5608
a,b,c,d = list(map(int,input()))

for i in range(2):
    for j in range(2):
        for k in range(2):
            if i%2==0 and j%2==0 and k%2==0:
                ans = a+b+c+d
                ans_s = f"{a}+{b}+{c}+{d}"
            elif i%2==0 and j%2==0 and k%2==1:
                ans = a+b+c-d
                ans_s = f"{a}+{b}+{c}-{d}"
            elif i%2== 0 and j%2==1 and k%2==1:
                ans = a+b-c-d
                ans_s = f"{a}+{b}-{c}-{d}"
            elif i%2== 1 and j%2==1 and k%2==1:
                ans = a-b-c-d
                ans_s = f"{a}-{b}-{c}-{d}"
            elif i%2==1 and j%2==1 and k%2==0:
                ans = a-b-c+d
                ans_s = f"{a}-{b}-{c}+{d}"
            elif i%2==1 and j%2==0 and k%2==0:
                ans = a-b+c+d
                ans_s = f"{a}-{b}+{c}+{d}"
            elif i%2==1 and j%2==0 and k%2==1:
                ans = a+b-c+d
                ans_s = f"{a}+{b}-{c}+{d}"
            else:
                ans = a-b+c-d
                ans_s = f"{a}-{b}+{c}-{d}"
            
            if ans == 7:
                print(ans_s+"=7")
                exit()


Measured memory_bytes: 61376
from math import *

def isprime(n):
	if n<10:
		return n in (2,3,5,7)
	for i in range(2,int(sqrt(n)+1)):
		if n%i==0:
			return False
	return True
 
x = int(input())
for d in range(x,x+300):
	if isprime(d):
		print(d)
		break


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <map>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    int b[100001] ={};
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        b[a[i]] += 1;
    }
    int sum = 0;
    for(int i = 0; i < 99999; i++) {
        sum = max(sum,b[i]+b[i+1]+b[i+2]);
    }
    cout << sum;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {

	long long  a, b;
	cin >> a >> b;
	long long gcd = 0,seki = a * b;

	for (int i = 1; i <= max(a, b); i++) {
		if (a % i == 0 && b % i == 0 && i > gcd) {
			gcd = i;
		}
	}
	//cout << gcd << " " << seki << endl;
	cout << seki / gcd << endl;

	return 0;
}

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

using namespace std;

constexpr int MAX_N = 100000;
vector<int> pre_order(MAX_N, -1);//pre_order[i]:=??±???????????¢?´¢??§???????????????i????????£?????¨??????timer
vector<int> post_order(MAX_N, -1);//post_order[i]:=??±???????????¢?´¢??§???????????????i????????£?????¨??????timer
vector<int> parent(MAX_N, -1);//parent[i]:=??±???????????¢?´¢??§??¨????§????????????¨???????????????i??????
vector<bool> visited(MAX_N, false);//??±???????????¢?´¢???????????§????¨?????????????????????°???????´?????????????

vector<vector<int>> G(MAX_N);

void add_edge(int s, int t) {
	G[s].emplace_back(t);
	G[t].emplace_back(s);
}

void dfs(const vector<vector<int>>& G, int u = 0, int prev_u = -1, int timer = 1) {
	pre_order[u] = timer;
	post_order[u] = timer;
	++timer;

	//u????¨????????????¨????????¢
	visited[u] = true;
	

	for (int i = 0; i < G[u].size(); ++i) {

		int v = G[u][i];

		//u?????£??\??????????????????v == G[u][i] ???????¨?
		if (!visited[v]) {

			//v?????????u??§?¢??????????
			parent[v] = u;

			//v??\????????±???????????¢?´¢????????????
			dfs(G, v, u, timer);

			//u???post_order?????´??°??????
			post_order[u] = min(post_order[u], post_order[v]);
		}

		//u?????£??\??????????????????v?????¢?¨?????????¢?´¢??§??´????????§????????£??????????????¨?????????
		else if (v != prev_u) {
			post_order[u] = min(post_order[u], pre_order[v]);
		}
	}
}

vector<int> articulation_points(const vector<vector<int>>& G, int G_sz, int root = 0) {
	dfs(G,root);
	vector<int> ans;
	vector<bool> used(G_sz, false);
	int root_child = 0;
	for (int j = 0; j < G_sz; ++j) {
	        if (parent[j] == root)++root_child;
	        if (root_child == 2) {
			ans.emplace_back(root);
			break;
		}
	}
	for (int i = 1; i < G_sz; ++i) {
		if (parent[i] != root
				&&pre_order[parent[i]] <= post_order[i]
				&& !used[parent[i]]) {

			ans.emplace_back(parent[i]);
			used[parent[i]] = true;
		}
	}
	sort(ans.begin(), ans.end());
	return ans;
}

int main()
{
	int N, E;
	cin >> N >> E;
	int s, t;

	for (int i = 0; i < E; ++i) {
		cin >> s >> t;
		add_edge(s, t);
	}
	vector<int>ans = articulation_points(G, N);
	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << endl;
	}
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#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 FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    REP(i, b){
        cout << a;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
l=input().split()
x=int(l[0])
k=int(l[1])
d=int(l[2])
x=abs(x)
l=[]
l.append(abs(x-k*(d)))
z=x-(k*d)
if(z<0):
    rem=(z%(2*d))
    l.append(rem)
    l.append(2*d-rem)
print(min(l))


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

int n;
int ar[50];
double ans;

int main() {
	cin >> n;
	for( int i = 0 ; i < n ; i++ )
		cin >> ar[i];
	sort( ar , ar+n );
	ans = ar[0];
	for( int i = 1 ; i < n ; i++ )
		ans = ( ans + ar[i] ) / 2.0;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
set <int> st;
int n;
int a[100005];
int main(int argc,char const* argv[])
{
  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
      auto r=st.insert(a[i]);
      if(r.second==false)
	{
	  st.erase(a[i]);
	}
    }
  cout << st.size() << endl;
  return 0;
}


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

using namespace std;

class Team {
public:
	int id;
	int time;
};

Team TeamData[10000];

bool cmp(const Team& t1, const Team& t2) {
	return t1.time < t2.time;
}

int main(void) {
	int n, m, s, sum;

	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> TeamData[i].id;
			sum = 0;
			for (int j = 0; j < 4; j++) {
				cin >> m >> s;
				sum += m * 60 + s;
			}
			TeamData[i].time = sum;
		}

		sort(TeamData, TeamData + n,cmp);
		cout << TeamData[0].id << endl << TeamData[1].id << endl << TeamData[n - 2].id << endl;
	}

	return 0;
}


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

int main(){
  int n,count=0;
  cin >> n;
  vector<int> v(n);
  r(i,n){
    cin >> v.at(i);
    if(*max_element(v.begin(),v.begin()+i)<=v.at(i))count++;
  }
  cout << count << endl;
}

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

long long N, D, x[100009], y[100009], p[1009][1009], tabl[1000009], score[1009][1009], r[3][2009][2009], maxn = 0, ans = 1000000007;

long long ranged(int ty, int px, int py, int qx, int qy) {
	return r[ty][px][py] + r[ty][qx][qy] - r[ty][px][qy] - r[ty][qx][py];
}

bool solve(long long px, long long py, long long border) {
	border++;
	long long A1 = border / D, A2 = border % D;

	long long D1 = (maxn - 2);
	for (int i = 0; i < 3; i++) {
		long long p1 = ranged(i, px, py, px + A2, py + A2);
		if (p1 > 0) { D1 = maxn - i; break; }
	}
	long long D2 = (maxn - 2);
	for (int i = 0; i < 3; i++) {
		long long p1 = ranged(i, px + A2, py, px + D, py + A2);
		if (p1 > 0) { D2 = maxn - i; break; }
	}
	long long D3 = (maxn - 2);
	for (int i = 0; i < 3; i++) {
		long long p1 = ranged(i, px, py + A2, px + A2, py + D);
		if (p1 > 0) { D3 = maxn - i; break; }
	}
	long long D4 = (maxn - 2);
	for (int i = 0; i < 3; i++) {
		long long p1 = ranged(i, px + A2, py + A2, px + D, py + D);
		if (p1 > 0) { D4 = maxn - i; break; }
	}

	bool flag = true;
	if (D1 > 2LL * A1 + 2LL) flag = false;
	if (D2 > 2LL * A1 + 1LL) flag = false;
	if (D3 > 2LL * A1 + 1LL) flag = false;
	if (D4 > 2LL * A1 + 0LL) flag = false;
	return flag;
}

int main() {
	cin >> N >> D;
	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> y[i];
		p[x[i] % D][y[i] % D]++;
	}
	for (int i = 0; i <= 500; i++) {
		for (int j = i * i + 1; j <= i * (i + 1); j++) tabl[j] = i * 2 + 1;
		for (int j = i * (i + 1) + 1; j <= (i + 1)*(i + 1); j++) tabl[j] = i * 2 + 2;
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < D; j++) { score[i][j] = tabl[p[i][j]]; maxn = max(maxn, score[i][j]); }
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < D; j++) {
			if (maxn - 2 <= score[i][j]) {
				r[maxn - score[i][j]][i + 1][j + 1]++;
				r[maxn - score[i][j]][i + D + 1][j + 1]++;
				r[maxn - score[i][j]][i + 1][j + D + 1]++;
				r[maxn - score[i][j]][i + D + 1][j + D + 1]++;
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j <= 2 * D + 1; j++) {
			for (int k = 1; k <= 2 * D + 1; k++) r[i][j][k] += r[i][j][k - 1];
		}
		for (int j = 1; j <= 2 * D + 1; j++) {
			for (int k = 0; k <= 2 * D + 1; k++) r[i][j][k] += r[i][j - 1][k];
		}
	}

	// ------------------ 探索フェーズ -----------------------
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < D; j++) {
			long long L = 0, R = 350000, M, minx = (1LL << 30);
			for (int k = 0; k < 22; k++) {
				M = (L + R) / 2;
				bool I = solve(i, j, M);
				if (I == true) { minx = min(minx, M); R = M; }
				else { L = M; }
			}
			ans = min(ans, minx);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 118016
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	double x1, y1, x2, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	printf("%lf\n", sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)));
	return 0;
}

Measured memory_bytes: 3176