akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int x, n;
  cin >> x >> n;
  arr(p,n);

  vecb exist(102, false);
  rep(i,n){
    exist[p[i]]=true;
  }

  int ans=999;
  int ab=999;
  rep(i,102){
    if(!exist[i] && ab>abs(x-i)){
      ans=i;
      ab=abs(x-i);
    }
  }

  prt(ans);
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x , s1 , s2 , s3;
    cin >> x;
    s3 = x % 10;
    s2 = (x % 100 - s3) / 10;
    s1 = (x % 1000 - s2 - s3) /100;
    cout << s1 + s2 + s3 << endl;
}

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


int main() {
    int h, w, bomb_num = 0;
    char s[51][51] = { 0 };

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') {
                bomb_num = 0;
                for (int k = i - 1; k <= i + 1; k++) {
                    for (int l = j - 1; l <= j + 1; l++) {
                        if (k >= 0 && k < h&&l >= 0 && l < w) {
                            if (s[k][l] == '#') bomb_num += 1;
                        }
                    }
                }
                s[i][j] = '0' + bomb_num;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << s[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//行数
		int a = sc.nextInt();
		//列
		int b = sc.nextInt();
		int[][] list = new int[a + 1][b + 1];
		
		//配列に格納する
		for (int i = 0; i < a; i++) {
		    for (int j = 0; j < b; j++) {
		        list[i][j] =sc.nextInt();
		    }
		}
		
		for (int i = 0; i < a; i++) {
			int sum = 0;
			for (int j = 0; j < b; j++) {
				sum += list[i][j];
			}
			list[i][b] = sum;
		}
		
		//右下の合計値を含めた列
		for (int i = 0; i < b + 1; i++) {
			int sum = 0;
			for (int j = 0; j < a; j++) {
				sum += list[j][i];
			}
			list[a][i] = sum;

		}

		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
			    //半角スペースを先頭だけ除外する
				if (j == 0)
					System.out.print(list[i][j]);
				else
					System.out.print(" " + list[i][j]);

			}
			System.out.println();
		}
    }
}


Measured memory_bytes: 41260
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  ll p[N];
  rep(i, N) cin>>p[i];
  ll count = 0;
  rep_s(i, 1,N-1){
    if(p[i-1]<p[i] && p[i] <p[i+1]) count++;
    else if(p[i-1]>p[i] && p[i] > p[i+1]) count++;
  }
  cout << count << endl;
  
}


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

using namespace std;

