akhauriyash/Code-Regression huggingface dataset:
#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--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll MOD = 1e9 + 7;
// return a^b O(log b)
template<typename T>
T mypow(T a, T b){
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}
// return nCk 前処理 O(N) + query あたり O(1)
long long comb(int n, int k){
    static bool init = false;
    long long res = 1;
    const ll M = 1e6 + 10;
    vector<ll> frc(M + 1, 1), inv(M + 1, 1);
    if(!init){
        init = true;
        REP(i, M){
            frc[i + 1] = (frc[i] * (i + 1)) % MOD;
            inv[i + 1] = mypow(frc[i + 1], MOD - 2);
        }
    }
    if (k < 0 || n < k) return 0;
    res = (((frc[n] * inv[k]) % MOD) * inv[n - k]) % MOD;
    return res;
}
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);

    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3) {
        cout << 0 << endl;
        return 0;
    }
    ll cnt = (x + y) / 3;
    ll p = x - cnt, q = cnt - p;
    if (p < 0 || q < 0) {
        cout << 0 << endl;
        return 0;
    }
    ll res = comb(cnt, p);
    cout << res << endl;
    return 0;
}

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

int main(){
  int D;
  cin >> D;
  if(D==25){
    cout << "Christmas" << endl;
  }else if(D==24){
    cout << "Christmas Eve" << endl;
  }else if(D==23){
    cout << "Christmas Eve Eve" << endl;
  }else if(D==22){
    cout << "Christmas Eve Eve Eve" << endl;
  }


  return 0;
}

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

ll N;
vector<ll> p;

void solve() {
  ll res = 0;
  vector<bool> match(N, false);
  for (int i = 0; i < N; i++) {
    if (p[i] == i + 1) {
      match[i] = true;
    }
  }
  for (int i = 0; i < N; i++) {
    if (match[i]) {
      if (i < N - 1 && match[i + 1]) {
        match[i] = false;
        match[i + 1] = false;
        res++;
      }
      else {
        match[i] = false;
        res++;
      }
    }
  }
  cout << res << "\n";
}

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


Measured memory_bytes: 1024
loop do
 a,op,b = gets.split()
 case op
  when "+" then puts (a.to_i+b.to_i)
  when "-" then puts (a.to_i-b.to_i)
  when "*" then puts (a.to_i*b.to_i)
  when "/" then puts (a.to_i/b.to_i)
  when "?" then break
 end
end

Measured memory_bytes: 8592
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int x,m=100;
    cin>>x;
    int y = 0;
    while (x > m) {
        ++y;
        m += m / 100;
    }
    cout << y;
}

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

using namespace std;

long long int  n,s, m,k,ans,b,d,f,s1,s2,s3,w,a,c,z2,z1,z3,ans1;
string  j,t,g,k2,k3;
bool ww=false,wwr=false;
set <int> ss;

//vector <pair<long long int,long long int >> a1;
char e1,e2;

