akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll N = input();
  string S = input<string>();
  vector<ll> r;
  vector<ll> g;
  vector<ll> b;
  
  for(int i=0;i<N;i++){
    if(S[i] == 'R'){
      r.push_back(i);
    }
    if(S[i] == 'G'){
      g.push_back(i);
    }
    if(S[i] == 'B'){
      b.push_back(i);
    }
  }

  ll sum = 0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int k = 2*j - i;
      if(k >= N)continue;
      if(S[i] != S[j] && S[i] != S[k] && S[j] != S[k]){
        sum++;
      }
    }
  }
  
  output(r.size() * g.size() * b.size() - sum);
  return 0;
}

Measured memory_bytes: 3656
//
//  main.cpp
//

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

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

struct Mod {
    static ll BASE;
    ll value = 0;
    static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
    Mod(ll value)
    : value(residue(value)) {}
    Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
    void operator+=(const Mod& rhs) { *this = *this + rhs; }
    Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
    void operator-=(const Mod& rhs) { *this = *this - rhs; }
    Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
    void operator*=(const Mod& rhs) { *this = *this * rhs; }
};
ll Mod::BASE = 1000000007;

int main() {
    ll N;
    cin >> N;
    auto linked = make_vec_nd(false, N, N);
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            ll ai;
            cin >> ai;
            linked[i][j] = (bool)ai;
        }
    }
    vector<Mod> dp(1 << N, (Mod)0);
    dp[0] = 1;
    for (ll flag = 0; flag < (1 << N) - 1; flag++) {
        ll cnt = 0;
        for (ll i = 0; i < N; i++) {
            if (flag & (1 << i)) {
                cnt++;
            }
        }
        for (ll i = 0; i < N; i++) {
            if ((flag & (1 << i)) == 0 && linked[cnt][i]) {
                dp[flag | (1 << i)] += dp[flag];
            }
        }
    }
    cout << dp[(1 << N) - 1].value << endl;
}


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

int main(int argc, char const* argv[]) {
    int k, n;
    cin >> k >> n;
    auto as = vector<int>(k);
    for (auto&& a : as) {
        cin >> a;
    }

    cout << ceil((k - 1) / (float)(n - 1)) << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
const int MAX_V = 1000000;//1000000?????§????´???°??¨?????????
int prime [999999];//??¨?????????????????????????????????
int sum[1000000];//?´????????????????
int main(){
	
	int i, k, n;
	for(i = 2; i < MAX_V; i++){
		prime[i] = 1;
	}
	for(i = 2; i*i < MAX_V; i++){//??¨?????????????????????????????¨????????????
		if(prime[i] == 1){
			for(k = 2*i; k < MAX_V; k += i){
				prime[k] = 0;//?´???°????????°????´???°??§??????
			}
		}
	}
	for(i = 2; i < MAX_V; i++){//?´????????????????
		sum[i + 1] = sum[i] + prime[i];//
	}
	while(scanf("%d", &n) != EOF){
		printf("%d\n", sum[n + 1]);
	}
	return 0;
}

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {

    static int n;
    static int[][] g;

    public static int maxPath(int i, int j){
        if(i==1 && j == n-1){
            return g[i][j];
        }
        if(i>1 || j>n-1){
            return 0;
        }

        return g[i][j] + Math.max(maxPath(i+1,j), maxPath(i,j+1));
    }

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        g = new int[2][n];
        for(int i=0; i<2; i++){
            for(int j=0; j<n; j++){
                g[i][j] = in.nextInt();
            }
        }
        System.out.println(maxPath(0,0));

    }
}


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

