akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    ll N;
    cin >> N;

    string S;
    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }

    REP(i, 32) {
        ll m = 1LL << i;
        if (abs(N) % (m * 2) == m) {
            S.push_back('1');
            if (i % 2 == 0) {
                N -= m;
            } else {
                N += m;
            }
        } else {
            S.push_back('0');
        }
        if (N == 0) break;
        // cout << i << " " << N << endl;
    }
    reverse(ALL(S));
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  putout((ll)pow(n,3));
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  for (int i = 1; i <= 10000; i++) {
    int x;
    cin >> x;
    if (x == 0) break;
    cout << "Case " << i << ": " << x << '\n';
  }
}


Measured memory_bytes: 3124
class Node:
	def __init__(self, key):
		self.key = key
		self.left = self.right = self.parent = None

class BST:
	def __init__(self):
		self.root = None
	
	def insert(self, key):
		parent = None
		current = self.root
		while current != None:
			parent = current
			if key < current.key:
				current = current.left
			else:
				current = current.right
		new = Node(key)
		new.parent = parent
		if parent == None:
			self.root = new
		elif key < parent.key:
			parent.left = new
		else:
			parent.right = new		
	
	def find(self, key):
		current = self.root
		while current != None:
			if key == current.key:
				return current
			if key < current.key:
				current = current.left
			else:
				current = current.right
		return None
		
	def delete(self, key):
		return
	
	def print(self):
		self.print_in_order(self.root)
		print()
		self.print_pre_order(self.root)
		print()
		
	def print_in_order(self, node):
		if node != None:
			self.print_in_order(node.left)
			print(' ' + str(node.key), end='')
			self.print_in_order(node.right)
		
	def print_pre_order(self, node):
		if node != None:
			print(' ' + str(node.key), end='')
			self.print_pre_order(node.left)
			self.print_pre_order(node.right)		

n = int(input())
bst = BST()
for i in range(n):
	cmd = list(map(str, input().split()))
	if cmd[0] == 'print':
		bst.print()
	else:
		key = int(cmd[1])
		if cmd[0] == 'insert':
			bst.insert(key)
		elif cmd[0] == 'find':
			if bst.find(key) != None:
				print('yes')
			else:
				print('no')
		else:
			bst.delete(key)



Measured memory_bytes: 85232
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int sum=0;
		if(i%2!=0){
		for(int j=1;j<=i;j++){
			if(i%j==0){
				sum++;
			}
		}
		if(sum==8){
			ans++;
		}
		}
	}
	cout<<ans;
}

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