int main() {
  cin>>n>>m;
 cout<<(n-1)*(m-1);
   
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(void){
	int x,a, b;
	cin >> x >> a >> b;

	if (a < x){
		a = x - a;
	}
	else{
		a = a - x;
	}
	if (b < x){
		b = x - b;
	}
	else{
		b = b - x;
	}
	if (b>a){
		cout << 'A' << endl;
	}
	else{
		cout << 'B' << endl;
	}
	return 0;

}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

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

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const int B = 4010;
bool ab[B * 2], ac[B * 2], bc[B * 2];

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    rep(i, B * 2) { ab[i] = ac[i] = bc[i] = true; }

    auto dif = [&](char p, char q) { return (p != '?' && q != '?' && p != q); };
    rep(i, a.size()) {
        rep(j, b.size()) {
            if (dif(a[i], b[j])) {
                ab[i - j + B] = false;
            }
        }
    }
    rep(i, a.size()) {
        rep(j, c.size()) {
            if (dif(a[i], c[j])) {
                ac[i - j + B] = false;
            }
        }
    }
    rep(i, b.size()) {
        rep(j, c.size()) {
            if (dif(b[i], c[j])) {
                bc[i - j + B] = false;
            }
        }
    }
    int ans = TEN(9);

    for (int d1 = -4000; d1 <= 4000; ++d1) {
        for (int d2 = -4000; d2 <= 4000; ++d2) {
            if (abs(d1 + d2) > 4000) continue;
            if (ab[d1 + B] && bc[d2 + B] && ac[d1 + d2 + B]) {
                int l = max({(int)a.size(), (int)b.size() + d1,
                             (int)c.size() + d1 + d2}) -
                        min({0, d1, d1 + d2});
                chmin(ans, l);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
  set<int> a = {1, 3, 5, 7, 8, 10, 12};
  set<int> b = {4, 6, 9, 11};
  set<int> c = {2};

  int x, y;
  cin >> x >> y;

  if (a.find(x) != a.end() && a.find(y) != a.end()) cout << "Yes" << endl;
  else if (b.find(x) != b.end() && b.find(y) != b.end()) cout << "Yes" << endl;
  else if (c.find(x) != c.end() && c.find(y) != c.end()) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int dp[55][1055][1055];
int n, a[55], minx = 10000000;
int main() {
	for (int i = 0; i < 55; i++)for (int j = 0; j < 1113025; j++)dp[i][j / 1055][j % 1055] = 10000000;
	dp[0][0][0] = 0; cin >> n; for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 1000; j++) {
			for (int k = 0; k < 1000; k++) {
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k] + a[i]);
				dp[i + 1][j + a[i]][k] = min(dp[i + 1][j + a[i]][k], dp[i][j][k]);
				dp[i + 1][j][k + a[i]] = min(dp[i + 1][j][k + a[i]], dp[i][j][k]);
			}
		}
	}
	for (int i = 0; i < 1055; i++) {
		for (int j = 0; j < 1055; j++)minx = min(minx, max(i, max(j, dp[n][i][j])));
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 242200
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	char ca;
	cin>>ca;
	if('A'<=ca && ca<='Z')cout<<"A"<<endl;
	else cout<<"a"<<endl;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

int n;
vector<pii> g[100000];
int col[100000];

void dfs(int v, int p)
{
	for(auto e : g[v]) if(e.first != p){
		int c = (col[v]+e.second)%2;
		col[e.first] = c;
		dfs(e.first, v);
	}
}

signed main()
{
	cin >> n;

	rep(i, 0, n-1){
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		g[u].pb({v, w});
		g[v].pb({u, w});
	}

	col[0] = 0;
	dfs(0, -1);

	rep(i, 0, n){
		cout << col[i] << endl;
	}

	return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int X, A, B;
	cin >> X >> A >> B;

	string ans;
	if (B <= A) {
		ans = "delicious";
	} else if (B <= (A + X)) {
		ans = "safe";
	} else if (B >= (A + X + 1)) {
		ans = "dangerous";
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#ABC116D-VariousSushi.py

from sys import stdin
#from numpy import sum

input = stdin.readline

N, K = list(map(int, input().split()))
List1= []
kind = set()
point1, point2 = 0, 0

INPUT = [tuple(map(int, input().split())) for _ in range(N)]

INPUT.sort(key = lambda x: -x[1])

for ti, di in INPUT[:K]:
    point1 += di
    if ti in kind:
        List1.append(di)
    kind.add(ti)

point2 = len(kind)

Score = point1 + point2**2
Test = Score

List1POP = List1.pop

for ti, di in INPUT[K:]:
    if 0 >= len(List1):
        break
    if ti in kind:
        continue
    Test = Test - List1POP() + di + 2 * point2 + 1
    point2 += 1
    kind.add(ti)
    Score = max(Score, Test)

print(Score)


Measured memory_bytes: 21444
#ifdef LC
#include "pch.h"
#else
#include <bits/stdc++.h>
#endif
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mt make_tuple

const int H = 1e7;
int *ptr[H];
int  val[H];
int siz = 0;
void save(int &x) {
    ptr[siz] =  &x;
    val[siz++] = x;
}
void backup(int to) {
    assert(0 <= to && to <= siz);
    while (siz > to) {
        --siz;
        *ptr[siz] = val[siz];
    }
}

const int N = 1 << 20;
const int M = 1e9 + 7;

int h, n;
int p[N];
int dp[N];

int twin(int v) {
    assert(n <= v && v < 2 * n);
    v = p[v - n] + n;
    assert(n <= v && v < 2 * n);
    return v;
}
int ls(int v) {
    return 2 * v;
}
int rs(int v) {
    return 2 * v + 1;
}
int pa(int v) {
    return v / 2;
}
int br(int v) {
    return v ^ 1;
}

void dfs_add(int v, int m) {
    (m *= v) %= M;
    if (v < n) {
        dfs_add(ls(v), m);
        dfs_add(rs(v), m);
    } else {
        for (v = twin(v); v > 0; v = pa(v)) {
            (m *= v) %= M;
            save(dp[v]);
            (dp[v] += m) %= M;
        }
    }
}

int ans = 0;

void dfs_ans(int v, int m) {
    (m *= v) %= M;
    if (v < n) {
        dfs_ans(ls(v), m);
        dfs_ans(rs(v), m);
    } else {
        for ((m *= (v = twin(v))) %= M; pa(v) > 0; v = pa(v)) {
            (m *= pa(v)) %= M;
            (ans += m * dp[br(v)]) %= M;
        }
    }
}

int32_t main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> h;
    n = 1 << (h - 1);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        --p[i];
    }
    for (int i = 1; i < n; ++i) {
        int save = siz;
        dfs_add(ls(i), i);
        dfs_ans(rs(i), 1);
        backup(save);
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M;
    cin >> N >> M;
    mat G(N);
    REP(i,0,M) {
        ll a, b;
        cin >> a >> b;
        --a; --b;
        G[a].pb(b);
        G[b].pb(a);
    }


    queue<ll> Q;
    vec D(N, -1);
    Q.push(0);
    ll k = 0;
    while(k < N) {
        ll c = 1;
        D[k] = 1;
        Q.push(k);
        while(!Q.empty()) {
            ll v = Q.front(); Q.pop();
            FORR(nv,G[v]) {
                if(D[nv] == -1) {
                    ++c;
                    D[nv] = c;
                    Q.push(nv);
                }
            }
        }
        while(D[k] != -1 && k < N) ++k;
    }

    ll m = 0;
    REP(i,0,N) m = MAX(m,D[i]);
    PR(m);

    return 0;
}

/*



*/

Measured memory_bytes: 18436
n,m,x=map(int,input().split())
a=[]
for c in range(n):
    a.append([int(x) for x in input().split()])
s=10**7
for d in range(2**n):
    p=0
    q=[0]*m
    for e in range(n):
        if (d%(2**(e+1)))//(2**e)==1:
            p+=a[e][0]
            for f in range(m):
                q[f]+=a[e][f+1]
    if s<p:
        continue
    r=0
    for f in range(m):
        if q[f]<x:
            r=1
            break
    if r==0:
        s=p
if s==10**7:
    print(-1)
else:
    print(s)

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

const int mxN = 21, mxV = 1 << 21, MOD = 1e9 + 7;
long long n, grid[mxN][mxN], dp[21][mxV];

long long recurse(int i, int mask)
{
    if (i < 0)
        return 1;
    if (dp[i][mask] != -1)
        return dp[i][mask];

    long long ways = 0;
    for (int j = 0; j < n; j++)
    {
        if (grid[i][j] == 1 && ((mask & (1 << j)) > 0))
        {
            int tmp = mask ^ (1 << j);
            ways += recurse(i - 1, tmp);
            ways %= MOD;
        }
    }
    dp[i][mask] = ways;
    return ways;
}

int main()
{
    for (int i = 0; i < 21; i++)
    {
        for (int j = 0; j < mxV; j++)
        {
            dp[i][j] = -1;
        }
    }

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

    cout << recurse(n - 1, (1 << n) - 1);
}

Measured memory_bytes: 347708
#include <iostream>

using namespace std;
int main(){
  int n;
  cin >> n;
  int i, arr[n], a=0;
  for(i=0; i<n; i++){
    cin >> arr[i];
    if(i%2==0 && arr[i]%2!=0)a++;
  }
  cout << a << endl;
  return EXIT_SUCCESS;
}

Measured memory_bytes: 3588
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, mut l: [isize; n]);
    let mut count = 0;

    let mut ans_vec = vec![vec![0; n]; n];

    l.sort_unstable();
    for i in 0..n {
        for j in i..n {
            ans_vec[i][j] = l[i] + l[j];
        }
    }

    for i in 0..n {
        for j in i + 1..n {
            let a1 = l[i] - l[j];
            let a2 = l[j] - l[i];
            let a3 = l[i] + l[j];
            for k in j + 1..n {
                if a1 < l[k] && a2 < l[k] && l[k] < a3 {
                    count += 1;
                }
            }
        }
    }

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


Measured memory_bytes: 33388
N = gets.to_i
H = gets.split.map(&:to_i)
dp = Array.new(N, 0)
dp[1] = (H[1] - H[0]).abs
2.step(N-1) do |i|
  dp[i] = [(H[i] - H[i-1]).abs + dp[i-1], (H[i] - H[i-2]).abs + dp[i-2]].min
end
puts dp.last

Measured memory_bytes: 11396
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 998244353
ll n,q,i,j,k,t,arr[sz],brr[sz],crr[sz],a,b,c,d;
map<string,ll>mp;
int main()
{
    scanf("%lld",&n);
    while(n--)
    {
     string cc;
     cin >> cc;
     mp[cc]++;
    }
    cout << mp.size() << endl;
}


Measured memory_bytes: 19292
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7

main(){
    int a=in(),b=in();
    cout<<(a>9||b>9?-1:a*b);
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    for (int i = A; i <= B; i++) {
      if (A + C > i || B - C < i) {
        System.out.println(i);
      }
    }
  }
}


Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();

    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (i * j == n) {
          System.out.println("Yes");
          return;
        }
      }
    }

    System.out.println("No");
  }

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
vector <ll> input;
ll prefix[200005];

