akhauriyash/Code-Regression huggingface dataset:
//Problem_B
#include <bits/stdc++.h>
using namespace std;

int main(){
   int a, b, c, d, e;
   cin>>a;
   cin>>b;
   cin>>c;
   cin>>d;
   cin>>e;
   if(a > b) swap(a, b);
   if(a > c) swap(a, c);
   if(d > e) swap(d, e);
   cout<<a + d - 50<<endl;

   return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}
int main()
{
    Imposter
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        input(a,n);ll ans=0;
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if(a[i]==a[j])
                continue;
                for(int k=j+1;k<n;k++)
                {
                    if(a[i]==a[k] || a[j]==a[k])
                    continue;
                    if((a[i]+a[j]>a[k]) and (a[i]+a[k]>a[j]) and a[j]+a[k]>a[i])
                    ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    vector<int> a(n*3);
    rep(i, n * 3) cin >> a[i];

    sort(all(a));
    reverse(all(a));
    ll ans = 0;
    for(int i = 1; i < n * 2; i+=2) {
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int i, x, y;
  int N, M;
  int ans=0;
  std::vector<int> H;
  std::vector<int> A;
  
  std::cin >> N >> M;
  H.resize(N);
  A.resize(N);
  for(i=0; i<N; i++){
    std::cin >> H[i];
  }
  for(i=0; i<M; i++){
    std::cin >> x >> y;
    A[x-1] = std::max(A[x-1], H[y-1]);
    A[y-1] = std::max(H[x-1], A[y-1]);
  }
  
  for(i=0;i<N;i++){
    if(H[i]>A[i]) ans++;
  }
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back



int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int d,e,f;
    if(r>=g&&r>=b){
        d=r;
        if(g>=b){
            e=g;
            f=b;
        }else{
            e=b;
            f=g;
        }
    }

    if(g>=r&&g>=b){
        d=g;
        if(r>=b){
            e=r;
            f=b;
        }else{
            e=b;
            f=r;
        }
    }

    if(b>=r&&b>=g){
        d=b;
        if(r>=g){
            e=r;
            f=g;
        }else{
            e=g;
            f=r;
        }
    }

    int count=0;
    /*if(f>n){
        cout << 0 << endl;
        return 0;
    }

    if(e>n){
        if(n%e==0){
            cout << 1 << endl;
        }
    }*/

    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            int s = n-(i*d+j*e);
            if(s>=0&&s%f==0) count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    string S;
    cin >> S;
    if(S=="AAA" || S=="BBB"){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

H,W,K=map(int,input().split())
MAP=[list(input().strip()) for i in range(H)]

NONE=set()
IN=[]
for i in range(H):
    if "#" in MAP[i]:
        IN.append(i)
    else:
        NONE.add(i)
        
USE=[i for i in range(H)]

for i in range(H-1,-1,-1):
    if i in NONE and i+1<H:
        USE[i]=USE[i+1]


for i in range(IN[-1]+1,H):
    USE[i]=IN[-1]


count=1
for i in range(H):
    for j in range(W):
        if MAP[i][j]==".":
            MAP[i][j]=0
        else:
            MAP[i][j]=count
            count+=1

for i in IN:
    for j in range(W-1,-1,-1):
        if MAP[i][j]==0 and j+1<W:
            MAP[i][j]=MAP[i][j+1]

    if 0 in MAP[i]:

        k=MAP[i].index(0)
        for j in range(k,W):
            MAP[i][j]=MAP[i][k-1]

for i in NONE:
    for j in range(W):
        MAP[i][j]=MAP[USE[i]][j]

for m in MAP:
    print(*m)

Measured memory_bytes: 51932
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll l,r;
	for(ll i=1;i<=sqrt(n)+1;i++){
		if(n%i==0) {
		l=i;
		r=n/i;
	 }
  }
  
	 cout<<l-1+r-1<<'\n';

}

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

int main(){
	long a, b, c, k; cin >> a >> b >> c >> k;
	
	long ans = 0;
	if(k == 0) ans = a - b;
	else if(k % 2 == 1){
		ans = b - a;
	}else if(k % 2 == 0){
		ans = a - b;
	}
	
	if(ans > 1e18) cout << "Unfair" << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, max, sum, L;


    scanf("%d", &n);

    max = sum = 0;
    for (int i=0; i<n; i++) {
        scanf("%d", &L);

        if (L>max)  max = L;
        sum += L;
    }

    if (max < sum-max)
        printf("Yes\n");

    else
        printf("No\n");

    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7ll;

int n;
int c;
int ans=1;

int main(){

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

cin>>n;

for(int i=1; i<=n; i++){
  int cnt=0;
  int j=i;
  while(j%2==0){
    j/=2;
    cnt++;
  }
  if(cnt>c){
    c=cnt;
    ans=i;
  }
}

cout<<ans<<endl;

}



Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
p = list(map(int, input().split()))
c1, c2, c3 = 0, 0, 0

for pi in p:
    if pi<=A:
        c1 += 1
    elif A<pi<=B:
        c2 += 1
    else:
        c3 += 1

print(min(c1, c2, c3))

Measured memory_bytes: 61300
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 hh, ww, kk, bla = 0, ans = 0;
	cin >> hh >> ww >> kk;
	bool table[hh][ww];
	for(int64 ii = 0;ii < hh;ii++)
	{
		for(int64 jj = 0;jj < ww;jj++)
		{
			table[ii][jj] = false;
			char tmp;
			cin >> tmp;
			if(tmp == '#')
			{
				table[ii][jj] = true;
				bla++;
			}
		}
	}
	for(int64 ii = 0;ii < (1 << hh);ii++)
	{
		for(int64 jj = 0;jj < (1 << ww);jj++)
		{
			int64 tmp = 0;
			for(int64 kk = 0;kk < hh;kk++)
			{
				for(int64 mm = 0;mm < ww;mm++)
				{
					if(ii & (1 << kk) || jj & (1 << mm))
					{
						if(table[kk][mm])
						{
							tmp++;
						}
					}
				}
			}
			if(bla - tmp == kk)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
static const ll MAX = 2e5;
static const ll INF = 1e9;
static const ll MOD = 1e9 + 7;

// 組合せを素数で割った値を求める
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(ll n, ll k) {
  if (n < k || n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if (n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

ll modinv(ll x) {
  return power(x, MOD - 2, MOD);
}

// 隣接リストを用いた深さ優先探索（再帰ver.） O(|V|+|E|)
vector<ll> G[MAX], H[MAX], color(MAX);
vector<ll> dp(MAX), nodes(MAX);
// main関数からこれらを削除すること

void dfs(ll u) {
  color[u] = 1; // GRAY
  ll count = 1, keep = 1;
  for (ll i = 0; i < G[u].size(); i++) {
    ll v = G[u][i];
    if (color[v] == 0) {
      dfs(v);
      H[u].emplace_back(v);
      count += nodes[v];
      keep *= dp[v];
      keep %= MOD;
      keep *= finv[nodes[v]];
      keep %= MOD;
    }
  }
  color[u] = 2; // BLACK
  nodes[u] = count;
  dp[u] = (keep * fac[count - 1]) % MOD;
}

vector<ll> dp2(MAX), nodes2(MAX);

void dfs2(ll n, ll u) {
  ll keep = 1;
  for (ll i = 0; i < H[u].size(); i++) {
    ll v = H[u][i];
    nodes2[v] = n - nodes[v];
    keep *= (dp[v] * finv[nodes[v]]) % MOD;
    keep %= MOD;
  }
  if (u != 0) keep *= (dp2[u] * finv[nodes2[u]]) % MOD;
  keep %= MOD;
  for (ll i = 0; i < H[u].size(); i++) {
    ll v = H[u][i];
    dp2[v] = (((keep * fac[nodes2[v] - 1]) % MOD * fac[nodes[v]]) % MOD * modinv(dp[v])) % MOD;
    dfs2(n, v);
  }
}

vector<ll> ans(MAX);

void dfs3(ll n) {
  for (ll i = 0; i < n; i++) {
    if (i == 0) ans[i] = dp[i];
    else {
      ll keep = fac[n - 1];
      keep *= (dp2[i] * finv[nodes2[i]]) % MOD;
      keep %= MOD;
      for (ll j = 0; j < H[i].size(); j++) {
        ll v = H[i][j];
        keep *= (dp[v] * finv[nodes[v]]) % MOD;
        keep %= MOD;
      }
      ans[i] = keep;
    }
  }
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 無向(有向)グラフの隣接リスト
  ll n; // n:頂点数
  cin >> n;
  
  // vector<ll> G[n]; // G:頂点数がnのグラフを表す隣接リスト
  
  for (ll i = 0; i < n - 1; i++) {
    ll u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].emplace_back(v);
    G[v].emplace_back(u); // 有向グラフではこの行をコメントアウト
  }
  
  COMinit();
  
  dfs(0);
  
  dfs2(n, 0);
  
  dfs3(n);
  
  for (ll i = 0; i < n; i++) cout << ans[i] << '\n';
}

Measured memory_bytes: 37120
#include <iostream>
#include <set>
#include <map>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
	map<string,int> mp;
	set<string> st;
	int n; cin>>n;
	for(int i=0;i<n;++i){
		string t; cin>>t;
		st.insert(t);
		mp[t]+=1;
	}
	set<string>::iterator it;
	int big=-1;
	for(it=st.begin();it!=st.end();++it){
		big=max(big,mp[*it]);
	}
	map<string,int>::iterator id;
	for(id=mp.begin();id!=mp.end();++id){
		if(id->second==big)
			cout<<id->first<<endl;
	}
	return 0;
}

Measured memory_bytes: 34560
N, K = gets.chomp.split.map(&:to_i)
S = gets.chomp.chars

arr = []

# 必ず1から始める
if S[0] == '0'
  arr << 0
end


cnt = 1
N.times do |i|
  next if i == 0

  if S[i-1] == S[i]
    cnt += 1
  else
    arr << cnt
    cnt = 1
  end
end

arr << cnt

# 最後は1で終わらす
if S[-1] == '0'
  arr << 0
end

# 累積和
cumsum = []
cumsum << arr[0]

1.upto(arr.size-1) do |i|
  cumsum[i] = cumsum[i-1] + arr[i]
end

ans = 0

# p arr
# p cumsum

# ゼロのスペースの数
zero_cnt = (arr.size/2)

if K >= zero_cnt
  puts N
  exit
end

(zero_cnt - K + 1).times do |i|
  if i == 0
    tmp = cumsum[2*K]
  else
    tmp = cumsum[i*2+2*K] - cumsum[i*2-1]
  end

  # p tmp

  ans = [ans, tmp].max
end

p ans



Measured memory_bytes: 11060
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    string s,t;
    cin>>s>>t;
    int ans=1e9;
    for (int i=0; i<=s.size()-t.size(); i++)
    {
        int cnt=0;
        for (int j=0; j<t.size(); j++)
        {
            cnt+=(t[j]!=s[i+j]);
        }
        ans=min(ans,cnt);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3656
n, a, b = map(int, input().split())
ans = 0

def calc_sum(i):
    ret = 0
    while i != 0:
        ret += i % 10
        i //= 10
    return ret

for i in range(1, n + 1):
    sum = calc_sum(i)
    if a <= sum and sum <= b:
        ans += i

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll up(ll t, ll a) {
	return (t + a - 1) / a;
}

int main(void) {
	int n;
	cin >> n;
	vector<ll> t(n), a(n);
	rep (i, n) cin >> t[i] >> a[i];

	ll nowT = t[0], nowA = a[0];
	rrep (i, n - 1) {
		nowT = max(up(nowT, t[i]), up(nowA, a[i])) * t[i];
		nowA = max(up(nowT, t[i]), up(nowA, a[i])) * a[i];
	}

	cout << nowT + nowA << endl;
	return 0;
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  std::string S, T;
  std::cin >> S >> T;

  int ans = 0;
  rep(i, 3) {
    if(S[i] == T[i]) ++ans;
  }
  std::cout << ans << '\n';
}


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

int main() {
	string s, t;
	cin >> s >> t;

	int k = 0;
	for(int i = 0; i < s.length(); ++i) {
		if(s[i] == t[0]) {
			break;
		}
		k++;
	}

	bool yes = true;

	for(int i = 0; i < s.length(); ++i) {
		if(t[i] != s[(k + i) % s.length()]) {
			yes = false;
			break;
		}
	}

	if(yes) puts("Yes");
	else puts("No");
}

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

int main(){
    int A,B,K;
    cin >> A >>B>>K;
    int count=0;
    for(int i=min(A,B);i>=1;i--){
        if(A%i == 0 && B%i == 0) count++;
        if(count == K){
            cout << i << endl;
            return 0;
        }
    }
}

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

int main() {
	long n,t[110000],x[110000],y[110000];
	bool ans = true;
	cin >> n;
	t[0]=x[0]=y[0]=0;
	for(int i=0;i<n;i++){
		cin >> t[i+1]>>x[i+1]>>y[i+1];
	}
	
	for(int i=0;i<n;i++){
		int time = t[i+1]-t[i];
		int distance = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
		if(time<distance){ ans = false; break;}
		if(distance%2 != time%2){ ans = false; break;}
	}
	
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
using namespace std;
 
class stack{
public:
    static const int MAX_ = 10000;
    int data_[MAX_];
    int top_;
    stack():top_(0){}
    bool isEmpty(){return top_ == 0;}
    bool isFull(){return top_ >= MAX_-1;}
    void push(int x){
        if(isFull())cout << "over flow" << endl;
        else data_[++top_] = x;
    }
    int pop(){
        if(isEmpty())cout << "under flow" << endl;
        else    return data_[top_--];
        return 0;
    }
};

int calc(int a,int b,string c){
	if(c == "+")return a + b;
	else if(c == "-") return a - b;
	else if(c == "*") return a * b;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	string c;
	stack st;
	while(cin>>c){
		if(c == "+" || c == "-" || c == "*"){
			st.push(calc(st.pop(),st.pop(),c));
		}else{
			st.push(atoi(c.c_str()));
		}
	}
	cout << st.pop() << endl;
  return 0;
}

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

int main (){

  int a,b,c;

  cin >>  a >> b >> c;
  
  if (a<b && b<c)  cout << "Yes" <<'\n';
  else if (!(a<b && b<c))  cout << "No"   <<'\n';
 return 0;

}

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<P> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i].first = a[i];
        b[i].second = i;
    }
    sort(b.begin(), b.end());
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        if (i < n / 2) {
            ans[b[i].second] = b[n / 2].first;
        } else {
            ans[b[i].second] = b[n / 2 - 1].first;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>
int main(void){
    char result[20];
    int i,lose;
    lose=0;

    scanf("%s", result);

    for(i=0;i<15;i++){
        if(result[i] =='x'){
            lose++;
        }
    }

    if(lose>=8){
        printf("NO\n");
    }else{
        printf("YES\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int H,W;
  cin >> H >> W;
  int h,w;
  cin >> h >> w;
  int black = H * w + h * W - h * w;
  cout << H * W - black << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;

void solve() {
	ll a, b , x;
	cin >> a >> b >> x;
	ll t;
	t = a / x;
	ll ans = b / x - t;
	if(a % x == 0) ans++;
	cout << ans << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
	}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
int n,qa,qb,val[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

bool jdg(const int t){
	lint used=0;
	for(int i=1; i<=n; ++i){
		if(val[i]>(lint)t*qb){
			used+=(val[i]-t*qb+qa-qb-1)/(qa-qb);
		}
	}
	return used<=t;
}

int main(){
	n=nxi(),qa=nxi(),qb=nxi();
	for(int i=1; i<=n; ++i){
		val[i]=nxi();
	}
	{
		int l=1,r=1e9,mid;
		while(l!=r){
			mid=(l+r)>>1;
			if(jdg(mid)) r=mid;
			else l=mid+1;
		}
		printf("%d\n",l);
	}
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
char S[110];
long long k,ans,a[110],tot;
int main(){
	scanf("%s",S+1);
	scanf("%lld",&k);
	int n=strlen(S+1);
	for(int i=1;i<=n;i++)
		if(S[i]!=S[i-1])a[++tot]=1;
		else a[tot]++;
	if(tot==1){
		printf("%lld\n",k*n/2);
		return 0;
	}
	if(S[1]==S[n])a[1]+=a[tot--];
	for(int i=1;i<=tot;i++)
		ans+=a[i]/2*k;
	if(S[1]==S[n]){
		ans-=a[1]/2;
		ans+=(a[1]-a[tot+1])/2+a[tot+1]/2;
	}
	printf("%lld\n",ans);
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int total = 0;
  
  rep(i, M) {
    int A;
    cin >> A;
    total += A;
  }
  
  if(total > N) cout << -1 << endl;
  else cout << N - total << endl;
  
  return 0;
}

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

int main() {
  int A, B, X;
  cin >> A >> B;

  if (A <= B){
    X += B;
    B--;
  }else if(A > B){
    X += A;
    A--;
  }
  if (A <= B){
    X += B;
    B--;
  }else if(A > B){
    X += A;
    A--;
  }
  cout << X << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define rep0(i,r) for (int i=0,i##end=r;i<i##end;++i)
#define ll long long
using namespace std;
const int N=1e6+6;
int n,a[N],b[N];
ll calc(ll k){
    ll s=0; rep(i,1,n) if ((a[i]&k)==a[i]) s+=b[i]; return s;
}
int main(){
    int k; scanf("%d%d",&n,&k);
    rep(i,1,n) scanf("%d%d",&a[i],&b[i]);
    ll ans=calc(k);
    for (int j=1;j<=k;j<<=1)
        if (k&j) k-=j,k|=j-1,ans=max(ans,calc(k));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4736
n=int(input())

data=[list(map(str,input().split())) for _ in range(n)]
#print(data)
for i in range(n):
    data[i][1]=int(data[i][1])*-1
    data[i].append(i+1)

data=sorted(data, key=lambda x:(x[0], x[1]))
for i in range(n):
    print(data[i][2])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
const int limit = 1e6;
const int hsize = 1e3;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
	vector<bool> prime(limit+1, true);
	prime[0] = prime[1] = false;
	for(int i=2; i*i<=limit; i++){
		if(prime[i]){
			for(int j=2; i*j<=limit; j++){
				prime[i*j] = false;
			}
		}
	}
	
	vector<vector<int> > cave(hsize+2, vector<int>(hsize+2, 0));
	vector<pair<int,int> > to_xy(limit+1);
	int sx=hsize/2, sy=hsize/2;
	cave[sx][sy]=1;
	to_xy[1] = make_pair(sx, sy);
	int x=sx, y=sy;
	int num=2, dir=0;
	for(int i=0; ; i++){
		bool flag = false;
		for(int j=0; j<i/2+1; j++){
			x+=dx[dir];
			y+=dy[dir];
			cave[x][y] = num;
			to_xy[num] = make_pair(x,y);
			num++;
			if(num>limit){
				flag = true;
				break;
			}
		}
		if(flag) break;
		dir = (dir+1)%4;
	}
	
	while(1){
		int m,n;
		cin >> m >> n;
		if(m==0) break;
		int x = to_xy[n].first;
		int y = to_xy[n].second;
		
		int maxnum=0, lastcave=0;
		vector<vector<int> > dp(hsize+2, vector<int>(hsize+2, -1));
		maxnum = dp[x][y] = (prime[n])? 1: 0;
		lastcave = n;
		while(y>0){
			y--;
			for(int i=1; i<=hsize; i++){
				if(cave[i][y] > m) continue;
				int maxparent=-1;
				for(int j=-1; j<=1; j++){
					if(cave[i+j][y+1] > m) continue;
					maxparent = max(maxparent, dp[i+j][y+1]);
				}
				if(maxparent!=-1){
					dp[i][y] = maxparent;
					if(prime[cave[i][y]]){
						dp[i][y]++;
						if((dp[i][y] > maxnum) || (dp[i][y]==maxnum && cave[i][y]>lastcave)){
							maxnum = dp[i][y];
							lastcave = cave[i][y];
						}
					}
				}
			}
		}
		if(maxnum==0){
			cout << "0 0" << endl;
		}else{
			cout << maxnum << " " << lastcave << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 18724
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

int N;
ll sum[2 * MAX_N + 1];

int main(){
	scanf("%d", &N);
	for(int i = 1; i < N + 1; i++){
		scanf("%lld", &sum[i]);
		sum[N + i] = sum[i];
		sum[i] += sum[i - 1];
	}
	for(int i = N + 1; i < 2 * N + 1; i++) sum[i] += sum[i - 1];
	ll res = 0LL;
	ll avg = sum[N] / 3;
	int j = 0, k = 0;
	for(int i = 0; i < N; i++){
		for(; k < i + N && sum[N + i] - sum[k] > avg; k++);
		for(; j < k && sum[j] - sum[i] < avg; j++);
		for(int l = 0; l < 9; l++){
			int sep1 = k + (l / 3) - 1;
			int sep2 = j + (l % 3) - 1;
			res = max(res, min(sum[N + i] - sum[sep1], min(sum[sep1] - sum[sep2], sum[sep2] - sum[i])));
		}
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 4320
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <stdio.h>
#include <string>

int main(){
	int a, b, c;
	std::cin >> a >> b;
	if(a==b) c=a*2;
	else if(a>b) c=a*2-1;
	else c=b*2-1;
	std::cout << c << std::endl;
	return 0;
}


Measured memory_bytes: 256
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M 1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
const ll N=2*1e5+5;
ll po2[N+1][2];
ll z[N+1];
int main()
{
    memset(po2,0,sizeof(po2));
    z[0]=0;
    ll i,j;
    for(i=1;i<=N;i++)
    {
        ll r=0;
        ll u=i;
        while(u>0)
        {
          r+=(u%2);
          u/=2;
        }
        z[i]=z[i%r]+1;
    }
    ll n;
    cin>>n;
    string S;
    cin>>S;
    ll X=0;
    for(i=0;i<n;i++)
    {
        X+=(S[i]-'0');
    }
    if(X==0)
    {
        for(i=0;i<n;i++)
            cout<<1<<"\n";
    }
    else if(X==1)
    {
       if(n==1)
       {
           cout<<0<<"\n";
       }
       else
       {
         if(S[n-1]=='1')
         {
             for(i=0;i<n-1;i++)
                cout<<2<<"\n";

             cout<<0<<"\n";
         }
         else
         {
             for(i=0;i<n;i++)
             {
                 if(S[i]=='1')
                 {
                     cout<<0<<"\n";
                 }
                 else
                 {
                     if(i==n-1)
                        cout<<2<<"\n";
                     else
                        cout<<1<<"\n";
                 }
             }
         }
       }

    }
    else
    {
    ll Y=X+1;
    X=X-1;
    po2[0][0]=1%X;
    po2[0][1]=1%Y;
    for(i=1;i<=n;i++)
    {
        po2[i][0]=(po2[i-1][0]*2)%X;
        po2[i][1]=(po2[i-1][1]*2)%Y;
    }
    ll pr[n+1][2];
    memset(pr,0,sizeof(pr));
    ll sf[n+1][2];
    memset(sf,0,sizeof(sf));
    for(i=1;i<=n;i++)
    {
        ll d=S[i-1]-'0';
        pr[i][0]=(pr[i-1][0]%X+(d*po2[n-i][0])%X)%X;
        pr[i][1]=(pr[i-1][1]%Y+(d*po2[n-i][1])%Y)%Y;
    }
    ll j=1;
    for(i=n;i>=1;i--)
    {
       ll d=S[i-1]-'0';
       sf[j][0]=(sf[j-1][0]%X+(d*po2[n-i][0])%X)%X;
       sf[j][1]=(sf[j-1][1]%Y+(d*po2[n-i][1]%Y))%Y;
       j++;
    }
    j=n-1;
    for(i=1;i<=n;i++)
    {
        if(S[i-1]=='0')
        {
           ll p=(pr[i-1][1]%Y+sf[j][1]%Y)%Y;
           p=(p%Y+po2[n-i][1]%Y)%Y;
           cout<<z[p]+1<<"\n";
        }
        else
        {
            ll p=(pr[i-1][0]%X+sf[j][0]%X)%X;


            cout<<z[p]+1<<"\n";
        }
        j--;
    }
    }

}


Measured memory_bytes: 14688
#include <iostream>
#include <queue>
#include <string.h>
using namespace std;
#define MAXN (10+1)
#define MAXM (30+1)
#define DM (1024+1) // 2^10 + 1
#define INF (1<<20)
int N,M,P,A,B;
int T[MAXN];
int F[MAXM][MAXM];
double D[MAXM][DM];
bool visited[MAXM][DM];

class State {
public:
  int p,use; // point, use, cost
  double c;
  State(int p,int use,double c) : p(p),use(use),c(c) {}
  bool operator < (const State &s) const {
    return c > s.c;
  }
};

double solve(int all) {
  memset(visited,0,sizeof(visited));
  for(int i=1;i<=M;i++) {
    for(int j=0;j<DM;j++) {
      visited[i][j] = false;
      D[i][j] = INF;
    }
  }
  priority_queue<State> PQ;
  PQ.push(State(A,0,0));
  D[A][0] = 0;
  while(!PQ.empty()) {
    State u = PQ.top(); PQ.pop();
    int p = u.p; int use=u.use;
    double c = u.c;
    if(p == B) {
      return D[p][use];
    }
    if(visited[p][use]) continue;
    if((use & all) == all) continue; // have no ticket
    visited[p][use] = true;

    for(int i=1;i<=M;i++) { // pos
      if(i==p) continue;
      if(F[p][i] >= INF) continue;
      for(int j=1;j<=N;j++) { // ticket
	int use2;
	if((use2=(use|(1<<j))) == use) continue;
	double cost = D[p][use] + (double)F[p][i]/T[j];
	if(cost < D[i][use2]) {
	  D[i][use2] = cost;
	  //printf("cost=%lf\n",cost);
	  PQ.push(State(i,use2,cost));
	} 
      }
    }   
    
  }
  return -1;
}

main() {
  while(cin>>N>>M>>P>>A>>B,N) {
    for(int i=0;i<MAXM;i++) {
      for(int j=0;j<MAXM;j++) {
	F[i][j] = INF;
      }
    }
    for(int i=1;i<=N;i++) cin>>T[i];
    for(int i=1;i<=P;i++) {
      int x,y,z; cin>>x>>y>>z;
      F[x][y]=F[y][x] = z; 
    }
    //puts("calc all...");
    int all=0;
    for(int i=0;i<N;i++) all = (all<<1) + 1;
    all <<= 1; // 1-origin
    //printf("solving...\n");
    double ans = solve(all);
    if(ans==-1) puts("Impossible");
    else cout << ans << endl;
  }
}

Measured memory_bytes: 7752
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
using namespace std;
struct node{int l;ll s;} f[2010][2010];
char ans[4010],a[2010];
int n,t;
ll k;

void print()
{
  for (int i=t;i;i--)
    printf("%c",ans[i]);
  cout <<endl;
}
void work(int l,int r,ll k)
{
  if (l==r) {printf("%s%c",ans+1,a[l]); print();return ;}
  if (l==r-1&&a[l]==a[r]) {ans[++t]=a[l]; printf("%s",ans+1); print(); return;}
  if (a[l]==a[r]) {ans[++t]=a[l]; work(l+1,r-1,k);}
  else {
      if (f[l+1][r].l>f[l][r-1].l) {ans[++t]=a[r];work(l,r-1,k);}
      else if (f[l+1][r].l<f[l][r-1].l) {ans[++t]=a[l];work(l+1,r,k);}
      else {
          if (a[l]>a[r])
          {
            if (f[l][r-1].s>=k) {ans[++t]=a[r];work(l,r-1,k);}
            else {ans[++t]=a[l];work(l+1,r,k-f[l][r-1].s);}
          }
          else {
            if (f[l+1][r].s>=k) {ans[++t]=a[l];work(l+1,r,k);}
            else {ans[++t]=a[r];work(l,r-1,k-f[l+1][r].s);}
          }
      }
  }
}

int main()
{
  scanf("%s",a+1);
  cin>>k;
  n=strlen(a+1);
  for (int i=1; i<=n; i++) f[i][i]=(node){0,1};
  for (int i=1;i<=n-1;i++)
    if (a[i]==a[i+1]) f[i][i+1]=(node){0,1};
    else f[i][i+1]=(node){1,2};
  for (int l=3; l<=n; l++)
    for (int i=1; i<=n-l+1;i++)
    {
      int j=i+l-1;
      if (a[i]==a[j]) f[i][j]=f[i+1][j-1];
      else {
        if (f[i+1][j].l>f[i][j-1].l) f[i][j]=(node){f[i][j-1].l+1,f[i][j-1].s};
        else if (f[i+1][j].l<f[i][j-1].l) f[i][j]=(node){f[i+1][j].l+1,f[i+1][j].s};
        else f[i][j]=(node){f[i][j-1].l+1,f[i+1][j].s+f[i][j-1].s};
      }
      if (f[i][j].s>k) f[i][j].s=k+1;
    }
  if (f[1][n].s<k) puts("NONE"); else work(1,n,k);
  return 0;
}

Measured memory_bytes: 62820
#include<bits/stdc++.h>
using namespace std;
char c1[16]={'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
char c2[16];
int main(){
	cin>>c2;int ans=0;
	for(int i=0;i<16;i++) if(c1[i]!=c2[i]) ans++;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output14.txt", "w", stdout);
#endif
	int n, d, ans = 0;
	cin >> n >> d;
	for (int i = 0; i < n; i++)
	{
		long a, b;
		cin >> a >> b;
		long double aa = sqrt((a * a) + (b * b));
		if (aa <= (long double)d)
			ans++;
	}

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

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const int MAX_N = 1e5+15;
int A,B,C;

void solve()
{
	cout <<min(A+B,min(A+C,B+C))<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> A >> B >> C;
	solve();
	return 0;
}


Measured memory_bytes: 256
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){

	fastio;
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vector<int> vred(a),vgreen(b);
	REP(i,0,a) cin >> vred[i];
	REP(i,0,b) cin >> vgreen[i];
	sort(vred.rbegin(),vred.rend());
	sort(vgreen.rbegin(),vgreen.rend());
	
	ll ans = 0;
	priority_queue<int,vector<int>,greater<int>> pq;
	REP(i,0,x){ ans += vred[i]; pq.push(vred[i]); }
	REP(i,0,y){ ans += vgreen[i]; pq.push(vgreen[i]); }

	vector<int> white(c);
	REP(i,0,c) cin >> white[i];
	sort(white.rbegin(),white.rend());
	for(int x : white){
		if(x > pq.top()){
			ans -= pq.top(); pq.pop();
			ans += x; pq.push(x);
		}
	}
	cout << ans << endl;

	return 0;
}
//

Measured memory_bytes: 2168
#include<stdio.h>
int main(void){
	long n;
	long x = 0;
	scanf("%ld", &n);
	for(int i=1; i<=n; i++){
		if(i%3!=0 && i%5!=0){
			x += i;
		}
	}
	printf("%ld\n", x);
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll> T;
long long euclid(long long x,long long y){
    long long a=max(x,y);
    long long b=min(x,y);
    if(a%b==0)return b;
    else{
        return euclid(b,a%b);
    }
}
long long ruijou(long long x, long long y){
    if(y==0) return 1;
    else if(y%2==0) return ruijou(x*x%mod,y/2);
    else return x*ruijou(x,y-1)%mod;
}


ll i,j,k;

int main(){
   ll A,B,C,D,K;
   cin>>A>>B>>C>>D>>K;
   ll okitime=(C-A)*60+(D-B);
   cout<<okitime-K<<endl;
}


Measured memory_bytes: 3596
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXA = 1e6 + 10;
const int MAXN = 1e4 + 10;
const int MOD = 1e9 + 7;
int factor[MAXA];
int a[MAXN];

void factors(int x){
    for(int i=2;i*i<=x;i++){
        int mul = 1;
        while(x%i == 0) x/=i,mul*=i;
        factor[i] = max(factor[i],mul);        
    }
    if(x > 1) factor[x] = max(factor[x],x);
}

int power(int x,int y){
    int res = 1;
    while(y){
        if(y&1) res = (res*x)%MOD;
        x = (x*x)%MOD;
        y >>= 1;
    }
    return res;
}

void solve(){
    int n; cin>>n;
    FOR(i,1,n){
        cin>>a[i]; factors(a[i]);
    }

    int lcm = 1;

    FOR(i,1,MAXA-1) lcm = (lcm*max(1LL,factor[i]))%MOD;

    int ans = 0;
    FOR(i,1,n) ans = (ans + power(a[i],MOD-2))%MOD;

    ans = (ans*lcm)%MOD;
    cout<<ans<<endl;
}

signed main(){

   FastRead;    

    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 6656
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

locale l = locale::classic();

int main(){
    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
s = list(input())

def list_intersection(a,b):
    c = []
    for i in range(len(a)):
        for j in range(len(b)):
            if a[i] == b[j]:
                c.append(a[i])
                a[i] = "_"
                b[j] = "&"
    return c

ans = 0
for i in range(1,n):
    inter = list_intersection(s[:i],s[i:])
    inter = set(inter)
    inter = list(inter)
    ans = max(ans,len(inter))

print(ans)


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

int N;
int data[110];

void input(){
  for(int i = 0 ; i < N ; i++)cin >> data[i];
}

void solve(){
  input();
  for(int i = 0 ; i < N ; i++){
    vector<int>vec;
    for(int j = 0 ; j < N ; j++){
      if(j == i)continue;
      vec.push_back(data[j]);
    }

    int diff = vec[1] - vec[0];
    bool f = true;
    for(int j = 2 ; j < vec.size() ; j++){
      if(vec[j] - vec[j-1] != diff)f = false;
    }
    if(f){
      cout << data[i] << endl;
      return;
    }
  }
}

int main(){
  while(cin >> N,N){
    N++;
    solve();
  }
  return 0;
}

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

long long pow9[4];

inline long long NchooseK(int N, int K) {
	long long res = 1;
	for (int i = 1; i <= K; i++, N--) {
		res = res * N / i;
	}
	return res;
}

int main() {
	pow9[0] = 1;
	for (int i = 1; i < 4; i++) {
		pow9[i] = pow9[i - 1] * 9;
	}
	string N;
	int K;
	cin >> N >> K;
	long long res = 0;
	for (int index = 0; K <= N.size() - index && index <= N.size(); index++) {
		if (index == N.size()) {
			if (K == 0) res++;
			break;
		}
		if (N[index] == '0') continue;
		int remain = N.size() - index - 1;
		if (remain >= K) {
			res += NchooseK(remain, K) * pow9[K];
		}
		if (remain >= K - 1) {
			int size = N[index] - '0' - 1;
			res += NchooseK(remain, K - 1) * pow9[K - 1] * size;
		}
		if (N[index] > '0') K--;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
n = gets.to_i
towns = n.times.map { gets.split.map(&:to_i) }
towns

s = towns.permutation(n).size
sum = towns.permutation(n).map{|ordered_towns|
  ordered_towns.each_cons(2).map{|a, b|
    Math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)
  }.inject(:+)
}.inject(:+)

puts sum/s

Measured memory_bytes: 2296
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array.IArray
import Data.Graph (buildG)

bfs :: Int -> Array Int [Int] -> [[Int]]
bfs n g = queue
  where
    queue = [1] : walk queue
    walk (xs:xss) = bss ++ walk xss
      where
        as = g ! head xs
        bss = zipWith (:) as (repeat xs)

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine
    as <- fmap concat . replicateM m $ do
        [a, b] <- fmap read . words <$> getLine
        return [(a, b), (b, a)]
    let g = buildG (1, n) as
    let ps = filter ((== n) . length) $ takeWhile ((<= n) . length) (bfs n g)
    let ans = length $ filter (\xs -> sort xs == [1..n]) ps
    print ans

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

int main(void) {
	int A, B, C;

	cin >> A >> B >> C;
	if ((A == 7 && B == 5 && C == 5)
		|| (A == 5 && B == 7 && C == 5)
		|| (A == 5 && B == 5 && C == 7))
		cout << "YES" << '\n';
	else
		cout << "NO" << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
main()
{
    int n,a,i,j,k;
    scanf("%d%d",&n,&a);
    k=n;
    char s[k][150],d[150];
    for(i=0;i<k;i++){
        fflush(stdin);
        scanf("%s",&s[i]);
    }
    for(i=0;i<k-1;i++){
        for(j=i+1;j<k;j++){
            if(strcmp(s[i],s[j])>0){
                fflush(stdin);
                strcpy(d,s[j]);
                strcpy(s[j],s[i]);
                strcpy(s[i],d);

            }
        }
    }
    for(i=0;i<k;i++){
        printf("%s",s[i]);
    }
    printf("\n");
}


Measured memory_bytes: 1728
#include <iostream>

int main() {
    std::string str;
    std::cin >> str;
    // from 0
    char init = '0';
    int sum0 = 0, sum1 = 0;
    for (int i = 0; (i < str.length()); ++i) {
        if (init != str[i]) sum0++;
        init = (init == '0') ? '1' : '0';
    }
    init = '1';
    for (int i = 0; (i < str.length()); ++i) {
        if (init != str[i]) sum1++;
        init = (init == '0') ? '1' : '0';
    }
    std::cout << std::min(sum0, sum1) << std::endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  f80 R;
  cin >> R;
  cout << 2 * R * 3.14159265359 << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 3808
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N, M;

int X[MAX_N];

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

    cin >> N >> M;

    unordered_set<int> tost;
    unordered_set<int> fromst;

    for (int i = 0; i < M; i++) {
        int s, t;
        cin >> s >> t;
        if (s == 1) {
            tost.insert(t);
        } else if (t == 1) {
            tost.insert(s);
        } else if (s == N) {
            fromst.insert(t);
        } else if (t == N) {
            fromst.insert(s);
        }
    }

    bool canreach = false;
    for (int i = 1; i <= N; i++) {
        if (tost.count(i) && fromst.count(i)) {
            canreach = true;
            break;
        }
    }
    if (canreach) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}

Measured memory_bytes: 11360
X = int(input())
Y = int(pow(X, 1/5) * 2)

for a in range(1, Y+1, 1):
  r = (a ** 5) - X
  b = 0
  if r >= 0:
    b = pow(r, 1/5)
  else:
    b = -pow(-r, 1/5)
  if round(b) ** 5 == r:
    print(a, int(b))
    break

Measured memory_bytes: 9452
package main

import (
  "fmt"
)

func main() {
  // var a int
  // fmt.Scan(&a)

  // fmt.Println(a)

  var a, b, c string
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&c)

  fmt.Print(a[:1])
  fmt.Print(b[1:2])
  fmt.Print(c[2:])
}

Measured memory_bytes: 512
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int inf = 1<<31-1;
const ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(void) {
    int n, k; cin >> n >> k;
    vector<int> l(k), r(k);
    rep(i, k) cin >> l[i] >> r[i];
    vector<int> dp(n * 3, 0);
    dp[0] = 1; dp[1] = MOD - 1;
    rep(i, n) {
        dp[i + 1] += dp[i]; dp[i + 1] %= MOD;
        rep(j, k) {
            dp[i + l[j]] += dp[i];
            dp[i + l[j]] %= MOD;
            dp[i + r[j] + 1] -= dp[i] - MOD;
            dp[i + r[j] + 1] %= MOD;
        }
    }cout << dp[n - 1] << endl;
}

Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int a,b;
   cin>>a>>b;
   
   int N;
   if(b<10){
       N=10*a+b;
   }
   else if(b>=10&&b<100){
       N=100*a+b;
   }
   else {
       N=1000*a+b;
   }
   bool ok=false;
   rep(i,N){
       if(i*i==N){
           ok=true;
           break;
       }
   }
   if(ok){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
  
}

Measured memory_bytes: 3596