int main(){
	int n,min;
	bool flag = true;
	vector<int> a;
	cin >> n;
	a.resize(n);
	for(int i=0;i<n;++i)cin >> a[i];
	min = a[n-1];
	for(int i=n-2;i>=0;--i){
		if(a[i] - min > 1){
			flag = false;
			break;	
		}else if(a[i] - min <= 0){
			min = a[i];
		}
	}
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

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

vector<char> vec;
rep(i, s.size()){
    if(s.at(i) == 'B'){
        if(vec.empty() == 0) vec.pop_back();
    }
    else{
        vec.push_back(s.at(i));
    }
}
rep(i, vec.size()) cout << vec.at(i);
cout << endl;

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



Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int x,y,n,q,i,j,root[10000],len[10000],c,a,b;
	scanf("%d %d",&n,&q);
	for(i=0;i<n;i++)	{
		root[i]=i;
		len[i]=1;
	}
	for(i=0;i<q;i++)	{
		scanf("%d %d %d",&c,&x,&y);
//		printf("%d %d %d\n",c,x,y);
		while(x!=root[x])	x=root[x];
		while(y!=root[y])	y=root[y];
		if(c==1)	{
			if(x==y)	printf("1\n");
			else printf("0\n");
		}
		else {
			if(x!=y)	{
				if(len[x]>len[y])	{
					root[y]=x;
				}
				else if(len[x]<len[y])	{
					root[x]=y;
				}
				else {
					root[y]=x;
					len[x]++;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
#define maxn 200100
#define ll long long
ll sum[4];
int p1,p2,n,a[maxn];
ll pre[maxn];
ll seg(int l,int r)
{
    return pre[r]-pre[l-1];
}
ll cal()
{
    ll mx=sum[0],mn=sum[0];
    for(int i=1;i<4;++i)
    {
        mx=max(mx,sum[i]);
        mn=min(mn,sum[i]);
    }
    return mx-mn;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
        pre[i]=pre[i-1]+a[i];
    }
    p1=1; sum[0]=a[1],sum[1]=a[2];
    p2=3; sum[2]=a[3],sum[3]=seg(4,n);
    while(p2<n-1&&abs(sum[3]-sum[2])>abs(sum[3]-sum[2]-2*a[p2+1]))
    {
        p2++;
        sum[2]+=a[p2];
        sum[3]-=a[p2];
    }
    ll ans=cal();
    for(int i=3;i<n;++i)
    {
        sum[1]+=a[i];
        sum[2]-=a[i];
        while(p1<i-1&&abs(sum[1]-sum[0])>abs(sum[1]-sum[0]-2*a[p1+1]))
        {
            p1++;
            sum[0]+=a[p1];
            sum[1]-=a[p1];
        }
        while(p2<n-1&&abs(sum[3]-sum[2])>abs(sum[3]-sum[2]-2*a[p2+1]))
        {
            p2++;
            sum[2]+=a[p2];
            sum[3]-=a[p2];
        }
        ans=min(ans,cal());
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 100000+10;
Int dp[max_n][15]; //dp[i][k]: checking i's digits and the number of mod k

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

    dp[0][0] = 1;
    for(int i = 0;i < s.size();i++) {
        int number = (s[i] != '?' ? s[i]-'0' : -1);
        for(int j = 0;j < 13;j++) {
            if(number != -1) {
                dp[i+1][(j*10+number) % 13] += dp[i][j];
                dp[i+1][(j*10+number) % 13] %= MOD;
            } else {
                for(int k = 0;k < 10;k++) {
                    dp[i+1][(j*10+k) % 13] += dp[i][j];
                    dp[i+1][(j*10+k) % 13] %= MOD;
                }
            }
        }
    }

    cout<<dp[s.size()][5]<<endl;

    return 0;
}






Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

void solve(int w,int h) {
    int n;
    cin >> n;
    
    vector<pair<int,int> > x,y;

    for(int i=0; i<n; ++i) {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        x.push_back(make_pair(a,i));
        x.push_back(make_pair(c,i));
        y.push_back(make_pair(b,i));
        y.push_back(make_pair(d,i));
    }

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());

    int prev=0;
    int rnkx=0;
    bool lc;
    if(x[2*n-1].first==w) lc=true;
    else lc=false;
    for(int i=0; i<2*n; ++i) {
        if(prev!=x[i].first) rnkx+=2;
        prev=x[i].first; x[i].first=rnkx;
    }
    if(!lc) rnkx+=2;

    prev=0;
    int rnky=0;
    if(y[2*n-1].first==h) lc=true;
    else lc=false;
    for(int i=0; i<2*n; ++i) {
        if(prev!=y[i].first) rnky+=2;
        prev=y[i].first; y[i].first=rnky;
    }
    if(!lc) rnky+=2;

    sort(x.begin(),x.end(),[](pair<int,int>& lhs, pair<int,int>& rhs) {
        return (lhs.second==rhs.second?lhs.first<rhs.first:lhs.second<rhs.second);
    });
    sort(y.begin(),y.end(),[](pair<int,int>& lhs, pair<int,int>& rhs) {
        return (lhs.second==rhs.second?lhs.first<rhs.first:lhs.second<rhs.second);
    });

    vector<vector<int> > mp;
    vector<int> vtemp(rnkx+1,0);
    for(int i=0; i<rnky+1; ++i) mp.push_back(vtemp);

    for(int i=0; i<n; ++i) {
        for(int j=y[2*i].first; j<=y[2*i+1].first; ++j) {
            for(int k=x[2*i].first; k<=x[2*i+1].first; ++k) {
                mp[j][k]=-1;
            }
        }
    }

    int col=0;
    int dx[4]={0,1,0,-1};
    int dy[4]={1,0,-1,0};
    queue<pair<int,int> > q;
    for(int i=0; i<rnky+1; ++i) {
        for(int j=0; j<rnkx+1; ++j) {
            if(mp[i][j]!=0) continue;
            mp[i][j]=++col;
            q.push(make_pair(i,j));
            while(!q.empty()) {
                pair<int,int> p=q.front(); q.pop();
                int pj=p.second;
                int pi=p.first;
                for(int k=0; k<4; ++k) {
                    if(pi+dy[k]>=0 && pi+dy[k]<rnky+1 && pj+dx[k]>=0 && pj+dx[k]<rnkx+1
                        && mp[pi+dy[k]][pj+dx[k]]==0) {
                            mp[pi+dy[k]][pj+dx[k]]=mp[pi][pj];
                            q.push(make_pair(pi+dy[k],pj+dx[k]));
                    }
                }
            }
        }
    }
    cout << col << endl;

    return;
}


int main() {
    int w,h;
    while(true) {
        cin >> w >> h;
        if(w==0 && h==0) break;
        solve(w,h);
    }
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  bool ans = false;
  if(S[0] == S[1] && S[2] == S[3]) ans = true;
  if(S[0] == S[2] && S[1] == S[3]) ans = true;
  if(S[0] == S[3] && S[1] == S[2]) ans = true;
  if(S[0] == S[1] && S[1] == S[2]) ans = false;
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  int a,b;
  cin>>a>>b;
  int x1=ceil(a/0.08);
  int x2=ceil(b/0.1);
  int x=max(x1,x2);
  if(floor(x*0.08)==a && floor(x*0.1)==b)
  {
    cout<<x<<endl;
  }
  else
    cout<<-1<<endl;

  return 0;
}

Measured memory_bytes: 3624
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int A, B;
std::string S,T;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> S>>T;
    in >> A >> B;
    std::string C;
    in >> C;

    out << A - (S == C ? 1 : 0) << ' ' << B - (T == C ? 1 : 0) << endl;;

    return 0;
}
#endif


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M) vector<vector<L>> K(N, vector<L>(M))
#define mod 1000000007
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main(){
  lli B,C,D,E,F,N,M,K,sum=0,num=0,ans=0;
  cin >> N;
  Vec(A,lli,N,0);Vec(P,lli,N,0);
  rep(i,0,N)cin >> A[i];
  P[0]=A[0];
  rep(i,1,N){
    P[i]=P[i-1]+A[i];
    if(P[i]==0){
      if(P[i-1]>0)P[i]--;
      else P[i]++;
      sum++;
    }
    else if(P[i]>0&&P[i-1]>0||P[i]<0&&P[i-1]<0){
      if(P[i]>0){
        sum+=P[i]+1;
        P[i]=-1;
      }else{
        sum+=-P[i]+1;
        P[i]=1;
      }
    }
  }
    P[0]=1;
    num+=labs(A[0]-1);
  rep(i,1,N){
    P[i]=P[i-1]+A[i];
    if(P[i]==0){
      if(P[i-1]>0)P[i]--;
      else P[i]++;
      num++;
    }
    else if(P[i]>0&&P[i-1]>0||P[i]<0&&P[i-1]<0){
      if(P[i]>0){
        num+=P[i]+1;
        P[i]=-1;
      }else{
        num+=-P[i]+1;
        P[i]=1;
      }
    }
  }
  P[0]=-1;
  ans+=labs(A[0]+1);
  rep(i,1,N){
    P[i]=P[i-1]+A[i];
    if(P[i]==0){
      if(P[i-1]>0)P[i]--;
      else P[i]++;
      ans++;
    }
    else if(P[i]>0&&P[i-1]>0||P[i]<0&&P[i-1]<0){
      if(P[i]>0){
        ans+=P[i]+1;
        P[i]=-1;
      }else{
        ans+=-P[i]+1;
        P[i]=1;
      }
    }
  }
  Out(min(sum,min(ans,num)));
}

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

const int MAXN = 2e5 + 6.66;
const int Max = 20;
int arr[MAXN];
int bits[Max][MAXN];

bool ok(int l, int r) {
  for(int i = 0; i < Max; i++)
    if(bits[i][r] - (l > 0 ? bits[i][l - 1] : 0) > 1) return false;
  return true;
}

int main() {
  int N; scanf("%d", &N);
  for(int i = 0; i < N; i++) scanf("%d", arr + i);
  for(int i = 0; i < Max; i++)
    bits[i][0] = (arr[0] >> i) & 1;
  for(int i = 1; i < N; i++) 
    for(int j = 0; j < Max; j++)
      bits[j][i] = bits[j][i - 1] + ((arr[i] >> j) & 1);
  int l = 0;
  long long ans = 1;
  for(int i = 1; i < N; i++) {
    while(l < i && !ok(l, i)) l++;
    ans += i - l + 1;
  }
  cout << ans << endl;
  return 0;
}


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


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

  rep(bit,1<<3){

    // rep(i,3) cout << (bit>>i & 1);
    // cout << endl;
    int sum = stoi(a.substr(0,1));
    rep(i,3){
      if(bit>>i & 1){
        sum += stoi(a.substr(i+1,1)); 
      } else {
        sum -= stoi(a.substr(i+1,1));
      }
    }
    // cout << sum << endl;
    if(sum == 7) {
      cout << a.substr(0,1);
      rep(i,3){
        if(bit>> i & 1) {
          cout << '+' << stoi(a.substr(i+1,1));
        } else {
          cout << '-' << stoi(a.substr(i+1,1));
        }
      }
      cout << "=7" << endl;
      break;
    }
  }
  return 0;
}

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

int main(){
  char s[110], t[110];
  scanf("%s %s", s, t);

  int table[30] = {0}, slen = strlen(s), tlen = strlen(t);
  for(int i=0; i<slen; i++)
    table[(int)s[i]-(int)'a']++;
  
  int now = 0;
  for(int i=0; i<=(int)'z'-(int)'a'; i++){
    while(table[i]){
      s[now++] = (char)(i+(int)'a');
      table[i]--;
    }    
  }

  for(int i=0; i<tlen-1; i++)
    for(int j=i+1; j<tlen; j++)
      if((int)t[i] < (int)t[j]){
	char c = t[i];
	t[i] = t[j];
	t[j] = c;
      }

  printf("%s\n", strcmp(s, t)<0 ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 1656
#include <stdio.h>
void countdataset(int n, int x);
int main(void) {
	int n, x;
	while (scanf("%d %d", &n, &x) == 2) {
		if (n == 0 && x == 0) break;
		countdataset(n, x);
	}
	return 0;
}
void countdataset(int n, int x) {
	int i, ii, iii, count = 0;
	for (i = 1; i <= n - 2; i ++) for (ii = i + 1; ii <= n - 1; ii ++) for (iii = ii + 1; iii <= n; iii ++) if (i + ii + iii == x) count ++;
	printf("%d\n", count);
}

Measured memory_bytes: 600
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	ll n;
	cin >> n;
	bool cd[4][13] = {0};
	REP(i,n){
		char c;
		ll a;
		cin >> c >> a;
		if(c == 'S'){
			cd[0][a-1]=true;
		}
		if(c == 'H'){
			cd[1][a-1]=true;
		}
		if(c == 'C'){
			cd[2][a-1]=true;
		}
		if(c == 'D'){
			cd[3][a-1]=true;
		}
	}
	REP(i,4){
		REP(j,13){
			//cout << "debag;" << cd[i][j] << endl;
			//cout << endl;
			if(!(cd[i][j])){
				if(i==0){cout << "S " << j+1 << endl;}
				if(i==1){cout << "H " << j+1 << endl;}
				if(i==2){cout << "C " << j+1 << endl;}
				if(i==3){cout << "D " << j+1 << endl;}
			}
		}
	}
	
  return 0;
}


Measured memory_bytes: 3120
from functools import lru_cache, reduce


@lru_cache(maxsize=None)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def sub():
    N, As = [input() for _ in range(2)]
    N = int(N)
    As = [int(e) for e in As.split(" ")]
    # As = sorted(As, reverse=True)

    memG = 0
    # if N == 2:
    # memG = gcd(As[0], As[1])
    if N < 3:
        for i in range(N):
            tmp = As[:i] + As[i + 1 :]
            g = reduce(gcd, tmp)
            if g > memG:
                memG = g
    else:
        gLeft = {0: As[0], 1: gcd(As[0], As[1])}
        for i in range(2, N):
            gI = gcd(gLeft[i - 1], As[i])
            gLeft[i] = gI
        gRight = {N - 1: As[N - 1], N - 2: gcd(As[N - 1], As[N - 2])}
        for i in range(2, N):
            gI = gcd(gRight[N - i], As[N - 1 - i])
            gRight[N - 1 - i] = gI

        buf = []
        for i in range(N):
            leftG = None
            if (i - 1) in gLeft:
                leftG = gLeft[i - 1]
            rightG = None
            if (i + 1) in gRight:
                rightG = gRight[i + 1]
            # tmpG = None
            if leftG is None:
                leftG = rightG
            elif rightG is None:
                rightG = leftG
            buf.append(gcd(leftG, rightG))
            # tmpG = gcd(leftG, rightG)
            # if tmpG > memG:
            #     memG = tmpG
        memG = max(buf)

    print("{}".format(memG))


sub()


Measured memory_bytes: 32276
def code(name,k):
    ret = name[0]
    for c1,c2 in zip(name,name[1:]):
        if len(ret) >= k: break
        if c1 in 'aiueo':
            ret += c2
    return ret

while True:
    N = int(input())
    if N == 0: break
    src = [input() for i in range(N)]
    maxl = max(map(len,src))
    for k in range(1,maxl+1):
        st = set()
        for s in src:
            cd = code(s,k)
            if cd in st:
                break
            st.add(cd)
        else:
            print(k)
            break
    else:
        print(-1)

Measured memory_bytes: 5624
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>

using namespace std;

long long mod = 1000000007;

long long pow(long long x, long long k)
{
    if (k == 0)
    {
        return 1LL;
    }
    long long temp = pow(x, k / 2);
    if (k % 2 == 1)
    {
        return (((temp * temp) % mod) * x) % mod;
    }
    else
    {
        return (temp * temp) % mod;
    }
}

long long modular_inverse(long long x)
{
    return pow(x, mod - 2);
}

long long binomial(long long n, long long k)
{
    long long rez = 1;
    for (int i = n - k + 1; i <= n; i++)
    {
        rez *= i;
        rez %= mod;
    }
    long long temp = 1;
    for (int i = 1; i <= k; i++)
    {
        temp *= i;
        temp %= mod;
    }
    rez *= modular_inverse(temp);
    rez %= mod;
    return rez;
}

int main()
{
    int n, r;
    cin >> n >> r;
    if (n >= 10)
    {
        cout << r << '\n';
    }
    else
    {
        cout << r + 100 * (10 - n) << '\n';
    }
    return 0;
}


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

//(i,j)の周囲8マスの爆弾の個数を返す
int num_of_bombs(int i, int j, int H, int W, vector<vector<char>> field){
  int a, b, c, d;

  //調査範囲決定（もっと美しく書きたい）
  if(i - 1 < 0)
    a = 0;
  else
    a = i - 1;
  if(i + 1 == H)
    b = H - 1;
  else
    b = i + 1;
  if(j - 1 < 0)
    c = 0;
  else
    c = j - 1;
  if(j + 1 == W)
    d = W - 1;
  else
    d = j + 1;
 // cout << "a: " << a << "b: " << b << "c: " << c << "d: " << d << endl;
  
  //爆弾を数える
  int counter = 0;
  
  for (int i = a; i <= b; i++)
  {
    for (int j = c; j <= d; j++)
    {
      if(field.at(i).at(j) == '#')
        counter++;
    } 
  }
  return counter;
}

int main(){
  // 入力
  int H, W;
  cin >> H >> W;
  vector<vector<char>> field(H, vector<char>(W));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> field.at(i).at(j);
    }
  }

  //空白マスのチェック, 数字の出力
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++)
    {
      if (field.at(i).at(j) == '.')
      {
        cout << num_of_bombs(i, j, H, W, field);
      }
      else
        cout << field.at(i).at(j);
      
    }
    cout << endl;
    
  }
}

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

