akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final int[] X = new int[n];
        
        for (int i = 0; i < n; i++) {
            X[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(X);
        int sum = 0, min = 0;
        for (int j = 0; j < n; j++) {
            min += Math.pow(X[0] - X[j],2);
        }
        for (int i = X[0] + 1; i < X[n-1]; i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        }
        System.out.println(min);
    }
}

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

#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define endl "\n"
#define int long long
#define pii pair<int, int>
#define piii pair<int, pair<int, int>>
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define deb(x) cout << #x << " = " << x << endl
#define all(x) x.begin(), x.end()
#define MAX 1000000000000000001
#define MAXN 1000000
#define mod 1000000007
#define PI 3.1415926535897932384626

int mod_exp(int x, int y);

//ofstream fout("file.out");
//ifstream fin("file.in");

void solve(){
    int ans;
    vector<int> a(6);
    for(int i = 1; i < 6; ++i){
        cin >> a[i];
        if(a[i] == 0) ans = i;
    }
    cout << ans << endl;
}

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

int mod_exp(int x, int y){
    y %= mod;
    int res = 1;
    while(y > 0){
        if(y % 2 != 0) res = (res * x) % mod;
        x = (x * x) % mod;
        y /= 2;
    }
    return res;
}


Measured memory_bytes: 3648
N = int(input())
A = [int(a) for a in input().split()]

def main():
    count = 0
    nums = A
    end = False
    while not end:
        for i in range(N):
            dm = divmod(nums[i], 2)
            if dm[1] != 0: # dm[1] is remainder
                end = True
                break
            nums[i] = dm[0] # dm[0] is quotient
        else:
            count += 1
    print(count)

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using T = tuple<int64_t,int64_t,int64_t>;

//UnionFind
int n = 100000;
vector<int> par(n);
vector<int> size(n);

void init(int n){
  for(int i=0; i<n; i++){
    par.at(i) = i;
    size.at(i) = 1;
  }
}

int root(int x){
  if(par.at(x) == x){
    return x;
  }
  else{
    return par.at(x) = root(par.at(x));
  }
}

bool same(int x, int y){
  return root(x) == root(y);
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y){
    return;
  }
  if (size.at(x) < size.at(y)){
    swap(x, y);
  }
  size.at(x) += size.at(y);
  par.at(y) = x;
}

int size_x(int x){
  return size.at(root(x));
}


//Kruskal
const int MAX_E = 500000; //最大の辺の数

struct edge{
  int64_t from;
  int64_t to;
  int64_t cost;
};

bool compare(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}

edge G[MAX_E];
int V, E;

int Kruskal(){
  sort(G, G+E, compare);
  init(V);
  int res = 0;
  for(int i=0; i<E; i++){
    edge e = G[i];
    //cout << e.from << " " << e.to << " " << e.cost << endl;
    if(!same(e.from, e.to)){
      unite(e.from, e.to);
      res += e.cost;
    }
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  V = N;
  E = (V-1)*2*2;
  vector<T> vec(N);
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    T p = make_tuple(a,b,i);
    vec[i] = p;
  }
  
  int cnt = 0;
  
  sort(vec.begin(),vec.end());
  
  for(int i=0; i<N-1; i++){
    T p = vec[i];
    T q = vec[i+1];
    edge add;
    add.to = get<2>(p);
    add.from = get<2>(q);
    add.cost = abs(get<0>(p) - get<0>(q));
    G[cnt] = add;
    cnt++;
    swap(add.to, add.from);   
    G[cnt] = add;
    cnt++;
  }
  
  for(int i=0; i<N; i++){
    T p = vec[i];
    T q = make_tuple(get<1>(vec[i]), get<0>(vec[i]), get<2>(vec[i]));
    vec[i] = q;
  }
  
  sort(vec.begin(),vec.end());
  
  for(int i=0; i<N-1; i++){
    T p = vec[i];
    T q = vec[i+1];
    edge add;
    add.to = get<2>(p);
    add.from = get<2>(q);
    add.cost = abs(get<0>(p) - get<0>(q));
    G[cnt] = add;
    cnt++;
    swap(add.to, add.from);
    G[cnt] = add;
    cnt++;
  }
  
  cout << Kruskal() << endl;
  
  
}
    
  

