akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
fn main() {
    let mut nn = i::u();
    let mut hh=i::iv(nn);


    let mut bh=0;
    let mut first = true;
    let mut bfalg =false;


    for x1 in 0..nn {
        let mut num1=x1;
        if (first){
            bh=hh[num1];
            first=false;
            bfalg=false;
        }else{
            let mut sa1=(hh[num1]-bh);
            if (sa1>=0){
                bh=hh[num1];
                bfalg=false;
            }else if (sa1<(-1)){
                println!("No");
                return;
            }else{
                bh=hh[num1]+1;
                bfalg=true;
            }
        }

    }
    println!("Yes");

}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


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

int main() {
	int R;
	string s;
	cin >> R;

	if(R < 1200)
		s = "ABC";
	else if(R < 2800)
		s = "ARC";
	else
		s = "AGC";
	
	cout << s << endl;
}

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

static const int MAX = 100;

int main(){
    int n;
    scanf("%d",&n);
    int u,k,adj[MAX][MAX],tmp;
    memset(adj,0,sizeof(adj));
    for(int i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(int m=0;m<k;m++){
            scanf("%d",&tmp);
            adj[u-1][tmp-1] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int m=0;m<n;m++){
            if(m) printf(" ");
            printf("%d",adj[i][m]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 3248
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque 

class Edge:
    def __init__(self, to, id):
        self.to = to
        self.id = id

def main():
    
    n = int(readline())
    g = [[] for _ in range(n)]

    for i in range(n-1):
        a, b = map(int, readline().split())
        g[a-1].append(Edge(b-1, i))
        g[b-1].append(Edge(a-1, i))

    dq = deque()    
    done = [0 for _ in range(n)]
    dq.append(0)
    done[0] = 1
    edgecolor = [0 for _ in range(n-1)]

    while len(dq) > 0: 
        v = dq.pop()
        c = -1
        for e in g[v]:
            nx = e.to
            edge_id = e.id
            if done[nx]:
                c = edgecolor[edge_id]
        k = 1
        for e in g[v]:
            nx = e.to
            edge_id = e.id
            if done[nx]:
                continue
            if k == c:
                k += 1
            edgecolor[edge_id] = k
            k += 1  
            done[nx] = 1
            dq.append(nx)

    mx = max(edgecolor) 
    print(mx)
    for ec in edgecolor:
        print(ec)

if __name__ == '__main__':
    main()


Measured memory_bytes: 60588
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll N, M;
	cin >> N >> M;
	struct Edge {
		ll to;
		ll cost;
	};
	vector<vector<Edge>> graph(N);
	rep(i,0,M) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		c *= -1;
		graph[a].push_back({b, c});
	}
	vector<ll> loop_detect(N);
	vector<ll> loops;
	rep(n,0,M+1) {
		rep(i,0,N) {
			for (Edge& e : graph[i]) {
				if (loop_detect[i] + e.cost < loop_detect[e.to]) {
					loop_detect[e.to] = loop_detect[i] + e.cost;
					if (n == M) {
						loops.push_back(e.to);
					}
				}
			}
		}
	}
	vector<bool> reachable_from_start(N);
	reachable_from_start[0] = true;
	vector<bool> reachable_to_end(N);
	reachable_to_end[N-1] = true;
	rep(n,0,M) {
		rep(i,0,N) {
			for (Edge& e : graph[i]) {
				if (reachable_from_start[i]) {
					reachable_from_start[e.to] = true;
				}
				if (reachable_to_end[e.to]) {
					reachable_to_end[i] = true;
				}
			}
		}
	}
	for (ll pt : loops) {
		if (reachable_from_start[pt] && reachable_to_end[pt]) {
			cout << "inf" << endl;
			return 0;
		}
	}
	vector<ll> dist(N, numeric_limits<ll>::max());
	dist[0] = 0;
	rep(n,0,M) {
		rep(i,0,N) {
			for (Edge& e : graph[i]) {
				if (dist[i] != numeric_limits<ll>::max()
					&& dist[i] + e.cost < dist[e.to]) {
					dist[e.to] = dist[i] + e.cost;
				}
			}
		}
	}
	cout << -dist[N-1] << endl;
}


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

int main() {
	int A, B, C;
	cin >> A >> B >> C ;
	if (A == B) {
		cout << C << endl;
	}
	else if (A == C) {
		cout << B << endl;
	}
	else {
		cout << A << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 1000001
#define M 2000001
#define inf 6666666
#define int long long
using namespace std;
int n,m,hd[N],t,x,y,z,vis[N],d[N];
struct edge
{
    int to,nt,w;
}e[M];
void add(int u,int v,int w)
{
    e[++t].to=v,e[t].w=w;
    e[t].nt=hd[u],hd[u]=t;
}
/*
struct my_queue
{
    int heap[N]={0},fa,son,sz=0;
    void push(int x)
    {
        son=++sz,fa=son>>1;
        while(fa&&d[heap[x]]<d[heap[fa]])heap[son]=heap[fa],son=fa,fa>>=1;
        heap[son]=x;
    }
    void pop()
    {
        int x=heap[sz--];
        fa=1,son=2;
        while(son<=sz)
        {
            if(son<sz&&d[heap[son]]>d[heap[son+1]])son++;
            if(d[x]>d[heap[son]])heap[fa]=heap[son],fa=son,son<<=1;
        }
        heap[fa]=x;
    }
    int top(){return heap[1];}
    bool empty(){return sz==0;}
}q;*/
struct my_queue
{
    int myq[N]={0},fst=0,lst=0;
    void push(int x){myq[lst++]=x;if(lst==N)lst=0;}
    void pop(){if(++fst==N)fst=0;}
    int top(){return myq[fst];}
    bool empty(){return lst==fst;}
}q;
bool spfa(int s)
{
    d[s]=0,vis[s]=true,q.push(s);
    while(!q.empty())
    {
        int k=q.top();
        q.pop();
        for(int i=hd[k],kk,w;i;i=e[i].nt)
        {
            kk=e[i].to,w=e[i].w;
            if(vis[kk]){if(d[kk]!=d[k]+w)return 1;}
            else
            {
                vis[kk]=true,d[kk]=d[k]+w;
                q.push(kk);
            }
        }
    }
    return 0;
}
signed main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%lld%lld%lld",&x,&y,&z);
        add(x,y,z),add(y,x,-z);
    }
    for(int i=1;i<=n;i++)d[N]=inf;
    for(int i=1;i<=n;i++)
        if(vis[i]==0&&spfa(i)){printf("No");return 0;}
    printf("Yes");
    return 0;
}


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

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

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    // init struct with \"n\" of \"nCk\" (maximum number in other words)
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    // c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
    // i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }

    // nPk - permutation
    mint p(int n, int k) {
        return fact[n] * ifact[n - k];
    }
};

int main() {
	ll n;
    cin >> n;
    mint ans = mint(10).pow(n);
    ans -= mint(9).pow(n);
    ans -= mint(9).pow(n);
    ans += mint(8).pow(n);
    cout << ans.x << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	LL ans = 0;

	LL A, B, C; cin >> A >> B >> C;
	LL mx = max({ A,B,C });
	ans = mx * 3 - (A + B + C);
	if (ans & 1)ans += 3;
	ans /= 2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<set>
#include<list>
#include<bitset>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<limits.h>
#define null NULL
using namespace std;
template <typename T> void sortV(vector<T> &x){ sort(x.begin(),x.end());};
#define dbg(name) printer(#name, (name))
template<typename T> void printer(string name, T value) {
    cerr<<name<<" :\t"<<value<<"\n";
}
void Solve(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(auto&x:h) cin>>x;
  vector<int> dp(n,INT_MAX);
  dp[n-1] = 0;
  for(int i=n-1;i>=0;i--){
      for(int j=1;j<=k;j++)
        if(i+j<n) dp[i] = min(dp[i],dp[i+j]+abs(h[i]-h[i+j]));
  }
  cout<<dp[0];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0); 
    //int t;cin>>t;while(t--)
        Solve();
    return 0;
}

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

int main(){
    ll n,m; cin >> n >> m;
    vector<ll> d; //mの約数をぶち込んだ数列
    ll sqm = ll(sqrt(m));
    for(ll i = 1; i <= sqm; i++){
        if(m % i == 0){
            d.push_back(i);
            d.push_back(m/i);
        }
    }
    sort(d.begin(),d.end()); //O(√nlogn)
    ll ans = 1LL;
    for(int i = 0; i < d.size(); i++){
        if(m/d[i] < n) break;
        ans = d[i]; //d[i]でmをn個以上に分割出来る時
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import           Data.Char
import qualified Data.IntMap.Strict    as M
import           Data.List

main :: IO ()
main = do
    n <- readLn
    as <- M.fromListWith (+) . (flip zip) (repeat 1) <$> readInts
    print $ solve n as

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

solve :: Int -> M.IntMap Int -> Int
solve n as 
    | all (== 2) peri
        = powWithMod (10 ^ 9 + 7) 2 (M.size peri)
    | otherwise
        = 0
    where peri = peripheries as

peripheries :: M.IntMap Int -> M.IntMap Int
peripheries mp = if odd (M.size mp) then M.delete 0 mp else mp

powWithMod :: Int -> Int -> Int -> Int
powWithMod m n 0 = 1
powWithMod m n p = n %*% powWithMod m n (p - 1)
    where x %*% y = x * y `mod` m

Measured memory_bytes: 12668
printRectangle :: Int -> Int -> IO ()
printRectangle h w = mapM_ putStrLn $ take h $ repeat $ take w $ repeat '#'

main :: IO ()
main = do
  input <- getLine
  let [h, w] = map read $ words input
  if h == 0 && w == 0
    then do return ()
    else do
    printRectangle h w
    putChar '\n'
    main

Measured memory_bytes: 4108
// Try SHPC 2018 MT Qual
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () =>  (get!(i64));
    }
    
    let a = get!();
    let b = get!();
    
    if a + b == 15 {
    	println!("+");
    } else if a * b == 15 {
    	println!("*");
    } else {
    	println!("x");
    }
}

Measured memory_bytes: 4352
import Data.List

solve :: [Int] -> Bool
solve xs
  | minimum xs == 1    = odd $ sum xs - length xs
  | length xs - p == 1 = not $ solve $! map (`div` q) ys
  | otherwise          = odd p
  where p = length $ filter even xs
        q = foldl1' gcd ys
        ys = map (\x -> if odd x then x - 1 else x) xs

main :: IO ()
main = do
  _ <- getLine
  a <- getLine
  putStrLn $ (\x -> if solve x then "First" else "Second") $ map read $ words a


Measured memory_bytes: 39548
#include<iostream>
using namespace std;
int main()
{
    long long int n,a[100000],b[100000];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]-1]=i+1;
    }
    for(int i=0;i<n;i++)
    {
        cout<<b[i]<<" ";
    }
}


