akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int x;
    cin >> x;
    for (int i = 1; i * 100 <= x; i++)
    {
        int r = x - i * 100;
        if (0 <= r && r <= 5 * i)
        {
            cout << 1 << endl;
            return;
        }
    }
    cout << 0 << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int 
#define pb push_back 
#define im (int i = 2 ; i <= 100 ; i++)
#define jx (int j = 0 ; j <= 100 ; j++)
#define kn (int k = 0 ; k <= 100 ; k++)
#define ln (int l = 0 ; l <= 100 ; l++)
#define pn (int p = 0 ; p <= 100 ; p++)
#define wq while (q--)
 
 
int main ()
{
    int n  , a , b ;
    cin >> n ;
    
    if (n < 100)
    {
        printf("0\n");
        return 0 ;
    }

    for im
    {
        a = (105 * (i - 1));
        b = i * 100 ;

       // cout << a << endl ;
        //cout << b << endl ;

        if (n < b && n > a)
        {
            printf("0\n");
            return 0 ; 
        }
    }
 
    printf("1\n");
    return 0 ;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int a,b;
    Scd2(a,b);

    int cnt = 0;
    int ans = 1;

    while( ans < b ){
        ans--;
        ans += a;
        cnt++;
    }

    printf ("%d\n", cnt );

    return 0;
}





Measured memory_bytes: 256
N = int(input())
v_l = list(map(int, input().split()))
c_l = list(map(int, input().split()))
net = [v_l[i] - c_l[i] for i in range(N)]
max = 0
for i in range(N):
  if net[i] > 0:
    max = max + net[i]
  else:
    max = max
print(max)

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

int main()
{
  string s;
  cin >> s;
  ll zero, one;
  zero = one = 0;
  for (ll i = 0; i < s.size(); i++)
  {
    if (s[i] == '0')
    {
      zero++;
    }
    else
    {
      one++;
    }
  }
  cout << min(zero, one) * 2 << endl;
}


Measured memory_bytes: 3760
# -*- coding: utf-8 -*-
"""
Created on Sun Jan  6 19:26:10 2019

@author: Yamazaki Kenichi
"""

N = int(input())
h = list(map(int,input().split()))
h = [0]+h

cost=[]
for i in range(N+1):
    if i <= 1:
        cost.append(0)
    elif i == 2:
        cost.append(abs(h[2]-h[1]))
    else:
        cost.append(min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2])))
print(cost[N])


Measured memory_bytes: 13928
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n, m;
	int i;
	long long dp[100001];
	bool broken[100001] = { 0, };
	int input;

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

	for (i = 0; i < m; i++)
	{
		scanf("%d", &input);

		broken[input] = true;
	}

	dp[0] = 1;
	dp[1] = !broken[1];

	for (i = 2; i <= n; i++)
	{
		if (broken[i])
		{
			dp[i] = 0;

			continue;
		}

		dp[i] = (dp[i - 2] + dp[i - 1]) % 1000000007;
	}

	printf("%lld\n", dp[n]);

	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

def main():
    x, y = map(int, input().split())

    # どちらも正またはどちらも負の場合
    if (x > 0 and y > 0) or (x < 0 and y < 0):
        # 目標の方が大きければ、ひたすら加算
        if x < y:
            ans = y - x
        # 目標の方が小さければ、符号判定して加算し、符号を戻す。
        else:
            ans = x - y + 2

    # x が 0 のパターン
    elif x == 0:
        # 目標が正なら、ひたすら加算。目標が負なら反転が必要
        if y > 0: ans = y
        else: ans = abs(y) + 1

    # y が 0 のパターン
    elif y == 0:
        # 開始が負なら、ひたすら加算。開始が正なら反転が必要
        if x < 0: ans = abs(x)
        else: ans = x + 1

    # 正負が不一致の場合
    else:
        # 反転1回と差の絶対値回数の加算が必要
        ans = abs(abs(x) - abs(y)) + 1

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  cout << N/3 << endl;
  return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
S = list(input())
if S[K-1] == "A":
    S[K-1] = "a"
if S[K-1] == "B":
    S[K-1] = "b"
if S[K-1] == "C":
    S[K-1] = "c"

print(*S, sep="")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
using namespace std;