int main(void){
	string str;
	cin >> str;
	int j = str.length();
	for(int i = 0; i < j; i++){
		str[i] -= 3;
		if(str[i] < 'A')
			str[i] += 'Z' - 'A' + 1;
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 1180
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
        double a1,a2,b1,b2,c1,c2,x,y;
        while(scanf("%lf%lf%lf%lf%lf%lf",&a1,&b1,&c1,&a2,&b2,&c2)!=EOF){
                x=(b2*c1-c2*b1)/(a1*b2-a2*b1);
                y=(a1*c2-a2*c1)/(a1*b2-a2*b1);
                if(x==-0)x=0;
                if(y==-0)y=0;
                printf("%.3lf %.3lf\n",x,y);
        }
        return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,i;
  cin>>n>>m;
  long long ans=n;
  vector<long long>h(n+1),a(m),b(m),sm(n+1,0);
  for(i=1;i<=n;i++){
    scanf("%lld",&h[i]);
  }for(i=0;i<m;i++){
    scanf("%lld%lld",&a[i],&b[i]);
    if(h[a[i]]<=h[b[i]]) sm[a[i]-1]++;
    if(h[b[i]]<=h[a[i]]) sm[b[i]-1]++;
  }for(i=0;i<n;i++){
    if(sm[i]!=0) ans--;
  }cout<<ans<<endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;
#define MAXN 100000
#define ll long long
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
vector<int> e[MAXN+5], f[MAXN+5]; bool sl; int color[MAXN+5], n, m; ll Ans, c[3], s;
void DFS(int p, int x){if(~color[p]){sl |= color[p]^x; return;} color[p] = x, ++c[x], ++s, m += e[p].size(); for(auto v:e[p]) DFS(v,-~x%3); for(auto v:f[p]) DFS(v,-~-~x%3);}
int main()
{
	n = read(); for(rint a, b = c[0] = read(); c[0]; a = read(), b = read(), e[a].push_back(b), f[b].push_back(a), c[0]--); memset(color+1,-1,n<<2);
	for(rint i = 1; i <= n; color[i]<0 ? DFS(i,s=c[0]=c[1]=c[2]=m=sl=0), Ans = sl?Ans+s*s:c[0]&&c[1]&&c[2]?Ans+c[0]*c[1]+c[1]*c[2]+c[2]*c[0]:Ans+m : 0, i++); printf("%lld\n",Ans); return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll Ai;
    vector<ll> A;
    for(int i=0;i<N;i++){
        cin >> Ai;
        A.push_back(Ai);
    }
    sort(A.begin(), A.end());
    vector<ll> Asum;
    for(int i=0;i<N;i++){
        if(i==0){
            Asum.push_back(A[i]);
        }else{
            Asum.push_back(A[i] + Asum.back());
        }
    }
    ll res = N-1;
    for(;res>=0;res--){
        if(res==0) break;
        if(A[res] > 2 * Asum[res-1]) break;
    }
    cout<<(N-res)<<endl;

    return 0;
}

Measured memory_bytes: 2548
# D - Powerful Discount Ticket
from heapq import heappush, heappop
N, M = map(int, input().split())
A = list(map(int, input().split()))

queue = []
for a in A:
    heappush(queue, -a)
    
for _ in range(M):
    tmp = heappop(queue)
    heappush(queue, int(tmp / 2))
    
ans = 0
for _ in range(N):
    ans -= heappop(queue)
    
print(ans)

Measured memory_bytes: 14180
#include "bits/stdc++.h"
using namespace std;
const int K = 43;

long long calc(long long N) {
	vector<long long> x;
	for (long long i = 2; i*i <= N; i++) {
		int m = 0;
		while (N%i == 0) { // 素数で割り切れなくなるまで割っていく
			m++;//割った個数を配列に足す
			N /= i;
		}
		if (0 != m) {
			x.push_back(m);
		}
		if (1 == N) {
			break;
		}
	}
	if (1 != N) {
		x.push_back(1);
	}

	long long nAns = 1;
	for (long long n = 0; n < x.size(); ++n) {
		nAns *= x[n] + 1;
	}
	return nAns;
}

long long calc2(long long N) {
	long long nAns = 0;
	for (long long i = 2; i <= sqrt(N); i++) {
		if (0 == N % i) {
			{
				long long tmpN = N;
				while (tmpN%i == 0) {
					tmpN /= i;
				}
				if (1 == tmpN % i) {
					nAns++;
				}
			}
			{			
				long long tmpN = N;
				long long isub = N / i;
				if (isub == i) {
					continue;
				}
				while (tmpN%isub == 0) {
					tmpN /= isub;
				}
				if (1 == tmpN % isub) {
					nAns++;
				}
			}
		}
	}
	return nAns + 1;
}


int main() {
	long long N;
	cin >> N;
	int n = 0;
	//case1
	// N = 1+ nk を満たす２以上のもの
	long long ans1 = calc(N - 1) - 1;
	//case2
	// N = (k+1)*k^n
	long long ans2 = calc2(N);
	cout << ans1+ans2<<  endl;
	return 0;
}




Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    string s;
    cin>>s;
    int ans = 0;
    if (s == "RRR") {
        cout<<3;
        return;
    }
    if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
        cout<<2;
        return;
    }
    if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout<<1;
    else cout<<0;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }


