akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
using namespace std;
#define M 100000
typedef struct PT{
    char name[11];
    int time;
} PT;
PT a[M+1];
int head=0,tail=0;
void Init()
{
    head=tail=0;
}
bool IsFull()
{
    return tail-head==-1||tail-head==M;
}
bool IsEmpty()
{
    return head==tail;
}
PT dequeue()
{
    if(IsEmpty())
    {
        cout<<"EMPTY"<<endl;
        exit(1);
    }
    if(head==M)
    {
        head=0;
        return a[M];
    }
    ++head;
    return a[head-1];
}
void enqueue(PT x)
{
    if(IsFull())
    {
        cout<<"FULL"<<endl;
        exit(1);
    }
    a[tail]=x;
    ++tail;
    if(tail==M+1)
        tail=0;
}
int main()
{
    PT in;
    int i,n,q,time=0;
    cin>>n>>q;
    for(i=0;i<n;i++)
    {
        cin>>in.name>>in.time;
        //scanf("%s%d",in.name,&in.time);
        enqueue(in);
    }
    while(!IsEmpty())
    {
        in = dequeue();
        if(in.time<=q)
        {
            time+=in.time;
            cout<<in.name<<' '<<time<<endl;
            //printf("%s %d\n",in.time,time);
        }
        else
        {
            time+=q;
            in.time-=q;
            enqueue(in);
        }
    }
    return 0;
}

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

int main(){
  long int a,b,x;
  long int cnt = 0;
  cin >> a >> b >> x;
  
  if (a == b){
    if(a%x == 0) cnt++;
    else cnt = 0;
  }
  else if(a%x != 0 && b%x != 0) cnt = (b/x) - (a/x);
  else cnt = 1+(b-a)/x;
//  else if( a%x == 0) cnt = 1+(b-a)/x;
//  else cnt = (b-a)/x;
  
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#
s, t = map(str, input().split())

a, b = map(int, input().split())
u = input()

if u == s:
    a -= 1
else:
    b -= 1

print(a, b)


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

using namespace std;

int main() {
  int n, m; cin >> n >> m;
  int x, y; cin >> x >> y;
  int mx = -1e5, mn = 1e5;
  for(int i = 0; i < n; i++) {
    int x; cin >> x;
    mx = max(mx, x);
  }
  for(int i = 0; i < m; i++) {
    int x; cin >> x;
    mn = min(mn, x);
  }
  for(int z = x + 1; z <= y; z++) {
    if(mx < z and mn >= z) {
      return !printf("No War\n");
    }
  }
  return !printf("War\n");
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] a = new int[N];
		for( int i=0; i<N; i++ ){
			a[i] = sc.nextInt();
		}
		int b = 1;
		int count = 0;
		for( int i=0; i<N; i++ ){
			if( a[i]==b ){
				count++;
				b++;
			}
		}
		if( count==0 ){
			count = N+1;
		}
		System.out.println(N-count);
	}
}


Measured memory_bytes: 87180
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll psum[200008];
signed main()
{
    fast;
  
    ll n,m,i,j,k,x,cn=0,ans=0;
    cin>>n>>m>>k;
    ll a[n+2] , b[m+2];
    for(i=1;i<=n;i++)
    {
    	cin>>a[i];
    }
    vector<ll> v;
    for(i=1;i<=m;i++)
    {
    	cin>>b[i];
    	psum[i] = psum[i-1] + b[i];
    	v.pb(psum[i]);
    }
    for(i=1;i<=n;i++)
    {
    	cn += a[i];
    	ll rem = k - cn;
    	if(rem==0)
    	{
    		ans = max(ans,i);
    		continue;
    	}
    	if(rem<0) continue;
    	auto it = upper_bound(v.begin(),v.end(),rem);
    	if(it!=v.begin())
    	{
    		it--;
    		ll ind = (it - v.begin()) + 1;
    		ans = max(ans , i + ind);
    	}
    	else ans = max(ans,i);
    }
    v.clear();
    cn  =0;
    for(i=1;i<=n;i++) 
    {
    	cn += a[i];
    	v.pb(cn);
    }
    cn = 0;
    for(i=1;i<=m;i++)
    {
    	cn += b[i];
    	ll rem = k - cn;
    	if(rem==0)
    	{
    		ans = max(ans,i);
    		continue;
    	}
    	if(rem<0) continue;
    	auto it = upper_bound(v.begin(),v.end(),rem);
    	if(it!=v.begin())
    	{
    		it--;
    		ll ind = (it - v.begin()) + 1;
    		ans = max(ans , i + ind);
    	}
    	else ans = max(ans,i);
    }
    cout<<ans;


}