Measured memory_bytes: 2432
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1180
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;

int main(void)
{
    int n, L;

    while (cin >> n >> L, n || L)
    {
        int ans = 0;
        int t = n;
        map<int, int> mp;
        vector<vector<int>> memo(1e6);
        if (memo[t].size() == 2)
            break;

        memo[t].push_back(ans);

        while (1)
        {
            vector<int> v;

            while (t)
            {
                v.push_back(t % 10);
                t /= 10;
            }
            while (1)
            {
                if ((int)v.size() == L)
                    break;
                v.push_back(0);
            }

            int minV = 0, maxV = 0;
            sort(v.begin(), v.end());

            t = 1;

            for (int i = 0; i < L; ++i)
            {
                maxV += t * v[i];
                t *= 10;
            }
            t = 1;
            for (int i = L - 1; i >= 0; --i)
            {
                minV += t * v[i];
                t *= 10;
            }
            t = maxV - minV;
            ans++;
            if (memo[t].size() == 2)
                break;

            memo[t].push_back(ans);
        }
        cout << memo[t][0] << " " << t << " " << memo[t][1] - memo[t][0] << endl;
    }
    return 0;
}


Measured memory_bytes: 26604
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

set<string> used;

void solve(){
	string str;
	str+='a';
	string res;
	char pt='a';
	while(1){
		used.insert(str);
		cout<<"?"<<str<<endl;
		cin>>res;
		if(res[0]!=str[str.size()-1]||(used.find(res)!=used.end())){
			cout<<"!OUT"<<endl;
			break;
		}
		used.insert(res);
		string nstr;
		nstr+=res[res.size()-1];
		nstr+=pt;
		while(1){
			if(used.end()==used.find(nstr)){
				break;
			}
			nstr+=pt;
		}
		str=nstr;
	}
}

