akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(){ string str[1000]; string s; int size = 0; while(getline(cin,s)){ if(s == "END_OF_TEXT") break; str[size++] = s; } char ch; string buf = ""; int line = 0, pos = 0; while(cin >> ch){ if(ch == '-') break; if(ch == 'a') pos = 0; if(ch == 'e') pos = str[line].size(); if(ch == 'p'){ pos = 0; if(line!=0) line--; } if(ch == 'n'){ pos = 0; if(line+1!=size) line++; } if(ch == 'f'){ if(pos != str[line].size()) pos++; else if(line+1!=size) { pos = 0; line++; } } if(ch == 'b'){ if(pos != 0) pos--; else if(line!=0) { line--; pos = str[line].size(); } } if(ch == 'd'){ if(pos != str[line].size()){ str[line] = str[line].substr(0,pos) + str[line].substr(pos+1); } else if(line+1!=size){ str[line] = str[line] + str[line+1]; for(int i=line+1;i+1<size;i++){ str[i] = str[i+1]; } str[size-1] = ""; size--; } } if(ch == 'k'){ if(pos == str[line].size() && line+1!=size){ str[line] = str[line] + str[line+1]; for(int i=line+1;i+1<size;i++){ str[i] = str[i+1]; } str[size-1] = ""; size--; buf = "IS_BREAK_LINE"; } else if(pos < str[line].size()){ buf = str[line].substr(pos); str[line] = str[line].substr(0,pos); } } if(ch == 'y'){ if(buf == "IS_BREAK_LINE"){ for(int i=size-1;i>=line+1;i--){ str[i+1] = str[i]; } size++; str[line+1] = str[line].substr(pos); str[line] = str[line].substr(0,pos); line++; pos = 0; } else if(buf != ""){ str[line] = str[line].substr(0,pos) + buf + str[line].substr(pos); pos += buf.size(); } } /* cout << line << " " << pos << endl; for(int i=0;i<size;i++){ cout << str[i] << endl; } puts(""); */ } for(int i=0;i<size;i++){ cout << str[i] << endl; } }

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

enum {
	MIN = 1000,
	MAX = 2000,
};

struct node {
	int val; // -1->min, -2->max
	node *l = 0, *r = 0;

	node() {}
	node(int val) : val(val) {}
};

node *mn = new node(-9999);
node *mx = new node(-9999);

node *create_min() {
	node *x = new node(MIN);
	x->l = mn;
	x->r = mn;
	return x;
}

node *create_max() {
	node *x = new node(MAX);
	x->l = mx;
	x->r = mx;
	return x;
}

typedef pair<int, int> P;

P pmin(P a, P b) {
	return make_pair(min(a.first, b.first), min(a.second, b.second));
}

P pmax(P a, P b) {
	return make_pair(max(a.first, b.first), max(a.second, b.second));
}

pair<int, int> eval(node *v) {
	if (v->val == MIN) {
		return pmin(eval(v->l), eval(v->r));
	} else if (v->val == MAX) {
		return pmax(eval(v->l), eval(v->r));
	} else {
		if (v->val == -9999) {
			return make_pair(0, 99);
		} else if (v->val < 0) {
			return make_pair(-v->val, -v->val * 10 + 9);
		} else {
			return make_pair(v->val, v->val);
		}
	}
}

int k;
string s;
node *rt;
pair<int, int> ans[1010];

void parse(node *v) {
	v->val = s[k] - '0';
	if (v->val == 0) {
		ans[k] = eval(rt);
		k++;
	} else {
		v->val *= -1;
		ans[k] = eval(rt);
		v->val *= -1;
		k++;

		if (isdigit(s[k])) {
			v->val = v->val * 10 + (s[k] - '0');
			ans[k] = eval(rt);
			k++;
		} else {
			ans[k] = eval(rt);
		}
	}
}