using namespace std;
const int MAXN = 55;
long long dp[MAXN][MAXN][MAXN * MAXN];

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

  vector<long long> x(N + 1);
  x[0] = 0;
  long long X = (long long)A;
  for (int i = 1; i <= N; ++i) {
    cin >> x[i];
    X = max(X, x[i]);
  }

  dp[0][0][0] = 1;

  for (int j = 1; j <= N; ++j) {
    for (int k = 0; k <= N; ++k) {
      for (int s = 0; s <= N * X; ++s) {
	if (s < x[j]) {
	  dp[j][k][s] = dp[j - 1][k][s];
	} else if (k > 0 && s >= x[j]) {
	  dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j]];
	} else {
	  dp[j][k][s] = 0;
	}
      }
    }
  }

  long long ans = 0;
  for (int i = 1; i <= N; ++i) {
    ans += (long long)dp[N][i][i * A];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;


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

    int f[n+2];
    for (int i = 0; i <= n; i++)
        f[i] = 0;

    double p = (sqrt(4.0*n - 11.0) - 1) / 2.0;
    for (int i = 1; i <= p; i++) {
        for (int j = 1; j <= p; j++) {
            for (int k = 1; k <= p; k++) {
                ll z = i*i + j*j + k*k + i*j + j*k + k*i;
                if (z > n) {
                    break;
                }
                else f[z]++;
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << f[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
  long a, b, c, k, n;
  n = 1000000000000000000;
  cin >> a >> b >> c >> k;
  c = (k%2)?(b-a):(a-b);
  if(-n<c && c<n){
    cout << c << endl;
  }
  else{
    cout << "Unfair" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define endl "\n"
typedef pair<ll,ll> pll;
const ll INF=1e18+4;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
const ll mn=1e5+4;
ll vcnt[mn];
ll lone[mn], pairs[mn];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,m; scanf("%lld%lld",&n,&m);
	memset(vcnt,0,sizeof vcnt);
	for (ll i=0;i<n;i++) {
		ll x; scanf("%lld",&x);
		vcnt[x]++;
	}
	for (ll x=0;x<mn;x++) {
		ll cnt=vcnt[x];
		if (cnt) {
			ll mod=x%m;
			pairs[mod]+=(cnt/2);
			lone[mod]+=(cnt%2);
		}
	}
	ll ans=0;
	for (ll x=0;x<m;x++) {
		if (x<(m-x)%m) {
			ll cand=0;
			ll take=min(lone[x],lone[m-x]);
			lone[x]-=take; lone[m-x]-=take;
			cand+=take;
			if (lone[x]>0) {
				ll use=min(lone[x]/2, pairs[m-x]);
				lone[x]-=use*2;
				pairs[m-x]-=use;
				cand+=use*2;
			}
			if (lone[m-x]>0) {
				ll use=min(lone[m-x]/2, pairs[x]);
				lone[m-x]-=use*2;
				pairs[x]-=use;
				cand+=use*2;
			}
			cand+=pairs[x]+pairs[m-x];
			//printf("x:%lld cand:%lld\n",x,cand);
			ans+=cand;
		}
		else if (x==(m-x)%m) {
			ll all=pairs[x]*2+lone[x];
			//printf("x:%lld add:%lld\n",x,all/2);
			ans+=all/2;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<assert.h>
#include<string.h>
#include<math.h>

#define MAX 1001
#define MAX_C 100001
#define max(a,b) ((a>b)?a:b)

int C, N, c[MAX], v[MAX], i, j, dp[MAX_C];

int main() {
  scanf("%d %d",&N,&C);
  assert( N < MAX );
  assert( C < MAX_C );
  for(i=0;i<N;i++) scanf("%d %d",v+i,c+i);
  
  memset(dp,-1,sizeof dp);
  dp[0] = 0;
  /*
  for(i=0;i<N;++i) {
    for(j=C;j>=0;--j) if( dp[j] != -1 ) {
      if( j + c[i] <= C ) {
	dp[j+c[i]] = max(dp[j+c[i]],dp[j]+v[i]);
      }
    }
  }
  */
  for(i=0;i<N;++i) {
    for(j=0;j<C;++j) if( dp[j] != -1 ) {
	if( j+c[i] <= C ) {
	  dp[j+c[i]] = max(dp[j+c[i]],dp[j]+v[i]);
	}
      }
  }

  int maxi = 0;
  for(i=0;i<=C;i++) maxi = max(maxi,dp[i]);
  printf("%d\n",maxi);
  
  return 0;
}

Measured memory_bytes: 1432
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec) for(int never = 0; never < vec.size(); never++){ cin>>vec[never];}
#define printVec(vec) for(int never = 0; never < vec.size(); never++){ cout<<vec[never]<<" ";} cout<<endl;
#define S second
#define F first
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;



void solve() {
    // cout << "test" << endl;
    int a;
    cin >> a;

    set<string> s;
    for (int i = 0; i < a; i++) {
        string bla;
        cin >> bla;
        s.insert(bla);
    } 

    cout << s.size() << endl;
    
}

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

    int t;
    t = 1;
    // cin >> t;
    while(t--) {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 19288
import Control.Monad

pops [] = [[]]
pops (x:xs) = xs : map (x:) (pops xs)
isCommonDiff (x:y:xs) = and $ zipWith (==) xs [y+z,y+z+z..]
 where z = y-x
solve xs = head [y| (y,ys)<-zip xs (pops xs), isCommonDiff ys]

main = do
 n <- getLine
 when (n /= "0") $ do
  l <- getLine
  print $ solve $ map read $ words l
  main

Measured memory_bytes: 5416
#include "iostream"
using namespace std;
int main(){
	int sec;
	int h, m, s;
	cin >> sec;
	h = sec/3600;
	sec = sec % 3600;
	m = sec / 60;
	sec = sec % 60;
	s = sec;
	cout << h << ":" << m << ":" << s << endl;
}

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

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


Measured memory_bytes: 3920
#include "stdio.h"

int main(){
    int N;
  	long L[100];
    scanf("%d",&N);
    L[0]=2;
    L[1]=1;
    for(int i=2;i<=N;i++){
        L[i]=L[i-1]+L[i-2];
    }
    printf("%ld",L[N]);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N==3||N==5) {
    cout << "YES" << endl;
  } else if (N==7) {
    cout << "YES" << endl;
  } else {
  cout << "NO" << endl;
  };
}

Measured memory_bytes: 256
def extgcd(a, b, d=0):
    """solve ax + by = gcd(a, b)
       return x, y, gcd(a, b)
       unproved
    """
    g = a
    if b == 0:
        x, y = 1, 0
    else:
        x, y, g = extgcd(b, a % b)
        x, y = y,  x - a // b * y
    return x, y, g

a, b = map(int, input().split())
print(*extgcd(a, b)[:2])

Measured memory_bytes: 6724
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = 4;
		int obj[] = {1,7,9,4};
		int arr[] = new int[4];
		boolean judge[] = new boolean[4];
		for(int i = 0;i < 4; i++) {
			arr[i] = scan.nextInt();
			for(int j = 0;j< 4;j++) {
				if(arr[i] == obj[j]) {
					judge[j] = true;
					break;
				}
			}
		}
		
		boolean flag = true;
		for(int j = 0;j< 4;j++) {
			if(!judge[j]) {
				System.out.println("NO");
				flag = false;
				break;
			}
		}
		
		if(flag) {
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define int long long
using namespace std;
int A,B,C,N;
vector<int> L(8);
int dfs(int depth, int a, int b, int c) {
    if (depth == N) {
        if (a == 0 || b == 0 || c == 0) return 114514;
        return abs(a - A) + abs(b - B) + abs(c - C);
    }
    int ans = 114514;
    ans = min(ans, dfs(depth + 1, a, b, c));
    ans = min(ans, dfs(depth + 1, a + L[depth], b, c) + (a > 0 ? 10 : 0));//導入と合体の区別
    ans = min(ans, dfs(depth + 1, a, b + L[depth], c) + (b > 0 ? 10 : 0));
    ans = min(ans, dfs(depth + 1, a, b, c + L[depth]) + (c > 0 ? 10 : 0));

    return ans;
}

signed main(){
  cin >> N >> A >> B >> C ;
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  cout << dfs(0,0,0,0) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

string S;

int main(){
    cin >> S;
    int N = S.length();
    string a, b;
    Rep(i, 0, N){
        if(i % 2 == 0){
            a += "0";
            b += "1"; 
        }else{
            a += "1";
            b += "0";
        }
    }
    int ca = 0, cb = 0;
    Rep(i, 0, N){
        if(S[i] == a[i]) ca++;
        if(S[i] == b[i]) cb++;
    }
    Print(Min2(ca, cb));
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b;
  cin >> a >> b;
  
  int c;
  c = a * b % 2;
  
  if ( c == 0 ) {
    cout << "Even" << endl;
  }
  if ( c == 1 ) {
    cout << "Odd" << endl;
  }
  
}

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

int n;
vector<int> a, cnt;

bool solve();

int main() {
  cin >> n;
  a.resize(n);
  for (auto &p : a) cin >> p;
  cout << (solve() ? "Possible" : "Impossible") << endl;
  return 0;
}

bool solve() {
  if (n == 2) return 1;
  sort(a.begin(), a.end(), greater<int>());
  if (a[0] != a[1]) return 0;
  if (a[n - 1] != (a[0] + 1) / 2) return 0;
  cnt.assign(n + 1, 0);
  for (auto p : a) ++cnt[p];
  if ((a[0] % 2 == 0) && cnt[a[n - 1]] != 1) return 0;
  if (a[0] & 1 && cnt[a[n - 1]] != 2) return 0;
  for (int i = a[n - 1] + (a[0] % 2 == 0); i <= a[0]; ++i)
    if (cnt[i] < 2) return 0;
  return 1;
}


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

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

    vector<int> a(N);
    for(int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end(), greater<int>());

    int dif_score = 0;
    for(int i = 0; i < N; i++) {
        if(i % 2 == 0) {
            dif_score += a.at(i);
        } else {
            dif_score -= a.at(i);
        }
    }

    cout << dif_score << endl;
}


Measured memory_bytes: 3484
import sys
N = int(input())
s = list(int(input()) for _ in range(N))
total = sum(s)

if total % 10 != 0:
    print(total)
    sys.exit()

s.sort()
for i in range(N):
    if (total - s[i]) % 10 != 0:
        print(total - s[i])
        sys.exit()

print(0)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    if(a+b*5+c*10+d*50+e*100+f*500>=1000)cout<<"1"<<endl;
    else cout<<"0"<<endl;
}

Measured memory_bytes: 1156
#include <iostream>

using namespace std;
using int64    = long long;
using PII      = pair<int, int>;
const int MAXN = 80;
const int INF  = 0x3f3f3f3f;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    int h1,m1,h2,m2,t;
    cin >> h1 >> m1 >> h2 >> m2 >> t;
    if(m2<m1) {
        m2+=60;
        h2--;
    } 
    int tot = (h2-h1)*60+(m2-m1);
    cout << tot - t << endl;
}


Measured memory_bytes: 3220
/* ITP1_5_C */
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    while(true){
      // input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height > 300 || width > 300) break;
      // drow
      for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
          if((i + j) % 2 == 0)
            sb.append("#");
          else
            sb.append(".");
        }
        sb.append("\n");
      }
      sb.append("\n");
    }
    // output
    System.out.print(sb);
  }
}

Measured memory_bytes: 25520
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
string t;
cin>>s>>t;
int n = stoi(s+t);
for(int i = 0; i<10000; i++){
    if(i*i==n){
        cout<<"Yes"<<endl;
        return 0;
    }
}

cout<<"No"<<endl;
return 0;
}

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

#ifdef SG
	#include <debug.h>
#else
	template<typename T> struct outputer;
	struct outputable {};
	#define PRINT(...)
	#define OUTPUT(...)
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
	#define fbegin(...)
	#define fend
	#define pbegin(...)
	#define pend
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb emplace_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100000;

struct Input {
	string s;
	
	bool read () {
		return !!getline(cin, s);
	}

	void init (const Input &input) {
		*this = input;
	}
};

struct Data: Input {
	int ans;
	
	void write () {
		cout << ans << endl;
	}
};


namespace Main {
	
	struct Solution: Data {
		int n;
		
		void solve () {
			n = sz(s);
			int lst = -1;
			forn (i, (n + 1) / 2) {
				if (s[i] != s[n / 2] || s[n - 1 - i] != s[n / 2]) {
					lst = i;
				}
			}
			ans = n - lst - 1;
		}
		
		void clear () {
			*this = Solution();
		}
	};
}


Main::Solution sol;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);

	#ifdef SG
		freopen((problemname + ".in").c_str(), "r", stdin);