int main(){

	solve();

	return 0;
}

Measured memory_bytes: 0
//
// Created by myabu on 2020/02/01.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int X[3];
    int K;
    cin>>X[0]>>X[1]>>X[2]>>K;

    sort(X, X+3);

    for (int i = 0; i < K; ++i) {
        X[2] *= 2;
    }

    cout<<X[0]+X[1]+X[2]<<endl;


    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
    int p,q,r,i;
    int x[3];
    int min = 999;
    
    scanf("%d %d %d",&p,&q,&r);
    x[0] = p+q;
    x[1] = p+r;
    x[2] = q+r;
    for(i = 0; i < 3; i++){
        if(min > x[i])
            min = x[i];
    }
    printf("%d\n",min);


    return 0;
}

Measured memory_bytes: 128
#include <cstdio>


int main(){
	char i[20];
	scanf("%s",i);
	if (i[2]=='\0'){
		for (int j=0;j<2;j++){
			printf("%c",i[j]);
		}
	}
	else{
		for (int j=2;-1<j;j--){
			printf ("%c",i[j]);
			}
		}
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int X;
  cin>>X;
  int num = X/100;
  X = X%100;
  if(5*num>=X) cout<<1<<endl;
  else cout<<0<<endl;
}



Measured memory_bytes: 3584
#include <stdio.h>

#define MAX 2000001

void Ins(int);
void IcK(int,int);
void Ext(void);
void MaxH(int);

int n,A[MAX],size; 

int main()
{
  int i,n;

  char moji[8];

  while(1)
    {

      scanf("%s",moji);
      
      if(moji[0]=='i')
	{
	  scanf("%d",&n);
	  Ins(n);
	}
      if(moji[0]=='e'&&moji[1]=='x')
	{
	  Ext();
	}
      if(moji[0]=='e'&&moji[1]=='n')
	{
	  break;
	}
    }
  return 0;
}


void Ins(int n)
{
  size++;
  A[size]=-MAX;
  IcK(size,n);
}
  