Measured memory_bytes: 13568
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> A(n);
    rep(i,n)cin >> A[i];
    sort(ALL(A));
    vector< pair<int, int>> V(m, make_pair(0,0));
    rep(i,m) cin >> V[i].second >> V[i].first;
    sort(ALL(V));
    reverse(ALL(V));

    vector<int> B(n);
    int idx = 0;
    for(int i=0; i<n; i++){
        if(idx >= m){
                B[i]=A[i];
                continue;
            }
        if(V[idx].second > 0){
            if(V[idx].first> A[i]){
                B[i] = V[idx].first;
                V[idx].second--;
            }
            else{
                B[i] = A[i];
            }
        }
        else{
            idx++;
            if(idx >= m){
                B[i]=A[i];
                continue;
            }
            if(V[idx].first> A[i]){
                B[i] = V[idx].first;
                V[idx].second--;
            }
            else{
                B[i] = A[i];
            }
        }
        // rep(i,n) cout << B[i]<<" "; cout << endl;
    }
    ll ans=0LL;
    rep(i,n) ans+=B[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
  	ll n, k;
  	cin >> n >> k;
  	vector<ll> vec;
  	while (n --) {
  		ll x;
  		cin >> x;
  		vec.pb(x);
	  }
	sort(all(vec));
	ll s = 0;
	for (auto u : vec) {
		if (!k) break;
		s += u;
		k --;
	}
	cout << s;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")
mod = 1000000007
inf = float('INF')
fact = [i for i in range(5 * 10 ** 5 + 1)]
fact[0] = 1
for i in range(5 * 10 ** 5):
    fact[i + 1] *= fact[i]
    fact[i + 1] %= mod
invfact = fact[:]
invfact[-1] = pow(invfact[-1], mod - 2, mod)
for i in range(5 * 10 ** 5, 0, -1):
    invfact[i - 1] = i * invfact[i]
    invfact[i - 1] %= mod

def combination_mod(n, k, mod=mod):
    """ power_funcを用いて(nCk) mod p を求める """ 
    """ nCk = n!/((n-k)!k!)を使用 """
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = fact[n]
    b = invfact[k]
    c = invfact[n - k]
    return (a * b * c) % mod

def nPk(a, b):
    return (fact[a] * invfact[a - b]) % mod

#solve
def solve():
    n, m = LI()
    ans = 0
    a = 1
    for i in range(n + 1):
        ans += nPk(m, i) * nPk(m - i, n - i) * nPk(m - i, n - i) * a * combination_mod(n, i) % mod
        ans %= mod 
        a *= - 1
    print(ans)
            
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 119124
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <ctype.h>

int main(void)
{

	char a;
	
	scanf("%c", &a);

	if (a >= 'A' && a <= 'Z') {
		a = 'A';
	}
	else if (a <= 'z' && a >= 'a') {
		a = 'a';
	}


	printf("%c", a);


	return 0;
}

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

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

    int64_t N;
    cin >> N;
    if (N % 2 != 0) {
        cout << 0 << endl;
    } else {
        int64_t ret = 0;
        int64_t div_n = 10;
        while (div_n <= N) {
            ret += N / div_n;
            div_n *= 5;
        }
        cout << ret << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>

int main() {
    int N, now = 1e9, ans = 0, a;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &a);
        if (a <= now) ++ans, now = a;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<vector<ll>> graph(n);
    for(int i = 0; i < n-1; i++) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    ll ans = 0;
    rep(i,0,n){
        ans += (i + 1) * (n - i);
        for(auto &t : graph[i]){
            if(t < i)continue;
            ll ii = i, jj = t;
            ans -= (ii + 1) * (n - jj);
        }
    }

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

Measured memory_bytes: 15792
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

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


int main(){
    int n, c; cin >> n >> c;
    vector<vector<int>> imos(30, vector<int>(100001));
    rep(i, 30)rep(j, 100001) imos[i][j] = 0;
    rep(i, n){
        int d, e, f; cin >> d >> e >> f;
        d--, f--;
        imos[f][d]++, imos[f][e]--;
    }
    
    rep(i, c)_rep(j, 1, 100001) imos[i][j] += imos[i][j - 1];
    rep(i, c)rep(j, 100001){
        if(imos[i][j] > 0) imos[i][j] = 1;
    }

    int ans = 0;
    rep(i, 100001){
        int count = 0;
        rep(j, c){
            count += imos[j][i];
        }
        ans = max(count, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
	}
	sort(a,a+3);
	if(a[0]+a[1] == a[2])
	cout<<"Yes";
	else
	cout<<"No";
return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  
  vector<string> vec(h);
  for(int i=0; i<(h); i++){
    cin >> vec[i];
  }
  
  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(vec[i][j] == '#'){
        row[i] = true;
        col[j] = true;
      }
    }
  }
  
  for(int i=0; i<h; i++){
    if(row[i]){
      for(int j=0; j<w; j++){
        if(col[j]){
          cout << vec[i][j];
        }
      } 
      cout << endl;
    }
  }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int N;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);
    rep(i,N){
        cin >> s[i] >> t[i];
    }
    string X;
    cin >> X;
    int p = 0;
    rep(i,N){
        if(X==s[i]){
            p = i;
            break;
        }
    }
    int ans = 0;
    for(int i=p+1;i<N;i++)ans += t[i];
    cout << ans << endl;
}

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