//		freopen((problemname + ".out").c_str(), "w", stdout);
		while (sol.read()) {
			sol.solve();
			sol.write();
			sol.clear();
		}
	#else
		sol.read();
		sol.solve();
		sol.write();
	#endif
	
	/*
	int t;
	cin >> t;
	forn (i, t) {
		sol.read();
		sol.solve();
		sol.write();
		sol.clear();
	}
	*/
	
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    int a = 0;
    rep(i,0,3){
	int d;
	cin >> d;
	a += d;
    }
    if(a >= 22)P("bust");
    else P("win");
    return  0;
}


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

constexpr int nax = 1e5;

int n, dp[nax], tab[nax];

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

    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        cin >> tab[i];
        if (i == 0) dp[i] = 0;
        else if (i == 1) dp[i] = dp[i - 1] + abs(tab[i] - tab[i - 1]);
        else dp[i] = min(dp[i - 2] + abs(tab[i] - tab[i - 2]), dp[i - 1] + abs(tab[i] - tab[i - 1]));
    }
    cout << dp[n - 1] << '\n';
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string x;
	cin >> x;
	stack<char> s;
	for(int i = 0; i < (int)x.size(); i++){
		if(s.size() && s.top() == 'S' && x[i] == 'T')
			s.pop();
		else
			s.push(x[i]);
	}

	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 644
