akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


ll answer(vector<int> &f,vector<int> &bene,bitset<10> ans){
    int cnt=0;
    rep(i,10){
        if(ans[i]&&f[i])cnt++;
    }
    return bene[cnt];
}
int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    vector<vector<int>> f(n,vector<int>(10));
    rep(i,n)rep(j,10)cin >> f[i][j];
    vector<vector<int>> benefit(n,vector<int>(11));
    rep(i,n)rep(j,11)cin >> benefit[i][j];

    int num=(1<<10);
    ll res=-10000000000000;
    rep2(ii,1,num){
        bitset<10> ans(ii);
        ll now=0;
        rep(i,n)now+=answer(f[i],benefit[i],ans);
        res=max(res,now);
    }
    cout << res << endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

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

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
#define MAX 3009
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in5.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int T=1;
    // cin >> T;
    FOR1(tt, T){
        // cout << "Case #" << tt << ": ";
        int n; cin >> n;
        int a[n+1];
        FOR1(i, n) cin >> a[i];
        int ans = 0;
        for(int i = 2; i <= n; i++){
            if(a[i-1] > a[i]){
                int stool = a[i-1]-a[i];
                a[i] += stool;
                ans += stool;
            }
        } 
        cout << ans;
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 5216
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    char c;
    cin >> c;
    char ans = c+1;
    cout << ans << endl;
    return 0;
}




















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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    for (auto &e: s) {
        e += n;
        if (e > 'Z') e -= 26;
    }
    
    cout << s << 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 REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> dw(n-1,0),de(n-1,0);
    string s;
    cin >> s;

    for(int i=1;i<n;i++){
        dw[i]=dw[i-1];
        if(s[i-1]=='W')dw[i]++;
        de[n-1-i]=de[n-i];
        if(s[n-i]=='E')de[n-1-i]++;
    }
//    REP(i,n)cout << dw[i] <<" " << de[i] << endl;
    int mi=INT_MAX;
    REP(i,n){
        mi=min(mi,dw[i]+de[i]);
    }
    cout << mi << endl;
}


