akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  string s,t;
  cin >> s >> t;
  
  //process
  int ans = 0;
  for(int i=0; i < s.length(); i++) {
    if(!(s[i]==t[i])) {
      ans++;
    }
  }
  
  //output
  cout << ans << endl;
}

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


int main(){
    int w,h,x,y;
    int ans=0;
    cin >> w >> h >> x >> y;
    if((double)w/2.0==(double)x && (double)h/2.0==(double)y) ans=1;
    cout << (double)w*h/2.0 << " " << ans << endl;
    return 0;
}

    

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

int main() {
    constexpr i64 mod = 998244353;
    int n;
    std::string s;
    std::cin >> n >> s;

    i64 c = 0, ret = 0;
    std::vector<std::pair<int, i64>> memo;
    for (int i = 0; i < n; i++) {
        c = (c * 2 + (s[i] == '1')) % mod;

        int d = i + 1;
        if (n % d || n / d % 2 == 0) continue;

        i64 overlap = 0;
        for (auto &e : memo) if (d % e.first == 0 && d / e.first % 2) overlap = (overlap + e.second) % mod;

        int flg = 1;
        for (int j = 0; j < n; j++) {
            int k = j / d % 2 ? '0' + '1' - s[j % d] : s[j % d];
            if (s[j] == k) continue;
            flg = k < s[j];
            break;
        }

        i64 count = (c + flg + mod - overlap) % mod;
        memo.emplace_back(d, count);
        ret = (ret + count * d % mod * 2 % mod) % mod;
    }

    std::cout << ret << std::endl;

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  int p[5000];
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int min_sum=20000;
  for(int i=0;i<=p[0];i++){
    int q[5000];
    for(int j=0;j<N;j++){
      q[j]=p[j];
    }
    int sum=i;
    q[0] -= i;
    for(int j=0;j<=N-2;j++){
      if(q[j]<=0)continue;
      sum+=q[j]*2;
      q[j+1] -= q[j];
    }
    if(q[N-1]>0){
      sum+=q[N-1];
    }
    min_sum=min(min_sum,sum);
  }
  cout<<min_sum<<endl;
}