#define MAX 100
#define INF INT_MAX
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int col[MAX];
int M[MAX][MAX];
int d[MAX];
int p[MAX];

void init(int n) {
	for (int i = 0; i < n; i++) {
		col[i] = WHITE;
		for (int j = 0; j < n; j++)
			M[i][j] = INF;
		d[i] = INF;
	}
}

void input() {
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v, c;
			cin >> v >> c;
			M[i][v] = c;
		}
	}
}

void dijkstra(int s) {
	d[s] = 0;
	p[s] = -1;
	while (true) {
		int minc = INF;
		int u;
		for (int i = 0; i < n; i++) {
			if (col[i] != BLACK && d[i] < minc) {
				minc = d[i];
				u = i;
			}
		}
		if (minc == INF) break;
		col[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (col[v] != BLACK && M[u][v] != INF) {
				if (d[u] + M[u][v] < d[v]) {
					d[v] = d[u] + M[u][v];
					p[v] = u;
					col[v] = GRAY;
				}
			}
		}
	}
}

void output() {
	for (int u = 0; u < n; u++)
		cout << u << " " << d[u] << endl;
}

int main() {
	cin >> n;
	init(n);
	input();
	dijkstra(0);
	output();
	return 0;
}



Measured memory_bytes: 3120
N = int(input())
taro,hanako = 0,0
for n in range(N):
    taro_str,hanako_str = input().split(' ')
    if taro_str == hanako_str:
        taro += 1
        hanako += 1
    if taro_str > hanako_str:
        taro += 3
    if hanako_str > taro_str:
        hanako += 3
