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

#define pb push_back
#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)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod = 1e9 + 7;
int main() {
	ll comb[2100][2100]{0};
	for(int i = 0; i < 2100; i++){
        for(int j = 0; j < 2100; j++){
            if(i == j || j == 0) comb[i][j] = 1;
            else if(j > i) comb[i][j] = 0;
            else comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % mod;
        }
    }
	int n, k; scanf("%d%d", &n, &k);
	for1(i, k) {
		ll result;
		result = comb[n-k+1][i] * comb[k-1][i-1] % mod;
		printf("%lld\n", result);
	}
	return 0;
}

Measured memory_bytes: 34688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k, a, b;
int main(){
    cin >> k >> a >> b;
    ll res = 1;
    if(b <= a + 2) res += k;
    else if(k <= a) res += k;
    else{
        k -= (a - 1);
        res = a + k / 2 * (b - a) + k % 2;
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
//#define LOCAL

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>

#define SIZE 1010

using namespace std;

char map[SIZE][SIZE];
int dir[][2] = {0, 1, 0, -1, 1, 0, -1, 0};

int bfs(int &x, int &y, int h, int w, int target){
	int step[SIZE][SIZE];
	for(int i = 0; i < h; i++)
		fill(step[i], step[i] + w, -1);
	step[x][y] = 0;

	queue<pair<int, int> > q;
	q.push(make_pair(x, y));

	while(!q.empty()){
		pair<int, int> temp = q.front();
		q.pop();

		if(map[temp.first][temp.second] == target + '0'){
			x = temp.first;
			y = temp.second;
			return step[x][y];
		}

		for(int i = 0; i < 4; i++){
			int newx = temp.first + dir[i][0];
			int newy = temp.second + dir[i][1];

			if(0 <= newx && newx < h && 0 <= newy && newy < w
				&& step[newx][newy] == -1 
				&& map[newx][newy] != 'X'){
				q.push(make_pair(newx, newy));
				step[newx][newy] = step[temp.first][temp.second] + 1;
			}
		}
	}
}

int main(void){
#ifdef LOCAL
	freopen("data.in", "r", stdin);
#endif
	int n, w, h;
	int x, y;

	scanf("%d%d%d", &h, &w, &n);
	getchar();
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			scanf("%c", &map[i][j]);

			if(map[i][j] == 'S'){
				x = i;
				y = j;
			}
		}
		getchar();
	}

	int result = 0;
	for(int i = 1; i <= n; i++)
		result += bfs(x, y, h, w, i);

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

	return 0;
}


Measured memory_bytes: 7568
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    int n; cin>>n;
    cout<<n/3;
    
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>

int main(void){
 int n;
  int d1[105], d2[105];
  scanf("%d", &n);
  int flag =0;
  for(int i=0;i<n;i++){
    scanf("%d %d", &d1[i], &d2[i]);
    if(i>=2){
    	if(d1[i]==d2[i]){
      		if((d1[i-1]==d2[i-1]) && (d1[i-2]==d2[i-2])){
              printf("Yes");
              return 0;
            }
        }
    }
  }
  printf("No");
  return 0;
      

}
  

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mo 1000000007
#define mems(a,x) memset(a,x,sizeof(a))
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
vector<ll>v[100005];


int main() {
	ll n,q;
	cin>>n>>q;
	vector<pair<ll,pair<ll,ll>>> v;
	for(int i=0;i<n;i++)
	{
		ll a,b,c;
		cin>>a>>b>>c;
		v.push_back(make_pair(a-c,make_pair(1,c)));
		v.push_back(make_pair(b-c,make_pair(-1,c)));
	}
	sort(v.begin(),v.end());
	ll k=0;
	multiset<ll>s;
	for(int i=0;i<q;i++)
	{
		ll d;
		cin>>d;
		while(k<2*n&&v[k].fi<=d)
		{
			if(v[k].se.fi==1)
			{
				s.insert(v[k].se.se);
				//cout<<v[k].fi<<v[k].se.se<<"in"<<" ";
			}
			else
			{
				s.erase(s.find(v[k].se.se));
				//cout<<v[k].se.se<<"dl"<<" ";
			}

			k++;

		}
		//cout<<endl;
		if(s.empty())cout<<"-1"<<endl;
		else
			cout<<*s.begin()<<endl;
	}


}


Measured memory_bytes: 23528
use input::Input;