signed main()
{
    int N,M; cin>>N>>M;
    vector<int> sum(N+1);
    for(int i=0;i<M;i++){
        int l,r; cin>>l>>r;
        l--; r--;
        sum[l]++; sum[r+1]--;
    }
    for(int i=0;i<N;i++){
        sum[i+1]+=sum[i];
    }
    
    int ans=0;
    for(int i=0;i<N;i++){
        if(sum[i]==M) ans++;
    }
    cout<<ans<<endl;
}


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

struct UNION_FIND
{
	vector <int> parent, height, sum;
	UNION_FIND() { ; };
	UNION_FIND(int n)
	{
		parent.resize(n + 1), height.resize(n + 1, 1);
		sum.resize(n + 1, 1);
		for (int i = 1; i <= n; i++)
			parent[i] = i;

	}
	int find(int n)
	{
		if (parent[n] == n) return n;
		return find(parent[n]);
	}
	void merge(int u, int v)
	{
		u = find(u), v = find(v);
		if (u == v)
		{
			return;
		}
		if (height[u]>height[v])
			swap(u, v);
		parent[u] = v;
		sum[v] += sum[u];
		if (height[u] == height[v])
			height[v]++;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, M;
	cin >> N >> M;
	UNION_FIND uf(N + 1);
	while (M--) {
		int u, v;
		cin >> u >> v;
		uf.merge(u, v);
	}
	set<int>st;
	for (int i = 1; i <= N; i++)st.insert(uf.find(i));
	cout << st.size() - 1;
}

Measured memory_bytes: 8184
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    vint a(4);
    REP(i,4) a[i]=s[i]-'0';