Measured memory_bytes: 9708
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    k, a, b = get_int_list()
    if b - a < 2:
        print(1 + k)
        return
    print(a + ((k - (a - 1)) // 2) * (b - a) + ((k - (a - 1)) % 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
ll n,k;
pair<ll,ll> a[100005];
ll cnt;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i].fi>>a[i].se;
	sort(a,a+n);
	for(int i=0;i<n;i++){
		cnt+=a[i].se;
		if(cnt>=k){
			cout<<a[i].fi;
			re 0;
		}
	}
	re 0;
}

Measured memory_bytes: 5144
//#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()
{
    seika s;
    cin >> s;
    int n = s.size();
    akari<int> from(26, n + 1);
    yukari<pair<int, char>> es(n + 2);
    for (int i = n; i >= 0; i--)
    {
        for (int j = 0; j < 26; j++)
        {
            es[from[j]].emplace_back(i, char('a' + j));
        }
        if (i)
        {
            from[s[i - 1] - 'a'] = i;
        }
    }
    akari<int> nxt(n + 2, -1), lastChar(n + 2, '~'), dist(n + 2, 1e9);
    queue<int> q;
    q.push(n + 1);
    dist[n + 1] = 0;
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (auto &e : es[v])
        {
            int pv = e.first;
            char pc = e.second;
            if (dist[pv] == dist[v] + 1)
            {
                if (pc < lastChar[pv])
                {
                    lastChar[pv] = pc;
                    nxt[pv] = v;
                    q.push(pv);
                }
            }
            else if (dist[pv] > dist[v] + 1)
            {
                dist[pv] = dist[v] + 1;
                lastChar[pv] = pc;
                nxt[pv] = v;
                q.push(pv);
            }
        }
    }
    seika ans;
    int cur = 0;
    while (cur <= n)
    {
        ans.push_back(lastChar[cur]);
        cur = nxt[cur];
        //print(cur, ans);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 69124
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

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

ll n, k;
vector<ll> a, f;

#pragma region BinarySearch
bool isOK(ll x)
{
	ll cnt = 0;
	rep(i, 0, n - 1)
	{
		cnt += max(0LL, a[i] - x / f[i]);
	}

	if (cnt <= k) return true;
	else return false;
}

ll binary_search()
{
	ll ng = -1, ok = 1e18;
	while (abs(ok - ng) > 1)
	{
		ll mid = (ok + ng) / 2;
		if (isOK(mid))ok = mid;
		else ng = mid;
	}
	return ok;
}
#pragma endregion


int main()
{
	cin >> n >> k;
	a.resize(n), f.resize(n);
	rep(i, 0, n - 1)cin >> a[i];
	rep(i, 0, n - 1)cin >> f[i];
	sort(all(a));
	sort(all(f));
	reverse(all(f));
	ll ans = binary_search();
	cout << ans << endl;
}


Measured memory_bytes: 3328
// AOJ 1357: Squeeze the Cylinders
// 2017.10.24 bal4u@uu

#include <stdio.h>
#include <math.h>

int r[500];
double x[501];

int main()
{
	int n, i, j;
	double t, max, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", r+i);
	ans = 0;
	for (i = 0; i < n; i++) {
		max = r[i];
		for (j = 0; j < i; j++) {
			t = x[j] + sqrt((r[i]+r[j])*(r[i]+r[j]) - (r[i]-r[j])*(r[i]-r[j]));
			if (t > max) max = t;
		}
		x[i] = max;
		if (x[i] + r[i] > ans) ans = x[i] + r[i];
	}
	printf("%.8lf\n", ans);
	return 0;
}

Measured memory_bytes: 1820
from collections import deque


def rotate(string, n):
    string = deque(string)
    string.rotate(n)
    return "".join(string)


def solve(s, t):
    for i in xrange(len(s)):
        if rotate(t, i) == s:
            return 'Yes'

    return 'No'


s = raw_input()
t = raw_input()
print solve(s, t)

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

int main(){
  string S;
  string T;

  cin>>S;
  cin>>T;

  bool flag=false;
  
  int sum=0;
  
  for(int i=0;i<S.size();i++){
  
  if(S!=T){
    S=S.back()+S.substr(0,S.size()-1);
  }
    
    else{
      cout<<"Yes"<<endl;
      sum++;
      flag=true;
      break;
    }
  }
  if(sum==0){
    cout<<"No"<<endl;
  }
}

    
  

  
  
     


Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $s = <STDIN>);
if (length($s) == 1) {
  say "YES";
  exit;
}
my @s = split '', $s;
my %h;
$h{'a'} = 0;
$h{'b'} = 0;
$h{'c'} = 0;
$h{$_}++ for @s;
my $max = max(values %h);
my $min = min(values %h);
if ($max - $min > 1) {
  say "NO";
} else {
  say "YES";
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll maxn = 1e6 + 7;
const ll mod = 1e9 + 7;
const int maxx = 5005;
ll q, t, n, m, k, ans, mx , a[maxn], b[maxn], f[maxx][maxx];
priority_queue<ll> pr;
string s, ss[maxn], str, s1, s2;
map<ll, ll> mp;
ll dp(ll i, ll j)
{
    if(i == 0)return f[0][j] = j;
    if(j == 0)return f[i][0] = i;
    if(f[i][j] != 1e5)return f[i][j];
    if(s1[i] == s2[j])return f[i][j] = min(f[i][j], dp(i-1, j-1));
    return f[i][j] = min(min(dp(i-1, j) + 1, dp(i, j-1) + 1), dp(i-1, j-1) + 1);
}
void sol()
{
    cin >> n >> m >> t >> k;
    ans = 0;
    if(k <= n)
    {
        ans += k;
        cout << ans;
        return;
    }
    else
    {
        ans += n;
        k -= n;

    }
    if(k <= m)
    {
        cout << ans;
        return;
    }
    else
    {
        k -= m;
    }
    ans -= k;
    cout << ans;
    return;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    sol();
}


Measured memory_bytes: 34908
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL dp[3001][4];
int main(){
	dp[0][1]=1;
	LL r,g,b,n;
	scanf("%lld %lld %lld %lld",&r,&g,&b,&n);
	rb(i,1,n){
		if(i>=r){
			dp[i][1]+=dp[i-r][1];
		}
		if(i>=g){
			dp[i][2]+=dp[i-g][2]+dp[i-g][1];
		}
		if(i>=b){
			dp[i][3]+=dp[i-b][1]+dp[i-b][2]+dp[i-b][3];
		}
//		cout<<dp[i]<<endl;
	}
	printf("%lld\n",dp[n][1]+dp[n][2]+dp[n][3]);
	return 0;
}

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    
    int n;
    cin >> n;
    vl a(n);
    rep (i, n) cin >> a[i];

    ll x = 0;
    for (int i = 2; i < n; i++) x ^= a[i];


    ll now = 0;
    while (a[0] > 0) {
        if ((a[0] ^ a[1] ^ x) == 0) {
            cout << now << endl;
            return 0;
        }
        if (a[0] == 1) break;

        ll mask = 1LL << 50;
        while (true) {
            ll b0 = a[0] & mask, b1 = a[1] & mask, b2 = x & mask;
            if ((b0 ^ b1 ^ b2) == 0) mask >>= 1;
            else break;
        }

        ll mask2 = mask - 1;
        ll y1 = (a[0] & mask2) + 1;
        ll y2 = mask2 - (a[1] & mask2) + 1;
        ll y = min(y1, y2);
        now += y;
        a[0] -= y;
        a[1] += y;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N, M;
TIII LRD[200010];
vector<PII> g[200010];
int x[200010];
bool u[200010];


void dfs(int v = 0, int c = 0){
	if(u[v]) return;
	u[v] = true;
	x[v] = c;
	for(PII p : g[v])
		if(!u[p.first]) dfs(p.first, x[v]+p.second);
}


bool solve(){
	rep(i, 0, N) dfs(i);
	rep(i, 0, M){
		int L = get<0>(LRD[i]), R = get<1>(LRD[i]), D = get<2>(LRD[i]);
		if(x[R]-x[L] != D) return false;
	}
	return true;
}


signed main(){
	cin >> N >> M;
	rep(i, 0, M){
		int L, R, D;
		cin >> L >> R >> D, L--, R--;
		g[L].pb({ R, D });
		g[R].pb({ L, -D });
		LRD[i] = mt(L, R, D);
	}

	if(solve()) Yes;
	else No;

	return 0;
}

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

int main(){
    cin.sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();

    vector<vector<int>>dp(n, vector<int>(m));

    dp[n-1][m-1] = (s[n-1] == t[m-1]);

    for(int i = n-2; i >= 0; i--){
        dp[i][m-1] = (s[i] == t[m-1]) | dp[i+1][m-1];
    }

    for(int i = m-2; i >= 0; i--){
        dp[n-1][i] = (s[n-1] == t[i]) | dp[n-1][i+1];
    }

    for(int i = n-2; i >= 0; i--){
        for(int j = m-2; j >= 0; j--){
            if(s[i] == t[j]){
                dp[i][j] = 1+dp[i+1][j+1];
            }else{
                dp[i][j] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }

    string out;
    int i = 0, j = 0;
    while(true){
        if(i == n-1){
            if(dp[i][j] == 1){
                out+=s[i];
            }
            break;
        }else if(j == m-1){
            if(dp[i][j] == 1){
                out+=t[j];
            }
            break;
        }else if(s[i] == t[j]){
            out += s[i];
            i++; j++;
        }else if(dp[i+1][j] > dp[i][j+1]){
            i++;
        }else{
            j++;
        }
    }
    cout<<out<<endl;
}


Measured memory_bytes: 38616
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>


int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}



int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    bool s[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        s[i]=true;
    }
    qsort (a,n,sizeof(int),sort);  
    
    int ans=0;
    for (int i=0; i<n; i++){
        if (a[i]==a[i+1] && s[i]==true){
            s[i]=false;
            s[i+1]=false;
        }
    }
    
    for (int i=0; i<n; i++){
        if (s[i]==true){
            ans++;
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 1020
import math
n = int(input())
s = int(input())
if n == s:
  print(n+1)
  exit()
ru = math.ceil(math.sqrt(n))+1
for i in range(2,ru+1):
  b = n+0
  a = 0
  while b:
    a +=b%i
    b//=i
  if s == a:
    print(i)
    exit()
for i in range(ru,0,-1):
  q = s-i
  if q <0:
    continue
  c = (n-q)// i
  if c <= ru-1:
    continue
  b = n+0
  a = 0
  while b:
    a+=b%c
    b//=c
  if a == s:
    print(c)
    exit()
print(-1)

Measured memory_bytes: 3064
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        char a = Cin.Next().First();
        char b = Cin.Next().First();
        string ans = "";

        if (a > b) {
            ans = ">";
        } else if (a < b) {
            ans = "<";
        } else {
            ans = "=";
        }
        Console.WriteLine(ans);
    }
}
public struct Parts {
    public int Size;
    public int Count;

    public Parts(int size, int count) {
        Size = size;
        Count = count;
    }
}

public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 13268
#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()
typedef long long ll;
static const int INF (1<<30);
static const ll mod = 1e9+7;

ll get_sum(vector<ll> vec) {
  int n = vec.size();
  ll sum = 0LL;
  rep(i, n-1) {
    sum += (vec[i+1]-vec[i]) * (i+1) * (n-2-i+1);
    sum %= mod;
  }
  return sum;
}


int main() {
  int n, m; cin >> n >> m;
  vector<ll> x(n), y(m);
  rep(i, n) cin >> x[i];
  rep(i, m) cin >> y[i];

  ll ysum = get_sum(y);
  ll xsum = get_sum(x);

  ll ans = xsum * ysum;
  ans %= mod;
    
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
n = int(input())
listA = list(map(int, input().split()))

gusuC=0
kisuC=0

index=0
while index < len(listA):
    if listA[index]%2==0:
        gusuC+=1
    else:
        kisuC+=1
    index+=1

if kisuC%2==0:
    print("YES")
else:
    if gusuC==0:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 14108
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    int n;
    cin>>n;
    string s,t,ans;
    cin>>s>>t;
    rep(i,0,2*n){
        if(i%2)ans+=t[i/2];
        else ans+=s[i/2];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int AC=0, WA=0, TLE=0, RE=0;
  int b;
  string a;
  cin >> b;
  for(int i=0;i<b;i++){
   cin >> a;
   if(a=="AC") AC++;
   if(a=="WA") WA++;
   if(a=="TLE") TLE++;
   if(a=="RE") RE++;
  }
  cout << "AC" << " " << 'x' << " " << AC << endl;
  cout << "WA" << " " << 'x' << " " << WA << endl;
  cout << "TLE" << " " << 'x' << " " << TLE << endl;
  cout << "RE" << " " << 'x' << " " << RE << endl;
}

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

int main() {
    int a,b,c;
    int empty,ans;
    cin >> a >> b >> c;
    empty = a-b;
    ans = c-empty;
    if (c<=empty){
        cout << 0 << endl;
    }
    else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
S = gets.chomp

if S == 'SUN'
  puts 7
elsif S == 'MON'
  puts 6
elsif S == 'TUE'
  puts 5
elsif S == 'WED'
  puts 4
elsif S == 'THU'
  puts 3
elsif S == 'FRI'
  puts 2
elsif S == 'SAT'
  puts 1
end

Measured memory_bytes: 1788
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	int *r = new int[n];

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

	int maxv = r[1] - r[0];
	int minv = r[0];
	for (int i = 1; i < n; ++i){
		maxv = max(maxv, r[i] - minv);
		minv = min(minv, r[i]);
	}

	cout << maxv << endl;

	return 0;
}



Measured memory_bytes: 3876
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

struct edge {
    long long to, cost;
};

typedef pair<long long, long long> P;

void dijkstra(long long s, vector<vector<edge>>& G, vector<long long>& d) {//始点、隣接リスト、距離を渡す
    priority_queue<P, vector<P>, greater<P>> que;
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        long long v = p.second;
        if (d[v] < p.first) continue;
        for (long long i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

vector<vector<edge>> G(60 * 2501);
vector<long long> dist(60 * 2501, INF);

int main(){
  
  int n, m, s;
  cin>>n>>m>>s;
  int u[m], v[m], a[m], b[m];
  REP(i, m){
    cin>>u[i]>>v[i]>>a[i]>>b[i];
    u[i]--;v[i]--;
    REP(silver, 2501){
      if(silver == 2500){
        G[u[i] * 2501 + silver].push_back({v[i] * 2501 + silver, b[i]});
        G[v[i] * 2501 + silver].push_back({u[i] * 2501 + silver, b[i]});
      }else{
        if(silver - a[i] < 0) continue;
        G[u[i] * 2501 + silver].push_back({v[i] * 2501 + silver - a[i], b[i]});
        G[v[i] * 2501 + silver].push_back({u[i] * 2501 + silver - a[i], b[i]});
      }
    }
  }
  int c[n], d[n];
  REP(i, n) cin>>c[i]>>d[i];
  REP(state, n * 2501){
    int i = state / 2501;
    int silver = state % 2501;
    if(silver == 2500) continue;
    int ns = silver + c[i];
    ns = min(ns, 2500);
    G[state].push_back({i * 2501 + ns, d[i]});
  }
  
  int start = 0 + min(s, 2500);
  dijkstra(start, G, dist);
  vector<long long> ans(n, INF);
  REP(state, n * 2501){
    int i = state / 2501;
    int silver = state % 2501;
    ans[i] = min(ans[i], dist[state]);
  }
  REP(i, n){
    if(i == 0) continue;
    cout << ans[i] <<endl; 
  }
  return 0;
}


Measured memory_bytes: 24656
// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskC solver = new TaskC();
    int testCase = 1;
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskC {
    long h, w;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      h = in.nextInt();
      w = in.nextInt();
      char[][] superpost = new char[(int) h][];
      for (int i = 0; i < h; ++i)
        superpost[i] = in.next().toCharArray();
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j)
          if (i % 2 == 0 && j < w - 1 || j == 0 || superpost[i][j] == '#')
            out.print('#');
          else
            out.print('.');
        out.println();
      }
      out.println();
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j)
          if (i % 2 == 1 && j > 0 || j == w - 1 || superpost[i][j] == '#')
            out.print('#');
          else
            out.print('.');
          out.println();
      }
    }
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }
    
    public String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Measured memory_bytes: 13584
#include<cstdio>
#include<algorithm>
using namespace std;
const long long mod = 1e9 + 7;
long long f[1000005][4];
int main()
{
	long long a;
	scanf("%lld",&a);
	f[0][0] = 1;
	for(int i=0;i<a;i++){
		for(int j=0;j<4;j++){
			f[i+1][j] += f[i][j] * 8 % mod;
			f[i+1][j|1] += f[i][j];
			f[i+1][j|2] += f[i][j];
			f[i+1][j] %= mod;
			f[i+1][j|1] %= mod;
			f[i+1][j|2] %= mod; 
		}
	}
	printf("%lld\n",f[a][3]);
}

Measured memory_bytes: 32976
#include <cstdio>
#include <algorithm>
#define SIZE 33554432
char Key[128];
int Hash;
char* c;
#define HASH(A) c = A; Hash = 1; while(*c){ Hash <<= 2; Hash += Key[*c]; ++c;}
using namespace std;
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	Key['A'] = 0;
	Key['C'] = 1;
	Key['G'] = 2;
	Key['T'] = 3;
	bool* dic = new bool[SIZE];
	fill(dic, dic + SIZE, false);
	int n;
	std::scanf("%d\n", &n);
	char str[21];
	for (int i = 0; i < n; ++i) {
		fgets(str, 21, stdin);
		if (str[0] == 'i') {
			HASH(str + 7)
				dic[Hash] = true;
		}
		else {
			HASH(str + 5)
				puts((dic[Hash] ? "yes" : "no"));
		}
	}
	return 0;
}

