akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin >> S;  
if (S=="MON") {cout << "6"  <<endl;
           }else if (S=="TUE") {cout << "5"  <<endl;
                            }else if (S=="WED") {cout << "4"  <<endl;
                                        }else if (S=="THU") {cout << "3"  <<endl;
                                                          }else if (S=="FRI") {cout << "2"  <<endl;
                                                                            }else if (S=="SAT") {cout << "1"  <<endl;
                                                                                              }else{cout << "7"  <<endl;
                                                                                                                   }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back

int a, b, c, x, y;

int main()
{
  scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
  int ans = a*x + b*y;
  for (int i = 2*max(x, y); i >= 0; i -= 2)
    {
      ans = min(ans, a*max(0, x-i/2) + b*max(0, y-i/2) + i*c);
    }
  printf("%d\n", ans);
}




Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int calcLimit(int n){
	int limit;
	for(limit=0;limit*limit<=n;limit++);
	return limit-1;
}

int main(){
	int n,count,limit;

	while(scanf("%d",&n)!=EOF){
		count=0;
		int* array = new int[n+1];
		for(int i=1;i<=n;i++)array[i]=0;
		limit = calcLimit(n);
		for(int i=2;i<=limit;i++){
			if(array[i] == 0)
			{
				for(int j=2*i;j<=n;j+=i){
					if(array[j]==0){
						array[j]=1;
						count++;
					}
				}
			}
		}
		printf("%d\n",n-(count+1));
	}

    return 0;
}


Measured memory_bytes: 59680
n=int(input())
a=list(map(int,input().split()))
num2=0
num4=0
kisu=0
for i in range(n):
    if a[i]%4==0:
        num4+=1
    elif a[i]%2==0:
        num2+=1
    else:
        kisu+=1
flag=True
if num4==0:
    if 0<kisu:
        flag=False
else:
    if num2==0:
        if not(kisu<=num4+1):
            flag=False
    else:
        if not(kisu<=num4):
            flag=False
print("Yes" if flag else "No")

Measured memory_bytes: 62576
N = gets.chomp.to_i
n = N
i = 0
while n > 0
    n /= 10
    i += 1
end
k = 0
a = 0
for j in 1..i/2 do
    a += 9*(100**(j-1))
end
if i%2 == 1
    a += (N-100**(i/2)+1)
end
puts a

Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
    int i,j,n[10],temp;
	for(i=0;i<10;i++){
		scanf("%d",&n[i]);
	}

	for(i=10;i>0;i--){
		for(j=0;j<i-1;j++){
			if(n[j]>=n[j+1]){
				temp=n[j+1];
				n[j+1]=n[j];
				n[j]=temp;
			}
		}
	}

	for(i=9;i>=7;i--){
		printf("%d\n",n[i]);
	}

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
ll k;
ll sum=1;
ll inf=1e18;
int main()
{
    long  double c;
    ll a;
    cin>>a>>c;
    k=(long long int )a*c;
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 3732
data = [int(i) for i in input().split(" ")]

x1 = data[0]
x2 = data[1]
y1 = data[2]
y2 = data[3]

if x1 >= 0 and y2 < 0:
    print(x1 * y2)
elif x2 < 0 and y1 >= 0:
    print(x2 * y1)
elif (x1 < 0 and x2 >= 0) and (y1 < 0 and y2 >= 0):
    print(max(x1*y1,x2*y2))
elif x1 >= 0 or y1 >= 0:
    print(x2 * y2)
elif x2 < 0 or y2 < 0:
    print(x1 * y1)


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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;

#define int ll
const int mod = 1e9+7;
const int N = 2e5+7;

int n;

int a[N];
int dp[N];
int sum[N];

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

	cin >> n;

	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];

		if(a[i]==a[i-1])
		{
			--i;
			--n;
		}
	}

	dp[0] = 1;

	for(int i = 1; i <= n; ++i)
	{
		dp[i] = dp[i-1];
		dp[i] += sum[a[i]];
		dp[i] %= mod;
		sum[a[i]] += dp[i-1];
		sum[a[i]] %= mod;
	}

	cout << dp[n] << endl;
}