x,a,b = [int(i) for i in input().split()]

'''
print('x', x)
print('a', a)
print('b', b)
'''

if( -a+b <= 0 ):
  print('delicious')
elif( -a+b > 0 and -a+b <= x ):
  print('safe')
else:
  print('dangerous')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string s;
int ans=0;
int main(){
cin>>s;
int j=s.size()-1;
for(int  k=0;k<s.size();k++){
   if(s[k]!=s[j])
    ans++;
   s[k]=s[j];
   j--;
}
cout<<ans;
return 0;
}


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


int main(){

    int n,m,l;
    scanf(" %d %d %d",&n,&m,&l);
    int A[n][m],B[m][l];
    long int Ans[n][l];

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            Ans[i][j]=0;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf(" %d",&A[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            scanf(" %d",&B[i][j]);
        }
    }

    for(int i =0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                Ans[i][j] += A[i][k]*B[k][j];
            }
        }
    }

    for(int i =0;i<n;i++){
        for(int j=0;j<l;j++){
            printf("%ld",Ans[i][j]);
            if(j != l-1){
                printf(" ");
            }
        }
        printf("\n");
    }
    

    return 0;
}



Measured memory_bytes: 2860
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 10000000000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define MAXN 500003
typedef long long ll;

using namespace std;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}




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

vector<pair<ll, ll> >v;
 ll sum=0,act=0,k,n,q,f;
 ll w;
cin>>n>>w;
v.reserve(n);
forr(i,0,n)
    {
        ll a,b;
        cin>>a>>b;
        v.pb(mp(a,b));
      
    }
    ll dp[n+1][w+1];
    forr(i,0,n+1)
    {
        forr(j,0,w+1)
        {
         if(i==0 || j==0)
         {
             dp[i][j]=0;
         }
         else if(j<v[i-1].first)
         {
          dp[i][j]=dp[i-1][j];   
         }
         else
         {
             dp[i][j]=max(v[i-1].second+dp[i-1][j-v[i-1].first],dp[i-1][j]);
         }
           // cout<<dp[i][j]<<" ";
        }
       // cout<<endl;
    }
    cout<<dp[n][w]<<endl;

return 0;
}


