akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <cstring>
#define MAX_N 1000 + 16
 
using namespace std;
 
int N, H, W;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];
int fld[2 * MAX_N][2 * MAX_N], // ??????????????¨?????£??¨??????(i, j)??????????????????????????????
dx[4] = { 1, -1, 0, 0 }, dy[4] = { 0, 0, 1, -1 };
 
// ????????????????°?????????????????????????????¬¬????§?????????????????????±???????§???????
int compress(int *x1, int *x2, int w)
{
	vector<int>xs;
 
	for (int i = 0; i < N; ++i)
	{
		int tx1 = x1[i], tx2 = x2[i];
		xs.push_back(tx1);
		xs.push_back(tx2);
	}
	xs.push_back(0);
	xs.push_back(w);
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for (int i = 0; i < N; ++i)
	{
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}
	return xs.size() - 1;
}
 
int bfs()
{
	int ans = 0;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (fld[i][j]) continue;
			++ans;
			queue<pair<int, int> >que;
			que.push(make_pair(j, i));
			while (!que.empty())
			{
				int nx = que.front().first, ny = que.front().second;
				que.pop();
 
				for (int i = 0; i < 4; ++i)
				{
					int tx = nx + dx[i], ty = ny + dy[i];
					if (tx < 0 || W < tx || ty < 0 || H< ty || fld[ty][tx] > 0) continue;
					que.push(make_pair(tx, ty));
					fld[ty][tx] = 1;
				}
			}
		}
	}
	return ans;
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	while (cin >> W >> H, W | H)
	{
		cin >> N;
		for (int i = 0; i < N; ++i)
		{
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		}
 
		memset(fld, 0, sizeof(fld));
 
		W = compress(X1, X2, W);
		H = compress(Y1, Y2, H);
 
		// imos-???
		for (int i = 0; i < N; i++)
		{
			fld[Y1[i]][X1[i]]++;
			fld[Y1[i]][X2[i]]--;
			fld[Y2[i]][X1[i]]--;
			fld[Y2[i]][X2[i]]++;
		}
		// ?¨?????´??§?
		for (int i = 0; i < H; i++)
		{
			for (int j = 1; j < W; j++)
			{
				fld[i][j] += fld[i][j - 1];
			}
		}
		// ???????´??§?
		for (int i = 1; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				fld[i][j] += fld[i - 1][j];
			}
		}// ?´??§??????????fld??????0??¨?????¨????????????
		cout << bfs() << endl;
	}
	return 0;
}
///////////////////////////End Sub//////////////////////////////////

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


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

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() {
	
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int ans = INF, t;
	for (int i = 0; i < n - k + 1; ++i) {
		t = min(a[i + k - 1] - a[i] + abs(a[i + k - 1]), a[i + k - 1] - a[i] + abs(a[i]));
		if (ans > t) ans = t;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

ll k;

ll combo(int n)
{
    vector<int> f;
    int i;
    ll ans = 1;

    for(i=0; i<7; ++i)
        if((n+i) % 7 == 0)
            ans *= (n+i)/7;
        else ans *= (n+i);

    ans /= 720;
    return ans;
}

int main()
{
   // freopen("input", "r", stdin);
   // freopen("output", "w", stdout);
    cin.sync_with_stdio(false); cin.tie(0);

    cin >> k;

    int i, j;
    vector<int> c(601);

    for(i=600; i; --i)
    {
        ll now = combo(i);
        c[i] = k/now;
        k %= now;
    }

    for(i=1; i<=600; ++i)
    {
        cout << "FESTIVA";
        for(j=0; j<c[i]; ++j) cout << "L";
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    unsigned long long int X,i=0, Y=100;
    scanf("%llu",&X);
    while(1)
    {


        Y=Y+(Y*0.01);
        i++;
        if(Y>=X)
            break;
    }
    printf("%d",i);
    return 0;
}


Measured memory_bytes: 1704
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define N 1003
using namespace std;
typedef long long ll;
const int Mod = 1e9 + 7;

inline int fsp(int x, int p = Mod - 2) {
    int res= 1;
    while (p) {
        if (p & 1) res = 1ll * res * x % Mod;
        x = 1ll * x * x % Mod, p >>= 1;
    } return res;
}

namespace dsu {
    int fa[N];
    void init(int n) {
        for (int i = 1; i <= n; ++i)
            fa[i] = i;
    }
    int find(int x) {
        return fa[x] == x ? x : fa[x] = find(fa[x]);
    }
    bool united(int x, int y) {
        int a = find(x), b = find(y);
        return fa[a] = b, a == b;
    }
}

using dsu::find;
using dsu::united;

struct Edge {
    int u, v, w, c;
    Edge() { u = v = w = c = 0; }
};

int n, m;
int tot = 1, fir[N], nxt[N << 1], to[N << 1], val[N << 1];
ll X, ans;
Edge e[N << 1];
int dep[N], fa[N][15], mx[N][15];

inline void addE(int u, int v, int w) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v, val[tot] = w;
    nxt[++tot] = fir[v], fir[v] = tot, to[tot] = u, val[tot] = w;
}

inline bool cmpw(Edge a, Edge b) {
    return a.w < b.w;
}

void dfs(int u, int p, int w) {
    fa[u][0] = p, dep[u] = dep[p] + 1, mx[u][0] = w;
    for (int k = 0; k < 11; ++k)
        mx[u][k + 1] = max(mx[u][k], mx[fa[u][k]][k]),
        fa[u][k + 1] = fa[fa[u][k]][k];
    for (int i = fir[u]; i; i = nxt[i])
        if (to[i] != p) dfs(to[i], u, val[i]);
}

inline int getmax(int u, int v) {
    if (dep[u] < dep[v]) swap(u, v);
    int res = 0, d = dep[u] - dep[v];
    for (int k = 11; k >= 0; --k)
        if ((d >> k) & 1) res = max(res, mx[u][k]), u = fa[u][k];
    if (u == v) return res;
    for (int k = 11; k >= 0; --k)
        if (fa[u][k] != fa[v][k])
            res = max(res, max(mx[u][k], mx[v][k])), u = fa[u][k], v = fa[v][k];
    return max(res, max(mx[u][0], mx[v][0]));
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> m >> X;
    for (int i = 1; i <= m; ++i)
        scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w);

    sort(e + 1, e + m + 1, cmpw);

    ll mst = 0;
    dsu::init(n);
    for (int i = 1; i <= m; ++i)
        if (!united(e[i].u, e[i].v))
            addE(e[i].u, e[i].v, e[i].w), mst += e[i].w, e[i].c = -1;

    if (mst == X) ans = 1ll * fsp(2, m - n + 1) * (fsp(2, n - 1) - 2) % Mod;

    dfs(1, 0, 0);

    int eql = 0, lrg = 0;
    for (int i = 1; i <= m; ++i) {
        if (e[i].c == -1) continue;
        ll tmp = e[i].w - getmax(e[i].u, e[i].v);
        if (tmp + mst == X) ++eql;
        if (tmp + mst > X) ++lrg;
    }

    ans = (ans + 2ll * (fsp(2, eql) - 1) % Mod * fsp(2, lrg)) % Mod;

    cout << ans << endl;

    return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i * 108 / 100 == n) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << ":(" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
				using namespace std;
				#define ll long long
				#define mod 1000000007
				#define pll pair<long,long>
				#define se second
				#define fi first
				#define pb push_back
				#include <ext/pb_ds/assoc_container.hpp>
				#include <ext/pb_ds/tree_policy.hpp>
				using namespace __gnu_pbds;

				typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
				typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;
				
			
				
				int main()
				{
					ios_base::sync_with_stdio(false);
					cin.tie(NULL);
					ll n,m;
					cin>>n>>m;
					
					cout<<n*(n-1)/2 + m*(m-1)/2;
				}
				


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  ll x=0,y=0;
  FOR(i,1,n+1){
    ll a;
    cin>>a;
    (x+=a*(i-1)-a*(n-i))%=mod;
  }
  FOR(i,1,m+1){
    ll a;
    cin>>a;
    (y+=a*(i-1)-a*(m-i))%=mod;
  }
  ll ans=x*y%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin >> D;
  if(D == 25){
    cout << "Christmas" << endl;
  }
  if(D == 24){
    cout << "Christmas Eve" << endl;
  }
  if(D == 23){
    cout << "Christmas Eve Eve" << endl;
  }
  if(D == 22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
//Author: master19
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ff first 
#define ss second 
#define pb push_back
#define endl "\n"
#define PI acos(-1.0)
#define mod 1000000007LL // fixed...
#define modd 1000000007LL // Can be changed for global use
#define ccy cout << "YES\n"
#define ccn cout << "NO\n"
#define cfy cout << "Yes\n"
#define cfn cout << "No\n"
#define x(arr) arr.begin(),arr.end()
#define ulli unsigned long long int
#define assign(x,val) memset(x,val,sizeof(x))
#define prec(val, dig) fixed << setprecision(dig) << val
#define vil vector < ll > 
#define vis vector < string > 
#define vip vector < pair < ll, ll > > 
#define pi pair < ll , ll > 
#define pii pair < pair < ll, ll >, ll >
#define Sort(arr) sort(arr.begin(), arr.end())
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define crap ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define get(arr, num) vector < ll > arr(num); for(int i=0; i<num; i++)cin >> arr[i];
#define get_set(arr, num, st, type) set < type > st; for(int i=0; i<num; i++) st.insert(arr[i]);
#define put(arr, num) for(int i=0; i<num; i++)cout << arr[i] << " "; cout << endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > new_ds; 
ll lets_do_it();
// pi xy[] = {{-1, 0}, {1, 0} , {0, -1}, {0, 1}};
// pi dig[] = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
// bool isValid(ll x, ll y, ll row, ll col){
//     return ((x>=0) && (y >=0)  && (x < row) && (y < col));
// }
int main(int argc, const char** argv) {
    crap;
    ll test = 1;
    // cin >> test;
    for(int loop=0; loop<test; loop++){
        // cout << "Case #" << (loop+1) << ": "; 
        lets_do_it();
    }
    return 0;
}
ll lets_do_it(){
    // Your code goes by here !!
    ll num;
    cin >> num;
    string str;
    cin >> str;
    if(str.length() > num){
        for(int i=0; i<num; i++)
            cout << str[i];
        cout << "...\n";
    }else
        cout << str << endl;






    return 0;
}


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

using namespace std;

bool desc(int a,int b){
    return a>b;
}

int main(){
    //int t;
    
    //cin>>t;
    
    //while(t--){
        int n;
        
        cin>>n;
        
        int a[n],b[n],d1=0,d2=0;
        
        string aa,bb,df;
        
        for(int i = 1 ; i <= n ; i++){
            df+=i+'0';
        }
        
        for(int i = 0 ; i < n ; i++){
            cin>>a[i];
            aa += a[i]+'0';
        }
        
        for(int i = 0 ; i < n ; i++){
            cin>>b[i];
            bb += b[i]+'0';
        }
        
        while(1){
            if(aa==df) break;
            prev_permutation(aa.begin(), aa.end());
            d1++;
        }while(1){
            if(bb==df) break;
            prev_permutation(bb.begin(), bb.end());
            d2++;
        }
        
        cout<<abs(d1-d2);
        
    //}
    
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
int pre[n+1];
pre[0]=0;
for(int i=0; i<n; ++i) cin>>pre[i+1], pre[i+1]+=pre[i];
int suff[n+2];
for(int i=0; i<n; ++i) cin>>suff[i+1];
suff[n+1]=0;
for(int i=n; i>0; --i) suff[i]+=suff[i+1];
int res = 0;
for(int i=1; i<=n; ++i) res=max(res, pre[i]+suff[i]);
cout<<res;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    t = input()
    f = {"P":0,"D":1}
    n = len(t)
    dp = [[0]*2 for i in range(n+1)]
    p = [[None]*2 for i in range(n+1)]
    for i in range(n):
        ni = i+1
        for j in range(2):
            if i > 0 and t[i-1] in "PD" and f[t[i-1]] != j:
                continue
            if t[i] == "?":
                for nj in range(2):
                    k = 0
                    if nj == 1:
                        k += 1
                        if j == 0:
                            k += 1
                    nd = dp[i][j]+k
                    if dp[ni][nj] <= nd:
                        dp[ni][nj] = nd
                        p[ni][nj] = j
            else:
                nj = f[t[i]]
                nd = dp[i][j]
                k = 0
                if nj == 1:
                    k += 1
                    if j == 0:
                        k += 1
                nd = dp[i][j]+k
                if dp[ni][nj] <= nd:
                    dp[ni][nj] = nd
                    p[ni][nj] = j
    if dp[n][0] < dp[n][1]:
        path = [1]
    else:
        path = [0]
    for i in range(1,n)[::-1]:
        path.append(p[i+1][path[-1]])
    k = "PD"
    ans = [k[i] for i in path[::-1]]
    print(*ans,sep="")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 150944
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }


}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力




const int MAX = 1100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();
    ll X,Y,ans=0;
    cin >> X>>Y;
    if(2*X-Y>=0 &&2*Y-X >= 0){
        if((2*X-Y)%3 == 0){
            ans = COM((X+Y)/3, (2*X-Y)/3);
        }
    }
    // 計算例
    cout << ans << endl;
}

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