Measured memory_bytes: 4992
// Author : heyuhhh
// Created Time : 2020/09/19 20:48:35
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
void run() {
    ll n;
    int x, m;
    cin >> n >> x >> m;
    
    vector<int> f(m + 2);
    vector<ll> sum(m + 2);
    f[1] = sum[1] = x;

    if (n <= m) {
        for (int i = 2; i <= n; i++) {
            f[i] = 1ll * f[i - 1] * f[i - 1] % m;
            sum[i] = sum[i - 1] + f[i];
        }
        ll res = sum[n];
        cout << res << '\n';
        return;
    }

    ll ans = x, S;
    vector<int> last(m + 2, -1);
    last[x] = 1;
    int len, k;
    for (int i = 2; i <= m + 1; i++) {
        f[i] = 1ll * f[i - 1] * f[i - 1] % m;
        sum[i] = sum[i - 1] + f[i];
        if (last[f[i]] != -1) {
            k = last[f[i]];
            len = i - k;
            S = sum[i] - sum[last[f[i]]];
            n -= i - 1;
            break;
        }
        ans += f[i];
        last[f[i]] = i;
    }
    ans += (n / len) * S + sum[k + n % len - 1] - sum[k - 1];
    cout << ans << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

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

#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;


void solveBruteForce()
{

}

void solveOptimized()
{
	int n;
	cin >> n;
	int a[n];

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

	sort(a, a + n);

	int divisible[1000001];
	for (int i = 1; i < 1000001; i++)
		divisible[i] = 0;
	divisible[0] = 1;

	for (int i = 0; i < n; i++)
	{
		int j = a[i];
		if (divisible[j] < 2)
		{
			while (j < 1000001)
			{
				divisible[j]++;
				j += a[i];
			}
		}
		
	}

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (divisible[a[i]] <= 1)
			ans++;
	}

	cout << ans;
}

void solve()
{
	// solveBruteForce();
	solveOptimized();
}

int main()
{


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

	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}




Measured memory_bytes: 8300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author k16069kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        int r = 0;
        int c = 0;

        int l = 0;
        int matrix[][] = new int[100][100];
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                if (r == 0 && c == 0) {
                    r = Integer.parseInt(st.nextToken());
                    c = Integer.parseInt(st.nextToken());
                } else {
                    for (int i = 0; i < c; i++) {
                        matrix[l][i] = Integer.parseInt(st.nextToken());
                    }
                    l++;
                }
            }
            if (l == r) {
                break;

            }

        }
        int sum = 0;
        int ans_matrix[][] = new int[r + 1][c + 1];
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                ans_matrix[i][j] = matrix[i][j];
                ans_matrix[i][c] += matrix[i][j];
            }
            sum += ans_matrix[i][c];
        }
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                ans_matrix[r][j] += matrix[i][j];
            }
        }
        ans_matrix[r][c] = sum;

        for (int i = 0; i < ans_matrix.length; i++) {
            for (int j = 0; j < ans_matrix[i].length; j++) {
                System.out.print(ans_matrix[i][j]);
                if (!(j == c)) {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 32980
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define M 1000000007
int n,x[205];
ll dp[205][205][205];
int main(void){
    cin>>n;
    for(int i=0;i<n;){
        char c;
        cin>>c;
        if(c=='U')x[i++]=1;
        else if(c=='D')i++;
        else n--;
    }
    dp[0][0][0]=1;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=n;j++){
            for(ll k=0;k<=n;k++){
                if(x[i]==1){
                    if(j>0)dp[i+1][j][k]=(dp[i][j][k]*j%M+dp[i][j-1][k-1])%M;
                    else dp[i+1][j][k]=dp[i][j][k]*j%M;
                }else{
                    dp[i+1][j][k]=(dp[i][j+1][k+1]*(k+1)*(j+1)%M+dp[i][j][k]*k)%M;
                }
            }
        }
    }
    cout<<dp[n][0][0]<<endl;
}


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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  
  if (N%X == 0) {
    cout << (N/X)*T << endl;
  }
  else {
    cout << (N/X + 1)*T << endl;
  }
}

