akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <forward_list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, k);
    make(string, s);
    int n = s.length();
    VI st25(k + 1), st26(k + 1);
    st25[0] = st26[0] = 1;
    for (int i = 1; i <= k; ++i) {
        st25[i] = st25[i - 1] * 25 % M7;
        st26[i] = st26[i - 1] * 26 % M7;
    }
    VI f(n + k), invf(n + k);
    f[0] = f[1] = invf[0] = invf[1] = 1;
    for (int i = 2; i < f.size(); ++i) {
        f[i] = f[i - 1] * i % M7;
        invf[i] = (M7 - (M7 / i) * invf[M7 % i] % M7) % M7;
    }
    for (int i = 1; i < invf.size(); ++i) {
        invf[i] = invf[i] * invf[i - 1] % M7;
    }
    auto C = [&](int i, int j) {
        return f[i] * invf[j] % M7 * invf[i - j] % M7;
    };
    int ans = 0;
    for (int len = 0; len <= k; ++len) {
        int q = st26[len] * st25[k - len] % M7;
        q = (q * C(n + k - len - 1, k - len)) % M7;
        ans += q;
    }
    cout << ans % M7;


    return 0;
}

Measured memory_bytes: 51288
import math

def doc_string():
    """
    I can fly.
    """
while True:
    s = int(raw_input())
    if s == -1:
        break
    x = 1.0
    y = 0.0
    dx = 0
    dy = 0
    for i in xrange(s - 1):
        dx = -y / math.hypot(x, y)
        dy = x / math.hypot(x, y)
        x += dx
        y += dy

    print x,y

Measured memory_bytes: 6384
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double loan = 100000;
		int week;

		while ((scan.hasNext())) {
			week = Integer.parseInt(scan.next());
			for (int i = 0; i < week; i++) {
				loan = loan * 1.05;

				loan = loan / 1000.0;
				BigDecimal bi = new BigDecimal(String.valueOf(loan));
				loan = (bi.setScale(0, BigDecimal.ROUND_UP).doubleValue()) * 1000.0;
			}
			System.out.println((int) loan);

		}
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

int main(void)
{
    int n; scanf("%d", &n);
    std::vector<double> value(n);
    for (int i=0; i<n; i++) scanf("%lf", &value.at(i));

    std::sort(value.begin(), value.end());

    for (int i=0; i<n-1; i++)
    {
        value.at(i+1) = (value.at(i)+value.at(i+1))/2.0;
    }

    printf("%lf\n", value.at(n-1));
}

Measured memory_bytes: 3740
if __name__ == '__main__':
    inputNum = int(input())
    result = 100000

    for num in range(2, inputNum):
        numA = num
        numB = inputNum - num
        _result = 0

        if numA > numB:
            break

        for num1 in str(numA):
            _result += int(num1)
        for num1 in str(numB):
            _result += int(num1)

        if result > _result:
            result = _result

    if inputNum == 2:
        result = 2
    print(result)


Measured memory_bytes: 3064
p = 10**9+7
N,M = map(int,input().split())
A = [0 for _ in range(N+1)]
for _ in range(M):
    i = int(input())
    A[i] = 1
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1,N+1):
    if A[i]==0:
        dp[i] = dp[i-1]
        if i>=2:
            dp[i] = (dp[i]+dp[i-2])%p
print(dp[N])

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int n;
  int a, b;
  
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    cin >> a;
    cin >> b;
    cout << a + b << endl;
  }
}

Measured memory_bytes: 256
n,k=[int(_) for _ in input().split()]
list1=[]
for j in range(n):
    list1.append(j+1)
for i in range(k):
    q=int(input())
    b=[int(b) for b in input().split()][:q]
    for z in range(q):
        try:
            list1.remove(b[z])
        except:continue
            
print(len(list1))
            
    