ll M = 1000000007;
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	ll i,j,k,l,m,n,x,y,z,a,b,c;
 
	cin >> n;

	for(i=0;i<n;i++)
	{
		cin >> k;
		input.push_back(k);
	}

	prefix[0] = input[0];

	for(i=1;i<n;i++)
	{
		prefix[i] = prefix[i-1]%M+input[i]%M;
		prefix[i] = prefix[i]%M;
	}

	ll ans = 0;

	for(i=0;i<n-1;i++)
	{
		ans = ans+(input[i]%M)*((prefix[n-1]-prefix[i]+M)%M);
		ans = ans%M;
	}

	cout << ans << '\n';


 
}

Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
long long n,a[100002],z=1,zs;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=2;i<=n;i++)
    {
        if(a[i]==a[i-1])z=(z+1)%2;
        else zs+=z,z=1;
    }
    if(z%2)zs++;
    cout<<zs<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  int s;
  cin>>s;
  int l[2000000];
  l[0]=s;
  int ans=0;
  bool ok=false;
  for(int i=1;i<2000000;i++){
    if(l[i-1]%2==0){
      l[i]=l[i-1]/2;
    }else{
      l[i]=3*l[i-1]+1;
    }
    for(int j=0;j<i;j++){
      if(l[j]==l[i]){
        ans=i;
        ok=true;
      }
    }
    if(ok){
      break;
    }



  }
  cout<<ans+1<<endl;



  

  



}


  
  


  




