akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	string s;
	string t;

	cin >> s;
	cin >> t;


	SINT32 buf2 = 0;
	for (SINT32 i = s.length()-t.length(); i >= 0; i--) {
//	rep(i,0,s.length()-t.length()+1) {
		SINT32 buf = 0;
		rep(j,0,t.length()) {
			if ((s[i+j] == t[j]) || (s[i+j] == '?')) {

			} else {
				buf = 1;
				break;
			}
		}
		if (buf == 0) {
			rep(j,0,t.length()) {
				s[i+j] = t[j];
			}
			rep(j,0,s.length()) {
				if (s[j] == '?') {
					s[j] = 'a';
				}
			}
			buf2 = 1;
			break;
		}
	}
	if (buf2 == 0) {
		cout << "UNRESTORABLE" << endl;
	} else {
		cout << s << endl;
	}

	
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll D;
    cin>>D;
    vll c(27);
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    vector<vll> s(D+1,vll(27));
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
    ll score=0;
    vi last_day(27,0);
    for(int i=1;i<=D;i++){
        int t;cin>>t;
        score+=s[i][t];
        last_day[t]=i;
        for(int j=1;j<=26;j++){
            score-=c[j]*(i-last_day[j]);
        }
        cout<<score<<endl;
    }

}

Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int T = sc.nextInt();
        int[] t = new int[n];
        for (int i = 0 ; i < n ; i++) {
            t[i] = sc.nextInt();
        }
        long x = 0;
        for (int i = 0 ; i < n - 1 ; i++) {
            x += Math.min((long) T, (long) (t[i + 1] - t [i]));
        }
        x += (long) T;
        System.out.println(x);
    }

}

Measured memory_bytes: 64328
N=int(input())
S=[]
T=[]
for i in range(N):
    s,t=map(str,input().split())
    S.append(s)
    T.append(int(t))
X=input()

f=S.index(X)
ans=0
if f==N-1:
    print(0)
else:
    for i in range(f+1,N):
        ans+=T[i]
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