int main(){
    string s;
    for (int i = 0; i < 3; i++) {
        cin >> s;
        cout << s[i];
    }
    cout << endl;
}

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

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    UnionFind (int n) {
        par.resize(n, -1);
        rank.resize(n, 1);
    }
    int find (int a) {
        if (par[a] == -1) return a;
        return par[a] = find(par[a]);
    }
    void unite (int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) return;
        if (rank[a] < rank[b]) {
            par[a] = b;
        } else {
            par[b] = a;
            if (rank[a] == rank[b]) {
                rank[a]++;
            }
        }
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i, n) {
        if (p[i] == i) ans++;
        else if (uf.find(i) == uf.find(p[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
struct node{
	int p;
	long long v;
}a[maxn];
int n,s;
int stk[maxn],top;
int Abs(int x){
	return x>0?x:-x;
}
int main(){
	scanf("%d%d",&n,&s);
	for(int i=1;i<=n;i++)
		scanf("%d%lld",&a[i].p,&a[i].v);
	int l=1,r=n;
	while(1){
		if(a[l].p>=s){
			for(int i=r;i>=l;i--)
				stk[++top]=a[i].p;
			break;
		}
		if(a[r].p<=s){
			for(int i=l;i<=r;i++)
				stk[++top]=a[i].p;
			break;
		}
		if(a[l].v>=a[r].v){
			stk[++top]=a[r].p;
			a[l].v+=a[r].v,r--;
		}
		else{
			stk[++top]=a[l].p;
			a[r].v+=a[l].v,l++;
		}
	}
	long long ans=0;
	stk[++top]=s;
	for(int i=top-1;i>=1;i--)
		ans=ans+Abs(stk[i+1]-stk[i]);
	printf("%lld\n",ans);
	return 0;
}


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

#define ll long long

#define si(x) scanf("%d", &x)
#define sll(x) scanf("%lld", &x)

#define pi(x) printf("%d", x)

int main()
{
    ll t, n, count = 0, m;
    string s;

    cin >> s;

    if (s[s.length() - 1] != 's')
    {
        cout << s + 's';
    }
    else
    {
        cout << s + "es";
    }

    return 0;
}

Measured memory_bytes: 3628
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(void) {
    int n;
    cin >> n;
    vector<char>c(n);
    ll r = 0;
    rep(i, n) {
        cin >> c[i];
        if (c[i] == 'R') {
            ++r;
        }
    }
    ll ans = 0;
    rep(i, r) {
        if (c[i] != 'R') {
            ++ans;
        }
    }
    cout << ans;
}

/*
*/


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a[3];
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		cout << (hypot(a[0], a[1]) == a[2] ? "YES\n" : "NO\n");
	}
}


Measured memory_bytes: 3176
ans = 'Yes'
N = int(input())
H_list = input().split()
H_list = [int(H_list[i]) for i in range(N)]

if N == 1:
    print(ans)
else: 
    first_H = H_list[0]
    second_H = H_list[1]
    if first_H - second_H >= 2:
        ans = 'No'
        print(ans)
    else:
        first_H -= 1
        for i in range(2, N):
            if second_H - H_list[i] >= 2:
                ans = 'No'
                break
            elif second_H - H_list[i] == 1:
                if first_H >= second_H:
                    ans = 'No'
                    break
                else:
                    second_H -= 1
            elif first_H < second_H:
                second_H -= 1
            first_H = second_H
            second_H = H_list[i]
        print(ans)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)
const int INF = 1e9 + 1;

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

  int ans = INF;
  rep(i, 0, 1e5 + 1) {
    ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b);
  }
  cout << ans << endl;
}

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

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

#define int long long
#define fi first
#define se second
#define ponto pair<int,int>

int n,k;