Measured memory_bytes: 9188
#include<iostream>
using namespace std;
int main()
{
  long long a,v;
  cin>>a>>v;
  long long b,w;
  cin>>b>>w;
  long long t;
  cin>>t;
  if(a==b)
  {
    cout<<"YES"<<"\n";
  }
  else if(a<b)
  {
    if(v<=w)
    {
      cout<<"NO"<<"\n";
    }
    else if(v>w)
    {
      long long t1,t2;
      t1=abs(b-a);
       t2=abs(v-w);
        long long t3;
       t3=t*t2;
        if(t1<=t3)
        {
          cout<<"YES"<<"\n";
        }
      else
      {
        cout<<"NO"<<"\n";
      }
    }
  }
  else if(a>b)
  {
    if(v<=w)
    {
      cout<<"NO"<<"\n";
    }
    else if(v>w)
    {
      long long t1,t2;
      t1=abs(a-b);
       t2=abs(w-v);
       long long t3;
       t3=t*t2;
        if(t1<=t3)
        {
          cout<<"YES"<<"\n";
        }
      else
      {
        cout<<"NO"<<"\n";
      }
    }
    }
    }

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb     push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
const int N=5e3+5;
int g[N][N];
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int n,ans=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)
            if(s[i]==s[j])
            {
                g[i][j]=1;
                g[j][i]=1;
            }
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int k=0;
            while(g[i+k][j+k]==1 and i+k<j)
            {
                g[i+k][j+k]=0;
                k++;
            }
            ans=max(ans,k);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	bool neg=0;
	while(!(c>='0' && c<='9')){
		if(c=='-') neg=1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return neg?-ret:ret;
}
void putint(LL v){
	if(v<0){
		putchar('-');
		v=-v;
	}
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
const int MOD=1000000007;
int powM(int V,int T=MOD-2){
	int R=1;
	while(T){
		if(T&1) R=(LL)R*V%MOD;
		T>>=1;
		V=(LL)V*V%MOD;
	}
	return R;
}
int H,sum[300005],tag[300005],prd[300005],adt[300005],p[300005];
void add(int d,int t,int v){
	if(tag[d]!=t){
		sum[d]=0;
		tag[d]=t;
	}
	sum[d]+=v;
	if(sum[d]>=MOD) sum[d]-=MOD;
}
#define initialization_confirm
#define corner_case_check
#define return_type_of_template_and_operator
int main(){
	#ifdef LOCAL_QTY
		#ifndef initialization_confirm // 不要忘记初始化
			exit(0);
		#endif
		#ifndef corner_case_check // 不要忘记检查边界情况（图不连通，n=1，etc.）
			exit(0);
		#endif
		#ifndef return_type_of_template_and_operator // 勿忘返回值类型
			exit(0);
		#endif
	#endif
	int i,j,k;
	H=readint();
	prd[0]=1;
	for(i=1;i<(1<<H);++i){
		prd[i]=prd[i>>1]*(LL)i%MOD;
	}
	for(i=(1<<H)-1;i>=1;--i){
		adt[i]=powM((LL)prd[i>>1]*prd[i>>1]%MOD*i%MOD);
	}
	for(i=(1<<H)-1;i>=1;--i){
		if(i>1){
			adt[i]-=adt[i>>1];
			if(adt[i]<0) adt[i]+=MOD;
		}
	}
	int res=0;
	for(i=(1<<(H-1));i<(1<<H);++i){
		p[i]=readint()+(1<<(H-1))-1;
		int cp=(LL)prd[i]*prd[p[i]]%MOD;
		cp=(LL)cp*cp%MOD;
		for(j=i>>1;j;j>>=1){
			for(k=p[i]>>1;k;k>>=1){
				res-=(LL)cp*adt[j]%MOD*adt[k]%MOD;
				if(res<0) res+=MOD;
			}
		}
	}
	memset(tag,-1,sizeof(tag));
	for(i=(1<<(H-1))-1;i>=1;--i){
		int l=i,r=i+1;
		while(l<(1<<(H-1))) l<<=1,r<<=1;
		--r;
		vector < int > ps;
		for(j=l;j<=r;++j){
			ps.push_back(p[j]);
			for(k=p[j]>>1;k>=1;k>>=1){
				add(k,i,(LL)prd[p[j]]*prd[j]%MOD);
			}
		}
		for(j=0;j<(int)ps.size();++j){
			int d=ps[j];
			for(k=d>>1;k>=1;k>>=1){
				if(tag[k]!=i) continue;
				res+=(LL)sum[k]*sum[k]%MOD*adt[i]%MOD*adt[k]%MOD;
				if(res>=MOD) res-=MOD;
				tag[k]=-1;
			}
		}
	}
	printf("%lld\n",(LL)res*powM(2)%MOD);
	return 0;
}
/*
 * 代码框架
 * 1. 开一个数组，预处理每个标号对应的到根的链乘积；以及在每个 lca处应该额外乘上的值
 * 		对于lca权值预先做差分，从而不用再考虑重复
 * 2. 自底向上枚举第一棵树上的结点，暴力枚举其中的点在对面的外联边，记录次数
 * 		开数组记录每个对面结点子树内链的条数，开数组记录每个对面结点是否访问过
 * 		每次自底向上枚举对面结点，计算与它的贡献。
*/

Measured memory_bytes: 8252
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int ans = 0;

            for (int i = n; i >= 1; i--) {
                ans = (int) Math.sqrt(i);
                if (ans % 1 == 0) break;
            }
            // 出力
            out.println(ans * ans);

        }

    }
}



