akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
vector<int> f,a;
int main()
{
	int n,k;
	int i,j;
	scanf("%d %d",&n,&k);
	a.resize(n+1);
	f.resize(k+1);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	f[0]=0;
	for(i=1;i<=k;i++)
	{
		f[i]=0;
		for(j=1;j<=n;j++)
		{
			if(a[j]>i)
			{
				break;
			}
			if(!f[i-a[j]])
			{
				f[i]=1;
				break;
			}
		}
	}
	if(f[k])
	{
		printf("First\n");
	}
	else
	{
		printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 640
import sys
import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    n = int(input())
    ans = [0,1]
    for i in range(2,n+1):
        x = i
        cnt = 0
        while x%2==0:
            x //= 2
            cnt += 1
        if cnt>ans[0]:
            ans[0] = cnt
            ans[1] = i
    print(ans[1])
    return

if __name__=='__main__':
    main()


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

int main(void) {

    int A, B; cin >> A >> B;
    if (A == B) {
        cout << "Draw" << endl;
    } else if (A == 1) {
        cout << "Alice" << endl;
    } else if (B == 1) {
        cout << "Bob" << endl;
    } else if (A > B) {
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <set>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    set <int> myset;
    int n,s;
    cin>> n;
    for(int i=0;i<n;i++){
        cin >>s;
        myset.insert(s);
    }
    cout<<myset.size();
    
    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a_list=list(map(int,input().split()))
dp=[-1]*(n+1)
dp[n]=0
D={}
for i in range(n-1,-1,-1):
    if not a_list[i] in D:
        dp[i]=a_list[i]
        D[a_list[i]]=i+1
    else:
        dp[i]=dp[D[a_list[i]]]
        D[a_list[i]]=i+1
first={}
for i in range(n):
    if not a_list[i] in first:
        first[a_list[i]]=i
cycle=[dp[0]]
i=dp[0]
while True:
    if i==0:
        break
    ne=first[i]
    i=dp[ne+1]
    cycle.append(i)
cycle.pop()
cycle=[0]+cycle
T=len(cycle)
order=k%T
if 1<=order:
    start=cycle[order-1]
    check={}
    if start==0:
        ans=[]
        for i in range(n):
            if ans==[]:
                ans.append(a_list[i])
                check[a_list[i]]=0
            else:
                if a_list[i] in check:
                    ans=ans[:check[a_list[i]]]
                    temp={}
                    for j in check:
                        if check[j]<check[a_list[i]]:
                            temp[j]=check[j]
                    check=temp
                else:
                    ans.append(a_list[i])
                    check[a_list[i]]=len(ans)-1
    else:
        ans=[]
        x=first[start]
        for i in range(x+1,n):
            if ans==[]:
                ans.append(a_list[i])
                check[a_list[i]]=0
            else:
                if a_list[i] in check:
                    ans=ans[:check[a_list[i]]]
                    temp={}
                    for j in check:
                        if check[j]<check[a_list[i]]:
                            temp[j]=check[j]
                    check=temp
                else:
                    ans.append(a_list[i])
                    check[a_list[i]]=len(ans)-1
    for i in ans:
        print(i,end='')
        print(' ',end='')
else:
    print()



    


Measured memory_bytes: 122356
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

A = []
tmp = 0
for i in range(1, X+1):
    tmp += i
    A.append(tmp)
    if tmp >= X:
        print(i)
        break


Measured memory_bytes: 12156
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size();i+=2){
    if(!(s[i]=='h' && s[i+1]=='i')){
      cout<< "No" <<endl;
      return 0;
    }
  }
  cout<< "Yes" <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool prime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}
ll div(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main() {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,counter=0;
    cin>>n;
    vector<ll>a(n+1,1);
  	for(ll i = 2;i<=n ;i++)
  	{
  		for(ll j = i ;j<= n ;j+=i)
  			a[j]++;
  	}
  	for(ll i = 1;i<n;i++)
  		{
  			counter += a[i];
  		}
    cout<<counter<<endl;
}


Measured memory_bytes: 11112
#include<stdio.h>
int main()
{
    int A[100],n,i,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    for(i=0;i<n/2;i++)
    {
        temp=A[i];
        A[i]=A[n-i-1];
        A[n-i-1]=temp;
    }
    for(i=0;i<n-1;i++){
        printf("%d ",A[i]);}
        printf("%d\n",A[n-1]);
        return 0;
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );}
using namespace std;
int main()
{
    int n,yen;
    cin >> n >> yen;

    for(int x = 0;x <= n;x++){
        for(int y = 0;y <= n - x;y++){
            int z = n - x - y;
            if(10000*x+5000*y+z*1000 == yen){
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;


    return 0;
}

Measured memory_bytes: 256
def resolve():
    a, b, x = map(int, input().split())
    ans = calc(x, b) - calc(x, a-1)
    print(ans)

def calc(x, n):
    if n == -1:
        return 0
    else:
        return n//x + 1

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3060
from collections import defaultdict
import sys
N=int(input())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
K=[0]*N
for a in A:
    dd[a]+=1
    K[a]+=1
L=list(dd.items())
L.sort()

if L[-1][1]<=1:
    print('Impossible')
    sys.exit()
m=L[-1][0]
if m%2==1:
    if L[0][0]!=m//2+1 or L[0][1]!=2:
        print('Impossible')
        sys.exit()
if m%2==0:
    if L[0][0]!=m//2 or L[0][1]!=1:
        print('Impossible')
        sys.exit()
s=L[0][0]
for i in range(s+1,m+1):
    if K[i]<=1:
        print('Impossible')
        sys.exit()
print('Possible')

Measured memory_bytes: 38384
#include<iostream>
#include<fstream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<typeinfo>
using namespace std;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	ll N,K;
	scanf("%lld %lld",&N,&K);

	ll ans = 0;
	for(ll num = min(K+1,N); num <= N; num++){
		ans += (N/num)*max(0LL,num-K)+max(0LL,(N%num)-K+1);
	}

	ll minus = 0;
	for(int num = min(K+1,N); num <= N; num++){
		if((0LL%num) >= K)minus++;
	}

	printf("%lld\n",ans-minus);

	return 0;
}


Measured memory_bytes: 256
#define DEBUG
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
#define all(x) begin(x), end(x)
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
#define TCC template<class C
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
#define ENI typename enable_if<
#define DTOR , Dbg&>::type operator<<
#define RIS return *this
TCC> static auto o(C *x)->decltype(os << *x, 0);
TCC> static char o(...);
TCC> ENI sizeof o<C>(0)!=1 DTOR(const C &x) {os<<x; RIS;}
TCC> Dbg &dump(C b, C e) {
    int ii = 0;
    for(C i = (os << "\n[", b); i!=e and ii<26; i++, ii++) *this << ", "+2*(i==b) << *i;
    RIS << ']';
}
TCC> ENI sizeof o<C>(0)==1 DTOR(const C &x) {
    return dump(all(x));
}
TCC, size_t X> ENI !is_same<C, const char>::value DTOR(C (&x)[X]) {
    return dump(all(x));
}
TCC, class D> Dbg &operator<<(const pair<C, D> &x) {RIS<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(ostream&)) { os << x; RIS; }
} dbg;
void err(istringstream *iss) { delete iss; }
TCC, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#ifdef DEBUG
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#else
#define bug(args...) 0
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
int T = 1, Q, cn;
const int inf = 1000000007, mxn = -1;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    // cin >> T;
    auto inputAll = [&]()->void {
        
    };
    auto kase = [&]()->void {
        // cout << "Case " << cn << ": ";
        string s;
        cin>>s;
        int mx=0;
        for(int i=0;i<3;i++){
            for(int j=i;j<3;j++){
                bool ok=1;
                for(int k=i;k<=j;k++)ok&=s[k]=='R';
                if(ok)mx=max(mx,j-i+1);
            }
        }
        cout<<mx<<'\n';
    };
    auto resetAll = [&]()->void {
        
    };
    while (cn++!=T) inputAll(), kase(), resetAll();
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

int r, g, b, n,ans;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> r >> g >> b >> n;
	rep(i,0,(n/r)+1){
		rep(j,0,((n-i*r)/g)+1){
			if((n-i*r-j*g)%b==0)
				ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
/*input
10000000019
*/

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long n; cin >> n;
    int F = 1;
    for (int i = 2; (long long)i * i <= n; ++i)
    {
        if (n % i == 0) {
            F = i;
        }
    }

    long long FF = n / F;
    cout << F + FF - 2;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, k;
double x[65], y[65], c[65], d[65], dx, dy, R, nx, ny, mx, my, p, l = 0, r = 200000, m, eps = 1e-8;
int main(){
	scanf("%d%d", &n, &k);
	rep(i,n) scanf("%lf%lf%lf", x+i, y+i, c+i);
	if(k == 1){
		puts("0");
		return 0;
	}
	while(eps < r - l){
		bool ok = false;
		m = (l + r) / 2;
		rep(i,n) d[i] = m / c[i];
		rep(i,n) rep(j,i){
			dx = x[j] - x[i];
			dy = y[j] - y[i];
			R = hypot(dx,dy);
			if(R >= d[i] + d[j]) continue;
			if(d[i] > d[j] + R){
				nx = R;
				ny = 0;
			}else if(d[j] > d[i] + R){
				nx = 0;
				ny = 0;
			}else{
				nx = (pow(d[i],2) - pow(d[j],2) + pow(R,2)) / (2 * R);
				ny = sqrt(pow(d[i],2) - pow(nx,2));
			}
			dx /= R; dy /= R;
			rep(kk,2){
				mx = dx * nx + dy * ny * (kk ? -1 : 1) + x[i];
				my = dy * nx + dx * ny * (kk ? 1 : -1) + y[i];
				int count = 0;
				rep(l,n) if(hypot(mx-x[l],my-y[l]) <= d[l]+eps) count++;
				if(count >= k) ok = true;
			}
		}
		(ok ? r : l) = m;
	}
	printf("%.8f\n", l);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
int INF = 1000000000;

int main()
{
  int n;
  cin>>n;
  vector<int> a(n), b(n);
  REP(i,n) cin>>a[i];
  REP(i,n) cin>>b[i];
  set<int> fr;
  while(true) {
    vector<vecint> dp(51, vecint(51, INF));
    REP(i,51) dp[i][i] = 0;
    REP(i,51)FOR(j,1,51) {
      if (fr.count(j) == 0) {
        dp[i][i%j] = min(dp[i][i%j], j);
      } else {
        dp[i][i%j] = min(dp[i][i%j], 0);
      }
    }
    REP(k,51)REP(i,51)REP(j,51) {
      dp[i][j] = min(dp[i][j], max(dp[i][k], dp[k][j]));
    }
    int mx = 0;
    REP(i,n) {
      mx = max(mx, dp[a[i]][b[i]]);
    }
    if (mx == 0) break;
    if (mx == INF) {
      cout << -1 << endl;
      return 0;
    }
    fr.insert(mx);
  }
  ll sum = 0;
  for (int i:fr) {
    sum += 1ll << i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

N, K = map(int, input().split())
U = [list(input().split()) for i in range(2 * K)]

People = []

for i in range(2 * K):
    if i % 2 == 1:
        People.append(U[i])

for i in range(1, N + 1):
    if str(i) in list(itertools.chain.from_iterable(People)):
        N -= 1

print(N)


Measured memory_bytes: 9392
#include <bits/stdc++.h>
using namespace std;
bool Binary_Search(int data[],int key,int N){
    
    int left = 0;
    int right = N;
    int mid;
    
    while(left <= right){
        mid = (left + right) / 2;
        if(data[mid] == key){
            return true;
        }
        else if(data[mid] < key){
            left = mid + 1;
        }
        else{
            right = mid - 1;
        }
    }
    return false;
}

int main(void){
   
    int X,N;
    cin >> X >> N;
    if(N == 0){
        cout << X << endl;
        return 0;
    }
    int data[N];
    for(int i=0;i<N;i++) cin >> data[i];
    sort(data,data+N);
    
    if(Binary_Search(data,X,N) == false){
        cout << X << endl;
    }
    else{
        int i = 1;
        while(1){
            if(Binary_Search(data,X-i,N) == false){
                cout << X - i << endl;
                break;
            }
            if(Binary_Search(data,X+i,N) == false){
                cout << X + i << endl;
                break;
            }
            i++;
        }
    }
}

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

typedef long long ll;

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

/**************************************************************/
    
    /* ============== Prettier and Simpler Solution ============== */
    ll length, X;   cin >> length >> X;     //length = N because the traveled distance by the first and second rays is ALWAYS X+(X-N)=N
    ll lrr = length - X, rest = lrr%X;        // lrr stands for large ray's reflection
    while(rest != 0)
    {
        length+= 2*X*(lrr/X);
        lrr = X;        X = rest;        rest = lrr%X;
    }
    length+= 2*X*(lrr/X)-X;
    cout << length << endl;
    /* ============== Prettier and Simpler Solution ============== */
}

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

struct data
{
	long long ywz,num;
} tong[100001];
long long n,ans;

bool cmp1(data x,data y)
{
	return x.num < y.num;
}

int main()
{
	SC("%lld",&n);
	for(long long i = 1; i <= n; i++)
	{
		SC("%lld",&tong[i].num);
		tong[i].ywz = i;
	}
	sort(tong+1,tong+n+1,cmp1);
	for(int i = 1; i <= n; i++)
		if(tong[i].ywz%2 != i%2)
			ans++;
	printf("%lld",ans>>1);
}

Measured memory_bytes: 1792
<?php
    while(true) { 
        list($n, $x) = explode(" ", trim(fgets(STDIN)));
        if($n + $x == 0) exit;
        
        $count = 0;
        for($i = 1; $i <= $n - 2; $i++) {
            if($i * 3 - 3 > $x) break;
            for($j = $i + 1; $j <= $n - 1; $j++) {
                for($k = $j + 1; $k <= $n; $k++) {
                    if($i + $j + $k == $x){ 
                        $count++;
                        break 1;
                    }
                }
            }
        }
        
        echo $count."\n";
    }

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/02  Problem: 088_arc_b / Link: https://abc083.contest.atcoder.jp/tasks/arc088_b?lang=en  ----- */
/* ------問題------

0 と 1 からなる文字列 S が与えられます。 以下の操作を好きな回数繰り返すことで S の要素をすべて 0 にできるような、|S| 以下の最大の整数 K を求めてください。
S の長さ K 以上の連続する区間 [l,r] を選ぶ(すなわち、r−l+1≥K が満たされる必要がある)。l≤i≤r なるすべての整数 i に対し、Si が 0 なら Si を 1 に、Si が 1 なら Si を 0 に置き換える。

-----問題ここまで----- */
/* -----解説等-----

ひっくり返していく中で境界を削除していきたい。
境界を削除する際には境界から端まで遠い方をKとすれば良い。
この複数あるKのうち、最小のものが解を生成する条件なのでこれを探せば良い。

ans = LINFとして 1WA
初期解に気をつけて#

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	string s; cin >> s;

	ans = SZ(s);
	
	FOR(i, 0, SZ(s)-1) {
		if (s[i] != s[i + 1]) {
			ans = min(ans, (LL)max(i + 1, SZ(s) - (i + 1)));
		}
	}


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;



int main(){
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll C;
    cin >> C;
    ll X;
    cin >> X;
    ll Y;
    cin >> Y;
    ll ans=INF;
    for(ll i=0;i<=max(X,Y)+10;i++){
        chmin(ans,max(0LL,A*(X-i))+max(0LL,B*(Y-i))+2*C*i)
    ;}
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
int read(){
	int i;
	scanf("%lld",&i);
	return i;
}
using vi=vector<int>;
#define PB push_back
#define ALL(x) x.begin(),x.end()
using pi=pair<int,int>;

struct UnionFind{
	vi rank,par;
	void Init(int n){
		rank.assign(n,0);
		par.assign(n,-1);
	}
	int Find(int a){
		return par[a]==-1?a:(par[a]=Find(par[a]));
	}
	bool Same(int a,int b){
		return Find(a)==Find(b);
	}
	void Unite(int a,int b){
		a=Find(a),b=Find(b);
		if(a==b)return;
		if(rank[a]<rank[b])swap(a,b);
		par[b]=a;
		if(rank[a]==rank[b])rank[a]++;
	}
};

const int mod=1000000009;

pi Merge(pi a,pi b){
	return pi(a.first+b.first,a.second*b.second%mod);
}

signed main(){
	int n=read(),m=read();
	vector<vi> g(n);
	vi deg(n,0);
	REP(_,m){
		int a=read()-1,b=read()-1;
		g[a].PB(b);
		g[b].PB(a);
		deg[a]++;
		deg[b]++;
	}
	priority_queue<pi> pq;
	REP(i,n)pq.push(pi(deg[i],i));
	vi used(n,0),ord;
	while(!pq.empty()){
		int v=pq.top().first,i=pq.top().second;
		pq.pop();
		if(deg[i]!=v)continue;
		ord.PB(i);
		for(auto j:g[i])if(!used[j])
			pq.push(pi(--deg[j],j));
		used[i]=1;
	}
	reverse(ALL(ord));
	vector<pi> ans(n);
	UnionFind uf;uf.Init(n);
	used.assign(n,0);
	for(auto i:ord){
		pi w(0,1);
		for(auto j:g[i])if(used[j])
			if(!uf.Same(i,j)){
				w=Merge(w,ans[uf.Find(j)]);
				uf.Unite(i,j);
			}
		if(w.first==0)
			w.first=1;
		else if(w.first==1)
			w.second=(w.second+1)%mod;
		ans[uf.Find(i)]=w;
		used[i]=1;
	}
	pi w=ans[uf.Find(0)];
	REP(i,n)if(!uf.Same(0,i)){
		w=Merge(w,ans[uf.Find(i)]);
		uf.Unite(0,i);
	}
	cout<<w.first<<endl<<w.second<<endl;
}

Measured memory_bytes: 19440
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  REP(i,n) cin >> s[i];
  
  sort(s.begin(), s.end());
  
  int ans = 1;
  
  REP(i,n){
    if(i != n-1){
      if(s[i] != s[i+1]){
        ans++;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 9664
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    if(n % 1000 == 0) {
        cout << 0;
        return 0;
    }
    cout << 1000 - (n % 1000);
}


Measured memory_bytes: 3516
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll n;
    cin>>n;
    ll res=0;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ll x=i-1;
            if(x&&n/x==n%x)
                res+=x;
            if(n/i!=i){
                x=n/i-1;
                if(x&&n/x==n%x)
                    res+=x;
            }
        }
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3664
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  set<int,greater<int>>大到小
#include <vector>// ::iterator it;
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e6+2e5;
inline ll read(){ll s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w;}
using namespace std;

int t,n,m,k=0,cnt=0,flag=0;

int main(){
    scanf("%d",&n);
    cnt=n/500;
    int ans=cnt*1000;
    n-=cnt*500;
    cnt=n/5;
    ans+=cnt*5;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <iso646.h>

using namespace std;

typedef long long i64;

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

    int n;
    cin >> n;

    int total = 0;
    for (int i = 0; i < n; i++)
    {
        int l, r;
        cin >> l >> r;

        total += r - l + 1;
    }

    cout << total;
}

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

int main() {
    int a, b, d, r;
    double f;
    cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = double(a) / b;
    
    printf("%d %d %.5f\n", d, r, f);
    
    return 0;
}

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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a, b;
  cin >> n >> a >> b;
  ll o = 0;
  for (int i = 0; i <= n; ++i) {
    int sum = 0, k = i;
    while(k){sum += k%10; k/=10; }
    if(sum <= b && sum >= a) o+= i;
  }
  std::cout << o << std::endl;

  return 0;
}



Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 1000
using namespace std;

int main(void) {
  int N;
  cin >> N;
  int A[MAX_N + 1][MAX_N + 1];
  int P[MAX_N + 1];
  queue<int> que;
  for (int i = 1; i <= N; i++) {
    rep(j, N - 1) { cin >> A[i][j]; }
    P[i] = 0;
    que.push(i);
  }
  que.push(-1);

  int Ans = N * (N - 1) / 2;
  vector<bool> seen(N + 1);
  int Num = 0;
  while (!que.empty()) {
    auto M = que.front();
    que.pop();
    if (M == -1) {
      if (Num == 0) {
        Ans = -1;
        break;
      }
      Ans -= (Num - 1);
      if (que.size() == 0) break;
      seen.assign(N + 1, false);
      Num = 0;
      que.push(-1);
      continue;
    }
    if (seen[M]) continue;
    int X = A[M][P[M]];
    if (seen[X]) continue;
    int Y = A[X][P[X]];
    if (Y == M) {
      seen[M] = true;
      seen[X] = true;
      P[M]++;
      if (P[M] < N - 1) que.push(M);
      P[X]++;
      if (P[X] < N - 1) que.push(X);
      Num++;
    }
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;

int main()
{
	int n;
	long long y;
	cin >> n>>y;
	int a=0,b=0;
	//10000,5000,1000
	for( a=0;a<=n;a++){
		for(b=0;b<=n-a;b++){
			if(a*10000+b*5000+(n-a-b)*1000 == y){
				cout << a <<" "<<b<<" "<<n-a-b<<endl;
				return 0;
			}
		}
	}
	cout <<"-1 -1 -1"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
    map<string,size_t> word_count;
    string word;
    while(cin>>word)
        ++word_count[word];
    map<string,size_t>::iterator a,b,c;
    a=b=word_count.begin();
    for( c=word_count.begin();c!=word_count.end();c++)
    {
        if(c->first.size()>a->first.size())
            a=c;
        if(c->second>b->second)
            b=c;
    }
    cout<<b->first<<' '<<a->first<<"\n";
    return 0;
}

Measured memory_bytes: 1188
n = int(input())
ans = [0] * (n + 1)
loop = int(n ** .5) + 1

def f(i, j, k):
    return i ** 2 + j ** 2 + k ** 2 + i*j + j*k + k*i

for i in range(1, loop+1):
    for j in range(1, loop+1):
        for k in range(1, loop+1):
            res = int(f(i, j, k))
            if res <= n:
                ans[res] += 1

for a in ans[1:]:
    print(a)


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

vector<int> section_sum(vector<int> numbers,int separate){
    int n = numbers.size()-separate;
    int initial_sum;
    decltype(numbers)::iterator nb = numbers.begin();
    decltype(numbers)::iterator ne = numbers.end();
    if (n<=0){
        vector<int> sep1;
        sep1.push_back(accumulate(nb,ne,0));
        return sep1;
    }else{
        vector<int> sep1(n),sep2(n),sep3(separate);
        sep1 = vector<int>(nb+separate , ne);
        sep2 = vector<int>(nb , ne-separate);
        sep3 = vector<int>(nb , nb+separate);
        initial_sum=accumulate(sep3.begin(),sep3.end(),0);
        for(int i=0  ;i<n  ;i++) sep1[i]-=sep2[i];
        for(int i=1  ;i<n  ;i++) {sep1[i]+=sep1[i-1];sep1[i-1]+=initial_sum;}
        sep1[n-1]+=initial_sum;
        sep1.insert(sep1.begin(),initial_sum);
        return sep1;
    }
}

int main(void){
    int n,k,tmp,pre;
    string st;
    cin>>n>>k;
    cin>>st;
    vector<int> a;
    vector<int> b;
    for(int i=0  ;i<n  ;i++){
        a.push_back(st[i]);
    }
    pre=a[0];
    tmp=1;
    for(int i=1  ;i<n  ;i++){
        if (a[i]==pre) tmp+=1;
        else{
            b.push_back(tmp);
            tmp=1;
            pre=a[i];
        }
    }
    b.push_back(tmp);
    if (a[n-1]==48) b.insert(b.end(),0);
    if (a[0]==48) b.insert(b.begin(),0);
    k=2*k+1;
    vector <int> ans=section_sum(b,k);
    vector <int> ans2;
    for(int i=0  ;i<ans.size()  ;i++){
        if (i%2==0) ans2.push_back(ans[i]);
    }
    cout<< *max_element(ans2.begin(),ans2.end()) <<endl;
}

Measured memory_bytes: 3000
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S;
ll ans = 0;

int main() {
  std::cin >> S;

  char prv = 'A';
  ll cnt = 0;

  rep( i, S.size() ) {
    if( S[i] == 'S' ) {
      cnt = 0;
    } else {
      ++cnt;
    }

    chmax( ans, cnt );
  }

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int gcd(int a, int b){
	return (b > 0)? gcd(b, a % b) : a ;
}

int main(void) {
    int N;
    cin >> N;
    int ans;
    cin >> ans;
    for(int i=1; i<N; i++) {
        int A;
        cin >> A;
        ans = gcd(ans, A);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()

int cnt[26];

int main(void){
	string s,t;
	int ans = 150;
	cin >> s;
	for(char i='a';i<='z';i++){
		t = s;
		int cur = 0;
		while(true){
			set<char> st;
			for(char i:t)st.insert(i);
			if(st.size()==1){
				break;
			}
			cur++;
			for(int j=0;j<t.size()-1;j++){
				if(t[j+1] == i){
					t[j] = i;
				}
			}
			t.pop_back();
		}
		ans = min(ans,cur);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#
# abc144 a
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    A, B = map(int, input().split())

    if 1 <= A <= 9 and 1 <= B <= 9:
        print(A*B)
    else:
        print("-1")


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 5"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 10"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """9 9"""
        output = """81"""
        self.assertIO(input, output)


if __name__ == "__main__":
    #unittest.main()
    resolve()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

ll n;

void dfs(ll i, ll cnt, string s) {
  rep(j, cnt) {
    char c = 'a'+j;
    if (i != n) dfs(i+1, cnt + (j == cnt-1) , s+c);
    else cout << s << c << endl;
  }
}

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

  cin >> n;
  dfs(1, 1, "");
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0;
  cin >> n;
  map<ll, ll> mp;
  for (ll i = 2; i <= n; ++i) mp[i * (i - 1) / 2] = i;

  if (n == 1) {
    cout << "Yes" << endl;
    cout << "2" << endl;
    cout << "1 1" << endl;
    cout << "1 1" << endl;
    return 0;
  }
  
  if (mp.count(n)) {
    int m = mp[n], num = 1;
    vector<set<int>> v(m);
    rep(i, m) for (int j = i + 1; j < m; ++j) v[i].insert(num),
        v[j].insert(num++);

    cout << "Yes" << endl;
    cout << m << endl;
    for (auto x : v) {
      cout << x.size() << " ";
      for (auto y : x) cout << y << " ";
      cout << endl;
    }
    return 0;
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 19048
/// N number

#include <bits/stdc++.h>

#define lop(n) for(int i=0; i<n; i++)
#define loop(j,n) for(int i=j; i<n; i++)

typedef long long ll;

using namespace std;

int main()
{
    int n, x, sum;
    while(cin>>n>>x)
    {
        if(n == 0 && x==0)
            return 0;
        sum=0;
        for(int i=1; i<n-1; i++)
        {
            for(int j=i+1; j<n; j++)
            {
                for(int k=j+1; k<=n; k++)
                {
                    if(i != j && i != k && j != k)
                    {
                        if(i+j+k == x)
                            sum++;
                    }
                }
            }
        }
        cout<<sum<<endl;
    }

    return 0;
}




Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
using namespace std;

int main(){
    long long int m;
    long long int point=0;
    cin >> m;
    while(m >= 500){
        m -= 500;
        point += 1000;
    }
    while(m >= 5){
        m -= 5;
        point += 5;
    }
    cout << point << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define NIL -1

struct Node{
    int parent,right,left;
};

int getDepth(struct Node *,int);

int main(){
    int n,m;
    int id,c,tmp;
    int depth[MAX];

    struct Node TREE[MAX];

    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        TREE[i].parent = TREE[i].left = TREE[i].right = NIL;
    }

    for(int i = 0;i < n;i++){
        scanf("%d%d",&id,&m);
        for(int j = 0;j < m;j++){
            scanf("%d",&c);
            //j == 0の時は、子供ではなく親となるノードなので
            if(j == 0){
                //子供のid
                TREE[id].left = c;
                //子供たちの親
                TREE[c].parent = id;
                tmp = c;
            }
            else{
                //子供たちのidのノードを設定
                TREE[tmp].right = c;
                TREE[c].parent = id;
                tmp = c;
            }
        }
    }
    for(int i = 0;i < n;i++){
        depth[i] = getDepth(TREE,i);
    }

    for(int i = 0; i < n; i++){
        printf("node %d: parent = %d, depth = %d, ", i, TREE[i].parent, depth[i]);
        //親がいなかったら
        if(TREE[i].parent == NIL){
            printf("root");
        }
        // 子供がいなかったら
        else if(TREE[i].left == NIL){
            printf("leaf");
        }
        // どちらでもない時
        else{
            printf("internal node");
        }
        printf(", [");
        //子供がいなくなるまで
        if(TREE[i].left != NIL){
            printf("%d",TREE[i].left);
            tmp = TREE[i].left;
            while(1){
                if(TREE[tmp].right == NIL) break;
                printf(", %d", TREE[tmp].right);
                tmp = TREE[tmp].right;
            }
        }
        printf("]\n");
    }

    return 0;
}

int getDepth(struct Node *TREE,int i){
    if(TREE[i].parent == NIL)return 0;
    return getDepth(TREE,TREE[i].parent) + 1;
}


Measured memory_bytes: 3256
#include<cstdio>
using namespace std;
int n,num,ans,ys[1000005];
int main(){
	scanf ("%d",&n);
	while (num<n){
		num=num*10+7;
		++ans;
	}
	while (1){
		if (num%n==0){
			printf ("%d\n",ans);
			return 0;
		}
		if (ys[num%n]){
			printf ("-1\n");
			return 0;
		}
		ys[num%n]=1;
		num%=n;num=num*10+7;
		++ans;
	}
	return 0;
}

Measured memory_bytes: 5636
N, K = map(int, input().split())
A = list(map(int, input().split()))

cumsum = [0 for _ in range(N + 1)]
for i in range(N):
    cumsum[i + 1] = cumsum[i] + A[i]

for i in range(N):
    if i <= K - 1:
        continue

    prev = cumsum[i] - cumsum[i - K]
    now = cumsum[i + 1] - cumsum[i - K + 1]
    if now > prev:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 31856
#abc125 c
n=int(input())
a=list(map(int,input().split()))

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

fl_gcd=[0]*(n+1)
fr_gcd=[0]*(n+1)

for i in range(n):
    fl_gcd[i+1]=gcd(fl_gcd[i],a[i])
    fr_gcd[n-i-1]=gcd(fr_gcd[n-i],a[n-1-i])
#print(fr_gcd)
#print(fl_gcd)

ans=0
for i in range(n):
    lr_gcd=gcd(fl_gcd[i],fr_gcd[i+1])
    ans=max(ans,lr_gcd)
print(ans)

Measured memory_bytes: 14060
# a, bの最大公約数を返す関数
def GCD(a, b):
    if (b == 0):
        return a
    else:
        return GCD(b, a % b)


if __name__ == "__main__":
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    res = 0
    for i in range(N):
        res = GCD(res, abs(x[i] - X))
    print(res)


Measured memory_bytes: 14224
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll>P;
typedef pair<ll,P>Pi;
ll n,a,b,ans,ra[100000],fa[100000];
vector<P>v1,v2;
priority_queue<Pi,vector<Pi>,greater<Pi>>pque;
ll find(ll x){
    if(x==fa[x])return x;
    return fa[x]=find(fa[x]);
}
void uni(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y)return ;
    if(ra[x]<ra[y])swap(x,y);
    fa[y]=x;
    if(ra[x]==ra[y])ra[x]++;
}
int main(void){
    cin>>n;
    vector<vector<Pi>>G(n);
    for(int i=0;i<n;i++)fa[i]=i;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v1.push_back({a,i});
        v2.push_back({b,i});
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    auto s=v1[0],t=v2[0];
    for(int i=1;i<n;i++){
        auto s1=v1[i],t1=v2[i];
        G[s.S].push_back(Pi(s1.F-s.F,{s.S,s1.S}));
        G[t.S].push_back(Pi(t1.F-t.F,{t.S,t1.S}));
        G[s1.S].push_back(Pi(s1.F-s.F,{s1.S,s.S}));
        G[t1.S].push_back(Pi(t1.F-t.F,{t1.S,t.S}));
        if(s.S==0)pque.push(Pi(s1.F-s.F,{s.S,s1.S}));
        if(s1.S==0)pque.push(Pi(s1.F-s.F,{s1.S,s.S}));
        if(t1.S==0)pque.push(Pi(t1.F-t.F,{t1.S,t.S}));
        if(t.S==0)pque.push(Pi(t1.F-t.F,{t.S,t1.S}));
        s=s1,t=t1;
    }
    while(pque.size()){
        auto p=pque.top();
        pque.pop();
        auto pp=p.S;
        ll p1=p.F,p2=pp.F,p3=pp.S;
        //cout<<p1<<endl;
        if(find(p2)!=find(p3)){
            //cout<<ans<<endl;
            uni(p2,p3);
            ans+=p1;
            for(auto x:G[p3])pque.push(x);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 27744
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

void Main() {
  ll n;
  std::cin >> n;
  std::vector<ll> h(n);
  for (auto &x : h) {
    std::cin >> x;
  }

  ll maxnum = -1;
  for (auto &x : h) {
    if (!(chmax(maxnum, x))) {
      if (abs(maxnum - x) >= 2) {
        std::cout << "No" << '\n';
        return;
      }
    }
  }

  std::cout << "Yes" << '\n';

  return;
}

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


Measured memory_bytes: 1024
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
S = int(input())

def f(b, n):
    if n < b:
        return n
    return f(b, n // b) + n % b

MAX = 10 ** 6
for b in range(2, MAX + 1):
    res = f(b, N)
    if res == S:
        print(b)
        exit()
x = N - S
if x < 0:
    print(-1)
elif x == 0:
    print(N + 1)
else:
    ans = -1
    for p in range(1, MAX + 1):
        if x % p == 0:
            b = (x // p) + 1
            if b > MAX and N // b == p:
                ans = b
    print(ans)


Measured memory_bytes: 74612