akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<LL> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL mod = 1000000007;
const LL LINF = 1e18 + 10;
const LL MAX = 1e5 + 1;

PII x[MAX];
int ans[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n, l, t;
	cin >> n >> l >> t;

	FOR(i, 0, n)
		cin >> x[i].X >> x[i].Y, ans[i] = x[i].X;

	LL cnt = 0;
	FOR(i, 0, n)
		if (x[i].Y == 1)
		{
			cnt += (x[i].X + t) / l;
			ans[i] = (ans[i] + t) % l;
		}
		else
		{
			if (x[i].X < t)
				cnt -= (t - x[i].X - 1)/ l + 1;

			ans[i] = ((ans[i] - t) % l + l) % l;
		}

	sort(ans, ans + n);
	cnt = (cnt%n + n) % n;
	rotate(ans, ans + cnt, ans + n);
	FOR(i, 0, n)
		cout << ans[i] << endl;

	cin >> n;
	return 0;
}

Measured memory_bytes: 2432
n, k = map(int, input().split())
s = [x for x in input()]

start = s[0]
current = 1
prev = None
utility = 0
while k != 0 and current < n:
  if s[current] != start:
    if not prev:
      prev = current
    else:
      utility += 1
  elif prev:
    if current == n:
      utility += 1
    else:
      utility += 2
    k = k-1
    prev = None
  else:
    utility += 1
  current += 1

if prev:
  if current == n and k > 0:
    utility +=  1
  if start == 'L':
    prev = 'R'
  else:
    prev = 'L'
else:
  if start == 'R':
    prev = 'R'
  else:
    prev = 'L'
while current < n:
  if s[current] == prev:
    utility += 1
  prev = s[current]
  current += 1
print(utility)


Measured memory_bytes: 4212
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

struct edge {
    ll to, cost;
};

int V;
vector<edge> G[1000000];
ll d[1000000];

void addedge(int st, int ed, ll co) {
    edge e;
    e.to = ed;
    e.cost = co;
    G[st].push_back(e);
}

ll dpblack[100010];
ll dpwhite[100010];

ll par[100010];
ll chinum[100010];

int main() {
    ll N;
    cin >> N;
    REP(i, 0, N - 1) {
        ll x, y;
        cin >> x >> y;
        addedge(x - 1, y - 1, 1);
        addedge(y - 1, x - 1, 1);
    }
    fill(dpblack, dpblack + 100010, 1);
    fill(dpwhite, dpwhite + 100010, 1);
    par[0] = -1;
    queue<int> que;
    que.push(0);
    while(!que.empty()) {
        ll p = que.front();
        que.pop();
        REP(i, 0, G[p].size()) {
            ll to = G[p][i].to;
            if (to != par[p]) {
                par[to] = p;
                que.push(to);
            }
        }
    }
    // REP(i, 0, N) {
    //     cout << par[i] << " ";
    // }
    // cout << endl;
    queue<int> queb;
    chinum[0] = G[0].size();
    REP(i, 1, N) {
        chinum[i] = G[i].size() - 1;
        if (chinum[i] == 0) {
            queb.push(i);
        }
    }
    while(!queb.empty()) {
        ll p = queb.front();
        queb.pop();
        if (p == 0) {
            continue;
        }
        ll parent = par[p];
        dpwhite[parent] = multiply(dpwhite[parent], (dpwhite[p] + dpblack[p]));
        dpblack[parent] = multiply(dpblack[parent], dpwhite[p]);
        chinum[parent]--;
        if (chinum[parent] == 0) {
            queb.push(parent);
        }
    }
    ll ans = (dpwhite[0] + dpblack[0]) % mod;
    cout << ans << endl;
}


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