Measured memory_bytes: 3164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_156c
{
    class Program
    {
        static void Main(string[] args)
        {
            int people = int.Parse(Console.ReadLine());
            int[] home = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int place = (int)Math.Round(home.Average(),MidpointRounding.AwayFromZero);
            int total = 0;

            foreach(int item in home)
            {
                total += (item - place) * (item - place);
            }

            Console.WriteLine(total);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13268
n, m = gets.chop.split.map(&:to_i)
ps, ys = [], []
arr = []
m.times do |i|
    line = gets.chop.split.map(&:to_i)
    arr << {p: line[0], y: line[1], i: i, ans: ''}
    # ps << line[0]
    # ys << line[1]
end
arr.sort! do |a, b|
    a[:y] <=> b[:y]
  end


counts = Array.new(1000000, 1)
m.times do |i|
    arr[i][:ans] = format('%06d', arr[i][:p]) + format('%06d', counts[arr[i][:p]])
    counts[arr[i][:p]] += 1
end
arr.sort! do |a, b|
    a[:i] <=> b[:i]
  end

m.times do |i|
    puts arr[i][:ans]
end

Measured memory_bytes: 57216
def calc(n, a, b, c):
    r = 0

    pre_x = -2
    for x in a:
        r += b[x-1]
        if pre_x + 1 == x:
            r += c[x-2]
        pre_x = x

    return r


n = int(input())  # 2-20
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

r = calc(n, a, b, c)
print(r)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n;
  cin >> n;
  V<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  ll t = a[0];
  rep(i, n) {
    if (a[i] < t) {
      ans += t - a[i];
    } else {
      t = a[i];
    }
  }
  cout << ans << endl;
}


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

using namespace std;
long long k;
int main()
{
	cin >>k;
	printf("%d\n",50);
	long long t1=k%50,t2=k/50;
	for(int i=1;i<=t1;i++)
		printf("%lld ",t2-t1+51+49);
	for(int i=t1+1;i<=50;i++)
		printf("%lld ",t2-t1+49); puts("");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 1000 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
vector<int> Sieve(int n)
{
    std::vector<int> res;
    bool prime[n+1];
    fill(prime,true);
    for(int p = 2 ; p*p<=n ; p++)
    {
        if(prime[p])
        {
            for(int i = p*p ; i<=n ; i+=p)
                prime[i] = false;
        }
    }
    for(int i = 2 ; i<=n ; i++)
        if(prime[i])
            res.pb(i);

    return res;
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    std::vector<int> primes = Sieve(N);
    int n,ans(0);
    cin>>n;
    for(auto x : primes)
    {
        int cur = 1 ;
        int res = x;
        while(n%res==0)
        {
            n/=res;
            ans++;
            res*=x;
        }
        while(n%x==0)
        {
            n/=x;
        }
    }
    if(n>1)
        ans++;
    cout<<ans;


    printclock;
    return 0;
}


Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const int MAXBIT = (1<<21) + 5;
const int MAXN = 25;
int dp[MAXN][MAXBIT];
int a[MAXN];
int n;
int play(int now,int bit){
    if(dp[now][bit]!=-1)    return dp[now][bit];
    if(now == n)            return (__builtin_popcount(bit) == n);
    int sum = 0;
    for(int i=0;i<n;i++)
        if( ((1<<i) & a[now] ) && !(bit & (1<<i)) )
            sum = (sum+play(now+1,bit|(1<<i)))%MOD;
    return dp[now][bit] = sum;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int num;
            scanf("%d",&num);
            if(num) a[i] |= (1<<j);
        }
    }
    memset(dp,-1,sizeof dp);
    printf("%d\n",play(0,0));
    return 0;
}


Measured memory_bytes: 205056
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main() {
	int a, b;
	char c;
	for (;;) {
		cin >> a >> c >> b;
		if (c == '+')
			cout << a + b << endl;
		else if (c == '-')
			cout << a - b << endl;
		else if (c == '*')
			cout << a * b << endl;
		else if (c == '/')
			cout << a / b << endl;
		else if (c == '?')
			break;
	}
	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 3080
def NTT(A,Mod,primitive=None,inverse=False):
    n=len(A)
    max_level=(n-1).bit_length()
    m=1<<max_level

    u=Mod-1
    e=0
    while u%2==0:
        e+=1
        u>>=1

    w=pow(primitive,u,Mod)

    if inverse: #逆変換ならば...
        w=pow(w,Mod-2,Mod) #逆元

    W=[0]*(e+1)
    W[-1]=w

    for k in range(e-1,-1,-1):
        W[k]=(W[k+1]*W[k+1])%Mod

    U=[[0]*(1<<x) for x in range(max_level+1)]

    for y in range(1,max_level+1):
        for x in range(1<<y):
            if x==0:
                U[y][x]=1
            else:
                U[y][x]=(U[y][x-1]*W[y])%Mod

    def ntt(x,level):
        t=len(x)
        if t==1:
            return x

        y=[0]*(t>>1)
        z=[0]*(t>>1)

        for k in range(t//2):
            y[k]=(x[k]+x[k+t//2])%Mod
            z[k]=((x[k]-x[k+t//2])*U[level][k])%Mod

        y=ntt(y,level-1)
        z=ntt(z,level-1)

        x=[0]*t
        for k in range(t>>1):
            x[2*k]=y[k]
            x[2*k+1]=z[k]

        return x

    B=A+[0]*(m-n)
    return ntt(B,max_level)

def Inverse_NTT(A,Mod,primitive=None):
    B=NTT(A,Mod,primitive,inverse=True)
    N_inv=pow(len(A),Mod-2,Mod)
    return [(N_inv*b)%Mod for b in B]

def Convolution_Mod(A,B,Mod,primitive=None):
    N=len(A);M=len(B)
    if N==0 or M==0:
        return []

    z=1<<((N+M-2).bit_length())

    A=A+[0]*(z-N)
    B=B+[0]*(z-M)

    P=NTT(A,Mod,primitive)
    Q=NTT(B,Mod,primitive)

    R=[(P[i]*Q[i])%Mod for i in range(z)]

    return Inverse_NTT(R,Mod,primitive)
#================================================
N,M=map(int,input().split())
Mod=998244353
A=list(map(int,input().split()))
B=list(map(int,input().split()))

C=Convolution_Mod(A,B,Mod,3)
print(" ".join(map(lambda x:str(x%Mod),C[:N+M-1])))

Measured memory_bytes: 359936
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

ll xors[200001] = {0};
ll sums[200001] = {0};
ll a[200000];
int main(){
  int N;
  cin >> N;
  rep(i, N) cin >> a[i];
  xors[0] = 0;
  sums[0] = 0;
  rep(i, N){
    xors[i + 1] = xors[i] ^ a[i];
    sums[i + 1] = sums[i] + a[i];
  }
  int l = 1;
  int r = 1;
  int num = 0;
  ll ans = 0;
  while(1){
    if((sums[r] - sums[l - 1]) == (xors[r] ^ xors[l - 1])) {
      //printf("[%d\t%d]\t%lld\t%lld\t%lld\t%lld\n", l, r, sums[l - 1], sums[r], xors[l - 1], xors[r]);
      num++;
      ans += r - l + 1;
      r++;
    }else{
      num = 0;
      l++;
    }
    if(r == N + 1) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];
ll tre[3030][3030];
ll dp[3030][3030][4];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll r, c, n;
	cin >> r >> c >> n;
	rep(i, n) {
		ll x, y, v;
		cin >> x >> y >> v;
		x--;
		y--;
		tre[x][y] = v;
	}
	rep(i, r) {
		rep(j, c) {
			for (ll k = 2;k >= 0;--k) {
				chmax(dp[i][j][k + 1], dp[i][j][k] + tre[i][j]);
			}
			rep(k, 4) {
				chmax(dp[i + 1][j][0], dp[i][j][k]);
				chmax(dp[i][j + 1][k], dp[i][j][k]);
			}
		}
	}
	ll ans = 0;
	rep(i, 4) {
		chmax(ans, dp[r - 1][c - 1][i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 358816
using System;
using System.Collections.Generic;
namespace 令和{
    class ABC{
        static void Main(){
            string[] n_m = Console.ReadLine().Split();
            int n = int.Parse(n_m[0]);
            int m = int.Parse(n_m[1]);
            UnionFind uf = new UnionFind(n);
            int ans = n;
            for(int i=0;i<m;i++){
               string[] x_y_z = Console.ReadLine().Split();
               if(uf.Unite(int.Parse(x_y_z[0])-1,int.Parse(x_y_z[1])-1)){
                   ans --;
               }
            }
            Console.WriteLine(ans);
        }
    }

    class UnionFind{
        public UnionFind(int n){
            this.parent = new int[n];
            for(int i=0;i<n;i++){
                parent[i] = i;
            }
        }

        public int[] parent;

        public int root(int x){
            if(parent[x]==x){return x;}
            parent[x] = root(parent[x]);
            return parent[x];
        }

        ///<summary>併合された場合はtrue</summary>
        public bool Unite(int x, int y){
            int rx = root(x);
            int ry = root(y);
            if(rx==ry){return false;}
            parent[ry] = rx;
            return true;
        }
        public void Merge(int x, int y){Unite(x,y);}

        public bool SameParent(int x, int y){
            if(root(x)==root(y)){return true;}
            return false;
        }
    }
}

Measured memory_bytes: 15428
import math

N = int(input())
h = list(map(int, input().split()))
h += [math.inf, math.inf]

dp = list([math.inf for i in range(N + 2)])  # dpテーブル
dp[0] = 0
for i in range(N):
    if dp[i + 1] > (dp[i] + abs(h[i] - h[i + 1])):
        dp[i + 1] = (dp[i] + abs(h[i] - h[i + 1]))
    else:
        dp[i + 1] = dp[i + 1]
    if dp[i + 2] > dp[i] + abs(h[i] - h[i + 2]):
        dp[i + 2] = dp[i] + abs(h[i] - h[i + 2])
    else:
        dp[i + 2] = dp[i + 2]

print(dp[N - 1])


Measured memory_bytes: 20808
#include <iostream>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int lmax = 1, rmin = n;
  while (m--) {
    int l, r;
    cin >> l >> r;
    lmax = max(l, lmax);
    rmin = min(r, rmin);
  }
  int ans = rmin - lmax + 1;
  cout << (ans < 0 ? 0 : ans) << endl;
}

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

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

  map<string, int> cnt;
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    ++cnt[s];
  }

  cout << "AC x " << cnt["AC"] << endl;
  cout << "WA x " << cnt["WA"] << endl;
  cout << "TLE x " << cnt["TLE"] << endl;
  cout << "RE x " << cnt["RE"] << endl;

  return 0;
}



Measured memory_bytes: 3588
from itertools import combinations
import numpy as np
n,m,x = map(int,input().split())
a_list = []
price_list = []
for _ in range(n):
    tmp = list(map(int,input().split()))
    price_list.append(tmp.pop(0))
    a_list.append(tmp)
    
all_list = [x for x in range(len(a_list))]
prices = []
for i in range(1,len(a_list)+1):
    for y in combinations(all_list,i):
        tmp = np.zeros(m)
        price = 0
        for ch in y:
            tmp += np.array(a_list[ch])
            price += price_list[ch]
        if np.all(tmp>=x):
            prices.append(price)
if prices != []:
    print(min(prices))
else:
    print(-1)

Measured memory_bytes: 27260
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
const int MX=200011;
int N, M, k;
ll pref[MX];
int arr[MX];
int main()
{
    cin>>N;
    ll last=0;
    for(int i=0; i<N; i++)
    {
        ll x;
        cin>>x;
        arr[i+1]=x;
        pref[i+1]=abs(x-last);
        pref[i+1]+=pref[i];
        last=x;
    }
/*for(int i=1; i<=N; i++ ) cout<<pref[i]<<" ";
    cout<<endl;*/
    for(int i=1; i<=N; i++)
    {

        if(i == N)
        {
            cout<<pref[N-1]+abs(arr[N-1]);
        }
        else
        {
            ll an=pref[N];
            an-=pref[i]-pref[i-1];
            an-=pref[i+1]-pref[i];
            an+=abs(arr[i-1]-arr[i+1]);
            an+=abs(arr[N]);
            cout<<an;

        }
        cout<<"\n";
    }
    return 0;
}


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

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

    int n;
    cin >> n;
    int a[n-1],b[n]={0};
    for (int i=0;i<n-1;i++) {
        cin >> a[i];
        ++b[a[i]-1];
    }
    for (int i=0;i<n;i++)
        cout << b[i] << "\n";
}

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

#include <iostream>
using namespace std;
int main() {
  uint64_t n;
  cin >> n;
  vector<uint64_t> a(n - 1);
  vector<uint64_t> b(n, 0);
  for (auto& ai : a) {
    cin >> ai;
    b[ai - 1]++;
  }
  for (auto bi : b) {
    cout << bi << endl;
  }

  return 0;
}


Measured memory_bytes: 6424
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var s = bufio.NewScanner(os.Stdin)

func getString() string {
	s.Scan()
	return s.Text()
}

func getInt() int {
	s.Scan()
	a, _ := strconv.Atoi(s.Text())
	return int(a)
}

type Runes []rune

func (s Runes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s Runes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s Runes) Len() int {
	return len(s)
}

func main() {
	s.Split(bufio.ScanWords)
	n := getInt()

	nums := make(map[string]int64, n)
	for i := 0; i < n; i++ {
		str := getString()
		runes := []rune(str)
		sort.Sort(Runes(runes))
		nums[string(runes)]++
	}

	var ans int64
	ans = 0
	for _, v := range nums {
		ans += (v * (v - 1)) / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
    string s;cin >> s;
    vector<Int> a(s.size());
    for(Int i=0;i<s.size();i++) a[i] = s[i]-'a';
    Int k;cin >> k;
    for(Int i=0;i<s.size();i++){
        if(a[i]==0) continue;
        if(a[i]+k>25){
            k-=(26-a[i]);
            a[i] = 0;
        }
    }
    k%=26;
    a[s.size()-1]+=k;
    a[s.size()-1]%=26;
    for(Int i=0;i<s.size();i++) cout << (char)(a[i]+'a');
    cout << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222



struct UnionFind {
  vll rank, par, data;

  UnionFind(ll x = MAX) {
    rank.resize(x + 1, 0);
    par.resize(x + 1, 0);
    data.resize(x + 1, 1);
    rep(i, x + 1) par[i] = i;
  }

  ll root(ll x) {
    if (x != par[x]) par[x] = root(par[x]);
    return par[x];
  }

  ll size(ll x) {
    return data[root(x)];
  }

  void unite(ll a, ll b) {
    ll x = root(a);
    ll y = root(b);
    if (x == y) return;
    if (rank[x] > rank[y]) {
      par[y] = x;
      data[x] += data[y];
    }
    else {
      par[x] = y;
      data[y] += data[x];
      if (rank[x] == rank[y]) rank[y]++;
    }
  }

  bool same(ll a, ll b) {
    return root(a) == root(b);
  }
};

ll xnum[MAX], ynum[MAX];

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



  cin >> n;
  UnionFind uf(MAX);
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    uf.unite(a, b + 1e5);
  }
  FOR(i, 1, 1e5 + 1) xnum[uf.root(i)]++;
  FOR(i, 1e5 + 1, 2e5 + 1) ynum[uf.root(i)]++;
  rep(i, MAX) ans += xnum[i] * ynum[i];
  cout << ans - n << endl;



  return 0;
}

Measured memory_bytes: 7680
S = input()
N = len(S)

if N%2==0:
  s1 = S[:N//2]
  s2 = S[N//2:][::-1]
else:
  s1 = S[:N//2]
  s2 = S[N//2+1:][::-1]

answer = 0
for i in range(N//2):
  if s1[i]!=s2[i]:
    answer += 1
print(answer)

Measured memory_bytes: 38384
def main(argv)
  (n, x) = gets.chomp.split(' ').map(&:to_i)
  l = gets.chomp.split(' ').map(&:to_i)
  
  c = 1
  d = 0
  n.times do |i|
    d += l[i]
    
    break if d > x
    
    c += 1
  end
  
  puts c.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

using namespace std;

int main() {
	int M, D; cin >> M >> D;
	int ans = 0;
	for (int m = 1; m <= M; ++m) {
		for (int d = 1; d <= D; ++d) {
			int d_1 = d % 10, d_10 = d / 10;
			if (d_1 >= 2 && d_10 >= 2 && d_1 * d_10 == m) {
				++ans;
			}
		}
	}
	cout << ans << endl;
}

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


bool ok(vector<ll>&h,ll mid,ll a,ll b)
{
	int i,n=h.size();
	ll t=0LL;
	for(i=0;i<n;i++)
	{
		ll ans = h[i]-b*mid;
		if(ans>0LL)
		{
			t+=ceil(ans*1.0/(a-b));
		}
	}
	if(t<=mid)
	{
		return true;
	}
	else
	{
		return false;
	}
}

int main(){
	int n,i;
	ll a,b;
	cin>>n;
	cin>>a>>b;
	vector<ll> h(n);
	for(i=0;i<n;i++)
	{
		cin>>h[i];
	}
	ll low,high,mid;
	low=0LL;
	high=1000000000LL;
	ll ans = -1LL;
	while(low<=high)
	{
		mid = low+(high-low)/2LL;
		if(ok(h,mid,a,b))
		{
			high=mid-1LL;
			ans = mid;
		}
		else
		{
			low=mid+1;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1024
A,B,C = map(int,input().split())
K = int(input())

count = 0

while A >= B:
    count += 1
    if count == K+1:
        print('No')
        exit()
    B *= 2

while B >= C:
    count += 1
    if count == K+1:
        print('No')
        exit()
    C *= 2

if A < B and B < C:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9124
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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 = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

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;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  int n;
  cin>>n;
  ll a[n];
  int cnt[64];

  ll list2[64];
  list2[0] = 1;
  for(int i = 1; i < 64; i++){
    list2[i] = list2[i-1]*2;
    list2[i]%=MOD;
  }
  for(int i = 0; i < 64; i++) cnt[i]=0;
  for(int i = 0; i < n; i++){
    cin>>a[i];
    for(int j = 0; j < 61; j++){
      if(a[i]&((ll)1<<j)) cnt[j]++;
    }
  }

  ll sum=0;
  for(int i = 0; i < 62; i++){
    // cout<<i<<" "<<list2[i]<<endl;
    sum+=list2[i]*cnt[i]%MOD*(n-cnt[i])%MOD;
    sum%=MOD;
    // cout<<sum<<endl;
  }
  cout<<sum<<endl;
  return 0;
}



Measured memory_bytes: 2560
#include <iostream>

int main() {
    int n;
    std::cin >> n;
   for (int i = 1; i <= 9; i++)
       for (int j = 1; j <= 9; j++)
           if (i * j == n) {
               std::cout << "Yes";
               return 0;
           }
   std::cout << "No";
    return  0;

}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

string type(int i) {
  if (1 <= i && i <= 12) {
    return "A";
  }
  return "Y";
}

int main(int argc, const char * argv[]) {
  string S;
  cin >> S;
  
  string f = S.substr(0,2);
  string b = S.substr(2,2);
  
  int fi = atoi(f.c_str());
  int bi = atoi(b.c_str());
  
  string ft = type(fi);
  string bt = type(bi);
  
  if (ft == "Y" && bt == "Y") {
    cout << "NA" << endl;
  } else if (ft == "Y" && bt == "A") {
    cout << "YYMM" << endl;
  } else if (ft == "A" && bt == "Y") {
    cout << "MMYY" << endl;
  } else {
    cout << "AMBIGUOUS" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
x = int(input())

my_dict = dict()

for i in range(1000):
    my_dict[i**5] = i

for i in range(-1000, 1000):
    target = x + (i ** 5)
    if (- target) in my_dict:
        print(-my_dict[-target], i)
        exit()
    elif target in my_dict:
        print(my_dict[target], i)
        exit()


Measured memory_bytes: 62516
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
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 long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){
  int a,b;
  cin >> a >> b;
  
  if(b==1){
    cout << 0 << endl;
  }
  int c=a;
  for(int i=1; i<inf; i++){
    if(b==1) break;
    if(c>=b){
      cout << i << endl;
      break;
    }
    c=c+a-1;
  }
}
      
    


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

using namespace std;

#define endl "\n"

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

	int n;
	string s,t;
	cin >> n;
	cin >> s >> t;
	string ans = "";
	for(int i=0; i<n; i++)
	{
		ans += s[i];
		ans += t[i];
	}

	cout << ans << endl;


	return 0;
}


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

using ll = long long;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    string s0, t0;
    rep(i, s.size()) {
        s0.push_back(s[i]);
    }
    rep(i, t.size()) {
        t0.push_back(t[t.size() - 1 - i]);
    }
    if (s0 < t0) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
# 2つのデータがどれだけ似ているか？ミンコフスキー距離
# x={x1, x2, ..., xn}
# y={y1, y2, ..., yn}
import math

n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))

# p=1 マンハッタン距離
print(sum([abs(i-j) for i, j in zip(x, y)]))
# p=2 ユークリッド距離
print(math.sqrt(sum([(i-j)**2 for i, j in zip(x, y)])))
# p=3
print((sum([abs(i-j)**3 for i, j in zip(x, y)]))**(1.0/3.0))
# print(math.pow(sum([abs(i-j)**3 for i, j in zip(x, y)]), 1/3))
# 上記でも同様の計算となる。
# p=∞ チェビシェフ距離
print(max([abs(i-j) for i, j in zip(x, y)]))


Measured memory_bytes: 5724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 100000000

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll q, b, e, k;
    cin >> q;
    rep(i, q) {
        cin >> b >> e >> k;
        cout << count(a.begin() + b, a.begin() + e, k) << endl;
    }

}


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

typedef long long ll;

const long double PI = (acos(-1));


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

  int n;
  string s;
  cin >> n >> s;

  for (int i = 0; i < s.size(); i++){
    s.at(i) += n;
    s.at(i) = 65 + (s.at(i) - 65) % 26;
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(lambda x: int(x), input().split(" ")))
ok = True
for i in v:
    if i % 2 == 0:
        if i % 3 == 0:
            continue
        elif i % 5 == 0:
            continue
        else:
            ok = False
            break
print("APPROVED" if ok else "DENIED")

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

int main(){
    vector<int> a(3);
    for (auto i = 0; i < 3; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<>());

    int ans, tmp;
    while((2 * a[0] - (a[1] + a[2])) % 2 != 0) {
        a[0]++;
        a[1]++;
        ans++;
    }

    ans += (a[0] - a[1]) / 2 + (a[0] - a[1]) % 2;
    tmp = (a[0] - a[2] - ((a[0] - a[1]) % 2));
    ans += tmp / 2 + tmp % 2;

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

Measured memory_bytes: 256
def resolve():
    S = input()

    memo = []
    def dfs(s):
        if len(s) == len(S)-1:
            memo.append(s)
            return 
        dfs(s + "1")
        dfs(s + "0")

    dfs("")
    comb = []
    for c in memo:
        sub = []
        store = S[0]
        for i, flag in enumerate(c):
            if flag == "0":
                store += S[i+1]
            elif flag == "1":
                sub.append(store)
                store = S[i+1]
        sub.append(store)
        comb.append(sub)

    total = 0
    for c in comb:
        ilist = list(map(int, c))
        sum = 0
        for a in ilist:
            sum += a
        total += sum

    print(total)

if __name__ == "__main__":
    resolve()

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

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

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    rep (i, mat.size()) {
      rep (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    rep (i, v.size()) cout << v[i] << ' ';
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}

bool check(int j, int n) {
  if (0 <= j && j <= n) return true;
  return false;
}

const int INF = 1001001001;

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> v(N+1);
  vector<int> w(N+1);
  rep (i, N) cin >> v[i+1] >> w[i+1];

  vector<vector<int>> dp = utils::empty<int>(N+1, W+1);

  for (int i=1; i<=N; i++) {
    for (int j=1; j<=W; j++) {
      int next_j = j-w[i];
      if (check(next_j, W)) {
        dp[i][j] = max(dp[i-1][j], dp[i-1][next_j]+v[i]);
      }
      else {
        dp[i][j] = dp[i-1][j];
      }
    }
  }


  cout << dp[N][W] << endl;
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<vector<char>> dp1(N + 1, vector<char>(K + 1));
    vector<vector<char>> dp2(N + 1, vector<char>(K + 1));
    vector<vector<short>> acc(N + 1, vector<short>(K + 2));

    dp1[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= K; j++) {
            if (!dp1[i][j]) continue;
            dp1[i + 1][j] = 1;
            if (j + A[i] <= K) dp1[i + 1][j + A[i]] = 1;
        }
    }

    dp2[N][0] = 1;
    for (int i = N; i > 0; i--) {
        for (int j = 0; j <= K; j++) {
            if (!dp2[i][j]) continue;
            dp2[i - 1][j] = 1;
            if (j + A[i - 1] <= K) dp2[i - 1][j + A[i - 1]] = 1;
        }
        for (int j = 0; j <= K; j++) {
            acc[i][j + 1] = acc[i][j] + dp2[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        bool flag = false;
        for (int j = 0; j <= K; j++) {
            if (!dp1[i][j]) continue;

            int mi = max(0, K - A[i] - j);
            int ma = max(0, K - j);
            if (acc[i + 1][ma] - acc[i + 1][mi] > 0) {
                flag = true;
                break;
            }
        }
        if (!flag) {
            ans++;
        } 
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

int main(){
		int A,B,C,x;
		int ans=0;
		cin>>A>>B>>C>>x;
		for(int i=0;i<=C;i++){
				for(int j=0;j<=B;j++){
						for(int k=0;k<=A;k++){
								if(i*50+j*100+k*500==x) ++ans;
						}
				}
		}
		cout<<ans<<endl;
		return 0;
}


		


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
 
int  a[102][7];
char f[102];
 
int identical(int *a, int *b)
{
    int i, j;
    memset(f, 0, sizeof(f));
    for (i = 1; i <= 6; i++) f[a[i]]++;
    for (i = 1; i <= 6; i++) f[b[i]]--;
    for (i = 1; i <= 6; i++) if (f[b[i]]) return 0;
 
    for (j = 0; j < 24; j++) {
        if (b[1] == a[rot[j][1]]) {
            for (i = 2; ; i++) {
                if (i > 6) return 1;
                if (b[i] != a[rot[j][i]]) break;
            }
        }
    }
    return 0;
}
 
int main()
{
    int n, i, j, f;
 
    n = in();
    for (i = 0; i < n; i++) {
        for (j = 1; j <= 6; j++) a[i][j] = in();
    }
    f = 1;
    for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
        if (identical(a[i], a[j])) { f = 0; goto done; }
    }
done:
    puts(f? "Yes": "No");
    return 0;
}



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

int main() {
  long N, c, d;
  cin >> N;
  c = 0;
  d = 0;
  vector<long> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < N; i++){   
    if(vec.at(i) >= c){
      c = vec.at(i);
    }
    if(c - vec.at(i) > 1){
      cout << "No" << endl;
      d = 1;
      break;
    }
    if(i == N-1 && d == 0){
      cout << "Yes" << endl;
    }
  }
}


Measured memory_bytes: 1024
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MAXN = (int) 1e5;

int n, K;

int a[MAXN + 5];

inline void input()
{
	n = read<int>(), K = read<int>();
	for(int i = 1; i <= n; ++i) a[i] = read<int>();
}

vector<int> adj[MAXN + 5];
int fa[MAXN + 5], dep[MAXN + 5];
pii nd[MAXN + 5];

inline void dfs(int u)
{
	dep[u] = u == 1 ? 0 : dep[fa[u]] + 1;
	nd[u] = mp(dep[u], u);

	for(auto v : adj[u]) dfs(v);
}

inline int kth_pre(int u, int k)
{
	while(k--) u = fa[u];
	return u;
}

int vis[MAXN + 5];

inline void dfs_mark(int u, int d)
{
	vis[u] = 1;
	if(d == K) return;

	for(auto v : adj[u]) dfs_mark(v, d + 1);
}

inline void solve()
{
	int ans = a[1] != 1;
	for(int i = 2; i <= n; ++i) adj[fa[i] = a[i]].push_back(i);

	dfs(1);
	sort(nd + 1, nd + n + 1);

	dfs_mark(1, 0);
	for(int i = n; i >= 1; --i) if(!vis[nd[i].snd] && dep[nd[i].snd] > K)
	{
		int u = nd[i].snd, p = kth_pre(u, K - 1);
		++ans, dfs_mark(p, 1);
	}
	printf("%d\n", ans);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

string BinToString(ll x)
{
	string res;
	for(int i=8;i>=0;i--){
		if((1LL<<i)&x) res+='1';
		else res+='0';
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	vii a[n];
	forn(i,0,n){
		int m; cin>>m;
		forn(j,0,m){
			int u,v; cin>>u>>v; u--;
			a[i].pb({u,v});
		}
	}
	
	int ans=0;
	for(int mask=0;mask<(1<<n);mask++){
		bool ok=1;
		forn(i,0,n){
			if((mask&(1<<i))==0) continue;
			for(ii tmp: a[i]){
				int u=tmp.F, v=tmp.S;
				if(bool((1<<u)&mask)!=v){ ok=0; break; }
			}
		}
		
		if(ok){
			ans=max(ans, __builtin_popcount(mask));
			//cout<<"mask="<<BinToString(mask)<<'\n';
		}
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)

int32_t main(){
  
    int n,k; cin >> n >> k;
    bool dislike[10] = {false};
    
    for(int i=1;i<=k;i++){
      int d; cin >> d;
      dislike[d] = true;
    }

    string s = to_string(n);
    int maxx_digit;

    for(int i=0;i<10;i++){
      if(!dislike[i]) maxx_digit = i;
    }

    for(int i=0;i<s.size();i++) s[i] = maxx_digit + 48;

    for(int i=s.size()-1;i>=0;i--){
      for(int j=0;j<10;j++){
        if(!dislike[j]){
          char temp = s[i];
          s[i] = j + 48;
          if(stoi(s)<n){
            s[i] = temp;
          }
          else break;
        }
      }
    }

    if(stoi(s)<n){
      vector<char> min_digit;
      for(int i=0;i<10;i++){
        if(!dislike[i]&&min_digit.size()!=2){
          min_digit.pb(i+48);
        }
      }
      s = string(s.size()+1,min_digit[0]);
      if(min_digit[0]=='0') s[0] = min_digit[1];
    }

    cout << s;

    return 0;
} 

Measured memory_bytes: 256
var i,n,l,max,sum:integer;
begin
  readln(n); max:=0; sum:=0;
  for i:=1 to n do begin
    read(l);
    if l>max then max:=l;
    sum:=sum+l
  end;
  if 2*max < sum then write('Yes')
  else write('No')
end.

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int x,i=1;
    while(true){
        cin>>x;
        if(x==0)break;
        else{
            cout<<"Case"<<" "<<i<<":"<<" "<<x<<endl;
            i=i+1;
        }
        
    }return 0;
}


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

int main(){
    int N;
    int Y;

    cin >> N >> Y;
    int x = 0,y = 0,z = 0;
    int total = 0;
    bool flag = 0;
    for (int i = 0; i <= N; i++){
        for (int j = 0; j <= N - i; j++){
                total = 10000 * i + 5000 * j + 1000 * (N - i - j);
                if (total == Y) {
                    x = i; y = j; z = N - i - j; flag = 1;
                }
        }
    }
    // if (flag == 1) printf("%d,%d,%d\r\n",x,y,z);
    // else printf("%d,%d,%d\r\n",-1,-1,-1);
    if (flag == 1) cout << x << ' ' << y << ' ' << z << endl;
    else cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

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

int main() {
	int N,M;
	ll x[1000],y[1000],z[1000];
	cin>>N>>M;
	REP(i,N){
		cin>>x[i]>>y[i]>>z[i];
	}
	
	ll ans=0;
	REP(i,1<<3){
		ll c[3];
		vector<ll> sum(N);
		REP(j,3){
			c[j]=(i>>j)&1;
			c[j]=c[j]*2-1;
			//cout<<c[j]<<" ";
		}
		//cout<<endl;
		REP(j,N){
			sum[j]=c[0]*x[j]+c[1]*y[j]+c[2]*z[j];
			//cout<<sum[j]<<endl;
		}
		
		sort(sum.begin(),sum.end());
		reverse(sum.begin(),sum.end());
		ll t=0;
		REP(j,M){
			t+=sum[j];
		}
		
		ans=max(ans,t);
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
while True:
    n,x = map(int,input().split())
    if n == x == 0:
        break

    n = n + 1
    c = 0
    for i in range(1,n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if x == i + j + k:
                    c += 1
    print(c)


Measured memory_bytes: 5596