int main(){
  ll n; cin >> n;
  ll a[n], sum = 0;
  REP(i, n){
    cin >> a[i];
    sum += a[i];
  }

  if(2*sum % (n*(n+1)) != 0){
    cout << "NO" << endl;
    return 0;
  }

  ll k = 2*sum / (n*(n+1)), d, dd = 0;
  REP(i, n){
    d = a[(i+1)%n] - a[i] - k;
    if(d > 0 || d%n){
      cout << "NO" << endl;
      return 0;
    }
    dd += d;
  }

  if(dd + n*k == 0)
    cout << "YES" << endl;
  else 
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 50010, M = 1000010;
int n, m, q, id[N][3][3], mod, cnt, uni[N * 6], g, v;

int fa4[M];
int getfa4(int pos) {
  return pos == fa4[pos] ? pos : fa4[pos] = getfa4(fa4[pos]);
}
bool chk(int x,int y) {
  return getfa4(x) == getfa4(y);
}
void init4() {
  rep (i, 0, mod-1) fa4[i] = i;
  rep (i, 0, mod-1) {
    int j = 4 * i % mod;
    if (!chk(i, j)) {
      fa4[getfa4(i)] = getfa4(j);
    }
  }
}

struct data {
  int x,y,z;
  bool operator < (const data& a) const {
    return z < a.z;
  }
} edg[N];
int getfa(int pos) {
  return pos == uni[pos] ? pos : uni[pos] = getfa(uni[pos]);
}
void merge(int x,int y) {
  if (getfa(x) != getfa(y)) {
    x = getfa(x), y = getfa(y);
    uni[x] = y;
  }
}
int main() {
  read(n), read(m), read(q), read(mod);
  rep (i, 1, m)
    read(edg[i].x), read(edg[i].y), read(edg[i].z);
  if (m == 1) g = edg[1].z;
  else {
    sort(edg + 1, edg + m + 1);
    g = edg[2].z - edg[1].z;
    rep (i, 2, m-1) g = __gcd(g, edg[i+1].z - edg[i].z);
  }
  g = __gcd(g, mod);
  mod = __gcd(3 * g, mod);
  init4();
  v = edg[1].z % g;
  rep (i, 1, m) edg[i].z -= v, edg[i].z = (edg[i].z % mod) / g;
  rep (i, 1, n) rep (a, 1, 2) rep (b, 0, 2)
    id[i][a][b] = ++ cnt;
  rep (i, 1, cnt) uni[i] = i;
  rep (i, 1, m) {
    int x = edg[i].x, y = edg[i].y;
    rep (a, 1, 2) rep (b, 0, 2) {
      merge(id[x][a][b], id[y][a == 2 ? 1 : 2][(2 * b + edg[i].z) % 3]);
    }
    rep (a, 1, 2) rep (b, 0, 2) {
      merge(id[y][a][b], id[x][a == 2 ? 1 : 2][(2 * b + edg[i].z) % 3]);
    }
  }
  rep (i, 1, q) {
    int x,y,z,a,b;
    read(x), read(y), read(z);
    a = z + v, b = v;
    // (x, a) -> (y, b)
    int key = 0;
    rep (ta, 1, 2) rep (tb, 0, 2) {
      if (getfa(id[y][1][0]) == getfa(id[x][ta][tb])) {
	if (chk((ta * b + tb * g) % mod, a % mod))
	  key = 1;
      }
    }
    if (key) puts("YES");
    else puts("NO");
  }
  return 0;
}


Measured memory_bytes: 7808
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int res;
  string s;
  cin >> s;
  if(s=="SUN") res=7;
  if(s=="MON") res=6;
  if(s=="TUE") res=5;
  if(s=="WED") res=4;
  if(s=="THU") res=3;
  if(s=="FRI") res=2;
  if(s=="SAT") res=1;
  cout << res << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll(x);cin >> (x);
#define stin(x) str(x);cin >> (x);
#define vllin(x,n) vll(x)(n);FOR(i,0,n-1){cin >> (x)[i];}
#define vllin2(a,b,n) vll(a)(n);vll(b)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vllin3(a,b,c,n) vll(a)(n);vll(b)(n);vll(c)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >> (x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vpl4in(x,n) vpl4(x)((n),mp(0,0));FOR(i,0,n-1){cin >> x[i].fi >> x[i].se;}
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rFOR(i,b,a) for(ll i=a;i>=b;i--)
#define SORT(x) sort(x.be,x.en)
#define rSORT(x) sort(x.rbegin(),x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll MOD = 1000000007;

signed main()
{
    llin(n);
    llin(q);
    vllin3(s,t,x,n);
    vector<pair<ll,pair<ll,ll>>> y(n*2);
    FOR(i,0,n-1){
        y[i*2].fi=s[i]-x[i];
        y[i*2+1].fi=t[i]-x[i];
        y[i*2].se.fi=1;
        y[i*2+1].se.fi=-1;
        y[i*2].se.se=y[i*2+1].se.se=x[i];
    }
    SORT(y);
    ll c=0;
    vllin(d,q);
    set<ll> z;
    FOR(i,0,2*n-1){
        while(y[i].fi>d[c]){
            if(z.sz==0){
                sal(-1)
            }else{
                sal(*z.begin())
            }
            c++;
            if(c==q) return 0;
        }
        if(y[i].se.fi==1){
            z.insert(y[i].se.se);
        }else{
            z.erase(y[i].se.se);
        }
    }
    while(c<q){
        sal(-1)
        c++;
    }
}

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

int main()
{
    int n;
    cin >> n;
    int l[n];
    for(int i=0;i<n;++i){
        cin >> l[i];
    }
    int count=0;
    sort(l,l+n,greater<int>());
    for(int i=0;i<n-2;++i){
        if(l[i]<l[i+1]+l[i+2]){
            for(int j=i+1;j<n-1;++j){
                for(int k=j+1;k<n;++k){
                    if(l[i]<l[j]+l[k])
                        count++;
                    else
                        break;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n;
    std::cin >> n;

    int min = 1e5;
    for (int i = 1; i <= n - 1; ++i)
    {
        int other = n - i;

        int tempone = i, temptwo = other;
        int sum = 0;
        while (tempone > 0)
        {
            sum += tempone % 10;
            tempone /= 10;
        }

        while (temptwo > 0)
        {
            sum += temptwo % 10;
            temptwo /= 10;
        }

        if (sum < min)
            min = sum;
    }

    std::cout << min;
}


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

int n,dp[20010];
pair<pair<int,int>,pair<int,int> > a[1010];  

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		int w,s,v;
		cin>>w>>s>>v;
		a[i]=make_pair(make_pair(w+s,w),make_pair(s,v));
	}
	sort(a+1,a+n+1); 
	for(int i=1;i<=n;i++){
		for(int j=a[i].second.first;j>=0;j--){
			dp[j+a[i].first.second]=max(dp[j+a[i].first.second],dp[j]+a[i].second.second);
		}
	}
	int maxv=0;
	for(int j=0;j<=20000;j++) maxv=max(maxv,dp[j]);
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 512
S=list(input())
S1=S[0]+S[1]
S2=S[2]+S[3]
if 13>int(S1)>0:
  if 13>int(S2)>0:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 13>int(S2)>0:
    print("YYMM")
  else:
    print("NA")

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

using namespace std;

typedef long long LL;

LL f[100005], rf[100005];
const int mod = 1e9+7;

LL poww(LL a, LL b){
	LL ret = 1;
	while(b){
		if(b%2) ret = (ret*a)%mod;
		a = (a*a)%mod; 
		b/=2;
	}
	return ret;
}

int mask[100005];

LL ncr(int a, int b){
	if(a < b) return 0;

	LL ret = 0;
	ret = (((f[a]*(rf[b]))%mod)*rf[a-b])%mod;
	return ret;
}

int main(){
	f[0] = 1;
	rf[0] = 1;
	for(int i=1;i<=100001;i++) f[i] = (f[i-1]*i)%mod, rf[i] = poww(f[i], mod-2);

	int n;
	scanf("%d", &n);

	int dist = 0;
	for(int i=1;i<=n+1;i++){
		int a;
		scanf("%d", &a);
		if(mask[a] == 0) mask[a] = i;
		else dist = i-mask[a]+1;
	}

	for(int i=1;i<=n+1;i++){
		printf("%lld\n", (ncr(n+1, i) - ncr(n+1-dist, i-1) + mod)%mod);
	}
}

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

int main() {
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  bool same = false;
  for (int i=0; i<S.size()-1; i++) {
    if (S.at(i)==S.at(i+1)) {
      same = true;
      break;
    }
  }
  if (!same) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef int fuko[yuzu|10];
fuko a;
int cmp(int u,int v){
return abs(u-*a/2)>abs(v-*a/2);
}
int main() {
int i,n=read();
for (i=1;i<=n;++i) a[i]=read();
sort(a+1,a+n+1),*a=a[n]; 
sort(a+1,a+n,cmp);
printf("%d %d",a[n],a[n-1]);
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)


int main()
{
    int n; cin >> n;
    string s = to_string(n);

    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

      return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ld = double;
int n;
ld dp[305][305][305];

ld memo_rec(int One, int Two, int Three){
    if(dp[One][Two][Three] != -1)   return dp[One][Two][Three];
    if(One + Two + Three == 0)  return dp[One][Two][Three] = 0.0;
    
    ld res = n;
    if(One > 0) res += memo_rec(One - 1, Two, Three) * One;
    if(Two > 0) res += memo_rec(One + 1, Two - 1, Three) * Two;
    if(Three > 0)   res += memo_rec(One, Two + 1, Three - 1) * Three;
    res *= 1.0 / (One + Two + Three);

    return dp[One][Two][Three] = res;
}

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

    cin >> n;
    vector<int> cnt(4, 0);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        ++cnt[a];
    }
    
    for(int i = 0; i <= 300; ++i){
        for(int j = 0; j <= 300; ++j){
            for(int k = 0; k <= 300; ++k){
                dp[i][j][k] = -1;
            }
        }
    }

    cout << fixed << setprecision(15);
    cout << memo_rec(cnt[1], cnt[2], cnt[3]) << endl;
}

Measured memory_bytes: 219392
// AtCoder Grand Contest 017
// A - Biscuits

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;


int N, P;

int main() {

    int a;
    ll ans[2];

    cin >> N >> P;
    ans[0] = 1;
    ans[1] = 0;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a % 2 == 0) {
            ans[0] += ans[0];
            ans[1] += ans[1];
        } else {
            ll pre_ans_0 = ans[0];
            ans[0] += ans[1];
            ans[1] += pre_ans_0;
        }
    }

    cout << ans[P % 2] << endl;

    return 0;

}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;

int main(){
	char s[200005];
	scanf("%s", s);
	for(int i = 0; s[i] !='\0'; i++){
		if(s[i] == '?') printf("%c", 'D');
		else printf("%c", s[i]);
	}


}

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

int main() {
  int n;
  cin>>n;
  char a[n];
  int r=0,b=0,g=0;
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    a[i]=c;
    if(c=='R')r++;
    if(c=='B')b++;
    if(c=='G')g++;
  }
  long long k=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(a[i]!=a[j]&&2*j-i<n){
        if(a[2*j-i]!=a[i]&&a[2*j-i]!=a[j])k++;
      }
    }
  }
  cout<<1LL*r*b*g-k<<endl;
}


