akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

template<typename N>
int query(const vector<N>& A, const vector<N>& B)
{
  vector<N> D(A.size());
  long sum = 0;
  for (size_t i = 0; i < A.size(); ++i) {
    D[i] = A[i] - B[i];
    sum += D[i];
  }
  if (sum < 0) return -1;
  sort(D.begin(), D.end());
  int index = 0;
  long value = 0;
  for (size_t i = 0, p = D.size(); i < D.size(); ++i) {
    if (D[i] >= 0) break;
    long d = abs(D[i]);
    ++index;
    while (value < d) {
      --p;
      value += D[p];
      ++index;
    }
    value -= d;
  }
  return index;
}

int main()
{
  int N;
  cin >> N;
  vector<long> A(N), B(N);
  for (int n = 0; n < N; ++n) cin >> A[n];
  for (int n = 0; n < N; ++n) cin >> B[n];
  cout << query(A, B) << endl;
  return 0;
}

Measured memory_bytes: 2560
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double



template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

const int MOD = 1e9 + 7;
int n, x, y, z, l, ng;
ll dp[41][1 << 16], ans;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n >> x >> y >> z;
	l = x + y + z - 1;
	int m = (1 << l) - 1;
	ng = (1 << l) | (1 << (l - x)) | (1 << (l - x - y));
	dp[0][0] = 1;
	REP(i, n) {
		FOR(a, 1, 11) {
			REP(s, 1 << l) {
				int t = (s << a) | (1 << (a - 1));
				if ((ng & t) != ng)dp[i + 1][t & m] = (dp[i + 1][t & m] + dp[i][s]) % MOD;

			}
		}
	}
	ans = 1;
	REP(i, n)ans = ans * 10 % MOD;
	REP(s, 1 << l) {
		ans += MOD - dp[n][s]; ans %= MOD;
	}
	print(ans);
}


Measured memory_bytes: 20736
import queue

N = int(input())

def common_divisors(n):
    i = 1
    res = []
    while i*i <= n:
        if n % i == 0:
            res.append(i)
            res.append(n//i)
        if i*i == n:
            res.pop()
        i += 1
    return res

ans = 0
ans += len(common_divisors(N-1))-1

for i in common_divisors(N):
    if i == 1:
        continue
    n = N
    while n % i == 0:
        n /= i
    if n % i == 1:
        ans += 1
print(ans)



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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  long double m = 360.0 / 60.0 * M;
  long double h = 360.0 / 12.0 * H + 30.0 / 60.0 * M;
  long double tmp = max(m, h) - min(m, h);
  tmp = min(tmp, 360.0 - tmp);
  tmp *= M_PI / 180;
  cout << fixed << setprecision(9) << sqrt(A * A + B * B - 2 * A * B * cos(tmp)) << "\n";
}