int main()
{
  string s; cin >> s;
  int mini = INT_MAX;
  for(int i=0; i<s.length()-2; i++) {
    string ans = "";
    ans += s[i];
    ans += s[i+1]; ans += s[i+2];
    mini = min(mini, abs(stoi(ans)-753));
  }
  cout << mini <<  "\n";
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  const int MAX = 60000;
  vector<bool> p(MAX);
  for (int i = 2; i < MAX; i++) {
    p[i] = true;
  }
  for (int i = 2; i * i < MAX; i++) {
    if (!p[i]) {
      continue;
    }
    for (int j = i * i; j < MAX; j += i) {
      p[j] = false;
    }
  }
  int cc = 0;
  for (int i = 2; cc < n; i++) {
    if (p[i] && i % 5 == 1) {
      printf("%d%c", i, " \n"[cc == n - 1]);
      cc++;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

constexpr long long MOD = 1000000007;

int main()
{
  int N;
  std::string s;
  std::cin >> N >> s;
  int R = 0;
  int B = 0;
  for (auto c: s)
  {
    if (c == 'R')
      ++R;
    else
      ++B;
  }
  std::cout << (R > B ? "Yes" : "No") << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll N,W;
	cin>>N>>W;
	ll *w=new ll[N];
	ll *v=new ll[N];
	ll** dp=new ll*[N+1];
	for(ll i=0;i<=N;i++)
	{
		dp[i]=new ll[W+1];
	}	
	for(ll i=0;i<N;i++)
		cin>>w[i]>>v[i];
	for(ll i=0;i<=N;i++)
	{
		dp[i][0]=0;
	}
	for(ll i=0;i<=W;i++)
	{
		dp[0][i]=0;
	}
	for(ll i=1;i<=N;i++)
	{
		for(ll j=1;j<=W;j++)
		{
			if(j>=w[i-1])
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[N][W]<<endl;

}

Measured memory_bytes: 79488
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  ll a, b, c, d, n;
  cin >> a >> b >> c >> d >> n;
  n *= 4;
  b = min(b, 2 * a);
  c = min(c, 2 * b);
  d = min(d, 2 * c);
  ll result = 0;
  result += n / 8  * d;
  n %= 8;
  result += n / 4 * c;
  n %= 4;
  result += n / 2 * b;
  n %= 2;
  result += n * a;
  cout << result << endl;
  return 0;
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using vvvll = V<V<V<ll>>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vvpll = V<vpll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;
using vvch = V<vch>;
using qll = queue<ll>;
using vqll = V<qll>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin() 
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a) //
/*vvll v(n,vll(m)) n行m列  continue
A.erase(A.begin()+i); 配列Aのi番目を消せる
std::binary_search(v.bgn,v.en,a); 二分探索
abs(a,b)   pow(a,n)  to_string  stoll
auto Iter=lower_bound(v.bgn,v.en,a); v[i]>=aのv[i]
v.insert(lower_bound(v.bgn,v.en,a),b); bを入れられる
lower upper  co(*Iter) co(Iter-v.bgn) v[i]>=aとなる初のi
priority_queue<ll> pque; pque.push(ai); pque.top()→max(ai) 
vqll q(3);  q[0].push(0); q[0].push(2); q[0].push(1);
q[0].front()→0 q[0].back()→1 q[0].pop(); q[0].front()→2
que.pop() que.sz while(!que.empty())
*/

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    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;
    }
}
#define comuse Comuse()
ll combi(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;
}
ll pow_mod(ll a,ll n,ll m){
  ll res=1;
  for(;n>0;n/=2){
    if(n%2==1)res=(res*a)%m;
    a=(a*a)%m;
  }
  return res;
}

int main(){
  str s;
  cin>>s;
  vvll dp(100001,vll(13));
  ll n=s.sz;
  if(s[0]=='?'){
    FOR(i,0,10){
      dp[0][i]=1;
    }
  }
  else{
    dp[0][s[0]-'0']=1;
  }
  FOR(i,1,n){
    if(s[i]=='?'){
      FOR(j,0,13){
        FOR(k,0,10){
          dp[i][(10*j+k)%13]+=dp[i-1][j]%MOD;
        }
      }
    }
    else{
      FOR(j,0,13){
        dp[i][(10*j+(s[i]-'0'))%13]+=dp[i-1][j]%MOD;
      }
    }
    //co(dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<" "<<dp[i][3]);
  }
  co(dp[n-1][5]%MOD);
}
    

  

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

int main()
{
    int n;
    cin >> n;
    string s = to_string(n);
    for (int i = 0; i < 3; i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<ctype.h>

int main()
{
    char buffer[1200];
    int i;
    
    fgets(buffer, 1200, stdin);
    for(i=0;i<1200;i++)
    {
        if(buffer[i]=='\0') break;
        else if(islower(buffer[i])) printf("%c", toupper(buffer[i]));
        else if(isupper(buffer[i])) printf("%c", tolower(buffer[i]));
        else printf("%c", buffer[i]);
    }
    
    return(0);
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
 
const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e18; 
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int k, x;
int main (){
    scanf ("%d %d", &k, &x);
    int l = x - k + 1, r = x + k - 1;
    for (int i = l; i <= r; ++i) printf ("%d ", i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

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

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 10, K = 26, inf = 1e9, infll = 1e18;
const double pi = acos(-1);

void solve(){
    int n, i, j, k, l, r; cin >> n;
    int a[n + 5], f = 1, ff = 1;
    for1(i, 1, n){
        cin >> a[i]; 
        if(a[i] == 0){
            ff = 0;
        }
    }
    if(ff == 0){
        cout << 0; return;
    }
    for1(i, 1, n){
        if(a[i] <= infll / f){
            f *= a[i];
        }
        else{
            cout << -1; return;
        }
    }
    cout << f;
}

signed main() {
    //freopen(".INP", "r", stdin); 
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
int main(){
  ll n,m;cin>>n>>m;
  if(n==1||m==1){
    if(n==1&&m==1)return cout<<1,0;
    ll x=max(n,m);
    cout<<max(ll(0),x-2);
  }else cout<<max((n*m)-2*(n+m)+4,ll(0));
}

Measured memory_bytes: 256
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
    #define vec(n) vector<int>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

  
  
    int main(){
      int n;
      cin >> n;
      auto v = vec(n);
      REP(i,1,n+1)cin >> v[i];

      int cnt = 0;
      int now = 1;
      bool f = false;
      while(cnt < n){
        now = v[now];
        if(now == 2){
          f = true;
          break;
        }
        cnt++;
      }

      if(f)cout << cnt+1 <<endl;
      else cout << -1 <<endl;
    }

    


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
  if ((0 <= x && x <= W) && (0 <=y && y <= H)){
    if ((0 <= x-r) && (x+r <= W) && (0 <= y-r) && (y + r <= H)){
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  }
  else{
    puts("No");
  }
  return(0);
}

Measured memory_bytes: 584
N=int(input())
s=input()
res=0
for i in range(1,N):
    X=s[:i]
    Y=s[i:]
    n=0
    for j in range(97,123):
        if X.count(chr(j))!=0 and Y.count(chr(j))!=0:
            n+=1
    res=max(res,n)
print(res)

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

const int mod = 1000000007;
struct mint {
  long long x;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


  
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

long long S;
int main(){
    cin>>S;

    mint dp[S+1][S+1];
    dp[0][0]=1LL;

    for(int i=1;i<=S;i++){
        for(int j=0;j<=S;j++){

            if(j==0){

                //dp[i][0]+=
            }
            else{
                if(dp[i-1][j-1].x!=0LL){
                    dp[i][j]+=dp[i-1][j-1];

                    if(j>=3){
                        dp[i][0]+=dp[i-1][j-1];
                    }
                }
            }
        }
    }

    //for(int i=0;i<(S+1)*(S+1);i++)cout<<dp[i/(S+1)][i%(S+1)]<<" \n"[i%(S+1)==(S+1)-1];
    cout<<dp[S][0]<<endl;
    return 0;
}

Measured memory_bytes: 34668
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,K;
    cin >> N >> K;
    vector<long long> A,B;
    for ( int i = 0; i < N; i++ ) {
        long long a;
        cin >> a;
        if ( a >= 0 ) { A.push_back(a); }
        else { B.push_back(-a); }
    }
    if ( B.size() > 0 ) { reverse( B.begin(), B.end() ); }

    long long ans = LLONG_MAX;

    if ( A.size() >= K ) { ans = min( ans, A[K-1] ); }
    if ( B.size() >= K ) { ans = min( ans, B[K-1] ); }
    for ( int i = 0; i < A.size(); i++ ) {
        if ( K-(i+1) >= 1 && K-(i+1) <= B.size() ) {
            long long l = max( A[i], B[K-(i+1)-1] );
            long long s = min( A[i], B[K-(i+1)-1] );
            ans = min( ans, s*2 + l );
        }
    }
    for ( int i = 0; i < B.size(); i++ ) {
        if ( K-(i+1) >= 1 && K-(i+1) <= A.size() ) {
            long long l = max( B[i], A[K-(i+1)-1] );
            long long s = min( B[i], A[K-(i+1)-1] );
            ans = min( ans, s*2 + l );
        }
    }


    cout << ans << endl;
    

    return 0;
}

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

void hekerman(char x[105]);

int main() {

    char x[105];

    scanf("%s", x);

    hekerman(x);

    return 0;
}

void hekerman(char x[105]) {

    int i, cnt = 0;
    char y[105];
    
    for(i = 0; i < strlen(x); i++) {
        if(x[i] == 'B') {
            cnt--;
        } else {
            y[cnt++] = x[i];
        }

        if(cnt < 0) {
            cnt = 0;
        }
    }

    for(i=0; i<cnt; i++) {
        printf("%c", y[i]);
    }
    printf("\n");

}

Measured memory_bytes: 1652
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    bool f[n][m];
    memset(f, false, sizeof(f));
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            f[s-1][i] = true;
        }
    }
    int p[m];
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        bool s[m];
        for (int i = 0; i < m; i++) {
            s[i] = p[i];
        }
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j))) {
                for (int k = 0; k < m; k++) {
                    s[k] ^= f[j][k];
                }
            }
        }

        bool flag = true;
        for (int j = 0; j < m; j++) {
            flag &= !s[j];
        }

        ans += flag;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;


int main(void) {

    int N; cin>>N;
    string S; cin>>S;
    int cnt=0;
    for (int i = 0; i < N-2; ++i) {
        if(S.substr(i,3) == "ABC") cnt++;
    }

    cout<<cnt<<endl;

}


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

int main() {
   int N,K,x;int n=1;int dst=0;
   cin>>N;
   cin>>K;
   for(int i=0;i<N;i++){
       cin>>x;
       if(x*2<=K){
            dst=dst+x;
     }else{
            dst=dst-x+K;
     }
  }cout<<dst*2<<endl;
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    n %= k;
    if (k - n > n) {
        cout << n << endl;
    } else {
        cout << k - n << endl;
    }
    return 0;
}

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

auto& in = std::cin;
auto& out = std::cout;

int64_t H,W;



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

	in >> H>>W;
	int64_t min_diff = H*W;
	for (int64_t w = 1; w < W; w++)
	{
		//h=H
		int64_t a = H*w,b, c;
		auto www = (W - w);
		if ((H & 1) == 0) { c = b = (H / 2)*www; }
		else if ((www & 1) == 0) { c = b = H*(www/2); }
		else {
			if (www < H) {
				b = (H / 2)*www;
				c = ((H+1) / 2)*www;
			}
			else {
				b = H*(www / 2);
				c = H*((www+1) / 2);
			}
		}
		min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c }));
	}
	for (int64_t h = 1; h < H; h++)
	{
		//h=H
		int64_t a = h*W, b ,c;
		auto hhh = (H - h);
		if ((W & 1) == 0) { c = b = (W / 2)*hhh; }
		else if ((hhh & 1) == 0) { c = b = W*(hhh / 2); }
		else {
			if (hhh < W) {
				b = (W / 2)*hhh;
				c = ((W + 1) / 2)*hhh;
			}
			else {
				b = W*(hhh / 2);
				c = W*((hhh + 1) / 2);
			}
		}
		min_diff = std::min(min_diff, std::max({ a,b,c }) - std::min({ a,b,c }));
	}
	std::cout << min_diff << std::endl;

	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    int prev = 0;
    rep(i, n){
        if(prev + 1 == v[i]) prev++;
    }

    if(prev == 0) cout << -1 << endl;
    else cout << n-prev << endl;
}

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

