akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
using namespace std;
inline ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
inline ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
inline void umax(ll &p,ll q){if(p<q)p=q;}
inline void umin(ll &p,ll q){if(p>q)p=q;}
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,k,t,a[maxn];
ll cnt[maxn];
vi e[maxn];
bool flag=true;
void dfs(int x,int y)
{
    if(!flag)return;
    ll p=0;
    for(int z:e[x])
    {
        if(z==y)continue;
        dfs(z,x);
        if(cnt[z]>a[x])
        {
            flag=false;
            return;
        }
        p+=cnt[z];
    }
    if((int)e[x].size()==1)
    {
        cnt[x]=a[x];
    }
    else
    {
        cnt[x]=(ll)2*a[x]-p;
        if(cnt[x]<0||cnt[x]>a[x])
        {
            flag=false;
            return;
        }
    }
}
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)scanf("%d",&a[i]);
    rep(i,1,n-1)scanf("%d%d",&j,&k),e[j].pb(k),e[k].pb(j);
    if(n==2)
    {
        puts(a[1]==a[2]?"YES":"NO");
        return 0;
    }
    rep(i,1,n)
    {
        if((int)e[i].size()>1)
        {
            dfs(i,-1);
            if(!flag)puts("NO");
            else if(cnt[i]!=0)puts("NO");
            else puts("YES");
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1)res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    vector<ll> cnt(k+1);
    for(int i=k;i>=1;--i){
        cnt[i]=modpow(k/i,n);
        for(int x=i+i;x<=k;x+=i){
            cnt[i]=(cnt[i]-cnt[x])%mod;
        }
        ans=(ans+cnt[i]*i)%mod;
    }
    ans=(ans+mod)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

struct edge {
  int x;
  int y;
  int weight;
  bool operator<(const edge& another) const {
    return weight < another.weight;
  }
  bool operator>(const edge& another) const {
    return weight > another.weight;
  }
};

vector<int> data(10010,-1);

int root(int x){
  if(data[x] == -1)return x;
  else return data[x] = root(data[x]);
}

bool same(int x,int y){
  if(root(x) == root(y))return 1;
  else return 0;
}

int unite(int x,int y){
  if(!same(x,y))data[root(x)] = y;
  return 0;
}

vector<edge> Kruskal(vector<edge> E){
  vector<edge> answer;
  priority_queue<edge,vector<edge>,greater<edge> > pque;
  for(int i = 0;i < data.size();i++)data[i] = -1;
  for(int i = 0;i < E.size();i++)pque.push(E[i]);
  while(pque.size()){
    if(!same(pque.top().x,pque.top().y)){
      answer.push_back(pque.top());
      unite(pque.top().x,pque.top().y);
    }
    pque.pop();
  }
  return answer;
}

int main(){
  int V,E,s,t,w,ans=0;
  cin >> V >> E;
  vector<edge> edges;
  FOR(i,0,E){
    cin >> s >> t >> w;
    edge e;
    e.x = s;
    e.y = t;
    e.weight = w;
    edges.push_back(e);
  }
  edges = Kruskal(edges);
  for(auto e:edges)ans += e.weight;
  cout << ans << endl;
}



Measured memory_bytes: 7568
import heapq

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
A = [i * -1 for i in A]
heapq.heapify(A)
for i in range(M):
    maxA = -1 * heapq.heappop(A)
    heapq.heappush(A,-1*(maxA//2))
print(-sum(A))

Measured memory_bytes: 65636
n = int(input())
a = [int(i) for i in input().split()]
mod = 10**9+7
ans = 0
for i in range(60):
    cnt = 0
    for j in range(n):
        if a[j]>>i & 1 == 0: cnt += 1
    ans += pow(2,i,mod)*cnt*(n-cnt)
print(ans%mod)

Measured memory_bytes: 122808
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> L(N+1);
    for(int i = 0;i<N;i++){
        cin >> A[i];
        L[A[i]]++;
    }
    vector<bool> frags(N+1);
    sort(L.begin(),L.end());
    int kind = 0;
    for(int i = 0;i < N+1;i++){
        if(L[i] > 0){
            frags[i] = 1;
        kind++;
        }
    }

    int ans = 0;
    int a = N;
    for(int i = 0;i < N+1;i++){
        if(kind > K && frags[i]){
            ans += L[i];
            kind--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>

using namespace std;

int main ()
{
  int count;
  cin >> count;
  long *in = new long[count];
  for (int i = 0; i < count; i++) {
    cin >> in[i] ;
  }

  int i = count - 1;
  for (; i >= 0; i -= 2) {
    printf("%ld ", in[i]);
  }
  if (i == -1) i = 0;
  else i = 1;
  for (;i < count; i+=2) {
    printf("%ld ", in[i]);
  }
  printf("\n");
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a - 1)*(b - 1) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define PI 3.14159265359
  
void kock(int n, double px1, double py1, double px2, double py2) {
      
    double sx,sy,tx, ty, ux, uy;
    if (n == 0) return;
      
    sx = (2*px1 + 1*px2)/3;
    sy = (2*py1 + 1*py2)/3;
    tx = (1*px1 + 2*px2)/3;
    ty = (1*py1 + 2*py2)/3;
    ux = (tx - sx) * cos(PI/3) - (ty - sy) * sin(PI/3) + sx;
    uy = (tx - sx) * sin(PI/3) + (ty - sy) * cos(PI/3) + sy;
  
      
    kock(n-1, px1, py1, sx, sy);
    printf("%f %f\n",sx, sy);
      
    kock(n-1, sx, sy, ux, uy);
    printf("%f %f\n", ux, uy);
      
    kock(n-1, ux, uy, tx, ty);
    printf("%f %f\n", tx, ty);
      
    kock(n-1, tx, ty, px2, py2);
      
}
  
int main() {
    int n;
    scanf("%d", &n);
      
    printf("0 0\n");
    kock(n, 0, 0, 100, 0);
    printf("100 0\n");
      
    return 0;
}

Measured memory_bytes: 1804
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int X,A,B;
	cin >> X >> A >> B;

	if (B<=A){
		printf("delicious\n");
	}else if (B<=(A+X)){
		printf("safe\n");
	}else{
		printf("dangerous\n");
	}

	return 0;
}

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

LL n, mod = 1000000007, x, y;
LL dp[100100][2];
vector<int> graph[100100];

LL solve(int u, int last, int p) {
	LL &ret = dp[u][last];
	if(ret != -1) return ret;
	LL temp = 1;
	LL temp2 = 1;
	bool check = false;
	for(int v : graph[u]) {
		if(v == p) continue;
		check = true;
		temp *= solve(v, 0, u);
		temp %= mod;
		if(!last) {
			temp2 *= solve(v, 1, u);
			temp2 %= mod;
		}
	}
	if(!last) temp = (temp + temp2) % mod;
	ret = temp;
	if(!check) {
		if(last) ret = 1;
		else ret = 2;
	}
	return ret;
}

int main() {
	memset(dp, -1, sizeof(dp));
	cin>>n;
	for(int i = 0; i < n-1; i++) {
		cin>>x>>y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	cout<<solve(1, 0, -1)<<endl;
	return 0;
}

/**
7
1 2
1 3
2 4
2 5
3 6
3 7
41
*/

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int A, B; cin >> A >> B;
	int g = __gcd(A, B);

	vector<int> divisors;
	for (int x = 1; x * x <= g; x++) {
		if (g % x == 0) {
			divisors.push_back(x);
			if (x * x < g) {
				divisors.push_back(g / x);
			}
		}
	}

	sort(divisors.rbegin(), divisors.rend());
	int K; cin >> K;
	cout << divisors[K-1] << '\n';

	return 0;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *H = map(int, read().split())
dp = [0] * N

for i in range(1, N):
    x = dp[i - 1] + abs(H[i] - H[i - 1])
    if i > 1:
        y = dp[i - 2] + abs(H[i] - H[i - 2])
        if x > y: 
            x = y
    dp[i] = x

ans = dp[-1]
print(ans)


Measured memory_bytes: 12308
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	ll N;
	cin >> N;
	vll A(N), B(N), C(N);
	for (ll i = 0; i < N - 1; i++)
	{
		cin >> A[i] >> B[i] >> C[i];
		A[i]--;
		B[i]--;
	}
	ll Q, K;
	cin >> Q >> K;
	K--;
	vll X(Q), Y(Q);
	for (ll i = 0; i < Q; i++)
	{
		cin >> X[i] >> Y[i];
		X[i]--;
		Y[i]--;
	}


	map<pair<ll, ll>, ll> dis;
	for (ll i = 0; i < N - 1; i++)
	{
		dis[{A[i], B[i]}] = C[i];
		dis[{B[i], A[i]}] = C[i];
	}

	vvll branch(N);
	for (ll i = 0; i < N - 1; i++)
	{
		branch[A[i]].emplace_back(B[i]);
		branch[B[i]].emplace_back(A[i]);
	}

	vll ans(N); // iからKまでの最短距離
	for (ll i = 0; i < N; i++)
	{
		ans[i] = LLINF;
	}
	ans[K] = 0;

	queue<ll> nodes;
	nodes.push(K);

	while (!nodes.empty())
	{

		ll now = nodes.front();
		nodes.pop();


		for (ll i = 0; i < branch[now].size(); i++)
		{

			if (ans[branch[now][i]] != LLINF)
			{
				continue;
			}


			ans[branch[now][i]] = ans[now] + dis[{now, branch[now][i]}];

			nodes.push(branch[now][i]);
		}


	}

	for (ll i = 0; i < Q; i++)
	{
		cout << ans[X[i]] + ans[Y[i]] << endl;
	}


}





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

s = [input() for _ in range(n)]

for i in range(n):
    s[i] = sorted(s[i])
    s[i] = "".join(s[i])

t = {}
for i in range(n):
    if s[i] in t :
        t[s[i]] += 1
    else :
        t[s[i]] = 1

print(sum(t[k]*(t[k]-1)//2 for k in t))


Measured memory_bytes: 23676
from collections import Counter

n = int(input())
a = [input() for s in range(n)]

c = Counter(a)
list = c.most_common()
max = list[0][1]

ans = []
for i, j in list:
    if j == max:
        ans.append(i)
    else:
        break

ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 47668
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <cmath>
#include <cassert>

#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, MOD = 1e9 + 7;

int N, K, a[105];
bool dp[100005];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N >> K;
    for (int i = 1; i <= N; i++) cin >> a[i];
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= N; j++) {
            if (i >= a[j] && !dp[i - a[j]])
                dp[i] = true;
            if (dp[i] || i < a[j]) break;
        }
    }
    cout << (dp[K] ? "First" : "Second") << '\n';
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string s = (min(abs(a-c), max(abs(a-b), abs(b-c))) <= d) ? "Yes" : "No";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

bool pq1(pair<int,int> p1,pair<int,int> p2) {

    return p1.second < p2.second;

}

bool pq2(pair<int,int> p1,pair<int,int> p2) {
    if (p1.first == p2.first) {
        return p1.second > p2.second;
    } else {
        return p1.first > p2.first;
    }
}

int main(void)
{
    IOS
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> v1;
    priority_queue<int,vector<int>> v2;
    REP(i,n) {
        int a,b;
        cin >> a >> b;
        v1.emplace_back(make_pair(b,a));
    }
    sort(ALL(v1),pq1);
    
    //cerr << v1[0].second << endl;

    int ans = 0;
    int cnt = 0;
    FOR(i,1,m+1) {
        //cerr << "i"<<i << endl;
        while(v1[cnt].second <= i && cnt < n) {
            v2.push(v1[cnt].first);
            cnt++;
        }
        if (!v2.empty()) {
            //cerr << v2.top() << endl;
            ans += v2.top();
            v2.pop();
        }

    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1908
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n = 0;
    cin >> n;
    int odd = 0, even2 = 0, even4 = 0;
    long long buf = 0;
    for (int i=0; i<n; i++) {
        cin >> buf;
        if (buf%2 == 1) odd++;
        else if (buf%4 == 0) even4++;
        else even2++;
    }
    if (even4 >= odd) cout << "Yes" << endl;
    else if (even2 == 0 && even4 + 1 == odd) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n; cin >> n;
    rep1(i,n+1){
        ll sum = ((i+1)*i)/2;
        //部分和
        if(n <= sum){
            //out(i);
            vl res;
            ll ttl = 0;
            for(int j=i;j>=1;j--){
                if(ttl+j == n){
                    res.push_back(j);
                    rep(k,res.size())out(res[k]);
                    return 0;
                }
                else if(n - (ttl+j) >= 0){
                    ttl += j;
                    res.push_back(j);
                }
            }
        }
    }
}


Measured memory_bytes: 384
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_   }
#else
#define MY_NAMESPACE(ns)
#define MY_NAMESPACE_
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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


MY_NAMESPACE(ABC168B)
int main()
{
	int k;
	cin >> k;

	string s;
	cin >> s;

	if ((int)s.size() <= k)
		cout << s << endl;
	else
		cout << s.substr(0, k) + "..." << endl;

	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define N 200000

int main(){
    char S[N+1];
    scanf("%s",S);

    long long count = 0;
    long long Slen = strlen(S);
    long long T[Slen+1];
    long long C[2019];
    long long digit=1;
    for(int i = 0;i<2019;i++) C[i]=0;
    T[Slen]=0;
    
    for(int i = Slen-1;i>-1;i--){
        T[i] = (T[i+1] + digit*(S[i]-'0')) % 2019;
        digit=digit*10%2019;
    }
    for(int i = 0;i<Slen+1;i++) C[T[i]]++;
    for(int i = 0;i<2019;i++) count+=(C[i]-1)*(C[i])/2.0;
    printf("%lld\n",count);
    return 0;
}

Measured memory_bytes: 3452
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> a(N);
	map<ll, ll> ball;
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i];
		if (ball.find(a[i]) == ball.end()) {
			ball[a[i]] = 1;
		}
		else {
			ball[a[i]] += 1;
		}
	}
	vector<ll> m;
	for (auto itr = ball.begin(); itr != ball.end(); itr++)
	{
		m.push_back(itr->second);
	}
	sort(m.begin(), m.end());
	ll s = ball.size();
	ll cnt = 0;
	for (ll i = 0; i < N; i++)
	{
		if (s <= K) break;
		cnt += m[i];
		s--;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 16500
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    sc.close();

    long d = c - a - b;
    boolean ans = (0 < d && 4 * a * b < d * d);
    System.out.println(ans ? "Yes" : "No");    
  }
}


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

int64_t gcd(int64_t a, int64_t b) {
  while (a != 0 && b != 0) {
    if (a < b) {
      b %= a;
    } else {
      a %= b;
    }
  }
  return std::max(a, b);
}

int main() {
  int64_t n, x;
  std::cin >> n >> x;
  std::vector<int64_t> xi(n);

  for (auto &i : xi) {
    int64_t tmp;
    std::cin >> tmp;
    i = std::abs(tmp - x);
  }

  if (n == 1) {
    std::cout << xi[0] << std::endl;
    return 0;
  }
  auto g = gcd(xi[0], xi[1]);

  for (int64_t i = 2; i < n; i++) {
    g = gcd(g, xi[i]);
    if (g == 1) {
      break;
    }
  }

  std::cout << g << std::endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  REP(i, n) {
    cin >> a.at(i);
    b.at(i) = a.at(i);
  }
  sort(b.begin(), b.end(), greater<int>());
  int m1 = b.at(0);
  int m2 = b.at(1);
  
  REP(i, n) {
    cout << (a.at(i) != m1 ? m1 : m2) << endl; 
  }
  
  return 0;
}

Measured memory_bytes: 3200
using System;

public class Test
{
	public static void Main()
	{
	        string[] data = Console.ReadLine().Split();//????????\?????????
            int a = 0, b = 0,c=0; //??????????????´??°
            a = int.Parse(data[0]);//??????????????°?????????
            b = int.Parse(data[1]);//??????????????°?????????
            c = int.Parse(data[2]);//??????????????°?????????

            if (a<b&&b<c) {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
	}
}

Measured memory_bytes: 8908
#include <iostream>
#include <vector>

bool in_field(int x, int y, int W, int H)
{
    return 0 <= x && x < W && 0 <= y && y < H;
}

int main()
{
    int H, W;
    std::cin >> H >> W;

    std::vector<std::string> s(H);
    for (int i = 0; i < H; i++) {
        std::cin >> s[i];
    }
    
    int seat_cnt = 0;
    for (int i = 1; i < H; i++) {        
        for (int j = 0; j < W; j++) {
            bool ok = (s[i][j] == '-');
            for (int dj : {-1, 1}) {
                int nj = j + dj;
                if (in_field(nj, i, W, H) && s[i][nj] != '-') {
                    ok = 0;
                }
            }
            constexpr int di[] = {-1, -1, -1, +0, +0, +1, +1, +1};
            constexpr int dj[] = {-1, +0, +1, +0, +0, -1, +0, +1};
            for (int k = 0; k < 8; k++) {
                int ni = i + di[k];
                int nj = j + dj[k];
                if (in_field(nj, ni, W, H) && s[ni][nj] == 'x') {
                    ok = 0;
                }
            }

            seat_cnt += ok;
        }
    }

    std::cout << seat_cnt << std::endl;
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    string S;
    cin >> S;

    if(S[3]==S[2] && S[4]==S[5])cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

ll N, A, B, C;
vector<ll> L;

//i: i番目の木の合成先を考える
//a: i-1番目の木まで合成したときのaの長さ
//returns: 消費mp
ll dfs(ll i, ll a, ll b, ll c) {
  if (i == N) {
    if (a == 0 || b == 0 || c == 0) {
      return 100000000;
    } else {
      return abs(A - a) + abs(B - b) + abs(C - c);
    }
  }
  // i番目の木をABCを合成するための木として採用しない
  ll res = dfs(i + 1, a, b, c);
  // i番目の木を、Aを合成するための木として採用する
  res = min(res, dfs(i + 1, a + L[i], b, c) + (a > 0 ? 10 : 0));
  // i番目の木を、Bを合成するための木として採用する
  res = min(res, dfs(i + 1, a, b + L[i], c) + (b > 0 ? 10 : 0));
  // i番目の木を、Cを合成するための木として採用する
  res = min(res, dfs(i + 1, a, b, c + L[i]) + (c > 0 ? 10 : 0));

  return res;
}

int main() {
  cin >> N >> A >> B >> C;
  L.resize(N);
  for (ll i = 0; i < N; i++) {
    cin >> L[i];
  }
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int countSolve(int a,int b,int n);
void solve(int n);

int main() {
	int n;
	while (1) {
		cin >> n ;
		if(cin.eof()) break ;
		solve(n);
	}
	return 0;
}

int countSolve(int a, int b, int n) {
	int x = n-a-b;
	int count = 0, i = 0 , j=0;
	for (i=0; i<10; i++) {
		for (j=0; j<10; j++) {
			if (x == i+j)
				count++;
		}
	 }
	return count;
}

void solve(int n) {
	int count = 0;
	for (int a=0; a<10; a++) {
		for (int b=0; b<10; b++) {
			count += countSolve(a,b,n);
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();

  bool check = true;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0 && s[i] == 'L'){
      check = false;
    }
    if(i % 2 == 1 && s[i] == 'R'){
      check = false;
    }
  }

  if(check){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W; cin >> H >> W;
    rep(i, H){
        string S; cin >> S;
        cout << S << endl << S << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{int x,y,sum,i;

  sum=0;
  for(i=0; i<4; i++){
  
  scanf("%d",&x);
  sum=sum+x;
  }

  x=sum/60;
  y=sum%60;

  printf("%d\n",x);
  printf("%d\n",y);

  return(0);

}

Measured memory_bytes: 596
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
x = 2
ps = Counter()
while x * x <= N:
  while N % x == 0:
    ps[x] += 1
    N //= x
  x += 1
if N > 1: ps[N] += 1
#print(ps)
res = 0
for k in ps.keys():
  ok = 0
  ng = pow(10, 12)
  while ng - ok > 1:
    m = (ok + ng) // 2
    if m * (m + 1) // 2 <= ps[k]: ok = m
    else: ng = m
  res += ok
print(res)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;
ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return mod_pow(x * x % MOD, n / 2) % MOD;
    else return x * mod_pow(x, (n - 1)) % MOD;
}
ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    ll ret = 1;
    while (n) if (n & 1) ret = ret * x % MOD; x = x * x % MOD; n /= 2;
    return ret;
}
ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) ret *= (i + 1); ret %= MOD;
    return ret;
}
ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);
    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    bool ret = true;
    while (c > 0)
    {
        c -= b;
        if (c <= 0) {
            break;
        }
        a -= d;
        if (a <= 0) {
            ret = false;
            break;
        }
    }
    if (ret) cout << "Yes";
    else cout << "No";
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> g[n];
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> ans(n, -1);
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int from = q.front(); q.pop();
    for (int to : g[from]) {
      if (ans[to] != -1) continue;
      ans[to] = from;
      q.push(to);
    }
  }
  cout << "Yes\n";
  for (int i = 1; i < n; ++i) {
    cout << ans[i]+1 << endl;
  }
}

Measured memory_bytes: 10116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

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

    int p[N];
    int ans=0;
    rep(i,N){
        cin>>p[i];
    }
    sort(p,p+N);
    rep(i,K){
        ans+=p[i];
    }
    cout << ans << endl;

    



}


