akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
char walls[5][5][2];

int main()
{
	int x=0,y=0,flag=1;
	string tmp;
	for(int i = 0; i < 9; ++i)
	{
		flag=(flag+1)%2;
		cin>>tmp;
		for(int j = 0; j < 5; ++j)
		{
			if(!flag&&j==4) walls[i/2][4][flag]='0';
			else walls[i/2][j][flag]=tmp[j];
			//cin>>walls[i/2][j][flag];
		}
	}

	/*cout<<"debug"<<endl;	
	for(int i = 0; i < 5; ++i)
	{
		for(int j = 0; j < 5; ++j)
		{
			cout<<" "<<walls[i][j][0];
		}
		cout<<endl;
	}
	cout<<endl;
	for(int i = 0; i < 5; ++i)
	{
		for(int j = 0; j < 5; ++j)
		{
			cout<<" "<<walls[i][j][1];
		}
		cout<<endl;
	}*/
	//cout<<"end"<<endl;

	int dir=0;
	bool change=false;
	do {
		if(dir==0)
		{
			if(!change&&0<=y-1&&walls[y-1][x][1]=='1') 
			{
				dir=3;
				change=true;
			}
			else
			{
				if(x==4||walls[y][x][0]=='0')
				{
					dir=1;
					change=true;
				}
				else
				{
					++x;
					cout<<"R";
					change=false;
				}
			}
		}
		else if(dir==1)
		{
			if(!change&&x<4&&walls[y][x][0]=='1')
			{
				dir=0;
				change=true;
			}
			else
			{
				if(y==4||walls[y][x][1]=='0')
				{
					dir=2;
					change=true;
				}
				else
				{
					++y;
					cout<<"D";
					change=false;
				}
			}
		}
		else if(dir==2)
		{
			if(!change&&walls[y][x][1]=='1')
			{
				dir=1;
				change=true;
			}
			else
			{
				if(x==0||walls[y][x-1][0]=='0')
				{
					dir=3;
					change=true;
				}
				else
				{
					--x;
					cout<<"L";
					change=false;
				}
			}
		}
		else if(dir==3)
		{
			if(!change&&0<=x-1&&walls[y][x-1][0]=='1')
			{
				dir=2;
				change=true;
			}
			else
			{
				if(y==0||walls[y-1][x][1]=='0')
				{
					dir=0;
					change=true;
				}
				else
				{
					--y;
					cout<<"U";
					change=false;
				}
			}
		}
		//cout<<",x="<<x<<",y="<<y<<",dir="<<dir<<endl;
	} while(change||x!=0||y!=0);
	cout<<endl;
  return 0;
}

Measured memory_bytes: 1176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

int bitree[2][334334],m;

int query(int i, int p){
	int v=0;
	while(p){
		v += bitree[i][p];
		p -= p&(-p);
	}
	return v;
}

void update(int i, int p, int v){
	int ret=0;
	while(p<=m){
		bitree[i][p] += v;
		p += p&(-p);
	}
}

void addtrain(int l, int r){
	update(0,l,1);
	update(0,r,-1);
	update(1,l,1-l);
	update(1,r,r-1);
}

int cnt(int p){
	int v;
	v = p*query(0,p)+query(1,p);
	--p;
	v -= (p*query(0,p)+query(1,p));
	return v;
}

vector<P> v[300300];