Measured memory_bytes: 888
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	string S;
	cin>>S;
	int ans=0;
	for(int i=0;i<S.length();i++){
		int a[26]={},b[26]={};
		for(int j=0;j<S.length();j++){
			if(j<=i)
				a[S[j]-'a']++;
			else
				b[S[j]-'a']++;
		}
		int temp=0;
		for(int j=0;j<26;j++)
			if(a[j] && b[j])
				temp++;
		ans=max(ans,temp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def balanced_neighbors(N: int) -> list:
    # N が偶数の時、i は N+1-i 以外の頂点と結べば
    # 隣接点の和は (N+1)(N-2)/2 となり、i に依存しない
    # ため全て同じになる。
    # N が奇数の時、N を抜いた N-1 個の頂点に対して偶数
    # の場合の処理をする。このとき、N 以外の頂点はその隣
    # 接点の和は N(N-3)/2 となっている。この状態で N と
    # その他全ての頂点とを結べば、N 以外の頂点の隣接点の
    # 和は
    # N(N-3)/2 + N = N(N-1)/2
    # であり、N のそれは 1 ~ N-1 の和なので
    # N(N-1)/2
    # となり等しくなる。
    if N < 3:  # 2 以下の頂点数では無理
        return []
    if N & 1:  # 奇数
        return balanced_neighbors(N-1) + [(i, N) for i in range(1, N)]

    # 偶数
    return [(i+1, j+1) for i in range(N) for j in range(i+1,N) if i+j != N-1]


if __name__ == "__main__":
    N = int(input())

    ans = balanced_neighbors(N)
    print(len(ans))
    for x, y in ans:
        print(x, y)


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

int main(){
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='p')cnt++;
    }
    cout<<s.size()/2-cnt<<endl;
    return 0;
}

Measured memory_bytes: 3756
from math import floor

r, g, b, n = map(int, input().split())
r, g, b = sorted([r, g, b])[::-1]