Measured memory_bytes: 35404
N, K = map(int, input().split())
V = list(map(int, input().split()))
r = min(N, K)

ans = 0
for a in range(r+1):
    for b in range(r+1):
        if r < a+b:
            continue
        t = V[:a] + V[::-1][:b]
        t.sort(reverse=True)
        for _ in range(K-a-b):
            if len(t) > 0 and t[-1] < 0:
                t.pop()
        if ans < sum(t):
            ans = sum(t)
print(ans)


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

using namespace std;

int main(){
	int n;
	while(cin >> n && n!=0){
		vector<int> v(n);
		for(int i=0;i<n;i++){
			cin >> v[i];
		}
		vector<vector<int> > dp(n,vector<int>(n,0));
		int ans=0;
		int mx=0;
		for(int i=2;i<=n;i++){
			for(int j=0;j<=n-i;j++){
				if(i==2){
					if(v[j]<=v[j+1]+1&&v[j]>=v[j+1]-1){
						dp[j][j+1] = 2;
					}
				}else{
					if(dp[j+1][j+i-2]==i-2&&v[j]<=v[j+i-1]+1&&v[j]>=v[j+i-1]-1){
						dp[j][j+i-1]=i;
					}
					mx = dp[j][j+i-1];
					for(int k=0;k<=i-2;k++){
						mx = max(mx,dp[j][j+k]+dp[j+k+1][j+i-1]);
						dp[j][j+i-1] = mx;
					}
				}
			}
		}

		cout << dp[0][n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3236
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
        
def main():
    plan=[0]
    n = int(input())
    plan+=list(map(int,input().split()))
    plan.append(0)
    pay_sum = 0
    for i in range(1,n+2):
        pay_sum += abs(plan[i] - plan[i-1])
    
    for i in range(1,n+1):
        result = abs(plan[i-1] - plan[i+1])
        result -= abs(plan[i-1] - plan[i])
        result -= abs(plan[i+1] - plan[i])
        print(pay_sum + result)

if __name__=="__main__":
    main()

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

int p[1000001];
int dp[1000001];
int main(){
	int n,x;
	while(cin >> n >> x && n){
		for(int i = 0 ; i < 1000001 ; i++) p[i] = 1 , dp[i] = 0;
		p[0] = p[1] = 0;
		for(int i = 1 ; i*i <= 1000000 ; i++){
			if( p[i] ){
				for(int j = i * i ; j <= 1000000 ; j+=i){
					p[j] = 0;
				}
			}
		}
		dp[0] = 1;
		for(int i = 0 ; i < n ; i++){
			int t;
			cin >> t;
			for(int j = t ; j < 1000001 ; j++){
				dp[j] |= dp[j-t];
			}
		}
		while(x>0 && (p[x] == 0 || dp[x] == 0) ){
			x--;
		}
		if( x == 0 ){
			cout << "NA" << endl;
		}else{
			cout << x << endl;
		}
	}
}

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

#define NMAX 200100
#define INF 2000000000

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

typedef unsigned long long ull;
typedef long long int lli;

using namespace std;

// std::ifstream cin("f.in");
// std::ofstream cout("f.out");

struct Operation {
    int lin, col;
    int iter;
};

queue<Operation> Q;
char mat[1001][1001];
int n, m;

int dl[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};

bool inside(int x, int y)
{
    return (x >= 0 && x < n && y >= 0 && y < m);
}

int main()
{
    cin >> n >> m;
    cin.get();
    
    for(int i = 0; i < n; i++)
    {
        cin.getline(mat[i], m + 1);
        for(int j = 0; j < m; j++)
            if(mat[i][j] == '#')
                Q.push({i, j, 0});
    }

    int ans = 0;

    while(!Q.empty())
    {
        auto curr = Q.front();
        Q.pop();

        for(int i = 0; i < 4; i++)
        {
            int l9 = curr.lin + dl[i];
            int c9 = curr.col + dc[i];

            if(inside(l9, c9) && mat[l9][c9] == '.')
            {
                mat[l9][c9] = '#';
                Q.push({l9, c9, curr.iter + 1});
            }
        }
        ans = curr.iter;
    }

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

Measured memory_bytes: 13328
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main(void) {
    int n;
    std::cin >> n;
    std::string s;
    
    int count=0;
    bool flag=false;
    for(int i=0;i<n;i++){
        std::cin >> s;
        if(s=="A"){
            count++;
        }else{
            if(count!=0){
                --count;
            }else{
                flag=true;
            }
        }
    }
    if(flag==false&&count==0){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" <<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX=4005;
bool adj[MAX][MAX];
vector<LL> GRAPH[MAX];


int main()
{
        LL a,b,c;
        cin>>a>>b>>c;
        LL x=a+b;
        LL res=min(x+1,c);
        cout<<res+b<<endl;
}


Measured memory_bytes: 384
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let Arr = (input.trim()).split("\n");
let N1 = Number(Arr[0]);
let arr1 = Arr[1].split(" ").map(Number);
// const N2 = Number(Arr[2]);
let arr2 = Arr[3].split(" ").map(Number);

const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}

console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));




Measured memory_bytes: 34912
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

int main(){
    ll h,a;
    cin>>h>>a;
    ll ans=0;
    while(0<h){
        ans++;
        h-=a;
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	long long int K,ans;
  int a;
	cin >> K;
	ans = 0;
	for (int i = 1; i < K + 1; i++) {
		for (int j = 1; j < K + 1; j++) {
			for (int k = 1; k < K + 1; k++) {
				a = __gcd(i, j);
				ans =ans+__gcd(a,k);
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
  double A, B;
  cin >> A >> B;
  
  double price11, price21, price12, price22;
  price11 = A/0.08;
  price21 = B/0.10;
  price12 = (A+1)/0.08;
  price22 = (B+1)/0.10;
  
  int price = (int)price11;
  if(price < price11){
    price++;
  }
  
  int check = 0;
  for(int i=price;i<price12;i++){
    if(price21<=i && i<price22){
      cout << i << endl;
      check = 1;
      break;
    }
  }
  
  if(check==0){
    cout << -1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a*b//gcd(a, b)


a, b, c, d = map(int, input().split())

first_c = c * (a // c + 1)
if a % c == 0:
    first_c -= c
last_c = c * (b // c)

first_d = d * (a // d + 1)
if a % d == 0:
    first_d -= d
last_d = d * (b // d)

cd = lcm(c, d)
first_cd = cd * (a // cd + 1)
if a % cd == 0:
    first_cd -= cd
last_cd = cd * (b // cd)

cnum = 0
dnum = 0
cdnum = 0

if first_c <= b:
    cnum = (last_c - first_c) // c + 1

if first_d <= b:
    dnum = (last_d - first_d) // d + 1

if first_cd <= b:
    cdnum = (last_cd - first_cd) // cd + 1

total = cnum + dnum - cdnum
print(b - a + 1 - total)


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

int main() {

	long long a, b, x;
	cin >> a >> b >> x;

	long long res;
	if (a == b) {
		if (a%x == 0) res = 1;
		else res = 0;
	}
	else if (a == 0) res = b / x + 1;
	else res = (b / x + 1) - ((a-1) / x + 1);

	cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
n, m, x = [int(i) for i in input().rstrip().split(' ')]

a = [int(i) for i in input().rstrip().split(' ')]

c1 = len(list(filter(lambda i: i < x, a)))
c2 = len(list(filter(lambda i: i > x, a)))
print(min(c1, c2))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    string base="keyence";
    string gives;
    cin>>gives;
    for(int i=0;i<8;i++){
        if((gives.substr(0,i)==base.substr(0,i))&&(gives.substr(gives.size()-7+i,gives.size())==base.substr(base.size()-7+i,base.size())))
        {    
            cout<<"YES"<<"\n";
            return 0;       
        }
    }
    cout<<"NO"<<"\n";
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
long long int INF=1e18L + 7;
int main()
{
    long long int n;
    cin>>n;
    long long int W;
    cin>>W;
    vector<long long int> w(n,0);
    vector<long long int> v(n,0);
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    vector<pair<bool,long long int>> arr(1e5+1,{false,INF});
    arr[0].first=true;
    arr[0].second=0;
    for(int i=0;i<n;i++)
    {
        for(int j=arr.size()-1;j>=0;j--)
        {
            if(arr[j].first)
            {
                arr[j+v[i]].first=true;
                arr[j+v[i]].second=min(arr[j+v[i]].second,arr[j].second+w[i]);
            }
        }
    }
    int best=0;
    for(int i=1;i<arr.size();i++)
    {
        if(arr[i].second<=W)
        {
            best=i;
        }
    }
    cout<<best;

}

Measured memory_bytes: 4448
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<=b;i++)

using Edge = pair<int, long long>;
using Graph = vector<vector<Edge> >;

void rec(const Graph &G, int v, int p, long long sum, vector<long long> &dist) {
    dist[v] = sum%2;
    for (auto e : G[v]) {
        if(e.first == p) continue;
        rec(G, e.first, v, sum+e.second, dist);
    }
}

int main() {
    int N; cin >> N;
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        int a, b; long long c; cin >> a >> b >> c;
        --a, --b;
        G[a].push_back({b, c%2});
        G[b].push_back({a, c%2});
    }
    vector<long long> dist(N, 0);
    rec(G, 0, -1, 0, dist);

    FOR(i,0,N-1){
      cout << dist[i] % 2 << endl;
    }
}   

Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a,b;
  cin >> a >> b;
  if(a==1) a=14;
  if(b==1) b=14;
  if(a>b) cout << "Alice" << endl;
  if(a<b) cout << "Bob" << endl;
  if(a==b) cout << "Draw" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll a,b,n,ans=0;cin>>a>>b>>n;
  if(n/b==0){
    ans=((a*n)/b)-a*(n/b);
  }
  else{
    if(n%b==b-1){ans=((a*n)/b)-a*(n/b);}
    else{
      ll x=((n/b)-1)*b+b-1;
      ans=((a*x)/b)-a*(x/b);
    }
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <set>
#include <string>
using namespace std;

const int numberOfAlphabet = 26;
const char last = 'a';

string convert(int n) {
	string res = "";
	while(n) {
		res += 'a' + (n % numberOfAlphabet);
		n /= numberOfAlphabet;
	}

	return res;	
}

int main() {
	char in[128];
	string prefix = "pre";
	const string postfix(2, last);
	set<string> used;

	for(int i = 0; i < 50; ++i) {
		string myWord = prefix + convert(i) + postfix;
		printf("?%s\n", myWord.c_str());
		fflush(stdout);
		scanf("%s", in);
		string opWord(in);
		if(opWord[0] != last || used.find(opWord) != used.end())
			break;

		used.insert(opWord);
		prefix = opWord[opWord.size() - 1];
	}

	printf("!OUT\n");

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1256
l = [0 for i in range(26)] 
b=[chr(ord('a') + i) for i in range(26)]
while True:
    try:
        n=input()
        a= n.lower()
        for i in range(26):
            c = a.count(b[i])
            l[i]+=c
    except EOFError:
        for i in range(26):
            print(f'{b[i]} : {l[i]}')    
        break


Measured memory_bytes: 5576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            string input2 = Console.ReadLine();
            string input3 = Console.ReadLine();
 
            var strings = input1.Split(' ');
            var counts = input2.Split(' ').Select(x => int.Parse(x)).ToList();
            string throwed = input3;
 
            Dictionary<string, int> countTable = new Dictionary<string, int>();
            for (int i = 0; i < counts.Count; i++)
            {
                countTable.Add(strings[i], counts[i]);
            }
 
            countTable[throwed]--;
 
            string o = "";
            foreach (KeyValuePair<string, int> pair in countTable)
            {
                o += pair.Value + " ";
            }
            o.TrimEnd(new char[] { ' ' });
            Console.Write(o);
        }
    }
}

Measured memory_bytes: 13396