Measured memory_bytes: 4136
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
ll cc(ll x,ll y)
{
	return (x*y)/(__gcd(x,y));
}
vec v[2005]; bool vis[2005]; ll lev[2005],dist[2005];
void ff()
{
	rep(i,0,2001)
	{
		lev[i]=0;
		vis[i]=false;
	}
}
void gg(ll n)
{
	repi(i,1,n)
	{
		dist[lev[i]]++;
	}
}
void bfs(ll x)
{
	vis[x]=true;
	queue<ll> q; ll y,z;
	q.push(x);
	lev[x]=0;
	while(!q.empty())
	{
		y=q.front();
		q.pop();
		z=v[y].size();
		rep(i,0,z)
		{
			if(!vis[v[y][i]])
			{
				lev[v[y][i]]=lev[y]+1;
				q.push(v[y][i]);
				vis[v[y][i]]=true;
			}
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll m,k,g,i,ans,l,n,h,w,x,y;
    	cin>>n>>x>>y;
    	rep(i,1,n)
    	{
    		v[i].pb(i+1);
    		v[i+1].pb(i);
    		dist[i]=0;
		}
    	v[x].pb(y); v[y].pb(x);
    	repi(i,1,n)
    	{
    		ff();
    		bfs(i);
    		gg(n);
		}
    	rep(i,1,n)
    	cout<<(dist[i]/2)<<'\n';
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

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

        // 入力
        int r = sc.nextInt();
        //String s = sc.next();

        // 処理
        double out = 2 * Math.PI * r;

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 35968
import collections
import sys

N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]

if N == 1:
    print(1)
    sys.exit()

pq = []
for i in range(N):
    for j in range(N):
        if i != j:
            pq.append((xy[i][0]-xy[j][0], xy[i][1]-xy[j][1]))
#print(pq)
pqc = collections.Counter(pq)
x = pqc.most_common()[0][1]
print(N-x)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	double d,t,s;
	cin >> d >> t >> s;
	if((double)d/(double)s <= (double)t)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 3712
MOD = 10**9+7
dp_1 = 1
dp_2 = 0

for c in input():
    t_1 = (dp_1*(int(c)+1)) % MOD
    t_2 = (dp_2*3+dp_1*int(c)) % MOD
    dp_1 = t_1
    dp_2 = t_2

print((dp_1+dp_2) % MOD)


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
//const int mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
VL dx={1,0,-1,0};
VL dy={0,1,0,-1};
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll k;
    cin>>k;
    fr(i,0,k)
    {
        cout<<"ACL";
    }
    return;
}
int main()
{
    IOS;
    ll t=1,pp;
    //cin>>t;
    pp=t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<": ";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3612
import sys
input = sys.stdin.readline
from collections import defaultdict
N = int(input())

ans = defaultdict(int)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            t = x**2 + y**2 + z**2 + x*y + y*z + z * x
            ans[t] += 1

for i in range(1,N+1):
    print(ans[i])



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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector <int> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    vector <long long> nb(n);
    for(int i=n-1;i>=0;i--){
        nb[i]=(c.end()-upper_bound(c.begin(),c.end(),b[i]));
        if(i<n-1){
            nb[i]+=nb[i+1];
        }
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        int ind=upper_bound(b.begin(),b.end(),a[i])-b.begin();
        if(ind<n){
            ans+=nb[ind];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// > val の要素数
int CountUpper(const vll &vec, ll val){
    return distance(upper_bound(ALL(vec), val), vec.end());
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    vll b(n);
    rep(i, n){
        cin >> b[i];
    }
    vll c(n);
    rep(i, n){
        cin >> c[i];
    }
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));
    vll ansb(n);
    rep(i, n){
        ansb[i] = CountUpper(c, b[i]);
    }
    for(int i = n-2; i >= 0; i--){
        ansb[i] += ansb[i+1];
    }
    vll ansa(n);
    rep(i, n){
        ansa[i] = CountUpper(b, a[i]);
    }
    ll ans = 0;
    rep(i, n){
        if(ansa[i]) ans += ansb[n-ansa[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
program abc119c
  implicit none
  integer n, a, b, c, mp, i, m, ix, bamboo(3)
  integer, allocatable :: l(:), ans(:)

  read *, n, a, b, c
  allocate(l(n), ans(4**n))
  read *, l
  ans = 10**9
  do i = 1, 4**n
     mp = 0
     bamboo = 0
     do m = 1, n
        ix = iand(ishft(i - 1, -(m - 1) * 2), 3)
        if (ix /= 0) then
           bamboo(ix) = bamboo(ix) + l(m)
           mp = mp + 10
        end if
     end do
     if (any(bamboo == 0)) then
        cycle
     end if
     ans(i) = mp + sum(abs(bamboo - [a, b, c])) - 30
  end do
  print *, minval(ans)
end program abc119c


Measured memory_bytes: 512
Q,H,S,D=map(int,input().split())
N=int(input())
H=min(H,Q*2)
S=min(S,H*2)
if D>=S*2 :
    print(S*N)
else:
    ans=0;
    if N%2==1:
        ans+=S
    
    ans+=(N//2)*D
    print(ans)

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

typedef long long ll;

//https://scrapbox.io/ganariya/AtCoderDP%E3%81%BE%E3%81%A8%E3%82%81%E3%82%B3%E3%83%B3%E3%83%86%E3%82%B9%E3%83%88_Q%E5%95%8F%E9%A1%8C_%E3%80%8CFlowers%E3%80%8D
//を見ながら。

class SegTree
{
    int n;
    vector<ll> node;

    public:
        SegTree(vector<ll> a) 
        {
            int sz = a.size();
            n = 1;
            while (n < sz) n*= 2; //nはsz以上の2の累乗とすると
            node.resize(2 * n - 1, 0);//node数は2*n-1  最下位ノードは[n - 1]から
        }
    
        void update(int index, ll x)
        {
            index += (n - 1); 
            node[index] = x; //ノード更新
            while(index > 0)
            {
                index = (index - 1) / 2; //親ノードへのアクセス
                node[index] = max(node[index * 2 + 1], node[index * 2 + 2]); //ノードの最大値更新
            }
        }
        /*
        区間[a, b] における最大値の取得
        */
        ll getMax(int a, int b, int k = 0, int l = 0, int r = -1)
        {
            if (r < 0) r = n - 1;
            if (r < a || b < l) return 0;
            if (a <= l && r <= b) return node[k];
            ll vl = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = getMax(a, b, k * 2 + 2, (l + r) / 2  +  1, r);
            return max(vl, vr);
        }
};


int main ()
{
    int N;
    cin >> N;

    vector<ll> h(N), a(N);
    for(int i = 0; i < N; i++) cin >> h[i];
    for(int i = 0; i < N; i++) cin >> a[i];

    vector<pair<ll, pair<ll, ll>>> hai(N);
    for(int i = 0; i < N; i++) hai[i] = make_pair(h[i], make_pair(a[i],i));
    sort(hai.begin(), hai.end());

    SegTree tree(vector<ll>(N, 0));
    for (int i = 0; i < N; i++) //ここでのiはheight
    {
        ll val = hai[i].second.first; //価値
        int index = hai[i].second.second; //本来のindex

        ll maxV = tree.getMax(0, index);
        tree.update(index, maxV + val);
    }

    cout << tree.getMax(0, N) << endl;

}

Measured memory_bytes: 13696
// lolinkの自作ライブラリ
/* option1:グラフが非連結の場合,option2:bridgeの検出,option3:関節点の検出*/
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define loINF (long)10000000000
#define shINF (short)10000
#define SORT(c) sort((c).begin(),(c).end())
//#define NOT_ALL_CONNECTED 	//option1
#define BRIDGE   				//option2
//#define ARTICULATION_POINT    //option3
using namespace std;
const long V_START = 0;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef pair<long,long> pr;
typedef vector<pr> VP;

bool pairCompare(const pr& firstElof, const pr& secondElof)
{
    return (firstElof.first < secondElof.first || ((firstElof.first == secondElof.first) && (firstElof.second < secondElof.second)));
}

VVL edge;
VL ord;
VL low;
VL pre;

void dfs(long now_ver,long parent,long order){
	long child_num = 1;
	char flag = 0;
	pre[now_ver] = parent;
	low[now_ver] = ord[now_ver] = order;

	REP(i,edge[now_ver].size()){
		long to = edge[now_ver][i];
		if (to == parent) continue;
		if (ord[to] == -1) { // 子ノードへの辺
			dfs(to,now_ver,order + child_num);
			child_num++;
			low[now_ver] = min(low[now_ver],low[to]);
		}
		low[now_ver]=min(low[now_ver],ord[to]);
	}
}

int main(void){
	long V,E;
	cin >> V >> E;
	edge = VVL(V+1,VL(0));
	ord = VL(V+1,-1);
	low = VL(V+1,loINF);
	pre = VL(V+1,-1);

	REP(i,E){
		long u,v;
		cin >> u >> v;
		edge[u].push_back(v);
		edge[v].push_back(u); 
	}

	#ifdef NOT_ALL_CONNECTED // グラフが非連結の場合
		FOR(i,V_START,V+V_START) 
			if(ord[i] == -1)
				dfs(i,-1,1);
	#endif

	#ifndef NOT_ALL_CONNECTED // グラフが連結の場合
		dfs(1,-1,1);
	#endif

	#ifdef BRIDGE
		VP bridge;
		long bridge_count = 0;

		FOR(i,V_START,V+V_START){
			if (ord[i] == low[i]) {
				if (i == 1) continue;
				bridge.push_back(make_pair(min(i,pre[i]),max(i,pre[i])));
				bridge_count++;
			}
		}

		sort(bridge.begin(),bridge.end(),pairCompare);

		REP(i,bridge.size()) 
			cout << bridge[i].first << " " << bridge[i].second << endl;
	#endif

	#ifdef ARTICULATION_POINT
		VL point;
		long point_count = 0;
		char root_count = 0;
		FOR(i,V_START,V+V_START){
			if (pre[i] == -1) continue;
			if (pre[i] == 1) root_count++;
			else {
				if (ord[pre[i]] <= low[i]) {
					point.push_back(pre[i]);
					point_count++;
				}
			}
		}
		if(root_count >= 2) {
			point.push_back(1);
			point_count++;
		}

		SORT(point);
		point.erase(unique(point.begin(),point.end()),point.end());

		// point_count:関節点の個数 , point:関節点
		cout << "関節点の個数:" << point_count << endl;
		REP(i,point.size()) cout << point[i] << endl;
		
	#endif

	#ifdef DEBUG
		dump1d_arr(ord);
		dump1d_arr(low);
		dump1d_arr(pre);
	#endif

	return 0;
}




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

using namespace std;
int main()
{
	char s[5];
	cin >> s;
	int ans = 700;
	for(int i=0; i<3; i++){
		if(s[i] == 'o')
			ans += 100;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll ans=1;
  rep(i,n){
    ll x;
    cin>>x;
    ans=lcm(ans,x);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
int main()
{
	RIII(r,g,b);
	PL((10*g+b)%4 ? "NO" : "YES");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(int argc, char **argv)
{
  vi l(10,0), v(2,0);
  char c;
  int total;
  for (;;) {
    rep (i, 10) {
      cin >> l[i];
      cin >> c;
    }
    cin >> v[0] >> c >> v[1];
    if (cin.eof())
      break;

    total = 0;
    tr (l, i) {
      *i = *i * (v[0]+v[1]);
      total += *i;
    }
    int time = total / (v[0]+v[1]);
    int i = 0;
    int d = 0;
    for (; d < time*v[0]; d += l[i++])
      ;
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
a = []
for i in range(3):
    a.append(list(map(int,input().split())))
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = -1
if a[0][0] == -1 and a[0][1] == -1 and a[0][2] == -1:
    print("Yes")
elif a[1][0] == -1 and a[1][1] == -1 and a[1][2] == -1:
    print("Yes")
elif a[2][0] == -1 and a[2][1] == -1 and a[2][2] == -1:
    print("Yes")
elif a[0][0] == -1 and a[1][0] == -1 and a[2][0] == -1:
    print("Yes")
elif a[0][1] == -1 and a[1][1] == -1 and a[2][1] == -1:
    print("Yes")
elif a[0][2] == -1 and a[1][2] == -1 and a[2][2] == -1:
    print("Yes")
elif a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
    print("Yes")
elif a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38588
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

struct Robot{
    ll x;
    ll l;
    ll left;
    ll right;
};

bool cmp( const Robot &a, const Robot &b ){
    return a.right < b.right;
}

int main(){

    ll n;
    cin >> n;

    vector<Robot> v(n);
    for(int i = 0; i < n; i++) cin >> v[i].x >> v[i].l;

    for(int i = 0; i < n; i++) {
        v[i].left  = v[i].x - v[i].l;
        v[i].right = v[i].x + v[i].l;
    }

    sort(all(v), cmp);

    ll ans = 1;
    ll leftMin = v[0].right;
    for(int i = 1; i < n; i++){
        if( v[i].left >= leftMin ){
            leftMin = v[i].right;
            ans ++;
        }
    }
    cout << ans << endl;
    


}

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

int main() {
	int N, M;
	cin >> N >> M;
	int L, R;
	int left_end = 0, right_end = N;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		if (left_end < L) left_end = L;
		if (right_end > R) right_end = R;
		//cout << left_end << endl;
		//cout << right_end << endl;
	}
	if (left_end <= right_end) {
		cout << right_end - left_end + 1 << endl;
	}
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF=1000000000;
typedef pair<int,int> P;
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; }
vector<string> v;
queue<P> Q;
int GCD(int a,int b){return b? GCD(b,a%b):a;}
int main(){
    int  N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    int res=A.at(0);
    for(int i=1;i<N;i++){
       res=GCD(res,A.at(i));
    }
    cout<<res<<endl;
}
 


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

int main(){
  int N;
  cin >> N;
  int mod =  pow(10,9)+7;
  int64_t power = 1;
  for(int i = 1; i <= N; i ++){
    power *= i;
    power %= mod;
  }
  cout << power << endl;
  
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

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

int main()
{
	int field[5][5] = {{0}};
	rep(i, 9){
		char str[6];
		scanf("%s", str);
		if(i%2){
			rep(j, 5){
				int a = str[j]-'0';
				field[i/2][j] |= a<<2;
				field[i/2+1][j] |= a;
			}
		}else{
			rep(j, 4){
				int a = str[j]-'0';
				field[i/2][j] |= a<<1;
				field[i/2][j+1] |= a<<3;
			}
		}
	}

	putchar('R');
	int y=0, x=1;
	int pre = 1;
	do{
		// printf("(%d, %d)\n", x, y);
		pre = (pre+2)%4;
		int dire = pre;
		do{
			dire = (dire + 1)%4;
		}while(!((field[y][x]>>dire)&1));
		pre = dire;
		putchar("URDL"[dire]);

		int dx[] = {0, 1, 0, -1};
		int dy[] = {-1, 0, 1, 0};
		x += dx[dire];
		y += dy[dire];
	}while(y!=0 || x!=0 || (field[0][0]==6 && pre==3));
	puts("");

	return 0;
}

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

int arr[100001] = {};
int dp[100001] = {};

int main() {
	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		cin >> arr[i];
	}
	dp[0] = 0;
	for(int i=1;i<n;i++) {
		dp[i] = 1999999999;
		for(int j=1;j<=k && i-j>=0;j++) {
			dp[i] = min(dp[i], dp[i-j] + abs(arr[i]-arr[i-j]));
		}
	}
	printf("%d", dp[n-1]);
}

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

const int mxN = 2e5;
int n, a[mxN], ans, amt[1000001];

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

    for (int i = 0; i < n; i++)
    {
        for (int j = a[i]; j <= a[n - 1]; j += a[i]) amt[j]++;
    }

    for (int i = 0; i < n; i++)
    {
        if (amt[a[i]] == 1) ans++;
    }

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

Measured memory_bytes: 8140
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
edge = [[] for _ in range(N + 1)]
for _ in range(M):
    s, t, d = map(int, input().split())
    edge[s].append((t, d))
    edge[t].append((s, -d))

dist = [None] * (N + 1)


def isOK(v):
    node = [v]
    if dist[v] is None:
        dist[v] = 0

    while node:
        s = node.pop()
        for t, d in edge[s]:
            if dist[t] is None:
                dist[t] = dist[s] + d
                node.append(t)
            else:
                if dist[t] != dist[s] + d:
                    return False
    return True


ans = "Yes"
for i in range(1, N + 1):
    if dist[i] is not None:
        continue

    if not isOK(i):
        ans = "No"
        break
print(ans)

Measured memory_bytes: 65892
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  priority_queue<int> que;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    que.push(a);
  }
  for(int i=0;i<M;i++){
    int n=que.top();
    que.pop();
    que.push(n/2);
  }
  long long answer=0;
  while(!que.empty()){
    answer+=que.top();
    que.pop();
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 892
a = int(input())
b = list(map(int, input().split()))
d = 0
c = 1000

while d+1 < a:
   if b[d+1] > b[d]:
       c = c - (b[d] * (c//b[d])) + ((c//b[d]) * (b[d+1]))
   else: pass
   d += 1

print(c)

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

int main(void){
        
    const int dx[8] = {0,1,1,1,0,-1,-1,-1};
    const int dy[8] = {1,1,0,-1,-1,-1,0,1};
    int H,W;
    string map[101];

    cin >> H >> W;
    for(int h=0;h<H;h++) cin >> map[h];
    
    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            if(map[h][w]=='.') {
                int count = 0;
                for(int dir=0;dir<8;dir++){
                    int nh = h + dx[dir];
                    int nw = w + dy[dir];
                    if (0 <= nw and nw < W and 0 <= nh and nh < H){ 
                        if(map[nh][nw]=='#')count++;
                    }
                }
                map[h][w] = char('0' + count);
            }

        } 
    }
    
    for(int h=0;h<H;h++) cout << map[h]<< endl;
    
    return 0;
}


Measured memory_bytes: 3548
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;
map<int, int> M;

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		M[x]++;
	}

	LL ans = 0;
	LL temp = 0;
	for (auto const& iM : M) {
		int x = iM.first;
		int y = iM.second;

		if (y % 2 == 0) temp++;
		else ans++;
	}

	// 2 tmep, 1 ans
	if (temp % 2 == 1) ans += temp - 1;
	else ans += temp;

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4864
N = int(input())
cake = 4
donuts= 7

cake_max= N // cake
donuts_max = N // donuts

for cake_num in range(cake_max+1):
    for donuts_num in range(donuts_max+1):
        if cake * cake_num + donuts * donuts_num == N:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3060
data class AB(val a: Int, val b: Int) {
    constructor(pc: List<Int>): this(pc[0], pc[1])
}
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val ab = Array(M) { AB(listOfInt()) }.sortedBy { it.b }
    var now = ab[0].b
    var ans = 1
    for (m in 1 until M) {
        if (ab[m].a >= now || now > ab[m].b) {
            ans += 1
            now = ab[m].b
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }






Measured memory_bytes: 75916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    int cnt=0;
    string s;
        cin >> s;
    vec v;
        for(int i=0; i<s.size(); i++) v.push_back(s[i]-'0');

    bool flag = true;
        while(flag){
            flag = false;
            for(int i=0; i<v.size()-1; i++){
                if(v[i]==v[i+1]) continue;
                flag = true;
                cnt += 2;
                if(v.size()!=2) 
                    v.erase(v.begin()+i, v.begin()+i+2);
                else flag = false;
                            
                break;
            }
        }
        cout << cnt << endl;
}

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

int a[100010],n;
vector <int> v[2];
int maxn=0;

void solve(int x,int id){
	for(int i=1;i*i<=x;i++){
		if(x%i==0){
			v[id].push_back(i);
			v[id].push_back(x/i);
		}
	}
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<2;i++) solve(a[i],i);
	sort(v[0].begin(),v[0].end());
	reverse(v[0].begin(),v[0].end());
	sort(v[1].begin(),v[1].end());
	reverse(v[1].begin(),v[1].end());
	for(int i=0;i<2;i++){
		for(int j=0;j<v[i].size();j++){
			int cnt=0;
			for(int k=0;k<n;k++) if(a[k]%v[i][j]==0) cnt++;
			if(cnt>=n-1) maxn=max(maxn,v[i][j]);
		}
	}
	printf("%d\n",maxn);
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/
int d[31][31];
int t[3][31];
int main(){
     int n,c;
     cin>>n>>c;
     for(int i=1;i<=c;i++){
          for(int j=1;j<=c;j++)cin>>d[i][j];
     }
     for(int i=1;i<=n;i++){
          for(int j=1;j<=n;j++){
               int x;cin>>x;
               t[(i+j)%3][x]++;
          }
     }
     ll res=1LL<<40;
     for(int i=1;i<=c;i++){
          for(int j=1;j<=c;j++){
               if(i!=j){
                    for(int k=1;k<=c;k++){
                         if(i!=k&&j!=k){
                              ll tmp=0;
                              for(int l=1;l<=c;l++)tmp+=t[0][l]*d[l][i];
                              for(int l=1;l<=c;l++)tmp+=t[1][l]*d[l][j];
                              for(int l=1;l<=c;l++)tmp+=t[2][l]*d[l][k];
                              // cout<<tmp<<"\n";
                              res=min(tmp,res);
                         }
                    }
               }
          }
     }
     cout<<res;
}
 
 
 
 

























Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0;
    cin>>n;
     int a,b,f=0;
    for(int i=0;i<n;i++)
    {

        cin>>a>>b;
        if(a==b)
            cnt++;
        else
            cnt=0;
        if(cnt>=3)
            f=1;
    }

    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";



    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b,c,d;cin >> n >> a >> b >> c >> d;
  vector<ll> l(n+1),r(n+1);
  l[0]=-(n-1)*d;
  r[0]=-(n-1)*c;
  for(int i=1;i<=n-1;i++){
    l[i]=l[i-1]+c+d;
    r[i]=r[i-1]+c+d;
  }
  ll t=abs(a-b);
  for(int i=0;i<=n-1;i++){
    if(l[i]<=t&&t<=r[i]){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 8192
#include <iostream>
using namespace std;
/*
  1
4 2 3 5
  6
*/
class Dice {
private:
  int s[6];
public:
  Dice();
  Dice(int t[6]);
  int get(int pos);
  void set(int pos, int x);
  void move(char dir);
  bool operator==(Dice d);
};

Dice::Dice() {
  for (int i = 0; i < 6; i++) {
    s[i] = 0;
  }
}

Dice::Dice(int t[6]) {
  for (int i = 0; i < 6; i++) {
    s[i] = t[i];
  }
}

int Dice::get(int pos) {
  return s[pos];
}

void Dice::set(int pos, int x) {
  s[pos] = x;
}

bool Dice::operator==(Dice d) {
  for (int i = 0; i < 6; i++) {
    if (s[i] != d.get(i)) {
      return false;
    }
  }
  return true;
}

void Dice::move(char dir) {
  int t;
  switch (dir) {
    case 'N': {
      t = s[0];
      s[0] = s[1];
      s[1] = s[5];
      s[5] = s[4];
      s[4] = t;
      break;
    }
    case 'E': {
      t = s[3];
      s[3] = s[5];
      s[5] = s[2];
      s[2] = s[0];
      s[0] = t;
      break;
    }
    case 'W': {
      t = s[0];
      s[0] = s[2];
      s[2] = s[5];
      s[5] = s[3];
      s[3] = t;
      break;
    }
    case 'S': {
      t = s[4];
      s[4] = s[5];
      s[5] = s[1];
      s[1] = s[0];
      s[0] = t;
      break;
    }
  }
}

int main() {
  int t, a, b;
  char c;
  Dice d;

  for (int i = 0; i < 6; i++) {
    cin >> t;
    d.set(i, t);
  }

  cin >> t;
  while (t--) {
    cin >> a >> b;
    for (int i = 0; i < 4; i++) {
      d.move('W');
      for (int j = 0; j < 4; j++) {
        d.move('N');
        for (int k = 0; k < 4; k++) {
          d.move('W');
          if (d.get(0) != a) continue;
          if (d.get(1) != b) continue;
          cout << d.get(2) << endl;
          goto end;
        }
      }
    }
    end:;
  }

  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<string> S(N); REP(i, N) cin >> S[i];
  map<string, int> m;
  REP(i, N) {
    m[S[i]]++;
  }
  cout << "AC" << " x " << m["AC"] << endl;
  cout << "WA" << " x " << m["WA"] << endl;
  cout << "TLE" << " x " << m["TLE"] << endl;
  cout << "RE" << " x " << m["RE"] << endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
using namespace std;
typedef long long ll;
const int maxn = 205;

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

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  int ret;
  cin>>ret;
  for(int i=1;i<n;i++){
    int x;
    cin>>x;
    ret=gcd(ret,x);
  }
  cout<<ret<<endl;
  return 0;
}

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

int main(void) {
    int height[10];
    
    for(int i = 0; i < 10; ++i) {
        cin >> height[i];
    }
    sort(height, height + 10);
    
    for(int i = 0; i < 3; ++i) {
        cout << height[9 - i] << endl;
    }
}


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

using namespace std;

vector<long long> solve(vector<pair<int, int>>& a) {
  int n = a.size();
  sort(a.begin(), a.end());
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 1e18));
  vector<vector<long long>> cost(n, vector<long long>(n, 1e18));
  for (int i = 0; i < n; ++i) {
    cost[i][i] = 0;
    for (int j = i + 1; j < n; ++j) {
      long long l = 0, r = 0, dl = 0, dr = 0;
      for (int k = i; k <= j; ++k) {
        r += a[k].second;
        dr += 1ll * a[k].second * (a[k].first - a[i].first);
      }
      cost[i][j] = dl + dr;
      for (int k = i + 1; k <= j; ++k) {
        long long d = a[k].first - a[k - 1].first;
        l += a[k - 1].second;
        dl += l * d;
        r -= a[k - 1].second;
        dr -= r * d;
        cost[i][j] = min(cost[i][j], dl + dr);
      }
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= i; ++j) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1ll * abs(a[i].first) * a[i].second);
      for (int k = i; k < n; ++k) {
        dp[k + 1][j + 1] = min(dp[k + 1][j + 1], dp[i][j] + cost[i][k]);
      }
    }
  }
  return dp[n];
}

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

  int n;
  cin >> n;
  vector<int> x(n), y(n), p(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> p[i];
  }
  vector<long long> ans(n + 1, 1e18);
  for (int mask = 0; mask < (1 << n); ++mask) {
    vector<pair<int, int>> a, b;
    for (int i = 0; i < n; ++i) {
      if (mask & (1 << i)) a.emplace_back(x[i], p[i]);
      else b.emplace_back(y[i], p[i]);
    }
    auto dpa = solve(a), dpb = solve(b);
    for (int i = 0; i < dpa.size(); ++i) {
      for (int j = 0; j < dpb.size(); ++j) {
        ans[i + j] = min(ans[i + j], dpa[i] + dpb[j]);
      }
    }
  }
  for (int i = 0; i <= n; ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef complex<double> P;

int n;
double x1,Y1,x2,y2,x3,y3,x4,y4,x5,y5;

double cr(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int naibu(P a,P b,P c,P p){
	return cr(p-a,b-a)>0&&cr(p-b,c-b)>0&&cr(p-c,a-c)>0||cr(p-a,b-a)<0&&cr(p-b,c-b)<0&&cr(p-c,a-c)<0;
}

int main(){
	cin>>n;
	while(cin>>x1>>Y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5){
		P a=P(x1,Y1),b=P(x2,y2),c=P(x3,y3),d=P(x4,y4),e=P(x5,y5);
		cout<<(naibu(a,b,c,d)^naibu(a,b,c,e)?"OK":"NG")<<endl;
	}
}

Measured memory_bytes: 952
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val MOD = 1e9.toLong + 7

  val N, K = in.next().toInt
  val _A = new Array[Long](N+1)
  _A(0) = Long.MinValue
  for (i <- 1 to N) {
    _A(i) = in.next().toLong
  }


  //
  val A = _A.sorted

  val mc = new ModComb(N, MOD)

  var ans = 0L
  for (i <- 1 to N-(K-1)) {
    val num = mc.comb(N-i, K-1)

    var hoge = (-A(i))
    while (hoge < 0) {
      hoge += MOD
    }
    val piyo = hoge * num


    ans += piyo % MOD
    ans %= MOD
  }

  for (i <- (K to N).reverse) {
    val num = mc.comb(i-1, K-1)

    var hoge = A(i)
    while (hoge < 0) {
      hoge += MOD
    }
    val piyo = hoge * num

    ans += piyo % MOD
    ans %= MOD
  }

  println(ans)
}

class ModComb(maxNum: Int, mod: Long) {

  private def repeatSquares(x: Long, n: Long): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % mod, n/2)
    else
      (x * repeatSquares(x*x % mod, n/2)) % mod
  }

  private val fact = new Array[Long](maxNum + 1)

  fact(0) = 1
  for (i <- 1 to maxNum)
    fact(i) = (i * fact(i-1)) % mod

  private val factInv = new Array[Long](maxNum + 1)

  factInv(maxNum) = repeatSquares(fact(maxNum), mod-2)
  for (i <- (1 to maxNum).reverse)
    factInv(i-1) = (i * factInv(i)) % mod


  // nCk
  def comb(n: Int, k: Int): Long = {
    val numer = fact(n)
    val denom = (factInv(n-k) * factInv(k)) % mod

    (numer * denom) % mod
  }

}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

int main() {

  int k,s;
  cin >> k >> s;
  int x,y,z,ans=0;
  for(x=0;x<=k;x++){
      if(x>s){
          break;
      }
      for(y=0;y<=k;y++){
          if(s-x-y<0){
              break;
          }else if(s-x-y<=k){
              ans++;
          }
      }
  }
  cout << ans << endl;

}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    visited=[1]+[0]*(n-1)
    vil=[0]*(n*10)

    nowi=1
    cnt=1
    while True:
        nxti=A[nowi-1]-1 #0ind
        cnt+=1
        if visited[nxti]==0:
            visited[nxti]=cnt
            vil[cnt-1]=nxti
            nowi=nxti+1 # 1ind
        else:
            prime=visited[nxti]
            loop=cnt-visited[nxti]
            break
    
    if k<=prime:
        print(vil[k]+1)
    else:
        mod=((k+1)-(prime-1))%loop
        if mod==0:
            mod=loop
        print(vil[prime-2+mod]+1)
    

    

    
resolve()

Measured memory_bytes: 108412
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll n;cin>>n;
    ll maxi=0;
    ll a[n];
    map<ll,ll>mp;
    f(i,0,n){cin>>a[i];maxi=max(maxi,a[i]);mp[a[i]]++;}
    bool visited[maxi+1];
    memset(visited,0,sizeof visited);
    f(i,1,maxi+1){
        if(mp[i]){
            if(mp[i]>=2)visited[i]=1;
            for(ll j=2;i*j<=maxi;j++)visited[i*j]=1;
        }
    }
    ll ans=0;
    f(i,0,n){
        ans+=!visited[a[i]];
    }
    cout<<ans;
    return 0;  
} 





Measured memory_bytes: 68652