#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;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin>>a[i];

    if(n%2==0){
        for (int i = n-1; i >= 1; i-=2) cout<<a[i]<<" ";
        for (int i = 0; i < n; i+=2) cout<<a[i]<<" ";
    }else{
        for (int i = n-1; i >= 0; i-=2) cout<<a[i]<<" ";
        for (int i = 1; i < n; i+=2) cout<<a[i]<<" ";
    }

    return 0;
}

Measured memory_bytes: 2944
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define ft first
#define ftt ft.ft
#define ftc ft.sc
#define sc second
#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define ctz __builtin_ctz
typedef pair<int, int> pii;
const int maxn = 1e3;
 



//int n ,res ,c ,d;
//pair <pii ,bool> a[maxn] ,b[maxn];
int n ,res ,m;
map<string , int> a , b;
string str;
int main(){FAST;
    cin >> n;
    forp(i ,0 ,n){
        cin >> str;
        auto itr = a.find(str);
        if(itr != a.end())
           itr->sc += 1;
        else
            a.insert({str ,1});
    }
	cin >> m;
    forp(i ,0 ,m){
        cin >> str;
        auto itr = b.find(str);
        if(itr != b.end())
           itr->sc += 1;
        else
            b.insert({str ,1});
    }
	for(auto it = a.begin(); it != a.end(); ++it){
			auto itr = b.find(it -> ft);
				if(itr != b.end()){
				if(itr -> sc < it -> sc)
					res = max(res ,int(it -> sc - itr -> sc));
				}
				else res = max(res ,int(it -> sc));
}

    out(max(res ,0));





    /*cin >> n;   
    int x ,y;
    forp(i ,0 ,n)
        cin >> x >> y ,a[i].ftt = x ,a[i].ftc = y;
    forp(i ,0 ,n)
        cin >> x >> y ,b[i].ftt = x ,b[i].ftc = y;
                
    sort(a ,a + n);
    sort(b ,b + n);

    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            if(a[i].ftt < b[i].ftt && a[i].ftc < b[i].ftc && !a[i].sc && !b[i].sc)
                res++ ,a[i].sc = b[i].sc = true;*/


   return 0;
}
 












Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, N) for(i = 0; i < N; i++)
#define ll long long
ll i, j, k;
int main() {
  int N;
  cin >> N;
  int tmp = N / 1000;
  if(N % 1000 == 0) {
    cout << "0";
  } else {
    cout << 1000 - (N - tmp * 1000);
  }

  return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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

int f(int n){
  if (n<=0) return 0;
  return (((n+1)/2)%2) ^ (n%2==0?n:0);
}

signed main() {
  int a,b;cin>>a>>b;
  int ans = f(b)^f(a-1);
  cerr<<f(b)<<endl;
  cerr<<f(a-1)<<endl;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for (int i = 1; i <= 9; i++) {
			if (n % i == 0 && n / i <= 9) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


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

using namespace std;

int main(){

	long long a,b,c,x;
	cin >> a >> b >> c ;
	
	vector<vector<int>> vec1,vec2;
	
	vec1 = vector<vector<int>>(a, vector<int>(b, 0));
	vec2 = vector<vector<int>>(b, vector<int>(c, 0));
	
	
	for(int i=0; i<a; i++){
		for(int j = 0; j<b; j++){
			cin >> vec1.at(i).at(j);
		}
	}
	
	for(int i=0; i<b; i++){
		for(int j = 0; j<c; j++){
			cin >> vec2.at(i).at(j);
		}
	}
	
	for(int i = 0; i<a; i++){
		for(int j=0; j<c; j++){
			x=0;
			for(int k=0; k<b; k++){
				x = x + vec1.at(i).at(k)*vec2.at(k).at(j);
			}
			cout << x ;
			if (j != c-1) cout << " " ;
		}
		 cout << endl;
	}
	
}



Measured memory_bytes: 3212
N = int(input())
Xls = list(map(int,input().split()))
X2ls = sorted(Xls)
M1 = X2ls[N//2-1]
M2 = X2ls[N//2]
lsans = []
for i in range(N):
    if Xls[i] <= M1:
        M = M2
    else:
        M = M1
    lsans.append(M)
for i in lsans:
    print(i)

Measured memory_bytes: 30736
#include<bits/stdc++.h>
using namespace std;
#define mex 100005
vector<int> adj[mex];
int vis[mex];
int d[mex];
int dfs(int v){
  vis[v]=1;
  int m1=0;
  for(auto u:adj[v]){
    if(vis[u]==0){
      int m2=dfs(u)+1;
      m1=max(m2,m1);
    }
    else{
      int m2=d[u]+1;
      m1=max(m1,m2);
    }
  }
  d[v]=m1;
  return d[v];
}
    
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
  }
  for(int i=1;i<=n;i++){
    if(vis[i]==0)
      d[i]=dfs(i);
  }
  //for(int i=1;i<=n;i++)
   //cout<<d[i]<<" ";
  //cout<<endl; 
  cout<<*max_element(d,d+n+1);
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k; cin>>n>>k;
	string s; cin>>s;
	ll g=1;
	rep(i, s.size()-1){
		if (s[i]!=s[i+1]) g++;
	}

	if (g-1<=k*2){
		cout << n-1 << "\n";
	}else{
		cout << n-(g-k*2) << "\n";
	}

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=100000 ;
///Power
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
int main()
{
   fast ;
   string s ;
   cin>>s ;
   char ans[400001] ;
   ll  q ;
   cin>>q ;
   ll cnt=0 ;
   for(ll i=2*N;i<2*N+s.length();i++)
   {
       ans[i]=s[i-2*N] ;

   }
   ll a=2*N-1,b=2*N+s.length() ;
   while(q--)
   {
       ll t ;
       cin>>t ;
       if(t==1)
        cnt++ ;
       else
       {
           ll x ;
           char r ;
           cin>>x>>r ;
           if(x==1)
           {
               if(cnt%2==0)
               {
                   ans[a]=r ;
                   a-- ;
               }
               else
                  {
                      ans[b]=r ;
                      b++ ;
                  }
           }
           else
           {
                if(cnt%2==0)
               {
                     ans[b]=r ;
                      b++ ;
               }
               else
               {
                   ans[a]=r ;
                   a-- ;
               }

           }
       }

   }
   if(cnt%2==0)
   {
       for(ll i=a+1;i<b;i++)
        cout<<ans[i] ;
   }
   else
   {
       for(ll i=b-1;i>a;i--)
        cout<<ans[i] ;
   }




}


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


int main() {
#ifndef ONLINE_JUDGE
	//freopen("inp.txt", "r", stdin);		freopen("outp.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);

	string s;	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/* #define int long long */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    int n;
    ll k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i], a[i]--;

    deque<int> roop;
    vector<bool>seen(n, false);
    int ans;
    int now = 0;

    while(true){
        if(seen[now]){
            while(roop[0] != now){
                k--;
                roop.pop_front();
                if(k == 0){
                    cout << roop[0]+1 << endl;
                    return 0;
                }
            }
            break;
        }
        roop.push_back(now);
        seen[now] = true;
        now = a[now];
    }

    cout << roop[k % roop.size()] + 1 << endl;
}

Measured memory_bytes: 4828
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);

    int mx = *max_element(ALL(A));
    int mn = *min_element(ALL(A));
    cout << mx - mn << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    dx = [1,0]
    dy = [0,1]
    INF = float('inf')
    h,w = readInts()
    dp = [[INF]*w for _ in range(h)]
    FIELD = [input() for _ in range(h)]
    # dp[j][i] = i番目とj番目にかかる魔法の度合い
    # 初期値 魔法1, なし 0
    if FIELD[0][0] == '#':
        dp[0][0] = 1
    else:
        dp[0][0] = 0
    for i in range(w):
        for j in range(h):
            for x,y in dx,dy:
                ny = j + y
                nx = i + x
                if ny >= h or nx >= w:
                    continue
                add = 0
                if FIELD[ny][nx] == '#' and FIELD[j][i] == '.':
                    add = 1
                dp[ny][nx] = min(dp[ny][nx], dp[j][i] + add)
    print(dp[h-1][w-1])
if __name__ == '__main__':
  main()


Measured memory_bytes: 5252
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

typedef long long ll;

const int MAX_N=2e3,MAX_M=2e3;

int N,M,Q;

string S[MAX_N];
int kasx[MAX_M][MAX_N+1],kasy[MAX_N][MAX_M+1],smx[MAX_M+1][MAX_N+1],sm[MAX_N+1][MAX_M+1];

int main(){
	cin>>N>>M>>Q;
	REP(i,N){
		cin>>S[i];
	}
	REP(m,M-1){
		REP(n,N){
			kasx[m+1][n+1]=kasx[m+1][n];
			if (S[n][m]=='1' && S[n][m+1]=='1'){
				kasx[m+1][n+1]++;
			}
		}
	}
	REP(n,N-1){
		REP(m,M){
			kasy[n+1][m+1]=kasy[n+1][m];
			if (S[n][m]=='1' && S[n+1][m]=='1'){
				kasy[n+1][m+1]++;
			}
		}
	}
	REP(m,M){
		smx[m+1][1]=(int)(S[0][m]-'0');
		REP(n,N-1){
			smx[m+1][n+2]=smx[m+1][n+1];
			if (S[n][m]=='0' && S[n+1][m]=='1'){
				smx[m+1][n+2]++;
			}
		}
	}
	REP(m,M){
		REP(n,N){
			sm[n+1][m+1]=sm[n+1][m]+smx[m+1][n+1]-kasx[m][n+1];
		}
	}
	REP(q,Q){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		int u=sm[x2][y2]-sm[x2][y1-1]+kasx[y1-1][x2],v=sm[x1-1][y2]-sm[x1-1][y1-1]+kasx[y1-1][x1-1];
		cout<<u-v+kasy[x1-1][y2]-kasy[x1-1][y1-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 68480
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

LL modpow(LL a, LL n, LL m) {
	LL r = 1;
	while(n) {
		if(n&1)	r = (r*a)%m;
		a = (a*a)%m;
		n >>= 1;
	}
	return r;
}

int main() {
	string str; cin >> str;
	LL n = str.length();
	LL curr = modpow(3ll, n, MOD);
	LL ones = 0;
	rep(i, 0, n) {
		if(str[i] == '0') {
			LL sub = (modpow(2ll, ones+1, MOD) * modpow(3ll, n-i-1, MOD))%MOD;
			curr = (curr - sub)%MOD;
			while(curr < 0)	curr += MOD;
			curr %= MOD;
		}
		else	ones++;
	}
	pll(curr); nl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    //static int[] dp;
    //static decimal[,,] dp;
    //static decimal N;
    static void Main(string[] args)
    {
        // 入力
        long[] input = Console.ReadLine().Split().Select(p => long.Parse(p)).ToArray();
        long A = input[0];
        long B = input[1];

        HashSet<long> ret = new HashSet<long>();

        long last = (long)Math.Ceiling(Math.Min(Math.Sqrt((double)A), Math.Sqrt((double)B)));
        for(int i=2; i <= last+1; i++)
        {
            // iで割り切れるだけ割る
            if(A%i == 0 && B%i == 0)
            {
                ret.Add(i);
            }
            if(A%i == 0)
            {
                while(A%i == 0)
                {
                    A /= i;
                }
            }
            if (B%i == 0)
            {
                while (B % i == 0)
                {
                    B /= i;
                }
            }
        }

        // 小さいほう(素数)が大きいほうを割り切れる場合
        if(A > 1 && A<B)
        {
            if(B%A==0)
            ret.Add(A);
        }
        else if(B > 1)
        {
            if (A % B == 0)
                ret.Add(B);
        }
        Console.WriteLine((ret.Count+1) + "");
    }
}


Measured memory_bytes: 13408
#include <stdio.h>

int main() {

    int t, cntAC=0, cntWA=0, cntTLE=0, cntRE=0;
    char str[105];

    scanf("%d", &t);
    while(t--) {
        scanf("%s", str);
        if(str[0] == 'A') {
            cntAC++;
        } else if(str[0] == 'W') {
            cntWA++;
        } else if(str[0] == 'T') {
            cntTLE++;
        } else if(str[0] == 'R') {
            cntRE++;
        }
    }

    printf("AC x %d\n", cntAC);
    printf("WA x %d\n", cntWA);
    printf("TLE x %d\n", cntTLE);
    printf("RE x %d\n", cntRE);

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int n=1;
vi bit;

void init(int N) {
  while(n<N) n*=2;
  bit=vi(n);
}

int sum(int i) {
  int s=0;
  while(i>0) {
    s+=bit[i];
    i-=i&-i;
  }
  return s;
}

void add(int i,int x) {
  while(i<=n) {
    bit[i]+=x;
    i+=i&-i;
  }
}

int main() {
  int N,Q;
  cin >> N >> Q;
  vi c(N);
  rep(i,N) cin >> c[i];
  vi l(Q),r(Q),ans(Q);
  vector<tiii> sec(Q);
  rep(i,Q) {
    cin >> l[i] >> r[i];
    get<0>(sec[i])=r[i];
    get<1>(sec[i])=l[i];
    get<2>(sec[i])=i;
  }
  
  init(N);
  sort(sec.begin(),sec.end());
  vi last(N,-1);
  int R=1;
  rep(i,Q) {
    while(R<=get<0>(sec[i])) {
      if(last[c[R-1]-1]!=-1) add(last[c[R-1]-1],-1);
      last[c[R-1]-1]=R;
      add(R,1);
      R++;
    }
    ans[get<2>(sec[i])]=sum(get<0>(sec[i]))-sum(get<1>(sec[i])-1);
  }
  
  rep(i,Q) cout << ans[i] << endl;
}

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

int main()
{
    int N;
    cin>>N;
    vector<vector<int>> A(N, vector<int>(N));
    for (int y=0; y<N; y++)
        for (int x=0; x<N-1; x++)
            cin>>A[y][x],
            A[y][x]--;

    vector<int> P(N);
    vector<vector<pair<int, int>>> T(N*(N-1)/2);
    for (int i=0; i<N; i++)
        if (i<A[i][0] && A[A[i][0]][0]==i)
            T[0].push_back(make_pair(i, A[i][0]));
    int d;
    for (d=0; d<N*(N-1)/2 && !T[d].empty(); d++)
    {
        for (int i=0; i<(int)T[d].size(); i++)
        {
            int x = T[d][i].first;
            int y = T[d][i].second;

            P[x]++;
            P[y]++;

            if (P[x]<N-1)
            {
                int t = A[x][P[x]];
                if (x==A[t][P[t]])
                    T[d+1].push_back(make_pair(x, t));
            }
            if (P[y]<N-1)
            {
                int t = A[y][P[y]];
                if (y==A[t][P[t]])
                    T[d+1].push_back(make_pair(y, t));
            }
        }
    }

    for (int i=0; i<N; i++)
        if (P[i]<N-1)
        {
            cout<<-1<<endl;
            return 0;
        }
    cout<<d<<endl;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  string S;
  cin >> S;
  if(S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi") {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	vector<int> in(n,0);
	vector<int> used(n,0);
	int d[101001]={};
	int ans=0;
	FOR(i,0,n){
		cin>>a[i];
		a[i]--;
		if(i==0){
			if(a[i]!=0){
				ans++;
				a[i]=0;
			}
			continue;
		}
		//g[i].PB(a[i]);
		in[a[i]]++;
	}
	queue<int> q;
	used[0]=1;
	FOR(i,1,n){
		if(in[i]==0)q.push(i);
	}
	while (q.size()) {
		int nw=q.front();
		q.pop();
		int nd=d[nw];
		//cerr<<nw<<" "<<nd<<endl;
		if(used[nw])continue;
		used[nw]=1;
		if(nd>=k-1&&a[nw]!=0){
			ans++;
		}else{
			if(a[nw]!=0)d[a[nw]]=max(d[a[nw]],nd+1);
		}
		in[a[nw]]--;
		if(in[a[nw]]==0)q.push(a[nw]);

	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 2176