    REP(S,1<<3){
        int res=a[0];
        REP(i,3){
            if(S>>i&1) res+=a[i+1];
            else res-=a[i+1];
        }
        if(res==7){
            string ans="0-0-0-0=7";
            REP(i,4) ans[i*2]='0'+a[i];
            REP(i,3) if(S>>i&1) ans[i*2+1]='+';
            cout<<ans<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  string s; cin >> s;
  if(s=="ABC") puts("ARC");
  else puts("ABC");
  return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int getgcd(int n, int m)
{
	int r;
  	int t;
  
	if (n > m) {
		t = m;
		m = n;
		n = t;
	}
	while ((r = m % n) != 0) {
		m = n;
		n = r;
	}
	return n;
}

int	main(void)
{
  	int	K;
  	int	i;
  	int	j;
  	int	k;
  	long long sum;
  	
  	scanf("%d", &K);
  	
  	sum = 0;
  	for(i=1; i<=K; i++)
    {
      	for(j=1; j<=K; j++)
        {
          	for(k=1; k<=K; k++)
            {
              	sum += getgcd(getgcd(i, j), k);
            }
        }
    }
  	printf("%lld", sum);
  	return (0);
}

Measured memory_bytes: 1732
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    int A,B,K;
    cin>>A>>B>>K;
    if(A+K-1<B-K+1) {for(int i=0;i<K;i++){ cout<<A+i<<"\n";} for(int k=0;k<K;k++){cout<<B-K+k+1<<"\n";}}
    else for(int j=0;j<=B-A;j++){cout<<A+j<<"\n";}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int bounding(int n,int x,int l[])
{
    int sum = 0;
    int i = 0;
    while(sum<=x)
    {
        sum+=l[i];
        i++;
    }
    return i;
}
int main()
{
    int n,x,l[101],res;
    cin>>n>>x;
    for(int i=0;i<n;i++)
        cin>>l[i];
    res = bounding(n,x,l);
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char order[100];
    //char number[1000];
    //char *getInt;
    int x[200];
    int j, q, k = 0;
    
    if(fgets(order, 1000, stdin) == NULL){
        printf("エラーー\n");
    }
    sscanf(order, "%d", &j);
    /*if(fgets(number, 1000, stdin) == NULL){
        printf("エラー\n");
    }
    getInt = strtok(number, " \n");
    sscanf(getInt, "%d", &x[0]);
    for(int i = 1; i < j; i++){
        getInt = strtok(NULL, " \n");
        sscanf(getInt, "%d", &x[i]);
    }*/
    for(int i = 0; i < j; i++){
        scanf("%d", &x[i]);
    }
    while(1){
        for(q = 0; q < j; q++){
            if(x[q] % 2){
                break;
            }else{
                x[q] /= 2;
            }
        }
        if(q == j){
            k++;
        }else{
            break;
        }
    }
    printf("%d\n", k);
    return 0;
}

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 ans=0,m=1e9;
  vector<int> vec(5);
  rep(i,5){
    cin>>vec[i];
    int c=vec[i]%10;
    if(c!=0)m=min(m,c);
    ans+=(vec[i]+9)/10*10;
  }
  if(m!=1e9)ans=ans+m-10;
  cout<<ans<<endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,a[51],s=0;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=n-k+1;i<=n;i++)s+=a[i];
	cout<<s<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_H = 1000, MAX_W = 1000;
int H, W;
int field[MAX_H][MAX_W];
int dist[MAX_H][MAX_W];

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

  cin >> H >> W;
  string str;
  rep(i,H) {
      cin >> str;
      rep(j, W) {
          if (str[j] == '#') {
              field[i][j] = 1;
          } else {
              field[i][j] = 0;
          }
      }
  }

  rep(i, H) {
      rep(j, W) {
          dist[i][j] = INFINT;
      }
  }

  queue<Pii> que;
  rep(i, H) {
      rep(j, W) {
          if (field[i][j] == 1) {
              dist[i][j] = 0;
              que.push(Pii(i, j));
          }
      }
  }

  while (!que.empty()) {
      Pii pii = que.front(); que.pop();
      for (int k = 0; k < 4; ++k) {
          int nx = pii.fi + dx[k], ny = pii.sc + dy[k];
          if (0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] == 0 && dist[nx][ny] == INFINT) {
              dist[nx][ny] = dist[pii.fi][pii.sc] + 1;
              que.push(Pii(nx, ny));
          }
      }
  }