int main(void){
	int n,i,d,l,r,ans;
	cin >> n >> m; ++m;
	for(i=0; i<n; ++i){
		cin >> l >> r; ++r;
		v[r-l].push_back(P(l,r));
	}
	for(d=1; d<m; ++d){
		ans = n;
		for(i=d; i<m; i+=d){
			ans += cnt(i);
		}
		for(i=(v[d].l_ength()-1); i>=0; --i){
			--n;
			addtrain(v[d][i].first,v[d][i].second);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 2e5 + 100;
VI val[N];

struct DSU {
  VI sz, par;
  DSU(int n) {
    par.resize(n);
    iota(par.begin(), par.end(), 0);
    sz.resize(n, 1);
  }
  int find(int u) {
    if (par[u]  == u) return u;
    return par[u] = find(par[u]);
  }
  void merge(int u, int v) {
    u = find(u), v = find(v);
    if (u != v) {
      par[u] = v;
      sz[v] += sz[u];
    }
  }
  int get(int u) {
    return sz[find(u)];
  }
};

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  int m; cin >> m;
  for (int i = 0; i < n; i++) {
    int sz; cin >> sz;
    while (sz--) {
      int x; cin >> x;
      val[x].push_back(i);
    }
  }
  DSU dsu(N + 100);
  for (int x = 1; x <= m; x++) {
    for (int i: val[x]) {
      dsu.merge(i, val[x][0]);
    }
  }
  if (dsu.get(0) == n) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }

  return 0;
}


Measured memory_bytes: 11352
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    for i in range(1, 3501):
        for j in range(i, 3501):
            mod = 4*i*j - n*(i+j)
            if mod > 0 and (n*i*j)%mod == 0:
                k = (n*i*j)//mod
                print(i, j, k)
                exit(0)
    




                
if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#include <iostream>
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


LL POW(LL x,LL y)
{
    LL ans=1;
    LL base=x;
    while(y)
    {
        if(y&1)
        {
            ans*=base;
        }
        base=base*base;
        y=y>>1;
    }
    return ans;
}


int main()
{    
    fastinput;
    LL n,i,j,k,t,temp;
    cin>>n;
    map<string,LL> grid;
    LL maxima=-1;
    string a;
    for(i=0;i<n;i++)
    {
        cin>>a;
        grid[a]++;
        maxima=max(maxima,grid[a]);
    }

    for(auto x:grid)
    {
        if(x.second==maxima)
        {
            cout<<x.first<<endl;
        }
    }

    


    
    return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int n;
	cin>>n;
	long long int minn=1000000000000000;
	for(long long int i=1;i*i<=n;i++){
		if(n%i==0){
			long long int j=n/i;
			long long int x=abs(1-i);
			long long int y=abs(1-j);
			long long int ans=x+y;
			minn=min(minn,ans);
		}
	}
	cout<<minn;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
def inpl(): return list(map(int,input().split()))
N, M = inpl()
X = np.sort(np.array(inpl(),dtype=np.int))

if N >= M:
  print(0)
  exit()
else:
  D = np.sort(X[1:] - X[:-1])
  print(D[:M-N].sum())

Measured memory_bytes: 23028
#include<stdio.h>

int main(){

int st1,st2;

int h1,h2,m1,m2;


int n[8][8]={
{0,300,500,600,700,1350,1650},
{6,0,350,450,600,1150,1500},
{13,7,0,250,400,1000,1350},
{18,12,5,0,250,850,1300},
{23,17,10,5,0,600,1150},
{43,37,30,25,20,0,500},
{58,052,45,40,35,15,0},
};

while(1){
scanf("%d",&st1);if(st1==0)break;

scanf("%d %d",&h1,&m1);

scanf("%d",&st2);
scanf("%d %d",&h2,&m2);

int t1=100*h1+m1;int t2=100*h2+m2;

int T1=st1,T2=st2,S=0;
if(st1>=st2){T1=st2;T2=st1;}

if(((t1>=1730&&t1<=1930)||(t2<=1930&&t2>=1730))&&n[T2-1][T1-1]<=40)
{S=(n[T1-1][T2-1])/2;}
else S=(n[T1-1][T2-1]);
if(S%50!=0){
int QQ=S/50;QQ++;S=QQ*50;
}


printf("%d\n",S);
}
return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
    vector<int> a(5);
    vector<int> v(5);
    vector<pair<int, int>> w(5);
    for(int i = 0; i < 5; i++){
        int tmp = 0;
        cin >> tmp;
        w[i].first = tmp % 10;
        w[i].second = tmp;
    }

    sort(w.begin(), w.end());

    int count = 0;
    int ans = 0;
    for(int i = 0; i < 5; i++){
        if(w[i].first == 0){
            count++;
            ans += w[i].second;
        }
        
    }

    sort(w.begin(), w.end(), greater<pair<int, int>>());
    for(int i = 0; i < 5 - count; i++){
        //cout << w[i].second << endl;
        if(i == 5 - count -1){
            ans += w[i].second;
        }
        else {
            ans += w[i].second + (10 - w[i].first);
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import numpy as np
N,W=list(map(int,input().split()))
DP=np.zeros(W+1,dtype=int)
for i in range(N):
    w,v=list(map(int,input().split()))
    a=DP[:-w]+v
    b=DP[w:]
    DP[w:]=np.fmax(a,b)
print(DP[-1])


Measured memory_bytes: 20492
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
#define X real()
#define Y imag()
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
const double EPS = 1e-8;
const double INF = 1e12;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

typedef vector<P> G;

double compare_x(const P &a, const P &b){
  return a.X != b.X ? a.X < b.X : a.Y < b.Y;
}

double compare_y(const P &a, const P &b){
  return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
}

double convex_radius(P *a, int n){
    if(n <= 1) return INF;
    int m = n / 2;
    double x = a[m].X;
    double d = min(convex_radius(a, m), convex_radius(a + m, n - m));
    sort(a, a + n, compare_y);
    vector<P> b;
    for(int i = 0; i < n; ++i){
        if(fabs(a[i].X - x) >= d) continue;
        for(int j = 0; j < (int)b.size(); ++j){
            P p0 = a[i], p1 = b[(int)(b.size()) - j - 1];
            if(p0.Y - p1.Y >= d) break;
            d = min(d, abs(p0 - p1));
        }
        b.push_back(a[i]);
    }
    return d;
}

int main() {
  int N; cin >>N;
  G g(N);
  REP(i, N){
    double x, y; cin >>x >>y;
    g[i] = P(x, y);
  }
  sort(g.begin(), g.end(), compare_x);
  printf("%.10lf\n", convex_radius(&g[0], N));
  return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

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


int N;
vector<PI> v;
int main(void){
    cin >> N;
    int a, b;
    REP(i,N){
        cin >> a >> b;
        v.push_back(PI(b, a));
    }
    sort(v.begin(), v.end());
    ll current_time = 0;
    REP(i,N){
        if(current_time + v[i].second <= v[i].first){
            current_time += v[i].second;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define matr vector<vector<int> > 
 
#define all(x) x.begin(), x.end()
 
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
int A[maxn]; 
int B[maxn];                      

pii p1 = {0, 0}; 

int dst(pii p) {return p.ff * p.ff + p.ss * p.ss;}

void solve() { 
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i] >> B[i];      
 
    }
    int mx = 0; 
    for (int i = 0; i < 10000; ++i) {
        vector<int> ord;
        for (int j = 0; j < n; ++j) {
            ord.pb(j); 
        }
        shuffle(all(ord), rnd); 
        p1 = {0, 0}; 
        for (int j = 0; j < n; ++j) {
            pii p2 = {p1.ff + A[ord[j]], p1.ss + B[ord[j]]}; 
            if (dst(p2) > dst(p1)) p1 = p2; 
        }
        mx = max(mx, dst(p1)); 
    }
    cout << sqrt(mx); 
}                                    
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 2304
/*input

*/
#include<bits/stdc++.h>

using namespace std;

typedef long long           ll;
typedef vector<int>         vi;
typedef pair<int,int>       ii;

#define endl                '\n'
#define ff                  first
#define pf                  printf
#define ss                  second
#define MX                  109
#define pb                  push_back
#define DB                  pf("Hi\n")
#define pf1(a)              pf("%.0f\n",a)
#define sc1(a)              scanf("%lf",&a)
#define mod(a,m)            (((a%m)+m)%m)
#define all(c)              (c).begin(),(c).end()
#define mem(a,b)            memset(a, b, sizeof(a))
#define RD                  freopen("0iuput.txt","r",stdin)
#define WR                  freopen("0uput.txt","w",stdout)
#define rep(i,a,b)          for(int i=int(a)-(a>b);i!=(b)-(a>b);i+=1-2*(a>b))
#define TC                  int ___T,case_n = 1;scanf("%d ",&___T);while(___T-->0)

int main()
{
    double a,b,c;
    sc1(a);
    sc1(b);
    c = round((a+b)/2);
    pf1(c);
}



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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    string S;

    cin >> S;

    cout << (S[0] == 'o' ? 100 : 0) + (S[1] == 'o' ? 100 : 0) + (S[2] == 'o' ? 100 : 0) + 700 << endl;

    return 0;
}

Measured memory_bytes: 256
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    let mut sum = 0;
    for i in 1..n + 1 {
        let num = i
            .to_string()
            .chars()
            .map(|c| c.to_string())
            .map(|x| x.parse::<usize>().unwrap())
            .fold(0, |sum, i| sum + i);
        if a <= num && num <= b {
            sum += i;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,A[200];
void push(int x)
{
    A[++top]=x;
}
int pop()
{
    top--;
    return A[top+1];
}
int main()
{   int a,b;
    top=0;
    char s[100];
    while(scanf("%s",s)!=EOF)
    {if(s[0]=='+')
    {   a=pop();
        b=pop();
        push(a+b);
    }
    else if(s[0]=='-')
    {   a=pop();
        b=pop();
        push(b-a);
    }
    else if(s[0]=='*')
    {   a=pop();
        b=pop();
        push(a*b);
    }
    else {push(atoi(s));}
    }
    printf("%d\n",pop());
    return 0;
}



Measured memory_bytes: 2036
module Main where

-- import Debug.Trace

{-
 - Next lexicographical permutation algorithm
 - by Project Nayuki, 2016. Public domain.
 - https://www.nayuki.io/page/next-lexicographical-permutation-algorithm
 -
 - Computes the next lexicographical permutation of the specified finite list of numbers.
 - Returns Nothing if the argument is already the highest permutation.
 -}
nextPermutation :: Ord a => [a] -> Maybe [a]
nextPermutation xs =
  let
    len = length xs
    revSuffix = findPrefix (reverse xs)  -- Reverse of longest non-increasing suffix
    suffixLen = length revSuffix
    prefixMinusPivot = take (len - suffixLen - 1) xs
    pivot = xs !! (len - suffixLen - 1)
    suffixHead = takeWhile (<= pivot) revSuffix
    newPivot : suffixTail = drop (length suffixHead) revSuffix
    newSuffix = suffixHead ++ (pivot : suffixTail)
  in
    if suffixLen == len then Nothing else Just (prefixMinusPivot ++ (newPivot : newSuffix))
  where
    findPrefix [] = []
    findPrefix (x:xs) = x : (if xs /= [] && x <= (head xs) then (findPrefix xs) else [])

-- debug = flip trace

permutationEqual a b = all (==True) (zipWith (\a b -> a == b) a b)

solve :: (Int, Maybe [Int], Int, Int) -> (Int, [Int], [Int]) -> (Int, Maybe [Int], Int, Int)
solve (idx, Nothing, pi, qi) (size, ps, qs) = (idx, Nothing, pi, qi)
solve (idx, _, pi, qi) _ | pi /= 0 && qi /= 0 = (idx, Nothing, pi, qi)
solve (idx, Just permutation, pi, qi) (size, ps, qs)
  | permutationEqual permutation ps = (idx + 1, npermutation, idx, qi) -- `debug` (mconcat [show permutation, show npermutation])
  | permutationEqual permutation qs = (idx + 1, npermutation, pi, idx) -- `debug` (mconcat [show permutation, show npermutation])
  | otherwise = (idx + 1, npermutation, pi, qi) -- `debug` (mconcat [show permutation, show npermutation])
  where
    npermutation = nextPermutation permutation

main =
  read <$> getLine >>= \size ->
  fmap (map read . words) getLine >>= \ps ->
  fmap (map read . words) getLine >>= \qs ->
  let
    factorial n = product [1..n]
    (_, _, pi, qi) = foldl solve (1, Just [1..size], 0, 0) [(size, ps, qs) | d <- [1..factorial size]]
    result = abs (pi - qi)
   in
   if permutationEqual ps qs
      then putStrLn "0"
      else putStrLn $ show result


Measured memory_bytes: 1020
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <functional>
#include <tuple>
using namespace std;

int digitsum(int pos) {
	string S = to_string(pos);

	int sum = 0;
	for (int i = 0; i < S.size(); i++) {
		sum += (S[i] - '0');
	}
	return sum;
}

int N, A, B, sum;

int main() {
	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++) {
		int v1 = digitsum(i);
		if (A <= v1 && v1 <= B) sum += i;
	}
	cout << sum << endl;
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll D[200005];
int main()
{
    ll M;
    cin >> M;
    REP(i, M)
    {
        cin >> D[i].first >> D[i].second;
    }

    ll ans = 0;
    vector<ll> v;
    REP(i, M)
    {
        vector<ll> t;
        ll p = D[i].second;
        ll n = D[i].first;
        while (p > 1)
        {
            ans += p / 2LL;
            if (p % 2LL == 1)
                t.push_back(n);
            p /= 2LL;
            n = 2 * n;
            if (n >= 10)
            {
                ans += p;
                n = (n % 10) + 1;
            }
        }
        t.push_back(n);

        stack<ll> s;
        REP(j, t.size())
        {
            s.push(t[t.size() - 1 - j]);
        }
        while (s.size() > 1)
        {
            ll a = s.top();
            s.pop();
            ll b = s.top();
            s.pop();

            ans++;
            ll m = a + b;
            if (m >= 10)
            {
                m = (m % 10) + 1;
                ans++;
            }
            s.push(m);
        }
        ll top = s.top();
        v.push_back(top);
    }

    {
        stack<ll> s;
        REP(i, v.size())
        {
            s.push(v[v.size() - 1 - i]);
        }

        while (s.size() > 1)
        {
            ll a = s.top();
            s.pop();
            ll b = s.top();
            s.pop();

            ans++;
            ll n = a + b;
            if (n >= 10)
            {
                n = (n % 10) + 1;
                ans++;
            }
            s.push(n);
        }
    }

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

Measured memory_bytes: 6640
#include "iostream"
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b,c;
  std::cin >> a >>b >>c;
  if((100*a+10*b+c)%4==0) printf("YES\n");
  else printf("NO\n");
  
  return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(x);
    int sum = 0, tmp = x;
    while (tmp) {
        sum += tmp % 10;
        tmp /= 10;
    }

    cout << ((0 == (x % sum)) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll dp[100010][4];

int main(){
    string S;
    cin >> S;
    dp[0][0] = 1;
    for(int i = 1; i <= S.size(); i++){
        if(S.at(i-1) == 'A'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = (dp[i-1][1] + dp[i-1][0]) % MOD;
            dp[i][2] = dp[i-1][2]; 
            dp[i][3] = dp[i-1][3];
        }else if(S.at(i-1) == 'B'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1];
            dp[i][2] = (dp[i-1][2] + dp[i-1][1]) % MOD;
            dp[i][3] = dp[i-1][3];
        }else if(S.at(i-1) == 'C'){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1];
            dp[i][2] = dp[i-1][2];
            dp[i][3] = (dp[i-1][3] + dp[i-1][2]) % MOD;
        }else{
            dp[i][0] = dp[i-1][0] * 3 % MOD;
            dp[i][1] = dp[i-1][1] * 3 % MOD;
            dp[i][1] += dp[i-1][0];
            dp[i][1] %= MOD;
            dp[i][2] = dp[i-1][2] * 3 % MOD;
            dp[i][2] += dp[i-1][1];
            dp[i][2] %= MOD;
            dp[i][3] = dp[i-1][3] * 3 % MOD;
            dp[i][3] += dp[i-1][2];
            dp[i][3] %= MOD;
        }
    }
    cout << dp[S.size()][3] << endl;
}


Measured memory_bytes: 3584
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    a, b, c = MI()
    return a == b == c


if __name__ == "__main__":
    YESNO(main(), "Yes", "No")


Measured memory_bytes: 5652
FIRST = 1
SECOND = 2

while True:

    score_count = int(input())

    if score_count == 0:
        break

    score_list = []

    for _ in range(score_count):

        total_score = 0
        score_data = [int(item) for item in input().split(" ")]

        last_score = 0
        frame_count = 1
        ball_state = FIRST

        for index, score in enumerate(score_data[1:], 1):

            if frame_count == 10:
                total_score += sum(score_data[index:])
                break

            if last_score + score == 10:
                if ball_state == FIRST:
                    # ストライク
                    total_score += score + score_data[index + 1] + score_data[index + 2]
                else:
                    # スペア
                    total_score += score + score_data[index + 1]
                    ball_state = FIRST
                    last_score = 0

                frame_count += 1

            else:
                # 通常
                total_score += score

                if ball_state == FIRST:
                    ball_state = SECOND
                    last_score = score
                else:
                    ball_state = FIRST
                    last_score = 0
                    frame_count += 1

        score_list.append([score_data[0], total_score])

    score_list.sort(key=lambda x: (-x[1], x[0]))
    output = [str(id) + " " + str(score) for id, score in score_list]
    print("\n".join(output))



Measured memory_bytes: 5624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int X;
  cin >> X;
  //
  
  long long A, B;
  for(A=-1000; A<=1000; A++)
    for(B=-1000; B<=1000; B++)
      if(pow(A, 5) == X+pow(B, 5) ){
	cout<<A<<" "<<B<<endl;
	return 0;
      }



  return 0;
}


Measured memory_bytes: 4028
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
if 2*n<=m:
    print(n+(m-2*n)//4)
else:
    print(m//2)

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> h(N,0);
  int cnt = 0;
  for(int i = 0;i<N;i++)
  {
    cin >> h.at(i);
    if(h.at(i) >= K)
    {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;


#define PI 3.14159265
#define int long long


main(){

	int n, k; cin >> n >> k;


	vector <int> h(n);

	for(int i = 0; i < n; i++){
		cin >> h[i];
	}

	sort(h.begin(), h.end());

	int record = h[k - 1] - h[0];

	for(int i = k; i < n; i++){
		record = min(record, h[i] - h[i - k + 1]);
	}


	cout << record << endl;
	
	return 0;
}

Measured memory_bytes: 1024
//topic8c
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  map< char , int > count;
  string str;
  while( cin>>str ){
    for(int i=0;i<(int)str.size();i++){
      if( isupper(str[i]) ){
        str[i]=tolower(str[i]);
      }
    }
    for(int i=0;i<(int)str.size();i++){
      count[ str[i] ]++;
    }
  }
  for(char ch='a';ch<='z';ch++){
    cout<<ch<<" : "<<count[ch]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3164
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1197
gi = lambda : list(map(int,input().strip().split()))
n, = gi()
l = gi()
ans = 0
m = -1
for e in l:
	if e >= m:
		m = e
		ans += 1
print(ans)

Measured memory_bytes: 3060
n, m = map(int,input().split())
x = []

for i in range(n):
    x.append(list(map(int,input().split())))

ans = []

ans.append(list([ x[i][0]+x[i][1]+x[i][2] for i in range(n)]))
ans.append(list([-x[i][0]+x[i][1]+x[i][2] for i in range(n)]))
ans.append(list([ x[i][0]-x[i][1]+x[i][2] for i in range(n)]))
ans.append(list([ x[i][0]+x[i][1]-x[i][2] for i in range(n)]))

ans.append(list([-x[i][0]-x[i][1]+x[i][2] for i in range(n)]))
ans.append(list([ x[i][0]-x[i][1]-x[i][2] for i in range(n)]))
ans.append(list([-x[i][0]+x[i][1]-x[i][2] for i in range(n)]))
ans.append(list([-x[i][0]-x[i][1]-x[i][2] for i in range(n)]))

for i in range(len(ans)):
    ans[i].sort()
    ans[i] = sum(ans[i][n-m:])

print(max(ans))



Measured memory_bytes: 3696
N = int(input())
A = input().split()
count = 0

for i in range(N):
  A[i] = int(A[i])
for i in range(N-1):
  if A[i] > A[i+1]:
    count += A[i] - A[i+1]
    A[i+1] = A[i]

print(count)

Measured memory_bytes: 25152
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (h2 * 60 + m2 - k) - (h1 * 60 + m1) << '\n';
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#define int long long
#define N 100002
using namespace std;
const int mod=1000000007;
int n,m,i,j,k,a[N],f[20][1<<17],g[1<<17],fac[N],inv[N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
int poww(int a,int b)
{
	int ans=1,base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans;
}
int C(int n,int m)
{
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int count(int x)
{
	int ans=0;
	for(int i=0;(1<<i)<=x;i++){
		if(x&(1<<i)) ans++;
	}
	return ans;
}
signed main()
{
	n=read();m=read();
	for(i=1;i<=m;i++) a[m-i+1]=read();
	for(i=fac[0]=1;i<=(1<<n);i++) fac[i]=fac[i-1]*i%mod;
	inv[1<<n]=poww(fac[1<<n],mod-2);
	for(i=(1<<n)-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	f[0][0]=1;
	for(i=1;i<=m;i++){
		for(j=0;j<(1<<n);j++){
			f[i][j]=(f[i][j]+f[i-1][j])%mod;
			for(k=0;k<n;k++){
				if(!(j&(1<<k))){
					f[i][j|(1<<k)]=(f[i][j|(1<<k)]+f[i-1][j]*C((1<<n)-j-a[i],(1<<k)-1)%mod*fac[1<<k]%mod)%mod;
				}
			}
		}
	}
	for(i=0;i<(1<<n);i++) g[i]=f[m][i]*fac[(1<<n)-i-1]%mod;
	int ans=0;
	for(i=0;i<(1<<n);i++){
		if(count(i)%2==0) ans=(ans+g[i])%mod;
		else ans=(ans-g[i]+mod)%mod;
	}
	printf("%lld\n",ans*poww(2,n)%mod);
	return 0;
}

Measured memory_bytes: 13036
from collections import Counter
n=int(input())
V=list(map(int,input().split()))
E=Counter(V[::2]).most_common()
O=Counter(V[1::2]).most_common()
if E[0][0]==O[0][0]:
	E2=Counter(V[1::2]).most_common()[1][1] if len(E)>1 else 0
	O2=Counter(V[::2]).most_common()[1][1] if len(O)>1 else 0 
print(n-E[0][1]-O[0][1] if E[0][0]!=O[0][0] else n-max(E[0][1]+E2,O[0][1]+O2))

Measured memory_bytes: 24108
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
typedef long long ll;
int N;
 
int main() {
    cin >> N;
 
    vector<ll> A;
    A.push_back(0);
    for (int i = 0; i < N; i++) { 
        ll a;
        scanf("%lld", &a);
        A.push_back(a);
    }
 
    for (int i = 1; i <= N+1; i++) {
        A[i] += A[i-1];
    }
 
    sort(A.begin(), A.end());
 
    A.push_back(-1000000008);
 
    ll ans = 0;
    ll temp = -10000000000008;
    ll cnt = 1;
    for (int i = 0; i <= N+1; i++) {
        if (A[i] == temp) cnt++;
        else {
            ans += cnt * (cnt-1) / 2;
            cnt = 1;
            temp = A[i];
        }
    }
 
    cout << ans << '\n';
 
}

Measured memory_bytes: 2420
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
X2 = L - X[::-1]
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))
Y2 = Y1[::-1]
Z = np.concatenate((np.arange(N, -1, -2), np.arange(N - 1, -1, -2)[::-1]))


def myfunc(n, x):
    return x[n + (N - n + 1)//2 - 1] - 2 * x[n - 1] - (L - x[N - (N - n + 1)//2])


len1 = np.dot(Z, Y1)
len2 = np.dot(Z, Y2)
x1 = X.tolist()
x2 = X2.tolist()
ans = max(len1, len2)
for n in range(1, (N + 1) // 2):
    len1 += myfunc(n, x1)
    len2 += myfunc(n, x2)
    ans = max(ans, len1, len2)

print(ans)

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

int main()
{
	int a,b;
	
	cin>>a>>b;
	if( a < b ) {
	    cout <<"a < b"<<endl;
	} else if( a > b ) {
	    cout <<"a > b"<<endl;	
	} else {
	    cout <<"a == b"<<endl;
	}

    return 0;
}

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

#define ll long long

const int mxN=1e4, M=1e9+7;
int n, d;
string k;
ll dp[mxN][100][2];

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

	cin >> k >> d;
	n=k.size();
	for(int i=n-1; i>=0; --i) {
		for(int j=0; j<d; ++j) {
			if(i==n-1) {
				for(int l=0; l<10; ++l) {
					if(l%d==j) {
						++dp[i][j][1];
						dp[i][j][0]+=l<=k[n-1]-'0';
					}
				}
				//dp[i][j][1]=j<10;
				//dp[i][j][0]=j<=k[n-1]-'0';
				continue;
			}
			for(int l=0; l<10; ++l) {
				dp[i][j][1]=(dp[i][j][1]+dp[i+1][(j+d-l%d)%d][1])%M;
				if(l<k[i]-'0')
					dp[i][j][0]=(dp[i][j][0]+dp[i+1][(j+d-l%d)%d][1])%M;
				else if(l==k[i]-'0')
					dp[i][j][0]=(dp[i][j][0]+dp[i+1][(j+d-l%d)%d][0])%M;
			}
		}
	}
	cout << (dp[0][0][0]+M-1)%M;
}


Measured memory_bytes: 15872
N = int(input())
ratio = [list(map(int, input().split())) for _ in range(N)]

takahasi, aoki = ratio[0]
for i in range(1, N):
    t_ratio, a_ratio = ratio[i]
    n = max(takahasi//t_ratio + min(1, takahasi % t_ratio), aoki//a_ratio + min(1, aoki % a_ratio))
    takahasi = n * t_ratio
    aoki = n * a_ratio

print(takahasi+aoki)


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    for(int i = 0; i < n - 2; ++i){
        for(int j = i+1; j < n-1; ++j){
            for(int k = j+1; k < n; ++k){
                if(i == j || i == k || k == j) continue;
                if(l[i] != l[j] && l[i] != l[k] && l[j] != l[k]){
                    if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]){
                        ++ans;
                        // cout << i + 1 << " " << j + 1 << " " << k + 1 << endl;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
	int n,q;
	int seq[10000],set[500];
	int i,j,k;
	int count;

	// read sequence
	scanf("%d",&n);
	for (i = 0;i != n;++i) {
		scanf("%d",seq + i);
	}
	// read set
	scanf("%d",&q);
	for (i = 0;i != q;++i) {
		scanf("%d",set + i);
	}
	// linear search
	for (i = 0;i != n;++i) {
		j = 0;
		while (j != q) {
			if (seq[i] == set[j]) {
				++count;
				// delete this element in set
				for (k = j + 1;k != q;++k) {
					set[k - 1] = set[k];
				}
				--q;
			} else {
				++j;
			}
		}
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2108
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n;
  cin >> n;
  int a[n];
  bool flag = true;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2 == 0){
      if(a[i]%3 == 0 || a[i]%5==0) continue;
      else flag = false;
    }
  }
  if(flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

u64 lcm(u64 a, u64 b) { return (a / gcd(a, b)) * b; }

int main() {
  u64 H, sum = 0;
  cin >> H;
  u64 cnt = 1;
  while (H > 0) {
    sum += cnt;
    cnt *= 2;
    H /= 2;
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll l[n + 1];
    l[0] = 2, l[1] = 1;
    for(int i = 2; i <= n; i++) {
        l[i] = l[i - 1] + l[i - 2];
    }
    cout << l[n] << endl;
}

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

int main()
{
    int n,ans=0;
    double t,a;
    cin >> n>>t>>a;
    double diff = 1e9;


    for(register int i = 0; i < n; i++)
    {
        double h;
        cin >> h;
        double temp = t - h * 0.006;
        if(abs(a - temp) < diff)
        {
            ans = i+1;
            diff = abs(a-temp);
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

ll calc(const string&s, ll mod) {
  ll sum = 0;
  ll pm = 1;
  ll n = size(s);
  REP(ri,n) {
    int i = n - 1 - ri;
    if (s[i] == '1') {
      sum += pm;
      sum %= mod;
    }
    pm *= 2;
    pm %= mod;
  }
  return sum;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  string s;
  cin>>s;
  int pcnt = 0;
  for (auto&&c:s) if (c=='1') ++pcnt;
  if (pcnt == 0) {
    REP(i,n) {
      cout<<1<<"\n";
    }
    return 0;
  } else if (pcnt == 1) {
    int idx = find(ALL(s), '1') - begin(s);
    REP(i,n) {
      if (i == idx) {
        cout<<"0\n";
      } else if (i < n-1) {
        cout<<"1\n";
      } else {
        cout<<"2\n";
      }
    }
    return 0;
  }
  ll sum_up = calc(s, pcnt+1);
  ll sum_down = calc(s, pcnt-1);
  vecint nx(n);
  ll pm_up = 1;
  ll pm_down = 1;
  REP(ri,n) {
    int i = n - 1 - ri;
    if (s[i] == '1') {
      nx[i] = (sum_down + pcnt-1 - pm_down) % (pcnt-1);
    } else {
      nx[i] = (sum_up + pm_up) % (pcnt+1);
    }
    pm_up *= 2;
    pm_down *= 2;
    pm_up %= pcnt+1;
    pm_down %= pcnt-1;
  }
  REP(i,n) {
    int cnt = 1;
    while (nx[i]) {
      int md = __builtin_popcount(nx[i]);
      nx[i] %= md;
      ++cnt;
    }
    cout<<cnt<<"\n";
  }
  return 0;
}


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

using namespace std;

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main(void) {
    int N;
    cin >> N;
    auto table = prime_table(55555);
    for(int i=0; i<table.size(); i++) {
        if(N && table[i] && i%5 == 2) {
            cout << i << " ";
            N--;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int r,i,x[11],D;
	scanf("%d" "%d" "%d" ,&r,&D,&x[0]);
	for(i=0;i<10;i++)
	{
		x[i+1]= r*x[i] -D;

		printf("%d\n" ,x[i+1]);
	}
	return 0;
}



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

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> c(m,vector<int>(n,0));
    rep(i,m){
        int ki; cin >> ki;
        rep(j,ki){
            int sij; cin >> sij;
            sij--;
            c[i][sij] = 1;
        }
    }
    vector<int> p(m);
    rep(i,m) cin >> p[i];

    int cnt = 0;
    rep(i,1<<n){
        //cout << bitset<5>(i) << " ";
        rep(j,m){
            int cntj = 0;
            rep(k,n){
                if(c[j][k] && (i>>k&1)) cntj++;
            }
            //cout << cntj << " ";
            if((cntj-p[j])%2) break;
            else if(j == m-1){
                cnt++;
                //cout << i << endl;
            }
        }
        //cout << endl;
    }
    cout << cnt << endl;
    /*rep(i,m){
        rep(j,n){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

struct UnionFind{
  vector<int> d;
  UnionFind(int n):d(n,-1){}
  int find(int x){
    if(d[x]<0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x,int  y){
    x = find(x);y = find(y);
    if(x==y) return false;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x,int y) {return find(x) == find(y);}
  int size(int x) {return -d[find(x)];}
};
 
int main(){
  int n;cin >> n;
  vector<vector<int>> G(n);
  rep(i,n-1){
    int a,b;cin >> a >> b;
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  queue<int> q;
  vector<int> fdist(n,-1),sdist(n,-1);
  fdist[0] = 0;
  sdist[n-1] = 0;
  q.push(0);
  while(!q.empty()){
    int ver = q.front();q.pop();
    for(auto nver:G[ver]){
      if(fdist[nver] != -1) continue;
      fdist[nver] = fdist[ver] + 1;
      q.push(nver);
    }
  }
  q.push(n-1);
  while(!q.empty()){
    int ver = q.front();q.pop();
    for(auto nver:G[ver]){
      if(sdist[nver] != -1) continue;
      sdist[nver] = sdist[ver] + 1;
      q.push(nver);
    }
  }
  int dist = fdist[n-1];
  int ind1,ind2;
  if(dist%2 ==0){
    rep(i,n){
      if(fdist[i] == dist/2 && sdist[i] == dist/2) ind1 = i;
      if(fdist[i] == dist/2+1 && sdist[i] == dist/2-1) ind2 = i;
    }
  }else{
    rep(i,n){
      if(fdist[i] == dist/2 && sdist[i] == dist/2+1) ind1 = i;
      if(fdist[i] == dist/2+1 && sdist[i] == dist/2) ind2 = i;
    }
  }
  // cout << dist << endl;
  // cout << ind1 << " " << ind2 << endl;
  // remove(G[ind1].begin(),G[ind1].end(),ind2);
  // remove(G[ind2].begin(),G[ind2].end(),ind1);
  UnionFind uf(100005);
  rep(i,n){
    for(auto v:G[i]) {
      if(v == ind1 && i == ind2) continue;
      if(v == ind2 && i == ind1) continue;
      uf.unite(i,v);
    }
  
  }

  if(uf.size(0)<=uf.size(n-1)) cout << "Snuke" << endl;
  else cout << "Fennec" << endl;

 // cout << uf.size(0) << " " << uf.size(n-1) << endl;


}

Measured memory_bytes: 9836
var
	S:String;
	N,i,f:Longint;
begin
	readln(S);
	N:=length(S);
	for i:=1 to N do if S[i]<>S[N-i+1]then inc(f);
	for i:=1 to (N-1)div 2 do if(S[i]<>S[(N-1)div 2-i+1])or(S[(N-1)div 2+1+i]<>S[N-i+1])then inc(f);
	if f>0 then writeln('No')else writeln('Yes');
end.


Measured memory_bytes: 128