Measured memory_bytes: 3664
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
#include<algorithm>
using namespace std;
#define debug(x) cout << #x << " = " << X << endl
typedef long long LL;

int main()
{	
	int n;
	while(~scanf("%d", &n))
	{
		if(n < 1200) printf("ABC\n");
		else if(n < 2800) printf("ARC\n");
		else printf("AGC\n");
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  pair<int, string> a[n];
  string s[n];
  for(int i=0;i<n;i++){cin >> s[i];}
  sort(s, s+n);
  
  int b[n]={};
  int ma=0,q=0;
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1]){b[q]++;}else{ma=max(b[q],ma);
                                a[q].first =b[q];
                                a[q].second =s[i];
                               q++;}
        if(i==n-2 && s[i] == s[i+1]){  ma=max(b[q],ma);
                                a[q].first =b[q];
                                a[q].second =s[i];}
    else{  ma=max(b[q],ma);
                                a[q].first =b[q];
                                a[q].second =s[i+1];}
  }

  
  for(int i=0;i<n;i++){
  if(a[i].first==ma){cout << a[i].second << endl;}
  }
}

Measured memory_bytes: 18176
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>


int main(){
  int N, R;
  scanf("%d", &N);
  scanf("%d", &R);
  if (N<10){
    R+=100*(10-N);
  }
  std::cout << R << std::endl;
  return 0;
}
 

