akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#define ab(x) ((x) < 0 ? -(x) : (x))
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a; i <= b; i++) 
#define dep(i,a,b) for(int i = a; i >= b; i--)
using namespace std;
typedef long long LL;
const int N = 100010;

struct point { int x, y, id; } t[N];
inline bool operator < (const point &a, const point &b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }

int n, D, a, b, f[N];
int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
void merge(int a, int b) { a = find(a), b = find(b); if (a != b) f[a] = b; }

void init() {	
	rep(i,1,n) { int a = t[i].x, b = t[i].y; t[i] = (point){a + b, a - b, i}; }
	D = max(ab(t[a].x - t[b].x), ab(t[a].y - t[b].y)); 
}

map<int, int> d; int cnt;
void work_init() {
	cnt = 0; d.clear();
	rep(i,1,n) if (d.find(t[i].y) == d.end()) d[t[i].y] = ++cnt;
}

map<int, int> s[N];
void check(int y, int i, int id) {
	if (d.find(y) == d.end()) return; else y = d[y];
	while (!s[y].empty() && t[i].x - s[y].begin()->first > D) s[y].erase(s[y].begin());
	while (s[y].size() > 1) {
		int tmp = s[y].begin()->second; s[y].erase(s[y].begin()); 
		merge(tmp, id);
	}
	if (!s[y].empty()) merge(s[y].begin()->second, id);
}

void work() {
	work_init(); rep(i,1,cnt) s[i].clear();
	sort(t + 1, t + n + 1);
	rep(i,1,n) {
		check(t[i].y - D, i, t[i].id), check(t[i].y + D, i, t[i].id);
		s[d[t[i].y]][t[i].x] = t[i].id;
	}
}

int ans[N];

int calc(int y, int i) {
	if (d.find(y) == d.end()) return 0; else y = d[y];
	while (!s[y].empty() && t[i].x - s[y].begin()->first > D) s[y].erase(s[y].begin());
	return s[y].size();
}

void cal() {
	work_init(); rep(i,1,cnt) s[i].clear();
	sort(t + 1, t + n + 1);
	rep(i,1,n) {
		ans[t[i].id] += calc(t[i].y - D, i) + calc(t[i].y + D, i);
		s[d[t[i].y]][t[i].x] = t[i].id;
	}
}

void calc() { cal(); rep(i,1,n) swap(t[i].x, t[i].y); cal(); rep(i,1,n) swap(t[i].x, t[i].y); }

int dx[2];
set< pair<int, int> > S;

int main() {
	scanf("%d%d%d",&n,&a,&b);
	rep(i,1,n) scanf("%d%d",&t[i].x,&t[i].y);
	
	init();
	
	rep(i,1,n) f[i] = i; work();
	rep(i,1,n) swap(t[i].x, t[i].y); work(); rep(i,1,n) swap(t[i].x, t[i].y);

	merge(a, b);
	calc(); LL s = 0; rep(i,1,n) if (find(i) == find(a)) s += ans[i];
	dx[0] = -D, dx[1] = D;
	rep(i,1,n) S.insert(mp(t[i].x, t[i].y));
	rep(i,1,n) if (find(t[i].id) == find(a)) {
		rep(j,0,1) if (S.find(mp(t[i].x + dx[j], t[i].y - D)) != S.end()) s--;
	}
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 20864
#include<bits/stdc++.h>
using namespace std;
long long  a[6],b[6],n=5,sum,mn=333339;
int main() {
    for(int i=0;i<n;i++){
    	cin>>a[i];//29 20 7 35 120
     	b[i]=a[i]%10;
	}
	for(int i=0; i<n; i++){
		if(b[i] != 0)
			mn = min(b[i],mn);
	}
	for(int i=0; i<n; i++){
		if(b[i] == mn){
			sum += a[i];
			a[i] = 0;
			break;
		}
	}
	for(int i=0; i<n; i++){
		if(a[i]%10 != 0)
			sum += a[i] +10 - a[i]%10;
		else
			sum += a[i];
	}
	cout<<sum;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)
ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}
ll lcm(ll p,ll q){return p/gcd(p,q)*q;}