int main() {
  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int> A(Q);
  rep(i,Q) cin>>A[i];
  vector<int> v(N,K-Q);//最終ポイントの管理。初期値K-Q
  rep(i,Q){
    v[A[i]-1]++;
  }
  rep(i,N){
    if(v[i]>0) puts("Yes");
    else puts("No");
  }
  return 0;
}

Measured memory_bytes: 1408
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)

Measured memory_bytes: 24784
def resolve():
    n = int(input())
    dict = {}
    s = [",".join(sorted(input())) for _ in range(n)]
    count = 0
    for i in range(n):
        if s[i] in dict:
            count += dict[s[i]]
            dict[s[i]] += 1
        else:
            dict[s[i]] =1

    print(count)
resolve()

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

using namespace std;
int main(){

    int k,s;
    cin >> k >> s;

    int ans = 0;
    for(int x=0; x<=k; x++){
        for(int y=0; y<=k; y++){
            int z = s - (x+y);
            if(z >= 0 && z <= k) ans++;
        }
    }

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

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll prev;
    cin >> N;
    cin >> prev;
    for(ll i = 1;i < N;i++) {
        ll temp;
        cin >> temp;
        if(temp < prev) {
            cout << "No" << endl;
            return 0;
        } else if(temp > prev) {
            temp--;
        }
        prev = temp;
    }
    cout << "Yes" << endl;
    return 0;
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string s;
    cin >> s;

    rep(i, s.size())
    {
        if(s[i]=='?')
        {
            s[i]='D';
        }
    }
    cout << s << endl;



    return 0;
}



Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n, m, t; std::cin >> n >> m >> t;
	std::vector<int> balls(n); for (auto& a : balls) std::cin >> a;
	std::vector<std::vector<long long int>> max_b{ std::vector<long long int>(t, -1) };
	for (const auto a : balls) {
		max_b[0][a % t] = std::max(max_b[0][a % t], (long long int)a / t);
	}
	for (auto _c = 1; (1 << _c) <= m; ++_c) {
		std::vector<long long int> last(t, -1);
		for (auto i = 0; i < t; ++i) if (max_b.back()[i] != -1) {
			for (auto j = 0; j <= i; ++j) if (max_b.back()[j] != -1) {
				last[(i + j) % t] = std::max(last[(i + j) % t], max_b.back()[i] + max_b.back()[j] + (i + j) / t);
			}
		}
		max_b.push_back(std::move(last));
	}
	auto result = max_b.back();
	for (auto i = 0; i + 1 < max_b.size(); ++i) if ((m & (1 << i)) != 0) {
		auto last = result;
		for (auto j = 0; j < t; ++j) if (max_b[i][j] != -1) {
			for (auto k = 0; k < t; ++k) if (last[k] != -1) {
				result[(j + k) % t] = std::max(result[(j + k) % t], max_b[i][j] + last[k] + (j + k) / t);
			}
		}
	}
	for (auto i = 2; i <= result.size(); ++i) {
		result[result.size() - i] = std::max(result[result.size() - i], result[result.size() - i + 1]);
	}
	int q; std::cin >> q;
	for (auto i = 0; i < q; ++i) {
		int a, b; std::cin >> a >> b;
		std::cout << (result[a] >= b ? "yes\n" : "no\n");
	}
}


