akhauriyash/Code-Regression huggingface dataset:
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  
    int nn;
    cin>>nn;

    string s,t;
    cin>>s>>t;
    int n = s.size(),m = t.size();

    int i=0, j=0;

    int c = 0;
    while(i < n and j < m) {
        if(c&1) {
            cout<<t[j];
            ++j;
        }
        else {
            cout<<s[i];
            ++i;
        }
        ++c;
    }
    while(i < n) {cout<<s[i]; ++i;}
    while(j < m) {cout<<t[j]; ++j;}

    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define openfiles ifstream cin("input10.txt"); ofstream cout("output10.txt");

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector <ll> dp(n, 1000000000), a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 1; j <= k; j++)
        {
            if(i - j >= 0)
                dp[i] = min(dp[i-j] + abs(a[i] - a[i - j]), dp[i]);
        }
    }
    cout<<dp[n - 1];
}


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

#define ran 101101

int n;
int A, B, C;
char s[ran][3];

bool f[ran][7][7][7];
char ch[ran][7][7][7], ans[ran];

void upd(int i, int a, int b, int c, char x) {
	if(a<0 || b<0 || c<0) return;
	if(f[i][a][b][c]) return;
	
	f[i][a][b][c] = true;
	ch[i][a][b][c] = x;
}