Measured memory_bytes: 3180
package main

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

func main() {
	n := readInt()
	d := make([]int, n)
	for i := range d {
		d[i] = readInt()
	}

	ans := 0
	for i := range d {
		for j := i + 1; j < n; j++ {
			ans += d[i] * d[j]
		}
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean [][] has = new boolean[4][13];
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        String [] ss = new String [] {"S", "H", "C", "D"};
        for(int i = 0; i < ss.length; i++) {
            map.put(ss[i], i);
        }
        for(int i = 0; i < n; i++) {
            String s = sc.next();
            int k = sc.nextInt();
            has[map.get(s)][k-1] = true;
        }
        for(int i = 0; i < 4; i++) {
            for(int k = 0; k < 13; k++) {
                if(!has[i][k]) System.out.println(ss[i] + " " + (k+1));
            }
        }
    }
}

Measured memory_bytes: 18200
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(scanner.nextLine());
        }

        boolean[] used = new boolean[n];
        int i = 0;
        int cnt = 0;
        while (true) {
            cnt++;
            if (arr[i] == 2) {
                System.out.println(cnt);
                return;
            }
            if (used[arr[i] - 1]) {
                System.out.println(-1);
                return;
            }
            i = arr[i] - 1;
            used[i] = true;
        }
    }
}