cnt = 0
for r0 in range(floor(n // r)+1):
  for g0 in range(floor((n-r*r0)// g)+1):
    sum = r * r0 + g * g0
    if sum > n:
      continue
    if (n - sum) % b == 0:
      cnt += 1

print(cnt)
      

Measured memory_bytes: 3060
n = int(input())
a = map(int, input().split())
babies = [(a, i) for i, a in enumerate(a)]
babies.sort(reverse=True)

dp = [[0]*(n+1) for i in range(n+1)]

ans = 0

for l in range(n):
  for r in range(n):
    if l+r == n:
      ans = max(ans, dp[l][r])
      break
    activeness, ind = babies[l+r]
    dp[l+1][r] = max(dp[l+1][r], dp[l][r] + abs(ind - l) * activeness)
    dp[l][r+1] = max(dp[l][r+1], dp[l][r] + abs(ind - (n-1-r)) * activeness)
print(ans)

Measured memory_bytes: 100768
#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;

const llong MOD = 1000000007;

llong powmod(llong x, llong n) {
  llong ans = 1;
  while (n) {
    if (n & 1)
      ans = ans * x % MOD;
    n >>= 1;
    x = (x * x) % MOD;
  }
  return ans;
}

llong pow2mod(llong n) {
  return powmod(2, n);
}

llong factmod(llong n, llong bottom) {
  llong ans = n % MOD;
  while (--n >= bottom) {
    ans = ans * n % MOD;
  }
  return ans;
}

llong combmod(llong n, llong a) {
  llong x = factmod(n, n - a + 1);
  llong y = factmod(a, 1);
  // x / y (% MOD) === x * y ^ -1 (% MOD)
  // y ^ -1 (% MOD) === y ^ (MOD - 2)
  return (powmod(y, MOD - 2) * x) % MOD;
}

void DBouquet(std::istream& in, std::ostream& out) {
  llong n, a, b;
  in >> n >> a >> b;

  llong sum = 0;
  sum += pow2mod(n) - 1;
  sum = (sum + MOD - combmod(n, a)) % MOD;
  sum = (sum + MOD - combmod(n, b)) % MOD;
  out << sum << endl;
}

int main(int argc, char** argv) { DBouquet(cin, cout); return 0; }


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

using namespace std;

int N, T;
vector<pair<int, int>> dishes;

int solve() {
  vector<vector<int>> dp1(N, vector<int>(T, 0));

  for (int j = dishes[0].first; j < T; ++j) {
    dp1[0][j] = dishes[0].second;
  }

  for (int i = 1; i < N; ++i) {
    for (int j = 0; j < T; ++j) {
      dp1[i][j] = dp1[i - 1][j];
      if (j >= dishes[i].first) {
        dp1[i][j] = max(dp1[i][j], dp1[i - 1][j - dishes[i].first] + dishes[i].second);
      }
    }
  }

  vector<vector<int>> dp2(N, vector<int>(T, 0));

  for (int j = dishes[N - 1].first; j < T; ++j) {
    dp2[N - 1][j] = dishes[N - 1].second;
  }

  for (int i = N - 2; i >= 0; --i) {
    for (int j = 0; j < T; ++j) {
      dp2[i][j] = dp2[i + 1][j];
      if (j >= dishes[i].first) {
        dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - dishes[i].first] + dishes[i].second);
      }
    }
  }

  int result = 0;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < T; ++j) {
      int subresult = dishes[i].second;

      if (i > 0) {
        subresult += dp1[i - 1][j];
      }
      
      if (i + 1 < N) {
        subresult += dp2[i + 1][T - 1 - j];
      }

      result = max(result, subresult);
    }
  }

  return result;
}

int main() {
  cin >> N >> T;

  dishes = vector<pair<int, int>>(N);

  for (int i = 0; i < N; ++i) {
    cin >> dishes[i].first >> dishes[i].second;
  }

  cout << solve() << endl;

  return 0;
}


