akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int a,b,i;
    scanf("%d%d",&a,&b);
    if (a>b) {
        for (i=1;i<=a;i++)
            printf("%d",b);
    }
    else if (a<=b) {
        for (i=1;i<=b;i++)
            printf("%d",a);
    }
    return 0;
}



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

int main() {
    int N; cin >> N;
    vector<long long> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];
    sort(L.begin(), L.end()); // L をソートしておく (二分探索に必要)

    long long res = 0;
    
    // a を固定して、(b, c) をしゃくとり法
    for (int i = 0; i < N; ++i) {
        int k = i;
        for (int j = i+1; j < N; ++j) {
            while (k < N && L[k] < L[i]+L[j]) ++k;
            res += k - (j+1);
        }   
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int res=0,t=0;
	for(int i=0;i<n;i++){
		int t_=0;
		while(a[i]>1){
			if(a[i]%2==1){
				int I=-1;
				for(int j=30;j>=0;j--) if(a[i]&1<<j){
					if(I!=-1) a[i]-=1<<j;
					else I=j;
				}
				if(t>I) t--;
				else t_++,res++;
			}
			else{
				a[i]/=2;
				if(t) t--;
				else res++;
				t_++;
			}
		}
		t=t_;
	}
	cout<<res<<endl;
}

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

class Main {

    public static void main( String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	String[] input = stdin.nextLine().split( "[, .]" );
	StringBuilder sb = new StringBuilder();
	
	for ( String str : input ) {
	    if ( 3 <= str.length() && str.length() <= 6 ) {
		sb.append( str );
		sb.append( " " );
	    }
	}
	System.out.println( sb.toString().trim() );	
    }
}

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

int N, H[100000];
int DP[100001];