Measured memory_bytes: 3628
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"4 3 6"# => "safe",
// r#"6 5 1"# => "delicious",
// r#"3 7 12"# => "dangerous",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i64,
        b: i64,
    }

    if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
        "Possible"
    } else {
        "Impossible"
    }.to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  ll N; 
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  vector<ll> d(N, 0);
  d[0] = a[0];
  for (int i = 1; i < N; i++) {
    d[i] += d[i - 1] + a[i];
  }
  
  ll res = 1e18;
  int l = 0, r = 2;
  for (int i = 2; i <= N - 2; i++) {
    while (abs(d[i - 1] - d[l]*2) >= abs(d[i - 1] - d[l + 1]*2)) {
      if (l + 1 >= i - 1) break;
      l++;
    }
    ll P = d[l];
    ll Q = d[i - 1] - d[l];
    
    if (r < i) r = i;
    while (abs(d[N - 1] - 2*d[r] + d[i - 1]) >= abs(d[N - 1] - 2*d[r + 1] + d[i - 1])) {
      if (r + 1 >= N - 1) break;
      r++;
    }
    ll R = d[r] - d[i - 1];
    ll S = d[N - 1] - d[r];
    
    ll max_num = max(P, max(Q, max(R, S)));
    ll min_num = min(P, min(Q, min(R, S)));
    res = min(res, abs(max_num- min_num));
  }
  
  cout << res << endl;
  // int n;
  // cin >> n;
  // vector<ll> a(n), x(n+1, 0);
  // for (auto &v : a) cin >> v;
  // for (int i = 0; i < n; i++) x[i+1] += x[i]+a[i];
  // ll res = 1e18, l, r;
  // ll P, Q, R, S;
  // for (int i = 2; i < n-1; i++) {
  //   l = 1;
  //   r = i+1;
  //   // for (int j = 1; j < i; j++) {
  //   //   mi = abs((x[i]-x[j])-x[j]);
  //   //   l = j;
  //   //   if (j+1 < i && mi < abs((x[i]-x[j+1])-x[j+1])) break;
  //   // }
  //   // for (int j = i+1; j < n; j++) {
  //   //   mi = abs((x[n]-x[j])-(x[j]-x[i]));
  //   //   r = j;
  //   //   if (j+1 < n && mi < abs((x[n]-x[j+1])-(x[j+1]-x[i]))) break;
  //   // }
  //   while (abs(x[i]-x[l]*2) >= abs(x[i]-x[l+1]*2)) {
  //     if (l+1 >= i) break;
  //     l++;
  //   }
  //   while (abs(x[n]-x[r]*2+x[i]) >= abs(x[n]-x[r+1]*2+x[i])) {
  //     if (r+1 >= n) break;
  //     r++;
  //   }
  //   P = x[l];
  //   Q = x[i]-x[l];
  //   R = x[r]-x[i];
  //   S = x[n]-x[r];
  //   ll tmp = max(P, max(Q, max(R, S)))-min(P, min(Q, min(R, S)));
  //   if (res > tmp) res = tmp;
  // }
  // dump(res);
  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<(n);i++)