Measured memory_bytes: 70784
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a<1 || a>9 || b<1 || b>9){
            cout << "-1" <<endl;
    }
    else{
            cout << a*b <<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n;
    int t[n];
    int tmp[n];
    int ans;
    for (int i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    cin >> m;
    int p[m], x[m];
    for (int i = 0; i < m; i++)
    {
        cin >> p[i] >> x[i];
    }

    for (int i = 0; i < m; i++)
    {
        ans = 0;
        for (int j = 0; j < n; j++)
        {
            tmp[j] = t[j];
        }
        tmp[p[i] - 1] = x[i];
        for (int j = 0; j < n; j++)
        {
            ans += tmp[j];
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX 100000
#define true 1
#define false 0

typedef struct{
  char name[11];
  int time;
}Process;

void initialize(void);
int isEmpty(void);
int isFull(void);

int head,tail;
Process Q[MAX];



void initialize(){
  head = tail = 0;
}

void enqueue(Process x){
  if(isFull() == true) exit(1);
  Q[tail] = x;
  if(tail + 1 == MAX)
    tail = 0;
  else{
    tail++;
    
  }
}

Process dequeue(){
  Process x;
  if(isEmpty() == true) exit(1);
  x = Q[head]; 
  if(head + 1 == MAX)
    head = 0;  
  else{
    head++;
  }
  return x;
}

int main(){
  int elaps = 0;
  int i,q,n;
  Process u;

  initialize();
  
  scanf("%d%d",&n,&q);
  
  for(i=0 ; i<n ; i++){
    scanf("%s%d",Q[i].name,&Q[i].time);

  }
  
  tail = n;
  
  while(head != tail){
    u = dequeue();
    if(q < u.time){
    elaps += q;
    u.time -= q;
    enqueue(u);
    }
    else{  
      elaps += u.time;
      printf("%s %d\n",u.name,elaps);
    }
  }
            
  return 0;
}



int isEmpty(void){
  if(head == tail) return true;
  return false;
}

int isFull(void){
  if(head == (tail + 1) % MAX) return true;
  return false;
}
  




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

int main()
{
	ios::sync_with_stdio(false);

	ll n, maxWeight;
	cin >> n >> maxWeight;

	ll values[n+1], weights[n+1], knap[n+1][maxWeight+1];
	weights[0] = values[0] = 0;

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

	for (int i = 0; i <= n; ++i)
		knap[i][0] = 0;

	for (int i = 0; i <= maxWeight; ++i)
		knap[0][i] = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int m = 1; m <= maxWeight; m++)
		{
			if (weights[i] > m)
				knap[i][m] = knap[i-1][m];
			else
				knap[i][m] = max(values[i] + knap[i-1][m-weights[i]], knap[i-1][m]);
		}
	}

	cout << knap[n][maxWeight] << endl;

	return 0;
}

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

int main(){
  long long A,B,K;
  cin >> A >> B >> K;
  if(K >= A){
    K -= A;
    A = 0;
  }
  else{
    A -= K;
    K = 0;
  }
  if(K >= B){
    B = 0;
  }
  else{
    B -=K;
  }
  cout << A << ' ' << B << endl;
}


Measured memory_bytes: 256
as,bs,cs = 3.times.map{gets.chomp.chars}
current = "a"

loop do
	if current == "a"
		break puts "A" if as.empty?
		current = as.shift
	elsif current == "b"
		break puts "B" if bs.empty?
		current = bs.shift
	else
		break puts "C" if cs.empty?
		current = cs.shift
	end
end



Measured memory_bytes: 1788
#include<stdio.h>
int main(void){
    int H,M,i,j;
    while(1){
        scanf("%d %d",&H,&M);
        if(H==0&&M==0)break;
        for(i=0;i<H;i++){
            for(j=0;j<M;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

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

// |n| = 10,000

map<int, int> generate_count(const vector<int> &arr, int start) {
	map<int, int> res;
	for (int i = start; i < arr.size(); i += 2) {
		res[arr[i]]++;
	}
	return res;
}

int find_min_change(map<int, int> &m) {
	int num = 0;
	int max_count = 0;
	for (auto &p : m) {
		int cur = p.ff;
		int cur_count = p.ss;
		if (cur_count > max_count) {
			max_count = cur_count;
			num = cur;
		}
	}
	return num;
}

void solve() {
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	map<int, int> m1 = generate_count(arr, 0);
	map<int, int> m2 = generate_count(arr, 1);
	int total1 = (n / 2) + (n % 2 ? 1 : 0);
	int total2 = n / 2;
	int chosen1 = find_min_change(m1);
	int chosen2 = find_min_change(m2);
	int chosen_count1 = total1 - m1[chosen1];
	int chosen_count2 = total2 - m2[chosen2];
	int ans;
	if (chosen1 != chosen2) {
		ans = chosen_count1 + chosen_count2;
	} else {
		// total1 -= chosen_count1;
		// total2 -= chosen_count2;
		// tie break
		m1.erase(chosen1);
		m2.erase(chosen2);
		int tie1 = find_min_change(m1);
		int tie2 = find_min_change(m2);
		// Use the second largest on first map
		if (m1[tie1] > m2[tie2]) {
			ans = (total1 - m1[tie1]) + chosen_count2;
		} else {
			ans = chosen_count1 + (total2 - m2[tie2]);
		}
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif
	solve();
}

Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> priceList = new ArrayList<>();

        for (int i = 0; i < n; i ++){
            priceList.add(sc.nextInt());
        }

        int maximumProfit = -1000000000;
        int minimumPrice = priceList.get(0);

        for (int i =1; i < priceList.size(); i++){
            int price = priceList.get(i);
            maximumProfit = Math.max(maximumProfit, price - minimumPrice);
            minimumPrice = Math.min(minimumPrice, price);
        }

        System.out.println(maximumProfit);
    }

}


Measured memory_bytes: 105660
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		List<Integer> listN = new ArrayList<Integer>();
		List<Integer> listX = new ArrayList<Integer>();
		for(;;){
			int n = scan.nextInt();
			int x = scan.nextInt();
			if((n == 0) && (x == 0)){
				break;
			}
			listN.add(n);
			listX.add(x);
		}

		for(int i = 0; i < listN.size(); i++){
			int n = listN.get(i);
			int x = listX.get(i);
			int cnt = 0;
			for(int a = 1; a <= n; a++){
				for(int b = a + 1; b <= n; b++){
					for(int c = b + 1; c <= n; c++){
						int sum = a + b + c;
						if(sum == x){
							cnt++;
						}
					}
				}
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 26840
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int h, w;
    
    while (1) {
        scanf("%d %d", &h, &w);
        
        if (h == 0 && w == 0) {
            break;
        }
        
        for(int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2044
function f()
    n,k=map(x->parse(Int,x),split(readline()))
    ni=zeros(Int,n)
    ni=map(x->parse(Int,x),split(readline()))
    flag=fill(-1,n)
    h=fill(-1,n)
    j=1
    c=0
    for i=1:k
        flag[j]=1
        c += 1
        j=ni[j]
        if flag[j] == 1
            s=1
            jn=j
            h[1]=jn
            j=ni[j]
            b=2
            while jn != j
                h[b]=j
                j=ni[j]
                b += 1
                s += 1
            end
            ansj=(k-c)%s
            println(h[ansj+1])
            exit()
        end
    end 
    println(j)  
end
f()           


Measured memory_bytes: 198256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c < 22)
    {
        cout << "win\n";
    }
    else
    {
        cout << "bust\n";
    }
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
    for (int i = 0; i < N; i++) {
        string str;
        cin >> str;
        if (str == "AC")
            c0++;
        else if (str == "WA")
            c1++;
        else if (str == "TLE")
            c2++;
        else if (str == "RE")
            c3++;
    }
    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
}

Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        var input = Reads();
        var n = input[0];
        var r = input[1];
        if (n >= 10)
            Console.WriteLine(r);
        else
            Console.WriteLine(r+(10-n)*100);

        Console.Out.Flush();
    }
}

Measured memory_bytes: 13396
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=2*100000;
char a[MAXN+5],b[MAXN+5];
int cnt1[MAXN+5],cnt2[MAXN+5],num1[MAXN+5],num2[MAXN+5];
int alen,blen,Max=-10;
int main()
{
	scanf("%s%s",a,b);
	alen=strlen(a);
	blen=strlen(b);
	for(int i=0;i<alen;i++)
	{
		cnt1[a[i]-'a']++;
		Max=max(Max,cnt1[a[i]-'a']);
	}
	for(int i=0;i<blen;i++)
	{
		cnt2[b[i]-'a']++;
		Max=max(Max,cnt1[a[i]-'a']);
	}
	for(int i=0;i<26;i++)
	{
		num1[cnt1[i]]++;
		num2[cnt2[i]]++;
	}
	for(int i=0;i<=Max;i++)
		if(num1[i]!=num2[i])
		{
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
long power(long base, long exponent, long mod){ if(exponent % 2){ return power(base, exponent - 1, mod) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2, mod); return root_ans * root_ans % mod; }else{ return 1; }}

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int ans = 1e9;
    for(int a = 0; a <= X; a++){
        if(B > C * 2){
            int ab = max(X - a, Y);
            ans = min(ans, a * A + ab * C * 2);
        }else{
            int ab = X - a;
            int b = max(0, Y - ab);
            ans = min(ans, a * A + b * B + ab * C * 2);
        }
    }
    cout << ans << endl;
}



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

int main() {
	int a, b;
	cin >> a >> b;

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;

}

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

std::string N;
int K;

long long count(int index, bool max_f, long long K_cur){
    if(K_cur == K){
        return 1;
    }
    if(index == N.size()){
        return 0;
    }
    long long cnt = 0;
    if(max_f){
        if(N[index] == '0'){
            cnt += count(index + 1, true, K_cur);
        }else{
            cnt += count(index + 1, true, K_cur+1);
            cnt += (N[index] - '0' - 1) * count(index + 1, false, K_cur+1);
            cnt += count(index + 1, false, K_cur);
        }
    }else{
            cnt += 9 * count(index + 1, false, K_cur+1);
            cnt += count(index + 1, false, K_cur);
    }
    return cnt;
}

int main(){
    std::cin >> N >> K;
    
    std::cout << count(0, true, 0) << std::endl;
    
    
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.Math.*;
public class Main{
    public static void main(String[] args)throws IOException{
	InputStreamReader isr = new InputStreamReader(System.in);
	BufferedReader br = new BufferedReader(isr);
	String line;
	while((line=br.readLine())!=null){
	    double v = Double.parseDouble(line);
	    double t = v/9.8;
	    double y = 4.9*t*t;
	    boolean flag=true;
	    int n=1;
	    while(flag){
		int l = 5*n-5;
		if(l>=y){
		    flag =false;
		    System.out.println(n);
		}
		n++;
	    }
	}
    }
}

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

bool x_large(vector<vector<int>> &a,int x){
    vector<int> s(a.at(0).size());
    for(int i=0;i<a.size();i++){
        for(int j=0;j<a.at(i).size();j++){
            s.at(i) += a.at(i).at(j);
        }
    }
    for(int i=0;i<s.size();i++){
        if(s.at(i) < x) return false;
    }
    return true;
}

bool large(vector<int> &s,int x){
    for(int i=0;i<s.size();i++){
        if(s.at(i)<x) return false;
    }
    return true;
}



int main(){
    int n,m,x;
    cin >>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        cin >> c.at(i);
        for(int j=0;j<m;j++){
            cin >>a.at(i).at(j);
        }
    }
    vector<int> t(m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            t.at(j) += a.at(i).at(j); 
        }
    }
    for(int i=0;i<m;i++){
        if(t.at(i) < x){
            cout << "-1" << endl;
            return 0;
        }
    }
    vector<int> sum;
    for(int bit=0;bit < (1<<n);bit++){
        int s_c = 0;
        vector<int> s_bit(m);
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                s_c += c.at(i);
                for(int j=0;j<m;j++) s_bit.at(j) += a.at(i).at(j); 
            }
        }
        if(large(s_bit,x)) sum.push_back(s_c);
    }
    sort(sum.begin(),sum.end());
    cout << sum.at(0) << endl;

}


Measured memory_bytes: 3544
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
  size_t N;
  int A, B, C;
  scanf("%zu %d %d %d", &N, &A, &B, &C);

  std::vector<int> l(N);
  for (auto& li: l) scanf("%d", &li);

  std::sort(l.begin(), l.end());
  int res = 1e9;
  do {
    for (size_t i = 1; i < N; ++i)
      for (size_t j = i+1; j < N; ++j)
        for (size_t k = j+1; k <= N; ++k) {
          int a = std::accumulate(l.begin(), l.begin()+i, 0);
          int b = std::accumulate(l.begin()+i, l.begin()+j, 0);
          int c = std::accumulate(l.begin()+j, l.begin()+k, 0);
          if (a == 0 || b == 0 || c == 0) continue;

          int cur = 0;
          cur += 10*(i-1);
          cur += 10*(j-i-1);
          cur += 10*(k-j-1);
          cur += abs(a-A);
          cur += abs(b-B);
          cur += abs(c-C);

          res = std::min(res, cur);
        }
  } while (std::next_permutation(l.begin(), l.end()));

  printf("%d\n", res);
}


Measured memory_bytes: 256
import java.util.*;
	public class Main{
      public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
 		String s = sc.next();
        int n = s.length();
        
        String left = s.substring(0,(n-1)/2);
        String right =s.substring((n+3)/2-1,n);
        
        if(left.equals(right)){
          System.out.println("Yes");
        }else{System.out.println("No");
             }
      }
    }

