akhauriyash/Code-Regression huggingface dataset:
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int X;
	cin >> X;

	vector<int> beki;
	beki.emplace_back(1);
	for (int i = 2; i <= sqrt(1000); i++) {
		int bekiOne = i * i;
		while (bekiOne <= 1000) {
			beki.emplace_back(bekiOne);
			bekiOne *= i;
		}
	}

	int ans = 0;
	for (auto one : beki) {
		if (one <= X) {
			ans = max(ans, one);
		}
	}

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



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    string s;
    cin >> s;

    string t = "CODEFESTIVAL2016";

    int ans = 0;
    REP(i,s.size()) if(s[i]!=t[i]) ans++;

    pl(ans)

    return 0;
}

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

int main() {
  int N,K;
  cin >>N>>K;
  int a=1;
  
  for(int i=1;;i++){
    if(pow(K,i) <= N){
      a++;
    }
    if(pow(K,i) > N){
      break;
    }
  }
  cout << a << endl;
}


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

int main()
{
	string s, t;
	cin >> s >> t;
	if (s.size() + 1 == t.size()) {
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != t[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}


Measured memory_bytes: 3628
N = int(input())
ans = 0
for i in range(1,N+1):
    n = str(i)
    if n[-1]=="0":continue
    if n[0]==n[-1]:
        ans+=1
    for j in range(5):
        a = int(n[-1]+"0"*j+n[0])
        b = int(n[-1]+"9"*j+n[0])
        if b<=N:
            ans+=10**j
        elif a<=N and N<b:
            ans+=(N-a)//10+1
        else:break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871;
const int N = 10;
char matrix[N][N];
char matrix2[N][N];
int h, w, k;
bool check(int msk, int msk2) {
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            matrix2[i][j] = matrix[i][j];
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if((msk & (1 << (i-1))) == 0 && (msk2 & (1 << (j-1))) == 0) continue;
            matrix2[i][j] = '*';
        }
    }
    /*
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++)
            cout << matrix2[i][j];
        cout << "\n";
    }*/
    int cnt = 0;
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            if(matrix2[i][j] == '#')
                cnt++;
    return cnt == k;
}
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
    cin >> h >> w >> k;
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            cin >> matrix[i][j];
    int ans = 0;
    for(int msk = 0; msk < (1 << h); msk++) {
        for(int msk2 = 0; msk2 < (1 << w); msk2++) {
            if(check(msk, msk2)) ans++;
        }
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



typedef long long ll;
#define INF 1LL<<60
int X, Y, Z, N;
ll A[101010], B[101010], C[101010];
ll AA[101010], BB[101010];
//---------------------------------------------------------------------------------------------------
ll dp1[101010];
void dodp1() {
    priority_queue<ll> que;
    rep(i, 0, N) dp1[i] = -INF;
    ll sm = 0;

    rep(i, 0, N) {
        que.push(-AA[i]);
        sm += AA[i];
        if (X < que.size()) {
            ll q = -que.top();
            sm -= q;
            que.pop();
        }
        if (que.size() == X) dp1[i] = sm;
    }
}
//---------------------------------------------------------------------------------------------------
ll dp2[101010];
void dodp2() {
    priority_queue<ll> que;
    rep(i, 0, N) dp2[i] = -INF;
    ll sm = 0;

    rrep(i, N - 1, 0) {
        que.push(-BB[i]);
        sm += BB[i];
        if (Y < que.size()) {
            ll q = -que.top();
            sm -= q;
            que.pop();
        }
        if (que.size() == Y) dp2[i] = sm;
    }
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> X >> Y >> Z;
    N = X + Y + Z;
    rep(i, 0, N) cin >> A[i] >> B[i] >> C[i];

    ll ans = 0;
    rep(i, 0, N) {
        ans += C[i];
        A[i] -= C[i];
        B[i] -= C[i];
    }

    vector<int> v;
    rep(i, 0, N) v.push_back(i);
    sort(v.begin(), v.end(), [&](int a, int b) { return A[a] - B[a] > A[b] - B[b]; });
    rep(i, 0, N) {
        int j = v[i];
        AA[i] = A[j];
        BB[i] = B[j];
    }

    dodp1(); dodp2();

    ll ma = -INF;
    rep(k, 0, N - 1) ma = max(ma, dp1[k] + dp2[k + 1]);

    ans += ma;
    printf("%lld\n", ans);
}

Measured memory_bytes: 7288
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n;
  cin>>n;
  
  int a[n+1];
  REPP(i,n){
    cin>>a[i];
  }
  
  int b[n+1]={};
  int temp;
  int index;
  int m=0;
  for(int i=n;i>=1;i--){
    temp = 0;
    index = 1;
    while(index*i<=n){
      temp += b[index*i];
      index++;
    }
    if(temp%2==a[i]){
      continue;
    }else{
      b[i]++;
      m++;
    }
  }
  
  cout<<m<<endl;
  REPP(i,n){
    if(b[i]==1){
      cout<<i<<endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long N){
	ll res = 0;
	FOR(i, 1, N+1) {
		if (i%3==0) continue;
		if (i%5==0) continue;
		res += i;
	}
	cout << res << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}

Measured memory_bytes: 3692
s = input().strip()
s1 = ["R", "U","D"]
s2 = ["L","U","D"]

for i in range(0,len(s),2):
    if not s[i] in s1:
        print("No")
        exit()

for i in range(1,len(s),2):
    if not s[i] in s2:
        print("No")
        exit()

print("Yes")


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

long long solve (int n,long long x){
  if (x==1&&n==0){
    return 1;
  }
  else if (x==1&&n!=0){
    return 0;
  }
  else if (x<pow(2,n+1)-1){
    return solve(n-1,x-1);
  }
  else if (x==pow(2,n+1)-1){
    return pow(2,n);
  }
  else if (x<pow(2,n+2)-3){
    return pow(2,n)+solve(n-1,x-pow(2,n+1)+1);
  }
  else {
    return pow(2,n+1)-1;
  }
}
 
int main() {
  long long N,X;
  cin >> N >> X;
  long long ans=solve(N,X);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include <cmath>
#include<cstdio>
#include<cstring>
#include<cstring> 
#include<cmath>
#include<deque>  
#include<functional>
#include<iostream>
#include<map> 
#include<vector>
#include<queue>
#include<string>  
#include<stack>  
#include<set>
#define mst(x,y) memset(x,y,sizeof x)
#define mp(x,y) make_pair((x),(y))
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
int n,a[100005],ns[100005],ans;
int main()
{
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
	}
	ans=(a[0]>0?a[0]:-a[0]); 
	for(int dis,i=1;i<n;i++){
		dis=(a[i]>a[i-1]?a[i]-a[i-1]:a[i-1]-a[i]);
		ans+=dis;
	}
	ans+=(a[n-1]>0?a[n-1]:-a[n-1]);
	ns[0]=((a[0]-0)*(a[1]-a[0])>0?0:2*min(abs(a[0]-0),abs(a[1]-a[0])));
	ns[n-1]=((a[n-1]-a[n-2])*(0-a[n-1])>0?0:2*min(abs(a[n-1]-a[n-2]),abs(0-a[n-1])));
	//cout<<ns[n-1]<<endl;
	for(int i=1;i<n-1;i++){
		ns[i]=((a[i]-a[i-1])*(a[i+1]-a[i])>0?0:2*min(abs(a[i]-a[i-1]),abs(a[i+1]-a[i])));
	}
	for(int i=0;i<n;i++){
		printf("%d\n",ans-ns[i]);
	}
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main()
{
    int n;
    int s=100000;
    cin>>n;
    for(int f=1;f<=n;f++)
    {
        s=s*1.05;
        if(s%1000!=0)
        {
            int u =s%1000;
            u=1000-u;
            s+=u;
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
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;}

int main(){
  int X; cin >> X;
  double px=0,py=0;
  int ans = 0;
  double deg = X;
  do{
    px += cos(deg*2*acos(-1)/360);
    py += sin(deg*2*acos(-1)/360);
    deg += X;
    ans++;
  }while(abs(px)>0.00001 || abs(py)>0.00001);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3948
//#pragma GCC optimize("O2")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 2e5 + 55;
const int mod = 1e9 + 7;
int n, a[maxn];
ll bp(ll a, ll p) {
	ll r = 1;
	while(p) {
		if(p&1) r = (r*a)%mod;
		a = (a*a)%mod, p>>=1;
	}
	return r;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	int g = 0;
	map<int, int> po;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		ll t = a[i];
		for(int d = 2; d*1ll*d <= t; d++) {
			if(t%d) continue;
			int cnt = 0;
			while(t%d == 0) t/=d, cnt++;
			po[d] = max(po[d], cnt);
		}
		po[t] = max(po[t], 1);
	}
	ll t = 1, q = 0;
	for(auto i : po)
		t = (t*bp(i.first, i.second))%mod;
	for(int i = 0; i < n; i++) {
		q = (q + t*bp(a[i], mod-2))%mod;
	}
	cout << q;

}


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

// 辺を表す構造体
struct edge{
    int to;
    long long cost;
};

// キューに入れる頂点を表す構造体
struct node{
    int id;
    long long cost;

    bool operator<(const node& rhs) const {
        return cost > rhs.cost;
    }
};

constexpr long long INF = 1LL << 61;

void dijkstra(int s, vector<long long>& cost, const vector< vector<edge> >& g){
    cost.resize(g.size());
    fill(cost.begin(), cost.end(), INF);
    cost[s] = 0;
    priority_queue<node> que;
    que.push({s, 0LL});

    while(!que.empty()){
        node now = que.top();
        que.pop();
        if(cost[now.id] < now.cost){
            continue;
        }
        for(auto& e : g[now.id]){
            if(cost[e.to] > now.cost + e.cost){
                cost[e.to] = now.cost + e.cost;
                que.push({e.to, now.cost + e.cost});
            }
        }
    }

    return;
}

int main(){
    int v, e, r;
    cin >> v >> e >> r;

    vector< vector<edge> > g(v);
    for(int i = 0 ; i < e ; ++i){
        int s, t;
        long long d;
        cin >> s >> t >> d;
        g[s].push_back({t, d});
    }

    vector<long long> cost;
    dijkstra(r, cost, g);

    for(int i = 0 ; i < v ; ++i){
        if(cost[i] < INF){
            cout << cost[i] << endl;
        }else{
            cout << "INF" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 19304
main(r,T,a,b,c,d,e,A,B,C){for(;scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&A,&B,&C)>7;printf("%d\n",r)){
	r=a*A+b*B+c*C;
	if(C>=d){
		if(r>a*A+b*B+e*C)r=a*A+b*B+e*C;
	}else{
		if(r>a*A+b*B+e*d)r=a*A+b*B+e*d;
		if(B+C>=d){
			if(T=d-C,r>a*A+b*(B-T)+e*d)r=a*A+b*(B-T)+e*d;
		}else if(A+B+C>=d){
			if(T=d-B-C,r>a*(A-T)+e*d)r=a*(A-T)+e*d;
		}else{
			if(r>e*d)r=e*d;
		}
	}
}exit(0);}

Measured memory_bytes: 600
#define _CRT_SECURE_NO_WARNINGS

#define MAX_N 10

#include <stdio.h>

int N, M;

int states[MAX_N];

int p[MAX_N];

void input()
{
    scanf("%d%d", &N, &M);
    for (int i = 0; i < M; ++i)
    {
        int z;
        scanf("%d", &z);
        for (int k = 0; k < z; ++k) {
            int b;
            scanf("%d", &b);
            states[i] |= 1 << (b - 1);
        }
    }
    for (int i = 0; i < M; ++i)
    {
        scanf("%d", &p[i]);
    }
}

int bits(int x)
{
    int ans = 0;
    while (x)
    {
        ++ans;
        x &= x - 1;
    }
    return ans;
}

int solve()
{
    int ans = 0;
    for (int s = 0; s < 1 << N; ++s)
    {
        int tag = 1;
        for (int i = 0; i < M; ++i)
        {
            int z = s & states[i];
            if ((bits(z) & 1) != p[i])
            {
                tag = 0;
                break;
            }
        }
        ans += tag;
    }
    return ans;
}

int main()
{
    input();
    printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;
int a[4];
int main()
{
	for(int i=1;i<=3;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+3);
	printf("%d",a[3]-a[1]);
	return 0;
}

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

#define INF 1000000000

int main(){
    int N,M,C,ans;
    ans = 0;
    cin >> N >> M >> C;
    vector<int> B(M);
    for(int i=0;i<M;i++) cin >> B[i];

    vector<vector<int>> A(N,vector<int>(M));
    for(int i=0;i<N;i++){
        int sum = 0;
        for(int j=0;j<M;j++){
            cin >> A[i][j];
            sum += A[i][j]*B[j];
        }
        if((sum+C) > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    V<int> ca(n + 1), cb(n + 1);
    for (int i = 0; i < n; i++) {
        ca[i + 1] = ca[i] + (s[i] == 'R');
        cb[i + 1] = cb[i] + (s[i] == 'W');
    }
    int res = INF;
    for (int i = 0; i <= n; i++) {
        int a = ca[n] - ca[i], b = cb[i];
        chmin(res, max(a, b));
    }
    cout << res << newl;
}

Measured memory_bytes: 5188
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();

    if ((Math.abs(b - a) % 2) == 0) {
      System.out.println((Math.abs(b - a) / 2) + Math.min(a, b));
    } else {
      System.out.println("IMPOSSIBLE");
    }

  }
}

Measured memory_bytes: 35692
#B - Comparing Strings
a,b = list(map(int, input().split()))
A=[]
B=[]
for row in range(b):
    A.append(a)
for row in range(a):
    B.append(b)

A=''.join(map(str,A))
B=''.join(map(str,B))

T=sorted([A,B])
print(T[0])

Measured memory_bytes: 3060
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int a;
string s;

void solve()
{
    cout << (a >= 3200 ? s : "red") << endl;
}

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

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(3*N);
  for(int i=0; i<3*N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int64_t ans = 0;
  
  for(int i=0; i<N; i++){
    ans += vec.at(2*i+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1536
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
#define MAX_ 1000000
int inv_list[MAX_]{}; //inv_list[i-1] = inverse of i
void inv_continuous(int n) {
  inv_list[0] = 1;
  for (int i = 0; i < n; i++) {
    inv_list[i + 1] = MOD - (inv_list[(MOD % (i + 2)) - 1] * (MOD / (i + 2)) % MOD);
  }
}
vector<int> prime_factor;
void prime_factorization(int n) {
  while (n % 2 == 0) {
    n /= 2;
    prime_factor.push_back(2);
  }
  for (int i = 3; i < (int)(sqrt((double)n)) + 2; i += 2) {
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
        prime_factor.push_back(i);
      }
    }
  }
  if (n != 1) {
    prime_factor.push_back(n);
  }
}
unordered_map<int, int> element_num; //change type if you need
template <class T>
void counter(T container) {
  for (int i = 0; i < container.size(); i++) {
    element_num[container[i]] += 1;
  }
}
class EFlatten {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> LIST(1000000, 0);
    rep(i, N) {
      element_num  = {};
      prime_factor = {};
      cin >> A[i];
      prime_factorization(A[i]);
      counter(prime_factor);
      for (auto &i : prime_factor) {
        LIST[i - 1] = max(LIST[i - 1], element_num[i]);
      }
    }
    inv_continuous(MAX_);
    int LCM = 1;
    rep(i, 1000000) {
      if (LIST[i]) {
        LCM *= bpm(i + 1, LIST[i]);
        LCM %= MOD;
      }
    }
    int ans = 0;
    rep(i, N) {
      ans = (ans + LCM * inv_list[A[i] - 1]) % MOD;
    }
    cout << ans << endl;
  }
};


signed main() {
  EFlatten solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 16000
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
using ll = long long;

int main()
{
    int k;
    string s;
    cin >> k;
    cin >> s;
    string snew = "";
    for (int i = 0; i<s.length(); i++)
    {
        if (i == k)
            {snew +="...";
            break;}
        else
            snew+=s[i];
    }
    cout << snew << endl;
}

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static String str;
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args) {
		int n = Integer.parseInt(scan.nextLine());
		//???????????????????????°???dice???????´?
		str = scan.nextLine();
		String[] dice1 = str.split(" ");
		str = scan.nextLine();
		String[] dice2 = str.split(" ");

		if(sort(dice1, dice2)){
			System.out.println("No");
			return;
		}else{
			for (int i = 0; i < n-2; i++) {
				if(!(sort(dice1, dice2))){
					str = scan.nextLine();
					dice2 = str.split(" ");
				}else{
					System.out.println("No");
					return;
				}
			}
		}
		
		System.out.println("Yes");
		
	}

	/**
	 * ?????????????????¢????????????????±???????????????????
	 * @param dice
	 * @param diceOrigin
	 * @return bool
	 */
	private static boolean sort(String[] dice, String[] diceOrigin){
		boolean bool = false;
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				for (int h = 0; h < 4; h++) {
					String[] direction = new String[i+j+(h*3)];
					String[] dice2 = Arrays.copyOf(dice, dice.length);
					//??????????????¢?????????
					for (int k = 0; k < i; k++) {
						direction[k] = "N";
					}
					//?¨????????????¢?????????
					for (int l = 0; l < j; l++) {
						direction[i+l] = "E";
					}
					//?????????????????????
					for (int f = 0; f < h; f++) {
						int num = f * 3;
						direction[i+j+num] = "W";
						direction[i+j+(num+1)] = "S";
						direction[i+j+(num+2)] = "E";
					}
					
					//move????????????
					bool = move(dice2, direction, diceOrigin);
					if(bool){
						return true;
					}
				}
			}
		}
		return bool;
	}
	
	/**
	 * ??????????????????????????????????????????
	 * @param dice
	 * @param direction
	 * @param diceOrigin
	 * @return diceCheck
	 */
	private static boolean move(String[] dice, String[] direction, String[] diceOrigin) {
		for (int i = 0; i < direction.length; i++) {
			if(direction[i].equals("E")){
				str = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = str;
			}else if(direction[i].equals("W")){
				str = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = str;
			}else if(direction[i].equals("S")){
				str = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = str;
			}else if(direction[i].equals("N")){
				str = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = str;
			}
		}
		
		/*
		 * ????????????????????????????????¢??¨?????????????????????????????¢???????????????
		 * ??¢????????£???????????°true??????????????§????????°false?????????
		 */
		boolean diceCheck = true;
		for (int i = 0; i < diceOrigin.length; i++) {
			for (int j = 0; j < diceOrigin.length; j++) {
				if(!(diceOrigin[i].equals(dice[i]))){
					return false;
				}
			}
		}
		return diceCheck;	
	}
}

Measured memory_bytes: 25116
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
if((a+b)<(c+d))cout<<"Right";
else if((a+b)==(c+d))cout<<"Balanced";
else cout<<"Left";
    return 0;
}

Measured memory_bytes: 256
def merge(A, left, mid, right):
	global cnt

	L = A[left:mid] + [1000000001]
	R = A[mid:right] + [1000000001]

	i = j = 0
	for k in range(left, right):
		if L[i] <= R[j]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1
	cnt += right - left

def mergeSort(A, left, right):
	if left + 1 < right:
		mid = (left + right) // 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)

if __name__ == '__main__':
	n = int(input())
	A = list(map(int, input().split()))
	cnt = 0
	mergeSort(A, 0, n)
	print(*A)
	print(cnt)


Measured memory_bytes: 63428
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>

#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 p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

using namespace std;
typedef long long ll;

const long long MOD = 1e9+7;

ll modPow(long long a, long long b, long long p){
    if(b == 1) return a % p;
    if(b%2 == 1) return (a * modPow(a, b - 1, p)) % p;
    long long tmp = modPow(a, b/2, p);
    return (tmp * tmp) % p;
}

ll calcP(ll start, ll end){
    ll tmp = 1;
    for(ll i = start; i >= end; i--){
        tmp *= i;
        tmp = tmp % MOD;
    }
    return tmp;
}

int main(){

    long long n, a, b;
    cin >> n >> a >> b;

    ll max = modPow(2, n, MOD) - 1;

//    ll end = n - a + 1;

    ll X = calcP(n, n - a + 1);
    ll Y = calcP(a, 1);

    ll tmp = calcP(4, 1);

    max -= (modPow(X, 1, MOD) * modPow(Y, MOD - 2, MOD))%MOD;
    if(max < 0){
        max += MOD;
    }

    X = calcP(n, n - b + 1);
    Y = calcP(b, 1);

    max -= (modPow(X, 1, MOD) * modPow(Y, MOD - 2, MOD))%MOD;
    if(max < 0){
        max += MOD;
    }

    p(max);

    return 0;

}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int popcount(int n)
{
	int res = 0;
	while (n)
	{
		n &= n - 1;
		++res;
	}
	return res;
}

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> vs(H);
	forn(i, H)
		cin >> vs[i];
	int bestres = H * W;
	forn(mask, 1 << (H-1))
	{
		bool gok = true;
		int actres = popcount(mask);
		vector<int> w(popcount(mask)+1);
		vector<int> part(H);
		forn(i, H-1)
		{
			part[i + 1] = part[i] + ((mask >> i) & 1);
		}

		forn(j, W)
		{
			bool ok = true;
			forn(i, H)
			{
				w[part[i]] += vs[i][j] - '0';
				if (w[part[i]] > K)
					ok = false;
			}
			
			if (!ok)
			{
				ok = true;
				actres++;
				w.clear();
				w.resize(popcount(mask) + 1);
				forn(i, H)
				{
					w[part[i]] += vs[i][j] - '0';
					if (w[part[i]] > K)
						ok = false;
				}
			}
			if (!ok)
			{
				gok = false;
				break;
			}
		}
		if (gok && bestres > actres)
		{
			bestres = actres;
		}
	}
	cout << bestres << endl;
	return 0;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)


S = input()

"""
10こ数字がならんでいるとして、各プラスいれるかいれないかで2**10通りある
つまり1024通りしかない
普通に計算するか、dfs
"""
def dfs(l):
    global ans
    if len(l) == len(S)-1:
        #  print(l)
        s = S[0]
        for idx, is_plus in enumerate(l):
            if is_plus:
                #  print(int(s))
                ans += int(s)
                s = S[idx+1]
            else:
                s = s + S[idx+1]
        else:
            #  print(int(s))
            ans += int(s)
    else:
        dfs(l + [True])
        dfs(l + [False])

ans = 0
dfs([])
print(ans)


Measured memory_bytes: 5464
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

int solve1()
{
    int n, m, ans = 0;
    bool exist = true;

    cin >> n >> m;
    vector<int> number(n, -1);

    rep(i, 0, m, 1)
    {
        int s, c;
        cin >> s >> c;
        --s;

        if (number[s] != -1 && number[s] != c)
        {
            //条件の矛盾が存在する場合
            exist = false;
        }
        else if (n > 1 && s == 0 && c == 0)
        {
            //2桁以上の条件下で最大桁を0にしようとしたとき
            exist = false;
        }
        else
        {
            number[s] = c;
        }
    }

    if (exist)
    {
        if (n > 1 && number[0] == -1)
        {
            //2桁以上の数であり、条件が入力で無かった場合
            number[0] = 1;
        }

        rep(i, 0, n, 1)
        {
            if (number[i] == -1)
            {
                number[i] = 0;
            }
            ans += number[i] * pow(10, n - 1 - i);
        }
    }
    else
    {
        ans = -1;
    }

    /*
    rep(i, 0, n, 1)
    {
        cout << number[i];
    }
    cout << endl;
    */

    return ans;
}

int main(void)
{
    cout << solve1() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=998244353;
int n,x;
LL ans,fac[100010],inv[100010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
LL C(int x,int y){
	return fac[x]*inv[y]%MO*inv[x-y]%MO;
}
LL cal(int x,int y){
	if (y<x || y>x*2) return 0ll;
	return C(x,y-x);
}
int main(){
	fac[0]=1;
	FOR(i,1,100000) fac[i]=fac[i-1]*i%MO;
	inv[100000]=pw(fac[100000],MO-2);
	FORD(i,99999,0) inv[i]=inv[i+1]*(i+1)%MO;
	cin>>n>>x;
	ans=1;
	FOR(m,1,n){
		LL t=0;
		FOR(j,0,x-1) (t+=cal(m,j))%=MO;
		FOR(i,0,m-1){
		//	<=i >=m-i+1
			if (m-i+1<=i) (t+=cal(i+i-m,x-1-(m-i)*2))%=MO;
			else if (i*2==x-1) (++t)%=MO;
		}
		(ans+=t*C(n,m))%=MO;
	}
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

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

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

    if (400 <= x && x <= 599) {
        cout << "8" << endl;
    }else if (600 <= x && x <= 799) {
        cout << "7" << endl;
    }else if (800 <= x && x <= 999) {
        cout << "6" << endl;
    }else if (1000 <= x && x <= 1199) {
        cout << "5" << endl;
    }else if (1200 <= x && x <= 1399) {
        cout << "4" << endl;
    }else if (1400 <= x && x <= 1599) {
        cout << "3" << endl;
    }else if (1600 <= x && x <= 1799) {
        cout << "2" << endl;
    }else if (1800 <= x && x <= 1999) {
        cout << "1" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
N,M = map(int,input().split())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    s = []
    for a in range(2):
        for b in range(2):
            for c in range(2):
                l.append(l[0]*((-1)**a)+l[1]*((-1)**b)+l[2]*((-1)**c))
    L.append(l)
cand = []
tmp = 0
for i in range(8):
    L = sorted(L,key=lambda x:x[3+i])[::-1]
    for j in range(M):
        tmp += L[j][3+i]
    cand.append(abs(tmp))
    tmp = 0
print(max(cand))


Measured memory_bytes: 45912
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(signed)(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 9000000000000;
#define LX 100010
    // struct edge{ll from,to,cost;};
    // edge es[2010];
    ll N,A,B;
    ll h[LX];
 
bool Judge(int x){
    int count=0;
    ll cost;
    for(int i=N-1;0<=i;i--){
         cost=h[i]-B*x;
        if(cost<=0)break;
            count+=(cost/(A-B));
            if(cost%(A-B)!=0)count++;
        if(count>x)break;
    }
    DEB(count)DEB(x)TF(!(count>x))END
    if(count>x)return false;
    else return true;
 
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>A>>B;
    REP(i,N)cin>>h[i];
    sort(h,h+N);
    int low=0,high=h[N-1]/B+1;
    ll mid;
    while(abs (high-low) > 1){
        mid=(high+low)/2;
        DEB(high)DEB(mid)DEB(low)END
        if(Judge(mid))high=mid;
        else low=mid;
    }
    cout<<high;
}
//ABC063 D - Widespread

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

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

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

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

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    cout<<n/3<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
  int n;
  std::cin >> n;
  int nn = n;
  int sum=0;
  while(n!=0){
    sum += n % 10;
    n -= (n % 10);
    n /= 10;
  }

  if(nn%sum==0){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
  return 0;
}


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

int main(){
    int k;
    cin >> k;
    vector<ll> a;
    for(int i=1;i<=9;i++)a.push_back(i);
    while(1){
        if(k<=a.size()){
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();
        vector<ll> b;
        swap(a,b);
        for(ll c:b){
            for(int i=-1;i<=1;i++){
                int s = c%10 + i;
                if(s>9 || s<0) continue;
                ll l = c*10 + s;
                a.push_back(l);
            }
        }
    }
    return 0;
}

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

int main(){
	double a, b, c, d, e, f;
	double x, y;
	while(cin >> a >> b >> c >> d >> e >> f){
		y = (c*d-a*f)/(b*d-a*e);
		x = (c-b*y)/a;
		printf("%.3f %.3f\n", x, y);
	}

	return 0;
}

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


int main()
{
	int c = 0, l = 0, n, act, ans = 0;

	cin >> n;

	while (n--) {
		cin >> act;
		if (act == c)
			l++;
		else
			ans += l / 2, l = 1, c = act;
	}

	cout << ans + l / 2 << '\n';

	return 0;
}





Measured memory_bytes: 256
import numpy as np
N = int(input())
data = [list(map(int,input().split())) for _ in range(N)]
list2 = []
for i in range(N):
    happy = data[i][0]+data[i][1]
    list2.append(happy)
S = np.array(list2)
S2 = S.argsort()[::-1]
glad = 0
for i in range(N):
    if i%2==0:
        glad += data[S2[i]][0]
    else:
        glad -= data[S2[i]][1]
print(glad)

Measured memory_bytes: 42216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

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

  int denomi = 0;
  rep(i, to_string(N).length()) {
    if (n < 10) {
      denomi += n;
      break;
    }
    denomi += n % 10;
    n /= 10;
  }

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


Measured memory_bytes: 3732
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    
    staff_list = []
    for _ in range(n):
        staff_list.append(0)
    
    for boss_index in a_list:
        staff_list[boss_index-1] += 1
    
    for staff in staff_list:
        print(staff)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32328
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    char s[201],t[101],p[101];
    cin >> s >> p;
    strcpy(t,s);
    strcat(s,t);
    if (strstr(s,p) == NULL) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    vector<int> deg(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        G[a].emplace_back(b);
        deg[b]++;
    }
    stack<int> S;
    for (int i = 0; i < n; ++i) {
        if(!deg[i]) S.emplace(i);
    }
    vector<int> ans;
    while(!S.empty()){
        int x = S.top(); S.pop();
        ans.emplace_back(x);
        for (auto &&i : G[x]) {
            if(!(--deg[i])) S.emplace(i);
        }
    }
    for (auto &&j : ans) cout << j+1 << "\n";
    return 0;
}


Measured memory_bytes: 3220