int main() {
	scanf("%d%d%d%d", &n, &A, &B, &C);
	
	A = min(A, 2);
	B = min(B, 2);
	C = min(C, 2);
	upd(0, A, B, C, 'A');
	for(int i=1;i<=n;i++) {
		scanf("%s", s[i]);
		
		for(int a=0;a<7;a++)
		for(int b=0;b<7;b++)
		for(int c=0;c<7;c++) {
			if(!f[i-1][a][b][c]) continue;
			
			if(s[i][0]=='A' && s[i][1]=='B') {
				upd(i, a+1, b-1, c, 'A');
				upd(i, a-1, b+1, c, 'B');
			}
			if(s[i][0]=='A' && s[i][1]=='C') {
				upd(i, a+1, b, c-1, 'A');
				upd(i, a-1, b, c+1, 'C');
			}
			if(s[i][0]=='B' && s[i][1]=='C') {
				upd(i, a, b+1, c-1, 'B');
				upd(i, a, b-1, c+1, 'C');
			}
		}
	}
	
	A=B=C=-1;
	for(int a=0;a<7 && A<0;a++)
	for(int b=0;b<7 && B<0;b++)
	for(int c=0;c<7 && C<0;c++)
		if(f[n][a][b][c]) {
			A = a; B = b; C = c;
		}
	
	if(A<0) {
		puts("No");
		return 0;
	}
	
	for(int i=n;i>0;i--) {
		//printf("%d %d %d %d %d\n", i, A, B, C, f[i][A][B][C]);
		ans[i] = ch[i][A][B][C];
		if(ans[i]=='A') {
			A--;
			if(s[i][1]=='B') B++;
			else C++;
		}
		if(ans[i]=='B') {
			B--;
			if(s[i][0]=='A') A++;
			else C++;
		}
		if(ans[i]=='C') {
			C--;
			if(s[i][0]=='A') A++;
			else B++;
		}
	}
	puts("Yes");
	for(int i=1;i<=n;i++) printf("%c\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 71204
#include<stdio.h>
int main()
{
	int n,d,x,a[111],c=0,z=0,t=0,i,j=1;

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

	i=0;
	while(i<n){
		while(j*a[i]+1<=d){
			z++;
			j++;
		}
		c+=z+1;
		z=0;
		j=1;
		t=0;
		i++;
	}
	printf("%d",x+c);
	return 0;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     gcd(int A, int B) {
        while (0!=B) {
                A %=B;
                swap(A, B);
        }
        return A;
}

ll      gcd(ll A, ll B) {
        while (0!=B) {
                A %=B;
                swap(A, B);
        }
        return A;
}

ll      lcm(ll A, ll B) {
        ll G=gcd(A, B);
        return A/G*B;
}

int     main() {
        ll X;
        cin >>X;
        ll A=lcm(360, X);
        cout <<A/X <<endl;
        return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
    int a, b,x;
    scanf("%d%d", &a, &b);
    if((a%2==1  && b%2==0) || (a%2==0  && b%2==1))
    {
        x=(a+b)/2+1;
    }
    else
    {
        x=(a+b)/2;
    }
    printf("%d\n", x);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n, k;

ll a[100010];

ll p, m;
ll sum;

ll acp[100010];
ll acm[100010];

int main(){

  n = in();
  k = in();
  REP( i , n ){
    a[i] = in();
    if( a[i] > 0 ){
      sum += a[i];
      acp[i+1] = a[i];
    } else {
      acm[i+1] = -a[i];
    }
  }

  REP( i , n ){
    acp[i+1] += acp[i];
    acm[i+1] += acm[i];
  }

  // SHOW( sum );

  p = INFLL;
  m = INFLL;
  REP( i , n-k+1 ){
    chmin( p, acp[i+k] - acp[i] );
    chmin( m, acm[i+k] - acm[i] );
  }

  ll ans = sum - min( p, m );

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


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define MAXN (20 + 5)
#define LL long long
using namespace std;
int main()
{
	LL n;
	scanf("%lld", &n);
	LL dq = 0, wz = 1, ans = 0;
	for (; dq + wz * 9 <= n; )
	{
		dq += wz * 9;
		wz *= 10;
		ans += 9;
	}
	for (int i = 9; i; i--)
	{
		if (dq + wz * i <= n)
		{
			ans += i;
			break;
		}
	}
	printf("%lld", ans);
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long n, std::vector<long long> p){
    ll a,aa,aaa;
    a=p[0];aa=p[1];
    ll cnt=0;
    repf(i,2,n){
        aaa=p[i];
        if((a>aa&&aa>aaa)||(a<aa&&aa<aaa)){
            cnt++;
        }
        a=aa;
        aa=aaa;
    }
    op(cnt)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> p(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&p[i]);
    }
    solve(n, std::move(p));
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
element = [int(i) for i in input().split()]
ans = 0
odd_l = Counter(element[::2])
even_l = Counter(element[1::2])
a1,b1= odd_l.most_common(1)[0]
a2,b2 = even_l.most_common(1)[0]
if a1 != a2:
    ans = n - b1 - b2
else:
    if len(odd_l) > 1:
        b3 = odd_l.most_common(2)[1][1]
    else:
        b3=0
    if len(even_l) > 1:
        b4 = even_l.most_common(2)[1][1]
    else:
        b4 = 0
    ans = min(n-b1-b4,n-b3-b2)
print(ans)


Measured memory_bytes: 18656
n, m = map(int, input().split())
h_list = list(map(int, input().split()))

result = {}
for i in range(n):
    result[i] = True

for i in range(m):
    a, b = map(int, input().split())
    if h_list[a-1] >=  h_list[b-1]:
        result[b-1] = False
    if h_list[a-1] <=  h_list[b-1]:
        result[a-1] = False

count = 0
for i in range(n):
    if result[i]:
        count+=1
print(count)


Measured memory_bytes: 24576
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
		cin.tie(0); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}}INIT;

vector<pair<int, int>> primeFact(int n) {
	vector<pair<int, int>> res;
	for (int i = 2; i * i <= n; i++) {
		int divcnt = 0;
		if (n % i == 0) {
			do {
				divcnt++;
				n /= i;
			} while (n % i == 0);
			res.emplace_back(i, divcnt);
		}
	}
	if (n != 1)
		res.emplace_back(n, 1);
	return res;
}


vector<int> fac, finv, inv;

void comb_init(int n) {
	fac  = vector<int>(n);
	finv = vector<int>(n);
	inv  = vector<int>(n);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < n; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

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

	comb_init(400000);

	int ans = 1;

	auto primes = primeFact(M);
	for(auto p : primes){
		(ans *= comb(N+p.second-1, p.second)) %= MOD;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <atcoder/all>

using namespace std;
using namespace atcoder;
typedef long long ll;

int main() {
  ll T;
  cin >> T;
  while (T--) {
    ll N, M, A, B, ans;
    cin >> N >> M >> A >> B;
    ans = floor_sum(N, M, A, B);
    cout << ans << endl;
  }
  
  
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
long long pow(long long p,long long q,long long r){
  if(q==0)return 1;
  else if(q%2==0)return pow(p,q/2,r)*pow(p,q/2,r)%r;
  else return pow(p,q-1,r)*p%r;
}
int main() {
  long long n,k,mod=1000000007;
  cin>>n>>k;
  long long a[k];
  a[0]=n-k+1;
  for(int i=1;i<k;i++){
    a[i]=(a[i-1]*(k-i)*(n-k+1-i)%mod)*pow(i,mod-2,mod)%mod*pow(i+1,mod-2,mod)%mod;
  }
  for(int i=0;i<k;i++){
    cout<<a[i]<<endl;
  }
}


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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/

signed main()
{
//	v.resize(n);
string s;cin >> s;
	 if(s[0] == s[1] && s[2] == s[3] && s[0] != s[3]){
	cout << "Yes" << endl;
}
else if(s[1] == s[2] && s[0] == s[3] && s[0] != s[1]){
	cout << "Yes" << endl;
}
else if(s[1] == s[3] && s[2] == s[0] && s[0] != s[3]){
	cout << "Yes" << endl;
}
else if(s[0] == s[1] == s[2] == s[3]) cout << "Yes" << endl;
else{
	cout << "No" << endl;
}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 50;
int n, m;
int sx, sy;
int cx, cy;
char mp[maxn][maxn];
int vis[maxn][maxn];
int vis2[maxn][maxn];
struct node{
    int x, y, d;
    bool operator <(const node &p)const{
        return d > p.d;
    }
};
int dx[4] = {0, 0, 1, -1};
int dy[4] = {-1, 1, 0, 0};
bool check(int x, int y){
    if(x >= 1 && x <= n && y >= 1 && y <= m && mp[x][y] == '.') return true;
    else return false;
}
int bfs(){
    priority_queue<node> q;
    node a, now;
    a.x = sx, a.y = sy, a.d = 0;
    q.push(a);
    vis[sx][sy] = 1;
    while(!q.empty()){
        now = q.top();q.pop();
        //cout << now.x << " " << now.y << " " << now.d << endl;
        if(now.x == cx && now.y == cy){
            return now.d;
        }
        for(int i = 0;i < 4;i++){
            int nx = now.x + dx[i];
            int ny = now.y + dy[i];
            if(check(nx, ny) && !vis[nx][ny]){
                a.x = nx, a.y = ny, a.d = now.d;
                q.push(a);
                vis[nx][ny] = 1;
                vis2[nx][ny] = 1;
            }
        }
        for(int i = -2;i <= 2;i++){
            for(int j = -2;j <= 2;j++){
                int nx = now.x + i;
                int ny = now.y + j;
                    if(check(nx, ny) && !vis2[nx][ny] && !vis[nx][ny]){
                    a.x = nx, a.y = ny, a.d = now.d + 1;
                    q.push(a);
                    vis2[nx][ny] = 1;
                }
            }
        }
    }
    return -1;
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n >> m;
    cin >> sx >> sy;
    cin >> cx >> cy;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            cin >> mp[i][j];
        }
    }
    cout << bfs() << endl;
    return 0;
}


Measured memory_bytes: 12936
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF =1e9+7;

int main() {
    ll n;
    cin>>n;
    vector<pair<ll,ll>> v;
    ll lon = 0;
    ll lonp = 0;
    ll minl = 0,lp =INF;
    ll mar = 0,rq = 0;

    rep(i,n){
        ll a,b;
        cin>>a>>b;
        v.push_back({a,b});
        if(b<lp){
            lp=b;
            minl=i;
        }
        if(a>rq){
            rq=a;
            mar=i;
        }
    }

   //cout<<mar<<" "<<minl<<endl;
   int p =0;
    rep(i,n){
            if(v[i].second-v[i].first+1>lon){
                lon=v[i].second-v[i].first+1;
                p=i;

            }
    }
    ll pl=INF,pr=0;
    rep(i,n){
        if(i!=p){
            pl= min(pl,v[i].second);
            pr = max(pr,v[i].first);
        }
    }


    ll ans = 0;
   // ans=lon+max(0ll,v[minl].second-v[mar].first+1);
   ans = lon+max(0ll,pl-pr+1);

   //cout<<ans<<endl;
    vector<pair<ll,ll>> v2;

    rep(i,n){
        ll y1 = max(v[i].second - v[mar].first+1,0ll);
        ll y2 = max(v[minl].second-v[i].first+1,0ll);
        v2.push_back({y1,-y2});
    }

    //cout<<v[mar].first<<" "<<v[minl].second<<endl;

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

    ll ans2=0;
    ll s=0;ll t=0;
    ll w = INF;
    rep(i,n){
        ll a = v2[i].first,b=-v2[i].second;
        if(w!=INF){
            ans2=max(ans2,w+a);
        }
        w=min(w,b);
    }
    cout<<max(ans,ans2)<<endl;




    return 0;
}


Measured memory_bytes: 4848
#include <iostream>
#include <cmath>
using namespace std;
int x,y,s,n,t,lx,ly,lt;

int main(){
	cin>>n;
	lx=0;ly=0;
	for(int i=1;i<=n;i++){
		cin>>t>>x>>y;
		s=abs(x-lx)+(y-ly);
		int ss=t-lt;ss-=s;
		if(ss<0||ss%2==1){
		cout<<"No"<<endl;
		return 0;}
		s=0;lx=x;ly=y;lt=t;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	for (int i = M - N + 1; i < M + N; i++)cout << i << " ";
	cout << endl;
}



Measured memory_bytes: 256
N = int(input())
S = input()

a = []
t = 0
for i,s in enumerate(S):
    if s == "E":
        t += 1
        a.append(t)
    else:
        t -= 1
        a.append(t)

index = a.index(max(a))

X = S[:index]
Y = S[index+1:]

print(X.count("W")+Y.count("E"))
    

Measured memory_bytes: 15520
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll a(3*n) ;
	for(auto &i:a) cin >> i ;
	mysort(a) ; myrev(a) ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		ans += a.at(i*2+1) ;
	}
	cout << ans << endl ;
}


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

int main(){
  int N,count;
  cin >> N;
  count = 0;
  int P=0;
  for(int i=0;i<N;i++){
    cin >> P;
    if(P != i+1){
      count ++;
    }
  }
  if(count >2){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
a,b,c,d,e,f=map(int,input().split())
L=[]
M=[]
from functools import lru_cache
@lru_cache(maxsize=1000)
def dfs(s,w):
    if s+w>f or s>f*e/(100+e):
        return
    x=(100*s)/(s+w)
    m=(100*e)/(e+100)
    if x==m:
        L.append([x,s+w,s])
        return
    elif x>m:
        dfs(s,w+100*a)
        dfs(s,w+100*b)
    else:
        L.append([x,s+w,s])
        dfs(s+c,w)
        dfs(s+d,w)
dfs(0,100*a)
dfs(0,100*b)
LS=sorted(L,key=lambda x:x[0],reverse=True)
print(LS[0][1],LS[0][2])

Measured memory_bytes: 7120
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int N;
int A[100005];
ll MOD = 1e9+7;

int main(int argc, char const *argv[]) {
	cin >> N;
	vector<int> v(N);

	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());

	if (N % 2 == 0) {
		int check = 1;
		for (int i = 0; i < N; i++) {
			if (i % 2 == 0 && v[i] == check) {
				continue;
			}
			else if (i % 2 == 1 && v[i] == check) {
				check += 2;
				continue;
			}
			else {
				cout << "0" << endl;
				return 0;
			}
		}
	}

	else {
		if (v[0] != 0) {
			cout << "0" << endl;
			return 0;
		}
		int check = 2;
		for (int i = 1; i < N; i++) {
			if (i % 2 == 1 && v[i] == check) {
				continue;
			}
			else if (i % 2 == 0 && v[i] == check) {
				check += 2;
				continue;
			}
			else {
				cout << "0" << endl;
				return 0;
			}
		}
	}		

	ll res = 1;

	for (int i = 0; i < N/2; i++) {
		res *= 2;
		res %= MOD;
	}
	cout << res << endl;
	
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


int main() {
    cout<<fixed<<setprecision(10);

    ll n,m; cin>>n>>m;
    vint a(m),b(m); rep(i,m) {cin>>a[i]>>b[i]; a[i]--; b[i]--;}

    auto uf = UnionFind(n);

    rep(i,m){
        uf.unite(a[i], b[i]);
    }

    int ans = 0;
    rep(i,n){
        chmax(ans, uf.size(i));
    }
    cout<<ans<<endl;


    return 0;

}

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

using namespace std;
string S;
int N;

long long int ans = 0;

long long int eval(string H) {

	long long int ret = 0;

	int M = H.size();
	long long int num = 0; long long int cur = 0;
	for (int i = 0; i <= M - 1; i++) {
		if (H[i] == '+') { ret += num; num = 0; }
		else { num = num * 10 + H[i] - '0'; }
	}

	return ret + num;

}

long long int  rec(int k, string T) {
	
	if (k == N) {  return eval(T); }


	return rec(k+1,T+S[k])+rec(k+1, T+"+"+S[k]);
}

int main(void) {

	cin >> S;
	N = S.size();
	
	ans = rec(1, S.substr(0,1));

	cout << ans << endl;

//	cout << eval("1+25") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;



int main(){
    int n,m;
    cin >> n >> m;
    int l[m+10],r[m+10];
    int maxl=0;
    int rinf=1000000;
    for (int i=0;i<m;i++){
        cin >> l[i] >> r[i];
        maxl=max(maxl,l[i]);
        rinf=min(rinf,r[i]);
    }
    if(maxl>rinf) cout << 0 << endl;
    else {
        int ans=rinf-maxl+1;
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    long[][][] dp;
    int mod  = (int) 1e9 + 7;

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

        Main instance = new Main();

        int res = (int) instance.solve(K, D);

        System.out.println(res);
    }

    public long solve(String K, int D) {
        int n = K.length();

        this.dp = new long[n][2][D];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < D; k++) {
                    dp[i][j][k] = -1;
                }
            }
        }

        long res = dfs(0, K, D, 0, 0);

        return (res + mod - 1) % mod;
    }

    public long dfs(int index, String K, int D, int flag, int d) {
        if (index >= K.length()) {
            if (d == 0) return 1;
            else return 0;
        }

        if (dp[index][flag][d] != -1) return dp[index][flag][d];

        int ch = K.charAt(index) - '0';

        long res = 0;

        if (flag == 1) {
            for (int i = 0; i < 10; i++) {
                res += dfs(index + 1, K, D, 1, (d + i) % D);
                res %= mod;
            }
        } else {
            for (int i = 0; i < ch; i++) {
                res += dfs(index + 1, K, D, 1, (d + i) % D);
                res %= mod;
            }
            res += dfs(index + 1, K, D, 0, (d + ch) % D);
        }

        dp[index][flag][d] = res % mod;
        return dp[index][flag][d];

    }
}


Measured memory_bytes: 71596
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> inputs = new ArrayList<Integer>();
		
		setInputs(inputs);
		
		ArrayList<Integer> results = new ArrayList<Integer>();
		
		//nÜÅÌfÌðÊXgÉÇÁ·é
		for(int i = 0; i < inputs.size(); i++){
			results.add(getNumPrimeNumbers(inputs.get(i)));
		}
		
		//ÊðoÍ·é
		for(int i = 0; i < results.size(); i++){
			System.out.println(results.get(i));
		}
	}
	
	private static void setInputs(ArrayList<Integer> inputs){
		Scanner sc = new Scanner(System.in);
		
		try{
			while(sc.hasNextInt()){
				inputs.add(sc.nextInt());
			}
		}catch(NoSuchElementException e){
			//EOF,EOTªüÍ³ê½ç½à¹¸ðÖißé
		}
	}
	
	private static boolean isPrimeNumber(int n){
		if(n == 2){
			return true;
		}
		else if(n % 2 == 0){
			return false;
		}
		
		for(int i = 3; i  * i < n + 1; i = i + 2){
			if(n % i == 0){
				return false;
			}
		}
		return true;
	}
	
	private static int getNumPrimeNumbers(int n){
		int count = 0;
		for(int i = 2; i < n + 1; i++){
			if(isPrimeNumber(i)){
				count++;
			}
		}
		
		return count;
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,H[5005],P[5005],id[5005];
ll dp[5005];
bool cmp(int b,int c){
	return min(H[b],H[c]-P[b])>min(H[c],H[b]-P[c]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d%d",H+i,P+i),id[i]=i;
	sort(id+1,id+1+n,cmp);
	memset(dp,0x3f,sizeof dp);
	int top=dp[0]=0;
	for(int i=1;i<=n;++i)
		for(int j=top;j>=0;--j)
			if(dp[j]<=H[id[i]]&&dp[j]+P[id[i]]<dp[j+1]){
				dp[j+1]=dp[j]+P[id[i]];
				if(j==top)++top;
			}
	printf("%d\n",top);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll i,n,k;map<ll,ll> b;cin>>n>>k;vll a(n);ain(i,n,a);
  //caricurate
  rep(i,n){
    for(ll j=i+1;j<n;j++){
      if(a[i]>a[j]){b[i]++;}
    }
    b[i]%=MOD;
  }
  vrsort(a);map<ll,ll> v;
  for(i=0;i<n;i++){
    ll j=i+1;
    while(a[i]==a[j]){j++;}
    v[a[i]]=n-j;
    v[a[i]]%=MOD;
  }
  //b*k+v*((k-1)*k)/2
  k%=MOD;
  ll ans=0;
  rep(i,n){
  ll h;
  if(k%2){h=(k-1)/2;h*=k;h%=MOD;}else{h=k/2;h*=(k-1);h%=MOD;}
  h*=v[a[i]];h%=MOD;
  ll y=b[i]*k;y%=MOD;ans+=y;ans%=MOD;ans+=h;ans%=MOD;
  }
  //output
  cout<<ans<<endl;
  
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int ans = min(a,k);
	k = max(0,k-a);
	if(k)
	{
		k = max(0,k-b);
		if(k)
		{
			ans -= k;
			cout << ans << "\n";
		}
		else
			cout << ans << "\n";
	}
	else
		cout << ans << "\n";
}

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

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

    int i;
    long long n;
    cin >> n;

    vector<int> a(n), b(n), c(n);
    for (i = 0; i < n; i++){
        cin >> a[i];
    }
    for (i = 0; i < n; i++){
        cin >> b[i];
    }
    for (i = 0; i < n; i++){
        cin >> c[i];
    }

    sort(begin(a), end(a));
    sort(begin(b), end(b));
    sort(begin(c), end(c));

    long long res = 0;

    for (i = 0; i < n; i++){
        int acount = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        int ccount = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
        if(acount > 0 && ccount < n){
            res += acount * (n - ccount);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    
    int x;
    cin >> x;
    
    for(int i = x;; i++){
        bool f = false;
        for(int j = 2; j < x; j++){
            if(i % j == 0){
                f = true;
                break;
            }
        }
        if(!f){
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}


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

int main() {
    int N; 
    cin >> N;
    string S = to_string(N);
    int sum =0;
    for(int i=0; i<S.size(); i++){
        sum += S.at(i) - '0';
    }

    if(N%sum==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int sum(int n){
    int sum=0;
    while(n>0){
        sum += n%10;
        n/=10;
    }
    return sum;
}

int dig(int n){
    int dig=0;
    while(n>0){
        dig++;
        n /= 10;
    }
    return dig;
}

int main() {
    int a,b;
    cin >> a >> b;
    if(a == 2 || b == 2) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
// Problem : C - HonestOrUnkind2
// Contest : AtCoder Beginner Contest 147
// URL : https://atcoder.jp/contests/abc147/tasks/abc147_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

vector<pii> te[20];
int cur[20]; // 0: undecide, 1: yes, 2: no

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N; cin >> N;
    rep(i, N) {
        int Ai; cin >> Ai;
        rep(j, Ai) {
            int u, b; cin >> u >> b;
            te[i].pb({--u, ++b});
        }
    }
    int ans = 0;
    rep(mask, 1<<N) {
        if(ans >= __builtin_popcount(mask)) continue;
        memset(cur, 0, sizeof cur);
        bool ok = true; queue<int> bq;
        rep(bit, N) {
            if(mask&(1<<bit)) {
                cur[bit] = 2;
                bq.push(bit);
            } else cur[bit] = 0;
        }
        while(!bq.empty()) {
            int at = bq.front(); bq.pop();
            for(pii& v:te[at]) {
                if(cur[v.fi] == 0) {
                    cur[v.fi] = v.se;
                    if(v.se == 2) bq.push(v.fi);
                } else if(cur[v.fi] != v.se) {
                    ok = false;
                    break;
                }
            }
        }
        if(ok) ans = __builtin_popcount(mask);
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[100010];
int main(){
	int n;
	cin >> n;
	int sum=1;
	for(int i=1;i<=n;i++){
		int t;
		cin >> t;
		a[t]=sum++;
	}
	for(int i=1;i<=n;i++){
		cout << a[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;cin>>S;
  
  if(S[0]==S[2]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  int flag = 0;
  long long sum = 0;
  int cnt = 0;
  long long m = 1e18;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] == 0) flag = 1;
    sum += abs(A[i]);
    if(A[i] < 0) cnt++;
    m = min(m, abs(A[i]));
  }
  if(flag == 1 || cnt % 2 == 0){
    cout << sum << endl;
    return 0;
  }
  cout << sum - m * 2 << endl;
}


Measured memory_bytes: 4000
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

for i in range(1, N):
    A1[i] = A1[i-1] +A1[i]

A2[0] = A1[0] + A2[0]

for j in range(1, N):
    A2[j] = max(A2[j-1] + A2[j], A2[j] + A1[j])

A = A1 + A2
print(max(A))

Measured memory_bytes: 9116
#include<cstdio>
#include<algorithm>
using std::sort;
using std::max;
using std::min;
#include<set>
using std::multiset;
#define reg register
#define INF 0X3F3F3F3F

const int MAXN=100000+5;

struct Interval{
	int l,r;
	bool operator<(const Interval& a)const{
		return r<a.r;
	}
};

int n;
Interval a[MAXN];
multiset<int> S;

inline void Read(void);
inline void Work(void);

int main(void){
	Read();
	Work();
	return 0;
}

inline void Read(void){
	reg int i;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d%d",&a[i].l,&a[i].r);
	return;
}

inline void Work(void){
	reg int i;
	int ans=0;
	sort(a+1,a+1+n);
	int l_B=a[1].l,r_B=a[1].r;
	for(i=2;i <= n;++i)
		S.insert(a[i].l);
	for(i=2;i<=n-1;++i){
		S.erase(S.find(a[i].l));
		int r_A=a[i].r,L2=*S.rbegin(),temp=0;
		temp=max(temp,max(r_A-max(L2,a[i].l)+1,0)+max(r_B-l_B+1,0));
		temp=max(temp,max(r_A-a[i].l+1,0)+max(r_B-max(l_B,L2)+1,0));
		ans=max(temp,ans);
		l_B=max(l_B,a[i].l),r_B=min(r_B,a[i].r);
	}
	ans=max(ans,max(r_B-l_B+1,0)+max(a[n].r-a[n].l+1,0));
	printf("%d\n",ans);
	return;
}

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

void fnInput(int& rnAchieve, vector<int>& rvnPrice, vector<vector<int>>& rvvnSkill)
{
  int nPriceSiz, nSkillSiz;
  cin >> nPriceSiz >> nSkillSiz >> rnAchieve;
  rvnPrice.resize(nPriceSiz);
  rvvnSkill.resize(nPriceSiz, vector<int>(nSkillSiz));

  for (int ny = 0; ny < rvvnSkill.size(); ny++)
  {
    cin >> rvnPrice[ny];

    for (int nx = 0; nx < rvvnSkill[ny].size(); nx++)
      cin >> rvvnSkill[ny][nx];
  }
}

int fnMinPriceSkillup(int nAchieve, const vector<int> cnrvnPrice, 
                      const vector<vector<int>>& cnrvvnSkill)
{
  int nMinPrice = INT_MAX;

  for (int nCtl = 0; nCtl < ( 1 << cnrvnPrice.size() ); nCtl++)
  {
    int nPrice = 0;
    vector<int> vnSumSkill(cnrvvnSkill[0].size());

    for (int ny = 0; ny < cnrvnPrice.size(); ny++)
      if (nCtl & ( 1 << ny ))
      {
        for (int nx = 0; nx < cnrvvnSkill[ny].size(); nx++)
          vnSumSkill[nx] += cnrvvnSkill[ny][nx];

        nPrice += cnrvnPrice[ny];
      }

    bool bRslt = true;

    for (int nSumSkill : vnSumSkill)
      if (nSumSkill < nAchieve)
      {
        bRslt = false;
        break;
      }

    if (bRslt)
      nMinPrice = min(nMinPrice, nPrice);
  }
  if (nMinPrice == INT_MAX)
    return -1;
  else
    return nMinPrice;
}
  
int main()
{
  int nAchieve;
  vector<int> vnPrice;
  vector<vector<int>> vvnSkill;

  fnInput(nAchieve, vnPrice, vvnSkill);
  cout << fnMinPriceSkillup(nAchieve, vnPrice, vvnSkill) << endl;

  return 0;
}

Measured memory_bytes: 3620
/*
*/
#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>  
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-10
#define M_PI 3.141592653589793
#define bs 1000000007;
#define bsize 512

const int N = 233031;

using namespace std;

long long n, Q;
long long q[N];

vector<pair<long long, long long> > queries[N];

map<long long, long long> s, toadd;
map<long long, long long> ::iterator it;
long long res[N];

int main(){
	//freopen("beavers.in","r",stdin);
	//freopen("beavers.out","w",stdout);
	//freopen("F:/in.txt","r",stdin);
	//freopen("F:/output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> n >> Q;
	for (int i = 1; i <= Q; i++)
	{
		cin >> q[i];
	}

	
	q[0] = n;

	s[q[Q]] = 1;

	for (int i = Q; i>=0; --i)
	{
		toadd.clear();
		while (true)
		{
			if (s.size() == 0)
				break;
			it = s.end();
			--it;
			long long val = (*it).first;
			long long times = (*it).second;
			if (val <= q[i])
				break;
			s.erase(it);
			toadd[q[i]] += val / q[i]*times;
			if (val%q[i])
				toadd[val%q[i]] += times;
		}
		for (it = toadd.begin(); it != toadd.end(); it++)
		{
			long long val = (*it).first;
			long long times = (*it).second;
			s[val] += times;
		}
		/*for (it = s.begin(); it != s.end(); it++)
		{
			cout << (*it).first << "%%" << (*it).second << endl;
		}
		cout << endl;*/
	}

	long long ttl = 0;

	for (it = s.begin(); it != s.end(); it++)
	{
		long long val = (*it).first;
		long long times = (*it).second;
		//cout << "@@" << val << " " << times << endl;
		res[val+1] += times;
		ttl += times;
	}

	/*for (int i = 1; i <= 5; i++)
	{
		cout << res[i] << " ";
	}
	cout << endl;
	*/
	//cout << ttl << endl;

	for (int i = 1; i <= n; i++)
	{
		ttl -= res[i];
		cout << ttl << "\n";
	}

	cin.get(); cin.get();
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S.at(2)==S.at(3)&&S.at(5)==S.at(4)){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define _1 first
#define _2 second
#define pb push_back
#define mod 1000000007
#define INF 1050000000

const int maxn = 1e5+10;

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

	int n,m; 
	cin >> n>>m;

	vvi v(1e6+10);

	int a, b;
	rep(i, m) {
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}

	for (auto i : v[1])for (auto j : v[i]) if (j == n) {
		cout << "POSSIBLE" << endl; return 0;
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 30704
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<cctype>
using namespace std;



int main(void)
{
  int n;
  int ans=0;
  cin>>n;
  int a;
  for(int i=0;i<n;i++){
    cin>>a;
    while(a%2==0){
      a/=2;
      ans++;
    }
  }
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b;cin>>a>>b;
    ll sum=0,last = b-a;
    for(ll i=1;i<last;i++)sum+=i;
    cout<<max(0ll,sum-a);
}


Measured memory_bytes: 256
# http://tutuz.hateblo.jp/entry/2019/02/25/154609

n = int(input())
p = tuple(map(int, input().split()))

a = [-1] * n
for x, ind in enumerate(p, 1):
    a[ind - 1] = x

# {a_pi+b_pi}を満たす
# {an},{bn}を満たさない

# {an}を満たす
# 累積和を取る

# 単純に累積和を取ると、{a_pi+b_pi}が崩れる
# {bn}から差し引くことで、累積和をとっても、{a_pi+b_pi}が崩れない

b = [0] * n
for i in range(1, n):
    b[i] -= a[i - 1]  # bにaの累積和をキャンセルする / これにより、すでに{bn}は単調減少
    a[i] += a[i - 1]  # 累積和

abs_min = abs(min(b)) + 1
b = list(map(lambda x: x + abs_min, b))

print(*a)
print(*b)


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

int main(){
    int n = 3;
    int a[n];
    for (int i = 0; i < n; i++){
     cin >> a[i];   
    }
    int tmp;
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            if (a[i] > a[j]){
                tmp = a[j];
                a[j] = a[i];
                a[i] = tmp;
            }
        }
    }
    for (int i = 0; i < n-1; i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    return 0;
}


Measured memory_bytes: 3092
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    var maxL = 0
    var minR= N
    for (m in 0 until M) {
        val (l, r) = listOfInt()
        if (maxL < l) maxL = l
        if (minR > r) minR = r
    }
    val ans = Math.max(0, minR - maxL + 1)
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 58384
#include <bits/stdc++.h>
using namespace std;
long long int k;
char arr[100+5];
int main(){
  
  cin>>k;
  cin>>arr;
  if(k%2==1) {
      cout<<"No";
        return 0;
  }
  for (int i = 0; i < k/2; ++i)
  {    int t= k/2;
      if (arr[i] != arr[t+i])
      {  
          cout<<"No";
          return 0;
      }
  }
            cout<<"Yes";



}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		int Slen = S.length();
		int cnt0=0,cnt1=0;
		for(int i=0;i<Slen;i++) {
			if(S.substring(i,i+1).equals("0"))cnt0++;
			else cnt1++;
		}
		//System.out.println(cnt0+" "+cnt1);
		System.out.println(Slen-Math.abs(cnt0-cnt1));
	}
}


Measured memory_bytes: 30232
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  k <- readLn
  xs <- getInts
  print $ solve n k xs

solve :: Int -> Int -> [Int] -> Int
solve n k xs = 2 * sum costs where
  costs = map cost xs
  cost x = min x . abs $ k - x

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


Measured memory_bytes: 508
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

int main() {
	
	ll x, y;
	cin >> x >> y;

	ll ret;
	ll now = x;
	ll cnt = 2;
	deque<ll> ans;

	while (true) {
		if (now > y) break;
		now *= cnt;
		ans.push_back(now);
	}
	ret = ans.size();


	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256