Measured memory_bytes: 25300
N,K = [int(x) for x in input().split()]
alist = [0]+ sorted([int(x) for x in input().split()])
countlist =[]
prev =0
count =0
while len(alist)>0:
	a = alist.pop()
	if a == prev:
		count+=1
	else:
		countlist.append(count)
		count = 1
		prev = a
countlist.sort()
countlist.reverse()
print(sum(countlist[K:]))

Measured memory_bytes: 25644
#include<stdio.h>

int main(){
int n;
while(1){
scanf("%d",&n);if(n==0)break;

int a=0,b=0,c=0;int i=1;
while(i<=n){
{int t=i;
while(1){
	while(1){
		if(t%10!=0)break;
		a++;
	t=t/10;
	}
	while(1){if(t%5!=0)break;b++;t=t/5;}
	while(1){if(t%2!=0)break;c++;t=t/2;;}
	if(t%10!=0&&t%5!=0&&t%2!=0)break;
}
	i++;
}

}
int s=0;
if(b<c)c=b;
s=a+c;
printf("%d\n",s);
}
return 0;
}

Measured memory_bytes: 1028
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

x = INT()
if x % 11 == 0:
    ans = x//11*2
elif x % 11 <= 6:
    ans = x//11*2+1
else:
    ans = x//11*2+2
print(ans)

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

char str [10] ;

int main() {
    int n, s;
    scanf("%d %d", &n, &s);
    map<int, pair<bool, int> > mp; // task num, is_Accepted, W count
    int tn;
    int p = 0;
    int ac = 0;
    for(int i= 0; i < s; i++){
        scanf("%d %s", &tn, str);
        string status = str;
        if(status == "AC") {
            if(mp.find(tn) == mp.end() ){
                ac++;
                mp[tn] = make_pair(true, 0);
            }else {
                pair<bool,int> curr = mp[tn];
                if(curr.first == false ){
                    ac++;
                    p += curr.second;
                    curr.first = true;
                    mp[tn] = curr;
                }
            }
        }else {
            if(mp.find(tn) == mp.end()){
                mp[tn] = make_pair(false, 1);
            }else{
                pair<bool,int> curr = mp[tn];
                if(curr.first == false ){
                    curr.second++;
                    mp[tn] = curr;
                }
            }
            
        }
    }
    cout<<ac<<" "<<p<<endl;
    
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll w[300100],e[300100];
int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='W'){
			w[i]=1;
		}
		else{
			e[i]=1;
		}
	}
	for(int i=1;i<s.size();i++){
		w[i]=w[i]+w[i-1];
	}
	for(int i=s.size()-2;i>=0;i--){
		e[i]=e[i]+e[i+1];
	}
	ll ans=INF;
	for(int i=0;i<s.size();i++){
		ll sum=w[i]+e[i]-1;
		ans=min(sum,ans);
	}
	cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5380
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            if (a % 2 == b % 2) {
                out.println("Alice");
            } else {
                out.println("Borys");
            }
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 21332
n = int(input())
dat = list(map(int, input().split()))
import collections
dat = collections.deque(dat)
alen = len(dat)
t = 1
res = 0
while len(dat) != 0:
    c = dat.popleft()
    if c == t:
        t+=1
    else:
        res += 1
if  res == alen:
    print("-1")
else:
    print(res)