using namespace std;

int main()
{ 
	int n;
	while (cin >> n)
	{
		vector<bool> a(n + 1, true);
		int cnt = n == 0 ? 0 : n - 1;

		// Sieve of Eratosthenes
		for (int i = 2; i*i <= n; ++i)
			if (a[i])
				for (int j = 0; i * (j + 2) <= n; ++j)
					if (a[i * (j + 2)]) a[i * (j + 2)] = false, cnt--;

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::string s, t;
    std::cin >> n >> s >> t;

    for (int i = 0; i < n; i++) {
        std::cout << s[i] << t[i];
    }
    std::cout << std::flush;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,a = 0,cnt = 1,ans = 1;
    cin >> n;
    rep1(i, n){
        a += i;
        ans = i;
        if (a == n) {
            cnt = 0;
            break;
        }else if (a > n){
            cnt = a - n;
            break;
        }
    }
    rep1(i, ans){
        if (i != cnt) {
            cout << i << endl;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll mod = 1000000007;
ll dp[55][3][3];

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

	memset(dp, 0, sizeof(dp));
	int n; cin>>n;
	vector<string> s(2);
	cin>>s[0]>>s[1];
	if(s[0][0] == s[1][0]){
		for(int i = 0; i < 3; i++){
			dp[0][i][i] = 1;
		}
	}else{
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				if(i != j)dp[0][i][j] = 1;
			}
		}
	}
	for(int i = 1; i < n; i++){
		for(int p0 = 0; p0 < 3; p0++){
			for(int p1 = 0; p1 < 3; p1++){
				for(int c0 = 0; c0 < 3; c0++){
					for(int c1 = 0; c1 < 3; c1++){
						if((s[0][i] == s[1][i])^(c0 == c1))continue;
						if((s[0][i] == s[0][i - 1])^(c0 == p0))continue;
						if((s[1][i] == s[1][i - 1])^(c1 == p1))continue;
						dp[i][c0][c1] += dp[i - 1][p0][p1];
						if(dp[i][c0][c1] >= mod)dp[i][c0][c1] -= mod;
					}
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			ans += dp[n - 1][i][j];
			if(ans >= mod)ans -= mod;
		}
	}
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}
//printf("%.10f\n", n);

ll x[1234567], y[1234567];
signed main() {
    while(true){
	ll m, n, a, b; cin >> m; map<ll, map<ll, ll>>ma;
	if(m==0){return 0;}
	vector<ll> v1, v2;
	rep(i, m) {
		cin >> x[i] >> y[i];
	}
	cin >> n;
	rep(i, n) {
		cin >> a >> b;
		rep(j, m) {
			if (ma[a - x[j]][b - y[j]] == 0) {
				v1.push_back(a - x[j]); v2.push_back(b - y[j]);
			}
			ma[a - x[j]][b - y[j]]++;
		}
	}
	rep(i, v1.size()) {
		//cout << v1[i] << ' ' << v2[i] << ' ' << ma[v1[i]][v2[i]] << endl;
		if (ma[v1[i]][v2[i]] == m) {
			cout << v1[i] << ' ' << v2[i] << endl;break;
		}
	}
    }
	return 0;
}


Measured memory_bytes: 35928
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll h = in(), w = in();
	ll cnt = 0;
	REP(i, h) {
		string s; cin >> s;
		cnt += count(ALL(s), '#');
	}
	cout << (cnt == w + h - 1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = long.Parse(Console.ReadLine());
			var aList = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();

			var absoluteDictionary = new Dictionary<int, int>();

			var isOdd = aList.Count % 2 == 1;

			if (isOdd)
			{
				for (int i = 0; i < n; i+=2)
				{
					absoluteDictionary.Add(i, 0);
				}
			}
			else
			{
				for (int i = 1; i < n; i += 2)
				{
					absoluteDictionary.Add(i, 0);
				}
			}

			foreach(var value in aList)
			{
				if(!absoluteDictionary.ContainsKey(value))
				{
					Console.WriteLine("0");
					return;
				}
				absoluteDictionary[value]++;
			}

			foreach(var keyValuePair in absoluteDictionary)
			{
				if(isOdd)
				{
					if(keyValuePair.Key == 0)
					{
						if (keyValuePair.Value != 1)
						{
							Console.WriteLine("0");
							return;
						}
					}
					else
					{
						if(keyValuePair.Value != 2)
						{
							Console.WriteLine("0");
							return;
						}
					}
				}
				else
				{
					if (keyValuePair.Value != 2)
					{
						Console.WriteLine("0");
						return;
					}
				}
			}

			var pow = aList.Count / 2;
			long answer = 1;

			for(int i = 0; i < pow; i++)
			{
				answer = answer * 2 % 1000000007;
			}

			Console.WriteLine(answer);
		}
	}
}


Measured memory_bytes: 22368
def main():
    import sys
    input = sys.stdin.readline

    N, M, Q = map(int, input().split())

    tb = [[0] * (N + 1) for _ in range(N + 1)]
    # tb[L][R]:=区間LR内を走る列車総数
    for _ in range(M):
        L, R = map(int, input().split())
        tb[L][R] += 1

    for L in range(1, N + 1):
        for R in range(1, N + 1):
            tb[L][R] += tb[L - 1][R]
            tb[L][R] += tb[L][R - 1]
            tb[L][R] -= tb[L - 1][R - 1]

    ans = []
    for _ in range(Q):
        p, q = map(int, input().split())
        ans.append(tb[q][q] - tb[p - 1][q] - tb[q][p - 1] + tb[p - 1][p - 1])

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 19084
class UnionFind:
    def __init__(self, n):
        self._n = n
        self._table = [-1]*n

    def _root(self, x):
        stack = []
        while self._table[x] >= 0:
            stack.append(x)
            x = self._table[x]
        for y in stack:
            self._table[y] = x
        return x
    
    def unite(self, x, y):
        x, y = self._root(x), self._root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self._table[x] += self._table[y]
        self._table[y] = x

    def same(self, x, y):
        return self._root(x) == self._root(y)

    def count_members(self, x):
        return -self._table[self._root(x)]

    def count_groups(self):
        return len({self._root(i) for i in range(self._n)})

    def __iter__(self):
        return (self._root(i) for i in range(self._n))

    def __str__(self):
        return str([self._root(i) for i in range(self._n)])

    def __repr__(self):
        return repr([self._root(i) for i in range(self._n)])

n, q, *Q = map(int, open(0).read().split())
uf = UnionFind(n)
for t, a, b in zip(Q[::3], Q[1::3], Q[2::3]):
    if t:
        print(int(uf.same(a, b)))
    else:
        uf.unite(a, b)

Measured memory_bytes: 57820
# coding: utf-8
# Here your code !

sa, sb, sc = [list(input()) for i in range(3)]
now = sa.pop(0)
while 1:
    #print(now, sa, sb, sc)
    if now == "a":
        if sa == []:
            pass
        else:
            now = sa.pop(0)
    elif now == "b":
        now = sb.pop(0)
    else:
        now = sc.pop(0)
    
    if sa == [] and now == "a" :
        print("A")
        break
    elif sb == [] and now == "b":
        print("B")
        break
    elif sc == [] and now == "c":
        print("C")
        break

Measured memory_bytes: 3064
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import groupby

    s = input()
    k = int(readline())
    l = len(s)

    if len(set(s)) == 1:
        return print(l * k // 2)

    ans = 0
    gr = [list(g) for k, g in groupby(s)]
    for g in gr:
        ans += len(g) // 2 * k

    if gr[0][0] == gr[-1][-1]:
        ans += ((len(gr[0]) + len(gr[-1])) // 2) * (k - 1)
        ans -= (len(gr[0]) // 2 + len(gr[-1]) // 2) * (k - 1)

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int64_t N, ans = 1;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0) {
            ans = 0;
        }
    }
    for (int64_t i = 0; i < N && ans != 0; i++) {
        if (ans > 1000000000000000000 / A[i]) {
            ans = -1;
            break;
        }
        ans *= A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4056
#include<cstdio>
#include<iostream>
using namespace std;
char s[51];
int n=1;
int main()
{
	char c=getchar();
	while(c!='\n')
	{
		s[n]=c;
		n++;
		c=getchar();
	}
	for(int i=1;i<n-8;i++)
	cout<<s[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
Y = Y // 1000

x, y, z = -1, -1, -1
for i in range(N+1):
  if Y < N+9*i:
    break
  if (Y-N-9*i) % 4 == 0:
    j = (Y-N-9*i) // 4
    if i+j <= N:
      x, y = i, j
      break

if x != -1:
  z = N - i - j
print(x, y, z)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int main(){
    char n[200000];
    cin >> n;
  
    int len = strlen(n);
    int sum=0;
    for(int i=0; i<len; i++) sum += n[i]-'0';
  
    if (sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackSub readDataArr = new StackSub(in.readLine().split(" "));
		System.out.println(readDataArr.calcData());
	}
}

class StackSub {
	private String[] readData;
	private int[] stack = new int[100];
	private int ans, operand1, operand2, pointer = 0;

	StackSub(String[] readData) {
		this.readData = readData;
	}

	public int calcData() {
		char tempCharData;
		for (int i = 0; i < readData.length; i++) {
			tempCharData = readData[i].charAt(0);
			operand1 = pointer - 2;
			operand2 = pointer - 1;

			if (tempCharData == '+') {
				stack[operand1] = stack[operand1] + stack[operand2];
				pointer--;
			} else if (tempCharData == '-') {
				stack[operand1] = stack[operand1] - stack[operand2];
				pointer--;
			} else if (tempCharData == '*') {
				stack[operand1] = stack[operand1] * stack[operand2];
				pointer--;
			} else {
				stack[pointer] = Integer.parseInt(readData[i]);
				pointer++;
			}
		}
		ans = stack[0];
		return ans;
	}
}

Measured memory_bytes: 24356
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let a: usize;
    let b: usize;
    let x: usize;
    input!(a, b, x);
    if a <= x && a + b >= x {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
import java.util.*;
import java.io.*;

public class Main {

  static int n;
  static String s;
  static final long MOD = 2019L;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    s = br.readLine();

    br.close();

    n = s.length();

    Map<Long, Long> m = new HashMap<>();

    m.put(0L, 1L);

    long now = 0, ten = 1;

    for(int i = n-1; i >= 0; i--){
      now += ten * (long)(s.charAt(i) - '0');
      now %= MOD;

      m.put(now, m.getOrDefault(now, 0L) + 1L);

      ten *= 10;
      ten %= MOD;
    }

    long ans = 0;

    for(Map.Entry<Long, Long> e : m.entrySet()){
      ans += e.getValue() * (e.getValue() - 1) / 2;
    }

    System.out.println(ans);
    
  }
}

Measured memory_bytes: 48436
#include<iostream>
#include<algorithm>
using namespace std;
int a[100];
int main()
{
	int n, m;
	while (cin >> n >> m)
	{
		for (int i = 0; i < n; i++)
			cin >> a[i];
		for (int i = 0; i < n; i++)
			m -= a[i];
		sort(a, a + n);
		int count = m / a[0];
		cout << count + n << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
a, b, H, M = list(map(int, input().split()))
omega_a = 30 * H
omega_b = 5.5 * M
# if (abs(omega_a-omega_b) > 180):
#     thita = abs(omega_a-omega_b) - 180
# else:
#     thita = abs(omega_a-omega_b)
thita = abs(omega_a-omega_b)
# print(thita)
# cos = math.cos(math.radians(thita))
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(thita)))
print('{:.22g}'.format(c))

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int cnt[10001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N;
	cin>>N;
	for(int i=1;i<=500;i++) for(int j=1;j<=500;j++) for(int k=1;k<=500;k++) if(i*i+j*j+k*k+i*j+j*k+k*i<=10000) cnt[i*i+j*j+k*k+i*j+j*k+k*i]++;
	for(int i=1;i<=N;i++) cout<<cnt[i]<<'\n';
	return 0;
}

Measured memory_bytes: 3576
N,Q = map(int,input().split())
T = [0]*(N+1)
V = [0]*(N+1)
for _ in range(N-1):
    a,b = map(int,input().split())
    T[b] = a
for _ in range(Q):
    p,x = map(int,input().split())
    V[p]+=x
for i in range(1,N+1):
    V[i]+=V[T[i]]
print(*V[1:])

Measured memory_bytes: 25852
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string s;
    cin >> s;
    string ans = "CODEFESTIVAL2016";
    int sum = 0;
    rep(i, 16){
        if(s[i] != ans[i]) 
            sum++;
    }
    cout << sum << endl;
    return 0;
}


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

int main(void){
    // Your code here!
    int i;
    int n,cnt=0;
    cin >> n;
    int V[n],C[n];
    for(i=0;i<n;++i){
        cin >>V[i];
    }
    for(i=0;i<n;++i){
        cin >>C[i];
    }
    for(i=0;i<n;++i){
        if (0<V[i]-C[i]){
            cnt += V[i]-C[i];
        } 
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    if(s.at(5) == '1'){
        cout << "TBD" << endl;   
    }else if(s.at(6) == '4' || s.at(6) == '3' || s.at(6) == '2' || s.at(6) == '1'){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
    
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    long cnt;
    foreach (i; iota(s.length - 1))
    {
        if(s[i] != s[i + 1])
            cnt++;        
    }
    cnt.writeln();
}

bool is_reversable(string s)
{
    bool ret = true;
    foreach (i; iota(s.length / 2))
    {
        ret &= (s[i] == s[$ - 1 - i]);
    }
    return ret;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 508
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  vector<int> a;
  vector<int> b;
  vector<int> c;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    a.push_back(x);
  }
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    b.push_back(x);
  }
  for(int i = 0; i < n-1; i++){
    int x;
    cin >> x;
    c.push_back(x);
  }
  int ans;
  ans = accumulate(b.begin(), b.end(), 0);
  for(int i = 0; i < n-1; i++){
    if(a[i+1] - a[i] == 1){
      ans += c[a[i]-1];
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
P=tuple(map(float,input().split()))
DP=[[0]*(n+1) for _ in range(n+1)]
DP[0][0]=1
for i in range(1,n+1):
    for j in range(i+1):
        DP[i][j]=DP[i-1][j]*(1-P[i-1])
        if j:
            DP[i][j]+=DP[i-1][j-1]*P[i-1]
ans=0
for i in range(n//2+1,n+1):
    ans+=DP[-1][i]
print(ans)

Measured memory_bytes: 254472
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

int A[100000];
int B[100000];

vector <int> prizes[100001];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        int A;
        int B;
        cin >> A >> B;
        prizes[A].push_back(B);
    }

    long long ans = 0;
    priority_queue <long long> pq;
    for(int i = 1; i < M + 1; i++){
        for(int j = 0; j < prizes[i].size(); j++){
            pq.push(prizes[i][j]);
        }
        if(!pq.empty()){
            ans += (long long) pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,a,b;
ll h[100100];

bool C(ll c){
	ll cnt = c;
	rep(i,n){
		ll hh = h[i] - b*c;
		if(hh <= 0)continue;
		cnt -= (hh/(a-b)) + (hh%(a-b) != 0);
	}
	return cnt >= 0;
}

int main(){
	cin >> n >> a >> b;
	rep(i,n)cin >> h[i];
	ll lb = 0;
	ll ub = 1e9;
	while(ub - lb > 1){
		ll mid = (ub+lb)/2;
		if (C(mid))ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
}




Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		sc.close();

		long res = sol(b)^sol(a-1);

		System.out.println(res);
	}
	private long sol(long a) {
		if (a % 2 == 1) return (a+1)/2 % 2;
		return (a+2)/2 % 2^(a+1);
	}
}  

Measured memory_bytes: 23124
#include<iostream>

using namespace std;
int main()
{
    int a=0,b=0,c=0;
    cin>>a>>b>>c;
    int d=a+b+c;
    if(d>=22)
    cout<<"bust"<<endl;
    else
    {
        cout<<"win"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N,L=map(int,input().split())
RES = 0
res = 100
mid = 0
List = []
for i in range(N):
  mid = L+i
  List.append(mid)
  if abs(mid)<abs(res):
    res = mid
for i in range(N):
  if res == List[i]:
    pass
  else:
    RES += List[i]
print(RES)

Measured memory_bytes: 9052