ll a,b,c,d;
ll f(ll n){
	ll X=lcm(c,d);
	return n-n/c-n/d+n/X;
}
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	printf("%lld",f(b)-f(a-1));
}

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

int main() {
int x,y,a,b,c;
cin >> x >> y;
a=b=c=-1;

for(int i=0;i<=x;i++){
    for(int j=0;j<=x-i;j++){
        if(10*i+5*j+x-i-j==y/1000){
            a=i;
            b=j;
            c=x-i-j;
            x=0;
        }
    }
}


cout << a << " " << b << " " << c << endl;

	return 0;
}

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

int n,ma,mb;
int a[40],b[40],c[40];
map<pair<int,int>,int> min_cost;

void res(int cur,pair<int,int> m,int used[]){
    if(min_cost[m]==0)min_cost[m]=cur;else if(min_cost[m]>cur)min_cost[m]=cur;else return;
    for(int i=0; i<n; i++)
        if(!used[i]){
            used[i]=true;
            res(cur+c[i],make_pair(m.first+a[i],m.second+b[i]),used);
            used[i]=false;
        }
}

int main(){
    cin>>n>>ma>>mb;
    int used[n];for(int i=0; i<n; i++)used[i]=0;
    for(int i=0; i<n; i++){int in1,in2,in3;cin>>in1>>in2>>in3;a[i]=in1;b[i]=in2;c[i]=in3;}
    res(0,make_pair(0,0),used);
    bool flag=true;
    long long mini=(1<<21);
    for(int i=1; i<401; i++)
        if(min_cost[make_pair(ma*i,mb*i)]!=0&&mini>min_cost[make_pair(ma*i,mb*i)]){
            flag=false;
            mini=min_cost[make_pair(ma*i,mb*i)];
        }
    if(flag)cout<<-1<<endl;else cout<<mini<<endl;
    return 0;
}


Measured memory_bytes: 1664
S = input()
NG = ['B','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = 'AC'
if S[2:-1].count('C') != 1:
  ans = 'WA'
for i in range(len(S)):
  if i == 0 and S[0] != 'A':
    ans = 'WA'
    break
  elif i == S[2:-1].find('C'):
    continue
  elif S[i] in NG:
    ans = 'WA'
print(ans)    

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

		// 整数の入力
		int ttl = sc.nextInt();
		int cake = sc.nextInt();
		int dnt = sc.nextInt();

		ttl = ttl-cake;
		ttl = ttl%dnt;

		System.out.println(ttl);

		sc.close();
	}
}


Measured memory_bytes: 21844
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn mod_pow(mut b: u64, mut e: u64, m: u64) -> u64 {
    let mut res = 1;

    while (e > 0) {
        if ((e & 1) == 1) {
            res = (res * b) % m;
        }
        e >>= 1;
        b = (b * b) % m;
    }
    res
}
const MOD: u64 = 998244353;
fn main() {
    input! {
        n: usize,
        d: [usize; n],
    }
    if d[0] != 0 {
        return println!("0")
    }
    let mut counts:Vec<u64> = vec![0; n+1];
    for i in 0..n {
        counts[d[i]] += 1;
    }
    if counts[0] != 1 {
        return println!("0")
    }

    let mut res = 1u64;
    for i in 1..n+1 {
        res *= mod_pow(counts[i-1], counts[i], MOD);
        res %= MOD;
    }
    println!("{}", res%MOD)
}