Measured memory_bytes: 100172
def f(n):
    if n%2:return 3*n+1 #odd
    else:return n//2 #even

if __name__ == "__main__":
    n = int(input())
    tmpset = set()
    res = 1
    while (n not in tmpset):
        tmpset.add(n)
        n = f(n)
        res += 1
    print(res)


Measured memory_bytes: 2940
import sys

H, W = map(int, input().split())

col = []
col.append('.' * (W + 2))
for i in range(H):
    col.append('.' + input() + '.')
col.append('.' * (W + 2))

dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1]]


for y in range(1, H + 1):
    for x in range(1, W + 1):
        if col[y][x] == '#':
            for dx, dy in dxdy:
                if col[y + dy][x + dx] == '#':
                    break
            else:
                print('No')
                sys.exit()
print('Yes')

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

long long dp[60][60][3000]; // 何個目までに何個選択し合計がいくつか

void solve() {
    int N, A; cin >> N >> A;
    dp[0][0][0] = 1;
    for (int i = 1; i <= N; i++) {
        int x; cin >> x;
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k <= 2500; k++) {
                // 使用しない
                dp[i][j][k] += dp[i-1][j][k];
                // 使用する
                if(k-x >= 0 && j > 0) dp[i][j][k] += dp[i-1][j-1][k-x];
            }
        }
    }

    long long ans = 0;
    for (int j = 1; j <= N; j++) {
        for (int k = 1; k <= 2500; k++) {
            if (k == A * j) ans += dp[N][j][k];
        }
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 34620
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll POW3(ll x,ll n,ll m){
  x%=m;
  if(n==0)return 1;
  if(n%2==0)return POW3(x*x,n/2,m)%m;
  return x*POW3(x,n-1,m)%m;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)//xのm進数でのx^nの位の値
{
  return x%POW2(m,n+1)/POW2(m,n);
}

ll keta(ll x,ll n)//xのn進数での桁数
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)//x!のnで割り切れる回数
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)//xのnで割り切れる回数
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

