akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n;
    cin >> n;
    int ans = (n/2) * (n-n/2);
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    ll n, tv = 1, av = 1, tmp; scll(n);
    vector<int> t(n), a(n);
    rep(i, 0, n) sc(t[i]), sc(a[i]);
    rep(i, 0, n){
        tmp = max(tv/t[i]+(tv%t[i]!=0), av/a[i]+(av%a[i]!=0));
        tv = t[i]*tmp, av = a[i]*tmp;
    }
    cout << tv + av << endl;
    return 0;
}

Measured memory_bytes: 256
// Created by abhay
#include <bits/stdc++.h>
#define sz(a) 			int((a).size())
#define pb 				push_back
#define all(c) 			c.begin(),c.end()
#define tr(c,i) 		for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 	(c.find(x) != c.end())
#define cpresent(c,x) 	(find(allc,x) != c.end())
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define int 		 	long long
#define w(tc)           int tc; cin>>tc; while(tc--)
#define ff              first
#define se              second
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define ne              "\n"

using namespace std;

int32_t main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	if (s == "ARC")
	{cout << "ABC";}
	else
		cout << "ARC";
}


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

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

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

/* -----  2018/02/23  Problem: 002_agc_b / Link: https://agc002.contest.atcoder.jp/tasks/agc002_b?lang=en  ----- */
/* ------問題------

N 個の箱があります。 箱は 1 から N まで番号が振られています。 最初、1 番目の箱には赤いボールが 1 個入っています。 また、2～N 番目の箱には白いボールが 1 個ずつ入っています。
高橋君は M 回の操作を順に行います。 i 回目の操作では、xi 番目の箱から適当なボールを 1 個選び、それを yi 番目の箱へ移します。
高橋君がすべての操作を終えた後、赤いボールが入っている可能性のある箱は何個か求めてください。

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

赤を最後に残すような感じで赤を伝搬する。
これを実際にシュミレーションすれば良い。

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

LL N, M;

LL ans = 0LL;

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

	cin >> N >> M;
	VI red(N, 0);
	red[0] = 1;
	VI ball(N, 1);
	FOR(i, 0, M) {
		int a, b; cin >> a >> b; a--, b--;
		if (red[a]) {
			if (ball[a] == 1) {
				ans--;
				red[a] = 0;
			}
			if (red[b] == 0)ans++;
			red[b] = 1;
		}
		ball[a]--;
		ball[b]++;
	}
	cout << ans + 1 << "\n";

	return 0;
}


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

minsum = 900000

for i in range(n - 1):
    count = 0
    a = i +1
    b = n -i -1
    for c in str(a):
        count += int(c)
    for c in str(b):
        count += int(c)
    if count < minsum:
        minsum = count
print(minsum)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	long long ans1 = 0, cnt1 = 0, ans2 = 0, cnt2 = 0;
	for (int i = 0; i < n; i++) {
		long long k; cin >> k;
		cnt1 += k; cnt2 += k;
		if (i % 2 == 0) {
			if (cnt1 <= 0) {
				ans1 += 1 - cnt1;
				cnt1 = 1;
			}
			if (cnt2 >= 0) {
				ans2 += 1 + cnt2;
				cnt2 = -1;
			}
		}
		else {
			if (cnt1 >= 0) {
				ans1 += 1 + cnt1;
				cnt1 = -1;
			}
			if (cnt2 <= 0) {
				ans2 += 1 - cnt2;
				cnt2 = 1;
			}
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct item
{
    int wt;
    int val;
};
ll solve(vector<item> ar,int n,int W)
{
    ll dp[n+1][W+1];
    for(int w=0;w<=W;w++)
        dp[1][w]=0;
    
    dp[1][ar[1].wt]=ar[1].val;
    for(int i=2;i<=n;i++)
    {
        for(int w=0;w<=W;w++)
        {
            dp[i][w]=dp[i-1][w];
            if(ar[i].wt>w)
            {
                continue;
            }
            dp[i][w]=max(dp[i][w],ar[i].val+dp[i-1][w-ar[i].wt]);
        }
    }
    return *max_element(dp[n],dp[n]+W+1);
}
int main() {
    int n,W;
    cin>>n>>W;
    vector<item> ar(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i].wt>>ar[i].val;
    }
    cout<<solve(ar,n,W);
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h;
    const ll w = 5;
    while (cin >> h, h) {
        vector<vector<ll>> m(h, vector<ll>(w)); cin >> m;
        reverse(all(m));
        ll ans = 0;
        function<ll(ll,ll,ll,ll)> chain = [&](ll x, ll y, ll k, ll cnt) {
            if (k < 0 || x >= w || m[y][x] != k) return cnt;
            ll c = chain(x+1, y, k, cnt+1);
            if (c >= 3) {
                ans += m[y][x];
                m[y][x] = -1;
            }
            return c;
        };
        auto fall = [&]() {
            rep(y, h-1) rep(x, w) {
                if (m[y][x] < 0) {
                    m[y][x] = m[y+1][x];
                    m[y+1][x] = -1;
                }
            }
        };
        while (true) {
            bool is_updated = false;
            rep(y, h) rep(x, w) {
                if (chain(x, y, m[y][x], 0) >= 3) {
                    is_updated = true;
                }
            }
            if (!is_updated) break;
            rep(i, h) fall();
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3108
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**7)

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, m = na()
memo = [-1] * n
def dp(v):
    if memo[v] != -1:
        return memo[v]
    if G[v]:
        memo[v] = max(dp(i) for i in G[v]) + 1
    else:
        memo[v] = 0
    return memo[v]


G = [[] for _ in range(n)]
for _ in range(m):
    f, t = na()
    G[f-1].append(t-1)
print(max([dp(i) for i in range(n)]))


Measured memory_bytes: 110384
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
#define ll long long int
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
#define eps 10e-6
#define mod 1000000007
ll a[100001];
int main(void){
	string s1, s2;
	string ans = "";
	cin >> s1 >> s2;
	rep(i,s1.size()){
		ans += s1[i];
		if(s2.size() != i)ans += s2[i];
	}
	cout << ans << endl;
}


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

using namespace std;

int main(){
    int N;
    string S;
    cin >> N;
     vector<int>A(N);
    int ans = 1e9;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        int tmp = 0;
        while(A[i] % 2 == 0){
            A[i] /= 2;
            tmp++;
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
ans = "YES"
while len(s) > 0:
    if s[-5:] == "dream":
        s = s[:-5]
    elif s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    else:
        ans = "NO"
        break
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 7;
const int mod = 1e9 + 7;
typedef long long ll;
int n, m, k;

int ar[maxn];

ll dp[12][12];
ll dpz[12];
ll che(ll x){
    ll mid = x;
    vector<int> dig;
    while(x > 0){
        dig.push_back(x % 10);
        x /= 10;
    }
    if(dig.size() == 1)return mid;
    reverse(dig.begin(), dig.end());
    ll ans = dpz[dig.size()];
    //if(mid >= 200 && mid <= 201)cout << "debug nas = " << ans << '\n';
    int pre = -1;
    for(int i=0;i<dig.size();i++){
        int x = dig[i];
        if(pre == -1){
            for(int j=1;j<x;j++)ans += dp[dig.size()][j];
            /*
               ans += dp[dig.size() - i][1] * (x - 1);
               if(i == dig.size() - 1){
               if(x == 9)ans += dp[dig.size() - i][2];
               else ans += dp[1][1];
               }
               */
        }
        else{
            for(int j = -1; j <= 1; j++){
                int nx = pre + j;
                if(nx >= 0 && nx <= 9 && nx < x){
                    ans += dp[dig.size() - i][nx];
                    /*
                       if(nx == 0)ans += dp[dig.size() - i][0];
                       else if(nx == 9)ans += dp[dig.size() - i][2];
                       else ans += dp[dig.size() - i][1];
                       */
                }
                else if(nx >= 0 && nx <= 9 && nx == x && i == dig.size() - 1){
                    ans++;
                    //if(mid >= 200 && mid <= 201)
                }
            }
        }
        if(pre != -1 && abs(pre - x) > 1)break;
        pre = x;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    for(int i=0;i<12;i++)dp[1][i] = 1;
    dpz[1] = 0;
    for(int pos = 2; pos < 12; pos++){
        dpz[pos] = dpz[pos - 1];
        for(int j=0;j<=9;j++){
            for(int k=-1;k<=1;k++){
                int nx = j + k;
                if(nx >= 0 && nx <= 9)dp[pos][j] += dp[pos-1][nx];
            }
            if(j > 0)dpz[pos] += dp[pos-1][j];
        }
    }
    //for(int i=1;i<=10;i++)cout << i << ' ' << che(i) << '\n';
    int n;
    cin >> n;
    ll l = 1, r = 3234566699;
    while(l < r){
        ll mid = (l + r) / 2;
        if(che(mid) >= n)r = mid;
        else l = mid + 1;
    }
    cout << l << "\n";
    return 0;
}