Measured memory_bytes: 3316
#include <cstdio>
#include <string>

bool is_ok(const std::string &s, std::string &t) {
  size_t N=s.length();
  for (size_t i=1; i<=N; ++i) {
    if (t[i] == 'S') {
      t.push_back((s[i%N]=='o'? 'S':'W')^t[(i+N-1)%N]^'S');
    } else {
      t.push_back((s[i%N]=='o'? 'W':'S')^t[(i+N-1)%N]^'S');
    }
  }

  if (t[1] != t.back()) return false;
  t.pop_back();
  if (t[0] != t.back()) return false;
  t.pop_back();
  return true;
}

int main() {
  int N;
  char buf[131072];
  scanf("%d %s", &N, buf);
  std::string s=buf;

  for (std::string t: {"SS", "SW", "WS", "WW"}) {
    if (is_ok(s, t)) {
      return !printf("%s\n", t.c_str());
    }
  }

  printf("-1\n");
}


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

using namespace std;

//int nums[8];
vector<int> nums;
//map<string,bool> used;
string src;

const int d[]={-1,4,1,-4};
bool used[8][8][8][8][8][8][8][8];
int dp[8][8][8][8][8][8][8][8];


void bfs(vector<int> s){
	//if(s==src)
	//	return 0;
	//bool f=true;
	//for(int i = 0; i < s.size(); i++){
	//	if(s[i]!=nums[i]){
	//		f=false;
	//		break;
	//	}
	//}
	//if(f){
	//	return 0;
	//}

	set<vector<int> > *prv=new set<vector<int> >();
	set<vector<int> > *nxt=new set<vector<int> >();

	prv->insert(s);
	dp[0][1][2][3][4][5][6][7]=0;

	int cnt=1;
	while(prv->size()){
		for(set<vector<int> >::iterator it = prv->begin(); it != prv->end(); it++){
			vector<int> cs=*it;
			if(used[cs[0]][cs[1]][cs[2]][cs[3]][cs[4]][cs[5]][cs[6]][cs[7]])
				continue;
			used[cs[0]][cs[1]][cs[2]][cs[3]][cs[4]][cs[5]][cs[6]][cs[7]]=true;
			int zi;
			for(int i = 0; i < cs.size(); i++){
				if(cs[i]==0){
					zi=i;
					break;
				}
			}
			for(int i = 0; i < 4; i++){
				int np=zi+d[i];
				if((zi==0&&(i==1||i==2))
					||((zi>=1&&zi<=2)&&(i>=0&&i<=2))
					||(zi==3&&(i==0||i==1))
					||(zi==4&&(i==3||i==2))
					||(zi==7&&(i==0||i==3))
					||((zi>=5&&zi<=6)&&(i!=1))
					){
					vector<int> ns=cs;
					std::swap(ns[zi],ns[np]);
					if(!used[ns[0]][ns[1]][ns[2]][ns[3]][ns[4]][ns[5]][ns[6]][ns[7]]){
						nxt->insert(ns);
						dp[ns[0]][ns[1]][ns[2]][ns[3]][ns[4]][ns[5]][ns[6]][ns[7]]
						=dp[cs[0]][cs[1]][cs[2]][cs[3]][cs[4]][cs[5]][cs[6]][cs[7]]+1;
						//if(ns==nums){
						//	return cnt;
						//}
					}
				}
			}
		}
//		cout<<nxt->size()<<endl;
		swap(prv,nxt);
		nxt->clear();
		cnt++;
	}
	delete prv,nxt;
}