ll SGS(ll x,ll y, ll m)//1+x+…+x^(y-1)をmで割った余り
{
  if(y==0)return 0;
  if(y%2==0){
    return (1+POW3(x,y/2,m))*SGS(x,y/2,m)%m;
  }
  return (1+x*SGS(x,y-1,m))%m;
}

ll SSGS(ll x,ll y,ll m)//Σ[k=1→y](1+x+…+x^(k-1))をmで割った余り
{
  if(y==0)return 0;
  if(y==1)return 1;
  if(y%2==0){
    return (SSGS(x,y/2,m)*(POW3(x,y/2,m)+1)%m+SGS(x,y/2,m)*y/2%m)%m;
  }
  return (SSGS(x,y-1,m)*x%m+y)%m;
}

int main()
{
  ll n,a,b,x[110000],ans=0;
  cin >> n >> a >> b;
  rep(i,n)cin >> x[i];
  rep(i,n-1)ans+=min(a*(x[i+1]-x[i]),b);
  printf("%lld",ans);
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    st s[3] ;
    loopcin(3 , s) ;

    for (lli i = 0 ; i < 3 ; i++)
    {
        cout << s[i][i] ;
    }

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define FOR(N) for(int i=0;i<N;i++)
#define FOR2(N) for(int j=0;j<N;j++)
using namespace std;
typedef long long ll;


int main() {
	int N, K,A=0;
	cin >> N >> K;
	while (N) {
		N = N / K;
		A++;
	}
	cout << A<< endl;
}


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

int main(){

  int N; cin >> N;

  vector<int> p(10);

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

  sort(p.begin(), p.end(), greater<int>());

  // for(int i = 0 ; i < N ; ++i){
  //   cout << p[i] << endl;
  // }

  int ans = 0;
  for(int i = 0 ; i < N ; ++i){
    if(i == 0)  ans += p[i]/2;
    else ans+= p[i];
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()
print("Yes" if n==m else "No")

Measured memory_bytes: 77480
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



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

}
vector<double> h(N);

REP(i,N){
     h[i]=fabs(A-(T-H[i]*0.006));
}
std::vector<double>::iterator iter = min_element(h.begin(), h.end());
size_t index = distance(h.begin(),iter);
cout << index+1 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)l
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    ll l, r;
    cin >> l >> r;
    ll ans = LINF;
    for(ll i = l; i < r; i++) {
        for(ll j = i + 1; j <= r; j++) {
            ans = min(ans, ((i * j) % 2019));
            if(ans == 0) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long
#define MOD 1000000007

int main(void)
{
  int n;
  cin >> n;
  vec<int> c(n + 1);
  c[0] = 200005;
  rep(i, n) cin >> c[i + 1];

  vec<ll> s(200010, 0);
  s[c[0]] = 1;
  rep(i, n) {
    if (c[i] != c[i + 1]) s[c[i + 1]] = (s[c[i + 1]] + s[c[i]] + MOD) % MOD;
  }
  cout << s[c[n]] % MOD << endl;
  return 0;
}


Measured memory_bytes: 2688
using System;
class Program
{
    static void Main(string[] args)
    {
        ulong N = ulong.Parse(Console.ReadLine());
        ulong[] town = new ulong[5];
        for(int i = 0; i < 5; i++)
        {
            town[i] = ulong.Parse(Console.ReadLine());
        }
        int bottolNeck = 0;
        ulong min = ulong.MaxValue;
        for(int i = 0; i < town.Length; i++)
        {
            if(town[i] < min)
            {
                min = town[i];
                bottolNeck = i;
            }
        }
        ulong t = 4;
        if (N % town[bottolNeck] != 0)
            t++;
        t += N / town[bottolNeck];
        Console.WriteLine(t);
    }
}

Measured memory_bytes: 13140