Measured memory_bytes: 3624
N = int(input())
P = [int(input()) for _ in range(N)]

lst = [0] * (N + 1)
for i in range(N):
    lst[P[i]] = i

count = 1
i = 1
while i < N: #startを動かす
    tmp = i
    # print ('tmp', tmp)
    tmp_count = 1
    while tmp < N and lst[tmp] < lst[tmp + 1]:
        tmp_count += 1
        tmp += 1
    count = max(count, tmp_count)
    i = tmp + 1

print (N - count)
# print (lst)

Measured memory_bytes: 18960
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


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

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100005];

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i);
    sort(a, a + n);
    if (n >= 3 && a[0] == a[2]) {
        cout << "Impossible" << endl;
        return 0;
    }
    int mx, st;
    if (a[0] == a[1]) {
        mx = a[0] * 2 - 1;
        st = 2;
    } else {
        mx = a[0] * 2;
        st = 1;
    }
    if (a[n - 1] != mx) {
        cout << "Impossible" << endl;
        return 0;
    }
    forn(i, n - 1) if (a[i + 1] > a[i] + 1) {
        cout << "Impossible" << endl;
        return 0;
    }
    for (int i = st; i < n; ++i) {
        bool ok = false;
        if (i > st && a[i] == a[i - 1]) {
            ok = true;
        }
        if (i < n - 1 && a[i] == a[i + 1]) {
            ok = true;
        }
        if (!ok) {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();
        int k = sc.nextInt();
        sc.close();
        char[] c = s.toCharArray();
        //int a = Integer.parseInt(S[0]);
        //int b = Integer.parseInt(S[1]);
        //int c = Integer.parseInt(S[2]);
        char target = c[k-1];

        for (int i = 0; i < n; i++) {
            if (c[i] != target) {
                c[i] = '*';
            }
        }
        System.out.println(String.valueOf(c));
    } 
}     

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N; ll K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) --A[i];
    vector<int> ord(N, -1);
    int way = 0, cir = 1;
    vector<int> ans;
    int cur = 0;
    while (ord[cur] == -1) {
        ord[cur] = sz(ans);
        ans.push_back(cur);
        cur = A[cur];
    }
    way = ord[cur];
    cir = sz(ans) - way;
    if (way >= K) cout << ans[K] + 1 << '\n';
    else {
        K -= way;
        K %= cir;
        cout << ans[way + K] + 1 << '\n';
    }
    return 0;
}


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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17 + 5
#define ll long long
#define int long long
#define pow poww

const int N = 1e5 + 5;
int n , mod = 1e9 + 7;
int dp[N][3];
vector < int > g[N];

int add(int a , int b)
{
    return (a + b) % mod;
}

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

void DFS(int i , int j)
{
    dp[i][0] = dp[i][1] = 1;
    REP(s , g[i].size())
    {
        int u = g[i][s];
        if(u != j)
        {
            DFS(u , i);
            dp[i][0] = mul(dp[i][0] , add(dp[u][0] , dp[u][1]));
            dp[i][1] = mul(dp[i][1] , dp[u][0]);
        }
    }
}