void IcK(int i,int n)
{

  int koukan;
  
  if(n<A[i])printf("error");
  
  A[i]=n;
  
  while(i>1&&A[i/2]<A[i])
    {
      koukan=A[i];
      A[i]=A[i/2];
      A[i/2]=koukan;

      i/=2;
    }
}

void Ext(void)
{
  int max;
  
  if(size<1)printf("error\n");

  printf("%d\n",A[1]);
  A[1]=A[size];
  size--;
  
  MaxH(1);


}
 
void MaxH(int i)
{
  int L,R,lg,koukan;
   
  L=2*i;
  R=2*i+1;
  
  if(L<=size&&A[L]>A[i])lg=L;
  else lg=i;
  
  if(R<=size&&A[R]>A[lg])lg=R;
  
  if(lg!=i)
    {
      koukan=A[i];
      A[i]=A[lg];
      A[lg]=koukan;
      
      MaxH(lg);
    }
}
  



Measured memory_bytes: 5640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, ll K, vector<ll> x, vector<ll> y) {
  ll res = 5e18;
  REP(i,N) REP(j,N) {
    ll top = y[i], bot = y[j];
    if (top > bot) continue;
    vector<ll> z;
    REP(k,N) if (top <= y[k] && y[k] <= bot) z.push_back(x[k]);
    sort(ALL(z));
    REP(k,int(z.size())-K+1) {
      chmin(res, (bot - top) * (z[k+K-1] - z[k]));
    }
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	ll K;
	scanf("%lld", &N);
	vector<ll> y(N-1+1);
	vector<ll> x(N-1+1);
	scanf("%lld", &K);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &x[i]);
	  scanf("%lld", &y[i]);
	}
	solve(N, K, x, y);
	return 0;
}


Measured memory_bytes: 256
import scala.collection.immutable.IntMap
import scala.io.StdIn._

object Main {
  def main(args: Array[String]) = {
    val map = generatePrimeNumberMap
    for (x <- io.Source.stdin.getLines()) {
      val value = x.toInt
      println(map.get(value).get)
    }
  }

  def generatePrimeNumberMap: scala.collection.mutable.HashMap[Int, Int] = {
    var map = scala.collection.mutable.HashMap[Int, Int]()

    var count = 0
    for (i <- 1 until 1000000) {
      if (isPrimeNumber(i)) {
        count = count + 1
      }
      map += i -> count
    }

    map
  }

  def isPrimeNumber(value: Int): Boolean = {
    if (value < 2) false
    else if (value == 2) true
    else if (value % 2 == 0) false
    else {
      val sqrt = Math.sqrt(value).toInt
      for (i <- 3 to sqrt by 2) {
        if (value % i == 0) {
          return false
        }
      }

      true
    }
  }
}

Measured memory_bytes: 175184
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    println(Solver(n).solve())
}

private class Solver(private val n: Int) {

    fun solve(): Int {
        return f("0")
    }

    private fun f(s: String): Int {
        if (s.toLong() > n) {
            return 0
        }

        var r = 0

        if (s.contains('3') && s.contains('5') && s.contains('7')) {
            r++
        }

        r += f(s + '3')
        r += f(s + '5')
        r += f(s + '7')

        return r
    }

}


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

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

  vector<int> data(N);

  for(int i=1; i<N; i++){
    cin >> buf;
    buf--; // 1-indexed -> 0-indexed
    data.at(buf)++;
  }

  for(int i=0; i<N; i++){
    cout << data.at(i) << endl;
  }
}


Measured memory_bytes: 3988
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define rp(i,n) for(long long i=1;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel rui(19, 1);
vel kai(1000007, 1);
vel ink(1000007, 1);
vel par;
int root(int ser) {
	if (par[ser] == -1) { return ser; }
	int ans = root(par[ser]);
	par[ser] = ans;
	return ans;
}
bool marge(pin a) {
	int x = root(a.first);
	int y = root(a.second);
	if (x != y) { par[x] = y; }
	return x != y;
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 1000007) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p;
	return ans;
}
signed main() {
	int n; cin >> n;
	vel pot(n); int a;
	rep(i, n) { cin >> a; pot[a - 1] = i; }
	int ans = 0;
	int now = 0;
	rep(i, n) {
		if (i != 0) {
			if (pot[i - 1] < pot[i]) { now++; }
			else { now = 1; }
		}
		else { now = 1; }
		mmax(ans, now);
	}
	cout << n - ans << endl;
	return 0;
}


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

const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

