akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

bool prime[1000000+1];

void seive(ll n){
	memset(prime,true,sizeof(prime));
	for(ll p=2;p*p<=1000000+1;p++){
		if(prime[p]==true){
			for(ll i=p*p;i<=1000000+1;i+=p){
				prime[i]=false;
			}
		}
	}
}

void solveTest(){
	ll n;
	cin>>n;
	if(n==1){
		cout<<0<<endl;
		return;
	}
	seive(n);
	ll ans=0;
	for(ll p=2;p<=1000000;p++){
		if(prime[p]){
			if(n%p!=0) continue;
			else{
				ll ele =p;
				while(n&&n%p==0){
					if(n%p!=0) break;
					n/=p;
					ans++;
					p*=ele;
				}
				p=ele;
			}
		}
	}
	if(n>1000000)ans++;
	cout<<ans<<endl;
	return ;
}


 
int main(){
	fastio();
	//input();

	solveTest();
	/*int t;
	cin>>t;
	while(t--){
		solveTest();
	}
	*/
	return 0;
}
     

Measured memory_bytes: 4592
no_flag = False
N = int(input())
old_t, old_x, old_y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if not no_flag:
        judge = (t - old_t) - (x - old_x) - (y - old_y)
        if (judge < 0) or (judge % 2):
            no_flag = True
if not no_flag: print('Yes')
else:   print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 