main()
{
    //freopen("P.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n - 1)
    {
        int u , v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    DFS(1 , -1);
    cout << add(dp[1][0] , dp[1][1]);
}


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

int N;
vector<long long> x, y;

int solve(){
    if(N == 1) return 1;

    int res = N;
    for(int i = 0; i < N; i++){
        for(int j = i; j < N; j++){
            if(i == j) continue;
            long long dx = x[j] - x[i], dy = y[j] - y[i];

            int sub = 0;
            for(int i2 = 0; i2 < N; i2++){
                for(int j2 = 0; j2 < N; j2++){
                    if(j2 == i2) continue;
                    if(dx == x[j2] - x[i2] && dy == y[j2] - y[i2]) ++sub;
                }
            }
            res = min(res, N - sub);
        }
    }
    return res;
}
int main(){
    cin >> N;
    x.resize(N); y.resize(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
    cout << solve() << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:
int n,k;
ll ans=0LL;
vector<int> tree[100010];

int dfs(int v,int p){
	int cmax=0;
	for(auto &v2:tree[v]){
		if(v2==p) continue;
		chmax(cmax,dfs(v2,v)+1);
	}

	if(p!=-1) if(cmax==k||(p!=0 && cmax == k-1)) ans++,cmax=-1;
	return cmax;
}

int main(void){
	cin >>  n >> k;

	rep(i,n){
		int a;
		cin >> a,a--;
		if(i==0)
			ans=(a!=0);
		else
			tree[a].push_back(i);
	}

	dfs(0,-1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
using namespace std;
int dp[1000][1000];
char c[1000][1000];
signed main(){
	int a,b;
	cin>>a>>b;
	dp[0][0]=1;
	f(i,a){
		f(j,b){
			cin>>c[i][j];
			if(c[i][j]=='#') dp[i][j]=0;
			else if(i&&j) dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			else if(i) dp[i][j]=dp[i-1][j];
			else if(j) dp[i][j]=dp[i][j-1];
		}
	}
	cout<<dp[a-1][b-1]<<endl;
	return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a=NULL,*b=NULL;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
inline int read() {
	int x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
const int maxn=1e5+1;
int n,a[maxn];
bool f() {
	int odd=0,even=0,id=0;
	for (int i=1;i<=n;++i) {
		odd+=(a[i]&1);
		even+=(~a[i]&1);
		if (a[i]&1) id=i;
	}
	if (even&1) return true;
	if (odd>1) return false;
	if (a[id]==1) return false;
	--a[id];
	int g=a[1];
	for (int i=2;i<=n && g>1;++i) g=__gcd(g,a[i]);
	if (g>1) for (int i=1;i<=n;++i) a[i]/=g;
	return f()^true;
}
int main() {
	n=read(),generate_n(a+1,n,read);
	puts(f()?"First":"Second");
	return 0;
}


Measured memory_bytes: 1664
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let (mut a, mut b, c,  mut x, mut y) = input!(i32, i32, i32, i32, i32);
    let mut total = 0;

    while x > 0 || y > 0 {
        if x <= 0 {
            a = 0;
        }
        if y <= 0 {
            b = 0;
        }
        if a + b > c * 2 {
            total += c * 2;
        } else {
            total += a + b;
        }
        x -= 1;
        y -= 1;
    }
    println!("{}", total);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define getMat(x, n, m, val) vector<vector<ll>> x(n, vector<ll> (m, val))
#define setp fixed<<setprecision
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll M=1000000000+7;
 
ll power(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

int main(){
    ll t=1;
    // cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        ll a[n];
        for(ll i=0;i<n;i++)cin>>a[i];
        sort(a,a+n);
        ll ans=0;
        for(ll i=0;i<k;i++)ans+=a[i];
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto h = lread();
    ulong i;
    while (2 ^^ i <= h)
        i++;
    writeln(2 ^^ i - 1);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
from operator import itemgetter
n = int(input())
ab = sorted([tuple(map(int,input().split())) for i in range(n)], key = itemgetter(1))
time = 0
for i in range(n):
    time += ab[i][0]
    if time > ab[i][1]:
        print("No")
        exit()
print("Yes")

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

 int digit(int a)
 {
  int count=0;
  while (a)
  {
    a/=10 ;
    count++;
  }
  return count;
}

int main(){
  int a, b ;
  while(cin >> a >> b)
    cout << digit(a+b)<<endl;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return [f = std::forward<F>(f)](auto&&... args) {
    return f(f, std::forward<decltype(args)>(args)...);
  };
}
template<typename T>
static inline T fin() { T t; cin >> t; return std::move(t); }

int main() {
  i64 k, x;
  cin >> k >> x;
  vector<i64> vec;
  for(int i = max(-1000000ll, x - k + 1);i <= min(1000000ll, x + k - 1);i++) {
    vec.push_back(i);
  }
  for(int i = 0;i < vec.size();i++) {
    cout << vec[i] << " \n"[i + 1 == vec.size()];
  }
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, q;
string s;
char t[202020];
char d[202020];

bool calc1(int cur){
    REP(i, q){
        if(t[i] == s[cur]){
            if(d[i] == 'L')cur--;
            if(d[i] == 'R')cur++;
        }
        if(cur == n + 1)return false;
    }
    return cur == 0;
}

bool calc2(int cur){
    REP(i, q){
        if(t[i] == s[cur]){
            if(d[i] == 'L')cur--;
            if(d[i] == 'R')cur++;
        }
        if(cur == 0)return false;
    }
    return cur == n + 1;
}

int main(){
    INIT;
    cin >> n >> q;
    cin >> s;
    s = " " + s;
    REP(i, q){
        cin >> t[i] >> d[i];
    }
    int l1 = 0, r1 = n + 1;
    while(r1 - l1 > 1){
        int mid = (l1 + r1)/2;
        if(calc1(mid)){
            l1 = mid;
        }else{
            r1 = mid;
        }
    }
    int l2 = 0, r2 = n + 1;
    while(r2 - l2 > 1){
        int mid = (l2 + r2)/2;
        if(calc2(mid)){
            r2 = mid;
        }else{
            l2 = mid;
        }
    }
    cout << n - l1 - (n - r2 + 1) << endl;
}

Measured memory_bytes: 976
#include<iostream>
using namespace std;
#define rep(i,s,e) for ( int i = s; i <= e; i++ )
#define MAX 10000
char C[MAX+2];
int n, m;

void setLeft(char ch){
    for ( int i = 1; ; i++ ){
	if ( C[i] == '#' ) { C[i] = ch; return; }
    }
}

void setB(){
    for ( int i = n; i >= 1; i-- ){
	if ( C[i] == '#' && C[i-1] != 'A' && C[i+1] != 'A' ){
	    C[i] = 'B'; return;
	}
    }
    setLeft('B');
}

bool isEmpty(){
    rep(i,1,n) if ( C[i] != '#' ) return false;
    return true;
}

void setC(){
    if ( isEmpty() ){ C[n/2+1] = 'C'; return; }
    rep(i,1,n){
	if ( C[i] == '#' ) continue;
	if ( C[i+1] == '#' ) { C[i+1] = 'C'; return; }
	if ( C[i-1] == '#' ) { C[i-1] = 'C'; return; }
    }
}

int getDist( int p ){
    int l = 0, r = 0;
    while( C[p+l-1] == '#' ) l--;
    if ( C[p+l-1] == 'X' ) l = -1000000;
    while( C[p+r+1] == '#' ) r++;
    if ( C[p+r+1] == 'X' ) r = 1000000;
    return min( (-1)*l, r);
}
void setD(){
    if ( isEmpty() ){ C[1] = 'D'; return; }
    int d, mi, md = -1;
    rep(i,1,n){
	if ( C[i] != '#' ) continue;
	d = getDist(i);
	if ( d > md ) {
	    md = d; mi = i;
	}
    }
    C[mi] = 'D';
}

main(){
    char ch;
    while( cin >> n >> m && n && m ){
	rep(i,0,n+1) C[i] = '#';
	C[0] = C[n+1] = 'X';
	rep(i,1,m){ 
	    cin >> ch;
	    if ( ch == 'A' ) setLeft('A');
	    else if ( ch == 'B' ) setB();
	    else if ( ch == 'C' ) setC();
	    else if ( ch == 'D' ) setD();
	}
	rep(i,1,n) cout << C[i];
	cout << endl;
    }
}

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

using namespace std;

int InsertionSort ( vector<int> &A, int gap )
{
	int count=0, i,v,j;

	for ( i = gap ; i < A.size() ; i++ )
	{
		v = A[i];
		for ( j = i-gap ; j>=0 && A[j]>v ; j-=gap )
		{
			A[j+gap] = A[j];
			count++;
		}
		A[j+gap] = v;
	}
	return count;
}

void show ( vector<int> v )
{
	int i;

	for ( i = 0 ; i < v.size() ; i++ )
		cout << v[i] << endl;
}

int ShellSort ( vector<int> &A )
{
	int count=0, i;

	vector<int> G;
	G.push_back ( 1 );
	
	i = 0;
	while ( 3*G[i]+1 <= A.size() )
	{
		G.push_back ( 3*G[i]+1 );
		i++;
	}

	cout << G.size() << endl;

	for ( i = G.size()-1 ; i > 0 ; i-- )
	{
		cout << G[i] << " ";
	}
	cout << G[i] << endl;

	for ( i = G.size()-1 ; i >= 0 ; i-- )
	{
		count += InsertionSort ( A, G[i] );
	}

	return count;
}

int main ()
{

	int n,a;
	vector<int> A;

	cin >> n;

	while ( n-- )
	{
		cin >> a;
		A.push_back ( a );
	}

	cout << ShellSort ( A ) << endl;

	show ( A );

return 0;
}



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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

int n, m;
int deg[MAXN];

void init ();
void input ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d%d", &n, &m );
	int u, v;
	lp ( i, 0, m ){
		scanf ( "%d%d", &u, &v );
		++deg[u], ++deg[v];
	}
}

void work ()
{
	// main work
	
	bool flag = true;
	lpi ( i, 1, n ){
		if ( deg[i] & 1 ){
			flag = false;
			break;
		}
	}
	
	cout << ( flag ? "YES" : "NO" ) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	ll k;
	vector<ll>  v;
	cin >> k;
	rep(i, 51) {
		if (i != ((50 - (k % 50)) % 50)) {
			v.push_back((k+49)/50+i-1);
		}
		
	}
	cout << 50 << endl << v << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;
LL N;
std::vector<std::vector<std::vector<std::vector<LL>>>>memo;

std::string cs[] = { "A","C","G","T","X" };

LL dp(LL i, LL j, LL k, LL l)
{
	if (i == N) return 1;
	if (memo[i][j][k][l] != -1) return memo[i][j][k][l];
	LL res = 0;
	rep(c, 4)
	{
		std::string str = cs[j] + cs[k] + cs[l] + cs[c];
		bool ok = true;
		rep(p, 3)
		{
			if (str.substr(p, 3) == "AGC")
			{
				ok = false;
				break;
			}
			auto temp = str.substr(0, p) + str[p + 1] + str[p] + str.substr(p + 2);
			rep(a, 2)
			{
				if (temp.substr(a, 3) == "AGC")
				{
					ok = false;
					break;
				}
			}
			if (!ok) break;
		}
		if (ok) (res += dp(i + 1, k, l, c)) %= mod;
	}
	return memo[i][j][k][l] = res;
}

int main()
{
	in >> N;
	memo.resize(N);
	rep(i, memo.size())
	{
		memo[i].resize(5);
		rep(j, memo[i].size())
		{
			memo[i][j].resize(5);
			rep(k, memo[i][j].size()) memo[i][j][k].resize(5, -1);
		}
	}
	out << dp(0, 4, 4, 4) << std::endl;
}


Measured memory_bytes: 512
n,a,b = map(int,input().split())
m = 10**9+7

def nCr(n_, r_, m_):
  c = min(r_ , n_ - r_)
  bunshi = 1
  bunbo = 1
  for i in range(1,c+1):
    bunshi = bunshi * (n_+1-i) % m_
    bunbo = bunbo * i % m_
  return bunshi * pow(bunbo, m_-2, m_) % m_


ans = pow(2,n,m)-1
ans -= nCr(n,a,m)
ans %= m
ans -= nCr(n,b,m)
ans %= m
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> d(n);
    for (auto &&i : d) scanf("%d", &i);
    while (q--) {
        int sz, x, mod;
        cin >> sz >> x >> mod;
        vector<int> dd(n), ok(n);
        for (int i = 0; i < n; ++i) {
            dd[i] = d[i] % mod;
            ok[i] = (dd[i] != 0);
        }
        ll loop = (sz-1)/n;
        ll dy = x%mod, ans = 0;
        for (int i = 0; i < n; ++i) {
            dy += (i < (sz-1)%n ? loop+1 : loop)*dd[i];
            ans += (i < (sz-1)%n ? loop+1 : loop)*ok[i];
        }
        cout << ans-dy/mod << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
N = int(input())
ans = 0
A = range(1, N)
for a in A:
    b = N - a

    sum_a = 0
    q, mod = divmod(a, 10)
    sum_a += mod
    while q != 0:
        q, mod = divmod(q, 10)
        sum_a += mod

    sum_b = 0
    q, mod = divmod(b, 10)
    sum_b += mod
    while q != 0:
        q, mod = divmod(q, 10)
        sum_b += mod

    if a == 1:
        ans = sum_a + sum_b
    elif ans > sum_a + sum_b:
        ans = sum_a + sum_b
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <cassert>
using namespace std;
using lint = long long;
const long mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int N, X;
vector<int> S;

long dp[210][100010];

long find(int now, int num){
    if(dp[now][num] != -1){
        return dp[now][num];
    }else if(now == N - 1){
        return dp[now][num] = num % S[now];
    }else{
        return dp[now][num] = (find(now + 1, num) * (N - now - 1) + find(now + 1, num % S[now])) % mod;
    }
}

int main(){
    cin >> N >> X;
    S.resize(N);
    cins(all(S));
    sort(all(S), greater<int>());
    memset(dp, -1, sizeof(dp));
    cout << find(0, X) << endl;
}


Measured memory_bytes: 164352
import java.util.*;

public class Main {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int nab = ((int)Math.max(X,Y)) * 2;
        int answer = Integer.MAX_VALUE;
        while(true) {
            int x = X - nab/2; if ( x < 0 ) { x = 0; }
            int y = Y - nab/2; if ( y < 0 ) { y = 0; }
            int v = x * A + y * B + nab * C;
            if ( v < answer ) {
                answer = v;
            }
            nab = nab - 2;
            if ( nab < 0 ) {
                break;
            }
        };
        System.out.println(answer);
    };
  }
}

Measured memory_bytes: 22868
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    long long n, x;
    cin >> n >> x;

    long long ans = n;
    long long a = x;
    long long b = n - x;
    while(a > 0){
        ans += b / a * a * 2;
        b %= a;
        swap(a, b);
    }
    ans -= b;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define MAX 500000
#define INF 2000000000
using namespace std;

int L[MAX/2+2],R[MAX/2+2];
int cnt = 0;

void Merge(int a[], int n, int left, int mid, int right){
	for(int i = 0; i < mid-left; i++)	L[i] = a[left+i];
	for(int i = 0; i < right-mid; i++)	R[i] = a[mid+i];
	L[mid-left] = R[right-mid] = INF;
	int i = 0, j = 0;
	for(int k = left; k < right; k++){
		cnt++;
		if(L[i] <= R[j])	a[k] = L[i++];
		else	a[k] = R[j++];
	} 
}

void Merge_sort(int a[], int n, int left, int right){
	if(left+1 < right){
		int mid = (right+left)/2;
		Merge_sort(a, n, left, mid);
		Merge_sort(a, n, mid, right);
		Merge(a, n, left, mid, right);
	}
}

int main(){
	int a[MAX], n;
	cin>>n;
	for(int i = 0; i < n; i++)
		cin>>a[i];
	Merge_sort(a, n, 0, n);
	for(int i = 0; i < n; i++){
		if(i)	cout<<" ";
		cout<<a[i];
	}
	cout<<endl<<cnt<<endl;
	return 0 ;
}



Measured memory_bytes: 6928
use proconio::input;
use std::collections::HashMap;

const LIMIT: usize = 1_000_005;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }

    a.sort();
    let a = a;

    let mut v = vec![0i64; LIMIT];
    for ai in a.iter().copied() {
        if v[ai] > 0 {
            v[ai] += 1;
            continue;
        }

        let mut tmp = ai;
        while tmp < LIMIT {
            v[tmp] += 1;
            tmp += ai;
        }
    }

    let mut ans = 0i64;
    for ai in a {
        if v[ai] == 1 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 12704
open Core

let n, y = Scanf.scanf "%d %d" (fun n y -> (n, y / 1000))

let pred i j = (10 * i) + (5 * j) + (n - i - j) = y

let rec find i j =
  if i > n then (-1, -1, -1)
  else if i + j > n then find (i + 1) 0
  else if pred i j then (i, j, n - i - j)
  else find i (j + 1)

let a, b, c = find 0 0

let () = Printf.printf "%d %d %d\n" a b c


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

int main()
{
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0)
    {
    	cout << "1" << endl;
    }
    else if(b==0)
    {
    	cout << "2" << endl;
    }
    else if(c==0)
    {
    	cout << "3" << endl;
    }
    else if(d==0)
    {
    	cout << "4" << endl;
    }
    else if(e==0)
    {
    	cout << "5" << endl;
    }
	return 0;
}


Measured memory_bytes: 3040
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m = lr()
base = (n-m)*100 + m*1900
print(base*(2**m))

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

namespace _ {
	bool rEOF = 1;//为0表示文件结尾
	inline char nc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
	}
	template<class _T>
	inline bool read(_T &num) {
		char c = nc(), f = 1; num = 0;
		while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
		while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
		return (bool)(num *= f);
	}
	inline bool need(char &c) { return c >= 'a'&&c <= 'z' || c >= '0'&&c <= '9' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
	inline bool read_str(char *a) {
		while ((*a = nc()) && need(*a) && rEOF)++a;
		*a = '\0'; return rEOF;
	}
}using namespace _;

int n;
long long a[100000+5];
long long b[100000 + 5];
int main()
{
	cin >> n;
	for (int i = 1; i <= n+1; i++)
		cin >> a[i];
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> b[i];
		if (a[i] <= b[i])
			ans += a[i], b[i] -= a[i], a[i] = 0;
		else
			ans += b[i], a[i]-=b[i],b[i] = 0;

		if (a[i+1] <= b[i])
			ans += a[i+1], b[i] -= a[i+1], a[i+1] = 0;
		else
			ans += b[i], a[i+1] -= b[i], b[i] = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

const int N = 1000001; 
  
int factorialNumInverse[N + 1]; 
int naturalNumInverse[N + 1]; 
int fact[N + 1]; 
  
void InverseofNumber(int p) 
{ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; 
} 
void InverseofFactorial(int p) 
{ 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
  
    for (int i = 2; i <= N; i++) 
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; 
} 
  
void factorial(int p) 
{ 
    fact[0] = 1; 

    for (int i = 1; i <= N; i++) 
    { 
        fact[i] = (fact[i - 1] * i) % p; 
    } 
} 
  
int Binomial(int N, int R, int p) 
{ 
    int ans = ((fact[N] * factorialNumInverse[R]) 
              % p * factorialNumInverse[N - R]) 
             % p; 
    return ans; 
}

//START OF CODE ->->->->->->->

void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    InverseofNumber(mod);
    InverseofFactorial(mod);
    factorial(mod);
    int b = Binomial(n*m-2,k-2,mod)%mod;
    int x = 0;
    rep(i,1,n){
        int coef = (n-i);
        coef %= mod;
        coef *= m;
        coef %= mod;
        coef *= m;
        coef %= mod;
        coef *= i;
        coef %= mod;
        x += coef;
        x %= mod;
    }
    int y = 0;
    rep(j,1,m){
        int coef = (m-j);
        coef %= mod;
        coef *= n;
        coef %= mod;
        coef *= n;
        coef %= mod;
        coef *= j;
        coef %= mod;
        y += coef;
        y %= mod;
    }

    cout<<(((x+y)%mod)*b)%mod<<endl;

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 27072