// 0-indexed, 半開
template <typename T> struct BIT {
  private:
    int n;
    vector<T> dat;

  public:
    BIT(vector<T> v) : n(v.size()) {
        dat.assign(n + 1, 0);
        for(int i = 0; i < n; i++)
            dat[i + 1] = v[i];
        for(int i = 1; i < n; i++)
            if(i + (i & -i) <= n) dat[i + (i & -i)] += dat[i];
    }
    BIT(int n) : n(n) { dat.assign(n + 1, 0); }
    void add(int k, T a) {
        for(k++; k <= n; k += k & -k)
            dat[k] += a;
    }
    // [0,a)
    T sum(int a) {
        T ret = 0;
        for(; a > 0; a -= a & -a)
            ret += dat[a];
        return ret;
    }
    // [a,b)
    T sum(int a, int b) { return sum(b) - sum(a); }
    int lowerBound(int w) {
        if(w <= 0) return 0;
        int x = 0;
        for(int k = 1 << int(log2(n)); k; k /= 2) {
            if(x + k <= n && dat[x + k] < w) {
                x += k;
                w -= dat[x];
            }
        }
        return x + 1;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<BIT<int>> bit;
    vector<vector<int>> v(26, vector<int>(n));
    rep(i, n) {
        int x = s[i] - 'a';
        v[x][i] = 1;
    }
    rep(i, 26) { bit.push_back(BIT<int>(v[i])); }

    while(q--) {
        int que;
        cin >> que;
        if(que == 1) {
            int id;
            char c;
            cin >> id >> c;
            id--;
            int x = c - 'a', y = s[id] - 'a';
            bit[y].add(id, -1);
            bit[x].add(id, 1);
            s[id] = c;
        } else {
            int l, r;
            cin >> l >> r;
            int ret = 0;
            rep(i, 26) {
                if(bit[i].sum(l - 1, r)) ret++;
            }
            cout << ret << endl;
        }
    }
}

Measured memory_bytes: 104492
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
  int ans;
  int d[3];
  scanf("%d%d%d", &d[0], &d[1], &d[2]);
  sort(d,d+3);
  ans = d[2]*10+d[0]+d[1];
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

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

#define MAX_N 110
int N, K;
//int A[MAX_N];
//int B[3];
int timeline[MAX_N];
int dp[MAX_N][3][3]; // dp[day][cons][last_choice]

const int MOD = 10000;

int main() {
  cin >> N >> K;
  rep(i, N) timeline[i] = -1;
  rep(i, K) {
    int a, b;
    cin >> a >> b;
    timeline[a-1] = b-1;
  }

  if (timeline[0] != -1) {
    dp[0][0][timeline[0]] = 1;
  }
  else {
    dp[0][0][0] = 1;
    dp[0][0][1] = 1;
    dp[0][0][2] = 1;
  }
  for (int i=1; i<N; i++) {
    int tc = timeline[i];
    if (tc != -1) {
      dp[i][1][tc] += dp[i-1][0][tc];
      dp[i][1][tc] %= MOD;
      rep(k, 3) {
        if (k != tc) {
          dp[i][0][tc] += dp[i-1][0][k] + dp[i-1][1][k];
          dp[i][0][tc] %= MOD;
        }
      }
    }
    else {
      rep(x, 3) {
        dp[i][1][x] += dp[i-1][0][x];
        dp[i][1][x] %= MOD;
        rep(k, 3) {
          if (k != x) {
            dp[i][0][x] += dp[i-1][0][k] + dp[i-1][1][k];
            dp[i][0][x] %= MOD;
          }
        }
      }
    }
  }

  int ans = 0;
  rep(i, 2) rep(j, 3) ans = (ans + dp[N-1][i][j]) % MOD;

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3108
S=input()

ans = "No"

if S == S[::-1]:
    if S[0:(len(S)-1)//2]==S[(len(S)-1)//2-1::-1]:
        if S[(len(S)+3)//2-1:] == S[-1:(len(S)+3)//2-2:-1]:
            ans="Yes"


print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	string s,o,e;
	cin>>o;
	cin>>e;
	for(int j=0; j<int(e.size()); j++)
	{
		s+=o[j];
		s+=e[j];
	}
	if(o.size()!=e.size())s+=o[o.size()-1];
	cout<<s<<endl;
}


Measured memory_bytes: 256
S = input()
string = ['dream', 'dreamer', 'erase', 'eraser']
string = [i[::-1] for i in string]
S = S[::-1]
i = 0
while i < len(S):
    can = False
    for word in string:
        d = S[i:i+len(word)]
        if word == d:
            can = True
            i += len(word)
            break
    else:
        break

if can is True:
    print('YES')
else:
    print('NO')    

Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define from1(obj) obj.begin() + 1, obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbp(p) cerr << #p << ":(" << p.first << ", " << p.second << ") "
#define dbpl(p) cerr << #p << ":(" << p.first << ", " << p.second << ")\n"
#define dbt3(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ") "
#define dbt3l(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ")\n"
#define dbt4(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ") "
#define dbt4l(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ")\n"
#define dbv(vec) cerr << #vec << ":{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"
#define dbvv(vv) cerr << #vv << ":{\n"; for (auto vec : vv) { cerr << "{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"; } cerr << "}\n"
#define dbm(map) cerr << #map << ":{ "; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "}\n"
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pil = pair<int, ll> ; using pll = pair<ll, ll>; using pli = pair<ll, int>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using ti4 = tuple<int, int, int, int>; using tl4 = tuple<ll, ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mll = map<ll, ll>; using mli = map<ll, int>;

int main() {
	int N, C; cin >> N >> C;
	vvi D(C + 1, vi(C + 1)); rep2(i, 1, C + 1) rep2(j, 1, C + 1) cin >> D[i][j];
	vvi c(N, vi(N)); rep(i, N) rep(j, N) cin >> c[i][j];
	dbvv(D); dbvv(c);
	vvi n(3, vi(C + 1)); // n[i][j]:添字和mod3=iのマスであって，色jで塗られているものの個数
	rep(i, N) rep(j, N) n[(i + j) % 3][c[i][j]]++;
	dbvv(n);
	int ans = 500 * 500 * 1000;
	rep2(i, 1, C + 1) { // 添字和mod3=0のマスを塗る色
		int temp0 = 0;
		rep2(l, 1, C + 1) temp0 += n[0][l] * D[l][i];
		db(i); dbl(temp0);
		rep2(j, 1, C + 1) {
			if (i == j) continue;
			int temp1 = 0;
			rep2(l, 1, C + 1) temp1 += n[1][l] * D[l][j];
			db(j); dbl(temp1);
			rep2(k, 1, C + 1) {
				if (i == k or j == k) continue;
				int temp2 = 0;			
				rep2(l, 1, C + 1) temp2 += n[2][l] * D[l][k];
				db(k); dbl(temp2);
				dbl(temp0 + temp1 + temp2);
				ans = min(ans, temp0 + temp1 + temp2);
			}
		}
	}
	cout << ans << endl;	
}

Measured memory_bytes: 1280
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;
typedef long long int LL;
LL n, a[3333];
LL gcd(LL a,LL b){
	return b==0 ? a : gcd(b,b%a);
}
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	LL ans = 0;
	for(int i=1;i<=n;i++){
		ans += a[i]-1;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void) {
    int N;
    cin >> N;
    int tmp;
    map<int, int> a;
    for (int i = 0; i < N; ++i) {
        cin >> tmp;
        auto ite = a.find(tmp);
        if (ite == a.end()) {
            a.insert(std::make_pair(tmp, 1));
        }
        else {
            ++ite->second;
        }
    }
    int num = a.size();

    vector<pair<int, int>> a2(num);

    int p = 0;
    for (const auto &aa : a) {
        a2[p].first = aa.first;
        a2[p].second = aa.second;
        ++p;
    }

    int ans = 1;

    for (int i = 0; i < num; ++i) {
        int nnn = a2[i].second;
        if (i >= 1) {
            if (a2[i].first - a2[i - 1].first <= 1) {
                nnn += a2[i - 1].second;
            }
        }
        if (i < num - 1) {
            if (a2[i + 1].first - a2[i].first <= 1) {
                nnn += a2[i + 1].second;
            }
        }
        if (nnn > ans) {
            ans = nnn;
        }
    }
    cout << ans;
    return 0;
}

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

long long int dp[100005];

void get_res(long long int *weight, int *value, int N, long long int W )
{
    int best_value = 0;
    for( int i = 0; i < N; i++ ){
        for( int j = 100000; j >= value[i]; j-- ){
		dp[j] = min(dp[j], dp[j-value[i]]+weight[i]);
		if(dp[j] <= W)
			best_value = max(best_value, j);
	}
    }
    cout << best_value << endl;
}

int main()
{
    int N;
    long long int W;

    cin >> N >> W;

    long long int weight[N];
    int value[N];

    for( int i = 0; i < N; i++ )
        cin >> weight[i] >> value[i];

    for( int j = 0; j <=100000; j++ ){
        dp[j] = 1000000005;
	}
    dp[0] = 0;
    get_res( weight, value, N, W );
    return 0;
}


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

using namespace std;

enum eRoll{
	W,
	S,
	N,
	E
};

class Dice {
private:
	int _dice[6];
public:
	void roll(eRoll er) {
		int _diceinfo[6];
		for (int i = 0; i < 6; ++i) {
			_diceinfo[i] = _dice[i];
		}
		switch (er) {
		case W:
			_dice[0] = _diceinfo[2];
			_dice[1] = _diceinfo[1];
			_dice[2] = _diceinfo[5];
			_dice[3] = _diceinfo[0];
			_dice[4] = _diceinfo[4];
			_dice[5] = _diceinfo[3];
			break;
		case S:
			_dice[0] = _diceinfo[4];
			_dice[1] = _diceinfo[0];
			_dice[2] = _diceinfo[2];
			_dice[3] = _diceinfo[3];
			_dice[4] = _diceinfo[5];
			_dice[5] = _diceinfo[1];
			break;
		case N:
			_dice[0] = _diceinfo[1];
			_dice[1] = _diceinfo[5];
			_dice[2] = _diceinfo[2];
			_dice[3] = _diceinfo[3];
			_dice[4] = _diceinfo[0];
			_dice[5] = _diceinfo[4];
			break;
		case E:
			_dice[0] = _diceinfo[3];
			_dice[1] = _diceinfo[1];
			_dice[2] = _diceinfo[0];
			_dice[3] = _diceinfo[5];
			_dice[4] = _diceinfo[4];
			_dice[5] = _diceinfo[2];
			break;
		}
	}

	int getTopNum() {
		return _dice[0];
	}

	void setNum() {
		for (int i = 0; i < 6; ++i) {
			cin >> _dice[i];
		}
	}
};

int main() {
	Dice dice;

	dice.setNum();

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'S') {
			dice.roll(eRoll::S);
		}
		else if (s[i] == 'W') {
			dice.roll(eRoll::W);
		}
		else if (s[i] == 'E') {
			dice.roll(eRoll::E);
		}
		else if (s[i] == 'N') {
			dice.roll(eRoll::N);
		}
	}

	cout << dice.getTopNum() << endl;


	return 0;
}



Measured memory_bytes: 3204
N = int(input())
a = []
for i in range(N):
    a.append(list(map(int, input().split())))

count = 0
for i in range(N)[::-1]:
    a[i][0] += count
    if (a[i][0]%a[i][1]) != 0:
        count += a[i][1] - (a[i][0]%a[i][1])
print(count)

Measured memory_bytes: 31348
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, a[5][5], d[25000005];

ll f(ll p, ll x, ll y) {
	ll i, j;
	for(i=1; i<=p; i++) d[i] = i;
	for(i=1; i<=n; i++) for(j=0; j<3; j++) {
		if(a[x][j] < a[y][j] && i >= a[x][j]) {
			d[i] = max(d[i], d[i-a[x][j]] + a[y][j]);
		}
	}
	return d[p];
}

int main() {
	ll i, j;
	cin >> n;
	for(i=0; i<2; i++) for(j=0; j<3; j++) cin >> a[i][j];
	n = f(n, 0, 1);
	cout << f(n, 1, 0);
	return 0;
}


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

bool comp(pair<int, int>& a, pair<int, int>& b){
    return a.second > b.second;
}

int main(){
    int n, a[50005], b[50005], p, q, ans;
    vector<pair<int, int> >ca, cb;
    cin >> n;
    for(int i=0; i<n/2; i++){
        cin >> a[i] >> b[i];
    }
    sort(a, a+n/2);
    sort(b, b+n/2);
    p = q = 1;
    ca.push_back(make_pair(0, 0));
    cb.push_back(make_pair(0, 0));
    ca.push_back(make_pair(a[0], 1));
    cb.push_back(make_pair(b[0], 1));
    for(int i=1; i<n/2; i++){
        if(ca[p].first != a[i]){
            ca.push_back(make_pair(a[i], 1));
            p++;
        }else{
            ca[p].second++;
        }

        if(cb[q].first != b[i]){
            cb.push_back(make_pair(b[i], 1));
            q++;
        }else{
            cb[q].second++;
        }
    }
    sort(ca.begin(), ca.end(), comp);
    sort(cb.begin(), cb.end(), comp);
    ans = n - ca[0].second - cb[0].second;

    if(ca[0].first == cb[0].first){
        ans = min(n - ca[1].second - cb[0].second, n - ca[0].second - cb[1].second);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main(){
	IO
	ll k;
	cin >> k;

	if(k%7 == 0) k/=7;
	k*=9;

	const ll mx = 1e7;
	ll res = 1LL;
	bool f = false;
	for(ll i = 1; i < mx; ++i){
		res = (res*10LL)%k;
		if(res == 1LL){
			cout << i << endl;
			f = true;
			break;
		}
	}
	if(!f)
		cout << -1 << endl;
	return 0;
}

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

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

  for(int i=0;i<n;i++)
  {
    string color;
    cin>>color;

    if(color=="Y")
    {
      four="Four";
      cout<<four<<endl;
      break;
    }
    else
    {
      continue;
    }
  }
  if(four!="Four")
  {
    cout<<"Three"<<endl;
  }
}


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

using namespace std;

int main() {
  int C[4][4];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> C[i][j];
    }
  }
  for (int i = 0; i < 3; i++) {
    C[i][3] = C[i][0];
    C[3][i] = C[0][i];
  }
  bool ok = true;
  for (int i = 0; i < 3; i++) {
    ok = ok &&
         (C[i][0] - C[i][1] == C[i + 1][0] - C[i + 1][1]) &&
         (C[i][1] - C[i][2] == C[i + 1][1] - C[i + 1][2]) &&
         (C[i][0] - C[i][2] == C[i + 1][0] - C[i + 1][2]) &&
         (C[0][i] - C[1][i] == C[0][i + 1] - C[1][i + 1]) &&
         (C[1][i] - C[2][i] == C[1][i + 1] - C[2][i + 1]) &&
         (C[0][i] - C[2][i] == C[0][i + 1] - C[2][i + 1]);
  }
  auto ans = ok ? "Yes" : "No";
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
const int maxn=5010;
const int mod=1e9+7;
inline int get_mod(int x){
	return x<mod?x:x-mod;
}
int dp[maxn][maxn][2],pair_way[maxn],size[maxn],f[maxn][2];
vector<int> g[maxn];
void dfs(int u,int fa){
	size[u]=1;
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		if(v==fa) continue;
		dfs(v,u);
	}
	dp[u][1][0]=1;
	for(int i=0;i<(int)g[u].size();i++){
		int v=g[u][i];
		if(v==fa) continue;
		for(int i=0;i<=size[u]+size[v];i++)
			f[i][0]=f[i][1]=0;
		for(int i=1;i<=size[u];i++){
			for(int j=1;j<=size[v];j++){
				for(int o=0;o<2;o++){
					for(int o2=0;o2<2;o2++){
						f[i+j][(o+o2)&1]=get_mod(f[i+j][(o+o2)&1]+(ll)dp[u][i][o]*dp[v][j][o2]%mod);
						f[i][(o+o2+1)&1]=get_mod(f[i][(o+o2+1)&1]+(ll)dp[u][i][o]*((ll)dp[v][j][o2]*pair_way[j]%mod)%mod);
					}
				}	
			}
		}
		for(int i=0;i<=size[u]+size[v];i++)
			dp[u][i][0]=f[i][0],dp[u][i][1]=f[i][1];
		size[u]+=size[v];
	}
}
int main(){
	int n,x,y;
	scanf("%d",&n);
	pair_way[0]=pair_way[2]=1;
	for(int i=4;i<=n;i+=2)
		pair_way[i]=get_mod(pair_way[i-2]+(ll)pair_way[i-4]*(i-2)%mod*(i-3)%mod);
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,-1);
	int ans=0;
	for(int i=1;i<=n;i++){
		dp[1][i][0]=(ll)dp[1][i][0]*pair_way[i]%mod;
		dp[1][i][1]=(ll)dp[1][i][1]*pair_way[i]%mod;
		ans=(ans+mod-dp[1][i][1])%mod;
		ans=get_mod(ans+dp[1][i][0]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 195456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = 200010;
int n, arr[N], vis[N];
ll k;
vector<int> v;

int visit(int idx) {
  if (vis[idx] == 1) return idx;
  vis[idx]++;
  v.push_back(idx);
  return visit(arr[idx]);
}

int main() {
  scanf("%d %lld", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  int id = visit(arr[1]);
  // debug(id);
  int pos = 0;
  for (int i = 0; i < (int)v.size(); ++i) {
    if (v[i] == id) {
      pos = i;
      break;
    }
  }
  if (k - 1 < pos) {
    printf("%d\n", v[k - 1]);
    return 0;
  }
  k -= pos;
  if (pos != 0) v.erase(v.begin(), v.begin() + pos);
  // for (auto p: v) cout << p << " ";
  // cout << endl;
  int sz = v.size();
  k %= sz;
  if (k == 0) k = sz;
  printf("%d\n", v[k - 1]);
}


Measured memory_bytes: 11736
import numpy as np

HW=list(map(int,input().split()))
H=HW[0]
W=HW[1]
a = [input().split() for l in range(H)]

for h in range(H):
    a[h] = [i for i in a[h] if i != '.'*W]

a=list(filter(None, a))
b=[]
for column in range(W):
    tmp=''
    for row in range(len(a)):
        tmp+=a[row][0][column:column+1]
    if tmp=='.'*len(a):
        b.append(column)

tmp2=[]
dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
for j in range(len(a)):
    tmp2.append(list(a[j][0]))
  
for t in range(len(tmp2)):
    tmp2[t]=dellist(tmp2[t],b)
    tmp2[t]=''.join(tmp2[t])
print('\n'.join(tmp2))


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

using namespace std;

int dist[10][10];

void AddEdge(int from, int to, int cost) { dist[from][to] = cost; }

void WarshallFloyd() {
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}

int main() {
  int H, W;
  cin >> H >> W;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int c;
      cin >> c;
      AddEdge(i, j, c);
    }
  }

  WarshallFloyd();

  int total = 0;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      int number;
      cin >> number;
      if (number == -1) continue;
      total += dist[number][1];
    }
  }
  printf("%d\n", total);

  return 0;
}


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

using namespace std;

#define pb push_back
#define int long long
#define ld long double

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < s.size(); i++){
        sum += s[i] - '0';
    }
    if (sum % 9 == 0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

void Main() {
  int N;
  cin >> N;

  char c[N];
  int w_num = 0, r_num = 0;
  for (int i = 0; i < N; i++) {
    cin >> c[i];
    if (c[i] == 'W') w_num++;
    if (c[i] == 'R') r_num++;
  }

  int ans = 0;
  for (int i = 0; i < r_num; i++) {
    if (c[i] == 'W') ans++;
  }

  cout << ans << endl;
}

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



Measured memory_bytes: 3816
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

n = iin()
d,x = map(int,input().split())
for i in range(n):
    a = iin()
    for j in range(d):
        if a * j + 1 > d:
            break 
        x = x + 1
print(x)

Measured memory_bytes: 3060