akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) {
  for (auto &e : vec) cout << e << " \n"[&e==&vec.back()];
}

template <class T>
void OUTS(vector<vector<T>> &df) {
  for (auto &vec : df) OUTS(vec);
}

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) {
  for (auto &e : vec) cout << e << "\n";
}

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(string, s);
  for (auto &e : s) {
    if (e == '1') e = '9';
    else e = '1';
  }
  OUTL(s);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
int main() {
 
    int a;
    int count=0;
    cin>>a;

    vector<int>vec;

    int j;
    for(int i=0;i<a;i++) {
        cin>>j;
        vec.push_back(j);
    }

    sort(vec.begin(),vec.end());

    int k=0;
    int middle = vec.size()/2;
    if(vec[middle] != vec[middle-1] ){
        k= vec[middle] - vec[middle-1];
    }

    cout<<k;

    return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,z;
string s,t;
//vll a;
// <------------- Implement Functions Here ----------> //

ll treasue[4000][4000];
ll dp[4000][4000][4];

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m >> k;
	for(ll i=0;i<k;i++) {
		cin>>x>>y>>z;
		treasue[x][y] = z;
	}

	for(ll i=1;i<=n;i++) {
		for(ll j=1;j<=m;j++) {
			dp[i][j][0] = max({ dp[i-1][j][3],dp[i-1][j][2],dp[i-1][j][1],dp[i-1][j][0] ,dp[i][j-1][0]});
			dp[i][j][1] = max({max({ dp[i][j-1][0], dp[i-1][j][3],dp[i-1][j][2],dp[i-1][j][1],dp[i-1][j][0] } ) + treasue[i][j], dp[i][j-1][1]});
			dp[i][j][2] = max({dp[i][j-1][1] + treasue[i][j], dp[i][j-1][2]});
			dp[i][j][3] = max({dp[i][j-1][2] + treasue[i][j], dp[i][j-1][3]});
		}
	}

	cout<<max({dp[n][m][0],dp[n][m][1],dp[n][m][2],dp[n][m][3] }); newl;

}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 377760
N = int(input())
cnt = [0] * (N + 1)

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            check = x*x + y*y + z*z + x*y + y*z + z*x
            if check <= N:
                cnt[check] += 1

for i in range(1,N+1):
    print(cnt[i])

Measured memory_bytes: 9248
S = list(input())
Q = int(input())
q = [input().split() for _ in range(Q)]

S_tmp = str(S)
Sl = []
Sr = []
flg_inv = 0
for i, qi in enumerate(q):
    if qi[0] == '1':
        flg_inv = 1 - flg_inv
    else:
        Fi = int(qi[1])
        Ci = qi[2]
        if (Fi == 1 and flg_inv == 0) or (Fi == 2 and flg_inv == 1):
            Sl.append(Ci)
        else:
            Sr.append(Ci)

# print("#", Sl, S, Sr, flg_inv)
if flg_inv == 0:
    ans = ''.join(Sl[::-1] + S + Sr)
else:
    ans = ''.join(Sr[::-1] + S[::-1] + Sl)

print(ans)

Measured memory_bytes: 46556
#include<iostream>
#include<stdlib.h>

using namespace std;

int main(){

  int A,B,C,D,E;
  int i;
  int time;
  int tap;

  while(cin >> A >> B >> C >> D >> E){
    time = 0;
    
    if(A < 0){
      for(i=A; i<0; i++){
	time += C;
      }
      time += D;
      for(i=0; i<B; i++){
	time += E;
      }
    } else if(A > 0){
      tap = B-A;
      for(i=0; i<tap; i++){
	time += E;
      }
    }
    cout << time << endl;
  }
}


Measured memory_bytes: 3100
import sys
n = int(input())
lst = list(map(int, input().split()))
res = 0
for p in range(200):
  for i in range(n):
    if lst[i] % 2 == 1:
      print(res)
      sys.exit()
  lst = [int(j / 2) for j in lst]
  res += 1

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