using namespace std;
char x[200000],y[200000];
signed main(){
	int a,b,c,d;
	string s;
	cin>>a>>b>>s;
	c=-1,d=a;
	f(i,b){
		cin>>x[i]>>y[i];
	}
	for(int i=b-1;i>=0;i--){
		if(x[i]==s[c+1]&&y[i]=='L')c++;
		if(x[i]==s[d-1]&&y[i]=='R')d--;
		if(x[i]==s[c]&&y[i]=='R')c--;
		if(x[i]==s[d]&&y[i]=='L')d++;
	}
	cout<<max((int)(0),d-c-1)<<endl;
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = (int) 1e8 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << ", ";
#define endln cerr << "\n";
#define chkpt cerr << "-----\n";

const int maxn = 1e5 + 5;
int n, a, b;
int x[maxn];

void solve() {
    cin >> n >> a >> b;
    FOR(i, 0, n) cin >> x[i];
    long long lo = 0, hi = 2 * LINF / b;
    while (lo < hi) {
        long long mi = lo + hi >> 1;
        long long tot = 0;
        FOR(i, 0, n) {
            if (x[i] > (long long) mi * b) {
                tot += (x[i] - (long long) mi * b + a - b - 1) / (a - b);
            }
        }
        if (tot > mi) {
            lo = mi + 1;
        }
        else {
            hi = mi;
        }
    }
    cout << (lo + hi >> 1) << "\n";
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-9;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	int n;
	cin >> n;
	ll res = 0;
	for (int i = 1; i < n; i++) {
		res += (n / i) ;
		if (n % i == 0) res--;
	}
	cout << res << "\n";


	return 0;
}

Measured memory_bytes: 3640
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        if k >= 0 and 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int A, B;
	cin >> A >> B;

	cout << max(0, A - 2 * B);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];   // 重み付き有向グラフの隣接リスト表現

