akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
    int N; cin >> N;
    int A;
    float sum_val = 0;
    for (int i = 0; i < N; i++) {
        cin >> A;
        sum_val += (float)1.0 / A;
    }
    cout << (float)1.0 / sum_val << endl;
    return 0;
}


Measured memory_bytes: 256
X = 2 #int(input())
packs = [int(candies) for candies in input().split()]
N = int(len(packs))
if sum(packs) % X == 0:
    A = int(sum(packs) / X) # 部分和がAになれば良い
else: 
    print('No')
    exit()
packSum = [sum([packs[x] for x in range(N) if i & (1 << x) != 0]) for i in range(1 << N)]
dp = [False] * (1 << N)
dp[0] = True #どのパックも使わないとき条件を満たす
for i in range(len(dp)): #現在使われてるパックの集合
    if not dp[i]:
        continue
    for j in range(N): #追加するパックの候補
        if i & (1 << j) == 0: #すでに使われていないか調べる
            dp[i | (1 << j)] = dp[i | (1 << j)] or packSum[i] // A == packSum[i | (1 << j)] // A or packSum[i] % A + packs[j] == A
            

if dp[-1]:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll ans,b;
string s;
int main(void){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='B')b++;
        else ans+=b;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main(){
  string a;

  getline(cin,a);

  for(int i=0;i<a.size();i++){
    if(isalpha(a[i])){
      if(islower(a[i])){
        a[i] = toupper(a[i]);
      }else{
        a[i] = tolower(a[i]);
      }
    }
  }

  cout << a << endl;

  return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define Maxn 607
#define modp 998244353
using namespace std;
int n;
char s[Maxn][Maxn];
int h[Maxn][Maxn],bin[Maxn];
int calc(int x,int y,int len)
{
	return (h[x+len-1][y+len-1]-(1LL*bin[len]*h[x-1][y-1])%modp+modp)%modp;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
		{
			s[i+n][j]=s[i][j];
			s[i][j+n]=s[i][j];
			s[i+n][j+n]=s[i][j];
		}
	for (int i=1;i<=2*n;i++)
		for (int j=1;j<=2*n;j++)
			h[i][j]=(27LL*h[i-1][j-1]+s[i][j]-'a'+1)%modp;
	bin[0]=1;
	for (int i=1;i<=2*n;i++)
		bin[i]=(27LL*bin[i-1])%modp;
	int ans=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
		{
			bool check=true;
			for (int k=0;k<n;k++)
				if (calc(i+k,j,n-k)!=calc(i,j+k,n-k)) check=false;
			if (check) ++ans;
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2048
package main

import (
	"fmt"
)

func main() {
	var n,l int
	fmt.Scan(&n,&l)

	apples := make([]int,n) 

	for i,_ := range apples {
		apples[i] = l + i+1 - 1
	}
	
	sum := 0
	if l >= 0 {
		for i := 1; i < len(apples); i++ {
			sum += apples[i]
		}
	} else if n + l > 0 {
		for i := 0; i < len(apples); i++ {
			sum += apples[i]
		}
	} else {
		for i := 0; i < len(apples)-1 ; i++ {
			sum += apples[i]
		}
	}
	fmt.Println(sum)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll k,N,M;
  cin>>k>>N>>M;
  for(ll i=N;i<=M;i++){
    if(i%k==0){cout<<"OK"<<endl;return 0;}
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

int n;
string s;
vector<int> g[3005];
int dist[3005];
int cnt;
void dfs(int u, int pr)
{
	for(int i=0;i<g[u].size();i++)
	{
		int h=g[u][i];
		if(pr==h)
		{
			continue;
		}
		dist[h]=dist[u]+1;
		dfs(h,u);
	}
	if(s[u]=='1')
	{
		cnt+=dist[u];
	}
}
int cnts[3005];
int dfs1(int u,int pr)
{
	cnts[u]=0;
	if(s[u]=='1')
	{
		cnts[u]++;
	}
	int cur=0;
	vector<pair<int,int> >st;
	for(int i=0;i<g[u].size();i++)
	{
		int h=g[u][i];
		if(pr==h)
		{
			continue;
		}
		int tmp=dfs1(h,u);
		st.push_back({tmp,h});
		cnts[u]+=cnts[h];
		cur+=tmp;
	}
	if(st.empty())
	{
		if(s[u]=='1')
		{
			return dist[u];
		}
		return 0;
	}
	int ans=0;
	if(s[u]=='1')
	{
		ans+=dist[u];
	}
	for(auto &x: st)
	{
		ans+=dist[u]*cnts[x.second];
		x.first-=dist[u]*cnts[x.second];
		cur-=dist[u]*cnts[x.second];
	}
	sort(st.begin(), st.end());
	if(st.back().first<=cur-st.back().first)
	{
		ans+=cur%2;
	}
	else
	{
		int tmp=2*st.back().first;
		for(auto x: st)
		{
			tmp-=x.first;
		}
		ans+=tmp;
	}
	return ans;
}
int main()
{
	cin>>n;
	cin>>s;
	for (int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int res=INF;
	for(int i=0;i<n;i++)
	{
		int sum=0;
		int tmp=0;
		int pos=-1;
		for(int j=0;j<g[i].size();j++)
		{
			int h=g[i][j];
			cnt=0;
			dist[h]=1;
			dfs(h,i);
			tmp=max(tmp,cnt);
			if(tmp==cnt)
			{
				pos=h;
			}
			sum+=cnt;
		}
		if(sum%2==0 and tmp<=sum/2)
		{
			res=min(res,sum/2);
		}
		else
		{
			if(sum%2==0)
			{
				if(res>sum/2)
				{
					int f=dfs1(pos,i);
					int ft=sum-tmp;
					if(f<=ft)
					{
						res=min(res,sum/2);
					}
				}
			}
		}
	}
	if(res>=INF)
	{
		res=-1;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define MM(arr,x) memset(arr,x,sizeof(x))
const int Mod = 1e9 + 7;
using namespace std;
ll dp[2050];
int main()
{
	int n;
	cin >> n;
	dp[0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=3;i+j<=n;j++)
		{
			dp[i+j]=(dp[i]+dp[i+j])%Mod; 
		}
	}
	cout<<dp[n];
	return 0;
} 

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

Measured memory_bytes: 23632
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    REP(i, N) cin >> T[i];
    sort(T.begin(), T.end());

    int ans = 0;
    int num = 0;
    int mint = -1;
    REP(i, N) {
        if (mint != -1 && mint + K < T[i]) {
            num = 0;
            mint = -1;
            ans++;
        }
        if (mint == -1) {
            mint = T[i];
        }
        num++;
        if (num == C) {
            num = 0;
            mint = -1;
            ans++;
        }
    }
    if (num > 0) {
        ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
int H,W,j=1; cin >> H >>W;
char a[W+3];
int b[H+3][W+3];
for(int i=0;i<H+3;i++){
    for(int j=0;j<W+3;j++){
   b[i][j]=0;
    }
  }
  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
      cin>>a[j];
      if(a[j]=='#')b[i][j]=1;
    }
  }
  for(int i=1;i<H+1;i++){
    for(j=1;j<W+1;j++){
     if(b[i][j]==1&&b[i+1][j]==0 &&b[i][j+1]==0
     && b[i-1][j]==0&&b[i][j-1]==0){
     cout << "No";
     break;
     } else if(i==H&&j==W)cout << "Yes";
  
  }
  if(b[i][j]==1&&b[i+1][j]==0 &&b[i][j+1]==0
     && b[i-1][j]==0&&b[i][j-1]==0){
     break;
     }
  
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int main(){
    ll N,M;
    cin>>N>>M;
    ll votesum=0;
    vector<ll>vote(N);
    rep(i,N){
     cin>>vote[i];
     votesum+=vote[i];
    }
    ll sum=0;
    rep(i,N){
        if(votesum/(4.0*M)<=vote[i])sum++;
    }
    if(M<=sum)cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
}



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

int main() {
  int a[5];
  for(int i=0; i<5 ; i++){
    cin >> a[i]; 
  }
  int last_index=0;
  for(int j=0; j<5 ; j++){ 
    if(a[j]%10==0);
    else if((10-a[last_index]%10) < (10-a[j]%10)) last_index=j;
  }
  int min=0;
  for(int j=0; j<5 ; j++){
    if(last_index==j) min += a[last_index];
    else if (a[j]%10!=0)min += (a[j] -a[j]%10)+10;
    else min += a[j];
  }
  cout << min << endl;

}


Measured memory_bytes: 256
S = []
Sa = input()
S.append(list(Sa.replace('a', '0').replace('b', '1').replace('c', '2')))
Sb = input()
S.append(list(Sb.replace('a', '0').replace('b', '1').replace('c', '2')))
Sc = input()
S.append(list(Sc.replace('a', '0').replace('b', '1').replace('c', '2')))

now = [0] * 3
turn = 0
len_a = len(Sa)
len_b = len(Sb)
len_c = len(Sc)

while True:
    if (now[0] == len_a and turn == 0) or (now[1] == len_b and turn == 1) or (now[2] == len_c and turn == 2):
        break
    next_turn = S[turn][now[turn]]
    now[turn] += 1
    turn = int(next_turn)

print(chr(ord('A') + turn))


Measured memory_bytes: 9144
#include <iostream>
#include <cstdio>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

int main()
{
	int N,n;
	char dstr[12];
	string str;
	list<int> l;
	cin>>N;
	for(int i=0;i<N;i++){
		scanf("%s",dstr);
		str=dstr;
		if(str=="deleteFirst"){
			l.erase(l.begin());
		}else if(str=="deleteLast"){
			l.erase(--(l.end()));
		}else if(str=="delete"){
			cin>>n;
			auto it = find(l.begin(),l.end(),n);
			if(it!=l.end()){
				l.erase(it);
			}
		}else{
			cin>>n;
			l.push_front(n);
		}
	}
	cout<<*(l.begin());
	for(auto it = ++l.begin();it!=l.end();it++){
		cout<<' '<<*it;
	}
	cout<<endl;
}

Measured memory_bytes: 32492
N, K = map(int, input().split())

h = []
for i in range(N):
    h.append(int(input()))

h.sort(reverse=True)

dh_max = h[0]

for i in range(N - K + 1):
    dh = h[i] - h[K+i-1]
    if dh < dh_max:
        dh_max = dh

print(dh_max)

Measured memory_bytes: 7384
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, child[MAXN], b4[MAXN], ans[MAXN];
vector <ll> v[MAXN];
void dfs(ll x, ll p, ll mx, ll mx2)
{
	b4[x] = mx;
	//note that since x i unique x != mx
	if(x > mx)
	{
		ans[x] ++;
		mx = x;
		mx2 = 0;
	}
	else
	{
		mx2 = max(mx2, x);
		if(b4[mx] > mx2) ans[mx] ++;
		else ans[child[mx]] ++;
	}
	for(auto i : v[x])
	{
		if(i==p)continue;
		child[x] = i;
		dfs(i, x, mx, mx2);
	}
}
void answer(ll x, ll p)
{
	ans[x] += ans[p];
	for(auto i : v[x])
	{
		if(i==p)continue;
		answer(i, x);
	}
}
int main()
{
	cin >> n;
	FOR(i,1,n) { ll a, b; cin >> a >> b; v[a].pb(b); v[b].pb(a); }
	dfs(1, 1, 0, 0);
	answer(1, 0);
	FOR(i,2,n+1) cout << ans[i]-1 << "\n";
}


Measured memory_bytes: 33664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
using pp=pair<int,pair<int,int>>;
#define MOD 1000000007
#define INF 1000000000

int main(){
  int N,K;
  cin>>N>>K;
  if(K==1){
    cout<<0<<endl;
  }else if(N==K){
    cout<<0<<endl;
  }else{
    cout<<N-K<<endl;
  }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x(x % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(100005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

typedef long long ll;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

map<ll, ll> prime_factorize(ll n) {
    map<ll, ll> res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        res[p] = num;
    }
    if (n != 1) res[n] = 1;

    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<map<ll, ll>> C(N);
    rep(i, N) C[i] = prime_factorize(A[i]);

    map<ll, ll> mp;
    rep(i, N) {
        for (auto c: C[i]) {
            if (mp.find(c.first) == mp.end() || mp[c.first] < c.second) mp[c.first] = c.second;
        }
    }

    mint l = 1;
    for (auto c: mp) l *= pow(c.first, c.second);
    mint ans = 0;
    rep(i, N) ans += l / A[i];
    cout << ans.x % mod << endl;
}


Measured memory_bytes: 5504
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
#define INF 1e+8
#define EPS 1e-7
#define PB push_back
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
class data{
public:
    short field[10][10];
    short cnt;
    data(){}
    data(short _field[10][10],short _cnt){
        rep(i,10){
            rep(j,10){
                field[i][j] = _field[i][j];
            }
        }
        cnt = _cnt;
    }
};
bool memo[10][10];
short chenge(char c){
    if(c == 'R')return 0;
    if(c == 'G')return 1;
    return 2;
}
bool check(short f[10][10],short W,short H){
    short comp = f[0][0];
    rep(i,H){
        rep(j,W){
            if(comp != f[i][j])return false;
        }
    }
    return true;
}
void dfs(short b,short col,short y,short x,short stage[10][10],short W,short H){
    rep(i,4){
        short ny = y+dy[i];
        short nx = x+dx[i];
        if(ny < 0 || ny > H-1 || nx < 0 || nx > W-1 || stage[ny][nx]!=b)continue;
        if(memo[ny][nx]++)continue;
        stage[ny][nx] = col;
        dfs(b,col,ny,nx,stage,W,H);
    }
    return ;
}
void copy(short stage[10][10],short bef[10][10],short W,short H){
    rep(i,H){
        rep(j,W){
            stage[i][j] = bef[i][j];
        }
    }
    return ;
}
int main(){
    int W,H;
    while(scanf("%d%d",&W,&H),W){
        short stage[10][10];
        rep(i,H){
            rep(j,W){
                char c;
                scanf(" %c",&c);
                stage[i][j] = chenge(c);
            }
        }
        queue < data > Q;
        Q.push(data(stage,0));
        short ans = -1;
        while(!Q.empty()){
            data d = Q.front();Q.pop();
    /*
            puts("-----------------------------");
            rep(i,H){
                rep(j,W){
                    printf("%d ",d.field[i][j]);
                }
                puts("");
            }
            puts("-----------------------------");*/
            if(check(d.field,W,H)){
                ans = d.cnt;
                break;
            }
            short col1 = (d.field[0][0]+1)%3;
            short col2 = (d.field[0][0]+2)%3;
            short sub[10][10];
            copy(sub,d.field,W,H);
            memset(memo,0,sizeof(memo));
            sub[0][0] = col1;
            dfs(d.field[0][0],col1,0,0,sub,W,H);
            Q.push(data(sub,d.cnt+1));
            copy(sub,d.field,W,H);
            memset(memo,0,sizeof(memo));
            sub[0][0] = col2;
            dfs(d.field[0][0],col2,0,0,sub,W,H);
            Q.push(data(sub,d.cnt+1));
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 55136
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	ll N, K;
	cin >> N >> K;

	ll ans = 0;
	repr(i, 1, N + 1) {
		ans += N / i * max(ll(0), i - K);
		ans += max(ll(0), N % i - K + 1);
	}

	if (K == 0) ans -= N;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll ans=n+1;
    rep(i,1,1000001){
        if(n%i==0){
            ans=min(ans,n/i+i);
        }
    }
    cout <<ans-2<<"\n";
}

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

int main() {
    int n;
    cin >> n;
    long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int cnt = 0;
    bool ok = true;
    while (ok == true) {
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0) a[i] = a[i] / 2;
            else ok = false;
        }
        if (ok == true) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

signed main(void)
{
	int n, cnt, ans;
	int i, j;
	cin >> n;
	ans = 0;
	for (i = 1; i < n; i++)
	{
		cnt = 0;
		for(j = 1; j * j < i; j++)
		{
			if (i % j == 0)
				cnt++;
		}
		ans += cnt * 2;
		if (j * j == i)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        if (s.length()<=k){
            System.out.println(s);
        }else {
            System.out.println(s.substring(0,k)+"...");
        }
    }
}


Measured memory_bytes: 38800
// Code by H~$~C
#include <bits/stdc++.h>
using namespace std;

static const int Maxn = 100005;
static const int mod = 1000000007;

inline long long modpower(long long x, long long y) {
  long long res = 1LL;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}

int n, k;
long long a[Maxn];
long long fact[Maxn];
inline long long C(int x, int y) {
  if (x < y) return 0;
  return fact[x] * modpower(fact[y], mod - 2) % mod * modpower(fact[x - y], mod - 2) % mod;
}

int main() {
  scanf("%d%d", &n, &k);
  fact[0] = 1;
  for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i % mod;
  for (int i = 1; i <= n; ++i)
    scanf("%lld", a + i);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i)
    (a[i] += 2 * mod) %= mod;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    long long t = (C(i - 1, k - 1) - C(n - i, k - 1) + mod) % mod;
    (ans += a[i] * t % mod) %= mod;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <unordered_map>
typedef long long ll;

using namespace std;
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);

    ll h, w, n;
    cin>>h>>w>>n;

    unordered_map<ll, ll> m;
    ll x=1e9;
    while (n--) {
        ll a, b;
        cin>>a>>b;
        --a, --b;
        for(int i=-2;i<=0;++i) for(int j=-2;j<=0;++j) {
            int r=a+i, c=b+j;
            if (r<0 or r+2>=h or c<0 or c+2>=w) continue;
            ++m[r*x+c];
        }
    }

    ll res[10]={};
    res[0]=(h-2)*(w-2);
    for(e: m) ++res[e.second];
    for(int i=1; i<10; ++i) res[0]-=res[i];

    for(e: res) cout<<e<<endl;
}


Measured memory_bytes: 36624
#include<bits/stdc++.h>
using namespace std;
string st;
int z;
int main()
{
    cin>>st;
    for(int i=0;i<st.size();i++)
    {
        if(st[i]=='C')z++;
        if(z>0&&st[i]=='F')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int i;
	char a[20];
	
	cin >> a;
	
	for(i=0; a[i] != 0; i++);
	for(i-=1; i>=0; i--) {
		cout << a[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

int main(void){
  int R;cin >> R;
  if(R<1200) cout << "ABC" << endl;
  else if(R<2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}


Measured memory_bytes: 256
S = str(input())

RLs = S.replace('LR', 'L,R').split(',')
# print(RLs)
# R..Lで1組となり、その外とは混ざらない

def moving_RL(RL):
  cnt_R = RL.count('R')
  cnt_L = RL.count('L')

  # ベースとなる数
  a = b = len(RL) // 2

  # 奇数個の場合
  if len(RL) % 2 == 1:

    # 均等にならない最後の1個を配分
    if cnt_R > cnt_L: a += 1
    else: b += 1

    # 最後の1個が奇数回目の移動で追加されるなら
    # 10^100回目＝偶数回目の時は、その逆になっている
    if max(cnt_R, cnt_L) % 2 == 0:
      a, b = b, a

  # 左右に0を追加した形で返す
  ret = ''
  if cnt_R > 1:
    ret += '0 ' * (cnt_R - 1)
  ret += '{} {} '.format(a,b)
  if cnt_L > 1:
    ret += '0 ' * (cnt_L - 1)

  return(ret.strip())

# 分割した R..L の1組ごとに実行し、戻りを結合
ans = ''
for rl in RLs:
  ans += moving_RL(rl) + ' '

print(ans.strip())

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

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    int q;
    cin >> q;
    int cnt = 0;
    for (int i = 0; i < q; i++)
    {
        int t;
        cin >> t;
        if (binary_search(s.begin(), s.end(), t))
        {
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  int odd = 0;
  rep(i,n) {
    int a;
    cin >> a;
    odd += ( a & 1 );
  }
  puts( ( odd & 1 ) ? "NO" : "YES" );
  compute();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    if(a == 0 || b == 0)cout << "Zero";
    else{
        if(a < 0 && 0 < b)cout << "Zero";
        else if(a > 0 && b > 0)cout << "Positive";
        else{
            if(abs(b-a+1) % 2 == 0)cout << "Positive";
            else cout << "Negative";
        }
    }
}       

Measured memory_bytes: 256
C1 = list(map(int,input().split()))
C2 = list(map(int,input().split()))
C3 = list(map(int,input().split()))
a = 0
b1,b2,b3 = C1[0],C1[1],C1[2]
a1,a2,a3  = 0,C2[1]-b2,C3[1]-b2
if C1[0]!=a1+b1 or C1[1]!=a1+b2 or C1[2]!=a1+b3 or C2[0]!=a2+b1 or C2[1]!=a2+b2 or C2[2]!=a2+b3 or C3[0]!=a3+b1 or C3[1]!=a3+b2 or C3[2]!=a3+b3:
    print("No")
else:
    print("Yes")


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

using namespace std;
typedef long long LL;
struct job {
	LL A;
	LL B;
};
job arr[212121];

bool cmp(job a, job b) {
	return a.B < b.B;
}

int main() {
	int N;
	scanf("%d", & N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", & arr[i].A, & arr[i].B);
	}	
	sort (arr, arr + N, cmp);
	LL sum = 0;
	bool ans = 1;
	for (int i = 0; i < N; i++) {
		sum += arr[i].A;
		if (sum > arr[i].B) ans = 0;
	}
	if (ans) printf("Yes\n");
	else printf("No\n");
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_K = (int)(1e1 + 5);

int n, k;
set<int> dset;

int ans = 0;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  for (int i = 0; i < k; ++i) {
    int tmp;
    scanf("%d", &tmp);
    dset.insert(tmp);
  }

  for (int i = n; i < 100 * n; ++i) {
    bool flg = false;
    string str_i = to_string(i);

    for (auto c: str_i) {
      int num = c - '0';
      if (dset.find(num) != dset.end()) {
        flg = true;
        break;
      }
    }

    if (flg) continue;

    ans = i;
    break;
  }


  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 x, a;
  scanf ("%" SCNi32 "%" SCNi32, &x, &a);
  printf ("%" PRIi32 "\n", x< a ? 0 : 10);
}

int main (void) {
  run();
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  string S, T;
  cin >> S >> T;
  map<char, int> cnt1, cnt2;
  rep(i, S.size()) {
    int s = S[i];
    int t = T[i];
    if (cnt1.find(s) == cnt1.end())
      cnt1[s] = 1;
    else
      cnt1[s]++;
    if (cnt2.find(t) == cnt2.end())
      cnt2[t] = 1;
    else
      cnt2[t]++;
  }
  rep(i, S.size()) {
    if (cnt1[S[i]] != cnt2[T[i]]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<Integer> cc = new ArrayList<>(N);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	static int INF=1000000007;
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];for(int i=0;i<N;i++) {}
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		int Q=sc.nextInt();
		
		StringBuffer S = new StringBuffer(sc.next());
		
		int v[]=new int[S.length()];
		
		int a=0;
		
		for(int i=0;i<S.length()-1;i++) {
			if(S.charAt(i)=='A'&&S.charAt(i+1)=='C') {
			
				
				v[i+1]=v[i]+1;
			}else  v[i+1]=v[i];
		}
		
		for(int i=0;i<Q;i++) {
			int l=sc.nextInt()-1;
			int r=sc.nextInt()-1;
			
			p(v[r]-v[l]);
			
			
		}
		
		
	}
	
		
	
	
		
	
	public static long modPow(long g,long N) {
		long T=1;
		for(int i=0;i<N;i++) {
			T*=g;
			T%=mod;
		}
		return T;
	}
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 64840
#include<bits/stdc++.h>//万能头文件
using namespace std;
int a[101],n;
int main() 
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];//输入数组
    cout<<(*max_element(a+1,a+1+n))-(*min_element(a+1,a+1+n))<<endl;
    //输出最大值和最小值的差，要换行
    return 0;//结束
}

Measured memory_bytes: 384
Scanf.scanf "%d %d" (fun n c ->
    let ch = Array.make c [] in
    for i = 1 to n do
        Scanf.scanf " %d %d %d" (fun s t c -> ch.(c - 1) <- (s, t) :: ch.(c - 1))
    done;
    let fr = Array.make 100001 0 in
    for i = 0 to c - 1 do
        let rec loop prevend = function
            | [] -> if prevend >= 0 then fr.(prevend) <- fr.(prevend) - 1
            | (s, t) :: tl ->
                    if s = prevend then loop t tl else (
                        if prevend >= 0 then fr.(prevend) <- fr.(prevend) - 1;
                        fr.(s - 1) <- fr.(s - 1) + 1;
                        loop t tl
                    )
        in
        loop (-1) (List.sort compare ch.(i))
    done;
    let asm = Array.make 100001 0 in
    asm.(0) <- fr.(0);
    for i = 1 to 100000 do
        asm.(i) <- asm.(i - 1) + fr.(i)
    done;
    Array.fold_left max 0 asm |> Printf.printf "%d\n"
)

Measured memory_bytes: 17280
use std::io::*;
use std::str::FromStr;
use std::f64::consts::PI;

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

const EPS: f64 = 1.0e-6;
 
fn solve1(a: f64, b: f64, theta: f64) -> f64 {
  b * b / theta.tan() / 2.0 * a
}

fn solve2(a: f64, b: f64, theta: f64) -> f64 {
  a * b * a - a * a * a * theta.tan() / 2.0
}

fn solve(a: f64, b: f64, theta: f64) -> f64 {
  if theta > PI / 2.0 - EPS {
    0.0
  } else if b < theta.tan() * a {
    solve1(a, b, theta)
  } else {
    solve2(a, b, theta)
  }
}

fn main() {
  let a : f64 = read();
  let b : f64 = read();
  let x : f64 = read(); //体積
  
  //二分探索
  let mut lb = 0.0;
  let mut ub = PI / 2.0;
  for _i in 0..100000 {
    let md: f64 = lb + (ub - lb) / 2.0;
    
    let ts = solve(a, b, md);
    
    //println!("{:.10}", (ts - x).abs());
    
    if ts > x {
      //もっと傾きを大きくする
      lb = md;
    } else {
      ub = md;
    } 
  }
  
  println!("{:.10}", ub * 180.0 / PI);
}
  

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String str = br.readLine();

		String front = str.substring(0, n / 2);

		String back = str.substring(n / 2, n);

		if (front.equals(back))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
#define X 1000000
ll po(ll x,ll y){
    ll res=1;
    for(;y;y>>=1){
	if(y&1)res=res*x%mod;
	x=x*x%mod;
    }
    return res;
}
ll n,a[10100],t[X];
int main(){
    rep(i,X)t[i]=0;
    cin>>n;
    rep(i,n){
	cin>>a[i];
	ll x=a[i];
	for(ll p=2;p*p<=x;p++){
	    ll cnt=0;
	    while(x%p==0)cnt++,x/=p;
	    chmax(t[p],cnt);
	}
	if(x>1)chmax(t[x],1LL);
    }
    ll lc=1;
    rep(i,X){
	lc=lc*po(i,t[i])%mod;
    }
    ll ans=0;
    rep(i,n){
	ans+=lc*po(a[i],mod-2)%mod;
	ans%=mod;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int A, B, C; IN(A, B, C);
    int ans = 0;
    if(A + B >= C - 1) ans += C;
    else ans += A + B + 1;
    ans += B;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vpll path;
//***********//
int main() { 
	ll A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;
	if (A == 0) cout << 1 << endl;
	else if (B == 0) cout << 2 << endl;
	else if (C == 0) cout << 3 << endl;
	else if (D == 0) cout << 4 << endl;
	else if (E == 0) cout << 5 << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
	int A=0;
	int B=0;
	int C=0;
	int D=0;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	while(1){
		C=C-B;
		if(C<=0){
			printf("Yes\n");
			break;
		}
		A=A-D;
		if(A<=0){
			printf("No\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		sc.close();


		for(int i=0;i<k;i++) {
			System.out.print("ACL");
		}
	}
}


Measured memory_bytes: 35724
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second


signed main() {
	ll t=1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll a[n],l[n],r[n];
		map<ll,ll> mp;
		rep(i,n){
			cin>>a[i];
		}
		ll c= 0;
		rep(i,n){
			ll sa = i - a[i];
			ll wa = i + a[i];
			c += mp[sa];
			mp[wa]++;
		}
		cout<<c;
		
	}
	
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x = c/b + (c%b?1:0);
    int y = a/d + (a%d?1:0);
    cout << (x<=y?"Yes":"No") << endl;
    return 0;
}



Measured memory_bytes: 3620
N = int(input())
students = list(map(int, input().split()))

sdict = {}
count = 1
for x in students:
  sdict[x] = count
  count += 1

sdict = sorted(sdict.items())

ans = ""
for x in sdict:
  ans += (str(x[1])+" ")
print(ans[:-1])

Measured memory_bytes: 24284
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(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 pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	ll N;
	bool flag = true;
	ll length;
	string W[200];
	cin >> N;

	REP(i, N) {
		cin >> W[i];
	}
	FOR(i, 1, N) {
		length = W[i - 1].size() - 1;
		if (W[i - 1][length] != W[i][0]) flag = false;
	}
	REP(i, N) {
		REP(j, N) {
			if (i == j)break;
			if (W[i] == W[j]) flag = false;
		}
	}
	if (flag) {
		cout << "Yes";
	}
	else cout << "No";

	return 0;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    bool ok[4]={0};
    rep(i,4){
        int x;
        cin>>x;
        if(x==1) ok[0]=1;
        if(x==9) ok[1]=1;
        if(x==7) ok[2]=1;
        if(x==4) ok[3]=1;
    }
    bool ans =1;
    rep(i,4){
        if(ok[i]==0) ans = 0;
    }
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256