Measured memory_bytes: 23764
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
X = int(input())
while(True):
    ans = is_prime(X)
    if ans == True:
        print(X)
        break
    X += 1

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

 int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  rep(i,n) {
   cin >> a.at(i);
   }
   
  vector<int> b(n);
  rep(i,n) {
   b.at(a.at(i) - 1) = i + 1;
   } 
 
 rep(i,n) {
  cout << b.at(i) << ' ';}
 
 }

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    ll cnt = 0;
    rep(i, n) {
        if(a[a[i]] == i)
            cnt++;
    }
    cout << cnt / 2 << endl;
}


Measured memory_bytes: 1024
m=->(a,b){b>0?a*m[a-1,b-1]/b:1}
n,a,b=gets.split.map &:to_i
v=gets.split.map &:to_i
v.sort!.reverse!
u=v.take(a)
e=u.inject(0.0){|r,i|r+=i}/u.size
x=y=r=0
n.times{|i|v[i]==v[a-1]&&(x+=1;i<a&&y+=1)}
y<a ?r+=m[x,y] : a.upto(b){|i|r+=m[x,i]}
puts e,r

Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {

       


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);
                int m = int.Parse(Console.ReadLine());
                if (n == 0 && m == 0) { break; }

                bool[,] tomodati = new bool[n, n];
                for (int i = 0; i < m; i++) {
                    int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    tomodati[ints[0]-1, ints[1]-1] = true;
                    tomodati[ints[1]-1, ints[0]-1] = true;
                }

                List<int> tomo = new List<int>();
                for (int i = 0; i < n; i++) {
                    if (tomodati[0, i]) { tomo.Add(i); }
                }
                int tomoCnt = tomo.Count ;
                List<int> tomo_no_tomo = new List<int>();
                tomo.Add(0);
                foreach (int x in tomo) {
                    for (int i = 0; i < n; i++) {
                        if (tomodati[x, i]) {
                            if (tomo.Contains(i) == false && tomo_no_tomo.Contains(i)==false) {
                                tomo_no_tomo.Add(i);
                            }
                        }
                    }                    
                }
                tomoCnt += tomo_no_tomo.Count;
                
                Console.WriteLine(tomoCnt);
            }
        }

        
    }



    
}

Measured memory_bytes: 7052
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int sum = 0;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i)  {
    cin >> v[i];
    sum += v[i];
  }
  int max = *max_element(v.begin(), v.end());
  if (2 * max < sum) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }
  return 0;
}

Measured memory_bytes: 256