//int dfs(string s,int cnt){
//	//cout<<cnt<<endl;
//	if(s=="01234567"){
//		return 0;
//	}
//	//if(dp[s]!=-1)
//		return dp[s];
//
//	//cout<<cnt<<endl;
//	int idx;
//	for(int i = 0; i < s.size(); i++){
//		if(s[i]=='0'){
//			idx=i;
//			break;
//		}
//	}
//	int minNum=10000000;
//	for(int i = 0; i < 4; i++){
//		int np=idx+d[i];
//		if(np>=0&&np<8){
//			string ns=s;
//			swap(ns[idx],ns[np]);
//			if(!used[ns]){
//				//used.insert(ns);
//				used[ns]=true;
//				minNum=min(minNum,dfs(ns,cnt+1)+1);
//				used[ns]=false;
//				//used.erase(ns);
//			}
//		}
//	}
//	dp[s]=minNum;
//	return minNum;
//}

int main(){

	//string ts="01234567";
	vector<int> v;
	for(int i = 0; i < 8; i++){
		v.push_back(i);
		nums.push_back(0);
	}

	//do{
	//	
	//}while(next_permutation(ts.begin(),ts.end()));

	memset(used,0,sizeof(used));
	bfs(v);
	while(cin>>nums[0]>>nums[1]>>nums[2]>>nums[3]>>nums[4]>>nums[5]>>nums[6]>>nums[7]){
		cout<<dp[nums[0]][nums[1]][nums[2]][nums[3]][nums[4]][nums[5]][nums[6]][nums[7]]<<endl;
//		cout<<dp[nums[0]]
		//string s;
		//for(int i = 0; i < 8; i++){
		//	s+=nums[i];
		//}
		//for(map<string,bool>::iterator it = used.begin(); it != used.end(); it++){
		//	used[it->first]=false;
		//}
//		src=s;

	}

	return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val (N, X) = listOfLong()
    val a = listOf(1L).toMutableList()
    val p = listOf(1L).toMutableList()
    for (n in 1 .. N.toInt()) {
        a.add(a[n - 1] * 2 + 3)
        p.add(p[n - 1] * 2 + 1)
    }
    fun f(n: Int, x: Long): Long {
        if (n == 0) {
            return  if (x <= 0L) 0 else 1
        } else if (x <= 1 + a[n - 1]) {
            return f(n - 1, x - 1)
        } else {
            return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1])
        }
    }
    val ans = f(N.toInt(), X)
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 37860
# include <bits/stdc++.h>
# define ll long long 
using namespace std;
const ll N = 2e5 + 10, mod = 1e9 + 7;
int a[3][3], b[N], c[3][3];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        for(int x = 0; x < 3; x++){
            for(int y = 0; y < 3; y++){
                if(b[i] == a[x][y]){
                    c[x][y] = true;
                }
            }
        }
    }
    for(int i = 0; i < 3; i++){
        if(c[i][0] + c[i][1] + c[i][2] == 3){
            cout << "Yes\n";
            return 0;
        }
        if(c[0][i] + c[1][i] + c[2][i] == 3){
            cout << "Yes\n";
            return 0;
        }
    }
    if(c[0][0] + c[1][1] + c[2][2] == 3){
        cout << "Yes\n";
        return 0;
    }
    if(c[0][2] + c[1][1] + c[2][0] == 3){
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int n;
  for(;;) {
    cin >> n;
    if(n == 0) break;
    
    int c;
    int ice[10] = {};
    for(int i=0; i<n; ++i) {
      cin >> c;
      ++ice[c];
    }

    for(int i=0; i<=9; ++i) {
      if(ice[i] == 0) cout << "-" << endl;
      else {
        for(int j=0; j<ice[i]; ++j) {
          cout << "*";
        }
        cout << endl;
      }
    }

  }
}



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