  int ans = 0;
  rep(i, H) {
      rep(j ,W) {
          if (field[i][j] == 0) {
              ans = max(ans, dist[i][j]);
          }
      }
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 16000
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  ll n,m;
  cin >> n >> m;
  
  int a,b,c,d;
  
  a = m+n+1<0?INF:m+n+1;
  b = m-n<0?INF:m-n;
  c = -m-n+1<0?INF:-m-n+1;
  d = -m+n+2<0?INF:-m+n+2;
  
  cout << min({a,b,c,d}) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;

ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }

inline int read(){
	char ch = getchar();
	int x = 0, f = 1;
	while(ch < '0' || ch > '9'){
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

int dp[maxn];//0 必败态; 1必胜态; -1尚未确定;
int a[105];
int n, k;
int cnt = 0;

bool dfs(int now){
	if(~dp[now]) return dp[now];
	bool ret = 0;
	rep(i, 1, n){
		if(a[i] > now) break;
		if(!dfs(now - a[i])) ret = 1;
	}
	return dp[now] = ret;
}

int main()
{
	n = read(), k = read();
	rep(i, 1, n) a[i] = read();
	memset(dp, -1, sizeof dp);
	sort(a + 1, a + n + 1);
	dp[0] = 0;
	dfs(k);
	puts(dp[k] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W, H, N, i, white = 0;
  cin >> W >> H >> N;
  int Mx = 0, mx = W, My = 0, my = H;
  vector<int> x(N), y(N), a(N), black(4);
  for (i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i) >> a.at(i);
    if (a.at(i) == 1) Mx = max(x.at(i), Mx);
    if (a.at(i) == 2) mx = min(x.at(i), mx);
    if (a.at(i) == 3) My = max(y.at(i), My);
    if (a.at(i) == 4) my = min(y.at(i), my);
  }
  
  if (Mx < mx && My < my) white = (mx - Mx) * (my - My);
  
  cout << white << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
// Time Complexity: O(1)
// Space Complexity: O(1)
int a, b;
cin >> a >> b;
int c(max(a / 2 * 25 + (a % 2 ? 13 : 0), b * 10));
cout << (floor(c * 0.08) == a && floor(c * 0.1) == b ? c : -1) << '\n';
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    double N, M; cin >> N >> M;
    vector<double> A(N);
    double total = 0;
    rep (i, 0, N) {
        cin >> A[i];
        total += A[i];
    }

    double div = total * (1.0 / (4.0 * M));
    int ans = 0;
    rep (i, 0, N) {
        if (A[i] >= div) ++ans;
    }

    if (ans >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100


void selectionSort(int array[],int n,int& change_count)
{
	int min;
	for(int i = 0; i < n-1; i++){
		min = i;	//?????????
		for(int j = i+1; j < n; j++){
			if(array[j] < array[min]){
				min = j;
			}
		}
		if(i != min){
			swap(array[i],array[min]);
			change_count++;
		}
	}

}

int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[ARRAY_SIZE];
	int change_count = 0;

	for(int i = 0; i < n; i++){
		cin >> array[i];
	}

	selectionSort(array,n,change_count);

	for(int i = 0; i < n; i++){
		if(i != n-1){
			printf("%d ",array[i]);
		}else{
			printf("%d\n",array[i]);
		}
	}
	printf("%d\n",change_count);
}

Measured memory_bytes: 1168
import itertools
 
N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

a = 0
b = 0
for i, x in  enumerate(itertools.permutations(range(1, N + 1))):
    #print(i, x)
    if x == p:
        a = i
    if x == q:
        b = i
print(abs(a - b))

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func main() {
	io := NewIo()
	defer io.Flush()

	list := make([]int, 5)
	largeIndex := 0
	for i := 0; i < 5; i++ {
		list[i] = io.NextInt()
		if (list[largeIndex]-1)%10 > (list[i]-1)%10 {
			largeIndex = i
		}
	}

	res := 0
	for i := 0; i < 5; i++ {
		if largeIndex == i {
			res += list[i]
		} else {
			res += 10 * (list[i] / 10)
			if list[i]%10 != 0 {
				res += 10
			}
		}
	}

	io.PrintLn(res)
}


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

int main() {
  int n; cin >> n;
  vector<char> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];

  char ans = a[0];
  for (int i = 1; i < n; i ++) {
    if (ans == 'F') ans = 'T';
    else if (a[i] == 'T') ans = 'T';
    else ans = 'F';
  }

  cout << ans << endl;
}



Measured memory_bytes: 3168
#include <iostream>

using namespace std;

int main(){
    char b;
    cin >> b;
    if(b == 'A') cout << 'T' << endl;
    if(b == 'T') cout << 'A' << endl;
    if(b == 'C') cout << 'G' << endl;
    if(b == 'G') cout << 'C' << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

l = 0
r = max(a)

while r - l > 1:
    cnt = 0
    mid = (r + l) // 2
    for i in range(n):
        d = (a[i] // mid) + (a[i] % mid != 0) - 1
        cnt += d
    if cnt <= k: r = mid
    else: l = mid 

print(r)

Measured memory_bytes: 30768
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int E,Y;
  cin>>E>>Y;
  if(E==0){
    if(1868<=Y&&Y<=1911){
      cout<<"M"<<Y-1868+1<<endl;
    }else if(1912<=Y&&Y<=1925){
      cout<<"T"<<Y-1912+1<<endl;
    }else if(1926<=Y&&Y<=1988){
      cout<<"S"<<Y-1926+1<<endl;
    }else{
      cout<<"H"<<Y-1989+1<<endl;
    }
  }else if(E==1){
    cout<<1868+Y-1<<endl;
  }else if(E==2){
    cout<<1912+Y-1<<endl;
  }else if(E==3){
    cout<<1926+Y-1<<endl;
  }else{
    cout<<1989+Y-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int cnt = 0, v = 0;
	while (v <= n) {
		cnt++;
		v = 2 * v + 1;
	}
	cout << cnt - 1 << endl;
}


Measured memory_bytes: 3128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        // 文字数が奇数の場合は絶対に条件を満たさない
        if (a.length() % 2 != 0) {
            System.out.println("No");
            return;
        }
        int cnt = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            for (int i = 0; i < a.length(); i++) {
                if (a.charAt(i) == c) {
                    cnt++;
                }
            }
            if (cnt % 2 != 0) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define eps 0.000000001
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int main(){
	char x;cin>>x;
	if(x>='a'&&x<='z') cout<<"a"<<endl;
	else{
		cout<<"A"<<endl;
	}
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

void add_score(ll& s, const char& c, map<char, int>& score){
    if(c == 'r'){
        s += score['p'];
    }
    else if(c == 's'){
        s += score['r'];
    }
    else{
        s += score['s'];
    }
}

/*void selection(vector<char>& select, const char& c, int i){
    if(c == 'r'){
        select[i] = 'p';
    }
    else if(c == 's'){
        select[i] = 'r';
    }
    else{
        select[i] = 's';
    }
}*/

int main()
{
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P;
    cin >> T;
    ll ans = 0;
    vector<char> select(N+1);
    map<char, int> score;
    score['r'] = R;
    score['s'] = S;
    score['p'] = P;
    for(int i=1;i<=N;++i){
        if(i > K){
            if(select[i - K] != T[i-1]){
                add_score(ans, T[i-1], score);
                select[i] = T[i-1];
            }
        }
        else{
            add_score(ans, T[i-1], score);
            select[i] = T[i-1];
        }
    }
    cout << ans << endl;
}


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

using namespace std;


int main(){
  long n;
  cin >> n;
 
 vector<long> a(n),b(n),c(n);
  
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) cin >> b[i];
  for(int i=0;i<n;i++) cin >> c[i];
  
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  
  long res=0;
  
  for(int i=0;i<n;i++){
   long num_c=n-(upper_bound(c.begin(),c.end(),b[i])-c.begin());
   long num_a=lower_bound(a.begin(),a.end(),b[i])-a.begin();
   res+=num_c*num_a;
  }
    
  cout << res << endl;
}

Measured memory_bytes: 2560
from collections import deque


def solver(K):
    q = deque([i for i in range(1, 10)])

    if K <= 9:
        ans = q[K - 1]

    else:
        cnt = 9
        for i in range(1, K):
            c = q.popleft()

            if c % 10 != 0:
                q.append(c * 10 + (c % 10) - 1)
                cnt += 1
                if cnt >= K:
                    break

            q.append(c * 10 + (c % 10))
            cnt += 1
            if cnt >= K:
                break

            if c % 10 != 9:
                q.append(c * 10 + (c % 10) + 1)
                cnt += 1
                if cnt >= K:
                    break

        ans = q[-1]
    return ans


def run():
    K = int(input())
    ans = solver(K)

    print(ans)


run()


Measured memory_bytes: 12204
import java.util.*;

public class Main {

    static class UnionFind {
        int[] size;
        int[] id;

        public UnionFind(int n) {
            size = new int[n];
            id = new int[n];

            for (int i = 0; i < n; ++i) {
                size[i] = 1;
                id[i] = i;
            }
        }

        void unify(int p, int q) {
            int root1 = find(p);
            int root2 = find(q);

            if (size[root1] > size[root2]) {
                size[root1] += size[root2];
                id[root2] = root1;
            } else {
                size[root2] += size[root1];
                id[root1] = root2;
            }
        }

        int find(int p) {
            int root = p;
            while (root != id[root]) root = id[root];
            while (p != root) {
                int next = id[p];
                id[p] = root;
                p = next;
            }
            return root;
        }

        boolean connected(int p, int q) {
            return find(p) == find(q);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        UnionFind uf = new UnionFind(n);
        for (int i = 0; i < q; ++i) {
            int com = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (com == 0) uf.unify(x, y);
            else {
                if (uf.connected(x, y))
                    System.out.println(1);
                else
                    System.out.println(0);
            }
        }
    }
}


Measured memory_bytes: 102564
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b,t;
  cin>>a>>b>>t;
  cout<<(t/a)*b<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a[] = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int min = Integer.MAX_VALUE;
        for (int i = -100; i <= 100; i++) {
            int total = 0;
            for (int j = 0; j < n; j++) {
                int s = (a[j] - i);
                total += s * s;
            }

            min = Math.min(min, total);
        }

        System.out.println(min);
    }
}

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

using namespace std;

int main()
{
    int N;
    int L;
    cin >> N >> L ;
    int po = L;
    int wa = 0;
    for (int i = 0; i < N; i++)
    {
        if(abs(L+i)<abs(po)){
            po = L+i;                
        }
            /* code */
    }
    for (int k = 0; k < N; k++)
    {
        wa = wa + L+k;/* code */
    }
    cout << wa-po;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<vector<int>> v(n, vector<int>(3));
  int not_zero = -1;
  rep(i, 0, n) {
    rep(j, 0, 3) cin >> v[i][j];
    if (v[i][2])
      not_zero = i;
  }

  rep(cx, 0, 101) {
    rep(cy, 0, 101) {
      bool flg = true;
      ll H =
          abs(v[not_zero][0] - cx) + abs(v[not_zero][1] - cy) + v[not_zero][2];
      rep(i, 0, n) {
        ll h = abs(v[i][0] - cx) + abs(v[i][1] - cy);
        if ((v[i][2] == 0 && H > h) || (v[i][2] > 0 && H - v[i][2] != h))
          flg = false;
      }
      if (flg) {
        cout << cx << " " << cy << " " << H << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll x; cin>>x;
	ll a=0;
	rep(i,1,x+1){
		a+=i;
		if(a>=x){
			cout<<i;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
int cnt[1000010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    
    rep(i, N) {
        int num = A[i];
        for(int j = 2; j * j <= 1000000; j++) {
            int tmp = 0;
            while(num % j == 0) {
                tmp++;
                num /= j;
            }
            //cout << j << " " << tmp << endl;
            if (cnt[j] < tmp) cnt[j] = tmp;
        }
        if (cnt[num] == 0) cnt[num] = 1;
    }
    int ans = 0;
    int C = 1;
    REP(i, 2, 1000000) {
        //if (cnt[i] > 0) cout << i << " " << cnt[i] << endl;
        C = Mul(C, power(i, cnt[i]));
    }
    //cout << C << endl;
    rep(i, N) {
        ans = (ans + Div(C, A[i])) % mod;
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 8320
N=int(input())
A=[int(i) for i in input().split()]
Q=int(input())
X=[i+1 for i in range((10**5))]
dic={}
ans=sum(A)
for i in A:
	try:
		dic[i]+=1
	except:
		dic.setdefault(i,1)
for i in range(Q):
	[B,C]=[int(i) for i in input().split()]
	try:
		ans+=dic[B]*(C-B)
		try:
			dic[C]+=dic[B]
		except:
			dic.setdefault(C,dic[B])
		dic[B]=0
	except:
		ans+=0
	print(ans)


Measured memory_bytes: 99328
#include<stdio.h>
#include<math.h>

int main(){
  long long int num, a, b, i;
  scanf("%lld", &num);

  for (i=sqrt(num); i>=1; i=i-1) {
    if (num%i==0) {
      a = i;
      b = num/i;
      break;
    }
  }

  printf("%lld\n", a+b-2);

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (a == b){
            System.out.println(c);
        }
        if (b == c){
            System.out.println(a);
        }
        if (c == a){
            System.out.println(b);
        }
        
        sc.close();
    }
}


Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys
import math

np = ":("

def solve(N: int):
    ans = math.ceil(N/ 108 * 100)
    if math.floor(ans * 1.08) != N:
        print(np)
    else:
        print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

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

int main ()
{
	long long n,m;
	cin>>n>>m;
	if(n<m) swap(n,m);
	cout<<n*m/gcd(n,m)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string S[3];
    REP(i, 3) {
        cin >> S[i];
    }
    cout << "A" << S[1][0] << "C" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

char s[111];
ll k;

main(){
    scanf("%s%lld", s, &k);
    int l = strlen(s);
    if(s[0] != s[l-1]){
        ll a = 0, b = 1;
        for(int i=1; i<l; i++){
            if(s[i] == s[i-1]){
                b++;
            }else {
                a += b / 2;
                b = 1;
            }
        }
        a += b/2;
        printf("%lld\n", k * a);
        return 0;
    }
    ll a = 0, b = 1, c = 1, i = 1;
    for(;i<l && s[i]==s[i-1]; i++){
        c++;
    }
    if(i == l){
        printf("%lld\n", l * k / 2);
        return 0;
    }
    for(; i<l; i++){
        if(s[i]==s[i-1]){
            b++;
        }else {
            a += b / 2;
            b = 1;
        }
    }
    printf("%lld\n", a * k + ((b + c)/2)*(k-1)+ b/2 + c/2);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define N 500
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int d[ N ][ N ];
    int h, w;
    int res = 0;

    scanf ( " %d %d", &h, &w );
    if ( !( h | w ) ) break ;

    for ( j = 0; j < h; ++j )
    for ( i = 0; i < w; ++i )
    {
      char ch;

      scanf ( " %c", &ch );
      if ( ch == '.' )
      {
        d[ j ][ i ] = ( j > 0 ? d[ j - 1 ][ i ] : 0 )
                    + 1;
      }
      else
      {
        d[ j ][ i ] = 0;
      }
    }

    for ( j = 0; j < h; ++j )
    {
      int k_operafan[ N ];
      int sp = 0;

      for ( i = 0; ; ++i )
      {
        int epr = 0;

        while ( sp > 0
             && ( i == w
               || d[ j ][ k_operafan[ sp - 1 ] ] > d[ j ][ i ] ) )
        {
          --sp;
          res = MAX( res
                   , d[ j ][ k_operafan[ sp ] ] * ( i - k_operafan[ sp ] ) );
          d[ j ][ k_operafan[ sp ] ] = d[ j ][ i ];
          epr = 1;
        }
        sp += epr;
        if ( i == w ) break ;

        k_operafan[ sp++ ] = i;
      }
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

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

int main() {
  int a;
  cin >> a;
  vector<int> weight(a);
  vector<int> differ(a);
  int total = 0;
  for(int i = 0; i < a; i++){
    cin >> weight.at(i);
  }
  for(int i = 0; i < a; i++){
    total += weight.at(i);
  }
  for(int i = 0; i < a; i++){
    int sum = 0;
    for(int j = 0; j < i; j++){
      sum += weight.at(j);
    }
    if(total - sum < sum){
      differ.at(i) = sum - (total - sum);
    }else{
      differ.at(i) = (total - sum) - sum;
    }
  }
  sort(differ.begin(), differ.end());
  cout << differ.at(0) << endl;
}

Measured memory_bytes: 256
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define mod        1000000007 
#define all(x) 	   x.begin(),x.end()	
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll fact(ll n){ if(n==0){return 1;}return (n*fact(n-1))%mod;}
ll power(ll x, ll y){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod-2);}
ll gcd(ll a,ll b){if(b==0){return a;}gcd(b,a%b);}
ll a[2000000];
void sieve(){ll i,j;fli(i,2,1000001){if(a[i]==0){for(j=i*i;j<1000001;j+=i){a[j]=1;}}}}
vector<ll>v1;
bool compar(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second);
} 
ll ans=0;
ll arr[1000000];
vector<ll>root;
map<string,ll>m1;
map<pair<string,ll>,ll>m2;

void comp()
{
	ll i,j,k,n,m;
	string s,t;
	cin>>n;
	ll ans;
	ans=(n*(n+1))/2;
	ans-=n;
	cout<<ans<<"\n";
} 
int main()
{
	speedup;
	ll i=0,t;
	ll n;
	//cin>>t;
	t=1;
	while(t--)
	{
	 comp();
	}
}

Measured memory_bytes: 2304