akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], right[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, A - 1);
		if (sum_BIT(BIT, B) == tmp + B - A + 1) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		L = A;
		R = B++;
		while (L < R) {
			M = (L + R) / 2;
			if (sum_BIT(BIT, M) < tmp + M - A + 1) R = M;
			else L = M + 1;
		}
		
		left[B] = left[L];
		right[left[L]] = B;
		if (s[B] < 0) add_BIT(W, BIT, B, -1);
		for (j = L; j < B; j = right[j]) {
			s[B] = (s[j] > s[B])? s[j]: s[B];
			s[j] = -1;
			add_BIT(W, BIT, j, 1);
		}
		if (j != B) {
			left[j] = B;
			right[B] = j;
		}
		if (B <= W) {
			d.key = B - s[B];
			d.id = B;
			push(d, &h);
		}
		
		while (h.size > 0 && s[h.obj[1].id] < h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6652
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define li long long int
#define FOR(i, a, b) for (li (i) = (a) ; (i) < (b) ; ++(i))
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    li sum[100100];
    REP(i, 100100) { sum[i] = 0; }
    
    li Q;
    cin >> Q;
    li l[Q + 100];
    li r[Q + 100];
    FOR(i, 0, Q) { cin >> l[i] >> r[i]; }

    vector<li> primeNumber; // 素数配列
    primeNumber.push_back(2);
    FOR(i, 2, 100100) {
        bool isPrimeNumber = true;
        FOR(k, 0, primeNumber.size()) {
            if ((i % primeNumber[k]) == 0) {
                // 今まで見つかった素数で割り切れた場合は素数ではない
                isPrimeNumber = false;
                break;
            }
        }
        if (isPrimeNumber) {
            // 今までの素数で割り切れなければ素数であるため素数配列に追加する
            primeNumber.push_back(i);
        }
    }
    
    // 先に累積和をすべて出し、その累積和の差分で各個数を求める
    FOR(i, 1, 100100) {
        sum[i] = sum[i - 1];
        bool found = find(primeNumber.begin(), primeNumber.end(), i) != primeNumber.end();
        if (!found) { continue; } // iが素数でなければ飛ばす

        bool found_second = find(primeNumber.begin(), primeNumber.end(), (i+1)/2) != primeNumber.end();
        if (found_second) { sum[i] += 1; }
    } 

    FOR(i, 0 , Q) { cout << sum[r[i]] - sum[l[i] - 1] << endl; }
    return 0;
}


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

s = ['#' * (W + 2)] + ['#' + input() + '#' for i in range(H)] + ['#' * (W + 2)]

# m : そこにたどり着くために必要な白マスの数
m = [[-1 for x in range(W+2)] for y in range(H+2)]
m[1][1] = 1


from collections import deque
qx = deque([1])
qy = deque([1])

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


while len(qx) > 0:
    x, y = qx.popleft(), qy.popleft()
    for d in range(4):
        nx, ny = x + dx[d], y + dy[d]
        # 訪れたことがあるなら調べない
        if m[ny][nx] != -1: continue

        if s[ny][nx] == '.':
            qx.append(nx), qy.append(ny)
            m[ny][nx] = m[y][x] + 1

if m[H][W] == -1:
    print(-1)