long long cnt = 0;
int G[100];
int mcount = 0;

void insertionSort(int A[], int n, int g){
    for (int i = g; i < n; i++){
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v){
            A[j + g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j + g] = v;
    }
};

void shellSort(int A[], int n){
    G[99] = 1;
    for (int i = 98; i >= 0; i--){
        if(G[i + 1] * 3 + 1 <= n){
            G[i] = G[i + 1] * 3 + 1;
        } else break;
    }

    for(int i = 99; i >= 0; i--){
        if(G[i] != 0)mcount++;
        else break;
    }

    for (int i = 100 - mcount; i < 100; i++){
        insertionSort(A, n, G[i]);
    }
    
};

int main() {
    int N; cin >> N;
    int A[N];
    rep(i, N){
        cin >> A[i];
    }

    shellSort(A, N);

    cout << mcount << endl;

    for(int i = 100 - mcount; i < 100; i++){
        if (i == 99){
            cout << G[i] << endl;
        } else {
            cout << G[i] << " ";
        }
    }

    cout << cnt << endl;

    rep(i, N){
        cout << A[i] << endl;
    }

}


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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }
signed main() {
	int N, x; cin >> N >> x;
	V v(N); input(v);
	int ans = 0;
	rep(i, 1, N) {
		int sum = v[i - 1] + v[i];
		ans += max(0ll, sum - x);
		v[i] = max(0ll, v[i] - max(0ll, sum - x));
	}
	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 1272
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N,K = mis()
    h = lmis()
    print(sum(h[i]>=K for i in range(N)))


main()


Measured memory_bytes: 11912
#include<stdio.h>

int main(void)
{
	int n, i, a;
	long long sum = 0;
	int max = -1000000;
	int min = 1000000;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a);
		sum += a;
		if (max <= a)
		{
			max = a;
		}
		if (min >= a)
		{
			min = a;
		}
	}
	printf("%d %d %lld", min, max, sum);
	putchar('\n');

	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 