print(taro,hanako)


Measured memory_bytes: 5600
from bisect import bisect_left

n = int(input())
l = sorted(list(map(int, input().split())))

#aを1番短い辺、bを2番めに短い辺とする
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        c_i = bisect_left(l, l[i] + l[j])
        cnt += c_i - (j+1)

print(cnt)

Measured memory_bytes: 3188
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/multiprecision/cpp_int.hpp>
// ↓これいる？
#include <boost/graph/strong_components.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
using namespace boost::multiprecision;
using ll = long long;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto&& i : v) cin >> i; }

//#include "atcoder.hpp"

int main() {
    int N;
    
    cin >> N;
  
  vector<ll> A(N);
  fill(A);
    
  REP(i, N-1)
    A[i+1] += A[i];
  
  auto ithalf = bst::lower_bound(A, A[N-1] / 2LL);
  
  long long r = min(abs(*ithalf * 2LL - A[N-1]), abs(A[N-1] - *(ithalf - 1LL) * 2LL));
    cout << r << endl;
    
    return 0;
}







Measured memory_bytes: 1792
n=int(input())
l=list(map(int,input().split()))
import collections
c=collections.Counter(l)
ans=n
eve=0
c=sorted(c.values(),reverse=True)
for i in c:
    if(i==1):
        break
    if(i%2==0):
        eve+=1
        ans-=i-2
    else:
        ans-=i-1