void dijkstra()
{
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    int d[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;

    while (!PQ.empty()) {
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;

        color[u] = BLACK;

        // 最小値を取り出し、それが最短でなければ無視
        if (d[u] < f.first * (-1)) continue;

        for (int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first;
            if (color[v] == BLACK) continue;
            if (d[v] > d[u] + adj[u][j].second) {
                d[v] = d[u] + adj[u][j].second;
                PQ.push(make_pair(d[v] * (-1), v));  // priority_queue はデフォルトで大きい値を優先するため -1 を掛ける
                color[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main()
{
    int k, u, v, c;
    int i, j;

    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> u >> k;
        for (j = 0; j < k; j++) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 8008
#include <stdio.h>
#include <stdlib.h>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define MOD 1000000007

SINT64 combination(SINT64 a, SINT64 b);
SINT64 modpow(SINT64 base, SINT64 exp);

SINT32 main() {
    SINT32 n,m;
    scanf("%d%d",&n,&m);
    SINT64 ans = 1;
    SINT32 m_nokori = m;

    for (UINT64 i = 2; i*i <= m_nokori; i++) {

        if ((m_nokori % i) == 0) {
            SINT32 count = 0;
            while ((m_nokori % i) == 0) {
                count++;
                m_nokori = m_nokori / i;
            }
            ans = ans * combination(n+count-1, n-1);
            ans = ans % MOD;
        }
    }

    if (m_nokori != 1) {
        ans = ans * combination(n+1-1, n-1);
        ans = ans % MOD;       
    }


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

//組み合わせ
SINT64 combination(SINT64 a, SINT64 b) {
    SINT64 bunshi = 1;
    SINT64 bunbo = 1;

    for (SINT32 i = 0; i < b; i++) {
        bunshi = (bunshi * (a - i)) % MOD;
        bunbo  = (bunbo  * (i + 1)) % MOD;
    }

    return bunshi * modpow(bunbo, MOD-2) % MOD; //逆元
}

//べき乗
SINT64 modpow(SINT64 base, SINT64 exp) {
    SINT64 half;
  
    if (exp == 0) {
        return 1;
    } else {
        if ((exp % 2) == 0) {
            //偶数
            half = modpow(base, exp/2);
            return ((half*half) % MOD);
        } else {
            //奇数
            return (base * modpow(base, exp-1) % MOD);
        }
    }
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

string S;

int main() {
  cin >> S;

  ll ans = 0;
  for (int bit = 0; bit < (1 << (S.size() - 1)); ++bit) {
    ll sum = 0;
    ll keta = 1;
    sum += S[0] - '0';
    for (int i = 0; i < S.size() - 1; ++i) {
      int next = S[i + 1] - '0';
      if (bit & (1 << i)) {
        ans += sum;
        keta = 1;
        sum = next;
      } else {
        sum *= 10;
        sum += next;
      }
    }
    ans += sum;
  }
  cout << ans;
}


Measured memory_bytes: 3540
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        String str = in.s();
        for (int i = 0; i < 4; i++) {
            char[] ans = new char[N];
            int s = i;
            for (int j = 0; j < N; j++) {
                int f0 = s / 2;
                int f1 = s % 2;
                int f2 = f0 ^ (str.charAt(j) == 'o' ? 0 : 1);
                ans[(j+1) % N] = f2 == 0 ? 'S' : 'W'; 
                s = ((f1 ^ f2) << 1) | f2;
            }
            if (i == s) {
                out.println(ans);
                return;
            }
        }
        out.println(-1);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 25428
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d;
    t = 0;
    while(1) {
        if(t % 2 == 0)
            c -= b;
        else
            a -= d;
        if(a <= 0 || c <= 0)
            break;
        t++;
    }

    if(t % 2 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
string str;
bool flag=false;
void dfs(int pointer){
  if(pointer==str.size()){
    flag=true;
    return;
  }
  if(str.substr(pointer,5)=="dream"){
    dfs(pointer+5);
  }
  if(str.substr(pointer,5)=="erase"){
    dfs(pointer+5);
  }
  if(str.substr(pointer,7)=="dreamer"){
    dfs(pointer+7);
  }
  if(str.substr(pointer,6)=="eraser"){
    dfs(pointer+6);
  }
}
int main(){
  cin>>str;
  dfs(0);
  if(flag)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) a[i] = sc.nextInt();
        int[] b = new int[n];
        for(int i = n-1; i >= 0; i--)
            if((n - i) % 2 == 1) b[(n - i - 1) / 2]= a[i];
            else b[(n + i) / 2] = a[i];
        for(int i = 0; i < n; i++) System.out.print(b[i] + " ");
    }
}

Measured memory_bytes: 95776
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    inf = int(1e9)
    N = ri()
    S = rs()
    dp = [[inf] * N for i in range(2)]
    # forbidden : '#.'
    if S[0] == '.':
        dp[0][0] = 0
        dp[1][0] = 1
    else:
        dp[0][0] = 1
        dp[1][0] = 0
    for i in range(1, N):
        if S[i] == '.':
            dp[0][i] = min(dp[0][i], dp[0][i-1])
            dp[1][i] = min(dp[1][i], dp[0][i-1] + 1)
            dp[1][i] = min(dp[1][i], dp[1][i-1] + 1)
        else :
            dp[0][i] = min(dp[0][i], dp[0][i-1] + 1)
            dp[1][i] = min(dp[1][i], dp[0][i-1])
            dp[1][i] = min(dp[1][i], dp[1][i-1])
    print(min(dp[0][N-1], dp[1][N-1]))



if __name__ == "__main__":
    main()


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

using  ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
constexpr ll kINF = 1152921504606846976;//2^60
constexpr double kEPS = 1e-6;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

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

int K;

int next (int n, int mod) {
  if (n % mod == mod - 1) {
    return n + mod;
  }
  return n + mod - 1 - (n % mod);
}

int S(int m) {
  int ret = 0;
  while(m > 0) {
    ret += m % 10;
    m /= 10;
  }
  return ret;
}

void solve() {
  int mod = 1;
  int n = 1;
  while(K > 0) {
    if (S(n) * mod >= n) {
      K--;
      cout << n << endl;
    } else {
      mod *= 10;
    }
    n = next(n, mod);
  }
}
signed main(void) {
  cin >> K;
  solve();
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

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

    int N;
    std::cin >> N;

    auto f = [](int n) -> int {
                 int cnt = 0;
                 while(0 < n) {
                     n /= 10;
                     cnt++;
                 }
                 return cnt;
             };

    int num_of_digit = f(N);

    ll ans = 0;
    for(int i = 1; i <= num_of_digit; i++) {
        if(i % 2 == 0) continue;
        else if(i == num_of_digit) {
            ans += N - pow(10, i - 1) + 1;
        }
        else {
            ans += pow(10, i) - pow(10, i - 1);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

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

  vector<vector<int>> s(M);
  rep(i, M) {
    int k; cin >> k;
    rep(j,k){
      int tmp; cin >> tmp; tmp--;
      s[i].push_back(tmp);
    }
  }
  int p[M]; rep(i,M) cin >> p[i];

  int result = 0;
  rep(i, 1<<N) {
    bool ok = true;
    rep(j, M) {
      int num = 0;
      for (auto x: s[j]) if (i & (1<<x)) num++;
      if (num%2!=p[j]) ok = false;
    }
    if (ok) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
       public static void main(String[] args){
              int nui[] = new int[10];
              Scanner docaonui = new Scanner(System.in);
              for (int i = 0; i < 10; i++){
            	  nui[i] = docaonui.nextInt();
              }
              Arrays.sort(nui);
              System.out.println(nui[9]);
              System.out.println(nui[8]);
              System.out.println(nui[7]);        
       }
}

Measured memory_bytes: 26360
#include <stdio.h>

int		main()
{
	int		A1, A2, A3;

	scanf("%d %d %d\n", &A1, &A2, &A3);
	if (A1 + A2 + A3 >= 22)
		printf("bust\n");
	else
		printf("win\n");
	return (0);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n;
	
	while (scanf("%d", &n) * n != 0){
		while (n-- > 0){
			int pm, pe, pj;
			int ave;
			
			scanf("%d %d %d", &pm, &pe, &pj);
			ave = (pm + pe + pj) / 3;
			if (pm == 100 || pe == 100 || pj == 100){
				puts("A");
			}
			else if ((pm + pe) / 2 >= 90){
				puts("A");
			}
			else if (ave >= 80){
				puts("A");
			}
			else if (ave >= 70){
				puts("B");
			}
			else if (ave >= 50 && (pm >= 80 || pe >= 80)){
				puts("B");
			}
			else {
				puts("C");
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 580
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 c = sc.nextInt();
  int x = b/a;
  if(x <= c){
    System.out.println(x);
  }else if(x>c){
    System.out.println(c);
  }
 }
}

Measured memory_bytes: 23124
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

struct rect { int ly, ry, lx, rx; };

int T, H, W;
char S[55][55];

int main(void) {
  cin >> T;
  while(T--) {
    cin >> H >> W;
    REP(i, 0, H) cin >> S[i];

    set<char> st;
    REP(i, 0, H) REP(j, 0, W) if(S[i][j] != '.') st.insert(S[i][j]);
    map<char, int> ctoi;
    int t = 0;
    for(char i : st) ctoi[i] = t++;

    int a[10];
    REP(i, 0, 10) a[i] = i;

    map<char, rect> p;
    REP(i, 0, H) REP(j, 0, W) if(S[i][j] != '.') p[S[i][j]] = (rect) { i, i, j, j };
    REP(i, 0, H) REP(j, 0, W) {
      if(S[i][j] != '.') {
        p[S[i][j]].ly = min(p[S[i][j]].ly, i);
        p[S[i][j]].ry = max(p[S[i][j]].ry, i);
        p[S[i][j]].lx = min(p[S[i][j]].lx, j);
        p[S[i][j]].rx = max(p[S[i][j]].rx, j);
      }
    }

    bool ans = false;
    do {
      bool f = true;
      for(auto r : p) {
        char c = r.first;
        rect q = r.second;
        REP(i, q.ly, q.ry + 1) REP(j, q.lx, q.rx + 1) {
          if(S[i][j] == '.' || a[ctoi[c]] < a[ctoi[S[i][j]]]) {
            f = false;
            goto END;
          }
        }
      }
END:
      ans = ans || f;
      if(ans) break;
    } while(next_permutation(a, a + (int) st.size()));
    cout << (ans ? "SAFE" : "SUSPICIOUS") << endl;
  }
  return 0;
}

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


int main(void){
  int N;
  cin >> N;
  int a = 0;
  int max_num = 0, min_num = 0;

  for(int i=0; i<N; i++){
    int num;
    cin >> num;
    if(i == 0){
      a = num;
    }
    
    int x = max(a, num);
    int y = min(a, num);

    if(max_num < x) max_num = x;
    if(min_num > y || min_num == 0) min_num = y;

    a = num;
  }

  cout << max_num - min_num << endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N;
    cin >> N;
    ll X = digsum(N);
    if (N%X == 0) cout << "Yes\n";
    else cout << "No\n";
}


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

int a[N],n,num;
ll ans=0;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i),a[i]-=i;
	sort(a+1,a+n+1),num=a[(n+1)>>1];
	for(int i=1;i<=n;i++) ans+=(ll)abs(num-a[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N): 
    t, x, y = map(int, input().split()) 
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2: 
        count += 1 
    T, X, Y = t, x, y
print("Yes" if count == N else "No")

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n; cin >> n;
    ll ans = 0;
    FOR(q,1,(int)sqrt(n)+1) if (n%q == 0) {
        ll m = n/q;
        if (m-1 > q) ans += m-1;
    }
    cout << ans << '\n';
}


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

int main() {
	string s;
	cin >> s;
	int c;
	c = 0;
	if (s[0] == 'o') {
		c += 1;
	}
	if (s[1] == 'o') {
		c += 1;
	}
	if (s[2] == 'o') {
		c += 1;
	}
	cout << 700 + c * 100 << endl;
	return 0;
	system("pause");
}

Measured memory_bytes: 256