akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 100007;
const LD EPS = 1e-7;

int A[MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int k;
	LL n1 = 2, n2 = 2;
	cin >> k;
	REP(i, k)
		cin >> A[i];
	RFOR(i, k, 0)
	{
		n1 += ((A[i] - n1) % A[i] + A[i]) % A[i];
		n2 -= n2 % A[i];
		n2 += A[i] - 1;
	}
	if (n1 > n2)
		cout << -1;
	else
		cout << n1 << ' ' << n2;
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 640
A, B, C, X = map(int, [input() for i in range(4)])

cnt = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if a * 500 + b * 100 + 50 * c == X:
                cnt += 1
print(cnt)


Measured memory_bytes: 2940
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, L: "List[int]", R: "List[int]"):
    ml = 1
    mr = N
    for Li, Ri in zip(L, R):
        ml = max(ml, Li)
        mr = min(mr, Ri)

    print(max(mr - ml + 1, 0))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    solve(N, M, L, R)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10868
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"

#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define LINF ((ll)1 << 60)
#define INF (1 << 28)
template<typename T>
void chmax(T& a, T b) {
        if (a < b) a = b;
}
template<typename T>
void chmin(T& a,T b) {
        if (a > b) a = b;
}
//.....................
ull mod = (int)1e9 + 7;
const int MAX = (int)2e5 + 5;

ll N;
ll T[MAX];
ll M;

void solve() {
        cin >> N;
        rep(i, N) cin >> T[i];
        ll sum = accumulate(all(T), 0);
        cin >> M;
        rep(i, M) {
                ll p, x;
                cin >> p >> x;
                p--;
                cout << sum - T[p] + x << endl;
        }
}