int selectionSort(int A[],int N) {
  int sw=0;
  for (int i=0; i<N-1; i++) {
    int minj=i;
    for (int j=i; j<N; j++) {
      if (A[j]<A[minj]) {
        minj=j;
      }
    }
    int t=A[i];
    A[i]=A[minj];
    A[minj]=t;
    if (i!=minj) {
      sw++;
    }
  }
  return sw;
}
int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  int sw=selectionSort(A,N);
  for (int i=0; i<N; i++) {
    cout << (i==0?"":" ") << A[i] << flush;
  }
  cout << endl;
  cout << sw << endl;
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
ll dp[100100];
 
int main() {
     string s;
     cin >>s;
     int ans =0;
     rep(i,3){
         if(s[i]=='1'){
            ans++;
         }
     }
     cout << ans <<endl;
}
  

Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int ans=0;
        
      for(int a=1;a<=n;a++){
		for(int c=1;c<Math.sqrt(n);c++){
    		for(int d=c;d<Math.sqrt(n-c*c);d++){
            for(int e=d;e<Math.sqrt(n-c*c);e++){
              int an=c*c+d*d+e*e+c*d+c*e+d*e;
             if(an==a){
               if(c==d&&d==e){
              ans++;
               }else if(c==d||d==e||e==c){
               ans+=3;
               }else{ans+=6;}
          
             }else if(an>a){
               break;}
            }
            }
    	}
        System.out.println(ans);
        ans=0;
      }
    

    	
    }
}


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

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

