akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  int key;
  struct node *n,*p;
};

struct node* nil;

struct node* search(int key){
  struct node* c;
  c=nil->n;
  while(c != nil && c->key != key){
    c=c->n;
  }
  return c;
}

void init(){
  nil=(struct node *)malloc(sizeof(struct node));
  nil->n=nil;
  nil->p=nil;
}

void printlist(){
  struct node* c;
  int ss;

  c=nil->n;
  ss=0;

  while(1){
    if(c == nil)break;
    if(ss++>0)printf(" ");
    printf("%d",c->key);
    c=c->n;
  }
  printf("\n");
}

void Dnode(struct node* t){
  if(t == nil)return;
  t->p->n=t->n;
  t->n->p=t->p;
  free(t);
}
void Dfirst(){
  Dnode(nil->n);
}

void Dlast(){
  Dnode(nil->p);
}

void Dkey(int key){
  Dnode(search(key));
}

void insert(int key){
  struct node *x =(struct node *)malloc(sizeof(struct node));
  x->key=key;
  x->n=nil->n;
  nil->n->p=x;
  nil->n =x;
  x->p=nil;
}

int main(){
  int key,i,n,ss;
  ss = 0;
  char s[20];
  int n1=0,n2=0;


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

  for(i=0;i<n;i++){
    scanf("%s",s);
    if(s[0] == 'i'){
      scanf("%d", &key);
      insert(key);
      n1++;
      ss++;
    }
    else if(s[0] == 'd'){
      if(strlen(s) > 6){
	if(s[6] == 'F')Dfirst();
	else if(s[6] == 'L')Dlast();
      }else{
	scanf("%d", &key);
	Dkey(key);
	n2++;
      }
      ss--;
    }
  }
  printlist();

  return 0;
}
 


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int N, M;
    cin >> N >> M;
    vector<pair<int, int> >G[N];
    rep(i, 0, M) {
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        G[l].push_back(make_pair(r, d));
        G[r].push_back(make_pair(l, -d));
    }

    int score[N], vis[N];
    memset(score, 0, sizeof(score));
    memset(vis, 0, sizeof(vis));

    rep(i, 0, N) {
        if(not vis[i]) {
            vis[i] = 1;
            score[i] = 0;
            queue<int> q;
            q.push(i);
            while(!q.empty()) {
                int v = q.front(); q.pop();
                rep(p, 0, G[v].size()) {
                    if(vis[G[v][p].first]) {
                        if(score[v] + G[v][p].second != score[G[v][p].first]) {
                            cout << "No" << endl;
                            return 0;
                        }
                    } else {
                        score[G[v][p].first] = score[v] + G[v][p].second;
                        vis[G[v][p].first] = 1;
                        q.push(G[v][p].first);
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  string s;
  cin >> s;
  if(s[(int)s.size()-1]=='s'){
    cout << s << "es" << endl;
  }
  else{
    cout << s << 's' << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int n, k;
int du[5];
int cn[5];
int main()
{
for (int i = 1, x, y; i <=  3; ++i)
{
cin >> x >> y;
++du[x], ++du[y];
}
for (int i = 1; i <= 4; ++i)
++cn[du[i]];
if (cn[1] == 2 && cn[2] == 2)
cout << "YES";
else cout << "NO";
}

Measured memory_bytes: 256
N_str, q_str = raw_input().split()
N = int(N_str)
q = int(q_str)

A = []
B = []

for i in range(N):
    a = raw_input().split()
    A.append([a[0], int(a[1])])

total_time = 0
while A:
    name, time = A.pop(0)
    if time <= q:
        total_time += time 
        B.append("%s %d" % (name, total_time))
    else:
        time -= q
        A.append([name, time])
        total_time += q
print '\n'.join(B)

Measured memory_bytes: 17340
#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,a,b,c;
	cin>>n>>a>>b>>c;
	vector<int> v(n);
	FOR(i,0,n){
		cin>>v[i];
	}
	int ans=mod;
	FOR(i,0,(1<<(2*n))){
		int na=0,nb=0,nc=0;
		int aa=0,bb=0,cc=0;
		FOR(j,0,2*n){
			int t=(i>>j)&3;
			if(t==0){
				na++;
				aa+=v[j/2];
			}
			if(t==1){
				nb++;
				bb+=v[j/2];
			}
			if(t==2){
				nc++;
				cc+=v[j/2];
			}
			j++;
		}
		if(na==0||nb==0||nc==0){
			continue;
		}
		int cst=(na+nb+nc-3)*10+abs(aa-a)+abs(bb-b)+abs(cc-c);
		ans=min(ans,cst);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //入力を保持する
        var XN = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
        var X = XN[0];
        var N = XN[1];
        //Ps配列が空の場合はXを出力して回答とする
        if (N == 0)
        {
            Console.WriteLine(X);
            return;
        }
        var Ps = Console.ReadLine().Split().Select(e => int.Parse(e)).ToArray();
        //Psを昇順に並び替える
        Array.Sort(Ps);
        //NのPs内に存在するかチェック
        var idx = Array.IndexOf(Ps, X);
        //NがPs配列に存在しない場合はXを出力して回答とする
        if (idx == -1)
        {
            Console.WriteLine(X);
            return;
        }

        //Ps内に含まれないXに最も近い数字を±1をしながら検索する
        var n = 1;
        while (true)
        {
            if (Array.IndexOf(Ps, X - n) == -1)
            {
                Console.WriteLine(X - n);
                break;
            }
            if (Array.IndexOf(Ps, X + n) == -1)
            {
                Console.WriteLine(X + n);
                break;
            }
            n += 1;

        }
    }
}



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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    string s;
    cin>> s;
    rep(i,3){
        if(s[i] == '7'){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 3624
s = input().strip()
sset = set(s)
ans = pow(100, 3)
for ss in sset:
  tmps = s
  c = 0
  while tmps.count(ss) != len(tmps):
    _tmps = ''
    for ps, ns in zip(tmps, tmps[1:]):
      if ps == ss or ns == ss:
        _tmps += ss
      else:
        _tmps += ps
    tmps = _tmps
    c += 1
  if ans > c:
    ans = c
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;cin >> n >> m;vector<pp> v(n);
    for (int i = 0; i < n; ++i)
    {
    	cin >> v[i].second >> v[i].first;
    }
    sort(v.begin(),v.end(),[&](pp p1,pp p2)
    	{
    		return p1.first>p2.first;
    	});
    set<ll> s;
    for(int i=1;i<=m;i++)s.insert(i);int ans=0;
    for (int i = 0; i < v.size(); ++i)
    {
    	int d=m-v[i].second+1;
    	auto it=s.upper_bound(d);
    	if(it!=s.begin())
    	{
    		ans+=v[i].first;
    		it--;
    		s.erase(it);
    	}
    }
    cout << ans;
    }

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    int n;
    cin>>n;
    if(n%2==0)
    {
        cout<<n/2;
    }
    else
    {
        cout<<n/2+1;
    }
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b!=c){
        cout<<"Yes"<<endl;
    }
    else if(a==c&&a!=b){
cout<<"Yes"<<endl;
    }
    else if(b==c&&b!=a){
cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <utility>
using namespace std;
typedef pair<double, double> PDD;
PDD calc(double mat[2][2], double vec[2]){
  double a = mat[0][0], b = mat[0][1], d = mat[1][0], e = mat[1][1];
  double c = vec[0], f = vec[1];
  double det = a * e - d * b;
  return make_pair((e * c - b * f) / det, (-c * d + a * f) / det);
}
int main(){
  double mat[2][2];
  double vec[2];
  while(cin >> mat[0][0] >> mat[0][1] >> vec[0] >> mat[1][0] >> mat[1][1] >> vec[1]){
    PDD res = calc(mat, vec);
    double x = (double)(round(res.first*1000))/1000.0, y = (double)(round(res.second*1000))/1000.0;
    x = (x == -0.0) ? 0.0 : x;
    y = (y == -0.0) ? 0.0 : y;
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

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

int main(){
    int n; cin >> n;
    int cnt = 0;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 1; i < n-1; i++){
        if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1])){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
    fast;
    lli n;
    cin>>n;
    if(n>=30)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    return 0;
}

Measured memory_bytes: 3624
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

#define NOTHING (-1)

main :: IO ()
main = do
    [n, m] <- map read.words <$> getLine :: IO [Int]
    digits <- V.unfoldrN m (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n digits

solve :: Int -> V.Vector Int -> Integer
solve n digits = memo V.! n
  where
    memo = V.generate (n + 1) $ \case
        0 -> 0
        i -> V.maximum . flip V.map digits $ \digit ->
            if  | cost U.! digit <= i -> case memo V.! (i - cost U.! digit) of
                    NOTHING -> NOTHING
                    x -> 10 * x + fromIntegral digit
                | otherwise -> NOTHING

cost :: U.Vector Int
cost = U.fromList [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

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

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

const int N = int(1e8) + 7;

ll lcm(ll a, ll b){
    return a/__gcd(a,b)*b;
}

ll count(ll a, ll b, ll d){
    return (b/d)- ((a-1)/d);
}

void init(){

}

void solve(){
    ll a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ll l = count(a,b,lcm(c,d));
    ll p = count(a,b,c) + count(a,b,d);
    printf("%lld\n", b-a+1-p+l);

}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


Measured memory_bytes: 256
#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;
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






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



  ll a, b, c;
  cin >> a >> b >> c;
  n = a - b;
  cout << max(0LL, c - n) << endl;





  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

const int INF = 1001001001;

int main()
{
    int n, q;
    cin >> n >> q;
    
    set<pii> S;
    unordered_map<int, int> m;
    
    rep(i, q){
        int a, v;
        cin >> a >> v;
        if(m.count(a)) S.erase(pii(m[a], a));
        m[a] -= v;
        S.insert(pii(m[a], a));
        cout << S.begin()->second << ' ' << -S.begin()->first << endl;
    }
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;
    vector<char> c(2*N);
    vector<int> a(2*N);
    rep(i,0,2*N){
        cin >> c[i] >> a[i];
        --a[i];
    }

    i64 ans=0;
    rep(i,0,N){
        int ma=N-i-1;
        {
            int p;
            rep(j,0,2*N) if(c[j]=='W' and a[j]==ma){
                p=j;
                break;
            }
            rep(j,p+1,2*N) if(c[j]=='W' and a[j]<ma) ++ans;
        }
         {
            int p;
            rep(j,0,2*N) if(c[j]=='B' and a[j]==ma){
                p=j;
                break;
            }
            rep(j,p+1,2*N) if(c[j]=='B' and a[j]<ma) ++ans;
        }
    }
    
    vector<i64> s(N),t(N);
    rep(i,0,2*N){
        if(c[i]=='W') s[a[i]]=i;
        else t[a[i]]=i;
    }

    vector<vector<i64>> w(2*N+1),b(2*N+1);
    for(int i=2*N-1; i>=0; --i){
        w[i]=w[i+1];
        b[i]=b[i+1];
        if(c[i]=='W') w[i].push_back(a[i]);
        else b[i].push_back(a[i]);
        sort(begin(w[i]),end(w[i]));
        sort(begin(b[i]),end(b[i]));
    }

    function<i64(int,int)> f=[&](int i,int j){
        return upper_bound(begin(b[s[i]+1]),end(b[s[i]+1]),j)-begin(b[s[i]+1]);
    };

    function<i64(int,int)> g=[&](int i,int j){
        return upper_bound(begin(w[t[i]+1]),end(w[t[i]+1]),j)-begin(w[t[i]+1]);
    };

    static i64 dp[2048][2048];
    fill_n((i64*)dp,2048*2048,inf64);

    rep(i,0,N+1) dp[i][0]=dp[0][i]=0;

    rep(i,1,N+1) rep(j,1,N+1){
        dp[i][j]=min(dp[i][j],dp[i-1][j]+f(i-1,j-1));
        dp[i][j]=min(dp[i][j],dp[i][j-1]+g(j-1,i-1));
    }

    cout << ans+dp[N][N] << endl;
}

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


Measured memory_bytes: 117632
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0){
		solve(n);
	    }
	}
    }

    static void solve(int n){
	int maxX=0, minX=0, maxY=0, minY=0;
	int i=0;
	int[][] box = new int[n][2];
	i++;

	for(; i<n; i++){
	    int num = kbd.nextInt();
	    int d = kbd.nextInt();
	    setBox(num, d, box, i);
	}

	for(i=0; i<n; i++){
	    if(box[i][0]>maxX) maxX=box[i][0];
	    if(box[i][0]<minX) minX=box[i][0];
	    if(box[i][1]>maxY) maxY=box[i][1];
	    if(box[i][1]<minY) minY=box[i][1];
	}

	System.out.println((maxX-minX+1)+" "+(maxY-minY+1));
    }

    static void setBox(int num, int d, int[][] box, int i){
	int x = box[num][0];
	int y = box[num][1];

	if(d==0){ x--; }
	else if(d==1){ y--; }
	else if(d==2){ x++; }
	else if(d==3){ y++; }

	box[i][0] = x;
	box[i][1] = y;
    }
}

Measured memory_bytes: 35264
#include <cmath>
#include <fstream>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

#define REP(i, x, n) for(int i = x, i##_len=(n); i < i##_len; i++)
#define rep(i,n) REP(i,0,n)
//#define DEBUG 2

void run() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	if (sx == tx) {
		rep(i, ty - sy) cout << 'U';
		cout << 'R';
		rep(i, ty - sy) cout << 'L';
		cout << "LL";
		rep(i, ty - sy) cout << 'U';
		cout << "RULL";
		rep(i, ty - sy + 2) cout << 'D';
		cout << "RRU";
	}
	else if (sy == ty) {
		rep(i, tx - sx) cout << 'R';
		cout << 'U';
		rep(i, tx - sx) cout << 'L';
		cout << "DD";
		rep(i, tx - sx) cout << 'R';
		cout << "URDD";
		rep(i, tx - sx + 2) cout << 'L';
		cout << "UUR";
	}
	else {
		rep(i, tx - sx) cout << 'R';
		rep(i, ty - sy) cout << 'U';
		rep(i, tx - sx) cout << 'L';
		rep(i, ty - sy) cout << 'D';
		cout << 'L';
		rep(i, ty - sy + 1) cout << 'U';
		rep(i, tx - sx + 1) cout << 'R';
		cout << "DR";
		rep(i, ty - sy + 1) cout << 'D';
		rep(i, tx - sx + 1) cout << 'L';
		cout << 'U';
	}
	cout << endl;
}

int main() {
#ifdef DEBUG
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	rep(i, DEBUG) {
		cout << "cnt:" << i << " ------------" << endl;
		run();
	}
#else
	run();
#endif
	return 0;
}


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

ll func( ll n, ll x )
{
    if ( n >= x )
    {
        return n / x + func(n,x*5);
    }
    else
        return 0;
}

int main( void )
{
    ll n;
    cin >> n;
    
    if ( n % 2 == 1 )
    {
        cout << 0 <<  endl;
    }
    else
    {
        ll ans = func(n,10);
        cout << ans <<  endl;
    }
}

Measured memory_bytes: 256
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU DONT LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define inv (mod+1)/3
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;while(t--)
ll zero=0;
ll one=1;
ll gcd(ll a,ll b){    if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) {    return (a/gcd(a,b)*b);}
ll expo(ll x, ll y) {ll res=1;x=x%mod;while(y>0){if(y&1)res=(1ll*res*x)%mod;
    y=y>>1;x=(1ll*x*x)%mod;} return res;}
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime(ll n){ll i;for(i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return(a.second<=b.second);}

//https://www.youtube.com/watch?v=k4V3Mo61fJM

ll rr[]={0,1,1,1,0,-1,-1,-1,};
ll cc[]={1,1,0,-1,-1,-1,0,1};

signed main()
{
    bolt;
    ll h,a,c=0;cin>>h>>a;
    while(h>0)
        h-=a,c++;
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<ll,ll>
#define prr pair<pr,ll>
#define ll long long int
#define ld long double
const ll mod=1e9+7;
const int N=2e5+5;
void solve(){
    int n,m;
    ll k;
    cin>>n>>m>>k;
    ll a[n];
    fr(i,0,n)
    cin>>a[i];
    ll pre[n];
    pre[0]=a[0];
    fr(i,1,n)
    pre[i]=pre[i-1]+a[i];
    set<pair<ll,int> > st;
    ll last=0;
    fr(i,0,m){
        ll x;
        cin>>x;
        last+=x;
        st.insert({-last,i});
    }
    int ans=0;
    auto it=st.lower_bound({-k,-1});
    if(it!=st.end()){
        ans=it->second+1;
    }
    fr(i,0,n){
        if(pre[i]>k)
        break;
        auto it=st.lower_bound({-(k-pre[i]),-1});
        if(it==st.end()){
            ans=max(ans,i+1);
        }
        else
        ans=max(ans,i+1+(it->second+1));
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 19280
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

#define ri(b,c) for(ll i=(b);i<(c);++i)
#define rj(b,c) for(ll j=(b);j<(c);++j)
#define rk(b,c) for(ll k=(b);k<(c);++k)
#define rl(b,c) for(ll l=(b);l<(c);++l)
#define rr(b,c) for(ll r=(b);r>(c);--r)
#define fcout cout<<fixed<<setprecision(10)
#define a_m a,b,c,d,e,f,g,h,i,j,k,l,m
#define n_z n,o,p,q,r,s,t,u,v,w,x,y,z
#define p50 614889782588491410
#define isprime(a) gcd(p50,a)==1

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

	ll a_m,n_z;
	cin>>a>>b;



    if(a*b==15)cout<<"*"<<"\n";
	else if(a+b==15)cout<<"+"<<"\n";
    else cout<<"x"<<"\n";
}


Measured memory_bytes: 256
n=int(input())
city={}

for i in range(1,n+1):
    c,p=input().split()
    p=int(p)

    if c in city:
        city[c].append((i,p))
    else:
        city[c]=[(i,p)]

clst=sorted(list(city.keys()))

for c in clst:
    plst=sorted(city[c],key=lambda x:x[1],reverse=True)

    for i,_ in plst:
        print(i)


Measured memory_bytes: 62920
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextLongList()
    var ans = A.reduceIndexed { i, a, b -> if (i and 1 == 0) a + b else a - b }
    for (a in A) {
        print("$ans ")
        ans = ans * (-1) + a * 2
    }
    println()
}

Measured memory_bytes: 59320
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;int64_t x;
 cin>>N>>x;
 vector<int>a(N);
 for(int i=0;i<N;i++){cin>>a.at(i);}
 sort(a.begin(),a.end());
 int64_t sum=0;
 for(int i=0;i<N;i++){
   sum+=a.at(i);}

 if(sum==x){cout<<N<<endl;}
 else if(sum<x){cout<<N-1<<endl;}
 else if(sum>x){int count=0;for(int i=0;i<N;i++){if(x-a.at(i)>=0){x-=a.at(i);count++;}}cout<<count<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

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

	int count = 0;

	REP(i, n){
		if (a[i] == a[i+1]){
			count++;
			a[i+1] = -1;
		}
	}

	cout << count << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define clr(a,n) memset(a,0,sizeof(int)*((n)+1))
#define N 410
#define M 100010
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
struct edges{
	int to,pre,id;
}e[M<<1];int a[N][N],t[N],h[N],etop,ok[N];
inline int add_edge(int u,int v,int id)
{	return e[++etop].to=v,e[etop].pre=h[u],h[u]=etop,e[etop].id=id;	}
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int dfs(int x,int *a,int &ok)
{
	if(!ok) return 0;a[x]=1;
	for(int i=h[x],y;i;i=e[i].pre)
		if(e[i].id<t[x])
		{
			if(t[y=e[i].to]) return ok=0;
			t[y]=e[i].id,dfs(y,a,ok);
			if(!ok) return 0;
		}
	return 0;
}
inline int can(int *a,int *b,int n)
{
	for(int i=1;i<=n;i++)
		if(a[i]+b[i]==2) return 0;
	return 1;
}
int main()
{
	int n=inn(),m=inn(),ans=0;
	for(int i=1,u,v;i<=m;i++)
		u=inn(),v=inn(),add_edge(u,v,i),add_edge(v,u,i);
	for(int i=1;i<=n;i++)
		clr(t,n),t[i]=m+1,ok[i]=1,dfs(i,a[i],ok[i]);
	for(int i=1;i<=n;i++) if(ok[i])
		for(int j=i+1;j<=n;j++) if(ok[j])
			ans+=can(a[i],a[j],n);
	return !printf("%d\n",ans);
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
ll MOD = 1e9 + 7;
int main() {
    ll n, a, b, c, d, ans, s;
    cin >> s;
    vector<ll>dp(2001,0);
    dp[0] = 1;
    for (int i = 3; i<=2000; i++) {
        rep(j, i-2){
            dp[i] = (dp[i]+dp[j])%MOD;
        }
    }
    cout << dp[s] << endl;
    return 0;
}



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

int main(){
  string S, T;
  cin >> S >> T;
  
  int count=0;
  
  if(S.at(0)==T.at(0)) count++;
  if(S.at(1)==T.at(1)) count++;
  if(S.at(2)==T.at(2)) count++;
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
L, R = map(int, input().split())

if R-L >= 2018:
    ans = 0
else:
    L = L%2019
    R = R%2019
    if L >= R :
        ans = 0
    else:
        ans = 2019
        for i in range(L, R):
            for j in range(i+1, R+1):
                mod_num = (i*j)%2019
                if ans > mod_num:
                    ans = mod_num
print(ans)


Measured memory_bytes: 3060
# D - Line++
def main():
    N, X, Y = map(int, input().split())
    dist = [0] * N
    calc_min_dist = lambda x, y: min(
        y - x, abs(X - x) + abs(y - Y) + 1, abs(Y - x) + abs(y - X) + 1
    )
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist[calc_min_dist(i, j)] += 1
    print("\n".join(map(str, dist[1:])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
	int x[2011] = {0};
	int r,d,i;
	scanf("%d %d %d",&r,&d,&x[2000]);
	for(i=2000;i<=2010;i++)
	{
		x[i+1] = x[i]*r - d;
	}
	for(i=2001;i<=2010;i++)
	{
		printf("%d\n",x[i]);
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){

	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(0<=a && c<=100){
		if ( a<b && b<c && a<c){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1808
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,a=0;
	cin>>N;
	for(int i=1;i<=N;i++){
		a=a+i;
	}
	cout<<a<<endl;
	
}

Measured memory_bytes: 256
D = [[1,0],[0,-1],[-1,0],[0,1]]
 
def dfs(x, y)
  if $fld[y][x] == "B"
    $flag_b = true
    return
  elsif $fld[y][x] == "W"
    $flag_w = true
    return
  end
  $cnt += 1
  $vst[y][x] = true
  D.each do |dx, dy|
    nx, ny = x + dx, y + dy
    if nx >= 0 && nx < $w && ny >= 0 && ny < $h && !$vst[ny][nx]
      dfs(nx, ny)
    end
  end
end
 
loop do
  $w, $h = gets.split.map(&:to_i)
  break if $w == 0
  $fld = $h.times.map{ gets.chomp.split("") }
  
  cw = cb = 0
  $vst = $h.times.map{ [false]*$w }
  for i in (0...$h)
    for j in (0...$w)
      if $fld[i][j] == "." && !$vst[i][j]
        $flag_b = $flag_w = false
        $cnt = 0
        dfs(j, i) 
        cb += $cnt if $flag_b && !$flag_w
        cw += $cnt if !$flag_b && $flag_w
      end
    end
  end
  puts "#{cb} #{cw}"
end

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 1e5 + 5;

int P[N],PP[N],n,i;
char A[N];

int main(){
    cin >> A+1;
    n = strlen(A+1);
    for(i=1;i<=n;i++){
        P[i] = P[i-1] + (A[i] == '1');
        PP[i] = PP[i-1] + (A[i] == '0');
    }

    for(i=n ;i>(n+1>>1); i--)
        if(P[i] == P[n-i] || PP[i] == PP[n-i])
            break;
    
    cout << i;
    return 0;
}

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

int main() {
  vector<vector<int>> C(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> C.at(i).at(j);
    }
  }
  for (int a1 = 0; a1 <= 100; a1++) {
    vector<int> B = {C.at(0).at(0) - a1, C.at(1).at(0) - a1, C.at(2).at(0) - a1};
    vector<int> A = {C.at(0).at(0) - B.at(0), C.at(0).at(1) - B.at(0), C.at(0).at(2) - B.at(0)};
    bool b = 1;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (B.at(i) + A.at(j) != C.at(i).at(j)) b = 0;
      }
    }
    if (b) return cout << "Yes" << "\n", 0;
  }
  cout << "No" << "\n";
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int DX[2] = {1, 0};
int DY[2] = {0, 1};

int dfs(int x, int y, int a, int N, vector<vector<int>> A){
  int a_new = a + A[x][y];
  if(x == 1 && y == N-1){
    return a_new;
  }else{
    int a_max = 0;
    REP(i, 2){
      if(x + DX[i] < 2 && y + DY[i] < N){
	a_max = max(a_max, dfs(x+DX[i], y+DY[i], a_new, N, A));
      }
    }
    return a_max;
  }
}


int main(void){

  int N;
  cin >> N;
  
  vector<vector<int>> A(2, vector<int>(N));
  REP(i, 2){
    REP(j, N){
      cin >> A[i][j];
    }
  }

  cout << dfs(0, 0, 0, N, A) << endl;

  return 0;
}


Measured memory_bytes: 384
//  ######    ##   ######    ##   ##    ##
//  ##  ##   ###   ##  ##   ###   ###   ##
//  ######  ####   ######  ####   ##### ##
//  ##     ## ##   ##     ## ##   ## #####
//  ##    ##  ##   ##    ##  ##   ##   ###
#include<bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(b);i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(d);j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for((a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for((a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRvl(c) for (vl::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvll(c) for (vll::iterator it = (c).begin(); it != (c).end(); it++)
#define mod 1000000007
#define gc getchar_unlocked
#define pc putchar_unlocked3
#define pb(a) push_back((a))
 
int arr[]={31,28,31,30,31,30,31,31,30,31,30,31};

void solve()
{
    /*nt n;
    cin>>n;
    int l=1,r=n-1;
    while(l<=r)
    {
        float mid = (l+r)/2;
        if(int(mid*1.08)==n){cout<<mid;return;}
        if(int(mid*1.08)>n)r=mid-1;
        else l=mid+1;
    }
    cout<<":(";*/

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a==c)cout<<"0";
    else cout<<"1";
}


int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    */
    
    lo t;
    //cin>>t;
    //while(t--)
        solve();




}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int n;
  double l;
  const double PI=3.1415926535;
  while(scanf("%d",&n),n+1){
    double x=1,y=0;
    double r=PI/2;
    while(--n){
      l=hypot(x,y);
      y+=sin(r);
      x+=cos(r);
      r+=atan(1/l);//printf("%f\n",r/PI);
    }
    printf("%f\n%f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 704
#include<bits/stdc++.h>
using namespace std;
int main(){
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;
  for(int i = L; i < R + 1; i++){
    if(i%d == 0){
      ans++;
    }else{
      continue;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
// Custom Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)
#define LF          '\n'

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '\0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}}

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

    char s[32];
    cin >> s;

    rep(i, 4) cout << s[i];
    cout << ' ';
    reps(i, 4, 11) cout << s[i];
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
int N;

signed main()
{
    cin >> N;
    vector<int> p(N + 1);
    for (int i = 1; i <= N; ++i) {
        cin >> p[i];
    }
    int cnt = 0;
    for (int i = 1; i < N; ++i) {
        if (p[i] == i) {
            swap(p[i], p[i + 1]);
            ++cnt;
        }
    }
    if (p[N] == N) {
        ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

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

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

let main() =
    let a =
        reada int
        |> Array.distinct
        |> Array.length
    if a = 2 then "Yes" else "No"
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 14176
#include <iostream>
#include <string>
#include <vector>

const int max_key_length = 12;

class Dictionary
{
    std::vector<int> _keys;
    int _char_to_id(char);
    int _to_hash(std::string);
public:
    Dictionary();
    ~Dictionary();
    void insert(std::string);
    bool find(std::string);
};

Dictionary::Dictionary() {
    int max_hashsize = 0;
    int w = 1;
    for (int i = 0; i < max_key_length; i++) {
        max_hashsize += 4 * w;
        w *= 4;
    }
    _keys.resize(max_hashsize);
}

Dictionary::~Dictionary() {
    ;
}

int Dictionary::_char_to_id(char c) {
    switch (c) {
        case 'A': return 1;
        case 'C': return 2;
        case 'G': return 3;
        case 'T': return 4;
    }

    // default
    return 0;
}

int Dictionary::_to_hash(std::string word) {
    int val = 0;
    int w = 1;
    for (int i = 0; i < word.length(); i++) {
        val += _char_to_id(word[i]) * w;
        w *= 4;
    }

    return val;
}

void Dictionary::insert(std::string word) {
    _keys[_to_hash(word)] = true;
}

bool Dictionary::find(std::string word) {
    return _keys[_to_hash(word)];
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;

    Dictionary dict;
    std::string op;
    std::string word;
    for (int i = 0; i < n; i++) {
        std::cin >> op;
        std::cin >> word;
        if (op[0] == 'i') {
            dict.insert(word);
        } else if (op[0] == 'f') {
            if (dict.find(word))
                std::cout << "yes" << std::endl;
            else
                std::cout << "no" << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 88504
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll n,k;
//ld ;
//string s;
 
int main() {
  cin >> n >> k;
  int sunuke[n];
  for(ll i=0;i<n;i++){
    sunuke[i] = 1;
  }
  for(ll i=0;i<k;i++){
    ll d = 0;
    cin >> d;
    for(ll j=0;j<d;j++){
      ll snk = 0;
      cin >> snk;
      if(sunuke[snk-1]==1)sunuke[snk-1] = 0;
    }
  }
  ll total = 0;
  for(ll i=0;i<n;i++){
    total += sunuke[i];
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
using namespace std;

// #define __DEBUG__

#ifdef __DEBUG__
bool debug_disabled = false;
#else
bool debug_disabled = true;
#endif

#define dbg if (debug_disabled) {} else cerr

void solve() {
    int n;
    cin >> n;
    int d = n % 10;
    if (d == 2 || d == 4 || d == 5 || d == 7 || d == 9) cout << "hon" << endl;
    else if (d == 0 || d == 1 || d == 6 || d == 8) cout << "pon" << endl;
    else cout << "bon" << endl;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3612
# coding: utf-8
# Your code here!

N,K = map(int,input().split())

ans = 0

for i in range(1,N+1):
    prob = 1/N
    score = i
    
    while(score < K):
        score *= 2
        prob *= 0.5
        
    ans += prob
    
print(ans)

Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char h[1000010];
	int ans=0;
	cin>>h;
	for(int i=1;i<strlen(h);i++)
	{
		if(h[i]!=h[i-1])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

int main(){
    lli a,b,c;
    string ans="No";
    lli i,j;
    cin>>a>>b>>c;
    if(c-a-b>0){
        if(4*a*b<(c-a-b)*(c-a-b)){
            ans="Yes";
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   int t, a;
   cin >> t >> a;
   vector<int> h(n);
   rep(i, 0, n) { cin >> h[i]; }
   int dd = INF;
   int ans = 0;
   rep(i, 0, n) {
      if (abs(t * 1000 - h[i] * 6 - a*1000) < dd) {
         dd = abs(t * 1000 - h[i] * 6 - a*1000);
         ans = i + 1;
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cont = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                cont += 1

print(cont)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K; cin >> N >> K;
    string S; cin >> S;
    // tolower + transform
    transform(S.begin() + (K - 1), S.begin() + K, S.begin() + (K - 1), [](unsigned char c){ return std::tolower(c); });
    cout << S << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632