Measured memory_bytes: 6396
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    while(cin>>a>>b) {
        a+=b;
        for(b=1; (a/=10)!=0; ++b);
        cout<<b<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3136
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 2005;
int a[N], n, m, k;
string s;
int cache[N][2][5];

int dp(int pos, int tight, int cnt)
{
	if (pos == n)
		return cnt == k;
	if (cnt > k)
		return 0;

	int &ans = cache[pos][tight][cnt];
	if (ans != -1)
		return ans;

	ans = 0;
	if (tight)
	{
		for (int i = 0; i < s[pos] - '0'; i++)
			ans += dp(pos + 1, 0, cnt + (i != 0));

		ans += dp(pos + 1, 1, cnt + (s[pos] != '0'));
	}
	else
	{
		for (int i = 0; i < 10; i++)
			ans += dp(pos + 1, 0, cnt + (i != 0));
	}

	return ans;

}

void solve()
{
	cin >> s;
	cin >> k;
	n = sz(s);
	memset(cache, -1, sizeof cache);
	cout << dp(0, 1, 0);

}

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

	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)
#define mod 998244353

int main(void)
{
    fastio;

    int n,c,v[25],ans=0,i;
    cin >> n;
    for(i=0;i<n;i++)cin >> v[i];
    for(i=0;i<n;i++)
    {
        cin >> c;
        if(v[i]>c)ans=ans+v[i]-c;
    }
    cout << ans ;

    return 0;
}


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
double dp[605],p[605];
bool v[605][605];
int n,l[605]; 
int main(){
	int m;
	scanf("%d%d",&n,&m);
	int x,y;
	FOR(i,1,m){
		scanf("%d%d",&x,&y);
		v[x][y]=1;
		l[x]++;
	}
	for(int i=n-1;i>=1;i--){
		FOR(j,i+1,n){
			if(v[i][j])dp[i]+=(dp[j]+1)/l[i];
		}
	}
	double ans=dp[1];
	for(int k=n-1;k>=1;k--){
		if(l[k]==1){
			p[k]=dp[k];continue;
		}
		int maxi=0;
		FOR(i,k+1,n){
			if(dp[i]>dp[maxi]&&v[k][i])maxi=i;
		}
		p[k]=0;
		FOR(i,k+1,n){
			if(i!=maxi&&v[k][i]){
				p[k]+=(dp[i]+1)/(l[k]-1);
			}
		}
		for(int i=k-1;i>=1;i--){
			p[i]=0;
			FOR(j,i+1,n){
				if(v[i][j])p[i]+=(p[j]+1)/l[i];
			}
		}
		ans=min(ans,p[1]);
		p[k]=dp[k];
	}
	printf("%.10f",ans);
	RE 0;
}





Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  double R;
  cin >> R;
  double ans=2*R*M_PI;
  cout << ans << endl;
}

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

#define rep(i, j, k) for(int i = (int) j; i < (int) k; ++i)
#define sz(x) ((int) (x).size())
#define ll long long
#define mp make_pair
#define pii pair<int, int >
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define zero(x) memset((x), (0), sizeof (x))
#define zerox(x, y) memset((x), (y), sizeof (x))

using namespace std;

int main()
{
#ifdef PIT
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
#endif //PIT

	ios_base::sync_with_stdio(false); cin.tie(0);
	int X, t;
	cin >> X >> t;
	cout << max(0, X-t) << endl;
	
#ifdef PIT
flush(cout);
cerr << endl << "Time: " << (clock() / double(CLOCKS_PER_SEC)) << endl;
#endif //PIT
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)


#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