Measured memory_bytes: 3152
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
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;}
using namespace std;
int main(){
  double n,m;
  cin>>n>>m;
  double val=0;
  priority_queue<int>que;
  rep(i,n){
    int a;
    cin>>a;
    val+=a;
    que.push(a);
  }

  double border=val/(4*m);
  int flag=0;
  rep(i,m){
    int b=que.top();
    if(b>=border)que.pop();
    else flag=1;
  }

  if(flag==1)cout<<"No";
  else cout<<"Yes";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    string w; cin >> w;

    unsigned int bit = 0;
    for (int i = 0; i < w.size(); i++) {
        bit ^= (1<<(w[i]-'a'));
    }

    cout << ((bit == 0) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  double b;
  int N;cin>>N;
  vector<double> A(N);
  for(int i=0;i<N;++i){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  for(int i=0;i<N-1;++i){
    b=(A[i]+A[i+1])/2.0;
    A[i+1]=b;
  }
  cout<<b;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 2000;
const int MOD = 1000000007;
const int INV2 = (MOD + 1) / 2;

int n;
int par[MAXN];

int fac[MAXN + 1];

int sz[MAXN];
int ways[MAXN][MAXN + 1][3]; // ways[i][j][k] = the number of ways to make directed paths in the subtree of i with total length j, with the root connected to k childs

void run() {
	fac[0] = 1; FORE(i, 1, MAXN) fac[i] = (ll)fac[i - 1] * i%MOD;

	scanf("%d", &n); par[0] = -1; FOR(i, 1, n) scanf("%d", &par[i]), --par[i];

	REP(i, n) sz[i] = 1;
	memset(ways, 0, sizeof(ways));
	REP(i, n) ways[i][0][0] = 1;
	for (int a = n - 1; a >= 0; --a) if(par[a]!=-1) {
		int b = par[a];
		for (int bk = 2; bk >= 0; --bk) for (int bj = sz[b] - 1; bj >= 0; --bj) if (ways[b][bj][bk] != 0) {
			int bways = ways[b][bj][bk]; ways[b][bj][bk] = 0;
			REPE(ak, 2) REPE(aj, sz[a] - 1) if (ways[a][aj][ak] != 0) REP(use, 2) {
				if (use == 1 && (ak == 2 || bk == 2)) continue;
				int aways = ways[a][aj][ak], nbk = bk + use, nbj = bj + aj + use, mlt = use == 0 ? 1 : ak == 1 && bk == 1 ? INV2 : ak == 1 || bk == 1 ? 1 : 2;
				ways[b][nbj][nbk] = (ways[b][nbj][nbk] + (ll)bways*aways%MOD*mlt) % MOD;
			}
		}
		sz[b] += sz[a];
		//REPE(j, sz[b] - 1) REPE(k, 2) if (ways[b][j][k] != 0) printf("ways[%d][%d][%d]=%d\n", b + 1, j, k, ways[b][j][k]);
	}
	//REP(i, n) REPE(j, sz[i] - 1) REPE(k, 2) if (ways[i][j][k] != 0) printf("ways[%d][%d][%d]=%d\n", i + 1, j, k, ways[i][j][k]);

	int ret = 0;
	REPE(j, sz[0] - 1) REPE(k, 2) if (ways[0][j][k] != 0) {
		int cur = (ll)ways[0][j][k] * fac[n - j] % MOD;
		if (j % 2 == 1) cur = cur == 0 ? 0 : MOD - cur;
		ret = (ret + cur) % MOD;
	}
	printf("%d\n", ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 47232
import java.util.Scanner;

public class Main {

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

		while (sc.hasNext()) {
			int n = Integer.parseInt(sc.nextLine());
				if (n == 0) {
					break;
				}
			calcMat(n);
		}
	}

	private static void calcMat(int n) {
		int[][] mt = new int[n + 1][n + 1];

			for (int i = 0; i < n; i++) {
				String[] dt = sc.nextLine().split(" ");
				for (int j = 0; j < n; j++) {
					mt[i][j] =  Integer.parseInt(dt[j]);
					mt[i][n] +=  mt[i][j];
					mt[n][j] += mt[i][j];
				}
			}

			for (int i = 0; i < n; i++) {
				mt[n][n] += mt[i][n];
			}

			for (int i = 0; i < n + 1; i++) {
				for (int j = 0; j < n + 1; j++) {
					String sp = (j < n)? "" : "\n";
					System.out.printf("%5d%s",mt[i][j] ,sp);
				}
			}
	}
}


Measured memory_bytes: 31852
mat=[]

for i in range(3):
    inp = [int(x) for x in input().split()]
    mat.append(inp)
    
n = int(input())

for _ in range(n):
    q = int(input())
    for i in range(3):
        if q in mat[i]:
            ind = mat[i].index(q)
            mat[i][ind] = '1'
            break
    
if mat[0][0]=='1' and mat[0][1]=='1' and mat[0][2]=='1':
    print('Yes')
    
elif mat[1][0]=='1' and mat[1][1]=='1' and mat[1][2]=='1':
    print('Yes')

elif mat[2][0]=='1' and mat[2][1]=='1' and mat[2][2]=='1':
    print('Yes')

#col
elif mat[0][0]=='1' and mat[1][0]=='1' and mat[2][0]=='1':
    print('Yes')

elif mat[0][1]=='1' and mat[1][1]=='1' and mat[2][1]=='1':
    print('Yes')

elif mat[0][2]=='1' and mat[1][2]=='1' and mat[2][2]=='1':
    print('Yes')

#diag
elif mat[0][0]=='1' and mat[1][1]=='1' and mat[2][2]=='1':
    print('Yes')

elif mat[0][2]=='1' and mat[1][1]=='1' and mat[2][0]=='1':
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<ctime>
#include<cmath>
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define rint register int
typedef long long ll;
using namespace std;
int a[101];
int main()
{   //freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,sum=0;
	cin>>n;
	for(rint i=1;i<=n;i++) cin>>a[i],sum+=a[i];
	sort(a+1,a+n+1);
	if(sum%10!=0) {cout<<sum<<endl;return 0;}
	else
	{	for(rint i=1;i<=n;i++)
		{	if((sum-a[i])%10!=0) {sum-=a[i];cout<<sum<<endl;return 0;}
		}
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> gg = { {1,0},{-1,0},{0,1},{0,-1} };
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> da(h);
	for (int i = 0;i < h;i++)
		cin >> da[i];
	vector<vector<bool>> ju(h+2, vector<bool>(w+2, false));
	for (int i = 0;i < h + 2;i++) {
		ju[i][0] = true;
		ju[i][w + 1] = true;
	}
	for (int i = 0;i < w + 2;i++) {
		ju[0][i] = true;
		ju[h + 1][i] = true;
	}
	vector < pair<int, int>> co(0);
	int hi = 0;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			if (da[i][j] == '#') {
				ju[i+1][j+1] = true;
				pair<int, int> x = { i+1,j+1 };
				co.push_back(x);
				hi++;
			}
		}
	}
    if(hi==h*w){
        cout << 0 <<endl;
        return 0;
    }
	int ans = 0,ne=0,ko=hi;
	hi = 0;
	while (hi != h * w) {
		ne = ko;
		ko = 0;
		for (int i = 0;i < ne;i++) {
			for (int j = 0;j < 4;j++) {
				if (!ju[co[hi].first + gg[j].first][co[hi].second + gg[j].second]) {
					ju[co[hi].first + gg[j].first][co[hi].second + gg[j].second] = true;
					pair<int, int> x={ co[hi].first + gg[j].first,co[hi].second + gg[j].second };
					co.push_back(x);
					ko++;
				}
			}
			hi++;
		}
		ans++;
		/*for (int i = 0;i < h+2;i++) {
			for (int j = 0;j < w+2;j++) {
				if (ju[i][j])
					cout << 1 << ' ';
				else
					cout << 0 << ' ';
			}
			cout << endl;
		}*/
	}
	cout << ans-1 << endl;
}

Measured memory_bytes: 11504
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

bool check(string s){
  int n = s.length();
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[n/2+i]) return false;
  }
  return true;
}

int main(void){

    string s;
    cin >> s;
    int n = s.length();
    for(int i = n-2; i >= 0; i-=2 ){
      s.erase(i);
      if( check(s) ) break;
    }
    cout << s.length() << endl;
    return 0;
}


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

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

    int dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1 ; i < n ; i++){
        dp[i][0] = max(dp[i-1][1] + a[i] , dp[i-1][2]+a[i]);
        dp[i][1] = max(dp[i-1][0] + b[i],dp[i-1][2] + b[i]);
        dp[i][2] = max(dp[i-1][0] + c[i],dp[i-1][1] + c[i]);
    }

    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 5992
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
using namespace std;
#define ll long long

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

	int n, k;
	while (cin >> n >> k) {
		if (k == 1) {
			cout << "1.0000000000" << endl;
			continue;
		}

		double ans;
		if (n < k) {
			ans = 0.0;
			for (int i = 1; i <= n; i++) {
				int cnt = 1;
				ll pow_cnt = 2;
				while (pow_cnt*i < k) {
					cnt++;
					pow_cnt *= 2;
				}
				ans += 1.0 / n * 1.0 / pow_cnt;
			}
		}
		else if (n == k) {
			ans = 1.0 / n;
			for (int i = 1; i < n; i++) {
				int cnt = 1;
				ll pow_cnt = 2;
				while (pow_cnt*i < k) {
					cnt++;
					pow_cnt *= 2;
				}
				ans += 1.0 / n * 1.0 / pow_cnt;
			}
		}
		else {
			ans = (n - k + 1)*1.0 / n;
			for (int i = 1; i < k; i++) {
				int cnt = 1;
				ll pow_cnt = 2;
				while (pow_cnt*i < k) {
					cnt++;
					pow_cnt *= 2;
				}
				ans += 1.0 / n * 1.0 / pow_cnt;
			}
		}
		printf("%.10lf\n", ans);
	}


	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int dp[1002][1002];