signed main() {
        int T = 1;
        cout << fixed << setprecision(20);
        rep(i, T) {
                solve();
        }
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define  clr(v,val)      memset(v,val,sizeof(v))
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
ll setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=500000+5,mod=1e9+7;
string s[109];
int main(){
    int n,m,k;
    cin>>n>>m>>k;

    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<(1<<m);j++){

            int cnt=0;
            for(int l=0;l<n;l++){
                for(int y=0;y<m;y++){
                    if(getBit(i,l)==1||getBit(j,y)==1) continue;
                    if(s[l][y]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout<<ans<<"\n";
}


















































































































Measured memory_bytes: 3616
import itertools

n, m = map(int, input().split())
path = [[False for _ in range(n)] for __ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    path[a-1][b-1] = True
    path[b-1][a-1] = True
example = [i for i in range(1, n)]

ans = 0
for ex in itertools.permutations(example):
    e = [0] + list(ex)
    for a, b in zip(e, e[1:]):
        if path[a][b] is False:
            break
    else:
        # print(e)
        ans += 1
print(ans)

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

typedef long long ll;
typedef long double ld;
#define PI 3.14159265
const ll N=2e5 + 5;
const ll mod=1e9 + 7;
#define debug(x) cerr<<#x<<" is "<<x<<endl;

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

    ld a,b,x;
    cin>>a>>b>>x;

    ld cur_h = x/(a*a);
    //debug(cur_h);
    ld ans;
    if(2*cur_h < b)
        ans = atan2(2.0*x , a*b*b);
    else
        ans = atan2(a*a*a , 2.0*(b*a*a - x));

    cout<<fixed<<setprecision(18)<<90.00 - ans*180 / PI;

}


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

int N,K;


int main() {
  int tmp,a,min,c;
    c=0;
    tmp=0;
    min=1000000000;
    cin>>N>>K;
    a=N-K+1;
    int h[N];
    for(int i=0;i<N;i++)
    {
        cin>>h[i];
 
    }
    sort(h, h + N);

    for(int i=0;i<a;i++)
    {
        c=abs(h[i]-h[i+K-1]);
 
        if(c<min)
        {
            min=c;
        }
    }
 
    cout<<min<<endl;
}

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

int main() {
	int n,m,i,j,k,ans,cur;
	cin >> n;
	vector<int> a(n);
	
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	ans=0;
	for(i=0; i<n-1; i++){
		if(a[i]==a[i+1]){
			ans++;
		}
	}
	if(ans==0){
		cout << "YES";
	}else{
		cout << "NO";
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MAX 105

int Mytime = 1;
int d[MAX], f[MAX];
struct Vertex {
	int degree;
	vector<int> adj;
	Vertex(int x = 0) {
		degree = x;
	}
};
vector<Vertex> v;

void DFS(int now) {
	if (d[now] != 0) // 已经搜索过了
		return;
	d[now] = Mytime;
	Mytime++;
	int count;
	for (count = 0; count < v[now].degree; count++) {
		DFS(v[now].adj[count]);
	}
	f[now] = Mytime;
	Mytime++;
}

int main(void) {
	int n, i, j;
	Vertex temp;
	v.push_back(temp);
	cin >> n;
	int u, k, ve;
	for (i = 1; i <= n; i++) {
		d[i] = f[i] = 0;
		cin >> u >> k;
		v.push_back(temp);
		v[i].degree = k;
		while (k--) {
			cin >> ve;
			v[u].adj.push_back(ve);
		}
	}
	for (i = 1; i <= n; i++) {
		DFS(i);
	}
	for (i = 1; i <= n; i++) {
		cout << i << " " << d[i] << " " << f[i] << endl;
	}

}


Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://arc059.contest.atcoder.jp/tasks/arc059_b>
 問題文============================================================
 文字列 t について、t の長さが 2 以上であり、かつ t の中の文字のうち過半数が同じ文字であるとき、
 t をアンバランスであると呼ぶことにします。
 例えば、voodoo や melee はアンバランスであり、noon や a はアンバランスではありません。
 
 小文字のアルファベットからなる文字列 s が与えられます。
 s にアンバランスな (連続する) 部分文字列が存在するか判定してください。
 存在する場合は、s の中でそのような部分文字列が存在する位置を一つ示してください。
 =================================================================
 
 解説=============================================================
 アンバランスな文字には必ず ”XX” or "XYX" といったアンバランスな文字が含まれる。
 よって、この２パターンだけを確認すれば良い
 ================================================================
 */
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    int l = -1, r = -1;
    
    for(int i = 0; i < (int)s.length()-1;i++){
        if(s[i] == s[i+1]){
            l = i; r = i+1;
            break;
        }
    }
    if(l != -1){
        cout << l + 1 << " " << r + 1 << endl; return 0;
    }
    for(int i = 0; i < (int)s.length()-2;i++){
        if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]){
            l = i; r = i+2; break;
        }
    }
    if(l != -1){
        cout << l+1 << " " << r+1 << endl;
    }else{
        cout << -1 << " " << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2020;
int i,j,k,n,m,ch,ans;
char s[N][N];
int a[N][N],h[N],d[N];
int main() {
	scanf("%d%d",&n,&m);
	ans=max(n,m);
	for (i=1;i<=n;i++) scanf("%s",s[i]+1);
	for (i=1;i<n;i++)
		for (j=1;j<m;j++) {
			int t=0;
			if (s[i][j]=='#') t++;
			if (s[i][j+1]=='#') t++;
			if (s[i+1][j]=='#') t++;
			if (s[i+1][j+1]=='#') t++;
			a[i][j]=t&1;
		}
	for (i=1;i<=n;i++) {
		for (j=1;j<m;j++) {
			if (a[i-1][j]) h[j]=1;
			else h[j]++;
		}
		k=0;
		for (j=1;j<m;j++) {
			while (h[j]<=h[d[k]]) {
				ans=max(ans,h[d[k]]*(j-d[k-1]));
				k--;
			}
			d[++k]=j;
		}
		while (k) ans=max(ans,h[d[k]]*(m-d[k-1])),k--;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 20096
use std::io;
use std::str::FromStr;

type Restaurant = (String, i32, i32);

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_restaurant() -> (String, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let mut s = line.split_whitespace();
    let name = s.next().unwrap().to_string();
    let score: i32 = s.next().unwrap().parse().unwrap();
    (name, score)
}

fn main() {
    let n: i32 = input();
    let mut restaurants: Vec<Restaurant> = Vec::new();
    for i in 0..n {
        let restaurant = input_restaurant();
        restaurants.push((restaurant.0, restaurant.1, i+1));
    }    
    restaurants.sort_by(|a, b| b.1.cmp(&a.1));
    restaurants.sort_by(|a, b| a.0.cmp(&b.0));
    // println!("{:?}", restaurants);
    for restaurant in restaurants {
        println!("{}", restaurant.2);
    }
}


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



int main() {
  int N; cin >> N;
  vector<int> A(N+2);
  A.push_back(0);
  for(int i=1; i<N+1; i++) cin >> A[i];
  A.push_back(0);

  int sum = 0;
  for(int i=0; i<N+1; i++){
    sum += abs(A[i]-A[i+1]);
  }

  for(int i=0; i<N; i++){
    if(A[i+1] >= A[i] && A[i+1] <= A[i+2] || A[i+1] <= A[i] && A[i+1] >= A[i+2]){
      cout << sum << endl;
    }else{
      cout << sum - 2*min(abs(A[i+1]-A[i]), abs(A[i+1]-A[i+2])) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<=b;++i)
const int N=2005,P=924844033;
int tot,ans;
int n,k,a[N],fac[N];
long long f[N][N][2][2];
bool vis[N];
int main(void) {
    cin>>n>>k;
    fac[0]=1;
    FOR(i,1,n) fac[i]=1LL*fac[i-1]*i%P;
    FOR(i,1,n) if(!vis[i]) for(int j=i;j<=n;j+=k) vis[j]=1,a[++tot]=j;
    f[0][0][0][0]=1;
    https://www.luogo.org/
    a[0]=-(1<<30);
    FOR(i,1,n) {
        f[i][0][0][0]=1;
        FOR(j,1,i) {
            f[i][j][0][0]=(f[i-1][j][1][0]+f[i-1][j][0][0]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][0])%P;
            f[i][j][0][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][1][0]+f[i-1][j-1][0][0])%P;
            f[i][j][1][0]=(f[i-1][j][0][1]+f[i-1][j][1][1]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][1])%P;
            f[i][j][1][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][0][1]+f[i-1][j-1][1][1])%P;
        }
    }
    FOR(i,0,n) {
        int sum=(f[n][i][0][0]+f[n][i][0][1]+f[n][i][1][0]+f[n][i][1][1])%P;
        if(i&1) (ans+=P-1LL*sum*fac[n-i]%P)%=P;
        else (ans+=1LL*sum*fac[n-i]%P)%=P;
    }
    printf("%d\n",ans);
    fclose(stdin);fclose(stdout);
}

Measured memory_bytes: 123776
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <map>
#include <cassert>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;



int main(){
	int n, k, m, k2;
	int next[10001];
	while(cin >> n >> k >> m && (n || k ||m)){
		for(int i = 1; i < n; i++) next[i] = i + 1;
		next[n] = 1;
		if(m != 1)next[m-1] = next[m];
		else next[n] = next[1];
		n--;
		while(next[m] != m){
			k2 = k % n;
			while(k2 < 2) k2 += n;
			for(int i = 1; i < k2; i++){
				m = next[m];
			}
			next[m] = next[next[m]];
			n--;
		}
		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 908
class Tree():
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append(e[1] - indexed)
            self.tree[e[1] - indexed].append(e[0] - indexed)

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.order = []
        self.order.append(root)
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj]

import sys
input = sys.stdin.readline

N, u, v = map(int, input().split())
u -= 1; v -= 1
E = [tuple(map(int, input().split())) for _ in range(N - 1)]

t = Tree(N, E)
t.setroot(u); dist1 = t.depth
t.setroot(v); dist2 = t.depth

tmp = 0
for i in range(N):
    if dist1[i] < dist2[i]:
        tmp = max(tmp, dist2[i])

print(tmp - 1)

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

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

int main(void){
    int n, t[100], m, p, x, sum = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> t[i];
        sum += t[i];
    }

    cin >> m;
    REP(i, m) {
        cin >> p >> x;
        cout << sum - t[p - 1] + x << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int l;
    int r;
    int d;
    scanf("%d", &l);
    scanf("%d", &r);
    scanf("%d", &d);
    int ans = 0;

    for(int x = l ; x <= r ; x++){
      for(int y = 1  ; d*y <= r ; y++){
        if(y*d==x){ans++;}
      }
    }

    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;

int solve(int an,int ap, int bn, int bp){
  int answer=0;
  REP(pairs,min(an,bn)+1)
    answer=max(answer,pairs+min(an-pairs,ap)/2+min(bn-pairs,bp)/2);
  return answer;  
}
int main(void)
{
  int n,m;
  cin >> n >> m;
  vector<int> bu(131072,0),bun(131072,0),bup(131072,0);
  REP(i,n){
    int x;
    cin >> x;
    bu[x]++;
  }
  REP(i,131072){
    bun[i%m]+=bu[i];
    bup[i%m]+=bu[i]/2*2;
  }
  int answer=bun[0]/2;
  if(m%2==0) answer+=bun[m/2]/2;
  for(int i=1;i*2<m;++i) answer+=solve(bun[i], bup[i], bun[m-i], bup[m-i]);
  cout << answer << endl;
  return 0;
}

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

bool cmp(const string &a, const string &b) {
    return a+b < b+a;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,l;
    while(cin >> n >> l) {
        vector<string> v(n);
        for(int i = 0; i < n; i++) {
            cin >> v[i];
        }
        sort(v.begin(), v.end(), cmp);
        for(auto s : v) {
            cout << s;
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


# nの逆元のリスト
def inv_mod(n: int, mod: int) -> list:
    inv = [0, 1]
    for i in range(2, n + 1):
        inv.append(mod - ((mod // i) * inv[mod % i]) % mod)
    return inv


# nの階乗のリスト
def fact(n: int, mod: int) -> list:
    fac = [1, 1]
    res = 1
    for i in range(2, n + 1):
        res = res * i % mod
        fac.append(res)
    return fac


# nの階乗の逆元のリスト
def fact_inv(n: int, inv: list, mod: int) -> list:
    facInv = [1, 1]
    for i in range(2, n + 1):
        facInv.append(facInv[i - 1] * inv[i] % mod)
    return facInv


# 二項係数
def nCr(n: int, r: int, mod: int, fac: list, facInv: list) -> int:
    if not (0 <= r and r <= n):
        return 0

    return ((fac[n] * facInv[r]) % mod) * facInv[n - r] % mod


def get_gates(h, w, a, b):
    i = 0
    gates = []
    while h-a-1-i >= 0 and b+i < w:
        gates.append((h-a-1-i, b+i))
        i += 1

    return gates


h, w, a, b = li()
MOD = 10**9 + 7

gates = get_gates(h,w,a,b)

inv = inv_mod(h+w, MOD)
fac = fact(h+w, MOD)
facInv = fact_inv(h+w, inv, MOD)

ans = 0
for ri, ci in gates:
    ans += nCr(ri+ci, ci , MOD, fac, facInv) * nCr(h+w-2-(ri+ci), w-1-ci, MOD, fac, facInv)
    ans %= MOD

print(ans)

Measured memory_bytes: 38976
N=int(input())
W=[]
miss_flag=False
past_W=[]

for i in range(N):
    W.append(str(input()))

for i in range(N):
    
    if W[i] in past_W:
        miss_flag=True
        break
    if i<N-1:
        if W[i][len(W[i])-1]!=W[i+1][0]:
            miss_flag=True
            break    

    past_W.append(W[i])
    

if miss_flag:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
import collections
n,k = map(int,input().split())

t = list(map(int,input().split()))
c = collections.Counter(t)
score_sorted = sorted(c.items(), key=lambda x:-x[1])
count = 0
memo = 0
for i,j in score_sorted:
    memo += j
    count += 1
    if count == k:
        break
print(n-memo)

Measured memory_bytes: 101704
#include<iostream>

int search(int *n, int key, int p, int l, int count){
	int c = (p+l)/2;
	if(n[c] == key)
		return count;
	else if(p>l)
		return count-1;
	else if(n[c] < key)
		return search(n, key, c+1, l, count+1);
	else
		return search(n, key, p, c-1, count+1);
}

int main(){
	int *data, n, key;
	while(true){
		std::cin >> n;
		if(n==0)
			return 0;
		data = new int[n];
		for(int i=0; i<n; i++)
			std::cin >> data[i];
		std::cin >> key;
		std::cout << search(data, key, 0, n-1, 1) << std::endl;
		delete[] data;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int n,fi[3]={1,1,1};
scanf("%d",&n);
while(1<n--){
  fi[2]=fi[0]+fi[1];
  fi[0]=fi[1];
  fi[1]=fi[2];
 }
printf("%d\n",fi[2]);
return 0;
}

Measured memory_bytes: 596
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int x, n; cin >> x >> n;
	vector<bool> p(102);
	rep(i, n)
	{
		int y; cin >> y;
		p[y] = true;
	}
	int mnd = 1000;
	int res = 0;
	rep(i, 102)
	{
		if (p[i])continue;
		if (abs(x - i) < mnd)
		{
			res = i;
			mnd = abs(x - i);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3632
import Data.Set (fromList)
-- import Data.List

main :: IO ()
main = do
    -- let l1 = "15"
    -- let l2 = "1 3 5 2 1 3 2 8 8 6 2 6 11 1 1"
    l1 <- getLine
    l2 <- getLine
    let n = read l1 :: Int
    let as = (map read . words) l2 :: [Int]
    putStrLn $ solve n as

solve :: Int -> [Int] -> String
solve n as = show . removeDup $ (x, n-x)
    where x = countDup as

removeDup :: (Int, Int) -> Int
removeDup (0, uni) = uni
removeDup (1, uni) = uni - 1
removeDup (x, uni) = removeDup (x-2, uni)

countDup :: [Int] -> Int
countDup as = abs $ length as - length (fromList as)


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

using namespace std;

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

  int x, y, z;
  cin >> x >> y >> z;
  swap (x, y);
  swap (x, z);

  cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int K,A,B;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}


Measured memory_bytes: 3632
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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


int main(void) {
	int a, b, h;

	cin >> a >> b >> h;

	cout << (a + b)*h / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<vector>
using namespace std;

int main(){
    int n, q, a, b, c;
    cin >> n >> q;

    vector<stack<int>> s(n);
    for(int i = 0; i < q; i++){
        cin >> a;
        if(a == 0){
            cin >> b >> c;
            s[b].push(c);
        }else if(a == 1){
            cin >> b;
            if(!s[b].empty()){
                cout << s[b].top() << endl;
            }
        }else if(a == 2){
            cin >> b;
            if(!s[b].empty())   s[b].pop();
        }
    }
    
    return 0;
}



Measured memory_bytes: 4320
#include<cstdio>
int main()
{
	char c;
	scanf("%c%*c%*c\n",&c);
	printf("%c",c);
	scanf("%*c%c%*c\n",&c);
	printf("%c",c);
	scanf("%*c%*c%c",&c);
	printf("%c",c);
	return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	int n, k;
	scanf("%d%d", &n, &k);
	vi h(n);
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);
	sort(all(h));
	n -= k;
	if (n <= 0)
		puts("0");
	else
		printf("%lld\n", accumulate(h.begin(), h.begin() + n, 0LL));
}


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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){
  
  bool pi[101];
  rep(i,101) pi[i] = false;
  
  int X, N;
  cin >> X >> N;
  rep(i,N){
    int p;
    cin >> p;
    pi[p] = true;
  }
  
  rep(i,101){
    if(i==0){
      //cout << "kohoa:" << X <<"\n";
      if(pi[X]==false){
        cout << X;
        return 0;
      }
    }else if((i%2)==1){
      //cout << "kohob:" << X-((i/2)+1) << "\n";
      if(X-((i/2)+1)<0){
        cout << X-((i/2)+1);
        return 0;
      }else if(X-((i/2)+1)>100){
        cout << X-((i/2)+1);
        return 0;
      }else{
        if(pi[X-((i/2)+1)]==false){
          cout << (X-((i/2)+1));
          return 0;
        }
      }
    }else{
      //cout << "kohoc:" << X+(i/2) << "\n";
      if(X+((i/2))>100){
        cout << X+(i/2);
        return 0;
      }else if(X+((i/2))>=0){
        if(pi[X+((i/2))]==false){
          cout << (X+((i/2)));
          return 0;
        }
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 3652
pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

fn main() {
	let input = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = Poper::new(input.split_whitespace());

	let n: usize = iter.read();
	let x: usize = iter.read();

	let mut d: usize = 0;
	let mut c: usize = 1;

	for _ in 0..n {
		let l: usize = iter.read();
		d = d + l;
		if x < d {
			println!("{}", c);
			return;
		}
		c += 1;
	}
	println!("{}", c);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

vector<ll> G[N];
ll par[N], cnt[N], h[N];
void A() {
	cout << "First";
	exit(0);
}
void B() {
	cout << "Second";
	exit(0);
}
void DFS(ll v, ll p = 0) {
	for (auto u : G[v]) {
		if (u ^ p) {
			h[u] = h[v] + 1;
			par[u] = v;
			cnt[v] ++;
			DFS(u, v);
		}
	}
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n;
    cin >> n;
    for (int i = 0; i < n - 1; i ++) {
    	ll v, u;
    	cin >> v >> u;
    	G[v].pb(u);
    	G[u].pb(v);
	}
	DFS(1);
	set<pll> s;
	for (int i = 1; i <= n; i ++) {
		s.insert({h[i], i});
	}
	if (n & 1) {
		A();
	}
	while (s.size()) {
		auto x = *s.rbegin();
		ll v = x.S;
		ll pp = par[v];
		if (cnt[pp] > 1) A();
		cnt[par[pp]] --;
		s.erase({h[v], v});
		s.erase({h[pp], pp});
		
	}
	B();
    return (0);
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i=0; i<n; i++) {
    cin >> s.at(i) >> t.at(i);
  }
  string x;
  cin >> x;
  int answer = 0;
  
  int num = 0;
  for(int i=0; i<n; i++) {
    if(s.at(i) == x) {
      num = i;
      break;
    }
  }
  for(int i=num+1; i<n; i++) {
    answer += t.at(i);
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> comb;

inline int first(int n){
	return ((1 << n) - 1);
}

int nextSet(int x){
	int small, ripple, newSmall,ones;
	
	small = x & -x;
	ripple = x + small;
	newSmall = ripple & -ripple;
	ones = (( newSmall / small ) >> 1) - 1;
	
	return (ripple | ones);
}

comb setComb(int s, int n){
	comb c;
	for(int i=1 ; i<=n ; i++){
		if( s & 1 ) c.push_back(i-1);
		s >>= 1;
	}
	return c;
}

int main(){
	int n=10, k, x, s, sum, ans;
	comb c;
	
	while( cin >> k >> s , k || s ){
		ans = 0;
		x = first(k);
		while( !(x & ~first(n) ) ){
			c = setComb( x , n );
			sum = 0;
			for(int i=0 ; i<c.size() ; i++){
				sum += c.at(i);
			}
			if( sum == s ) ans++;
			x = nextSet( x );
		}
		cout << ans << endl;
	}
}



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

using namespace std;

string ask(int x) {
	cout << x << endl;

	string s;
	cin >> s;

	if (s == "Vacant") {
		exit(0);
	}

	return s;
}

string s[100010];

bool good(int i, int j) {
	if (i % 2 == j % 2) {
		return (s[i] == s[j]);
	} else {
		return s[i] != s[j];
	}
}

void Solve() {
	int n;

	cin >> n;

	s[0] = ask(0);
	int last = 0;

	int lo = 0, hi = n-1;

	while (hi - lo > 1) {
		int mid = (lo + hi) / 2;
		s[mid] = ask(mid);
		if (good(last, mid)) {
			lo = mid;
			last = mid;
		} else {
			hi = mid;
		}
	}
	ask(lo);
	ask(hi);
}


int main() {
	int tests = 1;

	for (;tests; --tests) {
		Solve();
	}
}

Measured memory_bytes: 1620
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, k;
    long long sum = 0;
    cin>>n>>k;
    vector<long long> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(), h.end(), greater<long long>());
    for (int i = 0; i < n-k; i++) {
        sum += h[k+i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
    int r, g, b;
    scanf("%d %d %d", &r, &g, &b);

    if ((100*r+10*g+b) % 4 == 0) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}



Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

ll x, y;
int main(){
    scanf("%lld%lld", &x, &y);
    ll ans = 0;
    while(x*(1ll<<ans) <= y)ans++;
    printf("%lld\n", ans);
    return 0;
}

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

int l;
typedef pair<int,int> pii;
vector<pii> data;
void init(){
  data.clear();
}


bool input(){
  if(!(cin>>l))return false;
  if(l==0)return false;
  for(int i=0;i<12;i++){
    int m,n;
    cin>>m>>n;
    data.push_back(pii(m,n));
  }
  return true;
}

int  solve(){
  int m=0;
  for(int i=0;i<data.size();i++){
    m+=data[i].first-data[i].second;
    if(!(m<l)){
      return i+1;
    }
  }
  return -1;
}

int main(){
  while(init(),input()){
    int ans= solve();
    if(ans==-1){
      cout<<"NA"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> x(n);
	vector<int> y(n);
	vector<ll> h(n);
	ll t_x, t_y, t_h;
	rep (i, 0, n) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0) {
			t_x = x[i];
			t_y = y[i];
			t_h = h[i];
		}
	}


	rep (i, 0, 101) { // Cx
		rep (j, 0, 101) { // Cy
			vector<ll> tmp_ans(n); // H
			ll tmp_h = max((t_h + abs(t_x - i) + abs(t_y - j)), (ll)0);
			rep (k, 0, n) {
					tmp_ans[k] = max(tmp_h - abs(x[k] - i) - abs(y[k] - j), (ll)0);
			}

			bool flg = true;
			rep (k, 0, n) {
				if (h[k] != tmp_ans[k]) {
					flg = false;
					break;
				}
			}
			if (flg) {
				cout << i << " " << j << " " << tmp_h << endl;
				i = 101;
				j = 101;
			}
		}
	}

	return 0;
}


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

struct  DICE {
    int Top;
    int Bottom;
    int Front;
    int Back;
    int Left;
    int Right;
    void roll(char S) {
        if ('N'==S) {
            swap(Back, Top);
            swap(Top, Front);
            swap(Front, Bottom);
        } else if('S'==S) {
            swap(Back, Bottom);
            swap(Bottom, Front);
            swap(Front, Top);
        } else if('W'==S) {
            swap(Right, Bottom);
            swap(Bottom, Left);
            swap(Left, Top);
        } else if('E'==S) {
            swap(Left, Bottom);
            swap(Bottom, Right);
            swap(Right, Top);
        }
        return;
    }
};

int main() {
    int n;
    cin >>n;
    vector<DICE> D(n);
    for (int i=0; i<n; i++)
        cin >>D.at(i).Top >>D.at(i).Front >>D.at(i).Right >>D.at(i).Left >>D.at(i).Back >>D.at(i).Bottom;
    bool OK=false;
    for (int i=0; i<n-1; i++)
        for (int j=i+1; j<n; j++) {
            for (int k=0; k<2; k++) {
                if (D.at(i).Front==D.at(j).Front)
                    break;
                D.at(j).roll('E');
                for (int l=0; l<4; l++) {
                    if (D.at(i).Front==D.at(j).Front)
                        break;
                    D.at(j).roll('S');
                }
            }
            if (D.at(i).Front!=D.at(j).Front)
                continue;
            for (int k=0; k<4; k++) {
                if (D.at(i).Top==D.at(j).Top)
                    break;
                D.at(j).roll('E');
            }
            if (D.at(i).Top!=D.at(j).Top)
                continue;
            if ((D.at(i).Back==D.at(j).Back)&&(D.at(i).Bottom==D.at(j).Bottom)&&(D.at(i).Left==D.at(j).Left)&&(D.at(i).Right==D.at(j).Right)) {
                cout <<"No" <<endl;
                return 0;
            } else
                continue;
        }
    cout <<"Yes" <<endl;
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
	int n=0;
	int k=0;
	vector<int> data;
	int ans=0;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		int temp=0;
		cin >> temp;
		data.push_back(temp);
	}
	sort(data.begin(),data.end(),greater<int>());
	for(int i=0;i<k;i++){
		ans+=data[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

max=0
cnt=0
for i in range(N):
    if max-H[i]>=2:
        print('No')
        break
    else:
        cnt+=1
        if H[i]>max:
            max=H[i]
if cnt==N:
    print('Yes')
  

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

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int result = 0;

	// 単品よりもABピザを買う方がお得なら、買えるだけ買ってしまう
	if (a + b > 2 * c) {
		while (x != 0 && y != 0) {
			x--;
			y--;
			result += 2 * c;
		}
	}

	// 残りのAピザ・Bピザの補填
	if (x != 0) {
		if (a < 2 * c) {
			result += a * x;
		} else {
			result += 2 * c * x;
		}
	}
	if (y != 0) {
		if (b < 2 * c) {
			result += b * y;
		} else {
			result += 2 * c * y;
		}
	}

	cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int MAX = 2e5 + 10;
typedef long long i64;
using namespace std;
const double EPS = 1e-6;

int ar[MAX];
int ars[MAX];
const int MOD = 1e9 + 7;
int main() {

    #ifdef LOCAL_DEBUG
    freopen ("data.in", "r", stdin );
    //freopen ("data.out", "w", stdout );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    #define endl '\n'
    int n; cin >> n;


    for(int i = 0; i < n; i++)cin >> ar[i];

    for(int i = 0, j = n - 1; i <= (n-1) / 2; i++, j-= 2){
    	ars[i] = ar[j];
    	if(n - i - 1 != i)ars[n - i - 1] = ar[j - 1];
    }
    for(int i = 0; i < n ; i++)cout << ars[i] << (i == n - 1 ? '\n' : ' ');
}



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

ll N, K, T, W, H, M, C;

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

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

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



int main(){
    ll l,r;
    cin >> l>> r;
    ll n = 2019;
    vector<ll> v;

    for(ll i = l; i <= min(r, l + n) ; ++i){
        v.push_back(i%n);
    }
    //sort(ALL(v));
    ll ans = 2018;
    for(int i = 0; i < v.size(); ++i){
        for(int j = i + 1; j < v.size(); ++j){
            ans = min((v[i] * v[j])%n, ans);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=205;
//i_am_noob
int n,color[maxn],dist[maxn],ans=0,u,v;
char c;
queue<int> q;
bool adj[maxn][maxn],vis[maxn];

void dfs(int u, int pa){
    vis[u]=true;
    color[u]=(pa==-1?0:1-color[pa]);
    rep(n) if(!vis[i]) if(adj[u][i]) dfs(i,u);
}

void bfs(int k){
    dist[k]=0;
    q.push(k);
    vis[k]=true;
    while(!q.empty()){
        u=q.front();
        rep(n){
            if(vis[i]) continue;
            if(adj[u][i]){
                dist[i]=dist[u]+1;
                ans=max(ans,dist[i]);
                q.push(i);
                vis[i]=true;
            }
        }
        q.pop();
    }
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep(n) rep1(j,n){
        cin >> c;
        adj[i][j]=(c=='1');
    }
    memset(vis,0,sizeof(vis));
    rep(n) color[i]=-1;
    dfs(0,-1);
    rep(n) rep1(j,n) if(adj[i][j]&&color[i]==color[j]){
        print1(-1);
        return 0;
    }
    rep(n){
        memset(vis,0,sizeof(vis));
        bfs(i);
    }
    print1(ans+1);
    return 0;
}


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

int main() {
    char c;
    
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(max(A-B*2,0))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

typedef long long ll;

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

    ll a[n], b[n];
    for(int i = 0; i < n; i++)  cin >> a[i] >> b[i];

    ll ans = 0;
    for(int i = n-1; i >= 0; i--){
        a[i] += ans;
        ans += (a[i]+b[i]-1)/b[i]*b[i] - a[i];
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    double x  ;
    cin >> x ;
    cout << x * 2 * 3.16 <<endl ;
}


Measured memory_bytes: 3788
# 木なので、任意の2点を結ぶルートはただ1つだけ存在する
# 最初にそこを順に埋めるのが最適。後は自分の陣営を埋めていく。
# 問題：点1→点Nのルートをどう求める? →幅優先探索かなぁ。

# 幅優先探索を2回やる必要がありそう
# 1回目で点1→点Nのルートを辿る。各点で1つ前の点をメモ。点Nから点1に逆にたどり、距離が半分の点Pを記録する
# 2回めでもう一度点1から辿る、点Pから先は探索しない（Snukeに取られる部分）。探索できた地点数が半分以上か否かを調べる

from collections import deque

n = int(input())
edges = [list(map(int, input().split())) for _ in range(n-1)]

neighbor = [[] for i in range(n)]
for e in edges:
    neighbor[e[0] - 1].append(e[1] - 1)
    neighbor[e[1] - 1].append(e[0] - 1)
    # 1-index → 0-index

info = [(-1, -1)] * n
info[0] = (0, -1) # 点1からの距離, 1つ点1寄りの点の番号

q = deque([])
q.append(0)

# 1回目
while True:
    v = q.popleft()
    distance = info[v][0]
    for nei in neighbor[v]:
        if info[nei][0] < 0:
            q.append(nei)
            info[nei] = (distance + 1, v)
    if len(q) == 0:
        break

# print(info)

# 点1〜点Nの距離が 10の場合、先手は5まで行ける。11の場合、5まで行ける。
# 逆に辿る
now = n-1
distance = info[n-1][0]
half = distance // 2

if distance == half + 1:
    # distance = 1の場合
    snuke_side_marginal = now
else:
    while True:
        now = info[now][1]
        distance -= 1
        if distance == half + 1:
            snuke_side_marginal = now
            break

# print(snuke_side_marginal)

info = [(-1, -1)] * n
info[0] = (0, -1) # 点1からの距離, 1つ点1寄りの点の番号

q = deque([])
q.append(0)

n_visited = 1
# 2回目

while True:
    v = q.popleft()
    distance = info[v][0]
    for nei in neighbor[v]:
        if info[nei][0] < 0 and nei != snuke_side_marginal:
            q.append(nei)
            info[nei] = (distance + 1, v)
            n_visited += 1

    if len(q) == 0:
        break

if n_visited > n - n_visited:
    print('Fennec')
else:
    print('Snuke')


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//template end

typedef pair<ll,int> P;
vector<P> g[100010]; ll dist[100010]={};

int main(){
    int n,m; scanf("%d%d",&n,&m);
    int imos[100010]={};
    rep(i,0,m){
        int u,v,w; scanf("%d%d%d",&u,&v,&w);
        u--; v--;
        g[u].push_back({v,w});
        imos[u]++; imos[v]--;
    }
    rep(i,0,100001)dist[i]=INF,imos[i+1]+=imos[i];
    rep(i,0,n-1)if(imos[i]){
        g[i+1].push_back({i,0});
    }
    priority_queue<P,vector<P>,greater<P>> pq;
    dist[0]=0; pq.push({0,0});
    while(!pq.empty()){
        auto p=pq.top(); pq.pop();
        ll d=p.first,v=p.second;
        if(dist[v]<d)continue;
        for(P to:g[v]){
            if(chmin(dist[to.first],d+to.second))pq.push({dist[to.first],to.first});
        }
    } ll ans=dist[n-1];
    printf(ans==INF?"-1\n":"%lld\n",ans);
    return 0;
}

Measured memory_bytes: 9852
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string s;

void f(char c){
  if(c == 'C'){
    s = s.substr(1, s.size() - 1) + s.substr(0, 1);
  }else if(c == 'J'){
    s = s.substr(s.size() - 1, 1) + s.substr(0, s.size() - 1);
  }else if(c == 'E'){
    int qwe = s.size() / 2;
    if(s.size() % 2)s = s.substr(qwe + 1, qwe) + s.substr(qwe, 1) + s.substr(0, qwe);
    else s = s.substr(qwe, qwe) + s.substr(0, qwe);
  }else if(c == 'A'){
    reverse(all(s));
  }else if(c == 'M'){
    int i;
    rep(i, s.size())if('0' <= s[i] && s[i] <= '9'){
      s[i] == '9' ? s[i] = '0' : ++s[i];
    }
  }else if(c == 'P'){
    int i;
    rep(i, s.size())if('0' <= s[i] && s[i] <= '9'){
      s[i] == '0' ? s[i] = '9' : --s[i];
    }
  }
  return;
}

signed main(void){
  int i, j, k;
  int(n);
  for(int testcase = 0;testcase < n;testcase++){
    string t;
    cin >> t >> s;
    per(i, t.size())f(t[i]);
    pri(s);

    s.clear(); t.clear();
//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1220