int main() {
  int n;
  cin>>n;
  nvec(long,a,n);nvec(long,b,n);nvec(long,c,n);
  sort(all(a));sort(all(b));sort(all(c));
  long cnt=0;

  for(auto& e:b){
    cnt+=count_lt(a,e)*count_gt(c,e);
  }
  cout<<cnt;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

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

	string s, t;
	cin >> s >> t;
	int i, c = 0;
	rep(i, 0, s.length())
	{
		if(s[i] != t[i])
			c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 3796
import sys
n=int(input())
x1=[int(i)for i in input().split()]
for i in range(n-1):
    x2=[int(i)for i in input().split()]
    for i in range(6):
        if x2[i]==x1[0]:
            count=i
            if x2[5-i]==x1[5]:
                break
    if x2[count]==x1[0] and x2[5-count]==x1[5]:
        if count==0 or count==5:
            if count==5:
                for i in range(2):
                    x2[1],x2[0]=x2[0],x2[1]
                    x2[5],x2[1]=x2[1],x2[5]
                    x2[4],x2[5]=x2[5],x2[4]
        else:
            if count==1 or count==4:
                while x1[0]!=x2[0] or x1[5]!=x2[5]:
                    x2[1],x2[0]=x2[0],x2[1]
                    x2[5],x2[1]=x2[1],x2[5]
                    x2[4],x2[5]=x2[5],x2[4]
            else:
                while x1[0]!=x2[0] or x1[5]!=x2[5]:
                    x2[3],x2[0]=x2[0],x2[3]
                    x2[5],x2[3]=x2[3],x2[5]
                    x2[2],x2[5]=x2[5],x2[2]
        for i in range(4):
            if x2[2]==x1[2] and x2[3]==x1[3] and x2[4]==x1[4] and x2[1]==x1[1] :
                print('No')
                sys.exit()
            else:
                x2[1],x2[2]=x2[2],x2[1]
                x2[2],x2[4]=x2[4],x2[2]
                x2[4],x2[3]=x2[3],x2[4]
print('Yes')

Measured memory_bytes: 7916
N,x = list(map(int,input().split()))
A = list(sorted(list(map(int,input().split()))))
for i in range(N,0,-1):
    if sum(A[:i]) == x:
        print(i)
        break
    elif sum(A[:i]) < x and i == N:
        print(i-1)
        break
    elif sum(A[:i]) < x and i != N:
        print(i)
        break
else:
  print(0)

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

int c[505],s[505],f[505];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<n; i++)
        scanf("%d%d%d",&c[i],&s[i],&f[i]);
    for(int i=1; i<=n; i++)
    {
        int ans = 0;
        for(int j=i; j<n; j++)
        {
            if(ans<s[j])
                ans=s[j];
            if(ans%f[j]!=0)
                ans+=f[j]-ans%f[j];
            ans+=c[j];
        }
        printf("%d\n",ans);
    }
    return 0;
}


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