int main() {
    int n;
    while (scanf("%d", &n), n) {
        int ret = 0;
        char line[1001];
        for (int i=1; i<=n; ++i) {
            scanf("%s", line);
            for (int j=1; j<=n; ++j) {
                if (line[j-1] == '.') {
                    dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j], dp[i][j-1])) + 1;
                    ret = max(ret, dp[i][j]);
                } else {
                    dp[i][j] = 0;
                }
            }
        }
        printf("%d\n", ret);
    }
    return 0;
}

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

int main()
{
  ll n, m, ans=0, dif;
  cin>>n;

  m=n/500;
  ans+=(1000*m);
  n-=(500*m);
  m=n/5;
  ans+=(5*m);
  cout<<ans<<endl;

}

Measured memory_bytes: 256
from collections import deque
n = int(input())
G = [[]for i in range(n)]
for i in range(n-1):
    a,b = map(lambda x: int(x) - 1,input().split())
    G[a].append(b)
    G[b].append(a)

dist_zero = [-1]*n
dist_zero[0] = 0
queue = deque()
queue.append(0)
while queue:
    now = queue.popleft()
    for to in G[now]:
        if dist_zero[to] == -1:
            dist_zero[to] = dist_zero[now] + 1
            queue.append(to)

dist_n = [-1]*n
dist_n[-1] = 0
queue = deque()
queue.append(-1)
while queue:
    now = queue.popleft()
    for to in G[now]:
        if dist_n[to] == -1:
            dist_n[to] = dist_n[now] + 1
            queue.append(to)