void solve() {
    int n;
    std::cin >> n;

    auto xss = vec(n, vec(3, 0));
    for (auto& xs : xss) {
        for (auto& x : xs) {
            std::cin >> x;
        }
    }

    std::vector<int> score(n, 0);
    for (int t = 0; t < 3; ++t) {
        for (int i = 0; i < n; ++i) {
            score[i] += xss[i][t];

            for (int j = 0; j < n; ++j) {
                if (i == j) continue;
                if (xss[i][t] == xss[j][t]) {
                    score[i] -= xss[i][t];
                    break;
                }
            }
        }
    }

    for (auto s : score) std::cout << s << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int h,w;
  cin>>h>>w;
  vector<string> a(h);
  rep(i,h) cin>>a[i];
  vvi dp(h,vi(w,0));
  rep(i,h){
    if(a[i][0]=='#') break;
    dp[i][0]=1;
  }
  rep(j,w){
    if(a[0][j]=='#') break;
    dp[0][j]=1;
  }
  REP(i,1,h)REP(j,1,w){
    if(a[i][j]=='#') continue;
    if(a[i][j-1]=='.') dp[i][j]+=dp[i][j-1];
    if(a[i-1][j]=='.') dp[i][j]+=dp[i-1][j];
    dp[i][j]%=mod;
  }
  out(dp[h-1][w-1]);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 12092
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;

int n, q, orta, ort;
char s[N], x[N], y[N];

bool gitsag(int ind){
	if(ind == n + 1)
		return 1;
	for(int i = 1; i <= q; i++){
		if(x[i] == s[ind])
			ind = (y[i] == 'R') ? ind + 1 : ind - 1;
		if(ind == n + 1)
			return 1;
		if(ind == 0)
			return 0;
	}
	return 0;
}

bool gitsol(int ind){
	if(ind == 0)
		return 1;
	for(int i = 1; i <= q; i++){
		if(x[i] == s[ind])
			ind = (y[i] == 'R') ? ind + 1 : ind - 1;
		if(ind == 0)
			return 1;
		if(ind == n + 1)
			return 0;
	}
	return 0;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d %s",&n ,&q ,s + 1);
	for(int i = 1; i <= q; i++)
		scanf(" %c %c",x + i, y + i);
	int bas = 0, son = n + 1;
	// cout << "AMK" << endl;
	while(bas < son){
		orta = ((bas+son)/2);
		// cout << bas << " " << son << " " << orta << endl;
		if(gitsag(orta))
			son = orta;
		else
			bas = orta + 1; 
		// cout << bas << " " << son << " " << orta << endl;
	}
	orta = (bas+son)/2;
	// cout << "AMK" << orta << endl;;
	bas = 0, son = n + 1;
	while(bas < son){
		ort = ((bas+son+1)/2);
		if(gitsol(ort))
			bas = ort;
		else
			son = ort - 1; 
	}
	ort = (bas+son)/2;
	printf("%d\n", orta - ort - 1);
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
int main(){
  int i,n,maxv,minv;

  scanf("%d",&n);

  int R[n];

  for(i=0;i<n;i++)
    scanf("%d",&R[i]);

  maxv=R[1]-R[0];
  minv=R[0];
  
  for(i=1;i<=n-1;i++){
    if(maxv<R[i]-minv) maxv=R[i]-minv;
    if(minv>R[i]) minv=R[i];
  }

  printf("%d\n",maxv);

  return 0;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();
  	double rate= 380000.0;
  	double su1m=0;
  	cin>>n;
  	for (int i = 0; i < n; ++i)
  	{
  		/* code */
  		double val;
  		string s;
  		cin>>val>>s;
  		if(s=="JPY")
  			su1m+=val;
  		else
  			su1m+=(val*rate);
  	}
  	cout<<su1m<<endl;
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    priority_queue<P,vector<P>,greater<P>> toukou;
    for(int i=1; i<=n; i++){
        int a;
        cin >> a;
        toukou.push(make_pair(a,i));
    }
    rp(i,n){
        P p=toukou.top(); toukou.pop();
        cout << p.second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
gets
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

if a.inject(&:+) < b.inject(&:+)
  puts -1
  exit(0)
end

d = a.zip(b).map{|a,b| a-b}
dp = d.select(&:positive?).sort.reverse
dn = -d.select(&:negative?).inject(0,&:+)

if dn == 0
  puts 0
  exit(0)
end

(dp.size-1).times.each do |i|
  dp[i+1] += dp[i]
end

puts (dp.each_with_index.to_a.bsearch{|x, i| dn <= x} || [0,-1])[1] + d.select(&:negative?).size+1


Measured memory_bytes: 22372
# coding: utf-8
# Your code here!
from collections import deque
k=int(input())
ans=[]
d=deque([1,2,3,4,5,6,7,8,9])
c=0
while c<100100:
    q=d.popleft()
    ans.append(q)
    c+=1
    b=q%10
    if b!=0:
        d.append(q*10+b-1)
    d.append(q*10+b)
    if b!=9:
        d.append(q*10+b+1)
    
print(ans[k-1])

Measured memory_bytes: 16120
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=0;i<100;i++)
    {
        if(a*i%b==c)
        {
            cout<<"YES"<<NL;
            return 0;
        }
    }
    cout<<"NO"<<NL;
    return 0;
}


Measured memory_bytes: 256
n, t, s = gets.split.map(&:to_i)
dp = [0]*(t+1)
ret = 0
n.times do |i|
  a, b = gets.split.map(&:to_i)
  t.downto(b) do |j|
    dp[j] = [dp[j], dp[j - b] + a].max if !(j - b < s && s < j)
  end
  ret = [ret, dp.max].max
end
p ret

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(long long a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (long long) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
};

using mint = ModInt<1000000007>;

mint dp[100010][2];

void solve() {
  string s;
  cin >> s;
  int n = sz(s);
  dp[0][0] = 1;
  rep(i, n) rep(j, 2) {
    int x = s[i] - '0';
    if (j == 0) {
      if (x == 0) {
        dp[i + 1][0] += dp[i][j];
      } else {
        dp[i + 1][0] += dp[i][j] * 2;
        dp[i + 1][1] += dp[i][j];
      }
    } else {
      dp[i + 1][1] += dp[i][j] * 3;
    }
  }
  mint ans;
  ans = dp[n][0] + dp[n][1];
  cout << ans << endl;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<int, int> mp1, mp2;
    for(int i=0; i<N; i++){
        int D;
        cin >> D;
        mp1[D]++;
    }
    int M;
    cin >> M;
    for(int i=0; i<M; i++){
        int T;
        cin >> T;
        mp2[T]++;
    }
    for(auto x : mp2){
        if(x.second > mp1[x.first]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int a[3010];
int main() {
    int N;
    cin>>N;
    int mx=0;
    REP(i,0,N){
        cin>>a[i];
        mx += a[i]-1;
    }
    p(mx);
    return 0;
}

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

using namespace std;
int main(){
	int a[5],b[5],c[5];
	int ans=0;
	for(int i=0;i<5;i++)cin>>a[i];
	for(int i=0;i<5;i++){
		if(a[i]%10!=0)
			b[i]=(a[i]/10+1)*10;
		else b[i]=a[i];
		ans+=b[i];
	}
	int sum=0;
	for(int i=0;i<5;i++){
		c[i]=abs(a[i]-b[i]);
		sum=max(c[i],sum);
	}
	ans-=sum;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n,m,c;
int b[21];
int a[21][21];

void input(){
    cin >> n >> m >> c;
    for(int i=0;i<m;i++) cin >> b[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int ans = 0;
    for(int i=0;i<n;i++){
        int tmp = 0;
        for(int j=0;j<m;j++){
            tmp += a[i][j] * b[j];
        }
        tmp += c;
        if(tmp > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    int maxnum = max(a,max(b,c));
    cout << a+b+c+maxnum*pow(2,d)-maxnum << endl;

    return 0;
}

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

int main(){
    int k, a, b;
    cin>>k>>a>>b;
    if(b - a - 2 <= 0){
        cout<< 1 + k <<endl;
        return 0;
    }
    long long ans = 1ll * (1+k-a)/2*(b-a) + ((k-a+1) % 2)+a;
    cout<<ans<<endl;

}


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

int main() {
  int N;
  cin >> N;
  vector<int>data(N);
  for(int i=0;i<N;i++){
    char s;
    cin >> s;
    data.at(i)=int(s)-int('0');
  }
  vector<vector<int>>kazugoto(10,vector<int>(2));
  for(int i=0;i<10;i++){
    kazugoto.at(i).at(0)=-1;
  }
  for(int i=0;i<N;i++){
    kazugoto.at(data.at(i)).at(1)=i;
    if(kazugoto.at(data.at(i)).at(0)==-1) kazugoto.at(data.at(i)).at(0)=i;
  }
  int count=0;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(kazugoto.at(i).at(0)==-1||kazugoto.at(j).at(0)==-1) continue;
      if(kazugoto.at(i).at(0)>=kazugoto.at(j).at(1)-1) continue;
      set<int>result;
      for(int k=kazugoto.at(i).at(0)+1;k<kazugoto.at(j).at(1);k++){
        result.insert(data.at(k));
      }
      count+=result.size();
    }
  }
  cout << count << endl; 
}

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

// x, y. x and y is 0-indexed.
using Point = pair<int, int>;
// [l, r), l and r is 0-indexed.
template<typename T>
using Interval2d = tuple<Point, Point, T>;

template<typename T>
struct Imos2d {
    int h, w;
    vector<vector<T>> s;
    Imos2d(int h, int w, const vector<Interval2d<T>> &intervals) : h(h), w(w) {
        s.resize(h + 1, vector<T>(w + 1, 0));
        for (auto interval : intervals) {
            T v = std::get<2>(interval);
            Point p1 = std::get<0>(interval);
            Point p2 = std::get<1>(interval);
            s[p1.second][p1.first] += v;
            s[p1.second][p2.first] -= v;
            s[p2.second][p1.first] -= v;
            s[p2.second][p2.first] += v;
        }
        for (int y = 0; y < h; ++y) for (int x = 0; x < w; ++x) {
            s[y + 1][x] += s[y][x];
        }
        for (int y = 0; y < h; ++y) for (int x = 0; x < w; ++x) {
            s[y][x + 1] += s[y][x];
        }
    }
    int height() {
        return h;
    }
    int width() {
        return w;
    }
    // x, y. x and y is 0-indexed.
    T get(int x, int y) {
        return s[y][x];
    }
};

/*
    verified https://onlinejudge.u-aizu.ac.jp/problems/DSL_5_B
*/
int main() {
    int N; cin >> N;
    vector<Interval2d<long long>> intervals(N);
    for (int i = 0; i < N; ++i) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        intervals[i] = make_tuple(make_pair(x1, y1), make_pair(x2, y2), 1);
    }
    Imos2d<long long> imos(1001, 1001, intervals);

    long long res = numeric_limits<long long>::min();
    for (int y = 0; y < imos.height(); ++y) for (int x = 0; x < imos.width(); ++x) {
        res = max(res, imos.get(x, y));
    }
    cout << res << endl;
}



Measured memory_bytes: 13160
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

template <class T>
using MSet = std::multiset<T>;

int main() {
    Int n;
    std::cin >> n;

    MSet<Int> s;
    for (Int i = 0; i < n; ++i) {
        Int a;
        std::cin >> a;
        auto itr = s.lower_bound(a);
        if (itr != s.begin()) {
            s.erase(--itr);
        }
        s.insert(a);
    }

    std::cout << s.size() << std::endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int input[505][505];
vector<string> vec;
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &input[i][j]);
        }
    }
    int dir = 1;
    int j = 0;
    int i = 0;
    int pi = 0;
    int pj = 0;
    while (true)
    {
        i += dir;
        if (i == n || i == -1)
        {
            j++;
            dir *= -1;
            i += dir;
        }
        if (j == m)
            break;
        if (input[pi][pj] % 2)
        {
            input[pi][pj]--;
            input[i][j]++;
            vec.push_back(to_string(pi + 1) + " " + to_string(pj + 1) + " " + to_string(i + 1) + " " + to_string(j + 1));
        }
        pi = i;
        pj = j;
    }
    cout << vec.size() << endl;
    for (int i = 0; i < vec.size(); i++)
        cout << vec[i] << endl;
    system("pause");
}

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

int main()
{
    string s;
    int count = 0;
    cin >> s;

    if(s[0] == 'R' ||
       s[1] == 'R' ||
       s[2] == 'R'
    )
        count = 1;


    if(s[0] == 'R' &&
       s[1] == 'R'
       ||
       s[1] == 'R' &&
       s[2] == 'R'
    )
        count = 2;

    if(s[0] == 'R' &&
       s[1] == 'R' &&
       s[2] == 'R'
    )
        count = 3;
    
    cout << count << endl;

}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**6)

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ans = 0

for i,j in zip(v,c):
    if i > j:
        ans += i-j
        
print(ans)

Measured memory_bytes: 9172
'use strict'

function Main(input) {
  const N = Number(input.split('\n')[0]);
  const S = input.split('\n')[1].split('');

  let S_left, S_right;
  let counter = 0;
  let sufferlist = [];


  for(let i=1; i<N; i++) {
    S_left = S.slice(0, i)
      .filter((x,i,self) => self.indexOf(x) === i);
    S_right = S.slice(i)
      .filter((x,i,self) => self.indexOf(x) === i);

    for(let j=0; j<S_left.length ;j++) {
      if(S_right.some(value => value === S_left[j])) {
        counter++;
      }
    }
    sufferlist.push(counter);
    counter = 0;
    
    //console.log(S_left);
    //console.log(S_right);
    //console.log(sufferlist);
  }

  console.log(Math.max.apply(null, sufferlist));

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7908
A, B, C, D = map(int, input().split())
MOD = 998244353

dp = [[0] * (D + 2) for _ in range(C + 2)]
dp[A][B] = 1

for h in range(A, C + 1):
    for w in range(B, D + 1):
        d = dp[h][w] % MOD
        dp[h + 1][w] += d * w
        dp[h][w + 1] += d * h
        dp[h + 1][w + 1] -= d * w * h % MOD
print(dp[C][D] % MOD)


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

int except(string s, int p) {
    long long n = s.size();
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
        if ((s[i] - '0') % p == 0) {
            ans += i + 1;
        }
    }
    cout << ans << "\n";
    return 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, p; cin >> n >> p;
    string s; cin >> s;
    if (p == 2 || p == 5) return except(s, p);
    map<int, long long> m;
    int curr = 0; m[curr]++;
    int pt = 1;
    for (int i = n-1; i >= 0; i--) {
        curr = (curr + (s[i] - '0') * pt) % p;
        pt = pt * 10 % p;
        m[curr]++;
    }
    long long ans = 0;
    for (auto &iter: m) {
        ans += iter.second * (iter.second - 1) / 2; 
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1044
/**
 * The man who codes no bugs
 * McCheng is the man studying Maths in CUHK with IQ200
 * @author McCheng
 */

#include <bits/stdc++.h>
#define int long long
using namespace std;

class COneQuadrillionAndOneDalmatians {
public:
    static constexpr int kStressCount = 0;
    static void generateTest(ostream& test) {}
	void solve(istream& cin, ostream& cout) {
int n;
cin>>n;
stack<char> s;
while (n>0){
    char c=(n-1)%26+'a';
//    if (c=='a'-1) c='z';
    s.push(c);
    if (s.size()) n--;
    n/=26;
}
while (!s.empty()){
    char tmp=s.top();
    cout<<tmp;
    s.pop();
}
	}
};

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream &in(cin);
    ostream &out(cout);
    out << fixed;
    out.precision(20);
    COneQuadrillionAndOneDalmatians solver;
    solver.solve(in, out);
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
// int dy[]={0, 1, 0, -1};
// int dx[]={1, 0, -1, 0};

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

ll gcd(ll x,ll y){
    if(x == 0) return y;
    return gcd(y%x,x);
}


vector<ll> prime(1010);

void solve(){
    ll n,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++){
        ans += min((x[i]-x[i-1])*a,b);
    }
    cout << ans << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

int main() {

    string s;
    cin >> s;
    REP(i,0,s.size()){
        if(s[i] == ','){
            cout << " ";
        }else{
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertback(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  int n, l;
  cin>>n>>l;
  vector<string> v(n);
  rep(i, 0, n)
    cin>>v[i];
  sort(v.begin(), v.end());
  rep(i, 0, n)
    cout<<v[i];
  cout<<endl;
  return 0;
}


Measured memory_bytes: 12416
import java.util.*;

// ARC 77-C
// http://arc077.contest.atcoder.jp/tasks/arc077_a

public class Main {
	
	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int[] nums = new int[N];
		
		for (int i = 0; i < N; i++) {
			nums[i] = in.nextInt();
		}
		
		int index = N - 1;
		StringBuilder s = new StringBuilder();
		while (index >= 0) {
			s.append(nums[index] + " ");
			index -= 2;
		}
		index = N % 2;
		while (index < N) {
			s.append(nums[index] + " ");
			index += 2;
		}
		System.out.println(s);
	}
	
}


Measured memory_bytes: 96208
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();

    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i = 0;i<h;i++)cin>>s[i];
    int dp[h][w];
	memset(dp,0,sizeof(dp));

	dp[0][0] = (s[0][0]=='.');
	for(int i = 0;i<h;i++){
		for(int j = 0;j<w;j++)
		{
			if(s[i][j]=='#')continue;
			if(j)dp[i][j]+=dp[i][j-1];
			if(i)dp[i][j]+=dp[i-1][j];
			dp[i][j]%=MOD;
			// cout<<dp[i][j]<<" ";
		}
		// nl;
	}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}

Measured memory_bytes: 5248
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  int L[1000];
  for(int i=0;i<2*n;i++){
    scanf("%d",L+i);
  }
  sort(L,L+2*n);
  int ans=0;
  for(int i=0;i<2*n;i+=2){
    ans+=L[i];
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define N	16
#define M	16
#define N_	(1 << N)
#define MD	1000000007

int vv[N_], ff[N_], gg[N_];

void init() {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i < N_; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
}

long long choose(int n, int k) {
	return k > n ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	static int aa[M], dp[N_];
	int n, m, h, i, b, ans;

	init();
	scanf("%d%d", &n, &m);
	for (h = 0; h < m; h++)
		scanf("%d", &aa[h]), aa[h] = (1 << n) - aa[h];
	dp[0] = 1;
	for (h = m - 1; h >= 0; h--)
		for (b = (1 << n) - 1; b >= 0; b--) {
			int x = dp[b];

			if (x == 0)
				continue;
			for (i = 0; i < n; i++)
				if ((b & 1 << i) == 0)
					dp[b | 1 << i] = (dp[b | 1 << i] + x * choose(aa[h] - b, (1 << i) - 1)) % MD;
		}
	ans = 0;
	for (b = 0; b < 1 << n; b++) {
		int x, n_, cnt;

		x = dp[b];
		if (x == 0)
			continue;
		n_ = (1 << n) - 1 - b, cnt = n;
		for (i = 0; i < n; i++)
			if ((b & 1 << i) == 0) {
				x = x * choose(n_, 1 << i) % MD;
				n_ -= 1 << i;
				cnt++;
			}
		ans = (ans + (cnt % 2 == 0 ? 1 : -1) * x) % MD;
	}
	for (i = 0; i < n; i++)
		ans = (long long) ans * ff[1 << i] * 2 % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

/*If N is odd, then the median of X can be every integer between the median of A and the median of
B, and if N is even, then the median of X can be every multiple of 1/2
between the median of A and the median of B, inclusive. The variation of the median of X when one of its elements is increased by oneis either 0 or 1 when N is odd, and either 0 or 1/2
when N is even. Considered that the median of X can
be increased from A to B by repeating the operation of increasing one of the elements of X by 1, it can be seen that all of the real numbers mentioned above appears on that path as the median. The other real number cannot appear as the median, so it is sufficient.
*/

void test_case(){
	int n; cin >> n;
	vector<int> a(n),b(n);
	for(int i = 0 ; i < n ; i++){
		cin>>a[i]>>b[i];
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	ll x, y;
	if(n%2 == 1){
		x = a[n/2];
		y = b[n/2];
	}
	else{
		x = a[n/2-1]+a[n/2];
		y = b[n/2-1]+b[n/2];
	}
	cout<<y-x+1<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 4716
import java.util.Scanner;

public class Main {

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

		int inN = stdin.nextInt();
		int inY = stdin.nextInt();

		int result10000 = -1;
		int result5000 = -1;
		int result1000 = -1;

		mainloop:
		for (int num1000 = 0; num1000 <= inN; num1000++) {
			int sum1000 = 1000 * num1000;
			if (sum1000 > inY) {
				break;
			}

			for (int num5000 = 0; (num1000 + num5000) <= inN; num5000++) {
				int sum5000 = sum1000 + 5000 * num5000;
				if (sum5000 > inY) {
					break;
				}

				int sum10000 = inY - sum5000;
				if ((sum10000 % 10000) == 0) {
					int num10000 = sum10000 / 10000;
					if ((num1000 + num5000 + num10000) == inN) {
						result10000 = num10000;
						result5000 = num5000;
						result1000 = num1000;

						break mainloop;
					}
				}
			}
		}

		System.out.println(result10000 + " " + result5000 + " " + result1000);
	}

}


Measured memory_bytes: 22604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public void execute(CustomReader in) throws IOException {
        int[] nk = in.readLineAsIntArray();
        final int N = nk[0];
        final int K = nk[1];
        int[] h = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = in.readLineAsInt();
        }
        Arrays.sort(h);
        int minDiff = h[K - 1] - h[0];
        for (int l = 0, r = K - 1; r < N; l++, r++) {
            minDiff = Math.min(minDiff, h[r] - h[l]);
        }

        System.out.println(minDiff);
    }


    static class CustomReader extends BufferedReader {
        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }

        public char[][] readAsCharMatrix(int rows) throws IOException {
            char[][] matrix = new char[rows][];
            for (int i = 0; i < rows; i++) {
                matrix[i] = this.readLine().toCharArray();
            }
            return matrix;
        }

    }

}

Measured memory_bytes: 33272
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  ll cnt = 1;
  while(cnt < b){
    cnt--;
    cnt += a;
    ans++;
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256