fn main() {
    let mut input = Input::default();

    let n = input.parse();
    let ans = f(n);
    println!("{}", ans);
}

fn f(n: u64) -> String {
    let mut x = n;
    let mut res = String::new();

    while x > 0 {
        let p = (x % 26) as u8;
        let p = if p == 0 { 26 } else { p } - 1;
        res += &(('a' as u8 + p) as char).to_string();
        if x % 26 == 0 {
            x -= 1;
        }
        x /= 26;
    }
    res.chars().rev().collect()
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)



char S[505050], T[505050];
ll TZ[505050];
ll mt[505050], mk2[505050];
bool mk[60][505050];
ll i,j,k,ans;

void ZA(char *st){
    ll len=strlen(st);
    TZ[0] = len;
    ll i = 1, l = 0,r=1;
    //printf("%lld ",TZ[0]);
    fornum(i,1,len){
        if(i+TZ[i-l]<r){
            TZ[i] = TZ[i - l];
        }else{
            //printf("%lld:%lld ", i, r);
            l = i;
            while (r< len && st[r - l] == st[r])
                r++;
            TZ[i] = r - l;
            if(r==i){
                r++;
            }
        }
        //printf("%lld:%lld ", TZ[i],r);
    }
}

int main(){
    scanf("%s%s", S,T);
    ZA(T);
    ll Slen = strlen(S);
    ll Tlen = strlen(T);
    
    ll l=0,r=0;
    
    fornum(i,0,Slen){
        if(i+TZ[i-l]<r){
            mt[i] = TZ[i - l];
        }else{
            l = i;
            while(r-l<Tlen&&T[r-l]==S[r%Slen])
                r++;
            mt[i] = r - l;
            if(i==r){
                r++;
            }
        }
    }
    
    
    queue<ll> q;
    fornum(i,0,Slen){
        if(mt[i]==Tlen){
            mk[0][i] = true;
            mk2[i] = 1;
            q.push(i);
        }
    }
    if(q.size()==Slen){
        printf("-1");
        return 0;
    }
    
    fornum(i,0,40){
        ll a = q.size();
        fornum(j,0,a){
            ll qa = q.front();
            q.pop();
            if(mk[i][qa]&&mk[i][(qa+(1ll<<i)*Tlen)%Slen]){
                mk[i + 1][qa] = true;
                mk2[qa] *= 2;
                q.push(qa);
            }
        }
    }

    fornum(i,0,Slen){
        if(mk2[i]==(1ll<<40)){
            printf("-1");
            return 0;
        }
        ll a = mk2[i];
        ll b = (i+mk2[i] * Tlen) % Slen;
        while(mk2[b]){
            //printf("%lld ", b);
            a += mk2[b];
            b = (b + mk2[b] * Tlen) % Slen;
        }
        if(ans<a)
            ans = a;
        //printf(":%lld,%lld\n", i, ans);
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 36480
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l;
  int cnt = 0, mini = 0;

  cin >> n >> l;

  for(int i = 0;i < n;i++){
	cnt += (l + i);
  }

  if(l >= 0){
	mini = l;
  }else{
	mini = min((n - 1) + l, 0);
  }
  cout << cnt - mini << endl;
  
	
  return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    fun pow2(n: Int): ModInt {
        if (n == 0) return ModInt(1)
        var x = pow2(n / 2)
        x *= x
        if (n % 2 == 1) x *= 2
        return x
    }
    fun Combi(n: Int, a: Int): ModInt {
        var x = ModInt(1)
        var y = ModInt(1)
        repeat(a) { i ->
            x *= n - i
            y *= i + 1
        }
        return x / y
    }
    
    val (N, M) =listOfInt()
    var MNokori = M
    var ans = ModInt(1)
    var n = 2
    while (n * n <= MNokori) {
        if (MNokori % n == 0) {
            var cnt = 0
            while (MNokori % n == 0) {
                cnt++
                MNokori /= n
            }
            ans *= Combi(N + cnt - 1, N - 1)
        }
        n += 1
    }
    if (MNokori != 1) {
        ans *= Combi(N + 1 - 1, N - 1)
    }
    println(ans.toString())
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }

data class ModInt(private var v: Long) {
    companion object { private const val MOD = 1000000007L }
    init { this.v %= MOD }
    constructor(n: Int): this(n.toLong())
    operator fun plus(other: Int) = ModInt((this.v + other) % MOD)
    operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)
    operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)
    operator fun times(other: Int) = ModInt(this.v * other % MOD)
    operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)
    operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)
    private fun pow(a: Long, b: Long): Long {
        if (b == 0L) return 1L
        if (b % 2 == 0L) {
            val d = pow(a, b / 2)
            return (d * d) % MOD
        }
        return a * pow(a, b - 1) % MOD
    }
    override fun toString() = this.v.toString()
}