Measured memory_bytes: 79232
k, n = map(int, input().split())
a = list(map(int, input().split()))
ans = k
b = a[0] + (k-a[-1])
for i, v in enumerate(a):
    x = 0
    if i == 0:
        x = max(abs(a[i+1]-v), b)
    elif i == len(a)-1:
        x = max(b, abs(v-a[i-1]))
    else:
        x = max(abs(a[i+1]-v), abs(v-a[i-1]))
    ans = min(ans, k-x)
print(ans)

Measured memory_bytes: 26444
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[345678], aa[345678][2];
signed main() {
	int n, m, k, a, b, c, d, cnt = 0, ans = 0; string s, t; 
	cin >> n >> m;
	for (int h = 0; h < m; h++) {
		cin >> a; n -= a;
	}
	if (n < 0) { cout << -1 << endl; }
	else { cout << n << endl; }
	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	string s;
  	cin >> s;
  	vector <int>v(26);
  	for (int i = 0; i <(int)s.size() ; ++i)
  	{
  		v[s[i]-'a']++;
  	}
  	for (int i = 0; i < 26; ++i)
  	{
  		if(v[i] != 0)
  			if (v[i]%2 == 1)
  			{
  				cout << "No\n";
  				return 0;
  			}
  	}
  	cout << "Yes\n";
  	return 0;
}	

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
const long long LLINF = 1LL << 62;
const int INF = 1LL << 30;
using namespace std;