int main(void){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> H[i];
    
    DP[0] = 0;
    
    for(int i=1;i<N;i++){
        if( 2 <= i )    DP[i] = min( DP[i-1] + abs(H[i-1] - H[i]), DP[i-2] + abs(H[i-2] - H[i]) );
        else            DP[i] = DP[i-1] + abs(H[i-1] - H[i]);
    }
    
    cout << DP[N-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,m,a,sum=0;
	vector<int>v;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
		sum+=a;
	}
	sort(v.begin(),v.end());
	cout<<n+(m-sum)/v[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

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

    int l[n];
    rep(i,n)cin>>l[i];

    int posi=0;
    int cou=1;
    int flag=0;
    rep(i,n){
        posi+=l[i];
        if(posi<=x){
            cou++;
        }
        else {
            break;
        }
        
    }
    cout<<cou<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int m;
    int d;

    scanf("%d %d", &m, &d);

    int cnt = 0;
    for(int i = 1; i <= m; i++) {
        for(int j = 10; j <= d; j++) {
            int oneRank = j % 10;
            int tenRank = j / 10;

            if(oneRank < 2 || tenRank < 2) {
                continue;
            }

            if(i == oneRank * tenRank) {
                cnt++;
            }
        }
    }

    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
n,k,q=map(int,input().split())
d = defaultdict(int)
for i in range(q):
        a = int(input())
        d[a]+=1
for i in range(1,n+1):
        if k-(q-d[i]) <=0:
                print("No")
        else:
                print("Yes")


Measured memory_bytes: 62552
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
#include<cstdint>
int64_t const MOD = 1e9+7;

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};
typedef mod_int<MOD> mint;

int main() {
  int N, K; std::cin >> N >> K;
  int L = std::min(N/100, 31630);
  while(L*L <= N) ++L;
  std::vector<mint> dp1(L+1), dp2(L+1);
  std::fill_n(dp1.begin()+1, std::min(L, N), mint(1));
  std::fill_n(dp2.begin()+1, L, mint(1));
  
  mint sum; 
  while(K--) {
    std::swap(dp1, dp2);
    // sum up previous dp1[] to current dp2[]
    for(int i = 1; i <= L; ++i) dp2[i] += dp2[i-1];
    //
    sum = dp2[N/(L+1)];
    // sum up previous dp2[] to current dp1[]
    for(int i = L; i > 0; --i) {
      sum += dp1[i]*mint(N/i - N/(i+1));
      dp1[i] = sum;
    }
  }
  fin(sum.v_);
  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main() {
    int d, n; cin >> d >> n;
    
    int ans;
    if (n < 100) ans = n;
    else ans = 101;
    ans *= pow(100, d);

    out(ans);

    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T> T iabs(const T& x) { return max(x, -x); }

int n;
int t[102], v[102], a[40001];
int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> t[i];
        t[i] *= 2;
        t[i] += t[i - 1];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        v[i] *= 2;
    }
    t[n + 1] = t[n];
    for (int i = 0; i <= t[n]; ++i) {
        a[i] = 1 << 30;
    }
    for (int i = 0; i <= n + 1; ++i) {
        if (i > 0) {
            for (int j = t[i - 1], u = v[i]; j >= 0; --j, ++u) {
                a[j] = min(a[j], u);
            }
            for (int j = t[i - 1]; j <= t[i]; ++j) {
                a[j] = min(a[j], v[i]);
            }
        }
        if (i <= n) {
            for (int j = t[i], u = v[i]; j <= t[n]; ++j, ++u) {
                a[j] = min(a[j], u);
            }
        }
    }
    double ans = 0;
    for (int i = 0; i < t[n]; ++i) {
        // cerr << i << ' ' << a[i] << endl;
        ans += (a[i] + a[i + 1]) / 2.0;
    }
    ans /= 4;
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String s1 = sc.next();
        String s2 = sc.next();
        String[] s2List = s2.split("");
        String ans = "A" + s2List[0] + "C";
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
#include<iostream>

int main(){

    int a, b;
    std::cin >> a >> b;

    if(a > b){
        std::cout << "a > b" << std::endl;
    }else if(a == b){
        std::cout << "a == b" << std::endl;
    }else{
        std::cout << "a < b" << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3112
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static long comb(int n, int r) {
		if(n < r)return 0;
		if(n == r)return 1;
		long ans = 1;
		for(int i = 1; i <= r; ++i) {
			ans *= (n - i + 1);
			ans /= i;
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; ++i)
			a[i] = sc.nextInt();
		sc.close();
		int ans[] = new int[n + 1];
		ans[0] = a[0] % m;
		for(int i = 1; i < n; ++i) {
			ans[i] = ans[i - 1];
			ans[i] += a[i] % m;
			ans[i] %= m;
		}
		ans[n] = m;
		Arrays.sort(ans);
		long ans2 = 0;
		int t = ans[0];
		int cnt = 0;
		for(int i = 0; i <= n; ++i) {
			if(ans[i] == t)++cnt;
			else {
				if(t == 0)ans2 += cnt;
				ans2 += comb(cnt, 2);
				cnt = 1;
				t = ans[i];
			}
		}
		System.out.println(ans2);
	}

}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 100005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct edge {
    int to, cost;
    edge(int to, int cost) : to(to), cost(cost) {}
};

vector<edge> G[MAX];
vector<bool> first;

ll dp[MAX];
bool dfs(int v) {
    bool res = true;
    for (edge e : G[v]) {
        int u = e.to, d = e.cost;
        if (dp[u] < 0) {
            dp[u] = dp[v] + d;
            res &= dfs(u);
        } else {
            if (dp[u] != dp[v] + d) return false;
        }
    }
    return res;
}

//頂点の入次数を管理
int h[100010];

int main(){
    int N, M;
    cin >> N >> M;

    first.resize(N, true);

    rep(i, M) {
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;
        G[l].emplace_back(r, d);
        h[r]++;
        first[r] = false;
    }

    stack<int> st;
    rep(i, N) if (h[i] == 0) st.emplace(i);

    vector<int> res;
    while (st.size()) {
        int i = st.top(); st.pop();
        res.push_back(i);
        for (edge e : G[i]) {
            int u = e.to;
            h[u]--;
            if (h[u] == 0) st.push(u);
        }
    }

    if (res.size() != N) {
        cout << "No" << endl;
        return 0;
    }

    bool ans = true;
    rep(i, N) dp[i] = -1;

    rep(i, N) {
        if (first[i] && dp[i] < 0) {
            dp[i] = 0;
            ans &= dfs(i);
        }
        if (!ans) break;
    }

    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 12152
a = input()
b = input()
c = input()

turn = "a"

while True:
    if turn == "a":
        if a =="":break
        turn = a[0]
        a = a[1:]
    if turn == "b":
        if b =="":break
        turn = b[0]
        b = b[1:]
    if turn == "c":
        if c =="":break
        turn = c[0]
        c = c[1:]

turn = turn.upper()
print(turn)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
ll A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z;
void RemainderReminder() {
	cin >> N >> K;
	ll r = N - K;
	ll count = 0;
	for (ll i = (K + 1); i <= N; i++)
	{
		
		ll rem = i - K;

		ll cache = (N / i) * rem;
		ll rr = N - (N / i) * i;
		cache += max(0LL,rr - max(K - 1,0LL));
		count += cache;
	}
	cout << count << endl;
}
int main() {
	RemainderReminder();
	return 0;
}

Measured memory_bytes: 256
// oh, the less I know the better
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define endl '\n'
#define fst first
#define snd second
#define pb push_back
#define sz(x) int(x.size())
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 2e5+20;
const ll INF = 1e18;

struct STree{ // example: range sum with range addition
	vector<ll> st,lazy;int n;
	STree(int n): st(4*n+5,0), lazy(4*n+5,0), n(n) {}
	void push(int k, int s, int e){
		if(!lazy[k])return; // if neutral, nothing to do
		st[k]+=lazy[k]; // update st according to lazy
		if(s+1<e){ // propagate to children
			lazy[2*k]+=lazy[k];
			lazy[2*k+1]+=lazy[k];
		}
		lazy[k]=0; // clear node lazy
	}
	void upd(int k, int s, int e, int a, int b, ll v){
		push(k,s,e);
		if(s>=b||e<=a)return;
		if(s>=a&&e<=b){
			lazy[k]+=v; // accumulate lazy
			push(k,s,e);return;
		}
		int m=(s+e)/2;
		upd(2*k,s,m,a,b,v);upd(2*k+1,m,e,a,b,v);
		st[k]=min(st[2*k],st[2*k+1]); // operation
	}
	ll query(int k, int s, int e, int a, int b){
		if(s>=b||e<=a)return INF; // operation neutral
		push(k,s,e);
		if(s>=a&&e<=b)return st[k];
		int m=(s+e)/2;
		return min(query(2*k,s,m,a,b),query(2*k+1,m,e,a,b)); // operation
	}
	void upd(int a, int b, ll v){upd(1,0,n,a,b,v);}
	ll query(int a, int b){return query(1,0,n,a,b);}
};  // usage: STree rmq(n);rmq.init(x);rmq.upd(s,e,v);rmq.query(s,e);

vector<ii> intv[N];

int main(){

	fastio;
	int n,m;
	cin >> n >> m;
	ll ans = 0;
	for(int i = 0; i < m; ++i){
		int l,r,a;
		cin >> l >> r >> a;
		ans += a;
		intv[r].pb(ii(l,a));
	}

	ll res = INF;
	STree st(n+5);
	for(int i = 1; i <= n+1; ++i){
		for(auto par : intv[i-1]){
			int l = par.fst, val = par.snd;
			st.upd(0,l,val);
		}
		st.upd(i,i+1,st.query(0,i));
	}
	res = st.query(0,n+1);
	cout << ans-res << endl;

	return 0;
}


Measured memory_bytes: 26624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Ti4 tuple<int, int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n, m;
    while (cin >> n >> m) {
        if (n == 0) return 0;
        int p[1000] = {}, q[1000] = {}, s = 0, t = 0;
        for (int i = 0; i < n; i++) {
            int k;  cin >> k;
            s += k;  p[k] = 1;
        }
        for (int i = 0; i < m; i++) {
            int k;  cin >> k;
            t += k;  q[k] = 1;
        }
        bool get = 0;
        for (int i = 0; i <= 100 && !get; i++) {
            if (s%2 == t%2 && p[i] && 
            i - (s - t) / 2 >= 0 && q[i - (s - t) / 2]) {
                cout << i _ i - (s - t) / 2 << endl;
                get = 1;
                break;
            }
        }
        if (!get) cout << -1 << endl;

    }
}



Measured memory_bytes: 3096
import sys


def slove():
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    six_l = []
    for i in range(1, 7):
        six_l.append(pow(6, i))
    nine_l = []
    for i in range(1, 6):
        nine_l.append(pow(9, i))

    m_cnt = 10 ** 10
    for i in range(n // 6 + 1):
        t = n
        six = i
        t -= (6 * six)
        nine = t // 9
        t -= (nine * 9)
        cnt = t
        for j in range(len(six_l)):
            if six // six_l[-j-1] > 0:
                cnt += (six // six_l[-j-1])
                six %= six_l[-j-1]
        cnt += six
        for j in range(len(nine_l)):
            if nine // nine_l[-j-1] > 0:
                cnt += (nine // nine_l[-j-1])
                nine %= nine_l[-j-1]
        cnt += nine
        m_cnt = min(m_cnt, cnt)
    print(m_cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40816
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemC solver = new ProblemC();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int k = in.nextInt();
			int p = -1;
			for (int i = 0; i < n; i++) {
				int x = in.nextInt();
				if (x == 1) {
					p = i;
				}
			}
			int ans = n;
			for (int i = 0; i < n; i++) {
				if (p >= i && p <= i + k - 1) {
					int cur = 1;
					int l = i;
					int r = Math.max(0, n - i - k);
					cur += (l + k - 2) / (k - 1);
					cur += (r + k - 2) / (k - 1);
					ans = Math.min(ans, cur);
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 33860
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	unsigned long long a,b,x;
  	unsigned long long mam,mim;
  	cin>>a>>b>>x;
  	if(a%x!=0)mim=(a+x)/x;
  	else mim=a/x;
  	mam=b/x;
	cout<<mam-mim+1<<endl;
}

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

int count(int arr[], int n) {
	int c = 0;
	for (int i = 0; i < 3; i++) {
		if (arr[i] == n) c += 1;
	}
	return c;
}

int main() {
	int abc[3];
	cin >> abc[0] >> abc[1] >> abc[2];
	if (count(abc, 5) == 2 && count(abc, 7) == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3552
import collections

n = int(input())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
a_t = collections.Counter(sorted(a_t))
ans = 0
for i in a_t.values():
    ans += i * (i - 1) // 2
print(ans)


Measured memory_bytes: 43244
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <string.h>


typedef struct dice
{
	int label[6];
	int direction[6]; // 転がしたときに対応するラベル

}Dice;



void diceRotation(Dice *dice, char order) {
	int tmpDirc[6] = { 0 };
	for (size_t i = 0; i < 6; i++)
	{
		tmpDirc[i] = dice->direction[i];
	}

	if (order == 'S') {
		dice->direction[0] = tmpDirc[4];
		dice->direction[1] = tmpDirc[0];
		dice->direction[4] = tmpDirc[5];
		dice->direction[5] = tmpDirc[1];
	}
	else if (order == 'N') {
		dice->direction[0] = tmpDirc[1];
		dice->direction[1] = tmpDirc[5];
		dice->direction[4] = tmpDirc[0];
		dice->direction[5] = tmpDirc[4];
	}
	else if (order == 'W') {
		dice->direction[0] = tmpDirc[2];
		dice->direction[2] = tmpDirc[5];
		dice->direction[3] = tmpDirc[0];
		dice->direction[5] = tmpDirc[3];

	}
	else if (order == 'E') {
		dice->direction[0] = tmpDirc[3];
		dice->direction[2] = tmpDirc[0];
		dice->direction[3] = tmpDirc[5];
		dice->direction[5] = tmpDirc[2];
	}
}


// if dice1 and dice2 are same, return 1
// else return 0
int is_sameDice(Dice dice1, Dice dice2) {
	
	char order1[30] = "SSSSWSSSSWSSSSWSSSS";
	char order2[10] = "EEE";
	int top, front;

	
	int frontNum = 0;
	do {
		top = dice2.label[dice2.direction[0]];
		front = dice2.label[dice2.direction[frontNum++]];
		
	} while (top == front && frontNum < 6);

	if (top == front) { // dice2のすべての数字が同じ！
		int otameshi_i = 0;
		for (; otameshi_i < 5; otameshi_i++) {
			if (dice1.label[otameshi_i] != dice1.label[otameshi_i + 1]) {
				return 0;
			}
		}
		if (dice1.label[1] == dice2.label[1]) {
			return 1;
		}
		else {
			return 0;
		}
	}

	int orderlen = strlen(order1);
	int i = 0;
	for (i =0; i < orderlen; i++) {
		if (dice1.label[dice1.direction[frontNum-1]] == front) {
			break;
		}
		diceRotation(&dice1, order1[i]);
	}


	orderlen = strlen(order2);
	for (i = 0; i < orderlen; i++) {
		if (dice1.label[dice1.direction[0]] == top) {
			break;
		}
		diceRotation(&dice1, order2[i]);
	}


	// 同一のサイコロならば、ここまでで方向がそろう

	int sameFlag = 1;

	for (size_t i = 0; i < 6; i++)
	{
		if (dice1.label[dice1.direction[i]] != dice2.label[dice2.direction[i]]) {
			sameFlag = 0;
			break;
		}
	}

	return sameFlag;
}

/////////////////////////////////////////////////////////////////////////


int main(void) {

	//int result[1001] = { 0 };



	int n = 6;

	Dice dice[101] = { 0 };

	int init = 0;


	int allDice_i = 0;
	for (; allDice_i < 101; allDice_i++) {
		for (init =0; init < n; init++) {
			dice[allDice_i].label[init] = 0;
			dice[allDice_i].direction[init] = init;

		}
	}
	


	int q = 0;
	scanf("%d", &q);
	for (size_t i = 0; i < q; i++)
	{
		scanf("%d %d %d %d %d %d", &dice[i].label[0], &dice[i].label[1], &dice[i].label[2], &dice[i].label[3], &dice[i].label[4], &dice[i].label[5]);
	}
	

	int sameFlag = 0;

	for (size_t j = 0; j < q; j++)
	{
		for (size_t k = j; k < q; k++)
		{
			if (k == j) {
				continue;
			}
			if (is_sameDice(dice[j], dice[k]) == 1) {
				sameFlag = 1;
				break;
			}
		}
		if (sameFlag == 1) {
			break;
		}
	}

	if (sameFlag == 1) {
		puts("No");
	}
	else {
		puts("Yes");
	}

	
	

	return 0;
}



Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int n;
    cin>>n;
    ll sum = 0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        sum += i;

    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3612
MAX = 2 ** 31

def solve(h, w, o, used)
  minimum = MAX
  ro = o - 1
  return minimum if w < 0 or w > $wl
  return 0 if h == ($hl+1) and ro >= 0
  return minimum if ro <= 0
  $memo[h] ||= {}
  $memo[h][w] = {} unless $memo[h].key? w
  $memo[h][w][o] = {} unless $memo[h][w].key? o
  return $memo[h][w][o][used] if $memo[h][w][o].key? used
  if ((used >> w) & 1) == 1 then
    # ??\????????¨????????????????????´???
    minimum = [solve(h+1, w,   ro, 0), minimum].min
    minimum = [solve(h,   w-1, ro, used), minimum].min
    minimum = [solve(h,   w+1, ro, used), minimum].min
  elsif ((used >> w) & 1) == 0 then
    # ??\????????¨????????????????????´???
    used_new = used | (1 << w)
    if $field[h][w] < 0 then
      # ????????????????????´???
      minimum = [solve(h+1, w, ro, 0) - $field[h][w], minimum].min
      minimum = [solve(h,   w-1, ro, used_new) - $field[h][w], minimum].min
      minimum = [solve(h,   w+1, ro, used_new) - $field[h][w], minimum].min
    else
      # ????????????????´??????´???
      oxy = ((ro+$field[h][w]) > $ml) ? $ml : (ro+$field[h][w])
      minimum = [solve(h+1, w,   oxy, 0), minimum].min
      minimum = [solve(h,   w-1, oxy, used_new), minimum].min
      minimum = [solve(h,   w+1, oxy, used_new), minimum].min
    end
  end
  # p "h:#{h}, w:#{w}, o:#{o}, used:#{used}, min:#{minimum}"
  return $memo[h][w][o][used] = minimum
end

def gets_ints
  gets.split(" ").map(&:to_i)
end

loop do
  $memo = {}
  $wl, $hl = gets_ints
  break if $wl == 0 and $hl == 0
  $hl -= 1
  $wl -= 1
  $fl, $ml, $ol = gets_ints
  $field = (0..$hl).map { gets_ints }
  ans = (0..$wl).map do |w|
    solve(0, w, $ol, 0)
  end.min
  puts ans > $fl ? 'NA' : ans
end

Measured memory_bytes: 21636
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



int main() {
    ll n, x;
    cin >> n >> x;
    
    ll ans = 0;
    vector<ll> a(n), b(n);
    REP(i, n){
        cin >> a[i];
        b[i] = a[i];
        ans += a[i];
    }
    
    for(int i = 1; i < n; i++){
        ll sum = i * x;
        REP(j, n){
            b[j] = min(b[j], a[(j - i + n) % n]);
            sum += b[j];
        }
        
        ans = min(ans, sum);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 384
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [a, b, c, d, e, f] <- getIntList

  arr <- IO.newArray ((0,0),(30,3000)) False :: IO (IO.IOUArray (Int,Int) Bool)

  let dfs :: Int -> Int -> IO ()
      dfs w s
        | w * 100 + s > f = return () -- total amount check here.
        | otherwise = do
        t <- IO.readArray arr (w, s)
        IO.writeArray arr (w, s) True
        if t
          then return ()
          else do let w_amount = w * 100
                      total_amount = w_amount + s
                  dfs (w+a) s
                  dfs (w+b) s
                  when (s + c <= e * w) $ dfs w (s+c)
                  when (s + d <= e * w) $ dfs w (s+d)

  dfs 0 0

  let searchMax :: Int -> Int -> Int -> Int -> Int -> IO (Int, Int)
      searchMax w s d mw ms | w > 30 = return (mw, ms)
                            | s > 3000 = searchMax (w+1) 0 d mw ms
                            | otherwise = do
                                let dense | w == 0 = -1
                                          | otherwise = 10000 * s `div` (100 * w + s)
                                    mw' | dense > d = w
                                        | otherwise = mw
                                    ms' | dense > d = s
                                        | otherwise = ms
                                    d' = max d dense
                                t <- IO.readArray arr (w, s)
                                if t
                                  then searchMax w (s+1) d' mw' ms'
                                  else searchMax w (s+1) d  mw  ms

  (w, s) <- searchMax 0 0 (-1) 0 0

  putStrLn $ show (100*w+s) ++ " " ++ show s


Measured memory_bytes: 6044
N, K = gets.split.map(&:to_i)
MOD = 10**9 + 7

dp = Array.new(N + 1){Array.new(N + 1){Array.new(K + 2*N + 1, 0)}}
dp[0][0][0] = 1
(0 ... N).each do |i|
  (0 .. N).each do |j|
    (0 .. K).each do |k|
      next if (d = dp[i][j][k]) == 0
      l = k + 2*j
      dp[i + 1][j][l] = (dp[i + 1][j][l] + (2*j + 1)*d) % MOD
      dp[i + 1][j - 1][l] = (dp[i + 1][j - 1][l] + j*j*d) % MOD if j > 0
      dp[i + 1][j + 1][l] = (dp[i + 1][j + 1][l] + d) % MOD
    end
  end
end
puts  dp[N][0][K]

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

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    if (a1 + a2 + a3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}

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

int main() {
  string S,ans;
  cin >>S;
  if (S.at(5)=='1') ans="TBD";
  else if (S.at(6)=='5' ||S.at(6)=='6'||S.at(6)=='7'||S.at(6)=='8'||S.at(6)=='9') ans="TBD";
  
  else ans="Heisei";
  cout<< ans << endl;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            int[] res = {-1, -1, -1}; // 10000, 5000, 1000
            int n = sc.nextInt();
            int target = sc.nextInt();
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n - i; j++) {
                    int k = n - i - j;
                    int total = 10000 * i + 5000 * j + 1000 * k;
                    if (total == target) {
                        res[0] = i;
                        res[1] = j;
                        res[2] = k;
                    }
                }
            }
            System.out.println(String.format("%d %d %d", res[0], res[1], res[2]));
        }
    }
}

Measured memory_bytes: 23124
n,m = map(int,input().split())
if abs(n-m)>1:
  print(0)
else:
  ans = 1+(n==m)
  for i in range(1,n+1):
    ans *= i
    ans = ans%(10**9+7)
  for j in range(1,m+1):
    ans *= j
    ans = ans%(10**9+7)
  print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	ll k;
	cin >> k;

	bool b = true;
	char ans;
	for (int i = 0;i < k;i++) {
		if (s[i] != '1') {
			ans = s[i];
			b = false;
			break;
		}
	}
	if (b) {
		cout << 1 << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];

bool so(int n){
    if(n==1) return false;
    if(n==2) return true;
    bool ok = true;
    for(int i = 2;i*i<=n;++i){
        if(n%i==0) return  false;
    }
    return  true;
}
int main(){
    int q;
    cin >> q;
    vector<int> ans(100100);
    vector<int> cnt(100100,0);
    for(int i = 1;i<=100010;i++){
        if(so(i)) ans[i]++;
    }
    for(int i = 1;i<=100010;i+=2){
        if(ans[i]&&ans[(i+1)/2])cnt[i]++;
    }
    vector<int> s(100100);
    s[1]=cnt[1];
    for(int i = 1;i<=100010;++i){
        s[i+1] = cnt[i+1]+s[i];
    }
    rep(i,q){
        int l ,r;
        cin >> l >> r;
        cout << s[r]-s[l-1] <<endl;
    }

}


Measured memory_bytes: 4572
/* ***********************************************
Author        :yang12138
Created Time  :2018/4/28 20:17:45
File Name     :B.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;

const int N=305;
char s[N][N],tmp[N][N];

void solve(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%s",s[i]);

	int ans=0;
	for(int k=0;k<n;k++){
		bool flag=1;

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				tmp[i][j]=s[i][(j+k)%n];
			}
		}
		for(int i=0;i<n && flag;i++){
			for(int j=0;j<n && flag;j++){
				if(tmp[i][j]!=tmp[j][i]) flag=0;
			}
		}

		if(flag) ans+=n;
	}
	printf("%d\n",ans);
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	solve();
    
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

ll po(ll x, ll y) {
    ll ans = 1;
    while(y > 0) {
        if(y % 2) (ans *= x) %= MOD;
        (x *= x) %= MOD;
        y >>= 1;
    }
    return ans;
}

ll comb(ll n, ll r) {
    ll x = 1, y = 1;
    rep(i, r) (x *= n - i) %= MOD;
    rep(i, r) (y *= i + 1) %= MOD;
    y = po(y, MOD - 2);
    return x * y % MOD;
}

int main(void) {
    ll X, Y;
    cin >> X >> Y;
    ll m = (2 * X - Y) / 3;
    ll n = X - 2 * m;
    if((X + Y) % 3 || n < 0 || m < 0) {
        cout << 0 << endl;
    } else {
        cout << comb(m + n, m) << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/



signed main() {
	int a, b;
	cin >> a >> b;
	if (a >= 10 || b >= 10)cout << -1 << endl;
	else cout << a * b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int a, p;
    cin >> a >> p;
    int piece;
    piece = a*3+p;
    out(piece/2);
}

Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

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

    int ans = 1;
    int min = a[0];
    for(int i = 1; i <n; ++i) {
        if(min > a[i]) {
            min = a[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N,L = map(int,input().split())
aji1 = [L+i-1 for i in range(1,N+1)]
aji = [abs(L+i-1) for i in range(1,N+1)]
#print(aji)
minaji = max(aji1)
no = 0
for i in range(N):
    if aji[i] < minaji:
        no = i + 1
        minaji = aji[i]
aji1[no-1] = 0
print(sum(aji1))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define parr[1] push_back
#define pii pair<int,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)

const double pi = acos(-1.0);
const int maxn = (i64)2e5+5;

int main()
{
    //freopen("input.txt","r",stdin);
    int n,k;
    cin >> n >> k;
    int cnt = 0;
    while(n)
    {
        n = n/k;
        cnt++;
    }
    cout<<cnt;



return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include<math.h>
#define ll long long
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int main(){
    int N;
    cin >> N;
    if(N % 1000 == 0) cout << 0 << endl;
    else{
        int a,b,c;
        c = N % 10;
        N = N / 10;
        b = N % 10;
        N = N / 10;
        a = N % 10;
        cout << 1000 - 100*a - 10*b - c << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N,A,B;
  cin>>N>>A>>B;
  if(A<=N&&B<=N){
  if(A<B){
    cout<<A<<endl;
      if(A+B<N){
    cout<<0<<endl;
  }else{
    cout<<(A+B)-N<<endl;
  }
  }else if((A+B)==(N/2)){
    cout<<A<<endl;
    cout<<B<<endl;
  }else{
    cout<<B<<endl;
      if(A+B<N){
    cout<<0<<endl;
  }else{
    cout<<(A+B)-N<<endl;
  }
  }
  }else{
    cout<<0<<endl;
    cout<<0<<endl;
  }
}

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

#define rep(i, a, n) for(int i = (a);i < (n);i++)
#define REP(i, n)    rep(i, 0, n)
#define all(e)       (e).begin(), (e).end()

#ifdef LOCAL
#define show(x) cerr<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#else
#define show(x) true
#endif

using namespace std;
using ll=long long;
template<class T> using V=vector<T>;

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = (1 << 30) - 1;
const ll INFL = (ll) 5e15;
const int MOD = 1e9 + 7;

class Solver {
public:
    bool solve() {
        cin >> N >> M;
        if (N == 0) return false;
        R.resize(N);
        REP(i, N) {
            int x, y;
            cin >> R[i].second >> R[i].first;
        }
        sort(R.rbegin(), R.rend());
        for (auto e:R) {
            if (e.second <= M) {
                M -= e.second;
            } else {
                ans += e.first * (e.second - M);
                M = 0;
            }
        }

        cout << ans << endl;

        return true;
    }

private:
    int N, M;
    V<pair<int, int>> R;
    int ans = 0;
};

int main() {
    while (Solver().solve());

    return 0;
}



Measured memory_bytes: 3156
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e5+5;
int32_t main(){
    FastIO;
    string s1, s2;
    cin >> s1 >> s2;
    int n, m;
    n = s1.size(), m = s2.size();
    vc < vc <ll> > dp(n+1, vc <ll> (m+1, 0));
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            if (s1[i-1] == s2[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    if (dp[n][m] == 0) cout << "" << endl;
    else {
        string ans;
        int i=n, j=m;
        while(i>0 && j>0) {
            // whatis(i);
            // whatis(j);
            if (s1[i-1] == s2[j-1]) {
                ans += s1[i-1];
                i--;
                j--;
            }
            else if (dp[i-1][j] > dp[i][j-1]) i--;
            else j--;
        }
        reverse(all(ans));
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int n, line[100001];

int main()
{
    cin >> n;

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

    long long ans = line[0]-1;
    line[0] = 1;

    int max = 1;
    for (int i = 1; i < n; i++) {
        if (line[i] > max+1) {
//            cout << (line[i]-1)/(max+1) << " ";
            ans += (line[i]-1)/(max+1);
        } else if (line[i] == max+1) {
            max++;
 //           cout << "\n >> " <<  i << " " << max << " " << endl;
        }
    }

    cout << ans << endl;

    return 0;
}







Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

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

    int x;
    cin >> x;
    cout << (x^1) << endl;
}


Measured memory_bytes: 3652
bool[][] g;
bool[] visited;
int N;

int dfs(int v) {
	bool all_visited = true;

	foreach(i; visited) if(!i) all_visited = false;
	if(all_visited) return 1;

	int res;
	foreach(i; 0..N) {
		if(!g[v][i]) continue; // つながってないです
		if(visited[i]) continue; // もう通ったよ？？通れませんが？？

		visited[i] = true; // 通ってみよう
		res += dfs(i); // 次はどっちかな
		visited[i] = false; // 〜ここを通らない世界線を夢見て〜
	}

	return res;
}
void main() {
	auto ip = readAs!(int[]), M = ip[1];
	N = ip[0];
	g = new bool[][](N, N);
	visited = new bool[](N);
	foreach(i; 0..M) {
		auto ip2 = readAs!(int[]), a = ip2[0], b = ip2[1];
		g[a-1][b-1] = g[b-1][a-1] = true;
	}
	visited[0] = true;
	dfs(0).writeln; // 頂点1が始点です
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256