Measured memory_bytes: 50364
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    ll N,W,w[100],v[100];
    vector<ll> wv[4];
    vector<ll> sum[4];
    cin >> N >> W;
    for(int i = 0;i < N;i++){
        cin >> w[i] >> v[i];
        if(!i){
            wv[0].push_back(v[i]);
        }else{
            wv[w[i]-w[0]].push_back(v[i]);
        }
    }
    for(int i = 0;i < 4;i++){
        sort(wv[i].begin(),wv[i].end(),greater<ll>());
        sum[i].push_back(0);
        for(int j = 1;j <= wv[i].size();j++){
            sum[i].push_back(sum[i][j-1]+wv[i][j-1]);
        }
    }
    ll maxv = 0;
    for(int i = 0;i <= wv[0].size();i++){
        for(int j = 0;j <= wv[1].size();j++){
            for(int k = 0;k <= wv[2].size();k++){
                for(int l = 0;l <= wv[3].size();l++){
                    if(w[0]*i + (w[0]+1)*j + (w[0]+2)*k + (w[0]+3)*l > W)continue;
                    maxv = max(maxv,sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l]);
                }
            }
        }
    }
    cout << maxv << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long X){
    int a = X / 500;
    int b = (X % 500) / 5;
    cout << a * 1000 + b * 5 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b;
char op;
while(cin>>a>>op>>b){
if(op=='?'){
return 0;
}
else if(op=='+'){
cout<<a+b<<endl;
}
else if(op=='-'){
cout<<a-b<<endl;
}
else if(op=='*'){
cout<<a*b<<endl;
}
else if(op=='/'){
cout<<a/b<<endl;
}
}
     return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>

using namespace std;

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

const ll mod = 1e9+7;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

vector<ll> s;
ll dp[201][101000];

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

    for(int i = 0; i < 200; i++){
        fill(dp[i], dp[i]+101000, 0LL);
    }

    for(int i = 0; i < N; i++){
        ll xx;  cin >> xx;
        s.push_back(xx);
    }

    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());

    dp[0][x] = 1;
    for(int i = 0; i < N-1; i++){
        for(int j = 0; j <= x; j++){
            dp[i+1][j] = add(dp[i+1][j], mul(N-i-1, dp[i][j]));   // i番目を使わない
            int newX = j % s[i];
            dp[i+1][newX] = add(dp[i+1][newX], dp[i][j]);   // i番目を使う
        }
    }

//    for(int j = 0; j <= x; j++){
//        if(dp[N-1][j] != 0) {
//            cout << j << " " << dp[N-1][j] << endl;
//        }
////        ans = add(ans, mul(j, dp[N][j]));
//    }

    for(int j = 0; j <= x; j++){
        int newX = j % s[N-1];
        dp[N][newX] = add(dp[N][newX], dp[N-1][j]);
    }

    ll ans = 0;
    for(int j = 0; j <= x; j++){
//        if(dp[N][j] != 0) {
//            cout << j << " " << dp[N][j] << endl;
//        }
        ans = add(ans, mul(j, dp[N][j]));
    }
    cout << ans << endl;

    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vl l(n+1);
	l[0] = 2;
	l[1] = 1;
	REP(i, n - 1) {
		l[i + 2] = l[i + 1] + l[i];
	}
	cout << l[n] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
typedef long long ll;
using namespace __gnu_pbds;

typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;

lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
vector<ll> v[100005];
int vis[100005];
ll dp[100005];
ll n,m,i;
ll dfs(ll i)
{   if(dp[i]!=-1)
        return dp[i];
    vis[i]=1;
    ll j;
    ll ans=1;
    ll maxi=0;
    for(j=0;j<v[i].size();j++)
        maxi=max(dfs(v[i][j]),maxi);
    ans+=maxi;
    if(v[i].size()==0)
        ans=0;
    dp[i]=ans;
    return ans;
}
int main()
{   for(i=0;i<100005;i++)
        dp[i]=-1;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        v[x].pb(y);
    }
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
            dfs(i);
    }
    ll maxi=-1;
    for(i=1;i<=n;i++)
        maxi=max(maxi,dp[i]);
    cout<<maxi;
    return 0;
}