int main(void) {
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	printf("%.10lf ",W * H / 2);
	
	if (W/2 == x and H/2 == y) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
/*
 Author : Alokit Kumar
  */
 #include<bits/stdc++.h>
 using namespace std;
 #define int long long
 
 int32_t main()
 {
   int t,n,i,j,k,l=0;
   cin>>n;
   string s;int a[6];memset(a,0,sizeof(a));
   for(i=1;i<=n;i++)
   {
     cin>>s;
     if(s[0]=='M')
      a[1]++;
     else if(s[0]=='A') a[2]++;
     else if(s[0]=='R') a[3]++;
     else if(s[0]=='C') a[4]++;
     else if(s[0]=='H') a[5]++;
   }
   for(i=1;i<=3;i++)
   {
     for(j=i+1;j<=4;j++)
     {
       for(k=j+1;k<=5;k++)
        l+=a[i]*a[j]*a[k];
     }
   }
   cout<<l;
 }

Measured memory_bytes: 3632
package main


import (
    "fmt"
)

func main() {
    var N,a,b,c,d int32
    fmt.Scan(&N)

    a = N/1000
    b = N%1000/100
    c = N%1000%100/10
    d = N%1000%100%10

    if a == b && b == c || b == c && c == d {
      fmt.Println("Yes")
    } else {
      fmt.Println("No")
    }

}


Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <map>

#define ll long long int
using namespace std;

int main() {
  int n;
  cin >> n;
  ll a[200005];
  ll sums[200005];
  map<ll, int> seen;
  cin >> a[0];
  sums[0] = a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    sums[i] = sums[i - 1] + a[i];
  }
  seen[0] = 1;
  ll count = 0;
  for (int i = 0; i < n; i++) {
    count += seen[sums[i]];
    seen[sums[i]]++;
  }
  cout << count;
}


Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
using namespace std;
int a[1000000],n;
int binarysearch(int key)
{
  int left = 0;
  int right = n;
  while (left < right)
  {
    int mid = (left+right)/2;
    if(a[mid] == key)
      return 1;
    if(a[mid]<key) left = mid+1;
    else if(key<a[mid]) right = mid;
  }
   return 0 ;
}
int main (){
  int i,q,k,sum = 0;
  scanf("%d",&n);
  for(int i =0;i<n;i++)
    scanf("%d",&a[i]);
  scanf("%d",&q);
  for(int i = 0;i<q;i++)
  {
    scanf("%d",&k);
    if(binarysearch(k))
    sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 3588
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	REP(i, n-k) ans += a[i];
	cout << ans << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
#define input(X) getline(cin,X)
// static const int INF = 1e+9+7;
// static const ll INFL = 1e+18+7;
ll n,m,l;
int p;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

static const int MAX = 10000;
int V;
vector<int> graph[MAX];
int match[MAX];
bool used[MAX];
bool use_a[MAX];
bool use_b[MAX];

void add_edge(int u,int v){
  graph[u].push_back(v);
  graph[v].push_back(u);
}

bool dfs(int v){
  used[v] = true;
  for(int i = 0;i < graph[v].size();i++){
    int u = graph[v][i] , w = match[u];
    if(w < 0 || (!used[w] && dfs(w))){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int v = 0;v < V;v++){
    if(match[v] < 0){
      memset(used,0,sizeof(used));
      if(dfs(v)){
        res++;
      }
    }
  }
  return res;
}

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

void init(){
  rep(i,0,MAX){
    graph[i].clear();
  }
  clr(match,0);
  clr(used,0);
  clr(use_a,0);
  clr(use_b,0);
  V = 0;
}

int main(){
  while(cin >> n >> m,(n + m)){
    init();
    vi a(n);
    vi b(m);
    rep(i,0,n)cin >> a[i];
    rep(i,0,m)cin >> b[i];

    rep(i,0,n){
      rep(j,0,m){
        if(gcd(a[i],b[j]) > 1){
          use_a[i] = true;
          use_b[j] = true;
          add_edge(i,n+j);
        }
      }
    }
    rep(i,0,n)V += use_a[i];
    rep(i,0,m)V += use_b[i];
    V += n;
    print(bipartite_matching());
  }
  return 0;
}


Measured memory_bytes: 5252
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

void solve() {
    VV<int> c(3, V<int>(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    bool flag = false;
    rep(i, 3) {
        c[1][i] -= c[0][i];
        c[2][i] -= c[0][i];
    }
    flag = (c[1][0] == c[1][1] and c[1][0] == c[1][2]) and (c[2][0] == c[2][1] and c[2][0] == c[2][2]);

    if (flag)
        cout << "Yes\n";
    else
        cout << "No\n";
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = INT_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;
	while (tc--) {

		ll n, m, l, r;
		ll i, j;
		ll x, y;

		cin >> n;
		ll a[n + 5];
		ll mul = 1;
		ll f = 0, f1 = 0;

		for (i = 0; i < n; i++) {
			ll x;
			cin >> x;

			if (x == 0) {
				cout << 0 << endl;
				return 0;
			}

			if (mul > (ll(pow(10, 18)) / x)) {
				f = 1;
			}
			else
				mul = (mul * x) % (1000000000000000001);

		}

		if (f) {
			cout << -1 << endl;
		}

		else {
			cout << mul << endl;
		}




	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll H,W,N;
    cin >> H >> W >> N;
    cout <<( N + max(H,W) - 1) / max(H,W) << endl;
}



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

ll ps(ll n)
{
	ll p = (1LL << 50), ans = 0, t = 0;
	while (p > 1) {
		if (t + p <= n) {
			t += p;
			if ((n - t + 1) % 2LL)
				ans += p;
		}
		p /= 2LL;
	}
	if (((n + 1) / 2) % 2)
		ans++;
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll a, b; cin >> a >> b;
	cout << (ps(b) ^ ps(a - 1)) << '\n';
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n,m = [int(i) for i in readline().split()]
#d = [int(i) for i in readline().split()]
MOD = 10**9+7

n = int(input())
a = [int(i) for i in readline().split()]

from fractions import gcd
m = a[0]
for i in a:
    m = i//gcd(m,i)*m

ans = 0
for i in a:
    ans += m//i

print(ans%MOD)




Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> a(n - 1), b(n - 1);
	vector<vector<P>> path(n);
	REP(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		path[a[i]].push_back(P(b[i],i));
		path[b[i]].push_back(P(a[i],i));
	}
	vector<int> ent(n,-1);
	ent[0] = 1e6;
	queue<P> q;
	q.push(P(0,-1));
	vector<int> res(n-1);
	int m = 0;
	while (!q.empty()) {
		P p = q.front(); q.pop();
		int pl = 0;
		int cnt = 1;
		REP(i, path[p.first].size()) {
			P next = path[p.first][i];
			if (ent[next.first]==-1) {
				if (ent[p.first] == cnt) {
					cnt++;
				}
				res[next.second] = cnt;
				chmax(m, cnt);
				ent[next.first] = cnt;
				cnt++;
				q.push(P(next));
			}
			
			
		}
	}
	put(m);
	REP(i, n - 1) {
		put(res[i]);
	}
	return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
vector<bool> GetPrimeTable(int n)
{
	vector<bool> IsPrimeNumber(n+1, true);
	for(int i = 2; i <= n; i++){
		while(IsPrimeNumber[i] == false){
			i++;
		}
		for(int j = 2; i*j <= n; j++){
			IsPrimeNumber[i*j] = false;
		}
	}
	return IsPrimeNumber;
}

int GetPrimeCount(vector<bool>& PrimeTable, int n)
{
	int Count = 0;
	for(int i = 2; i <= n; i++){
		if(PrimeTable[i] == true){
			Count++;
		}
	}
	return Count;
}

int main()
{
	vector<bool> PrimeTable = GetPrimeTable(999999);
	while(true){
		int Nubmer;
		cin >> Nubmer;
		if(cin.eof() == true) break;
		cout << GetPrimeCount(PrimeTable, Nubmer) << endl;
	}
	return 0;
}

Measured memory_bytes: 3204
# input
N = int(input())
X = list(map(int, input().split()))

# check
l, r = N // 2 - 1, N // 2
sort_x = sorted(X)
lx, rx = sort_x[l], sort_x[r]

if lx == rx:
    for i in range(N):
        print(lx)
else:
    for ind in range(N):
        target = X[ind]
        if target <= lx:
            print(rx)
        if target >= rx:
            print(lx)


Measured memory_bytes: 30836
#include <stdio.h>

int main(){
	int a, b, c, d;
  	scanf("%d%d%d%d", &a, &b, &c, &d);
  	printf("%s", (a+b==c+d) ? "Balanced" : (((a+b-c-d) > 0) ? "Left" : "Right"));
  	return 0;
}

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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11


int main()
{
    int l,r,d; cin >> l >> r >> d;
    int cnt = 0;
    for(int i = l ; i <= r; i++){
        if(i % d == 0) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3620
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

o = Counter(v[::2]).most_common()
e = Counter(v[1::2]).most_common()
if o[0][0] == e[0][0]:
  if len(o) == 1: print(e[0][1])
  else:
    o1,o2 = e[0][1], e[1][1]
    e1,e2 = o[0][1], o[1][1]
  
    ans = min(n-o1-o2, n-e1-e2)
    print(ans)
else: print(n-o[0][1]-e[0][1])

Measured memory_bytes: 25348
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
int N;cin>>N;vi A(N);rep(i,N)cin>>A[i];
  map<int,int> mp,mq;
  rep(i,N)mp[A[i]]++;
  for(auto x : mp){
    int xn =x.second;
    while(xn>=3){ 
      
      xn=xn/3+xn%3;
    }
    mq[x.first]=xn;
  }
  int cnt=0;
  for(auto x:mq){
   if(x.second==2)cnt++;
  }
  if(cnt%2==0){
   cout<< mq.size()<<endl;;
  }
  else{
   cout<< mq.size()-1<<endl;;
 
  }
}


Measured memory_bytes: 9984
#include <stdio.h>
int main(void)
{
    int n,i,j,a,card[4][13];
    char c,mark[4]={'S','H','C','D'};
    scanf("%d",&n);
    for(i=0;i<4;i++)
    {
        for(j=0;j<13;j++)
        {
            card[i][j]=0;
        }
    }
    for(i=0;i<n;i++)
    {
        scanf(" %c %d",&c,&a);
        if(c=='S') card[0][a-1]=1;
        if(c=='H') card[1][a-1]=1;
        if(c=='C') card[2][a-1]=1;
        if(c=='D') card[3][a-1]=1;
    }
    for(i=0;i<4;i++)
    {
        for(j=0;j<13;j++)
        {
            if(card[i][j]==0)
            {
                printf("%c %d\n",mark[i],j+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>p(n);
  for(int i=0;i<n;++i){
    cin>>p[i];
  }
  int cnt=0;
  for(int j=1;j<=n;++j){
    if(j!=p[j-1]){
      cnt+=1;
    }
  }
  if(cnt==2 or cnt==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int h,w;
int maze[50][50];

int main(void){
	cin>>h>>w;
	for(int i = 0 ; i < h ; i ++)for(int j = 0 ; j < w ; j ++){
		char c; cin>>c; maze[i][j] = c - '0';
	}
	for(int i = 1 ; i < w ; i ++)
		maze[0][i] = maze[0][i] + maze[0][i-1];
	for(int i = 1 ; i < h ; i++)
		maze[i][0] = maze[i][0] + maze[i-1][0];
	for(int i = 1 ; i < h ; i ++)for(int j = 1 ; j < w ; j ++){
		maze[i][j] = min(maze[i-1][j],maze[i][j-1]) + maze[i][j];
	}
	cout<<maze[--h][--w]<<endl;
}

Measured memory_bytes: 1172
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

using vvd = V<vd>;

main {
  int n, m;
  while (cin >> n >> m, n) {
    vvd g(n, vd(n));
    cin >> g;
    vvd dp(m, vd(n, 1.0));
    loop(i, 1, m) rep(j, n) {
      double maxi = -INF;
      rep(k, n) cmax(maxi, dp[i - 1][k] * g[k][j]);
      dp[i][j] = maxi;
    }
    cout << prec(2) << *max_element(all(dp.back())) << endl;
  }
}

Measured memory_bytes: 3380
n = int(input())
h = list(map(int, input().split()))
f = [1 << 31] * n 

f[0] = 0
for i in range(0, n):
    if i >= 1: f[i] = min(f[i], f[i - 1] + abs(h[i] - h[i - 1]))
    if i >= 2: f[i] = min(f[i], f[i - 2] + abs(h[i] - h[i - 2]))

print(f[n - 1])


Measured memory_bytes: 13928
import sys
from collections import defaultdict
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dd = defaultdict(int)
tt = defaultdict(int)

for i in d:
    dd[i] += 1
for i in t:
    tt[i] += 1

for k, v in tt.items():
    if dd[k] < v:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 57252
#include <stdio.h>

int gcd(int,int);

int main(void){
	long a,b;
	long divi,multi;
	while(scanf("%ld %ld",&a,&b) != EOF){
		divi = gcd(a,b);
		multi = a*(b / divi);
		printf("%ld %ld\n",divi,multi);
	}
	return 0;
}

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

Measured memory_bytes: 1024
/*
auth - @sportykush
*/

#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;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];


int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast

cin >> k ;
cin >> l >> r;
bool check = false;
fr(i,l,r+1)
	if(i%k == 0)
		check = true;
cout << (check ? "OK" : "NG");

  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<math.h>
 
main(){
    int n;
    int a[100002];
    int i;
    int t, x, k;
 
    // 整数の入力
    scanf("%d", &n);
 
    a[0] = 0;
    t = 0;
    for(i = 1; i <= n; i++){
        scanf("%d ", &a[i]);
        t += abs(a[i] - a[i-1]);
    }
    a[n+1] = 0;
    t += abs(a[n+1] - a[n]);
 
    for(i = 1; i <= n; i++){
        x=t - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]);
        // 出力
        printf("%d\n", (int)x);
    } 
    
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std ; 
long long freq[100001];
int main (){
        int n,q ; 
        cin>>n;
        int arr[n];
        long long summ =0;
        for(int i =0;i<n;i++){
                cin>>arr[i];
                freq[arr[i]]++;
                summ+=arr[i];
        }
        cin>>q;
        for(int i =0;i<q;i++){
                int a,b;
                cin>>a>>b;
                summ-=(freq[a]*a);
                summ+=freq[a]*b;
                
                freq[b]+=freq[a];
                freq[a]=0;
                cout<<summ<<endl;
        }
} 

Measured memory_bytes: 4784
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

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

using namespace std;

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

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define MMax 12
#define Max 11000
#define MINSTR "x"
int N, M;
int A[MMax];
string dp[Max];

int costs[9] = {2,5,5,4,5,6,3,7,6};

int islarger(const string& lhs, const string& rhs) {
    if (rhs == MINSTR) return 1;
    if (lhs.length() > rhs.length()) return 1;
    if (lhs.length() < rhs.length()) return -1;
    rep(i, lhs.length()) {
        if (lhs[i] > rhs[i]) return 1;
        if (lhs[i] < rhs[i]) return -1;
    }
    return 0;
}

int main(int argc, const char * argv[]) {
    N = inputValue();
    M = inputValue();
    inputArray(A, M);
    
    rep(i, Max) {
        dp[i] = MINSTR;
    }

    dp[0] = "";

    rep(i, N+1) {
        if (dp[i] == MINSTR) continue;

        rep(j, M) {
            int costadd = costs[A[j]-1];
            if (i + costadd <= N) {
                string ans = (char)('0' + A[j]) + dp[i];
                if (islarger(ans, dp[i + costadd]) == 1) {
                    dp[i + costadd] = ans;
                    //cout << ans << "\n";
                }
            }
        }
    }

    output(dp[N]);

    return 0;
}

Measured memory_bytes: 30336
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
char g[500][500];
int cur = 0,ans[500][500];
void add(int cl,int cr,int rl,int rr){
	cur++;
	for(int i=cl;i<=cr;i++)
	for(int j=rl;j<=rr;j++)
		ans[i][j] = cur;
}
int main()
{
	int n,m,k;cin>>n>>m>>k;
	getchar();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			g[i][j] = getchar();
		}
		getchar();
	}
	int lc = 0;
	for(int i=1;i<=n;i++){
		int lr = 0;
		bool ok = 0;
		for(int j=1;j<=m;j++){
			if(g[i][j]=='#'){
				add(lc+1,i,lr+1,j);
				lr = j; 
				ok = 1;
			}
		}
		if(ok){
			cur--;
			add(lc+1,i,lr+1,m); 
			lc = i;
		}
	}
	for(int i=lc+1;i<=n;i++)
	for(int j=1;j<=m;j++)
	ans[i][j] = ans[i-1][j];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			printf("%d ",ans[i][j]);
		puts("");
	}
}


Measured memory_bytes: 1536
#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 x, a, b;
	cin >> x >> a >> b;
	char ans;
	if (abs(x - a) < abs(x - b)) ans = 'A';
	else ans = 'B';
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int i ;
char A= ',' ;
string  S;
int main(){
cin>>S;
for(i=0;i<19;i++){
	
	if (S[i]==A ){
	cout<<" "; 
	continue;
	}
	cout<<S[i];
}
	return 0;
	}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <algorithm>

const int maxn=100;

struct point
{
  int x,y,t;

  bool operator <(const point &other) const
  {
    return x<other.x;
  }
};

point p[(maxn<<1)+10];
int n,ans,used[(maxn<<1)+10];

int main()
{
  scanf("%d",&n);
  for(register int i=1; i<=n; ++i)
    {
      scanf("%d%d",&p[i].x,&p[i].y);
      p[i].t=0;
    }
  for(register int i=1; i<=n; ++i)
    {
      scanf("%d%d",&p[i+n].x,&p[i+n].y);
      p[i+n].t=1;
    }
  std::sort(p+1,p+(n<<1)+1);
  for(register int i=1; i<=n<<1; ++i)
    {
      used[p[i].y]=1;
      if(p[i].t)
        {
          for(register int j=p[i].y-1; j>=0; --j)
            {
              if(used[j])
                {
                  used[j]=0;
                  ++ans;
                  break;
                }
            }
          used[p[i].y]=0;
        }
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128