f = sum([(dist_zero[i]<=dist_n[i]) for i in range(n)])

print("Fennec" if 2*f > n else "Snuke")

Measured memory_bytes: 71328
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
const ll INF = 0x3f3f3f3f;

struct node{
	ll idx,h;
} a[N];
ll idx2[N],s[N],ss[N];

bool comp(node o,node m){
	return o.idx < m.idx;
}

int main(){
	int n;
	ll x,y,D,A,cnt = 0,sum = 0;
	
	scanf("%d%lld%lld",&n,&D,&A);
	for(int i = 1;i <= n;++i) scanf("%lld%lld",&a[i].idx,&a[i].h);
	sort(a+1,a+n+1,comp);
	
	ss[0] = 0;
	idx2[++sum] = a[1].idx+D;
	s[sum] = a[1].h%A ?a[1].h/A+1 :a[1].h/A;
	ss[sum] = ss[sum-1]+s[sum];
	
	for(int i = 2;i <= n;++i){
		ll l = a[i].idx-D;
		ll r = a[i].idx+D;
		
		ll sta = lower_bound(idx2+1,idx2+sum+1,l)-idx2-1;
		ll end = upper_bound(idx2+1,idx2+sum+1,r)-idx2-1;
		if(idx2[sta] < l) sta++;
		if(idx2[end] > r) end--;
		//cout << sta << " " << end << endl;
		
		ll sss = ss[end]-ss[max(0ll,sta-1)];
		ll need = a[i].h%A ?a[i].h/A+1 :a[i].h/A;
		
		if(need <= sss) continue;
		else{
			need -= sss;
			idx2[++sum] = a[i].idx+D;
			s[sum] = need;
			ss[sum] = ss[sum-1]+s[sum];
		}
	}
	
	cout << ss[sum];
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair< ll,pair<ll , ll> >; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
////////////////

void solve(){
  inl(N);
  if(N & 1) die(0);
  N = N / 2;
  ll ans = 0;
  while(N){
    ans += N / 5;
    N = N / 5;
  }
  out(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+50;
const int mod = 1e9+7;
typedef long long ll;
ll fac[maxn+50],inv[maxn+50];
ll qpow(ll x,ll k)
{
    ll ret=1;
    while(k)
    {
        if(k&1) ret = (ret*x)%mod;
        x = x*x%mod;
        k>>=1;
    }
    return ret;
}
void init()
{
    fac[0]=1;
    for(ll i=1; i<=maxn+1; i++) fac[i]=(fac[i-1]*i)%mod;
    inv[maxn+1]=qpow(fac[maxn+1],mod-2);
    for(ll i=maxn; i>=0; i--) inv[i]=(inv[i+1]*(i+1))%mod;
}
ll comb(ll n,ll m)
{
    if(m<0||m>n)
        return 0;
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
    int n,m;
    cin>>n>>m;
    int a=max(n,m);
    int b=min(n,m);
    init();
    ll ans;
    //cout << fac[a] << endl;
    if(a==b)
        ans=(2*fac[a])%mod*fac[b]%mod;
    else if(a-b>=2)
    {
        cout << 0 << endl;
        return 0;
    }
    else
        ans=(fac[a]%mod*fac[b])%mod;
    //cout << comb(10,1) << endl;
    cout << ans << endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 1792
$n = <>;
@h = split(" ",<>);
$prev = -10;
for($i=0;$i<$n;$i++){
	if($prev <= ($h[$i]-1)){
    	$prev = $h[$i]-1;
    } elsif($prev <= $h[$i]) {
    	$prev = $h[$i];
    } else {
    	print "No";
        exit 0;
    }
}
print "Yes";

Measured memory_bytes: 11724
#include <iostream>
using namespace std;
int a,b;
int main(){
	while(cin >>a >> b){
		int N;
		if(b/10==0) N = 10*a+b;
		else if(b/10<10) N= 100*a+b;
		else N = 1000*a+b;
		bool judge = false;
		for(int i=1;i*i<=N;i++){
			if(i*i==N) judge = true;
		}
		if(judge) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 256
S = list(map(str, input()))

if S[0] == S[1] and S[2] == S[3] and S[1] != S[2]:
	print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
	print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]: 
	print('Yes')
else:
	print('No')

Measured memory_bytes: 38256
s = list(input())

a = False
c = False
small = False
for i in range(len(s)):
    if i == 0 and s[i] == "A":
        a = True
    elif a == True and i >= 2 and i < len(s) - 1 and s[i] == "C" and c == False:
        c = True
    elif s[i] >= "a" and s[i] <= "z":
        small = True
    else:
        small = False
        break

if a == True and c == True and small == True:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q, H, W, D, L, R, K, X;
ll A;
ll B;
ll ans;
string S;
ll searchflg[100001];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
list<pair<ll, ll> > l[100001];
bool func(ll nowpos, ll nownum) {
	if (searchflg[nowpos] == nownum) {
		return true;
	}
	else if (searchflg[nowpos] != 10000000000) {
		return false;
	}
	else {
		searchflg[nowpos] = nownum;
		for (auto itr = l[nowpos].begin(); itr != l[nowpos].end(); itr++) {
			if (!func(itr->first, itr->second + nownum)) {
				return false;
			}
		}
	}
	return true;
}
ll x[100000], y[100000];
char c[100000];
ll grid[2002][2002];
ll num(ll x1, ll y1, ll x2, ll y2) {
	return grid[x1][y1] + grid[x2][y2] - grid[x1][y2] - grid[x2][y1];
}
int main() {
	cin >> N >> K;
	rep(i, 0, N) {
		cin >> x[i] >> y[i] >> c[i];
		if (c[i] == 'W')y[i] += K;
		x[i] %= K * 2;
		y[i] %= K * 2;
		grid[x[i] + 1][y[i] + 1]++;
	}
	rep(i, 1, K * 2 + 1) {
		rep(j, 1, K * 2 + 1) {
			grid[i][j] += grid[i - 1][j] + grid[i][j - 1] - grid[i - 1][j - 1];
		}
	}
	rep(i, 1, K + 1) {
		rep(j, 1, K + 1) {
			ll tmp = num(i, j, i + K, j + K);
			tmp += num(0, 0, i, j);
			tmp += num(0, j + K, i, K * 2);
			tmp += num(i + K, 0, K * 2, j);
			tmp += num(i + K, j + K, K * 2, K * 2);
			ans = max(ans, max(tmp,N-tmp));
		}
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 35072
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<llong> a(n,0);
    REP(i,n)
    {
        cin>>a[i];
    }
    llong ansa=0;
    llong ansb=0;
    llong suma=0;
    //2通り検討する
    for(int i=0; i<n; i++)
    {
        suma+=a[i];
        if(i%2==0&&suma<=0)
        {
            ansa+=abs(suma)+1;
            suma=1;
        }
        else if(i%2!=0&&suma>=0)
        {
            ansa+=abs(suma)+1;
            suma=-1;
        }
    }
    llong sumb=0;
    for(int j=0; j<n; j++)
    {
        sumb+=a[j];
        if(j%2!=0&&sumb<=0)
        {
            ansb+=abs(sumb)+1;
            sumb=1;
        }
        else if(j%2==0&&sumb>=0)
        {
            ansb+=abs(sumb)+1;
            sumb=-1;
        }
    }
    cout<<min(ansa,ansb)<<endl;
    return  0;
}


Measured memory_bytes: 1024
import sys
import math

a,b,k = list(map(int, input().split()))
if b-a+1 <= k:
    for i in range(a,b+1):
        print(i)
else:
    lis = list(range(a,a+k))
    lis.extend(list(range(b-k+1, b+1)))
    lis = list(set(lis))
    lis.sort()
    for i in range(len(lis)):
        print(lis[i])

Measured memory_bytes: 3064
N = int(input())
X = list(map(int,input().split(' ')))
A = [0] + X + [0]
#全探索にかかる金額
total = 0
for i in range(1,N+1):
  total += abs(A[i]-A[i-1])
total += abs(A[N])
# 特定のスポットのみ飛ばした場合
for i in range(1,N+1):
  X = abs(A[i+1] - A[i-1])
  M = abs(A[i] - A[i-1])
  L = abs(A[i+1] - A[i])
  total += X -M - L
  print(total)
  total += M + L - X
  

Measured memory_bytes: 14172
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   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; }
    const int MAX =3001;
const int MOD =998244353;

  
  
signed main(){
  int n,m;
  cin>>n>>m;
  cout<<(m*1900+(n-m)*100)*(1ll<<m)<<endl;


}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll a, b, x, n, res;

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

	cin >> a >> b >> n;

	ll x = n - n % b - 1;
	if (x < 1) x = n;

	cout << (a * x) / b - a * (x / b) << endl;

	return 0;
}


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

int main() {
  vector<vector<vector<int>>> data(4, vector<vector<int>>(3, vector<int>(10,0)));
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    data.at(a-1).at(b-1).at(c-1) += d;
  }
  for(int i = 0;i < 4;i++){
    for(int j = 0;j < 3;j++){
      for(int k = 0;k < 10;k++){
        cout << " " << data.at(i).at(j).at(k);
      }
      cout << "" << endl;
    }
    if(i != 3){
      for(int j = 0;j < 20;j++){
        cout << '#';
      }
      cout << "" << endl;
    }
  }
}



Measured memory_bytes: 3156
#include <stdio.h>
#define maxn 200010
int head[maxn],tot,n,m,d[maxn],pre[maxn],q[maxn*10],vis[maxn];
struct node{
	int to,next;
}e[maxn<<1];
void add_edge(int u,int v){
	tot++,e[tot].to=v,e[tot].next=head[u],head[u]=tot;
}
void init(){
	int i,u,v;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v),add_edge(v,u);
	}
}
void spfa(){
	int h,t,i,u,v,b;
	for(i=1;i<=n;i++)d[i]=maxn;
	d[1]=0,h=t=1,q[t]=1,t++,vis[1]=1;
	while(h<t){
		u=q[h];
		for(b=head[u];b;b=e[b].next){
			v=e[b].to;
			if(d[v]>d[u]+1){
				pre[v]=u;
				d[v]=d[u]+1;
				if(!vis[v])vis[v]=1,q[t]=v,t++;
			}
		}
		h++;
		vis[u]=0;
	}
	for(i=1;i<=n;i++)
		if(d[i]==maxn){printf("No\n");return;}
	printf("Yes\n");
	for(i=2;i<=n;i++)printf("%d\n",pre[i]);
}
int main(){
	init();
	spfa();
	return 0;
}

Measured memory_bytes: 6820
N,M = map(int, input().split())
S = [int(s) for s in input().split()]
T = [int(t) for t in input().split()]

mod = 10**9+7
dp = [[0]*(M+1) for _ in range(N+1)]
sum2D = [[0]*(M+1) for _ in range(N+1)]


for i in range(1, N+1):
    for j in range(1, M+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = sum2D[i-1][j-1] + 1
            dp[i][j] %= mod
        sum2D[i][j] = dp[i][j] + sum2D[i-1][j] + sum2D[i][j-1] - sum2D[i-1][j-1]
        sum2D[i][j] %= mod
        
ans = 1
for i in range(1, N+1):
    for j in range(1, M+1):
        ans += dp[i][j]
        ans %= mod
        
print(ans)

Measured memory_bytes: 105564
#include<cmath>
#include<ctime>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include <cstdio>
#define max(x, y) ((x > y ? x : y))
#define min(x, y) ((x < y ? x : y))
using namespace std;
const int N = 200;
short f[20][N][N][N];
int n, m ;
char a[N][N];
int sum[N][N];
int main(){
    scanf("%d %d", &n, &m);
    for (int i  = 1; i <= n ;  i++)
        for (int j = 1 ; j <= m ; j ++) {
            scanf(" %c", &a[i][j]);
            if (a[i][j] == '#')
                sum[i][j] = 1;
            sum[i][j] += sum[i - 1][j];
        }
    for (int cnt = 0; cnt < 20; cnt ++) {
        for (int i = m; i; i--)
            for (int hr = 1; hr <= n; hr++) {
                int mid = hr;
                for (int hl = hr; hl; hl--) {
                    if (cnt) {
                        while (mid - 1 > hl && min(f[cnt - 1][i][mid][hr], f[cnt - 1][i][hl][mid - 1]) <=
                                               min(f[cnt - 1][i][mid - 1][hr], f[cnt - 1][i][hl][mid - 2]))
                            mid--;
                        if (mid != hl)
                            f[cnt][i][hl][hr] = max(f[cnt][i][hl][hr],
                                                    min(f[cnt - 1][i][mid][hr], f[cnt - 1][i][hl][mid - 1]));

                        if (f[cnt - 1][i][hl][hr] + i <= m)
                            f[cnt][i][hl][hr] = max(f[cnt][i][hl][hr], f[cnt - 1][i][hl][hr] +
                                                                       f[cnt - 1][i + f[cnt - 1][i][hl][hr]][hl][hr]);
                        else
                            f[cnt][i][hl][hr] = max(f[cnt][i][hl][hr], f[cnt - 1][i][hl][hr]);
                        f[cnt][i][hl][hr] = max(f[cnt][i][hl][hr], f[cnt - 1][i][hl][hr]);
                    } else {
                        if ((sum[hr][i] - sum[hl - 1][i]) % (hr - hl + 1) == 0) {
                            if (i == m)
                                f[cnt][i][hl][hr] = max(f[cnt][i][hl][hr], 1);
                            else {
                                if ((sum[hr][i] - sum[hl - 1][i]) == (sum[hr][i + 1] - sum[hl - 1][i + 1]))
                                    f[cnt][i][hl][hr] = max(f[cnt][i][hl][hr], f[cnt][i + 1][hl][hr] + 1);
                                else
                                    f[cnt][i][hl][hr] = max(f[cnt][i][hl][hr], 1);
                            }
                        }
                    }
                }
            }
        if (f[cnt][1][1][n] == m) {
            printf("%d\n", cnt);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 266368
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        Map<Integer, Integer> xMap = new HashMap<>();
        int max = 0;
        for (int i = 0; i < N; ++i) {
            int a = sc.nextInt();
            for (int j = -1; j <= 1; ++j) {
                int x = a + j;
                Integer tmp = xMap.get(x);
                if (tmp == null) {
                    tmp = 0;
                }
                xMap.put(x, tmp + 1);
                if (tmp + 1 > max) {
                    max = tmp + 1;
                }
            }
        }
        _out.println(max);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 64340
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> g(h);
    int black = 0;
    rep(i, h)
    {
        string s;
        cin >> s;
        g[i] = s;
        rep(j, w)
        {
            if(s[j] == '#')
            {
                black++;
            }
        }
    }
//    cout << black << endl;
    int ans = 0;
    for(int i = 0; i < (1 << h); ++i)
    {
        for(int j = 0; j < (1 << w); ++j)
        {
            int count = 0;
            for(int y = 0; y < h; ++y)
            {
                if(((i >> y) & 1) == 1)
                {
                    continue;
                }
                for(int x = 0; x < w; ++x)
                {
                    if(((j >> x) & 1) == 1)
                    {
                        continue;
                    }
                    if(g[y][x] == '#')
                    {
                        count++;
                    }
                }
            }
            if(count == k)
            {
                ans++;
            }
        }
    }

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


Measured memory_bytes: 3588
#include<iostream>
#include<cmath>

int isprime(int);
using namespace std;

int main(){
  int i,j,n,b=0;

  cin >> n;

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

    
  for(i = 0; i < n; i++){
    if(isprime(a[i]) == true) b++;
  }
  
  cout << b << endl;

  return 0;
}
  
int isprime(int x){
  int j;
  
  if(x == 2)
    return true;
      
    if(x < 2 || x%2 == 0)
      return false;

    j = 3;

    while(j <= sqrt(x)){
      if(x%j == 0){
	return false;
      }
      
	j = j+2;
	
    }
    
    return true;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
std::vector<int> h;
int main()
{	
	int K, N;
	int t = 100000000000;
	cin >> N >> K;
	h.resize(N);
	for (int i = 0; i < N; ++i)cin >> h[i];
	sort(h.begin(), h.end());
	for (int i = 0; i < N - K + 1; ++i) {
		if (h[i + K - 1] - h[i] < t)t = h[i + K - 1] - h[i];
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 640
#-*-coding:utf-8-*-

from collections import deque
import sys
input=sys.stdin.readline

def main():
    commands=[]
    number = int(input())
    commands=list(input().split() for _ in range(number))
    q=deque()
    for command in commands:
        if command[0] == "insert":
            q.appendleft(command[1])
        elif command[0] == "delete":
            if command[1] in q:
                q.remove(command[1])
            else:
                continue
        elif command[0] == "deleteFirst":
            q.popleft()
        elif command[0] == "deleteLast":
            q.pop()
    print(*q)
if __name__=="__main__":
    main()


Measured memory_bytes: 526612
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using P = pair<ll, ll>;
const double EPS = 1e-12;
const ll INF = numeric_limits<ll>::max() / 2;
const ll MOD = 1e9 + 7;

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

    int n;cin>>n;
    if(n==3) cout<<2<<" "<<5<<" "<<63<<endl;
    else if(n==4) cout<<2<<" "<<5<<" "<<20<<" "<<63<<endl;
    else{
        vector<int> res,even_one,even_two,six,three;
        for(int i=2;i<=30000;i++){
            if(i%2==0 && i%3==0) six.push_back(i);
            else if(i%3==0) three.push_back(i);
            else if(i%2==0 && i%3==1) even_one.push_back(i);
            else if(i%2==0 && i%3==2) even_two.push_back(i);
        }
        vector<int> num;
        for(int i=1;i<5000;i++){
            num.push_back(even_one[i]);
            num.push_back(even_two[i]);
        }
        for(int i=1;i<5000;i++){
            num.push_back(six[i]);
        }
        if(n%2){
            res.push_back(2);res.push_back(4);res.push_back(6);
            if(n-3<=5000){
                for(int i=0;i<n-3;i++){
                    res.push_back(three[i]);
                }
            }
            else{
                for(int i=0;i<5000;i++){
                    res.push_back(three[i]);
                }
                int nokori=n-5003;
                for(int i=0;i<nokori;i++) res.push_back(num[i]);
            }
        }
        else{
            res.push_back(2);res.push_back(4);
            if(n-2<=5000){
                for(int i=0;i<n-2;i++){
                    res.push_back(three[i]);
                }
            }
            else{
                for(int i=0;i<5000;i++){
                    res.push_back(three[i]);
                }
                int nokori=n-5002;
                for(int i=0;i<nokori;i++) res.push_back(num[i]);
            }
        }
        for(int i=0;i<n;i++){
            if(i==19999){
                cout<<" "<<6;
                continue;
            }
            if(i==0) cout<<res[i];
            else cout<<" "<<res[i];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 768
#include <stdio.h>
int main () {
	int n,k,a = 1;
	scanf("%d",&n);
	scanf("%d",&k);
	for(int i = 0;i < n;i++) {
		if(a > k) a += k;
		else a *= 2;
	}
	printf("%d",a); 
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int k = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		sc.close();
		if(a >= b) ou.println(k + 1);
		else{
			if(k < a) ou.println(k + 1);
			else{
				long yono = a;
				long s = k + 1;
				k -= a - 1;
				if(k % 2 == 1) yono++;
				k /= 2;
				yono += (b - a) * (long)k;
				ou.println(Math.max(yono , s));
			}
		}
		ou.flush();
	}
}

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


int main(){
	long long int N, Y;
	cin>>N>>Y;
	long long int A = -1;
	long long int B = -1;
	long long int C = -1;
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N - i; j++){
			if(i * 10000 + j * 5000 ==Y - ( N - i - j) * 1000){
				if(( N - i - j) >= 0){
					A = i;
					B = j;
					C = N - i - j;
					goto ans;
				}
			}
		}
	}
	ans:

	cout<<A<<" "<<B<<" "<<C<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#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 each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;
    return ((m / gcd(m, n)) * n);
}

void solve() {
    ll k;
    cin >> k;
    ll ans = 0;
    for (ll i = 1; i <= k; i++) {
        for (ll j = 1; j <= k; j++) {
            for (ll l = 1; l <= k; l++) {
                ans += gcd(gcd(i, j), l);
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3644
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

Measured memory_bytes: 256
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

nums = [0] * 3
for e in p:
    if e <= a:
        nums[0] += 1
    elif e <= b:
        nums[1] += 1
    else:
        nums[2] += 1

ans = min(nums)
print(ans)


Measured memory_bytes: 3060
import itertools
n = input()
keta = len(list(n))
cnt=0
l = [3,5,7]
for k in range(3,keta+1):
  for i in itertools.product(l, repeat=k):
    if 3 in i and 5 in i and 7 in i:
      tmp=""
      for j in i:
        tmp+=str(j)
      if int(tmp)<=int(n):
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    using namespace std;
    signed main(){
    string a;
    int b=0,c,d;
    cin>>a;
    for(int i=0;i<4;i++){
    if(a[i]==a[i+1]){
    b=1;
    }
    }
    if(b==1){
    cout<<"Bad"<<"\n";
    }
    else{
    cout<<"Good"<<"\n";
    }
    return(0);
    }

Measured memory_bytes: 256