print(ans+2*(-eve//2))

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

int main() {
	
	int n;
	
	std::cin >> n;
	
	while(n-->0) {
		int a[3] = { 0, 0, 0};
		int point = 0;
		int out = 0;
		std::string commands = "";
		while(1) {
			std::cin >> commands;

			// HIT
			if( commands == "HIT") {
				if( a[2] == 1) point ++;
				a[2] = a[1];
				a[1] = a[0];
				a[0] = 1;
			}

			// OUT
			if( commands == "OUT") out ++;

			// HOMERUN
			if( commands == "HOMERUN") {
			for( int j=0; j<3; j++)
				if( a[j] == 1) {
					point ++;
					a[j] = 0;
				}
				point ++;
			}

			if(out==3) break;
		}
		
		std::cout << point << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

VI V[100005];
int col[100005];
int n, m;

LL solve(int at) {
	LL ans = 0;
	int ok = 1;
	LL cnt[2];
	cnt[0] = cnt[1] = 0;
		queue<int> Q;
		Q.push(at);
		col[at] = 0;
		cnt[0]++;
		while (!Q.empty()) {
			int u = Q.front();
			Q.pop();

			for (int v : V[u]) {
				if (col[v] == -1) {
					col[v] = 1 ^ col[u];
					Q.push(v);
					cnt[col[v]]++;
				}
				else {
					if (col[v] == (1 ^ col[u]));
					else ok = 0;
				}
			}
		}

		if (ok) {
			ans = cnt[0] * cnt[1];
		}
		else {
			LL n = cnt[0] + cnt[1];
			ans = n * (n - 1) / 2;
		}
		return ans;
}

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		V[u].push_back(v);
		V[v].push_back(u);
	}

	for (int i = 1; i <= n; i++) col[i] = -1;

	LL ans = 0;
	for (int i = 1; i <= n; i++) {
		if (col[i] != -1) continue;
		ans += solve(i);
	}

	ans -= m;
	printf("%lld\n", ans);
	return 0;
}


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

const int MAX = 100000;

int m,a,b;

bool prime[MAX];
vector<int>primes;

void make(){
	for(int i = 0 ; i < MAX ; i++)prime[i] = true;
	prime[0] = prime[1] = false;
	for(int i = 2 ; i < MAX ; i++){
		if(!prime[i])continue;
		primes.push_back(i);
		for(int j = i+i ; j < MAX ; j+=i){
			 prime[j] = false;
		}
	}
}


int main(){
	make();
	while(cin>>m>>a>>b,m){
		int maxi,resa,resb;
		maxi = resa = resb = -1;
		
		for(int i = 0 ;i < primes.size() ; i++){
			if(primes[i] > m)break;
			for(int j = 0 ; j < primes.size() ; j++){
		 		if(primes[i]*primes[j] > m)break;
		 		if((double)primes[i]/primes[j] >= (double)a/b && (double)primes[i]/primes[j] <= 1.0){
					if(maxi < primes[i]*primes[j]){
				 		maxi = primes[i]*primes[j];
						 resa = primes[i];
						 resb = primes[j];
					 }
				 }
			}
		}
		
		
		cout << resa << ' ' << resb << endl;
	}
	
	return 0;
}


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

int main()
{
        ll h;
        cin>>h;
        ll c=0;
        if(h!=1)
        {
            while(h/2>0)
            {
                c++;
                h=h/2;
            }
            c=pow(2,c+1)-1;
            printf("%lld",c);
        }
        else
        {
            cout<<1;
        }
}


Measured memory_bytes: 256
/**
 *   created: 28 April 2019  23:46:46
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
// #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
vector< vi > adj;
vl val;
vi vis;

ll dfs(int node,ll x){
	vis[node]=1;
	if(val[node]>=0)
		x = min(x,val[node]);
	for(int t : adj[node]){
		if(!vis[t])
			x = dfs(t,x);
	}
	return x;
}
int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		int r,d,x;
		cin>>r>>d>>x;
		rep(i,0,10){
			x = r*x - d;
			cout<<x<<endl;
		}
	}
	return 0;
}





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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define pii					pair<int, int>
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;

int main() {_
	int k,n;
	cin >> k >> n;

	vector<int> v(n),d(n);

	for(int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	ll minn = 0;
	ll sum = 0;
	
	for(int i = 1; i < n; ++i) {
		d[i] = v[i] -v[i-1];
		sum += d[i];
		if(minn < d[i]) minn = d[i];
	}

	if(v[0] == 0) d[0] = k - v[n-1];
	else d[0] = k - v[n-1] + v[0];
	sum += d[0];

	//for(int i = 0; i < n; ++i) cout << d[i] << " ";
	//cout << "\n";
	if(minn < d[0]) minn = d[0];

	cout << k - minn << "\n";
	
 
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N = 400005;
int n, c[400005];
int x[400005], y[400005], deg[400005], g[400005];
int cnt, first[N];
struct edge {int to, nxt, id;} e[400005];
void ins(int u, int v, int id)
{
    e[++cnt]=(edge){v, first[u], id};
    first[u] = cnt;
} 
void dfs(int u, int fa, int col) 
{
    int now=0;
    for(int i=first[u];i!=0;i=e[i].nxt)
	{
		
		//cout<<i<<" ";
        int v = e[i].to;
        //cout<<"now="<<now<<"col="<<col<<"v="<<v<<"u="<<u<<"\n";
        if(v == fa) continue;
        now++;
        if(now == col) ++now;
        g[e[i].id] = now;
        //cout<<"now="<<now<<"col="<<col<<"v="<<v<<"u="<<u;
        dfs(v, u, now);
    }
    //cout<<"\n";
}
int main() 
{
    cin >> n;
    for(int i = 1; i < n; ++i)
	{
        cin >> x[i] >> y[i];
        deg[x[i]]++; deg[y[i]]++;
        ins(x[i], y[i], i), ins(y[i], x[i], i);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) 
        if(deg[i] > deg[ans]) ans = i;
    cout<<deg[ans]<<"\n";
    dfs(ans,ans,0);
    for(int i=1;i<n;i++)
		cout<<g[i]<<"\n";
} 

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

#define ld long double
#define ll long long int
#define ull unsigned long long int

using namespace std;

int main() {

    int S;
//    string S;
    cin >> S;

    int a = S /100;
    int b = S % 100;

//    cout <<a<<endl;cout<<b<<endl;


    bool ay = false;
    bool am = false;
    bool by = false;
    bool bm = false;



    if (a > 0 && a <=12 ){
        ay = true;
        am = true;
    }
    else if (a >= 0){
        ay = true;
    }

    if (b > 0 && b <=12 ){
        by = true;
        bm = true;
    }
    else if (b >=0){
        by = true;
    }

    string ans;
    if (ay && by && am && bm){
        ans = "AMBIGUOUS";

    }

    else if (am && by){
        ans = "MMYY";

    }

    else if (ay && bm){
        ans = "YYMM";

    }

    else{
        ans = "NA";
    }


    cout << ans << endl;

}

Measured memory_bytes: 256
import sys
import itertools

n, m, x = map(int, input().split())
a = []
c = []
for _ in range(n):
    lst = list(map(int, input().split()))
    c.append(lst[0])
    a.append(lst[1:])
ans = 1000 * 1000 * 1000 * 100
for i in itertools.product('01', repeat=n):
    cur = 0
    algs = [0] * m
    for j in range(len(i)):
        if i[j] == '1':
            cur += c[j]
            for k in range(len(a[j])):
                algs[k] += a[j][k]
    for p in algs:
        if p < x:
            break
    else:
        ans = min(ans, cur)

if ans == 1000 * 1000 * 1000 * 100:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9088
n,x,y=map(int,input().split())
a=x-1 #Xより左側
b=y-x-1 #XとYの間
c=n-y #Yより右側

print(n)

for i in range(2,n):
    ans=0
    if i<a+c+2: #aとc(X,Yもカウント)
        ans+=a+c+2-i
    if i<(b+2)//2+a+1 and a>0: #aとb
        if i-1<=a:
            ans+=min(i-1,(b+2)//2)*2-1
        else:
            ans+=min((b+2)//2+a-i+1,a)*2
        if i>(b+2)//2 and b%2==0:
            ans-=1
    if i<(b+2)//2+c+1 and c>0: #bとc
        if i-1<=c:
            ans+=min(i-1,(b+2)//2)*2-1
        else:
            ans+=min((b+2)//2+c-i+1,c)*2
        if i>(b+2)//2 and b%2==0:
            ans-=1
    if i<=(b+2)//2: #bとb(X,Yもカウント)
        if i==(b+2)/2:
            ans+=(b+2)//2
        else:
            ans+=b+2
    print(ans)

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

int N,K;

int main(){
  cin >> N >> K;
  int number = 1;
  for(int i=1; i<N+1; i++){
    if(number*2 > number + K)
      number += K;
    else
      number *= 2;
   
  }
   cout << number << endl; 

}

Measured memory_bytes: 256
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int k,n,i;
		cin>>n>>k;
		VI64 v(k);
		for(auto &x:v)
			cin>>x;
		int ans=abs(v[k-1]-v[0]);
		for(i=1;i<k;i++)
		{
			int tem=v[k-1]-v[i];
			tem+=n-v[k-1];
			tem+=v[i-1];
			ans=min(ans,tem);
		}
		cout<<ans;

	}

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>

using namespace std;

int gcd(int a, int b){
    int ans, tmp;
    if(b > a){
        tmp = a;
        a = b;
        b = tmp;
    }

    int r;
    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


int main(){
    int N;
    int tmp;
    cin >> N;
    vector<int> A(N);

     for(int i=0; i<N; i++){
        cin >> A[i];
     }

    tmp = A[0];
    int ans;
    for(int i=1; i<N; i++){
        ans = gcd(A[i], tmp);
        tmp = ans;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

using namespace std;

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

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    int w,a,b;
    cin >> w >> a >> b;
    if(b+w < a) cout << a-(b+w) << endl;
    else if(a+w < b) cout << b-(a+w) << endl;
    else cout << 0 << endl;  
    return 0;
}

Measured memory_bytes: 256
def g_c_d(x, y):
    if y == 0:
        return x
    elif x == 0:
        return y
    else:
        return g_c_d(y, x % y)


def l_c_m(x, y):
    return x * y // g_c_d(x, y)


a = int(input())
b = 1
for i in range(a):
    c = int(input())
    b = l_c_m(b, c)
print(b)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <math.h> 

using namespace std;



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

	long long n, m, i, j, k, maxx, minn, ans, x, y, a, b, c;

	cin >> n >> m;
	vector<long long> ss(3);

	if ((n % 3 == 0) || (m % 3 == 0)) ans = 0;
	else ans = min(n, m);

	a = m / 2;
	b = m - a;
	for (i = 1; i < n; i++) {
		ss[0] = i * m;
		ss[1] = a * (n - i);
		ss[2] = b * (n - i);
		sort(ss.begin(), ss.end());
		ans = min(ans, ss[2] - ss[0]);
	}

	a = n / 2;
	b = n - a;
	for (i = 1; i < m; i++) {
		ss[0] = i * n;
		ss[1] = a * (m - i);
		ss[2] = b * (m - i);
		sort(ss.begin(), ss.end());
		ans = min(ans, ss[2] - ss[0]);
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
string Moji(int n,string s){
  if(n>s.size()) return s;
  string result;
  for(int i=0;i<n;i++){
    result+=s.at(i);
  }
  return result;
}

bool Can_Delete(){
  
}

int main() {
  //dream,dreamer,erase,eraser
  vector<string> a={"maerd","remaerd","esare","resare"};
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  
  while(s.size()>=5){
    if(Moji(6,s)==a.at(3)){     
      s.erase(s.begin(),s.begin()+6);
      continue;
    }else if(Moji(7,s)==a.at(1)){
      s.erase(s.begin(),s.begin()+7);
      continue;
    }else if(Moji(5,s)==a.at(2)){
      s.erase(s.begin(),s.begin()+5);
      continue;
    }else if(Moji(5,s)==a.at(0)){
      s.erase(s.begin(),s.begin()+5);
      continue;
    }else{
      break;
    }
  }
  
  if(s.size()==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 512
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
A=list(map(int, input().split()))
L = 1
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans = ans + L//a

MOD = 1000000007
print(int(ans)%MOD)


Measured memory_bytes: 4084
#include<iostream>

using namespace std;

int main() {
  int n;cin >> n;
  int a = 0;
  for(int i = 0; i < n ; i++) {
    int x; cin >> x;
    a ^= x;
  }
  if (a == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long x = Long.parseLong(in.next());
            long tmp = 100;
            int ans = 0;

            while (true) {
                if (tmp >= x) break;
                tmp = tmp + (long) (tmp * 0.01);
                ans++;
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 35812
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int h,w;
    cin >> h >> w;
    int x,y;
    for(int i = 0;i < h * w;i++)
    {
        string s;
        cin >> s;
        if(s == "snuke")
        {
            x = i % w;
            y = i / w;
        }
    }
    cout << char('A' + x) << y + 1 << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100002],i,j;
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for (i=1;i<=n;i++)
		if (i+1>a[i+1]) break;
	for (j=i+1;j<=n && a[j]==i;j++);
	puts((a[i]-i&1)|!(j-i&1)?"First":"Second");
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

const LL mod = 1e9 + 7;

LL n, k;
char s[1000005];
LL p25[1000005], p26[1000005];

LL pow2(LL a, LL b) {
    LL ans = 1;
    while(b > 0) {
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

class Inverse{
    public:
        vector<LL> inv;
        int sz;
    Inverse(int _sz = 0){
        sz = max(1, _sz);
        inv = vector<LL>(sz + 1);
        inv[1] = 1;
        for(int i = 2; i <= sz; i++) {
            inv[i] = inv[mod % i] * (mod - mod / i) % mod;
        }
    }
    LL get(LL x) {
        if(x <= sz) return inv[x];
        else return pow2(x, mod - 2);
    }
};


int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  p25[0] = p26[0] = 1;
  for (int i = 1; i <= 1000000; i++) {
    p25[i] = p25[i - 1] * 25 % mod;
    p26[i] = p26[i - 1] * 26 % mod;
  }

  Inverse inv(1000000);

  cin >> k;
  scanf("%s", s);
  n = strlen(s);
  k += n;

  LL c = 1, ans = 0;
  for (int i = n; i <= k; i++) {
    ans += c * p25[i - n] % mod * p26[k - i] % mod;
    ans %= mod;
    c = c * i % mod * inv.get(i - n + 1) % mod;
  }
  cout << ans << endl;


#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 27848