int32_t main()
{
	cin >> n >> k;
	int m = n/k;
	if(n == 0) cout << n << '\n';
	else if(n >= k) cout << min(abs(m*k - n), abs((m+1)*k - n)) << '\n';
	else if(n < k and n <= k/2) cout << n << '\n';
	else if(n < k and n > k/2) cout << k-n << '\n'; 
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Ord (comparing)

f :: (Int, Int) -> (Int, Int) -> Int
f (a, b) (c, d) = abs (a - c) + abs (b - d)

g :: (Int, Int) -> [(Int, Int)] -> Int
g xs yss = fst . minimumBy (comparing snd) . zip [1..] $ fmap (f xs) yss

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine
    as <- replicateM n $ do
        [a, b] <- fmap read . words <$> getLine :: IO [Int]
        return (a, b)
    bs <- replicateM m $ do
        [a, b] <- fmap read . words <$> getLine :: IO [Int]
        return (a, b)
    let ans = fmap (flip g bs) as
    mapM_ print ans

Measured memory_bytes: 1020
#include <sstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define INF 1000000000000
#define int long long

template<typename T>
void printVec(vector<T> &v) {
    for(int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

signed main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> v(n + 1, 0);
    for(int i = 0; i < n; i++) {
        if(s[i] == '.') v[i + 1] = v[i] + 1;
        else v[i + 1] = v[i];
    }

    int ans = INF;
    for(int i = 0; i < n + 1; i++) {
        ans = min(ans, i - v[i] + (v[n] - v[i]));
    }

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


Measured memory_bytes: 2180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    unsigned int a = 0xAAAAAAAAU;
    unsigned int r = a ^ a + n;

    unsigned int k = 1U << 31;

    do {
        if (r & k) break;
        k >>= 1;
    } while (k);

    do {
        cout << (bool)(r & k);
        k >>= 1;
    } while (k);

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define PB push_back
#define ll long long
#define pii pair<ll,ll>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 20
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
const int maxn=1e6+10;
using namespace std;


int main(){
    ll a,b;
    cin>>a>>b;
    if(a==1||b==1) cout<<1<<endl;
    else cout<<(a*b+1)/2<<endl;
    return 0;
}
/* a
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    int n;
    cin>>n;
    cout<<a[n-1]<<endl;
    return 0;
}
*/



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

int main() {
    std::ios::sync_with_stdio(false);
    lld tc = 1;
    // cin >> tc;
    while (tc--) {
        lld x;
        cin >> x;

        if (x >= 1800 && x <= 1999) {
            cout << 1;
        } else if (x >= 1600 && x <= 1799) {
            cout << 2;
        } else if (x >= 1400 && x <= 1599) {
            cout << 3;
        } else if (x >= 1200 && x <= 1399) {
            cout << 4;
        } else if (x >= 1000 && x <= 1199) {
            cout << 5;
        } else if (x >= 800 && x <= 999) {
            cout << 6;
        } else if (x >= 600 && x <= 799) {
            cout << 7;
        } else if (x >= 400 && x <= 599) {
            cout << 8;
        }
        cout << "\n";
    }
}

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

int main() {

    string s; cin >> s;

    if ( s.size() == 2 && s[0] == s[1] ) {
        cout << 1 << " " << 2 << endl;
        return 0;
    } 

    for (int i = 1; i < s.size() - 1; i++) {
        if (s[i-1] == s[i]) {
            cout << i << " " << i+1 << endl;
            return 0;
        } else if (s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        } else if (s[i-1] == s[i+1]) {
            cout << i << " " << i+2 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;

    return 0;
}


Measured memory_bytes: 512
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string str;
	cin>>str;
	deque<char> dq;
	for(auto i:str)
		dq.push_back(i);
	int isflip=0;
	int q;
	cin>>q;
	for(int i=1;i<=q;i++){
		int op;
		cin>>op;
		if(op==1)
			isflip=(!isflip);
		else{
			int isend;
			char ch;
			cin>>isend>>ch;
			if((isflip)^(isend-1))
				dq.push_back(ch);
			else
				dq.push_front(ch);
		}
	}
	if(isflip)
		reverse(dq.begin(),dq.end());
	for(auto i:dq)
		cout<<i;
	return 0;
}

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

using namespace std;

int main() {
	int n, m;
	long sum = 0;
	cin >> n >> m;
	int a[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	
	sort(a, a + n);
	
	if (a[n - m] >= sum / (double) m / 4.0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    int N;

    vector<ll> X;
    vector<ll> sX;

    cin >> N;
    X.resize(N);
    sX.resize(N);

    for (int i = 0; i < N;i++)
    {
        cin >> X[i];
        sX[i] = X[i];
    }
    sort(X.begin(), X.end());

    ll ln = X[N / 2 - 1];
    ll rn = X[N / 2];

    for (int i = 0; i < N;i++)
    {
        if(sX[i] < rn)
        {
            cout << rn << endl;
        }
        else
        {
            cout << ln << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>

int min(int a, int b){
  return a < b ? a :b;
}

int main(){
  int n,y,
      i,j,
      ye,ne,
      flag=0;
  
  scanf("%d%d", &n, &y);
  y /= 1000;
  
  for(i = min(y/10, n); 0<=i; i--){
    for(j = min((y-10*i)/5, n-i); 0<=j; j--){
      if(i*10 + j*5 + (n-i-j) == y){
        printf("%d %d %d", i, j, n-i-j);
        flag = 1;
        break;
      }
    }
    if(flag){
      break;
    }
  }
  
  if(flag==0){
    printf("-1 -1 -1");
  }
  return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var c1 = Console.ReadLine();
            var c2 = Console.ReadLine();

            if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0])
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 11092
package main

import (
	"fmt"
	"math"
)

func main() {
	var R int
	_, err := fmt.Scanf("%d", &R)
	if err != nil {
		panic(err)
	}
	d := float64(R)
	c := d * 2.0 * math.Pi
	fmt.Println(c)
}

Measured memory_bytes: 1824
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class agc023_b {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<string> S(N);
        for (int i = 0; i < N; ++i) {
            in >> S[i];
        }
        int res = 0;
        for (int b = 0; b < N; ++b) {
            bool ok = true;
            for (int i = 0; i < N; ++i) {
                for (int j = 0; j < N; ++j) {
                    if (S[i][(j + b) % N] != S[j][(i + b) % N]) {
                        ok = false;
                    }
                }
            }
            res += ok * N;
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	agc023_b solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int i,n,s=0,t;
	cin>>n;
	vi a(n+1),b(n+1),c(n+1);
	for1(i,n) cin>>a[i];
	for1(i,n) cin>>b[i];
	for1(i,n-1) cin>>c[i];
	t = a[1];
	for1(i,n){
		if(a[i] - t == 1) s+=c[t];
		s += b[a[i]];
		t = a[i];
		}
	cout<<s<<nw;
	
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

void solve() {
    int n, m; scanf("%d%d", &n, &m);
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        int a; scanf("%d", &a);
        ans += a;
    }
    ans = n-ans;
    printf("%d", ans>=0?ans:-1);
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

int main() 
{
    int n;
    cin >> n;
    int b[n-1];
    rep(i,n) cin >> b[i];
    int ans = 0;

    ans += b[0];
    for(int i=1; i<=n-2; i++) {
        ans += min(b[i-1], b[i]);
    }
    ans += b[n-2];

    cout << ans << endl;

    return 0;
}


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

constexpr auto mod = 998244353ll;

long long inverse(long long x) {
    auto ret = 1ll;
    auto k = mod - 2;
    while (k) {
        if (k & 1) ret = ret * x % mod;
        x = x * x % mod;
        k /= 2;
    }
    return ret;
}

long long gcd(long long a, long long b) {
    if (a < b) std::swap(a, b);
    if (a % b) return gcd(b, a % b);
    else return b;
}

int main() {
    long long ret = 0, n, a, b, k;
    scanf("%lld%lld%lld%lld", &n, &a, &b, &k);
    std::vector<long long> f(n + 1), inv(n + 1);
    f[0] = 1;
    for (auto i = 1ll; i <= n; i++) f[i] = (f[i - 1] * i) % mod;
    inv[n] = inverse(f[n]);
    for (auto i = n - 1; i >= 0; i--) inv[i] = (inv[i + 1] * (i + 1)) % mod;

    auto bp = b / gcd(a, b);
    for (auto i = 0ll; i <= n;) {
        if ((k - i * a) % b) {
            i++;
            continue;
        }
        auto j = (k - i * a) / b;
        if (j > n || j < 0) {
            i += bp;
            continue;
        }
        ret = (ret + f[n] * inv[i] % mod * inv[n - i] % mod * f[n] % mod * inv[j] % mod * inv[n - j] % mod) % mod;
        i += bp;
    }
    printf("%lld\n", ret);

    return 0;
}

Measured memory_bytes: 4992
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    double n,k;
    cin >> n >> k;
    double ans=0;

    FOR(i,1,n+1){
        if(i<k){
            ans += pow(0.5,ceil(log(k/i)/log(2)))/n;
        }else{
            ans += 1/n;
        }
    }
    cout << std::setprecision(15) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
p = 10**9+7
N = int(input())
S1 = input().strip()
S2 = input().strip()
cnt = 1
cur = 0
if S1[0]==S2[0]:
    cnt = 3
    cur += 1
else:
    cnt = 6
    cur += 2
while cur<N:
    if S1[cur]==S2[cur]:
        if S1[cur-1]==S2[cur-1]:
            cnt = (cnt*2)%p
        cur += 1
    else:
        if S1[cur-1]==S2[cur-1]:
            cnt = (cnt*2)%p
        else:
            cnt = (cnt*3)%p
        cur += 2
print(cnt)        

Measured memory_bytes: 61920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int r,d,x;
    cin >> r >> d >> x;
    FOR(i,1,11){
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

void outPut(int Array[],char mark){
	for(int i = 1; i <= 13; i++){
		if(Array[i] == 0) printf("%c %d\n",mark,i);
	}
}

int main(){
	char mark[2];
	int n,S[14],H[14],C[14],D[14],card;
	for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s %d",mark,&card);
		switch(mark[0]){
		case 'S':
			S[card] = 1;
			break;
		case 'H':
			H[card] = 1;
			break;
		case 'C':
			C[card] = 1;
			break;
		case 'D':
			D[card] = 1;
			break;
		}
	}
	outPut(S,'S');
	outPut(H,'H');
	outPut(C,'C');
	outPut(D,'D');
}


Measured memory_bytes: 2584
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    auto n = read<int>();
    auto v = read<std::tuple<int, int, int>>(n - 1);
    std::vector<std::vector<std::pair<int, int>>> tree(n);
    for (auto vv : v) {
        tree[std::get<0>(vv) - 1].emplace_back(std::get<1>(vv) - 1, std::get<2>(vv) % 2);
        tree[std::get<1>(vv) - 1].emplace_back(std::get<0>(vv) - 1, std::get<2>(vv) % 2);
    }
    std::vector<int> color(n);
    std::queue<std::tuple<int, int, int>> q;
    q.emplace(-1, 0, 0);
    while (!q.empty()) {
        int b, i, c;
        std::tie(b, i, c) = q.front();
        q.pop();
        color[i] = c;
        for (auto v : tree[i]) {
            if (v.first == b) continue;
            q.emplace(i, v.first, v.second ? 1 - c : c);
        }
    }
    for (auto c : color) {
        out(c);
    }
}

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


Measured memory_bytes: 8064
#include <stdio.h>
#include <string.h>
#define N 10000

typedef struct {
  char X[N];
  char Y[N];
}DATA;

int LCSLength(int,int);

int cnt=0;
int c[N][N];
DATA data[N];

int main() {

  int i,q;
  int m,n;

  scanf("%d",&q);
 
  for(i = 0; i < q; i++) {
    scanf("%s %s",&data[i].X[0],&data[i].Y[0]);
  }

  for(i = 0; i < q; i++) {
    printf("%d\n",LCSLength(strlen(data[i].X),strlen(data[i].Y)));
    cnt++;
  }
 
  return 0;
}

int LCSLength(int m,int n)
{
  int i,j;
 
  for(i = 1; i < m+1; i++)
    c[i][0] = 0;

  for(j = 0; j < n+1; j++)
    c[0][j] = 0;

  for(i = 1; i < m+1; i++) {
    for(j = 1; j < n+1; j++) {
      if(data[cnt].X[i-1] == data[cnt].Y[j-1])
	c[i][j] = c[i-1][j-1] + 1;
      else if(c[i-1][j] >= c[i][j-1])
	c[i][j] = c[i-1][j];
      else
	c[i][j] = c[i][j-1];
    }
  }
  return c[m][n];
}


  



Measured memory_bytes: 9840
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 10*60
#define EPS 1e-9

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) {
      res=res*x%m;
    }
    return res;
}


signed main(){
  int N;cin>>N;
  int ans=0;
  vector<int> v(N);
  REP(i,0,N){
    cin>>v[i];
  }
  sort(ALL(v));
  if(N%2==1){
    bool flg=true;
    if(v[0]!=0)flg=false;
    for(int i=1;i<N;i+=2){
      if(v[i]!=i+1||v[i+1]!=i+1){
        flg=false;
      }
    }
    if(!flg){
      print(0);
      return 0;
    }
    ans=mod_pow(2,N/2,MOD);
    print(ans)
  }
  else {
    bool flg=true;
    for(int i=0;i<N;i+=2){
      if(v[i]!=i+1||v[i+1]!=i+1){
        dbg
        flg=false;
      }
    }
    if(!flg){
      print(0);
      return 0;
    }
    ans=mod_pow(2,N/2,MOD);
    print(ans)
  }
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int counter[100005];
int main()
{
    ll n;cin >> n;
    vector<ll> a(n);rep(i,n) cin >> a[i];
    ll q; cin >> q;
    vector<ll> b(q);
    vector<ll> c(q);
    rep(i,q)cin >> b[i] >> c[i];
    ll sum = 0;
    rep(i,n)
    {
        counter[a[i]]++;
        sum += a[i];
    }
    rep(i,q)
    {
        counter[c[i]] += counter[b[i]];
        sum = sum-counter[b[i]]*b[i]+counter[b[i]]*c[i];
        counter[b[i]]= 0;
        cout << sum << endl;
    }


}

Measured memory_bytes: 6048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
typedef long long ll;
 
int main() {
   int n;
   string s;
   cin >> n >> s;
   int x=0,ans=0;
   rep(i,s.size()){
      if(s[i]=='I'){
         x++;
         ans=max(ans,x);
      } else if(s[i]=='D')
         x--;
   }

   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void print(int a[],int N,int b){
  int i;
  for(i=0;i<N;i++){
    if(i<N-1) cout<<a[i]<<" ";
    if(i==N-1) cout<<a[i]<<endl;  
}
  cout<<b<<endl;
}
void bubble(int a[],int N){
  int i,b=0,j,w=0,v;
  for(i=N-1;i>0+w;){
    w++;
    j=i;
    while(j>0){
    if(a[j]<a[j-1]){
      b++;     
      v=a[j];
      a[j]=a[j-1];
      a[j-1]=v;
    }
    j--;
    }
  }
  print(a,N,b);
}
int main(){
  int l;
  int N,i,a[100];
  cin>>N;
  for(i=0;i<N;i++){
    cin>>a[i];
  }
  bubble(a,N);
}

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

class Program
{
    static bool IsW(char c)
    {
        if (c == 'W')
            return true;
        else
            return false;
    }
    public static void Main()
    {
        string s = Console.ReadLine();
        bool t = IsW(s[0]);
        int c = 0;
        for (int i = 1; i < s.Length; i++)
        {
            if(t != IsW(s[i]))
            {
                t = IsW(s[i]);
                c++;
            }
        }
        Console.WriteLine(c);
    }
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

struct Prime {
  int n;
  vector<int> pri;
  Prime(int n) : n(n) {
    vector<bool> f(n, true);
    f[0] = f[1] = false;
    for (int i = 2; i < n; i++) {
      if (!f[i]) continue;
      pri.push_back(i);
      for (int j = i * 2; j < n; j += i) {
        f[j] = false;
      }
    }
  }
  map<i64, int> factor(i64 k) {
    map<i64, int> so;
    for (auto p : pri) {
      while (k % p == 0) k /= p, so[p]++;
    }
    if (k != 1) so[k] = 1;
    return so;
  }
};

auto prime = Prime(1000000);

void solve() {
  i64 n;
  cin >> n;
  auto mp = prime.factor(n);
  int ans = 0;
  for (auto m : mp) {
    int x = m.second;
    int now = 1;
    while (x >= now) {
      ans += 1;
      x -= now;
      now += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3892
# 日立製作所 社会システム事業部 プログラミングコンテスト2020: B – Nice Shopping
A, B, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(j) for j in input().split()]
x, y, c = [], [], []
for k in range(M):
    tmp = [int(i) for i in input().split()]
    x.append(tmp[0])
    y.append(tmp[1])
    c.append(tmp[2])

prices = []

prices.append(min(a) + min(b))

for k in range(M):
    prices.append(a[x[k] - 1] + b[y[k] - 1] - c[k])

print(min(prices))

Measured memory_bytes: 33968
#include <iostream>
#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <algorithm>
int main() {
    int N,K;
    int i,j;
    int h[100010];
    scanf("%d", &N);
    scanf("%d", &K);

    for(i=1;i<=N;i++)
        scanf("%d", &h[i]);

    int dp[100010];
    memset(dp, 0, sizeof(dp));
    dp[2] = abs(h[2]-h[1]);
    for(i=3;i<=N;i++)
    {
        int min = INT_MAX;
        int temp = i - K;
        if(temp <1) temp =1;
        for(j=temp; j<i;j++)
        {
            if(dp[j]+abs(h[i]-h[j])< min)
                min = dp[j]+abs(h[i]-h[j]);
        }
        dp[i] = min;
    }
    
    printf("%d", dp[N]);
    return  0;
}


Measured memory_bytes: 1024
### main

n = gets.strip.to_i
k = gets.strip.to_i

k.times do
  ai, bi = gets.strip.split(' ').map{|s| s.to_i - 1}

  ai = n - 1 - ai if ai > n / 2
  bi = n - 1 - bi if bi > n / 2

  ci = [ai, bi].min

  puts (ci % 3) + 1
end

Measured memory_bytes: 6112
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
struct d
{
	long long  x,num;
}a[100005];
bool cmp(d a,d b)
{
	if(a.x<b.x)
	return true;
	else
	return false;
}
int main()
{ 
    long long n,k,sum,i,key;
	while(scanf("%lld%lld",&n,&k)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%lld%lld",&a[i].x,&a[i].num);
		}
		sort(a,a+n,cmp);
		sum=0;
		for(i=0;i<n;i++)
		{
			sum+=a[i].num;
			if(sum>=k)
			{
				key=a[i].x;
				break;
			}
		}
		printf("%lld\n",key);
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  while(1){
    int n,a[1001],min=10000000;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=1;i<n;i++){
      int b=a[i]-a[i-1];
      if(b<min)min=b;
    }
    cout<<min<<endl;
  }
  return 0;
}

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

int main(){
    string s;
    while(cin >> s){
        string t(s.rbegin(), s.rend());
        for(char &c : s){
            if(false) {}
            else if(c == 'b') c = 'd';
            else if(c == 'd') c = 'b';
            else if(c == 'p') c = 'q';
            else if(c == 'q') c = 'p';
        }
        cout << (s == t ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 512
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		
		int distance = 0;
		while(true) {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		}
	}
}


Measured memory_bytes: 35784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
bool isok(P a,P b,ll c)
{
	ll a1 = a.first;
	ll a2 = a.second;
	ll b1 = b.first;
	ll b2 = b.second;
	ll cc = (b1+a1-1)/a1;
	ll cc1 = (b2+a2-1)/a2;
	if(cc>c||cc1>c)
		return 0;
	return 1;
}
int main()
{
	ll n;
	cin>>n;
	vector<P> vi;
	for(ll i=0;i<n;i++)
	{
		ll a,b;
		cin>>a>>b;
		vi.push_back(P(a,b));
	}
	for(ll i=1;i<n;i++)
	{
		if(vi[i].first<vi[i-1].first||vi[i].second<vi[i-1].second)
		{
			ll ri = max(vi[i-1].first,vi[i-1].second);
			ll le = 1;
			ll mid;
			while(le+1<ri)
			{
				mid = (ri+le)/2;
				if(!isok(vi[i],vi[i-1],mid))
					le = mid;
				else
					ri = mid;
			}
			vi[i].first*=ri;
			vi[i].second*=ri;
		}
	}
	cout<<vi[n-1].first+vi[n-1].second<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int64_t h;
    cin >> h;

    int64_t ans = 0, c = 1;
    while (h > 0){
        ans += c;
        h /= 2;
        c *= 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<memory.h>
#include<stdlib.h>

struct Stack
{
	int data[101];
	int p;
}stk;

//Stack stk;

void push(int n)
{
	stk.p++;
	stk.data[stk.p] = n;
}

int pop()
{
	int d = stk.data[stk.p];
	stk.p--;
	return d;
}


void initialize()
{
	stk.p = 0;
	memset(stk.data, 0, sizeof(stk.data));
}

int main()
{
	initialize();

	char item[100];
	int op1, op2;
	while (scanf("%s", item) != EOF)
	{
		switch (item[0])
		{
		case '+':
			op1 = pop();
			op2 = pop();
			push(op2 + op1);
			break;

		case '-':
			op1 = pop();
			op2 = pop();
			push(op2 - op1);
			break;

		case '*':
			op1 = pop();
			op2 = pop();
			push(op2 * op1);
			break;

		default:
			push(atoi(item));
			break;
		}
	}
	printf("%d\n", pop());

	return 0;
}

Measured memory_bytes: 1840
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define lint long long
#define trace(x) cout << #x << " = " << x << '\n'
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z, ans;
lint mod(lint n) { return (n%MOD + MOD)%MOD; }
lint kali(lint a, lint b, lint c = 1, lint d = 1) { return mod(mod(a*b)*mod(c*d)); }

int cnt[MAXN];

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &x);
		cnt[x]++;
	}
	ans = N;
	bool sisa = 0;
	for (int i = 0; i < MAXN; i++) {
		if (!cnt[i]) continue;
		int tinggal = (cnt[i]&1? 1: 2);
		ans -= (cnt[i]-tinggal);
		cnt[i] = tinggal;
		if (cnt[i] == 2) {
			cnt[i]--;
			ans--;
			sisa ^= 1;
		}
	}
	if (sisa) ans--;
	printf("%d\n", ans);
	
	return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<int> sw(n + 1);
    sw[0] = 0;
    FOR(i, 1, n + 1) {
        int s; cin >> s;
        sw[i] += sw[i - 1] + s;
    }
    
    int ans = 1000000;
    REP(i, n) {
        if (ans > abs(sw[i] - (sw[n] - sw[i]))) ans = abs(sw[i] - (sw[n] - sw[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n,m,k,i,j;
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<=n;i++){
        for(j=0;j<=m;j++){
            if(i*(m-j)+(n-i)*j == k){printf("Yes\n");return 0;}
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll q;cin>>q;
  for(ll i=0;i<q;i++){
    ll a,b;cin>>a>>b;
    if(a>b)swap(a,b);
    ll ans=a-1;
    ll l=pow(a*b,0.5);
    if(l*(l+1)<a*b)l++;
    //if(i==5){cout<<l<<" "<<r;return 0;}
    
      ans+=l-1;
      ll u=(a*b)/l;
      if((a*b)%l==0)u--;
      ans+=max(u-a,(ll)0);
    
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
def main():
	q = int(input())
	a = []
	for _ in range(q):
		query = input()
		qn = query[0]
		if qn != "2":
			x = int(query[2:])
		if qn == "0":
			a += [x]
		elif qn == "1":
			print(a[x])
		else:
			a.pop(-1)

main()


Measured memory_bytes: 13360
m, n = map(int, input().split())
inf = 1000000007

a = [m]
for i in range(30):
    m *= m
    m %= inf
    a.append(m)

ans = 1
i = 0
while(n>0):
    if n%2 == 1:
        ans *= a[i]
        ans %= inf
    n = n//2
    i += 1
    
print(ans)


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

int main()
{
	std::string s, t;
	std::cin >> s >> t;

	bool bSame = false;

	for ( int i = 0; i < s.length(); i++ )
	{
		if ( s == t )
		{
			bSame = true;
			break;
		}

		s.insert( s.begin(), s.back() );	//	最後の文字を先頭に持ってきて
		s.erase( s.length() - 1 );			//	最後の文字を削除する
	}

	if ( bSame )
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return ( 0 );
}


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

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	int a_sum = 0, b_sum = 0;
	rep(i, n){
		cin >> a[i];
	}
	rep(i, n){
		cin >> b[i];
		b_sum += b[i];
	}
	int mx = 0;
	rep(i, n){
		a_sum += a[i];
		if(i > 0) b_sum -= b[i - 1];
		int tmp = a_sum + b_sum;
		if(mx < tmp) mx = tmp;
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256