void dfs(node *v) {
	v->r = mn;
	if (isdigit(s[k])) {
		v->l = new node(0);
		parse(v->l);
		k++;
	} else {
		if (s[k] == '_') {
			v->l = create_min();
		} else {
			v->l = create_max();
		}
		k += 2;
		dfs(v->l);
	}
	if (isdigit(s[k])) {
		v->r = new node(0);
		parse(v->r);
		k++;
	} else {
		if (s[k] == '_') {
			v->r = create_min();
		} else {
			v->r = create_max();
		}
		k += 2;
		dfs(v->r);
	}
	k++;
}

void solve() {
	for (int i = 0; i < 1010; i++) {
		ans[i] = make_pair(-1, -1);
	}
	cin >> s;

	if (isdigit(s[0])) {
		if (s[0] == '0') {
			cout << s.substr(0, s.size() - 1) << " " << 1 << endl;
		} else {
			cout << s.substr(0, s.size() - 1) << " " << 2 << endl;
		}
		return;
	}

	node *v;
	if (s[0] == '_') {
		v = create_min();
	} else if (s[0] == '^') {
		v = create_max();
	}
	rt = v;

	k = 2;
	dfs(v);

	for (int i = 0; i < s.size(); i++) {
		if (ans[i].first == ans[i].second && ans[i].first >= 0) {
			cout << ans[i].first << " " << i + 1 << endl;
			return;
		}
	}
}

int main() {
	int Q;
	cin >> Q;
	while (Q--) solve();
}

Measured memory_bytes: 2432
#include<stdio.h>

int main(){

  int n,x,flag,cnt=0;
  int i,j;

  scanf("%d",&n);

  int A[n];

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

  for(i=0;i<n-1;i++){
    flag = 1;
    while(flag){
      flag = 0;
      for(j=n-1;j>=i;j--){
	if(A[j]<A[j-1]){
	  x = A[j];
	  A[j] = A[j-1];
	  A[j-1] = x;
	  flag=1;
	  cnt++;
	}
      }
    }
  }

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",cnt);
  
  return 0;
}



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