Measured memory_bytes: 8960
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int n;
	cin >> n;
	cout << "ABC" << n << endl;
	return 0;
}
/*
死のマウス
.　　あり許せん！
　　　∧＿＿∧
　|| （＃｀Д´ ） ||
　|| ( |　 　| | |||
　从| |　 　| |从从
￣) ⊂ノ￣￣!_つ￣て
　フヘ(　　　　ヽヘ(＼

*/

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vec<ll> A(N);
  REP(i, N) cin >> A[i];

  for (ll j = 0;; j++) {
    REP(i, N) {
      if (A[i] % 2 == 1) {
        cout << j << endl;
        return 0;
      }
      A[i] >>= 1;
    }
    if (all_of(ALL(A), [](ll Ai) { return Ai == 0; })) {
      cout << j << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3616
def main():
	s = input()

	start = ord('a')
	end = ord('z')

	for i in range(start,end+1):
		#print("*", chr(i))
		flg = 0
		for c in s:
			if c == chr(i):
				flg = 1
				break
		if flg == 0:
			print(chr(i))
			return
	print("None")
	return

if __name__ == '__main__':
	main()


Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
	int n, i, j, temp, flag;
	int a[1000];

	j = 0;
	
	scanf("%d", &n);

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

	flag = 1;
	while (flag)
	{
		flag = 0;
		for (i = n - 1; i >= 1; i--)
		{
			if (a[i] < a[i - 1])
			{
				temp = a[i];
				a[i] = a[i - 1];
				a[i - 1] = temp;
				flag = 1;
				j++;
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		printf("%d", a[i]);
		if (i != n - 1)
			putchar(' ');
	}
	putchar('\n');

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

	return 0;
}


Measured memory_bytes: 2124
import java.util.Scanner;

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

		int k = scan.nextInt();
		String s = scan.next();

		if(k >= s.length()) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0 , k) + "...");
		}
	}
}

Measured memory_bytes: 38612
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}