int main() {
   
   ll n;
   cin>>n;
   
   ll arr[n];
   
   for(ll i=0;i<n;i++)
   cin>>arr[i];
   
   ll maxx=0,k=0;
   for(ll i=0;i<n;i++)
   {
       if(arr[i+1]<=arr[i])
       k++;
       else
       {
       maxx=max(maxx,k);
       k=0;
       }
   }
    
   if(maxx==0)
   cout<<0;
   else
   cout<<maxx;
   
}

Measured memory_bytes: 1024
package main

import (
    "fmt"
)

func pow(a,b int) int {
    r := 1
    for i := 0; i < b; i++{
        r *= a
    }
    return r
}

func main() {
    var a,b int
    fmt.Scan(&a,&b)
    if(b == 100){
        b = 101
    }
    fmt.Println(b * pow(100, a))
}

Measured memory_bytes: 512
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long

int comp(const void *a, const void *b)
{ //昇順
  return *(int *)a - *(int *)b;
}

int main(void)
{
  int x, n;
  int p[101];
  int i;
  scanf("%d %d", &x, &n);
  for (i = 0; i < n; i++)
  {
    scanf("%d", &p[i]);
  }
  if (n == 0)
  {
    printf("%d\n", x);
    return 0;
  }

  qsort(p, n, sizeof(int), comp);

  int *sr = bsearch(&x, p, n, sizeof(int), comp);
  if (sr == NULL)
  {
    printf("%d\n", x);
    return 0;
  }
  int pos = sr - p;
  int lx, rx, lpos, rpos;
  lx = x - 1;
  rx = x + 1;
  lpos = pos - 1;
  rpos = pos + 1;
  while (1)
  {
    if (lx != p[lpos])
    {
      printf("%d\n", lx);
      break;
    }
    if (rx != p[rpos])
    {
      printf("%d\n", rx);
      break;
    }
    lpos--;
    rpos++;
    lx--;
    rx++;
  }

  return 0;
}