Measured memory_bytes: 77900
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll fac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    string s,t;cin >> s >> t;
    ll sl=s.size(),tl=t.size();
    for(int i=sl-tl;i>=0;i--){
        ll count=0;
        rep(j,tl){
            if(s[i+j]==t[j]||s[i+j]=='?')count++;
        }
        if(count==tl){
            rep(j,tl){
                s[i+j]=t[j];
            }
            rep(j,sl){
                if(s[j]=='?')s[j]='a';
            }
            cout << s << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

string s, t;
int ssum[100001], tsum[100001];
int q;

int main(){
    S(s);
    S(t);
    for(int i = 1; i <= s.size(); i++){
        ssum[i] = ssum[i-1];
        if(s[i-1] == 'A') ssum[i]++;
    }
    for(int i = 1; i <= t.size(); i++){
        tsum[i] = tsum[i-1];
        if(t[i-1] == 'A') tsum[i]++;
    }
    I(q);
    rep(i,q){
        int a, b, c, d;
        I(a,b,c,d);
        int sa, sb, ta, tb;
        sa = ssum[b]-ssum[a-1]; sb = b-a-sa+1;
        ta = tsum[d]-tsum[c-1]; tb = d-c-ta+1;
        while(true){
            if(sa >= 3) sa %= 3;
            if(sb >= 3) sb %= 3;
            if(sa+sb <= 1) break;
            if(sa == 1){
                sb += 2;
                sa = 0;
            } else if(sa == 2){
                sb++;
                sa = 0;
            } else if(sb == 1){
                sa += 2;
                sb = 0;
            } else if(sb == 2){
                sa++;
                sb = 0;
            }
        }
        while(true){
            if(ta >= 3) ta %= 3;
            if(tb >= 3) tb %= 3;
            if(ta+tb <= 1) break;
            if(ta == 1){
                tb += 2;
                ta = 0;
            } else if(ta == 2){
                tb++;
                ta = 0;
            } else if(tb == 1){
                ta += 2;
                tb = 0;
            } else if(tb == 2){
                ta++;
                tb = 0;
            }
        }
        if(sa == ta && sb == tb) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}
































Measured memory_bytes: 1792
n = int(input())
t = list(map(int, input().split()))
h = list(map(int, input().split()))

ret = 0
for i in range(len(h)):
    a = h[i]
    if a > t[i]:
        ret += t[i]
        a -= t[i]
    else:
        ret += a
        a = 0

    if a > 0:
        if a > t[i + 1]:
            ret += t[i + 1]
            t[i + 1] = 0
        else:
            ret += a
            t[i + 1] -= a

print(ret)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin>>n; vector<Int> a(n*3,0);
    for (int i = 0; i < n*3; i++) cin>>a[i];
    sort(a.begin(), a.end());
    Int sum=0;
    for (int i = 1; i < n*2; i+=2) sum+=a[n*3-1-i];
    cout<<sum<<'\n';
}

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

struct Vector2D {
	double x;
	double y;
	double abs() const {
		return std::sqrt(x * x + y * y);
	}
	Vector2D& operator-=(const Vector2D& rhs) {
		x -= rhs.x;
		y -= rhs.y;
		return *this;
	}
};

Vector2D operator-(const Vector2D& lhs, const Vector2D& rhs)
{
	return Vector2D(lhs) -= rhs;
}

int main()
{
	int data_count = 0;
	std::cin >> data_count;
	for (int i = 0; i < data_count; ++i) {
		Vector2D a, b;
		double ra, rb;
		if (std::cin >> a.x >> a.y >> ra >> b.x >> b.y >> rb) {
			double rab = (b - a).abs();
			int result;
			if (ra > rab + rb) {
				result = 2;
			} else if (rb > rab + ra) {
				result = -2;
			} else if (ra + rb < rab) {
				result = 0;
			} else {
				result = 1;
			}
			std::cout << result << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define N 1000002
vector<int> cl(N,-1);
class Queue{
	vector<int> v;
	int low;
	int high;
public:
	Queue():v(N,0),low(N-1),high(N-1){}
	void push(const int &t){
		v[low]=t;
		--low;
	}
	void pop(int &t){
		t=v[high];
		--high;
	}
	bool empty(){
		return high==low;
	}
};
int collatz(int n){
	int c=0;
	while(n<N){
		if(cl[n]!=-1)
			return c+cl[n];
		if(n%2==0){
			n/=2;
			++c;
		}else if(n%2==1){
			n=n*3+1;
			++c;
		}
	}
	return 0;
}
int main()
{
	/*Queue q;

	cl[1]=0;
	q.push(1);
	while( !q.empty() ){
		int t;
		q.pop(t);
		if( t*2<N ){
			if( cl[t*2]==0 ){
				cl[t*2]=cl[t]+1;
				q.push(t*2);
			}
		}
		if( (t-1)%3==0&&t>1 ){
			if( cl[(t-1)/3]==0 ){
				cl[(t-1)/3]=cl[t]+1;
				q.push((t-1)/3);
			}
		}
	}*/

	cl[1]=0;
	for(int i = 1; i < N; ++i){
		//if(i%5000==0)cout<<i<<endl;
		cl[i] = collatz(i);
	}

	while(true){
		int n;
		
		cin>>n;
		if(n==0)break;

		cout << cl[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
yymm = False

mmyy = False

if 1 <= s2 <= 12:
    yymm = True
if 1 <= s1 <= 12:
    mmyy = True
if yymm and mmyy:
    print("AMBIGUOUS")
if yymm and not(mmyy):
    print("YYMM")
if not(yymm) and mmyy:
    print("MMYY")
if not(yymm) and not(mmyy):
    print("NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  map<int,int> mp1;
  rep(i,n){
    int x; cin >> x;
    mp1[x]++;
  }
  map<int,int> mp2;
  int m; cin >> m;
  rep(i,m){
    int x; cin >> x;
    mp2[x]++;
  }
  
  for(auto it:mp2){
    if(it.S > mp1[it.F]){
      cout << "NO" << ln; return 0;
    }
  }
  cout << "YES" << ln;
  return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> H(N);
  for(int i=0; i<N; i++){ cin >> H.at(i); }
  
  int res;
  for(int i=0; i<N; i++){
    for(int j=0; j<i+1; j++){
      if( H.at(i)<H.at(j) ){ break; }
      if(j==i){ res++; }
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    n++;
    vector<int> t(n), x(n), y(n);
    t[0] = x[0] = y[0] = 0;
    rep(i, 1, n){
        cin >> t[i] >> x[i] >> y[i];
    }
    bool f = true;
    rep(i, 1, n){
        int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        int tim = t[i] - t[i - 1];
        if(dist % 2 == tim % 2 && dist <= tim);
        else f = false;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 2560
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = 0
for i in range(n):
    s += b[i]

for i in range(n - 1):
    if a[i + 1] == a[i] + 1:
        s += c[a[i] - 1]

print(s)

Measured memory_bytes: 61876
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

// b
int main() {
    ll n, h; cin >> h >> n;
    ll sum = 0;
    rep(i,n) {
        ll a; cin >> a;
        sum += a;
    }

    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
w_list = []
v_list = []
for _ in range(N):
    w,v = map(int,input().split())
    w_list.append(w)
    v_list.append(v)
dp = [[10**12]*(10**5+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w = w_list[i-1]
    v = v_list[i-1]
    for j in range(10**5+1):
        if j-v >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v]+w)
        else:
            dp[i][j] = dp[i-1][j]
maxer = 0
for j in range(10**5+1):
    if dp[i][j] <= W:
        maxer = j
print(maxer)

Measured memory_bytes: 119788
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


i64 n, k, a[202020], f[202020];

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> f[i];
	}
	sort(f,f+n);
	sort(a,a+n, greater<i64>());
	
	i64 ans = LINF;
	for(i64 i = ans/2; i >= 0; i /= 2){
		i64 cnt = 0;
		for(int j = 0; j < n; j++){
			if(a[j] * f[j] > ans){
				cnt += a[j] - (ans / f[j]);
			}
		}
		if(cnt <= k){
			ans -= max(i,1LL);
		}
		else{
			ans += max(i,1LL);
		}
		if(i == 0) break;
	}
	for(int j = 0; j < n; j++){
		if(a[j] * f[j] > ans){
			k -= a[j] - (ans / f[j]);
		}
	}
	if(k < 0) ans++;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

const int N=100010;

int n,m,v,p;
int a[N],s[N];

main(){
    #define task "agc041_b"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);

    n=in,m=in,v=in,p=in;
    forinc(i,1,n) a[i]=in;
    sort(a+1,a+n+1,greater<int>());
    fordec(i,n,1) s[i]=s[i+1]+a[i];
    int tot=p,j=p,t=p;
    forinc(i,p+1,n){
        int lf=a[i]+m;
        if(lf<a[p]) break;
        while(n>=j && a[j]>lf) j++;
        while(n>=t && a[t]+m>=lf) t++;
        int mx=lf*(t-j)-s[j]+s[t] + (n-t+1)*m + (p-1)*m;
        if(j<=i) mx-=m;
        tot+=mx>=m*(v-1);
    }
    cout<<tot;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  cout<<3*a*a;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int A[200] ;
int N ;
int count = 0;

int EvenOdd() {
	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i] % 2;
	 }
	return sum;	
}

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

    while (EvenOdd() == 0) {  
        for (int i = 0; i < N; i++) {
		A[i] = A[i] / 2;			
        }
	    count++;
	}
    cout << count << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;

signed main(){
    int N; cin >> N;
    bool ok = false;
    int x;
    for(int k = 1; k*(k - 1)/2 <= N; k++){
        if(k * (k - 1)/2 == N) {ok = true; x = k;};
    }
    if(!ok){
        cout << "No" << endl;
        return 0;
    }
    else cout << "Yes" << endl;
    cout << x << endl;
    vector<vector<int>> ans(x, vector<int>(x - 1));
    int n = 1;
    for(int b = 0; b < x - 1; b++) {
        for(int i = 0; i + b < x - 1; i++) {
            ans[i][i + b] = n;
            ans[i + b + 1][i] = n;
            n++;
        }
    }
    for(int i = 0; i < x; i++){
        cout << x - 1 << " ";
        for(int j = 0; j < x - 1; j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}


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


int main(void){
  int n,m; cin>> n >> m;
  int a[m];
  int sum = 0;
  rep(i,m){
    cin >> a[i];
    sum += a[i];
  }
  if(sum > n){
    cout << -1 << endl;
  }
  else cout << n - sum << endl;
  return 0;
}


Measured memory_bytes: 3636
let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let build_max_heap (t : int array) h =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= h && t.(l) > t.(i) then l else i in
    let m = if r <= h && t.(r) > t.(m) then r else m in
    if m <> i then begin
      let tmp = t.(i) in t.(i) <- t.(m); t.(m) <- tmp;
      max_heapify m
    end
  and doit i =
    if i > 0 then (max_heapify i; doit (i - 1))
  in doit (parent h)

let () =
  let h = read_int () in
  let t = Array.make (h + 1) 0 in
  let rec read i =
    if i <= h then (t.(i) <- Scanf.scanf "%d " (fun i -> i); read (i + 1))
  in read 1;
  build_max_heap t h;
  let rec doit i =
    if i <= h then (print_string " "; print_int t.(i); doit (i + 1))
  in doit 1;
  print_newline ()

Measured memory_bytes: 8636
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

void debug_out() {};
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(...) 1
#endif

struct C1 {
        ll N_{};
    ll W_{};
    vector<ll> w_{};
    vector<ll> v_{};
    vector<vector<ll>> dp_{};
    explicit C1(ll W, vector<ll> w, vector<ll> v) : N_(w.size()), W_(W), w_(move(w)), v_(move(v)){
        dp_.resize(N_, vector<ll>(W_+1, 0));
    }
    ll resolve() {
        for(ll i=0; i < N_; ++i) {
            for(ll j=0; j < W_+1; ++j) {
                if (i == 0) {
                    dp_[i][j] = (j >= w_[0]) ? v_[0] : 0;
                } else {
                    if (j - w_[i] >= 0) {
                        dp_[i][j] = max(dp_[i-1][j-w_[i]]+v_[i], dp_[i-1][j]);
                    } else {
                        dp_[i][j] = dp_[i-1][j];
                    }
                }
            }
        }
        return dp_[N_-1][W_];
    }
};

int main() {
    ll N, W;
    cin >> N >> W ;
    vector<ll> w{};
    vector<ll> v{};
    for (int i=0; i < N; ++i) {
        ll x, y;
        cin >> x >> y;
        w.emplace_back(x);
        v.emplace_back(y);
    }
    C1 c{W, move(w), move(v)};
    cout << c.resolve() << endl;
    return 0;
}


Measured memory_bytes: 79488
#include <stdio.h>

int main()
{
  int s, m, h, S;
 scanf("%d\n",&S);
 h = S / 3600;
 m = (S - h * 3600) / 60;
 s = S - (m * 60 + h * 3600);
 printf("%d:%d:%d\n", h, m, s);
   return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC118_B();
        }

        static void ABC118_B()
        {
            var NM = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var dict = new Dictionary<int, int>();

            for (var m = 1; m <= NM[1]; m++)
                dict.Add(m, 0);

            for (var n = 0; n < NM[0]; n++)
            {
                var KA = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                for (var a = 1; a <= KA[0]; a++)
                    dict[KA[a]] += 1;
            }
            Console.WriteLine(dict.Values.Count(x => x == NM[0]));
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int h,w,d;
    cin >> h >> w >> d;
    vector<pair<int,int>> a(h*w+1);
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            int x;
            cin >> x;
            a[x]=pair<int,int>(i,j);
        }
    }

    vector<int> m(h*w+1);
    for(int i=0;i<d;i++){
        m[i]=0;
    }
    for(int i=d;i<=h*w;i++){
        int x1=a[i].first;
        int y1=a[i].second;
        int x2=a[i-d].first;
        int y2=a[i-d].second;
        int p=std::abs(x1-x2)+std::abs(y1-y2);
        m[i]=m[i-d]+p;
    }

    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >> r;
        cout << m[r]-m[l] << endl;
    }
    return 0;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {

    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int new_v : G[v]) {
            if (dist[new_v] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 new_v について距離情報を更新してキューに追加する
            dist[new_v] = dist[v] + 1;
            que.push(new_v);
        }
    }

    if (dist[N - 1] == 2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 13168
// g++ temp.cpp
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string>
#include <climits>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

int c,r;
int a[10][10000];

int main(){
	while(1){
		cin>>r>>c;
		if(r==0&&c==0) break;
		REP(i,r)REP(j,c){
			cin>>a[i][j];
		}
		int res = 0;
		REP(i,pow(2,r)){
			int cnt[10000], sum=0;
			fill(cnt, cnt+c, 0);
			REP(j,r)REP(k,c){
				if((((i>>j)&1)==1&&a[j][k]==1)||(((i>>j)&1)==0&&a[j][k]==0)) cnt[k]++;
			}
			REP(k,c){
				sum+=max(cnt[k],r-cnt[k]);
			}
			res=max(res, sum);
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

long long int find_GCD(long long int a, long long int b){
  long long int max = 0;
  for(int i=min(a, b);i>0;i--){
    if(a%i==0 && b%i==0){
      max = i;
      break;
    }
  }
  return max;
}

long long int find_LCM(long long int a, long long int b){
  long long int LCM;
  for(int i=max(a, b);i<=a*b;i+=max(a, b)){
    if(i%a==0 && i%b==0){
      return i;
    }
  }
}

int main(){
  long long int a, b;
  while(cin >> a >> b){
    //    cout << a << " " << b <<endl;
    //    int GCD = find_GCD(a, b);
    //    cout << GCD << endl;
    //    cout << find_GCD(a, b) << endl;
    //    long long int GCD = find_GCD(a, b);
    //    long long int LCM = a*b/GCD;

    long long int GCD;
    long long int LCM;
    LCM = find_LCM(a, b);
    GCD = a*b/LCM;
    cout << GCD << " " << LCM << endl;
  }

} 

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

void printarray(int a[], int n){
	for (int i=0; i<n; i++){
		cout << a[i] << ' ';
		if (i==n-1){
			cout << endl;
		}
	}
}

void insertionsort(int a[], int n, int g, int& cnt){
	for (int i=g; i<n; i++){
		int v = a[i];
		int j = i-g;
		while (j>=0 && v < a[j]){
			a[j+g] = a[j];
			j -= g;
			cnt++;
		}
		a[j+g] = v;
	}
}

void shellsort(int v[], int n, int& cnt){
	int tmp = 1;
	int m = 0;
	while (tmp<=n){
		tmp = 3*tmp + 1;
		m += 1;
	}
	//cout << tmp << endl;
	int gl[m];
	int t = 1;
	for (int i=0; i<m; i++){
		gl[m-1-i] = t;
		t = t*3 + 1;
	}

	for (int i=0; i<m; i++){
		insertionsort(v, n, gl[i], cnt);
	}

	cout << m << endl;
	printarray(gl, m);
	cout << cnt << endl;
	for (int i=0; i<n; i++){
		cout << v[i] << endl;
	}

}


int main(){
	int n;
	cin >> n;
	int v[n];
	int cnt = 0;
	for (int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		v[i] = tmp;
	}

	shellsort(v,n,cnt);

	return 0;
}


Measured memory_bytes: 6968
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

int main() {
    const char* Vacant = "Vacant";
    ll N;
    cin >> N;
    vector<char> state(N, '$');
    ll start = 0;
    cout << start << endl << flush;
    string ans;
    cin >> ans;
    if (ans == Vacant) {
        return 0;
    }
    state[start] = ans[0];
    ll last = N-1;
    cout << last << endl << flush;
    ans.clear();
    cin >> ans;
    if (ans == Vacant) {
        return 0;
    }
    state[last] = ans[0];
    while (true) {
        ll half = (start + last) / 2;
        if (last - start == 2) {
            cout << half << endl << flush;
            return 0;
        }
        cout << half << endl;
        string ans;
        cin >> ans;
        if (ans == Vacant) {
            return 0;
        }
        state[half] = ans[0];
        if ((last - start) % 2 == 0) {
            if (state[start] == state[half]) {
                if ((half - start) % 2 == 0) {
                    start = half;
                } else {
                    last = half;
                }
            } else {
                if ((half - start) % 2 == 0) {
                    last = half;
                } else {
                    start = half;
                }
            }
        } else {
            if (state[start] == state[half]) {
                if ((half - start) % 2 == 0) {
                    start = half;
                } else {
                    last = half;
                }
            } else {
                if ((half - start) % 2 == 0) {
                    last = half;
                } else {
                    start = half;
                }
            }
        }
    }
}


Measured memory_bytes: 980
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}
  
int main(){
  int a,c,b,k;cin >> a >> b >> c >> k;
  int ans=0;
  if(a>=k)ans=k;
  else if(a+b>=k)ans=a;
  else ans=a-(k-(a+b));
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
 using namespace std;
 #define ll long long int
 int main()
 {
        long long int  n,x,a,c,sum=0,i;
          string s;
           cin>>s;
            for(i=0;i<s.size();i++)
             sum+=s[i]-'0';
              if(sum%9==0)
                 cout<<"Yes";
              else
                cout<<"No";
 }



Measured memory_bytes: 3680
#include"bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;
const int64_t MAX_VALUE = static_cast<int64_t>(pow(10, 18));

void Main() {
	long long N;
	cin >> N;
	vector<int64_t> A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A[i];
	}
	int64_t value = 1;
	bool isOver = false;
	for (int64_t a : A) {
		if (a == 0) {
			value = 0;
			isOver = false;
			break;
		}
		if (isOver) {
			continue;
		}

		if ((INT64_MAX / value) < a ||( a * value > MAX_VALUE)) {
			isOver = true;
			continue;
		}
		value = a * value;
	}
	if (isOver) {
		value = -1;
	}
	cout << value << endl;
}

int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  while(N>=K) {
    N /= K;
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <queue>

using namespace std;
typedef pair<int, int> P;

const int MAXW = 20;
const int MAXH = 20;
const int INF = 40000;

int h, w;
char maze[MAXW][MAXH];
bool visited[MAXW][MAXH];
int dist[MAXW][MAXH];
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};

void fill() {
  for (int x=0;x<w;x++) {
    for (int y=0;y<h;y++) {
      if (maze[x][y] == '.') {
        dist[x][y] = INF;
      } else {
        dist[x][y] = 0;
      }
    }
  }
}

int bfs(int x, int y) {
  fill();
  dist[x][y] = 0;
  visited[x][y] = true;
  queue<P> que;
  que.push(P(x, y));
  while (!que.empty()) {
    P p = que.front();
    que.pop();
    for (int i=0;i<4;i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] == '.' && !visited[nx][ny]) {
        visited[nx][ny] = true;
        dist[nx][ny] = dist[p.first][p.second] + 1;
        que.push(P(nx, ny));
      }
    }
  }
  int ans = 0;
  for (int i=0;i<w;i++) {
    for (int j=0;j<h;j++) {
      ans = max(ans, dist[i][j]);
    }
  }
  return ans;
}

void solve() {
  int ans = 0;
  for (int x=0;x<w;x++) {
    for (int y=0;y<h;y++) {
      if (maze[x][y] == '.') {
        memset(visited, 0, sizeof(visited));
        ans = max(ans, bfs(x, y));
      }
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> h >> w;
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      cin >> maze[j][i];
    }
  }
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
bool judge(string s,char a){
    rep(i,s.size()){
        if(s[i] != a){
            return false;
        }
    }
    return true;
}
int main(){
    string s;
    cin >> s;
    string ss;
    string sss;
    int ans = 1000;
    int tem;
    rep(i,alpha.size()){
        ss = s;
        tem = 0;
        while(!judge(ss,alpha[i])){
            rep(j,ss.size()-1){
                if(ss[j] == alpha[i]){
                    sss.push_back(ss[j]);
                }
                else{
                    sss.push_back(ss[j+1]);
                }
            }
            ss = sss;
            sss = "";
            tem++;
        }
        ans = min(ans,tem);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256