int main (){
    int x,y;
    int ans=0;
    cin >> x >> y;
    if(x==1&y==1){
        cout << 1000000 << endl;
        return 0;
    }
    if(x==1) ans+=300000;
    else if(x==2) ans+=200000;
    else if(x==3) ans+=100000;

    if(y==1) ans+=300000;
    else if(y==2) ans+=200000;
    else if(y==3) ans+=100000;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  while(op!='?'){
    int c;
    if(op=='+') c=a+b;
    if(op=='-') c=a-b;
    if(op=='*') c=a*b;
    if(op=='/') c=a/b;
    cout << c << endl;
    cin >> a >> op >> b;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

vi Topological_Sort(const Graph &G,vi h){
    stack<int> sta;
    vi ans;
    rep(i,G.size()) if(h[i]==0) sta.push(i);
    while(sta.size()){
        int t = sta.top();sta.pop();
        ans.push_back(t);
        for(auto v : G[t]){
            h[v]--;
            if(h[v]==0) sta.push(v);
        }
    }
    return ans;
}

int main(){
    int n,m;
    cin >> n >> m;
    Graph G(n);
    vi h(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        h[b]++;
    }
    vi v = Topological_Sort(G,h);
    reverse(v.begin(),v.end());
    vi dp(n,0);
    int ans = 0;
    for(int i :v){
        for(int u : G[i]){
            dp[i] = max(dp[i],dp[u]+1);
        }
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7164
using System;
using System.Collections.Generic;

namespace abc114_c
{
	class Program
	{
		static void Main(string[] args)
		{
			List<string>[] list = new List<string>[10];
			list[0] = new List<string> { "" };
			for (int i = 1; i < 10; i++)
			{
				list[i] = new List<string>();
				foreach (var item in list[i - 1])
				{
					list[i].Add(item + "3"); list[i].Add(item + "5"); list[i].Add(item + "7");
				}
			}
			int n = int.Parse(Console.ReadLine());
			int ret = 0;
			for (int i = 3; i < 10; i++)
			{
				foreach (var item in list[i])
				{
					int a = 0; int b = 0; int c = 0;
					for (int j = 0; j < item.Length; j++)
					{
						switch (item[j])
						{
							case '3': { a++; break; }
							case '5': { b++; break; }
							case '7': { c++; break; }
						}
					}
					if (int.Parse(item) <= n && a > 0 && b > 0 && c > 0) ret++;
				}
			}
			Console.WriteLine(ret);
		}
	}
}

Measured memory_bytes: 13792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    int count;
    count = 0;
    cin >> N;
    vector<int> l(N);
    for (int i = 0; i < N; i++)
    {
        cin >> l.at(i);
    }
    for (int i = 0; i < N - 2; i++)
    {
        for (int j = i + 1; j < N - 1; j++)
        {
            for (int k = j + 1; k < N; k++) //ここのkがjになってること気づかず時間間に合わなかった
            {
                if (l.at(i) != l.at(j) && l.at(j) != l.at(k) && l.at(k) != l.at(i) && l.at(i) + l.at(j) > l.at(k) && l.at(j) + l.at(k) > l.at(i) && l.at(k) + l.at(i) > l.at(j))
                    count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}

void putb(unsigned int v) {
  putchar('0'), putchar('b'), printb(v), putchar('\n');
}


int countTrailingZeroInbinary(int v) {
    if(v <= 1) return 0;
    int c = 0;
    while(v % 2 == 0) {
        v = v >> 1;
        c++;
    }
    return c;
}
int main()
{
	int N;
    cin >> N;
    int minCount = 999999999;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        int c = countTrailingZeroInbinary(a);
        if(c < minCount){
            minCount = c;
        }
    }
    cout << minCount << endl;
}


Measured memory_bytes: 384
import math as mt

s = int(input())
def check(x):
    a = [i for i in range(2,int(mt.sqrt(x))+1,1)]
    if all([x%j != 0 for j in a]):
        return False
    else:
        return True

f = True
while f:
    f = check(s)
    s+=1

print(s-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	int h,a; cin>>h>>a;
	cout<<h/a+(h%a==0?0:1);
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
int n,a,b,con=0,count=0;
  cin>>n>>a>>b;
  char mozi[n];
  scanf("%s",mozi);
  int i,j;
  for(i=0;i<n;i++){
    if(mozi[i]=='a'&&a+b>count){
      cout<<"Yes"<<endl;
       count++;   
     }
    else if(mozi[i]=='b'&&con<b&&count<a+b){
      cout<<"Yes"<<endl;
      count++;
      con++;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define LOOP_IT(s) for(auto it=(s).begin();it!=(s).end();++it)

int main(int argc,char* argv[])
{
    ZOOM

    double L,ans;
    cin>>L;
    ans = 1;
    for(ll i=0;i<3;++i)
    {
        ans*=static_cast<double>(L/3);
    }

    cout<<fixed<<setprecision(12)<<ans;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

const double EPS = 1e-10;
int n, m;
//memo[i][j]: 直前にjを入れてi回目のときの最大倍率
//a[i][j]: 直前i
double a[101][101], memo[101][101];

double rec(int i, int j){
	if(memo[i][j] > -EPS){
		return memo[i][j];
	}

	if(i == m){
		return 1;
	}

	double res = 0;
	for(int u=1;u<=n;u++){
		res = std::max(res, a[j][u] * rec(i+1, u));
	}

	return memo[i][j] = res;
}

int main(){
	while(std::cin >> n >> m, n){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				std::cin >> a[i][j];
			}
		}

		for(int i=1;i<101;i++){
			a[0][i] = 1;
		}

		for(int i=0;i<101;i++){
			for(int j=0;j<101;j++){
				memo[i][j] = -1;
			}
		}
		
		printf("%.2f\n", rec(0, 0));
	}
}

Measured memory_bytes: 1404
<?php 
  /*全探索
  for{
   上の段は進め多分の総和+
   下の段は、進め多分を全ての総和から引いたもの
   }
   max
  */
//fscanf(STDIN,"%s%s",$s,$t);
fscanf(STDIN,"%d",$n);

$a_1=explode(" ",trim(fgets(STDIN)));
$a_2=explode(" ",trim(fgets(STDIN)));
$a_part_sum=0;
$a2_part_sum=0;
$sum=0;
$b_sum=0;
for($i=0;$i<$n;$i++) $b_sum+=$a_2[$i];
for($i=0;$i<$n;$i++){
  $a_part_sum += $a_1[$i];
  $a2_part_sum += $a_2[$i-1];
  //echo $a_part_sum." ".$a2_part_sum."\n";
  $sum=max($sum,$a_part_sum+($b_sum-$a2_part_sum));
}


echo $sum."\n";


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

int main()
{
    int n,d,x,a,ans = 0;
    cin >> n >> d >> x;
    for(int i = 0; i < n; i++){
        cin >> a;
        ans += d / a;
        if(d % a) ans++;
    }

    cout << ans + x << endl;

    return 0;
}

Measured memory_bytes: 256
# qiitaにはbit全探索とは書いてないけど、bitが良さげ。
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
fac_list = factorization(n)

p = []
for i in range(len(fac_list)):
    for j in range(fac_list[i][1]):
        p.append(fac_list[i][0])

l = n
for i in range(2 ** len(p)):
    a = 1
    for j in range(len(p)):
        if ((i >> j) & 1):
            a *= p[j]
    b = int(n/a)
    l = min(l, max(len(str(a)),len(str(b))))
print(l)

Measured memory_bytes: 74376
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long ll;

class dsu {
public:
  vector<ll> rank, p, size;
  dsu(){};
  dsu(ll n) {
    rank.assign(n, 0);
    size.assign(n, 1);
    p.resize(n);
    for (int i = 0; i < n; ++i) p[i] = i;
  }

  ll getSize(ll x) {
    return size[findRep(x)];
  }
  
  void unite(ll x, ll y) {
    ll p1 = findRep(x), p2 = findRep(y);
    if (p1 == p2) return;
    if (rank[p1] < rank[p2]) swap(p1, p2);

    if (rank[p1] == rank[p2]) rank[p1]++;
    p[p2] = p1;
    size[p1] += size[p2];
  }
  
  ll findRep(ll x) {
    if ( x != p[x] ) {
      p[x] = findRep(p[x]);
    }
    return p[x];
  }
};

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

  vector< pair<ll, ll> > AB(M);
  ll A, B;
  for (int i = M - 1; i >= 0; --i) {
    cin >> A >> B;
    AB[i] = make_pair(A - 1, B - 1);
  }
  vector<ll> ans(M, 0);
  ans[0] = (ll) N * (N - 1) / 2;

  dsu *d = new dsu(N);

  for (int i = 0; i < M - 1; ++i) {
    ll A = AB[i].first, B = AB[i].second;
    if (d->findRep(A) != d->findRep(B)) {
      ans[i + 1] = ans[i] - (ll)(d->getSize(A) * d->getSize(B));
    } else {
      ans[i + 1] = ans[i];
    }
    d->unite(A, B);    
  }

  for (int i = M - 1; i >= 0; --i) {
    cout << ans[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 6016
#include<stdio.h>
int main(void){
  long n,nc,sn=0;
  scanf("%ld",&n);
  nc = n;
  while(nc!=0){
    sn += nc%10;
    nc /=10;
  }
  if(n%sn==0) printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define MOD 1000000007LL

using namespace std;

typedef long long ll;

ll hoge_pow(ll m, ll n) {
	if(n==1) return m;
	ll ret = hoge_pow(m,n/2);
	ret = (ret*ret)%MOD;
	if(n%2==1) {
		ret = (ret*m)%MOD;
	}
	return ret;
}

int main() {
	ll m,n;
	cin >> m >> n;
	ll ans = hoge_pow(m,n);
	cout << ans << endl;
}



Measured memory_bytes: 3136
using System;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split(' ');
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]);

        if (k % 2 == 1)
        {
            var ans = Math.Pow(n / k, 3);
            Console.WriteLine((long)ans);
        }
        else
        {
            var ans = Math.Pow(n / k, 3) + Math.Pow(n / (k / 2) - n / k, 3);
            Console.WriteLine((long)ans);
        }
    }
}


Measured memory_bytes: 11092
s = input()
s_list = list(s)
n = len(s)
ans =0
for i in range(n-1):
    if s_list[i] != s_list[-1-i]:
        s_list[-1-i]=s_list[i]
        ans+=1
s2 = "".join(s_list)
#print(s2)
print(ans)

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

int main()
{
  char suit[4] = { 'S','H','C','D', };
  vector<vector<bool> > m(4,vector<bool>(13,true));
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    char c;
    int j;
    cin >> c >> j;
    switch(c){
    case 'S': m[0][j-1] = false; break;
    case 'H': m[1][j-1] = false; break;
    case 'C': m[2][j-1] = false; break;
    case 'D': m[3][j-1] = false; break;
    }
  }
  for(int i=0; i<4; i++){
    for(int j=0; j<13; j++){
      if(m[i][j]) cout << suit[i] << " " << j+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1196
/* 
  ╔╗         ╔╗              ╔═══╗                                  
  ║║        ╔╝╚╗             ║╔═╗║                                  
  ║║╔╗╔╗╔══╗╚╗╔╝    ╔══╗     ║╚═╝║╔═╗╔══╗╔══╗╔═╗╔══╗ ╔╗╔╗╔╗╔╗╔══╗╔═╗
╔╗║║║║║║║══╣ ║║     ╚ ╗║     ║╔══╝║╔╝║╔╗║║╔╗║║╔╝╚ ╗║ ║╚╝║║╚╝║║╔╗║║╔╝
║╚╝║║╚╝║╠══║ ║╚╗    ║╚╝╚╗    ║║   ║║ ║╚╝║║╚╝║║║ ║╚╝╚╗║║║║║║║║║║═╣║║ 
╚══╝╚══╝╚══╝ ╚═╝    ╚═══╝    ╚╝   ╚╝ ╚══╝╚═╗║╚╝ ╚═══╝╚╩╩╝╚╩╩╝╚══╝╚╝ 
                                         ╔═╝║                       
                                         ╚══╝                       */


//Header files
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#ifndef ONLINE_JUDGE
#include<Personal/debug.h>
#else
#define debug(x...)
#endif

//Short data-types declaration
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vii;  
typedef vector<vector<long long> >vll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;

//Macros
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define rep(i,start,end) for(int i=(int)start;i<(int)end;i++)
#define repr(i,start,end) for(int i=(int)start;i>(int)end;i--)
#define all(x) (x).begin(), (x).end()

//Constants
const int mod = 1e9+7;

//Some useful functions
ll binpow(ll num,ll pow);
inline int mul(int a,int b) {return (a*1ll*b)%mod;}
inline int add(int a,int b) {return (a+0ll+b)%mod;}
inline int sub(int a,int b) {return ((a+0ll-b)%mod+mod)%mod; }
/*------------------------------------------------------Code Starts------------------------------------------------------*/
inline void solve()
{
	int x;
	cin>>x;
	if(x>=30) cout<<"Yes\n";
	else cout<<"No\n";
}

int main()
{
	auto start = high_resolution_clock::now();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
	cerr<<duration.count()<<" microseconds\n";
	return 0;
}
/*------------------------------------------------------Code ends------------------------------------------------------*/
ll binpow(ll num,ll pow)
{
	if(pow==0)
		return 1;
	ll val=binpow(num,pow/2);
	val*=val;
	if(pow&1) val*=num;
	return val;
}



Measured memory_bytes: 3580
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:i64));
    ret(n, 0).to_string()
}

fn ret(n: i64, c: i64) -> i64 {
    if n < 6 {
        n + c
    } else {
        std::cmp::min(
            {
                //6
                let (_, b) = log(n, 6);
                ret(b, c + 1)
            },
            {
                //9
                let (_, b) = log(n, 9);
                ret(b, c + 1)
            },
        )
    }
}

//base^a+b=nとなる(a,b)
fn log(n: i64, base: i64) -> (i64, i64) {
    let a = ((n as f64).log(base as f64) + 0.000001) as i64;
    let b = n - base.pow(a as u32);
    (a, b)
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "127" => "4",
    test2: "3" => "3",
    test3: "44852" => "16",
    add1:"108"=>"3",
    add2:"1"=>"1",
    add3:"6"=>"1",
    add4:"7"=>"2",
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//bool f[100001];//1000000以下の素数を調べよう！
//rrep(i,2,100001){
  //      f[i]=false;
    //}
//rrep(i,2,100001){
  //      if(!f[i]){
    //        for(int j=i+i;j<=100000;j+=i){
      //          f[j]=true;
        //    }
        //}
    //}
    //for(int i=3;i<=100000;i+=2){
      //  if(!f[i]){
        //    c[i]++;
      //  }
   // }

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=LINF,a[10000000],b[10000000],c,d,cmp=0,cmpp,m,h,w,x,y,sum=0;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n >> x;
       rep(i,n){
           cin>>a[i];
           a[i+n]=a[i];
           b[i]=INF;
       }
       rep(k,n){
          ll pos=x*k;
          // cout << "pos1 :" << pos << endl;
           rep(i,n){
               b[i]=min(b[i],a[i+n-k]);
               pos+=b[i];
              // Cout(pos);
           }
           ans=min(ans,pos);
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  map<ll,ll> a;
  for(ll i=0;i<n;i++) {
    ll temp=0;
    cin >> temp;
    a[temp]++;
  }
  if(a.size()==3&&n%3==0) {
    bool flag=true;
    ll check=0;
    for(auto p:a) {
      check=check^p.first;
      if(p.second!=n/3) {
        flag=false;
      }
    }
    if(check!=0) flag=false;

    if(flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  else if(a.size()==1&&a[0]==n) {
    cout << "Yes" << endl;
    return 0;
  }
  else if(a.size()==2&&a[0]==n/3&&n%3==0) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n, k; cin >> n >> k;
    V<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    sort(ALL(p));

    int sum = 0;
    for(int i = 0; i < k; i++){
        sum += p[i];
    }
    cout << sum << endl;

    return 0;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;
const int Nmax=514114;
char buf[Nmax];
int kind[Nmax];
void setkind(int i){
	if(buf[i-1]<=buf[i])kind[i]=kind[i-1];
	else kind[i]=kind[i-1]+1;
}
void addone(int n){
	int i=n-1;
	while(buf[i]=='9')i--;
	buf[i]++;
	setkind(i);
	for(i++;i<n;i++){
		buf[i]='0';
		setkind(i);
	}
}

signed main(){
	scanf("%s",buf+19);
	REP(i,19)buf[i]='0';
	int n=strlen(buf),ans=0;
	FOR(i,1,n)setkind(i);
	int head=19;
	while(head<n){
		ans++;
		addone(n);
		int l=head,r=n;
		while(r-l>1){
			const int mid=(l+r)/2;
			if(kind[mid]==kind[head])l=mid;
			else r=mid;
		}
		char c=buf[l];
		l=head-1,r--;
		while(r-l>1){
			const int mid=(l+r)/2;
			if(buf[mid]<c)l=mid;
			else r=mid;
		}
		head=r+1;
		while(head<n&&buf[head]=='0')head++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6400
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
	int n,k;
	int x[101][101];
	int a,b,c,d,e;
	int y[101][101];
	int p;
	int sum=1000000000;
	bool s[101];
	int h[101];
	int h2[101][201];

	while(true){
		memset(x,127,sizeof(x));
		memset(s,false,sizeof(s));
		memset(h,0,sizeof(h));
		cin>>n>>k;
		if(n==0 && k==0){
			break;
		}
		e=n;
		sum=1000000000;
		for(int i=0;i<k;i++){
			memset(y,127,sizeof(y));
			sum=1000000000;
			p=10000000;
			cin>>a;
			if(a==0){
				cin>>b>>c;
				y[0][b]=0;
				if(s[c]==true && s[b]==true){
					for(int j=1;j<=e;j++){
						for(int l=1;l<=n;l++){
							if(y[j-1][l]<100000000){
								for(int m=1;m<=h[l];m++){
									if(x[l][h2[l][m]]<100000000){
										y[j][h2[l][m]]=min(y[j][h2[l][m]],y[j-1][l]+x[l][h2[l][m]]);
									}
								}
							}
						}
					}
				}
				for(int j=1;j<=n;j++){
					sum=min(sum,y[j][c]);
				}
				if(sum>=1000000000){
					sum=-1;
				}
				cout<<sum<<endl;
			}

			if(a==1){
				cin>>b>>c>>d;
				x[b][c]=min(x[b][c],d);
				x[c][b]=min(x[c][b],d);
				s[c]=true;
				s[b]=true;
				h[b]++;
				h[c]++;
				h2[b][h[b]]=c;
				h2[c][h[c]]=b;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,a;
	cin>>n>>a;
	if(n%500<=a)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
def read_input():
    n, x = map(int, input().split())
    alist = list(map(int, input().split()))

    return n, x, alist

def submit():
    n, x, alist = read_input()

    edit = 0

    if alist[0] > x:
        edit += alist[0] - x
        alist[0] = x

    for i in range(n - 1):
        if alist[i] + alist[i + 1] > x:
            diff = alist[i] + alist[i + 1] - x
            edit += diff
            alist[i + 1] = alist[i + 1] - diff

    print(edit)


if __name__ == '__main__':
    submit()

    

Measured memory_bytes: 63984