int main()
{	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
		
	
	ll n;
	string s;
	
	cin>>n>>s;
	
	vector <ll> R,G,B;
	ll ans = 0;
	for(ll i=0;i<s.size();++i)
	{
		if(s[i]=='R')
		{
			R.push_back(i);
		}
		if(s[i]=='G')
		{
			G.push_back(i);
		}
		if(s[i]=='B')
		{
			B.push_back(i);
		}
	}
	
	for(ll i=0;i<s.size();i++)
	{
		for(ll j=i+1;j<s.size();j++)
		{
			if(s[i]==s[j])continue;
			ll diff = j-i;
			if((s[i]=='R' || s[j] == 'R') && (s[i]=='G' || s[j]=='G'))
			{
				ll coun = B.end()-lower_bound(B.begin(),B.end(),j+1);
				if(j+diff < s.size())
				{
					if(s[j+diff]=='B')coun--;
				}
				ans += max(0LL,coun);
			}
			if((s[i]=='R' || s[j] == 'R') && (s[i]=='B' || s[j]=='B'))
			{
				ll coun = G.end()-lower_bound(G.begin(),G.end(),j+1);
				if(j+diff < s.size())
				{
					if(s[j+diff]=='G')coun--;
				}
				ans += max(0LL,coun);
			}
			if((s[i]=='B' || s[j] == 'B') && (s[i]=='G' || s[j]=='G'))
			{
				ll coun = R.end()-lower_bound(R.begin(),R.end(),j+1);
				if(j+diff < s.size())
				{
					if(s[j+diff]=='R')coun--;
				}
				ans += max(0LL,coun);
			}
			
			
		}
	}
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 3700
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

LL T,n,i,j,k,x,y,z;
LL a[N],b[N];
char c[N];

map <LL,LL> M;

IL LL Abs(LL x){return (x<0)?-x:x;}
IL void Swap(LL &a,LL &b){a^=b^=a^=b;}
IL LL Min(LL a,LL b){return (a<b)?a:b;}
IL LL Max(LL a,LL b){return (a>b)?a:b;}

IL LL Mi(LL x,LL y,LL MOD){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL LL read(){
	LL p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

LL Gcd(LL a,LL b){return (!b)?a:Gcd(b,a%b);}

inline LL Ex_BSGS(LL x,LL y,LL p){
	register LL i=0,sum=1,s=1,m=0,k=0;
	M.clear();
	while ((s=Gcd(x,p))!=1){
		if (y%s)	return -1;
		sum=sum*(x/s)%p;
		y/=s;	p/=s;	k++;
		if (y==sum)	return k;
	}
	m=(LL)sqrt(p)+1;
	for (i=0;i<=m;i++)	M[y]=i,y=y*x%p;
	s=Mi(x,m,p);	y=s*sum%p;
	for (i=1;i<=m+1;i++){
		if (M[y])	return k+i*m-M[y];
		y=y*s%p;
	}
	return -1;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();
	if (n==7 || n==1){
		puts("1");
		return 0;
	}
	if ((n%7) == 0)	n/=7;
	if ((n%2) == 0){
		puts("-1");
		return 0;
	}
	n*=9;
	x=10;
	for (i=1;i<=4*n;i++){
		if (x%n == 1){
			cout<<i<<endl;
			return 0;
		}
		x=((x*10))%n;
	}
	cout<<"-1"<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;

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

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

  int order[n];
  rep(i, n) {
    int a;
    cin >> a;
    --a;
    order[a] = i + 1;
  }

  rep(i, n) printf("%d%c", order[i], i == n - 1 ? '\n' : ' ');
  return 0;
}


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

int main(void){
    long long int i, j, k, n, ans=0, po=0;
    scanf("%lld", &n);
    long long int a[n+1];
    for(i=0; i<n; i++) scanf("%lld", &a[i+1]);
    for(i=1; i<=n; i++){
        if(i%2 == 1&&a[i]%2 == 1) ans++;
    }
    printf("%lld", ans);
    
}

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


int solve(string s) {
    if (s[1] != '[') {
        int ret;
        stringstream ss;
        ss << s.substr(1);
        ss >> ret;
        return ret / 2 + 1;
    }

    vector<int> thr(0);

    int left = 1, brac = 0;
    for (int j = 1; j < s.size(); ++j) {
        if (s[j] == '[') {
            ++brac;
        } else if (s[j] == ']') {
            --brac;
        }
        if (brac == 0) {
            int v = solve(s.substr(left, j - left + 1));
            thr.push_back(v);
            left = j + 1;
        }
    }

    sort(begin(thr), end(thr));

    int ret = 0;
    for (int j = 0; j < thr.size() / 2 + 1; ++j) {
        ret += thr[j];
    }
    
    return ret;
}

int main () {
    int N;
    string S;
    cin >> N;
    for (int j = 0; j < N; ++j) {
        cin >> S;
        cout << solve(S) << endl;
    }
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    string str;
    cin >> str;
    if(str[2] == str[3] && str[4] == str[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main(){
    long long int N,K;
    cin >> N >> K;
    if(K<N) N=(N%K);
    long long int prevN = N+1;
    while(prevN>N){
        prevN = N;
        N = abs(N-K);
    }
    cout << prevN;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// 関節点、橋、lowlink
// lowlink
typedef pair<int,int> mypair;
void dfs(int v,int p,int &k,vector<int> &ord,vector<int> &low,vector<bool> &used,vector<vector<int> > &g,vector<mypair> &bridge,vector<int> &articulation){
	used[v] = true;
	ord[v] = k++;
	low[v] = ord[v];
	bool isarticulation = false;
	int cnt = 0;
	for(int i=0;i<g[v].size();i++){
		if(!used[g[v][i]]){
			cnt++;
			dfs(g[v][i],v,k,ord,low,used,g,bridge,articulation);
			low[v] = min(low[v],low[g[v][i]]);
			if(~p&&ord[v]<=low[g[v][i]])isarticulation = true;
			if(ord[v]<low[g[v][i]])bridge.push_back( mypair( min(v,g[v][i]), max(v,g[v][i]) ) ) ;
		}
		else if(g[v][i] != p){
			low[v] = min(low[v],ord[g[v][i]]);
		}
	}
	if(p==-1 &&cnt>1)isarticulation=true;
	if(isarticulation)articulation.push_back(v);
}

int main(){
	int v,e;
	cin>>v>>e;
	vector<vector<int> >g(v);
	vector<int> ord(v),low(v);
	vector<int> art;
	vector<mypair> bridge;
	vector<bool> used(v,false);
	int k=0;

	for(int i=0;i<e;i++){
	int s,t;
	cin>>s>>t;
	s--,t--;
	g[s].push_back(t);
	g[t].push_back(s);
	}

	for(int i=0;i<v;i++)if(!used[i])dfs(i,-1,k,ord,low,used,g,bridge,art);
	sort(art.begin(),art.end());
	sort(bridge.begin(),bridge.end());
	//関節点
	//cout<<art.size()<<endl;
	//for(int i=0;i<art.size();i++)cout<<art[i]<<endl;	
	//橋
	cout<<bridge.size()<<endl;
	//for(int i=0;i<bridge.size();i++)cout<<bridge[i].first<<' '<<bridge[i].second<<endl;
	return 0;
}

Measured memory_bytes: 256
import collections as cl
h,w,n = map(int,input().split())
l = []
for i in range(n):
  a,b = map(int,input().split())
  for i in range(3):
    x = a+(i-1)
    if x in [-1,0,1,h,h+1,h+2]:
      continue
    for j in range(3):
      y = b+(j-1)
      if y in [-1,0,1,w,w+1,w+2]:
        continue
      l.append((x-1)*w+y)
#print(l)
p = cl.Counter(l)
q = cl.Counter(p.values())
print((h-2)*(w-2)-sum(q.values()))
for i in range(1,10):
  if i in q.keys():
    print(q[i])
  else:print(0)

Measured memory_bytes: 119920
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	LL A,B;
	cin >> N >> A >> B;
	vector<LL> X(N);
	for(int i=0;i<N;++i){
		cin >> X[i];
	}
	LL ans = 0;
	for(int i=1;i<N;++i){
		if( A*(X[i]-X[i-1]) < B ){
			ans += A*(X[i]-X[i-1]);
		}else{
			ans += B;
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
static const int MAX = 100;

void trace(int A[], int n){
  for(int i=0; i<n; i++ ){
    if(i>0)cout<<' ';
    cout<<A[i];
  }
  cout<<endl;   
}

int bubbleSort(int A[],int N){
  bool flag = true;
  int times = 0;
  for (int i=0; flag; i++ ){
    flag=false;
    for(int j=N-1; j>=i+1; j--){
      if(A[j] < A[j-1]){
        int tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        flag = true;
        times++;
      }
    }
  }
  trace(A,N);
  return times;
}

int main(){
  int n, a[MAX], times;

  cin >> n;

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

  times = bubbleSort(a,n);
  cout << times << endl;

  return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
typedef long long LL;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int h,w,d;
	cin >>h>>w>>d;
	vector<vector<int>> a(h,vector<int>(w));
	rep(i,h)
		rep(j,w)
			cin >>a[i][j];
	vector<pair<int,int>>r(h*w);
	rep(i,h)
		rep(j,w){
			r[a[i][j]-1]=pair<int,int>(i,j);
		}
	vector<LL> s(h*w+1);
	rep(i,h*w)
		s[i]=0;
	for (int i=0;i+d<h*w;++i){
		s[i+d]+=s[i]+abs(r[i].first-r[i+d].first)+abs(r[i].second-r[i+d].second);
	}
	int q;
	cin >>q;
	rep(kk,q){
	int l,r;
	cin >>l>>r;
	cout <<s[r-1]-s[l-1]<<endl;
	}
}

Measured memory_bytes: 2944
#coding:utf-8
# x=int(raw_input())  # 1 # 一つの数字のみ
w, a, b =map(int,raw_input().split())  # 2 3  # 二つの数字
if a ==b:
    print 0
elif a < b:
    if a + w >= b:
        print 0
    else:
        print b-(a+w)
elif a >b:
    if b + w >= a:
        print 0
    else:
        print a-(b+w)




# print x,y,z


Measured memory_bytes: 2568
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  String a=sc.next();
  String b=sc.next();
  System.out.println((a.length()<b.length())?"LESS":(a.length()>b.length())?"GREATER":(a.compareTo(b)<0)?"LESS":(a.compareTo(b)==0)?"EQUAL":"GREATER");
}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<pii> line(n);
  foreach(i,line)i=in<pii>();
  vector<int> mins;
  vector<int> maxs;
  foreach(i,line)mins.emplace_back(i.first);
  foreach(i,line)maxs.emplace_back(i.second);
  sort(all(mins));
  sort(all(maxs));
  ll upper;
  ll downer;
  if(n&1){
    upper = maxs[n/2];
    downer = mins[n/2];
  }else{
    upper = maxs[n/2-1] + maxs[n/2];
    downer = mins[n/2-1] + mins[n/2];
  }

  cout << upper - downer + 1 << endl;
  return 0;
}


Measured memory_bytes: 7256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    int l;
    cin >> l;

    double res = (double)l * l * l / 27.0;
    // cout << res << endl;
    printf("%.6lf\n", res);

	return 0;
}

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

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	ll N,A,B,C,D;

	cin>>N;

	cin>>A>>B>>C>>D;

	ll diff = abs(B - A);
	bool flag =false;	
	for(ll  i = 0; i < N;i++){
		ll downer = C * (N - 1 - i) - D * i;
		ll upper = -C * i + D * (N - 1 - i); 
		
		if(downer <= diff && upper >= diff)flag = true;

	}

	cout<<( flag ? "YES" : "NO")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int a[9];
  int n;
  cin >> n;
  REP(i,9){
    a[i] = 0;
  }

  REP(i,n){
    int b;
    cin >> b;
    if(b/400 <= 7){
      a[b/400]++;
    }
    else{
      a[8]++;
    }
  }

  int min=0,max=0;
  REP(i,8){
    if(a[i] != 0)
      min++;
  }
  max = min+a[8];
  if(min == 0)
    min = 1;


  cout << min << " " << max << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int hit, brow;

void op(int a[4], int b, int i)
{
  for (int j = 0; j < 4; j++){
    if (b == a[j] && i == j){
      hit++;
    }
    else if (b == a[j] && i != j){
      brow++;
    }
  }
}

int main()
{
  int a[4], b[4];
  int i;
  
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]){
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    hit = brow = 0;
    for (i = 0; i < 4; i++){
      op(a, b[i], i);
    }
    
    cout << hit << " " << brow << endl;
  }
}

Measured memory_bytes: 1160
n , q = map(int,input().split())
kuro = (n-2)**2
nowy = n - 1
nowt = n - 1
yoko = [n-1 for i in range(n-1)]
tate = [n-1 for i in range(n-1)]

for _ in range(q):
    p = list(map(lambda x:int(x)-1,input().split()))
    if p[0] == 0:
        if p[1] < nowt:
            kuro -= nowy - 1
            for i in range(p[1],nowt):
                yoko[i] = nowy
            nowt = p[1]
        elif p[1] > nowt:
            kuro -= yoko[p[1]] - 1
    elif p[0] == 1:
        if p[1] < nowy:
            kuro -= nowt - 1
            for i in range(p[1],nowy):
                tate[i] = nowt
            nowy = p[1]
        elif p[1] > nowy:
            kuro -= tate[p[1]] - 1
print(kuro)

Measured memory_bytes: 100320
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define dbg(x) cerr << #x"=" << x << endl;
const int MAX_N = 1e5+100;
const int MOD = 1e9+7;
int n,m;
bool a[MAX_N];
int f[MAX_N];

int main(){
    //freopen("in.txt", "r", stdin);
    cin >> n >> m;
    memset(a, true, sizeof a);
    int x;
    for(int i = 1; i <= m; ++i){
        cin >> x;
        a[x] = false;
    }
    f[0] = 1;
    if(a[1]) f[1] = 1;
    for(int i = 2; i <= n; ++i){
        if(!a[i]) continue;
        f[i] = (f[i-1] + f[i-2]) % MOD;
    }
    cout << f[n] << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m;
    cin>>n>>m;
    ll x=2*m;
    if(n<=x)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<n-x<<endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = scan.nextInt();

        int b = scan.nextInt();
        
        System.out.print( a * b );
        System.out.print(" ");
        System.out.println( (a + b) * 2);     
    } 
}


Measured memory_bytes: 26172
//
//  main.cpp
//
// https://atcoder.jp/contests/abc132/tasks/abc132_d

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

// 重み付き有向グラフ、隣接リスト表現
template <typename INT>
struct ListCostGraph {
    // 辺構造体
    struct Edge {
        size_t from;
        size_t to;
        int cost;
    };
    // 辺のリスト
    vector<vector<Edge>> edges;
    // コンストラクタ
    ListCostGraph(size_t size) {
        edges.resize(size);
    }
    // 辺を追加する
    void add_edge(size_t from, size_t to, INT cost) {
        edges[from].push_back(Edge{from, to, cost});
    }
    // ダイクストラ法 O(E logV)
    vector<INT> dijkstra(size_t s) {
        vector<INT> dist(edges.size(), numeric_limits<INT>::max());
        using P = pair<INT, size_t>;
        constexpr size_t DISTANCE = 0;
        constexpr size_t VERTEX = 1;
        priority_queue<P, vector<P>, greater<P>> que;
        dist[s] = 0;
        que.push(P(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            size_t v = get<VERTEX>(p);
            int d = get<DISTANCE>(p);
            if (dist[v] < d) {
                continue;
            }
            for (int i = 0; i < edges[v].size(); i++) {
                const Edge& e = edges[v][i];
                int new_dist = dist[v] + e.cost;
                if (dist[e.to] <= new_dist) { // eを使っても最短経路が改善しないとき
                    continue;
                }
                dist[e.to] = new_dist;
                que.push(P(new_dist, e.to));
            }
        }
        return dist;
    }
};

int main(int argc, char* argv[]) {
    int N, M;
    cin >> N >> M;
    ListCostGraph<int> graph(3 * N);
    for (int i = 0; i < M; i++) {
        int ui, vi;
        cin >> ui >> vi;
        ui--;
        vi--;
        for (int j = 0; j < 3; j++) {
            graph.add_edge(3 * ui + j, 3 * vi + (j + 1) % 3, 1);
        }
    }
    int S, T;
    cin >> S >> T;
    S--;
    T--;
    S *= 3;
    T *= 3;
    int dist = graph.dijkstra(S)[T];
    if (dist == numeric_limits<int>::max()) {
        cout << -1 << endl;
    } else {
        cout << dist / 3 << endl;
    }
}



Measured memory_bytes: 17792
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long n=1;
    cin>>n;
    long t=n-1;//记录最短步数
    double a=sqrt(n);
   for(int i=2;i<=a;i++){
       if(n%i==0){
            t=n/i+i-2<t? n/i+i-2:t;
       }
   }
    cout<<t;
    return 0;
}


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

int main()
{
    ll n, x;
    cin >> n;
    map<ll, ll>mp;
    for(ll i = 0; i < n; i++){
            //ll x;
       cin >> x;
       mp[x]++;
   // cout << mp[x] << " ";
    }
    //cout<<mp[x]<< " ";
    ll ans = 0;
    for(auto i : mp){
        if(i.second < i.first)
            ans += i.second;
        else
            ans = ans + (i.second - i.first);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9496
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main() {

    int n;
    long long result_anagramWords = 0;

    cin >> n;
    std::unordered_map<std::string, int> wordHash;

    for (int idx=0; idx<n; idx++){
        std::string oneWord;
        cin >> oneWord;
        sort(oneWord.begin(),oneWord.end());
        wordHash[oneWord]++;

    }

    for (auto& p : wordHash){
        result_anagramWords += (long long)p.second*(p.second-1)/2;            
    }

    cout << result_anagramWords << endl;

}


Measured memory_bytes: 10660
s = gets
n = s.to_i
 
six = (1..6).map{|i|6**i}
nine = (1..5).map{|i|9**i}
arr = [1, *six, *nine]
list = [0]
count = 0
loop do
  count += 1
  list = list.flat_map do |i|
    arr.map {|j| i + j }
  end
  list = list.uniq.select{|i| i <= n}
  break if list.any?{|i|i==n}
end
p count

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

int main() {
  string a;
  cin>>a;
  if(a.at(5)=='0'){
    if(a.at(6)=='1'||a.at(6)=='2'||a.at(6)=='3'||a.at(6)=='4'){
      cout<<"Heisei"<<endl;
      return 0;
    }
  }
  cout<<"TBD"<<endl;
  return 0;
}
                             
    


Measured memory_bytes: 3612
program main;

var
	s : string;	
    i : integer;
    ok : boolean;

begin
	ok := false;
	readln(s);
    for i := 1 to length(s) do 
    	if s[i] = '7'
        	then ok := true;
    if (ok)  
    	then writeln('Yes')
    	else writeln('No');
end.

Measured memory_bytes: 1328
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto Comb = new Combination();

    if (N == 2) {
        writeln(1);
        return;
    }

    if (N == 3) {
        writeln(4);
        return;
    }

    long ans = 0;
    auto steps = new long[](N+1);
    
    foreach (k; 2..N+1) {
        steps[k] = Comb.comb(k-1, N-k-1) * Comb.fact(k) % MOD * Comb.fact(N-k-1) % MOD;
    }

    foreach_reverse(k; 2..N+1) {
        if (steps[k] == 0) continue;
        steps[k] = steps[k] - steps[k-1];
        steps[k] = (steps[k] % MOD + MOD) % MOD;
        ans = (ans + steps[k] * k % MOD) % MOD;
    }
    
    ans.writeln;
}

class Combination {
    immutable int MAX = 2*10^^6+1;
    immutable long MOD = 10^^9+7;
    long[] modinv;
    long[] f_mod;
    long[] f_modinv;
    
    this() {
        modinv = new long[](MAX);
        modinv[0] = modinv[1] = 1;
        foreach(i; 2..MAX) {
            modinv[i] = modinv[MOD.to!int % i] * (MOD - MOD / i) % MOD;
        }

        f_mod = new long[](MAX);
        f_modinv = new long[](MAX);
        f_mod[0] = f_mod[1] = 1;
        f_modinv[0] = f_modinv[1] = 1;

        foreach(i; 2..MAX.to!int) {
            f_mod[i] = (i * f_mod[i-1]) % MOD;
            f_modinv[i] = (modinv[i] * f_modinv[i-1]) % MOD;
        }
    }

    long comb(int n, int k) {
        if (n < 0 || k < 0 || n < k) return 0;
        return f_mod[n] * f_modinv[n-k] % MOD * f_modinv[k] % MOD;
    }

    long fact(int n) {
        if (n < 0) return 0;
        return f_mod[n];
    }
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}


Measured memory_bytes: 60284
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;

  vi x(n), y(n);
  vector<pii> p;
  rep(i, n){
    cin>>x[i]>>y[i];
    p.pb(mp(x[i],y[i]));
    dump(x[i],y[i]);
    dump(atan2(y[i], x[i]));
  }
  sort(all(p), [&](auto &left, auto &right)
      {return atan2(left.second, left.first) < atan2(right.second, right.first);}
      );
  dump(p);

  double ans = 0;
  rep(s, n){
    rep(leng, 1, n+1){
      dump(s, leng);
      int cur = s;
      int X = 0;
      int Y = 0;
      rep(_, leng){
        X += p[cur%n].first;
        Y += p[cur%n].second;
        dump(X, Y, sqrt(X*X+Y*Y));
        cur++;
      }
      chmax(ans, sqrt(X*X+Y*Y));
    }
  }
  printf("%.12f", ans);

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 384
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,m,X;
	cin >> n >> m >> X;
	int c[n];
	int a[n][m],ach[m];
	memset(ach,0,sizeof(ach));
	for(int i=0; i<n; i++){
		cin >> c[i];
		for(int j=0; j<m; j++){
			cin >> a[i][j];
			ach[j] += a[i][j];
		}
	}
	bool ac = 1;
	for(int i=0; i<m; i++){
		if(ach[i]<X)ac=0;
	}
	if(!ac){
		cout << -1 << endl;
		return 0;
	}
	int mncost = 1e9;
	for(int i=1; i<(1<<(n)); i++){
		int cur[m]; for(int j=0; j<m; j++)cur[j]=0;
		int cos = 0;
		for(int j=0; j<n; j++){
			if(i&(1<<j)){
				cos += c[j];
				for(int k=0; k<m; k++)cur[k] += a[j][k];
			}
		}
		bool ok = 1;
		for(int j=0; j<m; j++){
			if(cur[j]<X)ok=0;
		}
		if(ok){
			mncost = min(mncost,cos);
		}
	}
	if(mncost==1e9)mncost = -1;
	cout << mncost << endl;
}	


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll gcd(ll a, ll b){
    ll tmp;
    if(a%b == 0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}

const ll SIZE = 1e5+10;

ll a,b;

int main(){
    cin >> a >> b;
    cout << max(0LL,a-b*2) << endl;
    
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

void solve() {
    int n, k;
    cin >> n >> k;
    V<int> B(n, 0);
    rep(i, n) {
        int a;
        cin >> a;
        B[--a]++;
    }
    sort(B.begin(), B.end(), greater<int>());
    int ans = n - accumulate(B.begin(), B.begin() + k, 0);
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3960
h,w,k = map(int , input().split())
c=[]
for i in range(h):
    cc = input()
    c.append(cc)
ans = 0
for i in range(1 << h):
    for j in range( 1 << w):
        cnt = 0
        for kk in range(h):
            for l in range(w):
                if (c[kk][l] == '#' and (not (i & (1 << kk))) and (not (j & (1 << l)))):
                    cnt += 1
        if (cnt == k): ans += 1

print(ans)  

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(){
    set<int> d;
    int a,b,c;
    cin >> a >> b >> c;
    d.insert(a);
    d.insert(b);
    d.insert(c);
    d.size() == 2 ? cout << "Yes" : cout << "No";
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,ans;
int main()
{
	cin>>a>>b;
	if(a==0||b==0)
	{
		if(a>b)
		{
			cout<<abs(a-b)+1<<endl;
			exit(0);
		}
		cout<<abs(a-b)<<endl;
		exit(0);
	}
	if(a>0&&b>0)
	{
		if(a<b)
		cout<<abs(a-b)<<endl;
		else
		cout<<abs(a-b)+2<<endl;
	}
	if(a>0&&b<0||a<0&&b>0)cout<<abs(abs(a)-abs(b))+1<<endl;
	if(a<0&&b<0)
	{
		if(a==b)cout<<0<<endl;
		if(a>b)cout<<abs(abs(a)-abs(b))+2<<endl;
		if(a<b)cout<<abs(abs(a)-abs(b))<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力値
		int k = sc.nextInt();
		int x = sc.nextInt();
		sc.close();
		System.out.println((k*500)>=x?"Yes":"No");
	}
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; i++)
#define FOR2(i, z, n) for(int i=z; i<n; i++)

int main() {
  string str1, str2;
  cin >> str1 >> str2;

  vector<vector<int> > matrix(str1.length() + 1, vector<int>(str2.length() + 1, 0));

  FOR2(i, 1, str1.length() + 1) {
    matrix[i][0] = i;
  }
  FOR2(i, 1, str2.length() + 1) {
    matrix[0][i] = i;
  }

  FOR2(i, 1, str1.length() + 1) {
    FOR2(j, 1, str2.length() + 1) {
      int sub = (str1[i - 1] == str2[j - 1] ? 0 : 1);
      matrix[i][j] = min(min(matrix[i - 1][j] + 1, matrix[i][j - 1] + 1), matrix[i - 1][j - 1] + sub);
    }
  }

  //debug to display the matrix
  /*FOR(i, str2.length() + 1) {
    FOR(j, str1.length() + 1) {
      cout << matrix[j][i] << " ";
    }
    cout << endl;
  }*/

  cout << matrix[str1.length()][str2.length()] << endl;
}


Measured memory_bytes: 6924
import sys
N, M = map(int, input().split())
PS = sys.stdin.read().strip().split()
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum(w if a > 0 else 0 for a, w in zip(ac, wa))
print(sum(ac), penalties)

Measured memory_bytes: 18008
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

    ll A[N], X[N], S = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        S += A[i];
    }

    X[0] = S;
    for(int i = 1; i < N; i+=2) X[0] -= 2 * A[i];
    for(int i = 1; i < N; i++) X[i] = 2 * A[i - 1] - X[i - 1];

    for(int i = 0; i < N; i++) {
        if(i == 0) cout << X[i];
        else cout << " " << X[i];
    }

    return 0;
}

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

const int maxn=5e3+10;
const int mod1=1e9+7,mod2=1e9+9;
int n;
char s[maxn];
int l,r,ret,ans;
int hs1[maxn],pw1[maxn],hs2[maxn],pw2[maxn];

int main()
{
	scanf("%d%s",&n,s+1);
	pw1[0]=pw2[0]=1;
	for(int i=1;i<=n;i++) pw1[i]=1ll*pw1[i-1]*37%mod1,pw2[i]=1ll*pw2[i-1]*37%mod2,hs1[i]=(1ll*hs1[i-1]*37+s[i])%mod1,hs2[i]=(1ll*hs2[i-1]*37+s[i])%mod2;
	l=0,r=n;
	while(l<r)
	{
		int mid=(l+r)>>1;
		int flag=0;
		for(int i=1;i<=n-mid+1&&flag==0;i++)
		{
			int h1=(hs1[i+mid-1]-1ll*hs1[i-1]*pw1[mid]%mod1+mod1)%mod1;
			int h2=(hs2[i+mid-1]-1ll*hs2[i-1]*pw2[mid]%mod2+mod2)%mod2;
			for(int j=i+mid;j<=n-mid+1;j++)
			{
				if(h1==(hs1[j+mid-1]-1ll*hs1[j-1]*pw1[mid]%mod1+mod1)%mod1)
				{
					if(h2==(hs2[j+mid-1]-1ll*hs2[j-1]*pw2[mid]%mod2+mod2)%mod2)
					{
						flag=1;
						break;
					}
				}
			}
		}
		if(flag) l=mid+1,ret=mid;
		else r=mid;
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 384
from collections import Counter

def main():
    h,w,m=map(int,input().split())
    hw=set([tuple(map(int,input().split())) for _ in range(m)])
    hs=Counter([i[0] for i in hw])
    ws=Counter([i[1] for i in hw])
    hh = [hs.most_common()[0]]
    for i in hs.items():
        if i[1] == hh[0][1]:
            hh.append(i)
    ww = [ws.most_common()[0]]
    for i in ws.items():
        if i[1] == ww[0][1]:
            ww.append(i)
    
    for i in hh:
        for j in ww:
            if (i[0], j[0]) not in hw:
                #print(hw, i[0],j[0])
                print(i[1] + j[1])
                return
    else:
        print(hh[0][1]+ww[0][1]-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 121352
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int m,k;

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

	cin>>m>>k;
	int maxi=(1<<m)-1;
	if(k>maxi)
    {
        cout<<-1;
        return 0;
    }
    if(m==1)
    {
        if(k==1)
            cout<<-1;
        else
            cout<<"0 0 1 1";
        return 0;
    }

    for(int i=0;i<=maxi;i++)
        if(i!=k)
            cout<<i<<" ";

    cout<<k<<" ";

    for(int i=maxi;i>=0;i--)
        if(i!=k)
            cout<<i<<" ";

    cout<<k;

	return 0;
}


Measured memory_bytes: 1792
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#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)
using namespace std;

// _________コーディングはここから！！___________
template <typename T = long long, const int sz = 5 * 10000000> struct IO {
    char reader[sz], writer[sz];
    char *now, *now2 = writer;
    IO() {
        reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
        now = reader;
    }
    inline T read() {
        while(*now && *now <= 32) now++;
        if(*now == '-') {
            now++;
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return -res;
        } else {
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return res;
        }
    }
    inline string read_str() {
        string res;
        while(*now and *now != '\n' and *now != ' ') res += *now++;
        now++;
        return res;
    }
    inline void write(T x, char margin = ' ') {
        if(x == 0) {
            putchar('0');
            putchar(margin);
            return;
        }
        if(x < 0) {
            putchar('-');
            x = -x;
        }
        while(x) {
            *now2 = '0' + x % 10;
            now2++;
            x /= 10;
        }
        do {
            now2--;
            putchar(*now2);
        } while(now2 != writer);
        putchar(margin);
    }
    inline void write_str(string s, char margin = ' ') {
        for(auto c : s) putchar(c);
        putchar(margin);
    }
};
IO<int> io;
int n, m, k;
constexpr int MAX = 1e9 + 1;
constexpr int N = 200010;
int a[N], b[N];
main() {
    n = io.read(), m = io.read(), k = io.read();
    rep(i, n) {
        a[i + 1] = io.read() + a[i];
        if(a[i + 1] >= MAX) a[i + 1] = MAX;
    }
    rep(i, m) {
        b[i + 1] = io.read() + b[i];
        if(b[i + 1] >= MAX) b[i + 1] = MAX;
    }
    int now;
    rep(i, n + 1) {
        if(a[i] <= k) now = i;
    }
    int ans = now;
    for(int i = 1; i <= m; i++) {
        if(b[i] > k) break;
        while(b[i] + a[now] > k) now--;
        ans = max(ans, i + now);
    }
    io.write(ans);
}

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

int N;
bitset<2009> A[2009];
bitset<2009> dp[2009];
bitset<2009> kl[2009], kr[2009];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < i; j++) {
			char c; cin >> c;
			if (c == '1') { A[i].set(j); A[j].reset(i); }
			else { A[i].reset(j); A[j].set(i); }
		}
	}
	for (int i = 0; i < N; i++) { dp[i].set(i); }

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j < i; j++) kl[i].set(j);
	}
	for (int i = 0; i <= N; i++) {
		for (int j = i; j < N; j++) kr[i].set(j);
	}

	for (int i = 1; i < N; i++) {
		for (int j = 0; j < N - i; j++) {
			int cl = j, cr = j + i;

			// dp[cl][cr]
			bitset<2009> G1 = (dp[cl + 1] & (dp[cr] & (A[cl] & (kr[cl + 1] & kl[cr + 1]))));
			if (G1.count() >= 1) { dp[cr][cl] = 1; }

			// dp[cr][cl]
			bitset<2009> G2 = (dp[cl] & (dp[cr - 1] & (A[cr] & (kr[cl] & kl[cr]))));
			if (G2.count() >= 1) { dp[cl][cr] = 1; }
		}
	}
	
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (dp[0][i] == 1 && dp[N - 1][i] == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
       Scanner stdIn= new Scanner(System.in);

        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();
        int d = stdIn.nextInt();
        for(;;){
            if(c<=b){
                System.out.println("Yes");
                break;
            }
            c=c-b;
            if(a<=d){
                 System.out.println("No");
                break;
            }
            a=a-d;
        }
    }
}


Measured memory_bytes: 35816
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = self.right = None
    def nextNode(self):
        if not self.right:
            return None
        x = self.right
        while x.left:
            x = x.left
        return x
    def preorder(self):
        L = [self.key]
        if self.left: L += self.left.preorder()
        if self.right: L += self.right.preorder()
        return L
    def inorder(self):
        L = []
        if self.left: L += self.left.inorder()
        L.append(self.key)
        if self.right: L += self.right.inorder()
        return L

def insert(t, z):
    y = None
    x = t
    while x:
        y = x # 親を設定
        x = x.left if z.key < x.key else x.right
    z.parent = y
    if not y: # t が空の場合
        return z
    if z.key < y.key:
        y.left = z # z を y の左の子にする
    else:
        y.right = z # z を y の右の子にする
    return t

def find(t, k):
    x = t
    while x:
        if x.key == k:
            return x
        x = x.left if k < x.key else x.right
    return None

def delete(t, k):
    node = find(t, k)
    delNode(node)

def delNode(node):
    if not node: return
    if not node.left and not node.right: # 子がないとき
        if node == node.parent.left:
            node.parent.left = None
        if node == node.parent.right:
            node.parent.right = None
    elif not node.right: # 左の子だけのとき
        if node == node.parent.left:
            node.parent.left = node.left
        if node == node.parent.right:
            node.parent.right = node.left
        node.left.parent = node.parent
    elif not node.left: # 右の子だけのとき
        if node == node.parent.left:
            node.parent.left = node.right
        if node == node.parent.right:
            node.parent.right = node.right
        node.right.parent = node.parent
    else: # 子が２つのとき
        next = node.nextNode()
        node.key = next.key
        delNode(next)

t = None
m = int(input())
for _ in range(m):
    cmd = list(input().split())
    if cmd[0] == 'insert':
        t = insert(t, Node(int(cmd[1])))
    if cmd[0] == 'find':
        print('yes' if find(t, int(cmd[1])) else 'no')
    if cmd[0] == 'delete':
        delete(t, int(cmd[1]))
    if cmd[0] == 'print':
        print('', *t.inorder())
        print('', *t.preorder())



Measured memory_bytes: 96820
#include<iostream>
#include<algorithm>
using namespace std;
long long int A,B,C,D,t;
int main() {
    cin >> A >> B >> C >> D;
	t = __gcd(C,D);
    t = C * D / t;
	cout << B-A+1-(B/C-(A-1) / C+B / D-(A-1) / D-B / t+(A-1) / t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>

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

	tmp=max(a + b, a - b);
	int ans = max(tmp, a*b);

	cout << ans << endl;
	//rewind(stdin);
	//getchar();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

template <typename T>
void ri(T& x);

int n, a[1000], ans;

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

    ri(n);
    
    for (int i=0; i<n; ++i)
        ri(a[i]);
    
    for (int i=0; i<n; ++i)
        for (int j=i+1; j<n; ++j)
            ans += a[i] * a[j];
        
    cout << ans << endl;

    return 0;
}





template <typename T>
void ri(T& x) {
    char c;
    bool minus = false;
    while ((c=getchar())<'0' || '9'<c)
        if (c == '-') minus = true;
    x = c-'0';
    while ('0'<=(c=getchar()) && c<='9')
        x = 10*x - '0' + c;
    if (minus) x = -x;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	string s, b="", e="", c;
	int q, tmp, r=0;
	cin >> s >> q;
	REP(i, 0, q){
		cin >> tmp;
		if(tmp == 1) ++r;
		else{
			cin >> tmp >> c;
			if(tmp == 1 && r % 2 == 0) b = c + b;
			else if(tmp == 1 && r % 2 == 1) e  += c;
			else if(tmp == 2 && r % 2 == 1)  b = c + b;
			else e = e += c;
		}
	}
	
	if( r % 2 == 0) cout << b+s+e;
	else{
		s = b+s+e;
		for(int i = (int)s.length()-1; i>= 0; i--) cout << s[i];
	}  

}


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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Enumerable.Range(0, n).Select(x => Console.ReadLine()).ToArray();

        var map = new Dictionary<(int c2, int c5, int d), int>();
        foreach (var a1 in a)
        {
            var value = (c2: 0, c5: 0, d: 0);
            var index = a1.IndexOf(".");
            if (index >= 0)
            {
                value.d = a1.Length - index - 1;
            }
            var number = decimal.Parse(a1.Replace(".", ""));
            while (number % 2 == 0) {
                value.c2++;
                number /= 2;
            }
            while (number % 5 == 0)
            {
                value.c5++;
                number /= 5;
            }
            if (!map.ContainsKey(value)) {
                map.Add(value, 0);
            }
            map[value]++;
        }

        var count = 0L;
        foreach (var item1 in map.Keys)
        {
            if (Math.Min(item1.c2, item1.c5) >= item1.d)
            {
                count += (long)map[item1] * (map[item1] - 1) / 2;
            }
        }
        foreach (var item1 in map.Keys)
        {
            foreach (var item2 in map.Keys)
            {
                if (map.Keys.ToList().IndexOf(item1) < map.Keys.ToList().IndexOf(item2))
                {
                    if (Math.Min(item1.c2 + item2.c2, item1.c5 + item2.c5) >= item1.d + item2.d)
                    {
                        count += (long)map[item1] * map[item2];
                    }
                }
            }
        }

        Console.WriteLine($"{count}");
        Console.ReadLine();
    }
}

Measured memory_bytes: 60252