Measured memory_bytes: 1728
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	int N;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	int *a = (int *)malloc(sizeof(int) * N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		a[i] = A[i];
	}

	int cnt = 0, ans = 0;
	while (1) {
		cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
				cnt++;
			}
		}
		if (cnt == N) {
			ans++;
		}
		else {
			break;
		}
	}

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


#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define maxn 600020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

int a[maxn],f[maxn],g[maxn];
int n,S;

int main(){
	scanf("%d",&n);
	S = (1 << n) - 1;
	rep(i,0,S) scanf("%d",&f[i]) , g[i] = -inf;
	rep(i,0,n - 1){
		rep(j,0,S){
			if ( j & (1 << i) ){
				if ( f[j] < f[j ^ (1 << i)] ){
					g[j] = f[j] , f[j] = f[j ^ (1 << i)];
					if ( g[j] < g[j ^ (1 << i)] ) g[j] = g[j ^ (1 << i)];
				}
				else if ( g[j] < f[j ^ (1 << i)] ) g[j] = f[j ^ (1 << i)];
			}
		}
	}
/*	rep(j,0,S){
		cout<<j<<" "<<f[j]<<" "<<g[j]<<endl;
	}*/
	rep(i,1,S){
		int pre = 0,ans = f[i] + g[i];
		repd(j,n - 1,0){
			if ( i & (1 << j) ){
				ans = max(ans,f[pre | ((1 << j) - 1)] + g[pre | ((1 << j) - 1)]);
				pre |= 1 << j;
			}
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	vs a(n);
	rep(i, n) cin >> a[i];

	rep(i, n) {
		repr(j, i + 1, n) {
			if (a[i] == a[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	rep(i, n-1) {
		if (a[i][a[i].size() - 1] != a[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static String str;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        str=sc.nextLine();
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<str.length(); i++) {
            char c = str.charAt(i);
            if (Character.isUpperCase(c)) {
                c += 32;
                sb.append(c);
            }
            else if(Character.isLowerCase(c)){
                c -= 32;
                sb.append(c);
            }else sb.append(c);
        }
        System.out.println(sb.toString());
        sc.close();
    }
}



Measured memory_bytes: 26224
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a=1,n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		if(a<k)a*=2;
		else a+=k;
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNext()) {
			int cycle = scanner.nextInt();
			if(cycle == 0) return;
			
			int count;
			int target;
			
			String text = scanner.next();

			for(int i = 0; i < cycle; i++) {
				StringBuffer sb = new StringBuffer();
				count = 1;
				target = Integer.valueOf(text.substring(0, 1));
				
				for(int p=1; p<text.length(); p++) {
					if (target == Integer.valueOf(text.substring(p, p+1))) {
						count++;
					} else {
						sb.append(count);
						sb.append(target);
						
						count = 1;
						target = Integer.valueOf(text.substring(p, p+1));
					}
				}
				sb.append(count);
				sb.append(target);
				
				text = sb.toString();
			}
			System.out.println(text);
		}
	}
}

Measured memory_bytes: 37828
#include<iostream>
#define Maxn 101

using namespace std;

int main()
{
	int n, A[Maxn], B[Maxn];
	cin >> n;
	for(int i = 0; i < n-1; i++)
		cin >> B[i];
	A[0] = B[0];
	for(int i = 0; i < n-1; i++)
		A[i+1] = B[i];
	for(int i = 0; i < n-1; i++)
	{
		if(B[i] < A[i])
			A[i] = B[i];
	}
	int sum = 0;
	for(int i = 0; i < n; i++)
		sum += A[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    string n;
    cin >> n;
    for(int i = 0;i < 3;i++)
    {
        if(n[i] == '7')
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define mk make_pair

int main()
{
	string s;
	cin>>s;
	if(s=="ARC")
	cout<<"ABC"<<endl;
	else
	cout<<"ARC"<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vpulli vector <pair <ulli,ulli> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pair <int,int>> >
#define vvb vector <vector <bool> >
#define fr(i,n) for (int i = 0; i < (n); i++)
#define frbig(i,n) for (lli i = 0; i < (n); i++)
#define fra(i,a,n) for (lli i = a; i < (n); i++)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
const lli MOD = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    lli k;
    cin >> n >> k;
    vi a(n);
    fr(i,n){ cin >> a[i]; a[i]--;}
    int x=0;
    vi s;
    vb used(n,false);
    while(!used[x]){
        used[x]=true;
        s.pb(x);
        x=a[x];
    }
    int f=0;
    while(s[f]!=x){
        f++;
    }
    if(k>f){
    k-=f;
    cout << s[f+k%(s.size()-f)]+1;
    }
    else cout << s[k]+1;
    return 0;
}

Measured memory_bytes: 5068
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
int main() {
  int a;
  cin >> a;
  cout << "ABC" << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 100000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int k,n;
    cin>>k>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0,d=0;
    for(int i=1;i<n;i++)
        d=max(d,a[i]-a[i-1]);
    d=max(d,a[0]+(k-a[n-1]));
    cout<<k-d;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define M(x,y) ((x)>(y)?(x):(y))
#define m(x,y) ((x)<(y)?(x):(y))

int main() {
	int n, a[200001]; ll S=0, s=0, min=9999999999999999;
	scanf("%d", &n);
	rep(i, n) { scanf("%d", &a[i]); S += a[i]; }
	rep(i,n-1) {
		s += a[i];
		min = m(min, M(S - 2 * s, 2 * s - S));
	}
	printf("%lld", min);
}

Measured memory_bytes: 896
import numpy as np
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  tmp = list(map(int, input().split()))
  s.append(tmp)

total = 0
d = np.zeros(26)
for i in range(D):
  t = int(input())
  
  total += s[i][t-1]
  d[t-1] = (i+1)
  for j in range(26):
    total -= int(c[j]*((i+1)-d[j]))
  print(total)
    
  
  

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  string c[3];
  cin >> c[0] >> c[1] >> c[2];
  cout << c[0][0] << c[1][1] << c[2][2];
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    int n;
    cin >> n;
    vector<int> ans(26, INT_MAX);
    while(n--){
        vector<int> h(26);
        string s;
        cin >> s;
        for(int i=0; i<(int)s.length(); ++i)
            h[s[i]-'a']++;
        
        for(int i=0; i<26; ++i){
            ans[i] = min(ans[i], h[i]);
        }
    }

    for(int i=0; i<26; ++i){
        if(ans[i]){
            cout << string(ans[i], 'a'+i);
        }
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
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(b<a)a=b;}

int main(){
  int n;
  cin >> n;
  vector<char> s(n);
  vector<pair<int,int>> sum(n+1,{0,0});
  rep(i,n)cin >> s[i];
  
  rep(i,n){
    if(s[i] == 'W') sum[i+1].first += (1+sum[i].first);
    else sum[i+1].first = sum[i].first;
   // cout << sum[i].first << endl;
  } 
  for(int i=n-1;i>=0;--i){
    if(s[i] == 'E')sum[i].second += (1 + sum[i+1].second); 
    else sum[i].second = sum[i+1].second;
  }
  int turn = 300010;
  //cout << sum[0].second << endl; 
  rep(i,n+1){
    int tmp = sum[i].first + sum[i].second;
    //if(turn > tmp) cout << i << endl;
    chmin(turn,tmp);
  }
  cout << turn << endl;
}

Measured memory_bytes: 2944
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	int count = 0;
	int i;
	for (i = a; i <= b; ++i)
	{
		if (c % i == 0)
			count++;
	}

	printf("%d\n", count);
	return 0;
}

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

using namespace std;

int main() {

	string str;
	string p;
	
	cin >> str >> p;

	str += str;

	int judge = str.find(p);

	if (judge == string::npos) {

		cout << "No" << endl;

	}
	else {

		cout << "Yes" << endl;

	}

	return 0;

}


Measured memory_bytes: 3176