/*
hate number dp
*/


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second



int main(){
    ll n,k;
    cin >> n >> k;
    ll p[n]= {};
    rep(i,0,n) cin >> p[i];

    sort(p,p+n);
    ll ans = 0;
    rep(i,0,k){
        ans += p[i];
    }
    cout << ans << endl;
}




Measured memory_bytes: 3656
#include<iostream>
using namespace std;
const int N=3003;
const int mod=998244353;
int dp[N],A[N];
int ans;
int n,s;
void solve()
{
	int i,j;
	cin>>n>>s;
	for(i=1;i<=n;i++) cin>>A[i];
	for(i=1;i<=n;i++)
	{
		for(j=s;j>=A[i];j--)
		{
			dp[j]=(dp[j-A[i]]+dp[j])%mod;
		}
		if(A[i]<=s) dp[A[i]]=(dp[A[i]]+i)%mod;
		ans=(dp[s]+ans)%mod;
	}
	cout<<ans<<endl;
}
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 256
#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;
typedef long long ll;




int main()
{
    ll K,A,B;cin >> K >> A >> B;
    ll ans = 1;
    if(B-A<=2){
        ans += K;
    }else{
        for (ll i = 1; i <= K; i++) {
            if(i < K && ans >= A) i++, ans+=(B-A);
            else ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll dp[200005][2];

void solve()
{
    int n;
    scanf("%d", &n);
    vector<ll> a(n), s0(n+1), s1(n+1);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    for (i = 0; i < n; i++) {
        s0[i + 1] = s0[i] + (i%2==0? a[i]: 0);
        s1[i + 1] = s1[i] + (i%2==1? a[i]: 0);
    }

    if (n % 2 == 0) {
        ll ans = MAX(s0[n], s1[n]);
        for (i = 0; i <= n / 2; i++) {
            ll ans0 = s0[2 * i] + s1[n] - s1[2 * i];
            ans = MAX(ans, ans0);
        }
        printf("%lld\n", ans);
    }
    else {
        ll ans = MAX(MAX(s0[n-1], s1[n-1]), s0[n]-s0[1]);
        int j;
        int m = n / 2;

        for (i = 0; i <= m; i++) {
            int j;
            for (j = 0; j < 2; j++) {
                dp[i][j] = -LINF;
            }
        }
        dp[0][0] = dp[0][1] = 0;
        for (i = 0; i < m; i++) {
            dp[i + 1][0] = MAX(dp[i + 1][0], dp[i][0] + a[2 * i]);
            dp[i + 1][1] = MAX(dp[i + 1][0], dp[i][0] + a[2 * i + 1]);
            dp[i + 1][1] = MAX(dp[i + 1][1], dp[i][1] + a[2 * i + 1]);
        }

        for (i = 0; i < n / 2; i++) {
            ll ans0 = dp[i][1] + s0[n] - s0[2*(i+1)];
            ans = MAX(ans, ans0);
        }
        for (i = 1; i < n / 2; i++) {
            ll ans0 = s0[2 * i] + s1[n] - s1[2 * (i + 1)];
            ans = MAX(ans, ans0);
        }
        printf("%lld\n", ans);      
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 9080
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . ___
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/
//use readint!
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<assert.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
using namespace std;
const int INF=1e9;
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
inline int readint(){
    int x=0;
    int f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
long long a[200005];
long long n;
map<long long,long long> mli;
int main(){
//	freopen("eee.d","r",stdin);
	long long i,j;
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	for(i=2;i<=n;i++) a[i]=a[i]+a[i-1]; 
//	for(i=1;i<=n;i++) cout<<a[i]<<' ';
//	cout<<endl;
	mli[0]++;
	for(i=1;i<=n;i++){
		mli[a[i]]++;
//		cout<<a[i]<<" "<<[a[i]]<<endl;
	}
	long long ans=0;
	for(map<long long,long long>::iterator it=mli.begin();it!=mli.end();it++) ans+=(it->second*(it->second-1))/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14336
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a, b, c, q, flag;
int main(){
	while(cin>>a>>b>>c){
		q = c % b;
		flag = 0;
		for(int i = 1; i <= 1000; i++){
			if((a * i) % b == q){
				cout<<"YES"<<endl;
				flag = 1;
				break;
			}
		}
		if(flag == 0)
			cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n,W;
	cin>>n>>W;
	const int64_t INF=4e18;
	vector<long long> d(100005,INF);
	d[0]=0;
	for(int i=0;i<n;i++)
	{
		int v,w;
		cin>>w>>v;
		for(int j=100000-v;j>=0;j--)
		{
			d[j+v]=min(d[j+v],d[j]+w);
		}
	}
	for(int i=100000;i>=0;--i)
	{
		if(d[i]<=W)
		{
			cout<<i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long INF = 1000000000000;
    int n, W;
    cin>>n>>W;
    long long weights[n];
    int values[n];
    int sum = 10;
    for(int i=0;i<n;i++){
        cin>>weights[i]>>values[i];
        sum += values[i];
    }
    pair<int, long long> dp[n+1][sum];
    for(int i=0;i<=n;i++){
        dp[i][0] = {1, 0};
    }
    for(int i=1;i<sum;i++){
        dp[0][i] = {0, INF};
    }
    for(int i=1;i<=n;i++){
        for(int v=1;v<sum;v++){
            if((v < values[i-1]) || (dp[i-1][v-values[i-1]].second + weights[i-1] > W)){
                dp[i][v] = dp[i-1][v];
            }else{
                pair<int, long long> include = dp[i-1][v-values[i-1]];
                pair<int, long long> exclude = dp[i-1][v];
                dp[i][v] = {include.first || exclude.first, min(include.second + weights[i-1], exclude.second)};
            }
        }
    }
    int ans = 0;
    for(int i=0;i<sum;i++){
        if(dp[n][i].first == 1){
            ans = i;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 158080
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    X = list(map(int, input().split()))
    x = sorted(X)[N // 2 - 1:N // 2 + 1]
    for i in X:
        print(x[i <= x[0]])


if __name__ == "__main__":
    main()


Measured memory_bytes: 26016
import java.util.*;

public class Main {
    static long mod = 1000000007;

    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        } else if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

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

        for (int i = 0; i < n; ++i) {
            lis[i] = sc.nextInt();
        }
        int[] sorted = Arrays.copyOf(lis, n);
        Arrays.sort(sorted);

        for (int i = 0; i < n; ++i) {
            if (sorted[n-1] == lis[i]) {
                System.out.println(sorted[n-2]);
            } else {
                System.out.println(sorted[n-1]);
            }
        }
    }
}


Measured memory_bytes: 100952
import java.util.Scanner;
class Main {
	public void ci(){
		Scanner sc = new Scanner(System.in);
		double r,S,O;
		r = sc.nextDouble();
		S = r * r * 3.141592653589;
		O = 2 * r * 3.141592653589;
		System.out.printf("%2.6f %2.6f\n",S,O);
	}
	public static void main(String[] args){
		new Main().ci();
	}
}

Measured memory_bytes: 19092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

#define add push_back
#define inf 2147000000

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

using namespace std;

int main(void){
	int a,b;
	while(scanf("%d",&a)!=EOF){
	scanf("%d",&b);
	
	a+=b;
	int i=0;
	int flg=0;
	if(a==0)flg=-1;
	for(i=0;a>=10;i++){
		a/=10;
	}
	i+=flg;
	cout<<i+1<<endl;
	}
}

Measured memory_bytes: 0
//ABC150

#include <iostream>
#include <vector>
#include <utility>
#include <climits>
#include <random>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <string>

using namespace std;

int l_num(vector<bool> v, int x){
    int count=0;
    for(int i=0; i<x; i++){
        if(v.at(i)) count++;
    }
    return count;
}

int func(int x){
    if(x==1)return 1;
    else return x*func(x-1);
}

int main(){
    int n, p_rank=0, q_rank=0;
    cin >> n;
    vector<int> p(n), q(n);
    vector<bool> p_used(n, true), q_used(n, true);
    for(int i=0; i<n; i++){
        cin >> p.at(i);
    }
    for(int i=0; i<n; i++){
        cin >> q.at(i);
    }
    for(int i=0; i<n-1; i++){
        p_rank += l_num(p_used, p.at(i)-1)*func(n-1-i);
        p_used.at(p.at(i)-1) = false;
        q_rank += l_num(q_used, q.at(i)-1)*func(n-1-i);
        q_used.at(q.at(i)-1) = false;
    }
    cout << abs(p_rank-q_rank) << endl;
    return 0;
}

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

int main(){
	string S;
	vector<bool> exist(26,false);
	cin >> S;
	int l=S.size();
	for(int i=0;i<l;i++)exist[S[i]-'a']=true;
	for(int i=0;i<=26;i++){
		if(i==26)cout << "None" << endl;
		else if(!exist[i]){
			char c='a'+i;
			cout << c << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = 301000;

const LL mod = 998244353;
LL fact[MAXN], invfact[MAXN];

LL binom(LL N, LL M) {
    return (fact[N]*((invfact[M]*invfact[N-M])%mod))%mod;
}

LL Inverse(LL n, LL m) {
    n %= m;
    if (n <= 1) return n; // Handles properly (n = 0, m = 1).
    return m - ((m * Inverse(m, n) - 1) / n);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    fact[0] = 1;
    for (int i = 1; i < MAXN; i++) fact[i] = (fact[i-1]*i)% mod;
    for (int i = 0; i < MAXN; i++) invfact[i] = Inverse(fact[i], mod);
    LL N, A, B, K;
    cin >> N >> A >> B >> K;
    LL res = 0;
    for (LL i = 0; i <= N; i++) {
        LL s = K-A*i;
        if (s < 0 or s > N*B or s%B) continue;
        LL j = s/B;
        res += (binom(N, i)*binom(N, j)) % mod;
    }
    res %= mod;
    cout << res << "\n";
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    long A, B, C, D, E;
    cin >> A >> B >> C >> D;
    
    //最小公倍数
    long a, b, r, x, tmp;
    a = C;
    b = D;
    x = a*b;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a%b;
    }
    E = x/b;
    
    long numAC, numAD, numAE, cntA;
    numAC = (A-1)/C;
    numAD = (A-1)/D;
    numAE = (A-1)/E;
    cntA = (A-1)-numAC-numAD+numAE;

    long numBC, numBD, numBE, cntB;
    numBC = B/C;
    numBD = B/D;
    numBE = B/E;
    cntB = B-numBC-numBD+numBE;

    cout << cntB-cntA;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <set>
using namespace std;
#define rep(x,to) for(int x=0; x<(to); (x)++)


int main() {
	int n;
	char s[10];
	string t;
	set<string> Set;
	cin >> n;
	rep(i,n) {
		scanf("%s", s);
		if(s[0] == 'i') {
			cin >> t;
			Set.insert(t);
		} else {
			cin >> t;
			if(Set.find(t) == Set.end()) printf("no\n");
			else printf("yes\n");
		}
	}
	return 0;
}

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

int main() {
  int N, M;
  string S, T;
  cin >> N >> M >> S >> T;
  auto X = lcm<long long>(N,M);
  auto Y = gcd(N,M);

  bool b{1};
  for (int i = 0; i != Y; ++i) {
    if (S[i*N/Y] != T[i*M/Y]) {
      b = 0;
      break;
    }
  }
  cout << (b ? X : -1) << endl;
}


Measured memory_bytes: 3724
import collections

n,m = map(int,raw_input().split(' '))
operations = [map(int, raw_input().split(' ')) for _ in range(m)]
def f(operations, n):

	res = [-1] * n

	for s,c in operations:
		s -=1
		if res[s] == -1:
			res[s] = c
		elif res[s] != c:
			return (False, res)
	
	for i in range(len(res)):
		if res[i] == -1: 
			res[i] = 0 if (i or n == 1) else 1
	
	if res[0] == 0 and n > 1:
		return (False, res)
	return (True, res)
f,r = f(operations, n)
print ''.join(map(str,r)) if f else -1

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int n; cin >> n;
	vl a(n);
	rep(i,n-1){
		int x; cin >> x;
		a[x-1] ++;
	}
	for(auto x: a){
		cout << x <<endl;
	}
}

Measured memory_bytes: 4840
n = int(input())
a = [input().split() for i in range(n)]

for i in range(n):
    a[i].append(i+1)

b = sorted(a, key = lambda x:int(x[1]), reverse = True)
c = sorted(b, key = lambda x:x[0])

for i in c:
    print(i[2])

Measured memory_bytes: 3188
a, b, m = map(int, input().split())

cost_a = list(map(int, input().split()))
cost_b = list(map(int, input().split()))

ans = min(cost_a) + min(cost_b) 
for i in range(m):
  x, y, c = map(int, input().split())
  cost = cost_a[x - 1] + cost_b[y - 1] - c
  ans = min(ans, cost)

print(ans)

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

using namespace std;

#define MOD (1000000007)

struct ModInt {
    long long x;

    ModInt (long long x = 0):x (x%MOD) {}

    ModInt& operator+=(const ModInt a) {
        if ( (x += a.x) >= MOD )
            x -= MOD;
        return *this;
    }

    ModInt& operator-=(const ModInt a) {
        if ( (x += MOD - a.x) >= MOD )
            x -= MOD;
        return *this;
    }

    ModInt& operator*=(const ModInt a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    ModInt operator+(const ModInt a) {
        ModInt res(*this);
        return res += a;
    }

    ModInt operator-(const ModInt a) {
        ModInt res(*this);
        return res -= a;
    }

    ModInt operator*(const ModInt a) {
        ModInt res(*this);
        return res *= a;
    }
};

ModInt C[4005][4005];
static void init_comb () {
    C[0][0] = 1;
    for ( int i = 0; i <= 4000; i++ ) {
        for ( int j = 0; j <= i; j++ ) {
            C[i+1][j] += C[i][j];
            C[i+1][j+1] += C[i][j];
        }
    }
}

static ModInt calc_comb (int n, int k) {
    return C[n][k];
}

static ModInt f2 (int n, int k) {
    return calc_comb(n+k-1, k-1);
}

static ModInt f (int n, int k) {
    if ( n < k )
        return 0;
    if ( n == 0 && k == 0 )
        return 1;
    if ( k < 1 )
        return 0;
    return f2(n-k, k);
}

int main (void) {
    long long N, K;
    cin >> N >> K;

    init_comb();

    for ( int i = 1; i <= K; i++ ) {
        ModInt blue = f(K, i);
        ModInt red = f2(N-K-(i-1), i+1);
        ModInt ans = blue * red;
        cout << ans.x << endl;
    }

    return 0;
}


Measured memory_bytes: 128948
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		String t = scan.nextLine();
		scan.close();
		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != t.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 42344
#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.second<< " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // bit全探索
  int N;
  cin >> N;
  vector<vector<P>> XY;
  rep(i, N) {
    int A;
    cin >> A;
    vector<P> B;
    rep(j, A) {
      int X, Y;
      cin >> X >> Y;
      --X;
      B.push_back(make_pair(X, Y));
    }
    XY.push_back(B);
  }
  //rep(i, N) show(XY[i]);
  int ans = 0;  
  for (int bit = 0; bit < (1<<N); bit++) {
    bool flag = true;
    for (int i = 0; i < N; i++) {
      if ((bit&(1<<i)) == 0) continue;
      for (auto p : XY[i]) {
        if (((bit>>p.first)&1) ^ (p.second==1)) {
          //cout << bit << '-' << i << '-' << p.first << '\n';
          flag = false; break;
        }
      }
    }
    if (flag) {
      int temp = 0;      
      for (int j = 0; j < 16; j++) {
        if (bit>>j&1) {
          ++temp;
        }
      }
      if (temp > ans) {
        //cout << '-' << bit << '\n';
        ans = temp;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

int main()
{ int n;
  string str;
  cin>>n;
  cin>>str;
  if(str.length()>n)
     {cout<<str.substr(0,n)<<"...";
     }
  else
     {cout<<str;
     }


    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N; cin >> N;
    int ab = 0, a = 0, b = 0, cnt = 0;
    vector<string> s(N);
    rep(i, N) cin >> s[i];
    rep(i, N) {
        if (s[i][0] == 'B' && s[i][s[i].length()-1] == 'A') ab++;
        else if (s[i][0] == 'B') b++;
        else if (s[i][s[i].length()-1] == 'A') a++;
        rep(j, s[i].length()-1) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') cnt++;
        }
    }
    if (ab == 0) {
        cout << min(a, b) + cnt << endl;
        return 0;
    }
    if (a + b == 0) {
        cout << cnt + ab - 1 << endl;
    }
    else cout << cnt + min(a, b) + ab << endl;
}


Measured memory_bytes: 768
data T = W | C deriving Show

parse [] = []
parse ('\"':r) =
  let w = takeWhile (/= '\"') r
      r'= dropWhile (/= '\"') r
  in
    (C,w):(parse $ tail r')
parse (a:r) =
  let w = takeWhile (/= '\"') r
      r'= dropWhile (/= '\"') r
  in
    (W,(a:w)):(parse r')

cmp n [] [] = if n == 0 then "IDENTICAL" else "CLOSE"
cmp n _ [] = "DIFFERENT"
cmp n [] _ = "DIFFERENT"
cmp n ((W,w1):d1) ((W,w2):d2) =
  if w1 /= w2
  then "DIFFERENT"
  else cmp n d1 d2
cmp n ((C,w1):d1) ((C,w2):d2) =
  if w1 /= w2
  then if n == 0
       then cmp 1 d1 d2
       else "DIFFERENT"
  else cmp n d1 d2
cmp n ((_,w1):d1) ((_,w2):d2) = "DIFFERENT"

ans' s1 s2 = 
  let t1 = parse s1
      t2 = parse s2
  in
    cmp 0 t1 t2

ans (".":_) = []
ans (s1:s2:ss) = (ans' s1 s2):(ans ss)
main = do
  c <- getContents
  let i = lines c
      o = ans i
  mapM_ putStrLn o



Measured memory_bytes: 4496
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
int max(const void *a, const void *b){return *(int*)b - *(int*)a;}

int r;

int main(void)
{
    scanf("%d",&r);
    printf("%d\n", 3*r*r);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
  char s[11],ans[11];
  scanf("%s",s);
  int len=strlen(s),i,last=0;
  for(i=0;i<len;i++){
    if(s[i]!='B'){
      ans[last]=s[i];
      last++;
    }
    else if(s[i]=='B' && last!=0)
      last--;
  }
  for(i=0;i<last;i++)
    printf("%c",ans[i]);
  puts("");
  return 0;
}

Measured memory_bytes: 1644
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define YES cout << "YES" << endl
#define NO  cout << "NO"  << endl
#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 100100100
using namespace std;
typedef long long ll;

int main(){
  int W, a, b;  cin >> W >> a >> b;
  if(a<b) cout << (b<a+W ? 0 : b-a-W) << endl;
  else if(a>b)  cout << (a<b+W ? 0 : a-b-W) << endl;
  else  cout << 0 << endl;
  return 0;
}

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

int main()
{
    int m=0,i;
    char a[3];
    for(i=0;i<3;i++)
    {
        scanf("%c",&a[i]);
    }
    for(i=0;i<3;i++)
   {

    if(a[i]=='o')
    m++;
   }
   printf("%d",m*100+700);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
const int maxN=1e4+10;
int N;
long long a[maxN],b[maxN];
int main()
{
	cin>>N;
	long long sum1=0;
	for(int i=0;i<N;i++)
	{
		cin>>a[i];
		sum1+=a[i];
	}
	long long sum2=0;
	for(int i=0;i<N;i++)
	{
		cin>>b[i];
		sum2+=b[i];
	}
	if(sum1>sum2)
	{
		cout<<"No"<<endl;
		return 0; 
	}
	long long need1=0,need2=0;
	for(int i=0;i<N;i++)
	{
		if(a[i]>b[i])
		{
			need1+=a[i]-b[i];
		}
		else
		{
			need2+=(b[i]-a[i]+1LL)/2LL;
		}
	}
	cout<<(max(need1,need2)<=sum2-sum1?"Yes":"No")<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int p[n];
  rep(i, n) { cin >> p[i]; }

  int a[n];
  a[0] = 1001001001;
  for (int i = 0; i < n - 1; ++i) {
    a[i + 1] = min(a[i], p[i]);
  }

  int ans = 0;
  rep(i, n) {
    if (p[i] <= a[i]) ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[][] a=new int[3][3];
		boolean[][] b=new boolean[3][3];
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				a[i][j]  = sc.nextInt();
			}	
		}
		int n  = sc.nextInt();
		int pre;
		for(int k=0;k<n;k++){
			pre=sc.nextInt();
			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){
					if(pre==a[i][j]){
						b[i][j]  = true;
					}
				}	
			}
		}
		boolean ans=false;
		for(int i=0;i<3;i++){
			if(b[0][i]&& b[1][i]&& b[2][i]){
				ans=true;
			}
		}
		for(int i=0;i<3;i++){
			if(b[i][0]&& b[i][1]&& b[i][2]){
				ans=true;
			}
		}

		if(b[0][0]&& b[1][1]&& b[2][2]){
			ans=true;
		}

		if(b[2][0]&& b[1][1]&& b[0][2]){
			ans=true;
		}
		if(ans){
		System.out.println("Yes");
		}else{
		System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
from collections import defaultdict
N, K = map(int, input().split())
a = defaultdict(int)
for i in range(N):
  num, length = map(int, input().split())
  a[num] += length
num = list(a.keys())
num.sort()
cnt = 0
for i in range(len(num)):
  cnt += a[num[i]]
  if cnt >= K:
    break
print(num[i])

Measured memory_bytes: 10856
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL f(LL n, LL k) {
    if (n < k) {
        return n == 1 ? 1 : 0;
    }
    if (n % k == 0) {
        return f(n/k, k);
    } else {
        return f(n % k, k);
    }
}

struct Factor {
    LL x;
    LL times;
};

vector<Factor> factor(LL nc) {
    vector<Factor> v;
    for (LL i = 2; i * i <= nc; i++) {
        if (nc % i == 0) {
            Factor fa = {i, 0};
            while (nc % i == 0) {
                nc /= i;
                fa.times++;
            }
            v.push_back(fa);
        }
    }
    if (nc > 1) {
        Factor fa = {nc, 1};
        v.push_back(fa);
    }
    return v;
}

vector<LL> all(LL nc) {
    vector<LL> v;
    LL i;
    for (i = 2; i * i < nc; i++) {
        if (nc % i == 0) {
            v.push_back(i);
            v.push_back(nc / i);
        }
    }
    if (i * i == nc) {
        v.push_back(i);
    }
    return v;
}

int main() {
    LL n;
    scanf("%lld", &n);
    auto vn = all(n);
    auto vnm = factor(n - 1);
    LL ans = 1;
    for (auto fa : vnm) {
        // printf("fa = {%lld, %lld}\n", fa.x, fa.times);
        ans *= (fa.times + 1);
    }
    for (auto i : vn) {
        if (f(n, i)) {
            ans++;
        }
    }
    printf("%lld\n", ans);

}


Measured memory_bytes: 384
// in the name if Allah
// YA Ali!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll INF = 1<<30 ;
const ll N= 1e6 ;
#define f first
#define s second
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC optimize("O4")
#pragma GCC optimize("O5")
#pragma GCC optimize("O6")
#pragma GCC optimize("O7")
#pragma GCC optimize("O8")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
ll n ;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n ;
cout << 3 * (n * n) ;
    return 0;
}
 /*
              _     _   __
        /_\  (_    (_)  __)
       /   \  _) . (_) (__
 */


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

typedef long long ll;
const int INF = 1e9 + 5;
int main() {
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> cur(3), prev(3);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> cur[j];
			int mx = -1;
			for (int k = 0; k < 3; k++) {
				if (k != j) {
					mx = max(mx, prev[k]);
				}
			}
			cur[j] += mx;
		}
		prev = cur;
	}
	cout << (*max_element(prev.begin(), prev.end()));
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        List<int> amount = new List<int>();

        amount.Add(1);
        int tmp = 1;
        while (true)
        {
            tmp *= 6;
            if (tmp > N)
            {
                break;
            }
            amount.Add(tmp);
        }

        tmp = 1;
        while (true)
        {
            tmp *= 9;
            if (tmp > N)
            {
                break;
            }
            amount.Add(tmp);
        }

        int[] DP = new int[N + 1];
        for (int i = 0; i <= N; i++)
        {
            DP[i] = 1000000;
        }


        DP[0] = 0;
        for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j < amount.Count; j++)
            {
                if (i + amount[j] <= N)
                {
                    DP[i + amount[j]] = Math.Min(DP[i] + 1, DP[i + amount[j]]);
                }
            }
        }

        Console.WriteLine(DP[N]);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);
const long double PI = acos(-1);
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<double> pnt;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

/* START */

int32_t main() { _
	string s;
	cin >> s;
	int cnt = 1;
	for (int i = 1; i < 4; ++i)
		if (s[i] == s[i - 1]) {
			++cnt;
			if (cnt >= 3)
				return cout << "Yes" << endl, 0;
		} else
			cnt = 1;
	cout << (cnt >= 3? "Yes": "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> cost(1000000);
vector<vector<int>> data(1000000);


int main(){
    char n;
    cin >> n;
    if(n >= 'a' && n <= 'z') cout << "a" << endl;
    else cout << "A" << endl;
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> v(n);

    FOR(i,0,n){
      cin>>v[i];
      v[i] = -v[i];
    }
    FOR(i,0,n){
      ll in;
      cin>>in;
      v[i] += in;
    }

    sortAl(v);

    ll sum=0;
    ll plus=0;
    ll res=0;
    FOR(i,0,n){
      sum += v[i];
      if(v[i]>0){
        res++;
        plus += v[i];
      }
    }

    if(sum>0){
      cout<<-1<<endl;
    }
    else{
      FOR(i,0,n){
        if(plus<=0){
          break;
        }
        plus+=v[i];
        res++;
      }

      cout<<res<<endl;
    }
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int n,a[10001],b[10001],i,j,d;
    while(scanf("%d",&n),n){
        for(i=0;i<n;i++){
            a[i]=0;
            b[i]=0;
        }
        for(i=1;i<n;i++)
            a[i*i%n]=1;
        for(i=0;i<n;i++)
            for(j=0;j<n;j++)
                if(i!=j&&a[i]&&a[j]){
                    d=i-j;
                    if(d<0)d+=n;
                    if(d>(n-1)/2)d=n-d;
                    b[d]++;
                }
        for(i=1;i<=(n-1)/2;i++)
            printf("%d\n",b[i]);
    }
    return 0;
}

Measured memory_bytes: 680