int C(ll x,ll y,ll z)
{
    if(x!=y)
    {
        if(x!=z)
        {
            if(z!=y) return 6;
            else return 3;
        }
        else
            return 3;
    }
    else
    {
        if(x!=z) return 3;
        else return 1;
    }

}
int main ()
{
    int n;
    cin>>n;
    int x=sqrt(n);
    int a[n+10],t=0;
    memset(a,0,sizeof(a));
    for(int i=1;i<=x;i++)
        for(int j=i;j<=x;j++)
            for(int k=j;k<=x;k++)
            {
                t=i*i+j*j+k*k+i*j+i*k+j*k;
                if(t<=n) a[t]+=C(i,j,k);
            }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<endl;
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    vec.push_back(0);
    vector<pair<int,int> > sequence(0);
    int count = 1;
    rep(i,N){
        if (vec[i] == vec[i + 1]){
            count++;
        }
        else{
            sequence.push_back(pair<int,int>(vec[i],count));
            count = 1;
        }
    }
    int ans = 0;
    int len_seq = sequence.size();
    rep(i,len_seq){
        if (sequence[i].first > sequence[i].second){
            ans += sequence[i].second;
        }
        else{
            ans += sequence[i].second - sequence[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
ans = 0
for i in range(60):
    mask = 1 << i
    count = sum(1 for j in a if mask & j == 0)
    ans += count * (n-count) * pow(2,i,mod)
print(ans % mod)

Measured memory_bytes: 42156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    // 手前からできるだけ小さくしたい
    a[0]--;
    rep3(i, 1, n) {
        if (a[i] < a[i - 1]) { out("No"); return 0; }
        if (a[i] > a[i - 1]) a[i]--;
    }
    out("Yes");
}



Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a, b;
  cin >> a >> b;
  if(b < a) a--;
  print(a);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int INT;
typedef unsigned long long LONG;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
const int mod = 998244353;
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define FW freopen("data2.txt", "w", stdout);
//快速读入输出，只适用于整数，使用时流同步打开，C语言不准关流
// getchar()<<cin(关流)<<scanf()<<cin
template <class T>
inline bool Read(T& ret)
{
    char c;
    int sgn;
    if (static_cast<void>(c = getchar()), c == EOF)
        return 0;
    while (c != '-' && (c < '0' || c > '9'))
        c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
        ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}
//输出只能用于整数
template <class T>
inline void Write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        Write(x / 10);
    putchar(x % 10 + '0');
}

LL dp[N * 2] = { 0 };
int lowbit(int x)
{
    return (x & -x);
}
void add(int x, int val)
{
    for (int i = x; i < 2 * N; i += lowbit(i)) {
        dp[i] = (dp[i] % mod + val) % mod;
    }
}
LL sum(int x)
{
    LL ans = 0;
    while (x) {
        ans = (ans % mod + dp[x]) % mod;
        x -= lowbit(x);
    }
    return ans % mod;
}

LL rang_sum(int l, int r)
{
    return (sum(r) - sum(l - 1)) + mod;
}
void slove(int question_num)
{
    int n, k;
    cin >> n >> k;
    unordered_map<int, int> num;
    for (int i = 1; i <= k; ++i) {
        int a, b;
        cin >> a >> b;
        num[a] = b;
    }
    add(1, 1);
    for (int i = 2; i <= n; ++i) {
        for (auto j : num) {
            int a = j.first, b = j.second;
            if (a >= i)
                continue;
            if (b >= i) {
                LL cur = rang_sum(1, i - a);
                add(i, cur);
            } else {
                LL cur = rang_sum(i - b, i - a);
                add(i, cur);
            }
        }
    }
    cout << (rang_sum(n, n) % mod) << endl;
}

int main()
{
    int num = 1;
    // cin >> num;
    for (int i = 1; i <= num; ++i) {
        slove(i);
    }
    // system("pause");
    return 0;
}

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

void call(int n) {
	int i = 1;
	for (int i = 1; i <= n; i++) {
		int x = i; if (x % 3 == 0) cout << " " << i;
		else while (x) { if (x % 10 == 3) { cout << " " << i; break; } x /= 10; }
	}
	cout << endl;
}

int main() {
	int n; cin >> n; call(n);
	return 0;
}


Measured memory_bytes: 3092
k = gets.to_i
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts arr[k - 1]

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int X,N,i,j;
    cin>>X>>N;
    if(N==0){
        cout<<X<<endl;
        return 0;
    }
    vector<int>p(N);
    for(i =0;i<N;i++){
        cin>>p[i];
    }

    //sort p from smallest to biggest
    for(i=0;i<N;i++){
        for(j=N-1;j>i;j--){
            if(p[j]<p[j-1])swap(p[j],p[j-1]);
        }
    }
    int gap = 100;
    int ans;
    j = 0;
    //find the num(not incleded in p)with the smallest gap with X
    for(i=-1;i<=(X+p[N-1]);i++){
        if(i == p[j]){
            j++;
            continue;
        }else{
            if(gap>abs(i-X)){
                gap = abs(i-X);
                ans = i;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

const int MN = 100010;
int n, MD;

struct ModInt {
    typedef ModInt M;
    int v;
    ModInt(int _v = 0) : v(_v) {}
    M& operator += (const M &r) {
        if ((v += r.v) >= MD) v -= MD;
        return *this;
    }
    M& operator *= (const M &r) {
        v = ll(v) * r.v % MD;
        return *this;
    }
    M operator + (const M &r) { return M(*this) += r; }
    M operator * (const M &r) { return M(*this) *= r; }
};
typedef ModInt Mint;

vector<int> g[MN];
Mint dp1[MN][2], dp2[MN][2];

void dfs1(int v, int p) {
    dp1[v][0] = dp1[v][1] = 1;
    for (int i = 0; i < int(g[v].size()); i++) {
        int u = g[v][i];
        if (u == p) continue;
        dfs1(u, v);
        dp1[v][0] *= dp1[u][0];
        dp1[v][1] *= (dp1[u][0] + dp1[u][1]);
    }
}

using T = array<Mint, 2>;
void dfs2(int v, int p) {
    if (p == -1) {
        dp2[v][0] = dp2[v][1] = 1;
    }
    
    vector<int> c;
    for (auto u : g[v]) {
        if (u == p) continue;
        c.push_back(u);
    }
    int cc = int(c.size());
    vector<T> pf(cc + 2), sf(cc + 2);

    pf[0] = {1, 1};
    for (int i = 0; i < cc; i++) {
        int u = c[i];
        pf[i+1] = pf[i];
        pf[i+1][0] *= dp1[u][0];
        pf[i+1][1] *= (dp1[u][0] + dp1[u][1]);
    }

    sf[cc+1] = {1, 1};
    for (int i = cc-1; i >= 0; i--) {
        int u = c[i];
        sf[i+1] = sf[i+2];
        sf[i+1][0] *= dp1[u][0];
        sf[i+1][1] *= (dp1[u][0] + dp1[u][1]);
    }

    for (int i = 0; i < cc; i++) {
        int u = c[i];
        dp2[u][0] = pf[i][0] * sf[i+2][0] * dp2[v][0];
        dp2[u][1] = dp2[u][0] + dp2[v][1] * pf[i][1] * sf[i+2][1];
        dfs2(u, v);
    }
}

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

    cin >> n >> MD;
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs1(0, -1);
    dfs2(0, -1);
    for (int i = 0; i < n; i++) {
        Mint ans = dp1[i][1] * dp2[i][1];
        cout << ans.v << "\n";
    }
    return 0;
}

Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Vl = V<ll>;
using Vd = V<ld>;
using VVi = V<Vi>;
using VVl = V<Vl>;
using VVd = V<Vd>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
// struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
// const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll h, w, m; cin >> h >> w >> m;
  
  Vi ci(h), cj(w);
  set<Pi> S;
  rep(i, m) {
    int x, y; cin >> x >> y;
    --x, --y;
    ++ci[x];
    ++cj[y];
    S.emplace(x, y);
  }

  int mi = 0, mj = 0;
  rep(i, h) chmax(mi, ci[i]);
  rep(i, w) chmax(mj, cj[i]);

  Vi vi, vj;
  rep(i, h) if (ci[i] == mi) vi.push_back(i);
  rep(i, w) if (cj[i] == mj) vj.push_back(i);
  
  for (auto i : vi) for (auto j : vj) {
    if (S.find({i, j}) == S.end()) {
      cout << (mi + mj) << '\n';
      return 0;
    }
  }
  cout << (mi + mj - 1) << '\n';
}


Measured memory_bytes: 23812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

int main() {
  long long n, k;
  cin >> n >> k;
  long long GCD;
  vector<long long> a(n);
  rep(i, n) {
    cin >> a[i];
    if(i == 0) GCD = a[i];
    else GCD = gcd(GCD, a[i]);
  }

  bool yes = false;

  rep(i, n) {
    if(a[i] == k) yes = true;
    else if(a[i] > k && (a[i] - k) % GCD == 0) yes = true;

    if(yes) break;
  }

  if(yes) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	vector<pair<string,int>>v(7);

	for(int i=0;i<7;i++){
		v.at(i).second=i;
		if(i==0)v.at(i).first="SUN";
		if(i==1)v.at(i).first="MON";
		if(i==2)v.at(i).first="TUE";
		if(i==3)v.at(i).first="WED";
		if(i==4)v.at(i).first="THU";
		if(i==5)v.at(i).first="FRI";
		if(i==6)v.at(i).first="SAT";
	}
	string s="";
	cin>>s;

	for(int i=0;i<7;i++){
		if(v.at(i).first==s){
			cout<<7-v.at(i).second<<endl;
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main(){

  int n;
  long double s[1000]={0},m,h;

  while(cin >>n,n){
    m=0;
    h=0;
    for(int i=0; i<n; i++){
      cin >>s[i];
      m+=s[i];
    }
    m/=n;

    for(int i=0; i<n; i++){
      h+=(s[i]-m)*(s[i]-m);
    }
    h=sqrt(h/n);
    printf("%.12Lf\n",h);
   

  }

  return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int t=0,k=s.length()-1;
	if(s[0]!='A'||(int(s[1])>64&&int(s[1])<91)||s[k]=='C') cout<<"WA";
	else
	{
		for(int i=2;i<k+1;i++)
		{
			if(t!=1&&s[i]=='C') t=1;
			else if(int(s[i])>64&&int(s[i])<91)
			{
				cout<<"WA";
				return 0;
			}
		}
		if(t==0) cout<<"WA";
		else cout<<"AC";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a;
  int b=0;
  int c[8],d[8];
  int h,l;
  while(true){
    b=0;
    cin>>a;
    if(a==0000){
      break;
    }
    while(true){
      if(a==6174){
	cout<<b<<"\n";
	break;
      }
      if(a==0){
	cout<<"NA\n";
	break;
      }
      for(int i=0;i<4;i++){
	c[i]=a%10;
	a=a/10;
	d[i]=c[i];
      }
      sort(c,c+4);
      sort(d,d+4,greater<int>());
      for(int i=0;i<4;i++){
	if(i==0){
	h=c[i]*1000;
	l=d[i]*1000;
	}
	if(i==1){
	   h=c[i]*100+h;
	   l=d[i]*100+l;
	}
	if(i==2){
	  h=c[i]*10+h;
	  l=d[i]*10+l;
	}
	if(i==3){
	  h=c[i]+h;
	  l=d[i]+l;
	}
      }
      a=l-h;
      b++;
    }
  }
  return(0);
}



Measured memory_bytes: 3164
n,k = list(map(int, input().split()))
a=list(map(int, input().split()))

ans=[]
for i in range(1<<n):
    
    if bin(i).count("1")==k:
        cst=0
        use=a.copy()
        for u in range(1,n):
            if(i>>u&1):
                left_max=max(use[:u])
                cst+=left_max-use[u]+1 if left_max>=use[u] else 0
                use[u]= max(left_max+1, use[u])
        ans.append(cst)
print(min(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    cin >> N;
    vector<int> A(N);
    int a = 1;
    ll sum = 0;
    REP(i,N){
        cin >> A[i];
        a *= ((A[i]>0) - (A[i]<0));
        A[i] = abs(A[i]);
        sum += A[i];
    }
    sort(ALL(A));
    if(a < 0){
        sum -= 2*A[0];
    }
    cout << sum <<"\n";
}

Measured memory_bytes: 640
import std.stdio, std.conv, std.string;

void main() {
	auto ip = readln.split.to!(int[]);
	if(ip[0] + ip[1] <= ip[1] + ip[2] && ip[0] + ip[1] <= ip[2] + ip[0]){
		writeln(ip[0] + ip[1]);
	} else if(ip[1] + ip[2] <= ip[0] + ip[1] && ip[1] + ip[2] <= ip[2] + ip[0]){
		writeln(ip[1] + ip[2]);
	} else {
		writeln(ip[2] + ip[0]);
	}
}

Measured memory_bytes: 256
def a_digit_sum_2(N):
    n_lead = int(str(N)[0])  # Nの先頭の数字
    n_later = str(N)[1:]  # Nの先頭以外の数字列
    n_length = len(str(N))  # Nの桁数
    if n_later == '9' * (n_length - 1):  # 先頭以外が9のみから構成された数だった
        ans = n_lead + 9 * (n_length - 1)  # c9...9の各桁をそのまま足す
    else:
        ans = (n_lead - 1) + 9 * (n_length - 1)  # 先頭は1減らさなければならない
    return ans 

N = int(input())
print(a_digit_sum_2(N))

Measured memory_bytes: 3060
/*
author: rootn
*/

#include<bits/stdc++.h>
using namespace std;

#define X first
#define Y second
#define pb push_back
#define mp make_pair

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    string s;cin >> s;
    string x = "";
    x += s[0];
    x += s[1];
    string y = "";
    y += s[2];
    y += s[3];
    int xx = stoi(x);
    int yy = stoi(y);
    bool mmyy = false, yymm = false;
    if(xx <= 12 && xx >= 1)
        mmyy = true;
    if(yy <= 12 && yy >= 1)
        yymm = true;
    if(mmyy && !yymm)
        cout << "MMYY\n";
    else if(yymm && !mmyy)
        cout << "YYMM\n";
    else if(yymm && mmyy)
        cout << "AMBIGUOUS\n";
    else
        cout << "NA\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int l[111];

int main()
{
    int n, x, d = 0, cnt = 1;
    cin>>n>>x;
    REP(i,n) {
        cin>>l[i];
    }
    REP(i,n) {
        d = d + l[i];
        if (d > x) {
            break;
        }
        cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


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

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()


/* Field */
using namespace std;


/* Function */

int main (void) 
{

  /* Variable_Proclamation */
  int A, B;   // input
  int C, D;   // input
  string ans; // output

  int left_dish, right_dish;


  /* Input, Initialize */
  cin >> A >> B;
  cin >> C >> D;


  /* Calculation */
  left_dish  = A + B;
  right_dish = C + D;

  if(left_dish > right_dish)
  {
    ans = "Left";
  }
  else if(left_dish < right_dish)
  {
    ans = "Right";
  }
  else if(left_dish == right_dish)
  {
    ans = "Balanced";
  }


  /* Output */
  cout << ans << endl;


  return 0;

}




Measured memory_bytes: 256
a,b,c,d = map(int, input().split())

taka = [a,b]
ao = [c,d]

judge = 0
while True:
    if judge == 0:
        ao[0] -= taka[1]
        judge = 1
        if ao[0] <= 0:
            print("Yes")
            break
    else:
        taka[0] -= ao[1]
        judge = 0
        if taka[0] <= 0:
            print("No")
            break
        


Measured memory_bytes: 9200
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

int A, P;

int main(int argc, char **argv) {
    std::cin >> A >> P;

    std::cout << (A * 3 + P) / 2 << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define inf 0xffffff
using namespace std;


int main()
{
    char a[15];
    while(~scanf("%s",a))
    {
        int len=strlen(a);
        if(a[0]!='A' ||  ( a[1]>='A' && a[1]<='Z') ||  ( a[len-1]>='A' && a[len-1]<='Z') )
        {
            printf("WA\n");
            continue;
        }
        int s1=0,s2=0;
        for(int i=2;i<len-1;i++)
        {
            if(a[i]>='A' &&a[i]<='Z')
            {
                s1++;
                if(a[i]=='C')
                    s2++;
            }

        }
        if(s1==1 && s2==1)
            printf("AC\n");
        else
            printf("WA\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S; cin >> S;
    int n = S.size();
    vi exist(26);

    string res = "yes";
    for(auto& e : S){
        if(exist[e - 'a']){
            res = "no";
        }
        exist[e - 'a'] = true;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

E = [0] * (N + 1)
W = [0] * (N + 1)
for i, s in enumerate(S):
    E[i + 1] = E[i] + (s == 'E')
    W[i + 1] = W[i] + (s == 'W')

ans = N
for i in range(1, N + 1):
    L = W[i - 1]
    R = E[N] - E[i]
    ans = min(ans, L + R)

print(ans)


Measured memory_bytes: 27128
from collections import defaultdict
s = input()
n, p = len(s), 2019

dd = defaultdict(int)
dd[0] = 1
prev = 0

for i in range(n-1, -1, -1):
    d = int(s[i]) * pow(10, n-i, p)
    prev = (prev + d) % p
    dd[prev] += 1

print(sum(v*(v-1)//2 for v in dd.values()))

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

using namespace std;

vector<string> w;

bool exist(const string &s) {
    for (auto word : w) {
        if (word == s)
            return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    for (int i=0; i<n; i++) {
        string s;
        cin >> s;

        if (i == 0) {
            w.push_back(s);
            continue;
        }

        string lw = w[w.size()-1];

        if (lw[lw.length()-1] == s[0] && !exist(s)) {
            w.push_back(s);
            continue;
        }
        else {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
long n,k,m,j,p,i,f[333][333][333];main(){scanf("%d%d%d",&n,&k,&m);for(f[i=0][1][0]=1;i<=n;++i)for(j=0;k/++j;)for(p=i;~p;--p)(f[i+1][j][p]+=f[i][j][p]*(p+1))%=m,((p?f[i][j][p-1]:f[i][j+1][i])+=f[i][j][p])%=m;printf("%d",f[n][k+1][n]);}


Measured memory_bytes: 262144
#include <iostream>

using namespace std;

int main(){
  int H,W;
  cin >> H >> W; 
  while(H!=0 || W!=0){
    for(int i=0;i<W;i++){
      cout << "#";
    }
    cout << endl;
    for(int j=1;j<H-1;j++){
      cout << "#";
      for(int k=1;k<W-1;k++){
	cout << ".";
      }
      cout << "#" << endl;
    }
    for(int i=0;i<W;i++){
      cout << "#";
    }
    cout << endl << endl;
    cin >> H >> W;  
  }
  return 0;
}



Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP((i),0,(n))
#define ALL(v) (v).begin(),(v).end()

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> x(200);
	rep(i, n)cin >> x.at(i);
	int sum = 0;
	rep(i, n) {
			sum += min(x.at(i) * 2, (k - x.at(i)) * 2);
		}
		cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[15][7];
  rep(i,15)rep(j,7)a[i][j]=7*(i+1)+j+1-7;
  ll ans=0;
  rep(i,11) {
    rep(j,5) {
      ll sum=0;
      rep(k,3)rep(l,3) sum+=a[i+k][j+l];
      if(sum%11==m) {
        ans+=n/11;
        if(i+2<n%11) ans++;
        if(i>=9&&(i+2)%11>=n%11) ans--;
      }
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> s = new ArrayList<String>();

        int[] counter = new int[26];
        for (int i = 0; i < 26; i++) {
            counter[i] = 0;
        }

        while (sc.hasNext()) {
            s.add(sc.nextLine().toLowerCase());
        }

        for (int j = 0; j < s.size(); j++) {
            for (int i = 0; i < s.get(j).length(); i++) {
                char c = s.get(j).charAt(i);
                if (c >= 97 && c <= 122) {
                    counter[c - 97]++;
                }
            }
        }

        for (int i = 0; i < 26; i++) {
            System.out.println((char) (i + 97) + " : " + counter[i]);
        }
        sc.close();
    }
}


Measured memory_bytes: 26176
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int a[1000000];

map<int, int> mp;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n) cin >> a[i];  
  REP(i, n) mp[a[i]]++;

  int mid = n/2;  
  if(n%2 == 0 && mp[1] != 2) {cout << "0" << endl; return 0;}
  if(n%2 == 1 && mp[0] != 1) {cout << "0" << endl; return 0;}
  
  ll ans = 1;  
  for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
    //cout << itr->first << " " << itr->second << endl;
    //ans = (itr->second%MOD) * (ans%MOD);
    ans = itr->second * ans % MOD;
  }

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


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

#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    vector<bool> vis(8, 0);
    int mn = 0, mx = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] / 400 > 7) {
            mx++;
            continue;
        }
        vis[a[i] / 400] = true;
        mn = 0;
        for (int j = 0; j < 8; j++) {
            mn += vis[j];
        }
        mx = mn;
    }
    if (mn == 0 && mx) mn = 1;
    cout << mn << ' ' << mx << '\n';
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int n;
string s;
vector<bool> a;

bool judge() {
  vector<bool> t;
  t.push_back(a[n - 1]);
  rep(i, n) t.push_back(a[i]);
  t.push_back(a[0]);
  
  rep(i, n) {
    auto ok = [&](bool left, bool right) {
      int c = s[i];
      bool animal = a[i];
      if(animal == false) {
        if (c == 'o') {
          if (left == right) return true;
        } else {
          if (left != right) return true;
        }
      } else {
        if(c == 'x') {
          if (left == right) return true;
        } else {
          if (left != right) return true;
        }
      }
      return false;
    };

    if(!ok(t[i], t[i + 2])) return false;
  }
  return true;
}


int main() {

  cin >> n >> s;

  auto ok = [&] {
    rep(start1, 2) {
      rep(start2, 2) {
        a = vector<bool>(n, 0); // falseのとき羊、trueの時オオカミ
        a[0] = bool(start1);
        a[1] = bool(start2);
        for (int i = 1; i < n; ++i) {
          if (i == n - 1) {
            if(judge()) return true;

          } else {
            if (a[i] == false) {
              if (s[i] == 'o') a[i + 1] = a[i - 1];
              else a[i + 1] = !a[i - 1];
            } else {
              if (s[i] == 'x') a[i + 1] = a[i - 1];
              else a[i + 1] = !a[i - 1];
            }
          }
        }
      }
   }
   return false;
  }();

  if(!ok) {
    cout << -1 << endl;
    return 0;
  }

  string ans;
  rep(i, n) {
    if(a[i] == false) ans += "S";
    else ans += "W";
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include<algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;

int main()
{
    ll N,res,i;
    cin >> N >> i;

    res = N -i + 1;

    cout << res << endl;

}



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

int main(){
    int A,B,C,X;
    cin >> A >> B >>C >>X;
    int res=0;
    for (int a=0;a<=A; ++a){
        for (int b=0;b<=B;++b){
            for(int c=0;c<=C;++c){
                int total=500*a+100*b+50*c;
                if (total==X)++res;

            }
        }
    }
    cout <<res <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  ll N; cin >> N;
  for (int k = 1; k <= N; ++k) {
    auto sum = k * (k + 1) / 2;
    if (sum < N) {
      continue;
    }
    auto d = sum - N;
    for (int i = 1; i <= k; ++i) {
      if (i != d) {
        cout << i << CRLF;
      }
    }
    return;
  }
  return;
}

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

  solve();

  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 FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    LL K;
    cin >> K;
    queue<LL> q;
    FOR(i, 1, 10) {
        q.push(i);
    }
    LL res = 0;
    REP(i, K) {
        res = q.front();
        q.pop();
        if(res%10 != 0) {
            q.push(res*10 + res%10 - 1);
        }
        q.push(res*10 + res%10);
        if(res%10 != 9) {
            q.push(res*10 + res%10 + 1);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#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() {

	SINT32 N = 0;
	SINT32 M = 0;

	cin >> N;
	cin >> M;

	

	cout << N-M+1 << 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);
*/

/*
//ワーシャルフロイド
vector<vector<SINT32>> dist(N,vector<SINT32>(N));
rep(i,0,N) {
	rep(j,0,N) {
		if (i != j) {
			dist[i][j] = INF;
		}
	}
}
rep(k,0,N) {
	rep(i,0,N) {
		rep(j,0,N) {
			dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]);
		}
	}
}
*/



/* 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);
	}
*/

/*
	//順列全表示
	//sortしてからでないと全列挙にならない
	sort(DATA.begin(),DATA.end());
	do {
		cout << buf << endl;
		rep(i,0,R) {
			cout << DATA[i] << " ";
		}
		cout << endl;

    } while (next_permutation(DATA.begin(),DATA.end()));
*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    ll t1,t2;
    cin>>t1>>t2;
    ll a1,a2,b1,b2;
    cin>>a1>>a2;
    cin>>b1>>b2;
    ll sub,cnt=0;
    if(a1!=b1&&(a1*t1+a2*t2==b1*t1+b2*t2)){
        cout<<"infinity\n";
        return;
    }
    else if(a1>b1){
        if(a1*t1+a2*t2<b1*t1+b2*t2){
            sub=(b1-a1)*t1+(b2-a2)*t2;
            ll x=(a1-b1)*t1/sub;
            cnt=2*x;
            if((b1-a1)*t1%sub)++cnt;
        }
    }
    else if(a1<b1){
        if(a1*t1+a2*t2>b1*t1+b2*t2){
            sub=(a1-b1)*t1+(a2-b2)*t2;
            ll x=(b1-a1)*t1/sub;
            cnt=2*x;
            if((b1-a1)*t1%sub)++cnt;
          
        }
    }
    cout<<cnt<<endl;
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256