else:
    print(sum([c.count('.') for c in s]) - m[H][W])


Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;

    cout << (n-1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
i,m,h,t,a;
main(){
    char s[201];
    for(;scanf("%s%d",s,&m),s[0]!='-';puts("")){
        a=strlen(s);
        for(i=t=0;i<m;scanf("%d",&h),t+=h,i++);
        for(i=0;i<a;printf("%c",s[(t+i++)%a]));
    }
}

Measured memory_bytes: 1792
from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect


def main():
    s = int(input())
    n = ceil(sqrt(s))
    b = n**2
    sm = n*(n-1)


    rest = 0

    if sm >= s:
        x1 = n
        y2 = n-1
        rest = sm-s
    else:
        x1 = n
        y2 = n
        rest = b-s
    

    print(0,0,x1,rest,1,y2)



main()

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi x(n);
  rep(i, n) cin >> x[i];
  ll ans = LINF;
  rep(i, 101) {
    ll c = 0;
    rep(j, n) {
      c += (x[j] - i) * (x[j] - i);
    }
    mins(ans, c);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main() {
	int R,G,B,n;cin>>R>>G>>B>>n;

	int ans=0;
	for(int r=0; r*R<=n;r++){
	for(int g=0; g*G+r*R<=n;g++){
		if((n-r*R-g*G)%B==0 && n-r*R-g*G>=0){
			//cout<<r<<"#"<<g<<"#"<<n-r*R-g*G<<endl;
			ans++;
		}
	}}

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



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

void read(int &x){
    char c; x=0;
    for (c=getchar(); c<48;)c=getchar();
    for (; c>=48; c=getchar())x=(x<<3)+(x<<1)+(c^48);
}

long long f[60][3];
int n,p,i,x;

int main(){
	read(n); read(p);
	f[0][0]=1; 
	for (i=1; i<=n; i++){
		read(x);
		if (x%2==1){
			f[i][0]=f[i-1][1]+f[i-1][0];
			f[i][1]=f[i-1][0]+f[i-1][1];			
		}
		else {
			f[i][1]=f[i-1][1]+f[i-1][1];
			f[i][0]=f[i-1][0]+f[i-1][0];			
		}
	}
	printf("%lld\n",f[n][p]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <sstream>

#include <array>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>

#include <algorithm>
#include <numeric>

#include <cstdint>
#include <cctype>
#include <cmath>
#include <cassert>
#include <ctime>
#include <chrono>
#include <climits>
#include <fstream>
#include <ios>

#include <iterator>
#include <utility>
#include <complex>
#include <memory>

using namespace std;

//#define MY_DEBUG

#define DESYNC_IO


#ifdef MY_DEBUG
#define DEBUG_STDERR(x) cerr << x << endl;
#else
#define DEBUG_STDERR(x)
#endif // MY_DEBUG


void Solve() {
    int n, m;
    cin >> n >> m;
    vector<int> year(m);
    unordered_map<int, vector<int>> ump;
    for (int i = 0; i < m; ++i) {
        int p, y;
        cin >> p >> y;
        year[i] = y;
        ump[p].emplace_back(y);
    }
    for (auto& item : ump) {
        sort(begin(item.second), end(item.second));
    }
    unordered_map<int, string> ids;
    for (const auto& item : ump) {
        int id{ 1 };
        string p{ to_string(item.first) };
        if (p.length() < 6) {
            p = string(6 - p.length(), '0') + p;
        }
        for (int y : item.second) {
            string temp{ to_string(id) };
            ++id;
            if (temp.length() < 6) {
                temp = string(6 - temp.length(), '0') + temp;
            }
            ids[y] = p + temp;
        }
    }
    for (int y : year) {
        cout << ids[y] << '\n';
    }
}

void Run() {
#ifdef MY_DEBUG
    chrono::high_resolution_clock::time_point start{ chrono::high_resolution_clock::now() };
#endif // MY_DEBUG

#ifdef DESYNC_IO
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif // DESYNC_IO

#ifdef MY_DEBUG
    ifstream input{ "input.txt" };
    cin.rdbuf(input.rdbuf());
#endif // MY_DEBUG

    Solve();

#ifdef MY_DEBUG
    auto dt{ std::chrono::high_resolution_clock::now() - start };
    auto dt_millisec{ std::chrono::duration_cast<std::chrono::milliseconds>(dt) };
#endif // MY_DEBUG
    DEBUG_STDERR("\ntime spent: " << dt_millisec.count() << " miilliseconds");
}

int main() {
    Run();
    return 0;
}

Measured memory_bytes: 19492
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	int n;
	cin >> n;
	vi d(n, 0);
	int x;
	forn(i, n-1) cin >> x, d[x-1]++;
	forn(i, n) cout << d[i] << '\n';
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3992
#入力。参加者数N, 初期得点K ,正解数Q
N, K, Q = list(map(int,input().split()))
#入力。正解した人の番号A[i]
A = [None for _ in range(Q)]
for i in range(Q):
  A[i] = int(input())
#初期得点(hp)をリスト化。
hp = [K for _ in range(N)]
#まず他の人への攻撃力at(各人の正解数)を記録。
at = [0 for _ in range(N)]
#正解した人の攻撃力+1。
for i in range(Q):
  j = A[i]
  at[j-1] += 1
#攻撃力分の数を一度全員のhpからマイナスする。
s = sum(at)
for i in range(N):
  hp[i] -= s
#各々自分の攻撃力分は本来受けないはずのダメージなのでhpに戻す(足す)。
for i in range(N):
  hp[i] += at[i]
#結果(生き残り判定)
for i in range(N):
  if hp[i] > 0:
    print('Yes')
  else:
    print('No')

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int cnt = 0;

    rep(i, 3) {
        char c;
        cin >> c;
        if (c == '1') cnt++;
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
class UnionFind {
public:
	int cNum;//要素数
	vector<int> parent;
	vector<int> count;
	vector< vector<int> > GList;
	UnionFind(int n) {
		cNum = n;
		parent = vector<int>(n);
		count = vector<int>(n, 1);
		GList.resize(n);
		for (int i = 0; i < n; ++i) {
			parent[i] = i;
			GList[i].push_back(i);
		}
	}
	int find(int x) {
		if (parent[x] == x) { return x; }
		return parent[x] = find(parent[x]);
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int Count(int x) { return count[find(x)]; }
	void add(int x, int y) {//union
		x = find(x);
		y = find(y);
		if (x == y)return;
		parent[x] = y;

		count[y] += count[x];
		if (GList[y].size() < GList[x].size()) {
			swap(GList[x], GList[y]);
		}
		GList[y].insert(GList[y].end(),
			GList[x].begin(), GList[x].end());
	}
};

void solve() {
	int N, M, K;
	cin >> N >> M >> K;
	vector<int> ans(N, -1);
	UnionFind uf(N);
	for (int i = 0; i < M; ++i) {
		int A, B;
		cin >> A >> B;
		--A; --B;
		uf.add(A, B);
		ans[A]--;
		ans[B]--;
	}
	for (int i = 0; i < N; ++i) {
		ans[i] += uf.Count(i);
	}
	for (int i = 0; i < K; ++i) {
		int C, D;
		cin >> C >> D;
		--C; --D;
		if (uf.same(C, D) == true) {
			ans[C]--;
			ans[D]--;
		}
	}
	for (int i = 0; i < N; ++i) {
		if (i)cout << " ";
		cout << ans[i];
	}
	cout << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vec<PII> x(n);
    rep(i,n) {
        int p; cin >> p;
        x[i] = make_pair(p,i);
    }
    sort(all(x));
    // for(int i = 0; i < n; ++i) {
    //     debug(x[i].first);
    //     debug(x[i].second);
    // }

    vi ans(n);
    for(int j = 0; j < n; ++j) {
        int p, i;
        tie(p,i) = x[j];
        if(p<=x[(n/2)-1].first) {
            int q = n/2;
            ans[i] = x[q].first;
        }
        else {
            int q = n/2-1;
            ans[i] = x[q].first;
        }
    }

    for(auto i : ans) cout << i << '\n';
}

Measured memory_bytes: 4608
<?php
$r = 0;
list($n,$m) = explode(" ",trim(fgets(STDIN)));
for($i = 0; $i < $n; $i++){
    $A[$i] = explode(" ",trim(fgets(STDIN)));
}
for($i = 0; $i < $m; $i++){
    $b[$i] = trim(fgets(STDIN));
}
foreach($A as $key => $val){
    $r = 0;
    for($i = 0; $i < $m; $i++){
        $r += ($A[$key][$i] * $b[$i]);
    }
    echo $r."\n";
}

Measured memory_bytes: 17240
import sys
input = sys.stdin.readline

N, M = [int(x) for x in input().split()]
G = [[] for _ in range(N+1)]

for _ in range(M):
    a, b = [int(x) for x in input().split()]
    G[a].append(b)
    G[b].append(a)
    
ans = 0
for _ in range(M):
    for i in range(1, N + 1):
        if len(G[i]) == 1:
            tmp = G[i][0]
            G[i].remove(tmp)
            G[tmp].remove(i)
            ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int const md = 1000003;
int fc[md];

int pw(int a, int p){
	int an = 1;
	while (p){
		if (p & 1)an = (ll)an * a % md;
		a = (ll)a * a % md;
		p >>= 1;
	}
	return an;
}

int go(int d, int n) { return (ll)fc[n] * pw(d, n) % md; }

int solve(){
	int x, d, n;
	scanf("%d%d%d", &x, &d, &n);
	if (x == 0)return 0;
	if (d == 0)return pw(x, n);
	if (n >= md)return 0;
	int ed = (x + (ll)d * (n - 1)) % md;
	if (ed == 0)return 0;
	int i = (ll)ed * pw(d, md - 2) % md;
	if (i < n)return 0;
	int an = (ll)go(d, i) * pw(go(d, i - n), md - 2) % md;
	return an;
}

int main(){
	fc[0] = 1;
	f(i, 1, md)fc[i] = (ll)fc[i - 1] * i % md;
	int q;
	scanf("%d", &q);
	while (q--)printf("%d\n", solve());
}

Measured memory_bytes: 4736
import java.io.*;
import java.util.*;
public class Main{
   
     public static void main(String []args){
       Scanner s=new Scanner(System.in);
       long a[]=new long [3];
       for(int i=0;i<3;i++)
       a[i]=s.nextLong();
       Arrays.sort(a);
       boolean flag=false;
       for(int i=0;i<2;i++)
       {if(a[i]==a[i+1])
       {flag=true;
       break;}}
       if(a[0]==a[1] && a[1]==a[2])
       flag=false;
       if(flag)
       System.out.println("Yes");
       else
       System.out.println("No");}}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  ll ans = 1e12;
  FOR(i,1,sqrt(N)+1) {
    if (N % i == 0) {
      ll j = N / i;
      ans = min(ans, i + j);
    }
  }
  cout << ans - 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;

int n;

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

Measured memory_bytes: 256
#include<iostream>
#include<boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
using namespace std;

int main()
{
  const int size = 100001;
  int n;
  cin >> n;
 
  cpp_int *ar = new cpp_int[n];
  cpp_int sum = 0;
  
 for (int i=0; i<n; ++i){
   cpp_int a;
   cin >> a;
   ar[i] = a;
   sum = sum ^ a;
 }

  for (int i=0; i<n; ++i){
   if (i!= 0) cout << " ";
   cout << (sum ^ ar[i]);
 }
  
  cout << endl ;
  
  return 0;
}


Measured memory_bytes: 9408
#include <bits/stdc++.h>
int main()
{
	int H,N;
  	int a;
  scanf("%d %d",&H,&N);
  for(int i=0;i<N;i++){
    scanf("%d",&a);
    H-=a;
  }
  printf("%s",(H>0)?"No":"Yes");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m,n,s1,s2,d1,d2;
    cin>>m>>n>>s1>>s2>>d1>>d2;
    vector<string> s;
    s1--;
    s2--;
    d1--;
    d2--;
    for(int i=0;i<m;i++){
        string x;
        cin>>x;
        s.push_back(x);
    }
    //   for(int i=0;i<m;i++){
    //       cout<<s[i]<<endl;}
    
    deque <pair<pair<int,int>,int>> d;
    int dist[m][n];
    bool vis[m][n];
    for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
    {
        dist[i][j]=INT_MAX;
        vis[i][j]={false};
    }
    dist[s1][s2]=0;
    d.push_back({{s1,s2},0});
    int temp[]={-2,-1,0,1,2};
    while(!d.empty()){
        int i=d.front().first.first;
        int j=d.front().first.second;
       
        int val=d.front().second;
        // cout<<"exploring parent"<<i<<" "<<j<<" "<<val<<endl;
        d.pop_front();
        
        if(!vis[i][j]){
            vis[i][j]=true;
           // cout<<"hello"<<endl;
           
            for(int i1=0;i1<5;i1++){
                for(int j1=0;j1<5;j1++){
                    int x=i+temp[i1];
                    int y=j+temp[j1];
                    //cout<<"i1="<<i1<<"j1="<<j1<<endl;
                    //cout<<"x= "<<x<<"y= "<<y<<"i1="<<i1<<"j1="<<j1<<"temp[i1],j1="<<temp[i1]<<" "<<temp[j1]<<"before"<<endl;
                    if(x>=0 && x<m &&y >=0 &&y<n &&(temp[i1]!=0 || temp[j1]!=0)){
                       // cout<<"i1!=0 || j1!=0="<<(i1!=0 || j1!=0)<<" "<<i1<<" "<<j1<<endl;
                        if(s[x][y]=='.' ){
                         //  cout<<"x="<<x<<"y="<<y<<endl;
                            if((temp[i1]==1&&temp[j1]==0)||(temp[i1]==0&&temp[j1]==1)||(temp[i1]==-1 &&temp[j1]==0)||(temp[i1]==0&&temp[j1]==-1)){
                                if(dist[i][j]<dist[x][y]){
                                    dist[x][y]=dist[i][j];
                                 //   cout<<"pushing"<<x<<" "<<y<<endl;
                                    d.push_front({{x,y},dist[x][y]});
                                }
                            }
                            else{
                                if(dist[i][j]+1<dist[x][y]){
                                    dist[x][y]=dist[i][j]+1;
                                   // cout<<"pushing"<<x<<" "<<y<<endl;
                                    d.push_back({{x,y},dist[x][y]});
                                }
                            }
                        }
                    }
                }
            }
        }
    }
 //   cout<<dist[d1][d2];
    cout<<((dist[d1][d2]==INT_MAX)?-1:dist[d1][d2])<<endl;
    
}

Measured memory_bytes: 9636
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
cnt=[0]*(n)
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    cnt[i+1]=cnt[i]+1
  else:
    cnt[i+1]=cnt[i]
for l,r in l:
  print(cnt[r-1]-cnt[l-1])

Measured memory_bytes: 30656
//==========================================c#
/* ===========================================
// null
// 
// 
=========================================== */
using System; //Console, IComparable
using System.IO; //StreamWriter 
using System.Linq; //Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; //List<T>

class Program { 
    static void Main() { 
        StreamWriter so = new StreamWriter(Console.OpenStandardOutput());
        IOC io = new IOC();
        
        var n = io._int;
        var hash = new Dictionary<string, int>();
        
        for (int i = 0; i < n; i++){
            var s = io._string;
            if (!hash.ContainsKey(s)){
                hash.Add(s, 1);
            }
            else{
                hash[s]++;
            }
        }
        
        var max_cnt = hash.Values.Max();
        
        var ans = new List<string>();
        foreach(var fd in hash){
            if (fd.Value == max_cnt){
                ans.Add(fd.Key);
            }
        }
        
        ans.Sort(StringComparer.Ordinal);
        
        foreach(var fd in ans){
            so.WriteLine(fd);
        }
        so.Close();
    } 
}

public class IOC{
    public int _int{get{return int.Parse(Console.ReadLine());}}
    public int[] _inta{get{return Array.ConvertAll(Console.ReadLine().Split(), int.Parse);}}
    public long _long{get{return long.Parse(Console.ReadLine());}}
    public long[] _longa{get{return Array.ConvertAll(Console.ReadLine().Split(), long.Parse);}}
    public string _string{get{return Console.ReadLine();}}
    public string[] _stringa{get{return (Console.ReadLine().Split());}}
    public double _double{get{return double.Parse(Console.ReadLine());}}
    public double[] _doublea{get{return Array.ConvertAll(Console.ReadLine().Split(), double.Parse);}}
}

/* ===========================================
            int n = int.Parse(Console.ReadLine());

for(int i = 0; i < n; i++){
                int sum = Console.ReadLine().Split().Select(int.Parse).Sum();
                so.WriteLine(sum.ToString());
            }
            so.Close();
=========================================== */



Measured memory_bytes: 38364
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int main() {
	int N,a,b,c,d,b2,c2;
	cin >> N;
	a = N / 1000;
	b = (N - a * 1000) / 100;
	c = (N - a * 1000 - b * 100) / 10;
	d = N % 10;
	b2 = b;
	c2 = c;
	if ((a == b&&b == c) || (b2 == c2&&c2 == d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

struct team_t {
  array<uint32_t, 11> times;
  array<bool, 11> corrects;
  uint32_t id;
  team_t() : times({}), corrects({}), id(0) {}

  uint32_t get_corrects() {
    uint32_t count = 0;
    for (uint32_t i = 0; i < corrects.size(); i++) {
      if (corrects[i]) {
        count++;
      }
    }
    return count++;
  }

  uint32_t get_penalty() {
    uint32_t penalty = 0;
    for (uint32_t i = 0; i < corrects.size(); i++) {
      if (corrects[i]) {
        penalty += times[i];
      }
    }
    return penalty;
  }

  bool operator==(team_t &team) {
    if (this->get_corrects() == team.get_corrects()) {
      return this->get_penalty() == team.get_penalty();
    }
    return false;
  }

  bool operator<(team_t &team) {
    if (this->get_corrects() == team.get_corrects()) {
      if (this->get_penalty() == team.get_penalty()) {
        return id > team.id;
      } else {
        return this->get_penalty() < team.get_penalty();
      }
    } else {
      return team.get_corrects() < this->get_corrects();
    }
  }

  void correct(uint32_t pid, uint32_t time) {
    corrects[pid] = true;
    times[pid] += time;
  }

  void println() {
    cout << id << " " << get_corrects() << " " << get_penalty() << endl;
  }

  void wrong(uint32_t pid) { times[pid] += 20; }
};

int32_t main() {
  while (true) {
    uint32_t M, T, P, R;
    cin >> M >> T >> P >> R;
    if (M == 0) break;

    vector<team_t> teams(T + 1);
    for (uint32_t i = 0; i < teams.size(); i++) {
      teams[i].id = i;
    }

    for (uint32_t i = 0; i < R; i++) {
      uint32_t m, t, p, j;
      cin >> m >> t >> p >> j;
      if (j == 0) {
        teams[t].correct(p, m);
      } else {
        teams[t].wrong(p);
      }
    }

    sort(teams.begin() + 1, teams.begin() + T + 1);

    for (uint32_t i = 1; i < T; i++) {
      cout << teams[i].id;
      if (teams[i] == teams[i + 1]) {
        cout << "=";
      } else {
        cout << ",";
      }
    }
    cout << teams[T].id;
    cout << endl;
  }

  return 0;
}

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

typedef long long int LLI;
LLI A;
LLI B;
LLI P;
LLI N;
LLI BIT[114514];
LLI ten[114];

void add(LLI k, LLI x) {
  k -= A;
  k++;
  while (k <= N) {
    BIT[k] += x;
    BIT[k] %= P;
    k += k&-k;
  }
}

LLI getsum(LLI k) {
  LLI ret = 0;
  k -= A;
  k++;
  while (k > 0) {
    ret += BIT[k];
    ret %= P;
    k -= k&-k;
  }
  return ret;
}

int main() {
  ten[0] = 1;
  for (int i=1; i<14; i++) {
    ten[i] = ten[i-1]*10;
  }

  while (1) {
    scanf("%lld%lld%lld", &A, &B, &P);
    if ((A|B|P) == 0) return 0;

    N = B-A+1;
    fill(BIT, BIT+N+10, 0);
    LLI ans = 0;
    for (LLI k=A; k<=B; k++) {
      add(k, 1);
      add(k+1, -1);
      LLI dpk = getsum(k);
      //printf("dp[%lld]: %lld\n", k, dpk);
      ans += dpk;
      ans %= P;

      LLI k_ = k;
      int d = 0;
      while (k_ > 0) {
        k_ /= 10;
        d++;
      }
      
      for (LLI i=0; ; i++) {
        LLI lim = min(ten[d+i]-1, B);
        add(k*ten[i], dpk);
        add(lim+1, -dpk);
        if (lim >= B) break;
      }
    }

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

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

using namespace std;

vector<int> pierwsze;
int euklides[4010];
set<long long> liczby;
map<long long, int> ile;

void init() {
    for( int i=2; i<=4000; i++ ) {
        if( !euklides[i] ) {
            pierwsze.push_back( i );
            for( int j=i*i; j<=4000; j+=i ) {
                euklides[j] = true;
            }
        }
    }
}

void skroc( long long & x ) {
    long long c;
    for( int & i : pierwsze ) {
        c = (long long)i*i*i;
        while( x%c == 0 ) {
            x /= c;
        }
    }
}

void stworz_b( long long & a, long long & b ) {
    for( int & i : pierwsze ) {
        if( a%i == 0 ) {
            b*=i;
            a/=i;
            if( a%i == 0 ) {
                a/=i;
            } else {
                b*=i;
            }
        }
    }
    if( b > 10000000000ll ) {
        b = 0;
        return;
    }
    if( a<=100000 ) {
        b *= a;
        if( b > 10000000000ll ) {
            b = 0;
            return;
        }
        b *= a;
        if( b > 10000000000ll ) {
            b = 0;
            return;
        }
    } else {
        long long c = sqrt( a );
        if( c*c != a ) {
            b = 0;
            return;
        } else {
            b *= c;
            if( b > 10000000000ll ) {
                b = 0;
                return;
            }
        }
    }
}

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

    init();
    int n;
    cin >> n;
    long long a;
    for( int i=0; i<n; i++ ) {
        cin >> a;
        skroc( a );
        liczby.insert( a );
        ile[a]++;
    }
    long long b;
    int wy=0;
    if( *liczby.begin() == 1 ) {
        wy++;
        liczby.erase( liczby.begin() );
    }
    while( liczby.size() ) {
        a = *liczby.begin();
        b=1;
        stworz_b( a, b );
        a = *liczby.begin();
        auto it = liczby.find( b );
        if( it == liczby.end() ) {
            wy += ile[a];
        } else {
            wy += max( ile[a], ile[*it] );
            liczby.erase( it );
        }
        liczby.erase( liczby.begin() );
    }
    cout << wy;
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll x,y,z;
  cin >> x >> y >> z;
  ll d=min(x,z);
  x-=d;
  z-=d;
  d=min(y,z);
  y-=d;
  z-=d;
  pr(x,y);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

using Edges = vector<pair<int, LL>>;
using Graph = vector<Edges>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const LL INF = (1LL << 60);
vector<LL> dijkstra(const Graph &g, int n, int s) {
    vector<LL> dist(n, INF);

    min_priority_queue<pair<LL, int>> que;
    dist[s] = 0;
    que.push({0, s});
    while (not que.empty()) {
        auto dv = que.top(); que.pop();
        LL v = dv.second;
        int d = dv.first;

        if (dist[v] < d) continue;

        for (auto e : g[v]) {
            if (dist[e.first] > dist[v] + e.second) {
                dist[e.first] = dist[v] + e.second;
                que.push({ dist[e.first], e.first });
            }
        }
    }

    return dist;
}
int main() {
    int n, m, s, t; cin >> n >> m >> s >> t;
    --s; --t;
    Graph graph_yen(n), graph_snu(n);
    rep(i, m) {
        int u, v; LL a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        graph_yen[u].push_back(make_pair(v, a));
        graph_yen[v].push_back(make_pair(u, a));
        graph_snu[u].push_back(make_pair(v, b));
        graph_snu[v].push_back(make_pair(u, b));
    }

    auto dist_yen = dijkstra(graph_yen, n, s);
    auto dist_snu = dijkstra(graph_snu, n, t);

    vector<LL> d(n, 0);
    rep(i, n) {
        d[i] = dist_yen[i] + dist_snu[i];
    }
    for (int i = n - 2; i >= 0; i--) {
        d[i] = min(d[i], d[i + 1]);
    }

    LL maxi = 1e15;
    rep(i, n) d[i] = maxi - d[i];
    rep(i, n) cout << d[i] << endl;
    return 0;
}


Measured memory_bytes: 19016
#include <bits/stdc++.h>
using namespace std;
int n,a[42];
long long s(int x,long long ans)
{
	if(x==n)return ans;
	long long b=0;
	long long s1=0;
	for(int i=x;i<n;i++)
	{
		b=b*10+a[i];
		s1=s1+s(i+1,ans+b);
	}
	return s1;
}
int main()
{
	int c=getchar();
	while(c<=32)
	{
		c=getchar(); 
	}
	while(c>32)
	{
		a[n++]=c-'0'; 
		c=getchar(); 
	}
	cout<<s(0,0)<<'\n';
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

L = []
for i in range(m):
    l, r = map(int, input().split())
    L.append((l, r))
    
ans_min = 0
ans_max = 10 ** 7
for i in L:
    ans_min = max(i[0], ans_min)
    ans_max = min(i[1], ans_max)

ans = min(ans_max-ans_min+1, n)
print(max(ans, 0))

Measured memory_bytes: 16592
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"
#include <time.h>


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int
#define  NN cout << "No"<<endl;
#define  YY cout << "Yes"<<endl;

int x, n,xx[100000];

int gcd(int n, int m) {
	if (m != 0) {
		gcd(m, n%m);
	}
	else {
		return abs(n);
	}
}


int main() {
	cin >> n>>x;
	fori0(n) {
		cin >> xx[i];
		xx[i] -= x;
	}
	int c = xx[0];
	fori0(n) {
		c = gcd(c, xx[i]);
		
	}
	cout << c;
	//system("pause");
	return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    ll n;
    ll ans=0;
    cin>>n;
    map<ll,ll> m;
    for(ll i=2;i<=1000000;){
        if(n%i==0){
            m[i]++;
            n/=i;
        }
        else{
            i++;
        }
    }
    if(n>2) m[n]++;
    for(auto itr=m.begin();itr!=m.end();itr++){
        for(ll i=1;true;i++){ 
            if(i<=m[itr->first]){
                ans++;
                m[itr->first]-=i;
            }
            else{
                break;
            }
        }
    }
    cout<<ans<<endl;
}

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

#define int long long
#define rep(a,b,c) for(int a=b;a<c;a++)

using namespace std;

int waku[1003][1003][3];

void fir(){
    for(int i=0;i<1003;i++){
        for(int j=0;j<1003;j++){
            for(int k=0;k<3;k++){
                waku[i][j][k]=0;
            }
        }
    }
}

signed main()
{
    char s;
    int w,h,n;
    fir();
    cin >> h >> w >> n;
    rep(i,1,h+1){
        rep(j,1,w+1){
            cin >> s;
            for(int k=0;k<3;k++)waku[i][j][k]+=(waku[i-1][j][k]+waku[i][j-1][k]-waku[i-1][j-1][k]);
            if(s=='J'){
                waku[i][j][0]++;
            }else if(s=='O'){
                waku[i][j][1]++;
            }else{
                waku[i][j][2]++;
            }
        }
    }
    /**
        debag
    rep(i,1,h+1){
        rep(j,1,w+1){
            cout << waku[i][j][0] << " ";
        }
        cout << endl;
    }
    */
    int ans[3];
    int lw,lh,rw,rh;
    rep(i,0,n){
        cin >> lw >> lh >> rw >> rh;
        rep(j,0,3){
            ans[j] = waku[rw][rh][j]+waku[lw-1][lh-1][j]-waku[rw][lh-1][j]-waku[lw-1][rh][j];
        }
        cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
    }
    return 0;
}

Measured memory_bytes: 26648
import java.util.*;
 
public class Main{
	
	static int gcd(int a, int b){
		if(a<b){
			int temp= a;
			a=b;
			b=temp;
		}
		if(b==0) return a;
		return gcd(a%b,b);
	}
	
	
	public static void main(String []args){
	    Scanner sc= new Scanner(System.in);
	    
		int n=sc.nextInt();
		int[] A = new int [n];
		int[] L = new int [n];
		int[] R = new int [n];
		
		for(int i=0;i<n; i++){
		    A[i]=sc.nextInt();
		}
		
        // gcd(x,y)において結合即が成り立つため左右それぞれからのgcdを計算しておく(あとで利用するため)
		L[0]=0;
		R[0]=0;
		for (int i=1; i<n; i++){
		    L[i]=gcd(L[i-1],A[i-1]);
		    R[i]=gcd(R[i-1],A[n-i]);
		}
		
        // どれを入れ替えると最大になるか確認していく
		int gcd=0;
		for (int i=0; i<n; i++){
		    int temp=gcd(L[i], R[n-i-1]);
		    
		    if(gcd<temp){
		        gcd=temp;
		    }
		    
		}
		System.out.println(gcd);
		
    }
}


Measured memory_bytes: 51876
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = (60 * h2 + m2) - (60 * h1 + m1) - k;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
import itertools
n,m,x = map(int, input().split())
book = []
for i in range(n):
  b = list(map(int, input().split()))
  book.append(b)
book = sorted(book, key=lambda x:x[0])
junretu = itertools.permutations(range(n))
max_ = 2**n
min_nedan = 10**9
for j in range(max_):
  bit = format(j, "0"+str(n)+"b")
  count_list = [0]*m
  nedan = 0
  for b in range(n):
    if bit[b] == "1":
      naiyou = book[b]
      nedan += naiyou[0]
      for i in range(1, m+1):
        count_list[i-1] += naiyou[i]
  if min(count_list)>=x:
    if nedan < min_nedan:
      min_nedan = nedan
if min_nedan == 10**9:
  print(-1)
else:
  print(min_nedan)


Measured memory_bytes: 68736
// 2015/06/30 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int N, M, p;
	cin >> N >> M >> p;

	int d[10001];
	d[0] = p;			// 配列dに出発駅pも含める

	for(int i=1; i<=M; i++){
		cin >> d[i];
	}

	sort(d, d+M+1);			// ソート

	int c_min = N-1;

	for(int i=0; i<M+1; i++){
		int q = d[i];				// 折り返し駅q
		int r1 = d[(i-1+M+1)%(M+1)];		// qの1つ前の駅r1
		int r2 = d[(i+1)%(M+1)];		// qの1つ後の駅r2

		int c1 = ((p-q+N)%N)*2+(r1-p+N)%N;	// 先に左回りのコストc1
		int c2 = ((q-p+N)%N)*2+(p-r2+N)%N;	// 先に右回りのコストc2

		c_min = min(c_min, min(c1, c2));	// c_min, c1, c2の最小値
	}

	cout << c_min*100 << endl;

	return 0;
}

Measured memory_bytes: 1212
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<u64>();
    let (_, k) = (v[0], v[1]);
    let a = read_vec::<u64>();

    let mut k_digit: usize = 0;
    let mut max_elem = k;
    while max_elem != 0 {
        k_digit += 1;
        max_elem /= 2;
    }
    let k_digit = k_digit;
    // println!("{}", k_digit);

    let mut digit_nums = vec![0u64; k_digit];

    for &num in a.iter() {
        let mut num = num;
        for i in 0..k_digit {
            if num % 2 == 1 {
                digit_nums[i] += 1;
            }
            num /= 2;
        }
    }
    // println!("{:?}", &digit_nums);
    let mut current_k = 0u64;
    for ki in (0..k_digit).rev() {
        if (1 << ki) + current_k > k {
            continue;
        }
        if a.len() as u64 - digit_nums[ki] > digit_nums[ki] {
            current_k += 1 << ki;
        }
    }

    let mut ans = 0;
    for num in a {
        ans += current_k ^ num;
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
n = int(input())
t_list = [int(input()) for nesya in range(5)]
z = min(t_list)
for t in t_list:
  if z == t:
    if n%t == 0:
      t_ = n//t
    else:
      t_ = n//t+1
    print(t_ + 4)
    break

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

int main () {
  int m,n,a,b;
  cin>>m>>n>>a>>b;
  if(m<=n){
    cout<<m*a<<endl;
  }
  else{
    int sum = m-n;
    cout<<n*a + sum*b<<endl;
  }
  return 0;
}


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

Measured memory_bytes: 23892
local a,b,c = io.read("*l"),{},0
for v in io.read():gmatch("%d+") do
  table.insert(b,tonumber(v))
end
table.sort(b)
c = b[1]
for i = 1 , a - 1 do
  c = (c+b[i+1])/2
end
print(c)

Measured memory_bytes: 1008
// https://atcoder.jp/contests/abc142/tasks/abc142_b

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n' 

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

    int N, K;
    cin >> N >> K;

    int ans = 0;
    for(int i = 1; i <= N; i++) {
        int h;
        cin >> h;

        ans += (h >= K);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define rep(i, a, b) for(ll i=a; i<b; i++)
#define rer(i, a, b) for(ll i=a-1; i>=b; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n;

signed main(){
    int a, b, k; cin >> a >> b >> k;
    vector<int> v;
    rep(i, 1, 101){
        if(a%i==0 && b%i==0) v.pb(i);
    }
    reverse(all(v));
    cout << v[k-1] << endl;
    return 0;
}

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


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;


lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli A, B, C, D;

	cin >> A >> B >> C >> D;

	lli x, y;

	lli E = C * (D / extgcd(C, D, x, y));

	auto f = [=](lli a) {return a - a / C - a / D + a / E; };

	COUT(f(B) - f(A - 1));

	return 0;
}

Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
const Long MOD = 1e9 + 7;
const Long MX = 1e6;
int n;
Long memo[MX + 2][4];
Long dp(int pos, int mk) {
  //cout << pos << " " << mk << endl;
  if (pos == n) {
    return mk == 3;
  }
  if (memo[pos][mk] != -1) return memo[pos][mk];
  Long &ans = memo[pos][mk] = 0;
  fore(i, 0, 10) {
    if (i == 0)
      ans += dp(pos + 1, mk | 1);
    else if (i == 9)
      ans += dp(pos + 1, mk | 2);
    else
      ans += dp(pos + 1, mk);
    ans %= MOD;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  fore(i, 0, n) fore(j, 0, 4) memo[i][j] = -1;
  cout << dp(0, 0) << '\n';

  return 0;
}

Measured memory_bytes: 128532