using namespace std;
#define ll long long
const int MAXN = 2e5 + 1;
int mass[301][301];
int ans[301][301];
int summcolomn[301];
vector<int> res;
ll rec(int d, ll c, int &who){
    if(c==1){
        who=d;
        return 0;
    }
    if(c%2==0){
        if(d>=5){
            int h=d*2;
            h=h%10+h/10;
            return c+rec(h,c/2, who);
        }
        else{
            return c/2+rec(d*2,c/2, who);
        }
    }
    else{
        if(d>=5){
            int h=d*2;
            h=h%10+h/10;
            ll ans1=c-1+rec(h,c/2, who);
            if(who+d<=9) {
                who+=d;
                return ans1+1;
            }
            else{
                who+=d;
                who=who/10+who%10;
                return ans1+2;
            }

        }
        else{
            ll ans1=c/2+rec(d*2,c/2, who);
            if(who+d<=9) {
                who+=d;
                return ans1+1;
            }
            else{
                who+=d;
                who=who/10+who%10;
                return ans1+2;
            }
        }
    }
}
void solve() {
    int m;
    cin>>m;
    ll ans=0;
    for(int i=0;i<m;i++){
        int d;
        ll c;
        cin>>d>>c;
        int h;
        ans+=rec(d,c, h);
        res.push_back(h);
    }
    /*cout<<ans<<endl;
    for(int i=0;i<res.size();i++){
        cout<<res[i]<<" ";
    }*/
    for(int i=0;i<res.size()-1;i++){
        int now=res[i];
        int last=res[i+1];
        if(now+last>9){
            now+=last;
            ans+=2;
            res[i+1]=now%10+now/10;
        }
        else{
            ans++;
            res[i+1]=now+last;
        }
    }
    cout<<ans;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 1400
S = input()
a = int(S[:2]) < 13 and S[:2] != '00'
b = int(S[2:]) < 13  and S[2:] != '00'


if a and b:
    print('AMBIGUOUS')
elif a and not b:
    print('MMYY')
elif (not a) and b:
    print('YYMM')
else:
    print('NA')

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

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

	vector<int> a(M);
	for (int i = 0; i < M; ++i) {
		cin >> a[i];
	}

	int sum = reduce(a.begin(), a.end());

	int answer = N - sum;
	if (answer >= 0) {
		cout << answer << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3232
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

//??°?????????????????°

void function()
{
	//??¢??°
}

int main()
{
	int a[4][3][10] = { 0 };
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] += v;
	}

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
		if (i != 3)
		{
			cout << "####################" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double


lin a,b,q;
lin s[100001],t[100001],x[100001];
lin slt[100001],srt[100001],tls[100001],trs[100001];

int search(lin* p, lin val, int mn, int mx)
{
    if(mn == mx)
        return mn;

    int md = (mn + mx) / 2;
    if(p[md] >= val)
        return search(p, val, mn, md);
    else
        return search(p, val, md+1, mx);    
}

bool valid_b(int bb)
{
    return 0 <= bb && bb < b;
}

bool valid_a(int aa)
{
    return 0 <= aa && aa < a;
}

lin calc_ts(lin xx, int bb, int aa)
{
    if(!valid_a(aa))
        return -1;

    return abs(xx-t[bb]) + abs(t[bb]-s[aa]);    
}

lin calc_t(lin xx, int bb)
{
    if(!valid_b(bb))
        return -1;

    lin cand1 = calc_ts(xx, bb, tls[bb]);
    lin cand2 = calc_ts(xx, bb, trs[bb]);

    if(cand1 >= 0 && cand2 >= 0)
        return min(cand1, cand2);
    else if(cand1 >= 0)
        return cand1;
    else if(cand2 >= 0)
        return cand2;
    else
        return -1;
}

lin calc_st(lin xx, int aa, int bb)
{
    if(!valid_b(bb))
        return -1;

    return abs(xx-s[aa]) + abs(s[aa]-t[bb]);    
}

lin calc_s(lin xx, int aa)
{
    if(!valid_a(aa))
        return -1;

    lin cand1 = calc_st(xx, aa, slt[aa]);
    lin cand2 = calc_st(xx, aa, srt[aa]);

    if(cand1 >= 0 && cand2 >= 0)
        return min(cand1, cand2);
    else if(cand1 >= 0)
        return cand1;
    else if(cand2 >= 0)
        return cand2;
    else
        return -1;
}

lin calc(lin xx)
{
    int aa = search(s, xx, 0, a-1);
    int bb = search(t, xx, 0, b-1);

    //cout << xx << " " << aa << " " << bb << endl;

    lin cand[4];
    cand[0] = calc_s(xx, aa);
    cand[1] = calc_s(xx, aa-1);
    cand[2] = calc_t(xx, bb);
    cand[3] = calc_t(xx, bb-1);

    lin res = -1;
    rep(i,4)
    {
        if(cand[i] < 0)
            continue;

        if(res < 0)
            res = cand[i];
        else
            res = min(res, cand[i]);
    }

    return res;
}

int main(void)
{
    cin >> a >> b >> q;
    rep(i,a)
    {
        cin >> s[i];
    }
    rep(i,b)
    {
        cin >> t[i];
    }
    rep(i,q)
    {
        cin >> x[i];
    }

    int p = 0;
    rep(i,a)
    {
        while(p < b && s[i] > t[p])
        {
            p++;
        }
        srt[i] = p;
        //cout << srt[i];
    }
    //cout << endl;

    p = 0;
    rep(i,b)
    {
        while(p < a && t[i] > s[p])
        {
            p++;
        }
        trs[i] = p;
        //cout << trs[i];
    }
    //cout << endl;

    p = b-1;
    for(int i = a - 1; i >= 0; i--)
    {
        while(p >= 0 && s[i] < t[p])
        {
            p--;
        }
        slt[i] = p;
        //cout << slt[i];
    }
    //cout << endl;

    p = a-1;
    for(int i = b - 1; i >= 0; i--)
    {
        while(p >= 0 && t[i] < s[p])
        {
            p--;
        }
        tls[i] = p;
        //cout << tls[i];
    }
    //cout << endl;

    rep(i,q)
    {
        cout << calc(x[i]) << endl;
    }

    return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int A=0,B=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='A') A++;
        else B++;
    }
    if(A==2||B==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3604
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn pow(b: u64, p: usize) -> u64 {
    if p == 0 {
        1
    } else if p == 1 {
        b
    } else if p % 2 == 0 {
        pow(b * b, p / 2)
    } else {
        pow(b * b, p / 2) * b
    }
}

fn main() {
    let mut sc = Scanner::new();
    let a: i32 = sc.cin();
    let b: i32 = sc.cin();
    let c: i32 = sc.cin();
    let d: i32 = sc.cin();
    put!(if (a-b).abs()<=d && (b-c).abs()<=d || (a-c).abs()<=d { "Yes" } else { "No" });
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

using namespace std;

int
main(void){	
	string s; int k;
	cin >> s;
	cin >> k;
	vector<string> vec;
	for(int i = 0; i < s.size(); i++){
		string ins = "";
		for(int j = i; j < min(i + 5, (int)s.size()); j++){
			ins += s[j];
			vec.push_back(ins);
			//cout << ins << "\n";
		}
	}
	vector<string> ans;
	sort(vec.begin(), vec.end());
	ans.push_back(vec[0]);
	for(int i = 1; i < vec.size(); i++){
		if(vec[i] != vec[i - 1])
			ans.push_back(vec[i]);
	}
	cout << ans[k - 1];
	//cout << vec[k - 1];
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);
  vector<ll> b(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  ll l = 0;
  for (ll i = 0; i < n; ++i) {
    if (n%2 == 0) {
      l = a[n/2-1] + a[n/2];
    } else {
      l = a[(n+1)/2-1];
    }
  }

  ll r = 0;
  for (ll i = 0; i < n; ++i) {
    if (n%2 == 0) {
      r = b[n/2-1] + b[n/2];
    } else {
      r = b[(n+1)/2-1];
    }
  }

  cout << r-l+1 << endl;

  return 0;
}


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

struct ModInt {
    using M = ModInt;

    static vector<M> fact, finv;
    static long long MOD;
    long long v;

    // normalize: [-MOD, MOD**2] -> [0, MOD)
    ModInt(const long long _v = 0) : v((_v < 0) ? _v % MOD + MOD : _v % MOD) {}

    M operator+(const M& x) const { return M(v + x.v); }
    M operator-(const M& x) const { return M(v - x.v); }
    M operator*(const M& x) const { return M(v * x.v); }
    M operator/(const M& x) const { return M(v * x.inv().v); }
    M& operator+=(const M& x) { return *this = *this + x; }
    M& operator-=(const M& x) { return *this = *this - x; }
    M& operator*=(const M& x) { return *this = *this * x; }
    M& operator/=(const M& x) { return *this = *this / x; }
    bool operator==(const M& x) const { return v == x.v; }
    bool operator!=(const M& x) const { return v != x.v; }
    friend istream& operator>>(istream& input, M& x) {
        return input >> x.v, x = M(x), input;
    }
    friend ostream& operator<<(ostream& output, const M& x) {
        return output << x.v;
    }
    inline M pow(long long n) const {
        M x(v), res(1);
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
    inline M inv() const { return this->pow(MOD - 2); }
    static void build(int n) {
        fact.assign(n + 1, 1);
        for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
        finv.assign(n + 1, fact[n].inv());
        for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
    }
    static M comb(int n, int k) {
        if (n < k || k < 0) return M(0);
        return fact[n] * finv[n - k] * finv[k];
    }
    static M extgcd(int a, int b, int& x, int& y) {
        M d(a);
        if (b) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.length();
    ModInt::build(n + k);
    ModInt ans = 0;
    for (int i = 0; i <= k; i++) {
        ModInt tmp = ModInt::comb(i + n - 1, n - 1);
        tmp *= ModInt(25).pow(i) * ModInt(26).pow(k - i);
        ans += tmp;
    }
    cout << ans << endl;
}

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

int c[114514];
int big;

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		if (a >= 100001)big++;
		else c[a]++;
	}
	for (int i = 1; i <= 100000; i++) {
		if (c[i] >= i)big += c[i] - i;
		else big += c[i];
	}
	cout << big << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll nCrmod(ll n,ll r){ll x=1,y=1; rep(i,r){x=x*(n-i)%mod; y=y*(i+1)%mod;} return x*powmod(y,mod-2)%mod;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,sum=0;
	cin >> n;
	map<string,ll> m;
	rep(i,n){
		string s;
		cin >> s;
		m[s]++;
		chmax(sum,m[s]);
	}
	vs ans;
	for(auto&& e:m){
		if(e.second==sum) ans.pb(e.first);
	}
	sort(all(ans));
	for(auto&& e:ans) cout << e << endl;
	return 0;
}

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

int main(){
  int n;
  int pr[10000] = {1,1}, ans[10001] = {0};
  vector<int> prime;

  for(int i=2; i<10000; i++){
    if(pr[i] == 0)
      prime.push_back(i);
    for(int j=i*i; j<10000; j+=i)
      pr[j] = 1;
  }
  
  for(int i=0; i<prime.size(); i++){
    int xx = 0;
    for(int j=i; j>=0; j--){
      xx += prime[j];
      if(xx > 10000)
	break;
      ans[xx]++;
    }
  }

  while(cin >> n && n)
    cout << ans[n] << endl;

  return 0;
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define watch(x) cout << (#x) << " is " << (x) << endl;

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

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

void solve() {
    vector<int> v;
    int tc = 3;
    while(tc--) { int a; cin >> a; v.pb(a); }
    sort(allof(v));
    if(v[0]==5 and v[1]==5 and v[2]==7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



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

int main()
{
    int n;
    cin>>n;
    int a[n];
    a[0]={0};
    unordered_map<int, int> m;
    for(int i=1;i<n;++i)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    for(int i=1;i<=n;++i)
    cout<<m[i]<<endl;
    return 0;
}

Measured memory_bytes: 12176
#include <iostream>
#include <string>

using namespace std;


int main()
{
	int A, B;
	string op;

	cin >> A >> op >> B;

	if (op == "+") {
		cout << A + B << endl;
	}
	else if (op == "-") {
		cout << A - B << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define ld long double
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << std::endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 100 + 10;
const int M = 1e5;
// make sure N size is correctttt!!!!!!!!!

int n, w[N], val[N], dp[N][M+10], WT;

int solve(int idx, int values){
   if(values < 0){
      return inf;
   }
   if(idx >= n){
      if(values != 0)return inf;
      return 0;
   }
   int &ans = dp[idx][values];
   if(ans != -1)
      return ans;
   ans = inf;
   ans = min({ans, w[idx] + solve(idx+1, values-val[idx]), solve(idx+1, values)});
   return ans;
}

int32_t main(){_

   cin>>n>>WT;

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

   memset(dp, -1, sizeof dp);
   
   int ans = 0;
   for (int i = 1; i <= M; ++i)
   {
      int tt = solve(0, i);//exactly i values
      if(tt <= WT){
         ans = i;
      }
   }

   cout<<ans;
   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 86272
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;


int main ()
{
  prep();
  long long n;
  cin >> n;
  int arr[n];
  int freqs[100001] = {0};
  int nextodd = 0;
  int nexteven = 0;
  int next = 0;
  for (int i=0; i<n; i++){
      cin >> arr[i];
      freqs[arr[i]]++;
  }
  int evens = 0;
  int odds = 0;
  int singles = 0;
  for (int i=1; i<=100000; i++){
      if (freqs[i] == 1){
          singles++;
          continue;
      }
      if (freqs[i] == 0){
          continue;
      }
      if (freqs[i]%2 == 0){
          evens++;
      }else{
          odds++;
      }
  }
  
  cout << singles-(evens%2 != 0)+odds+evens;
  return 0; 
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int a;
    string s;
    cin >> a >> s;
    cout << (a >= 3200 ? s : "red") << endl;

    return 0;
}

Measured memory_bytes: 256
//---------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                        NEVER  GIVE  UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({a*c,a*d,b*c,b*d});
	return 0;
}


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

int main() {
    int i,j,k;
    string s;
    cin >> s;
  
  if(s=="Sunny")
  {
    cout <<  "Cloudy"<< endl;
  }else if(s=="Cloudy")
  {
        cout <<  "Rainy"<< endl;

  }else{
    cout << "Sunny"<<endl;
  }
}


Measured memory_bytes: 256
def slove():
    import sys
    import heapq
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    heapq.heapify(a)
    bc = [[c, b] for b, c in [list(map(int, input().rstrip('\n').split())) for _ in range(m)]]
    bc.sort(reverse=True)
    for c, b in bc:
        for i in range(b):
            p = heapq.heappop(a)
            if p < c:
                heapq.heappush(a, c)
            else:
                heapq.heappush(a, p)
                break
    print(sum(a))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 100352
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin>>s>>t;
    cout<<t +s<<endl;
    return 0;
}





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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi p(n);
    rep(i,n){
        int a; cin>>a;
        p[a-1]++;
    }
    sort(all(p));
    vi sum(n+1,0);
    rep(i,n) sum[i+1]=sum[i]+p[i];
    FOR(k,1,n){
        int l=0, r=n/k+1; //L OK, R NG
        while(r-l>1){
            int mid = (l+r)/2;
            int itr = lower_bound(all(p),mid)-p.begin();
            ll val = sum[itr]+(n-itr)*mid;
            if (val>=mid*k){
                l = mid;
            }else{
                r = mid;
            }
        }
        cout<<l<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	long long x, y, z;
	cin >> x >> y >> z;
	if (x != 0) {
		x--;
		cout << y / z - x / z << endl;
	}
	else {
		cout << y / z + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        int length = S.length();
        char[] data = S.toCharArray();
        int answer = 0;
        for (int i = 1; 2*i < length; i++) {
            int remain = length - 2*i;
            int len = remain / 2;
            boolean found = true;
            for (int j = 0; j < len; j++) {
                if (data[j] != data[len + j]) {
                    found = false;
                    break;
                }
            }
            if (found) {
                answer = remain;
                break;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		char c[] = sc.nextLine().toCharArray();
		
		int num1 = Character.getNumericValue(c[0]);
		
		int num2 = Character.getNumericValue(c[1]);

		int num3 = Character.getNumericValue(c[2]);
		
		int count = 0;
		
		if(num1 == 1){
			count++;
		}
		
		if(num2 == 1){
			count++;
		}
		
		if(num3 == 1){
			count++;
		}
		
		System.out.println(count);
		
	}

}


Measured memory_bytes: 22864
package main

import "fmt"

func pow(x, n int) int {
	ans := 1
	for i := 0; i < n; i++ {
		ans *= x
	}
	return ans
}

func main() {
	var x int
	fmt.Scan(&x)

	ans := 0
	for b := 1; b < 32; b++ {
		tmp := 0
		for p := 2; p < 10; p++ {
			if x < pow(b, p) {
				break
			}
			tmp = pow(b, p)
		}
		if ans < tmp {
			ans = tmp
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512