akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;

namespace Contest
{
    class Program
    {
        public void Solve()
        {
            var sc = new Scanner();
            int R = sc.NextInt();
            int G = sc.NextInt();
            int B = sc.NextInt();
            int N = sc.NextInt();
            int cnt = 0;
            for (int r = 0; r * R <= N; r++)
            {
                for (int g = 0; r * R + g * G <= N; g++)
                {
                    int d = N - r * R - g * G;
                    if (d % B == 0)
                    {
                        cnt++;
                    }
                }
            }

            Console.WriteLine(cnt);
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private char _separator;
    private StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 13140
n,a,b=map(int,input().split())
ans = 0

def make_sum(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

for i in range(1,n+1):
    if make_sum(i)>=a and make_sum(i)<=b:
        ans += i
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
const int N = 1e5+7;


int main(){

	int a,b;
	cin >> a >> b;
	if(a%2 != 0 && b%2 != 0) cout << "Yes" << endl;
	else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,h,w;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
    
    
}


Measured memory_bytes: 256
int main(){
  int k,s;
  scanf("%d%d",&k,&s);
  printf("%d\n",(++s*s+s-(k>s?0:3*(s-k)*(s-k-1))+(k*2>s?0:3*(s-2*k-1)*(s-2*k-2)))/2);++s;
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 1e5+5;
int x, y, a, b, c, k;
deque<int> p, q, r;



int main(){
	scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
	for(int i = 0; i<a; i++) scanf("%d", &k), p.push_back(k);
	for(int i = 0; i<b; i++) scanf("%d", &k), q.push_back(k);
	for(int i = 0; i<c; i++) scanf("%d", &k), r.push_back(k);
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	sort(r.begin(), r.end(), greater<int>());
	while(p.size()>x) p.pop_front();
	while(q.size()>y) q.pop_front();
	int reds = 0, greens = 0;
	/*
	while(r.size() && ((r.front()>p.front() && reds<x) || (r.front()>q.front() && greens<x))){
		bool rsmall = p.front()<q.front();
		if (reds<x && greens<y){
			if (r.front()<=min(p.front(), q.front())) break;
			if (p.front()<q.front()) p.push_back(r.front()), p.pop_front(), r.pop_front(), reds++;
			else q.push_back(r.front()), q.pop_front(), r.pop_front(), greens++;
		}
		else if (reds<x){
			if (r.front()<=p.front()) break;
			p.push_back(r.front()), r.pop_front(), p.pop_front(), reds++;
		}
		else if (greens<y){
			if (r.front()<= q.front()) break;
			q.push_back(r.front()), r.pop_front(), q.pop_front(), greens++;
		}	
	} */
	while(r.size()){
		int mn = min(p.front(), q.front());
		if (r.front()<=mn) break;
		if (p.front()<q.front()) p.push_back(r.front()), p.pop_front(), r.pop_front();
		else q.push_back(r.front()), r.pop_front(), q.pop_front();
	}
	ll ans = 0;
	for(int v: p) ans+= (ll)v;
	for(int v: q) ans+= (ll)v;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1536
import numpy as np
N=int(input())
A=list(map(int,input().split()))

A.insert(0,0)
A.append(0)
A=np.array(A)
S=np.sum(np.abs(np.diff(A)))

for i in range(1,N+1):
    S_i=S+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))
    print(S_i)

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

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

using namespace std;

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

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

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int a[100005];

int main(){
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];
  sort(a, a+n);
  REP(i, n-1) a[i+1] %= a[0];
  int m1=a[0];
  sort(a, a+n);
  int idx=0;
  while(a[idx]==0) idx++;
  int m2=a[idx];
  while(m1 > 0 and m2 > 0){
    m2 %= m1;
    if(m1>m2) swap(m1, m2);
  }
  cout << m2 << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
map<int ,int>a;
int main()
{
    int n,m;
    cin>>n;
    int t;
    while(n--)
    {
        cin>>t;
        a[t]++;
    }
    cin>>m;
    while(m--)
    {
        cin>>t;
        if(a[t]==0)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        a[t]--;
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

struct chain {
    char car;
    shared_ptr<chain> cdr;
};

string solve(int n, int a0, int b0, int c0, const vector<string> & ops) {
    map<tuple<int, int, int>, shared_ptr<chain>> cur, prv;
    cur[make_tuple(min(5, a0), min(5, b0), min(5, c0))] = nullptr;
    for (string op : ops) {
        cur.swap(prv);
        cur = map<tuple<int, int, int>, shared_ptr<chain> >();
        for (auto it : prv) {
            auto [a, b, c] = it.first;
            shared_ptr<chain> as = make_shared<chain>((chain) { 'A', it.second });
            shared_ptr<chain> bs = make_shared<chain>((chain) { 'B', it.second });
            shared_ptr<chain> cs = make_shared<chain>((chain) { 'C', it.second });
            auto use = [&](int da, int db, int dc) {
                auto [a, b, c] = it.first;
                auto ns = da == 1 ? as : db == 1 ? bs : cs;
                cur[make_tuple(a + da, b + db, c + dc)] = ns;
            };
            if (op == "AB") {
                if (a >= 2) {
                    use(-1, 1, 0);
                } else if (b >= 2) {
                    use(1, -1, 0);
                } else {
                    if (a) use(-1, 1, 0);
                    if (b) use(1, -1, 0);
                }
            } else if (op == "BC") {
                if (c >= 2) {
                    use(0, 1, -1);
                } else if (b >= 2) {
                    use(0, -1, 1);
                } else {
                    if (c) use(0, 1, -1);
                    if (b) use(0, -1, 1);
                }
            } else if (op == "AC") {
                if (a >= 2) {
                    use(-1, 0, 1);
                } else if (c >= 2) {
                    use(1, 0, -1);
                } else {
                    if (a) use(-1, 0, 1);
                    if (c) use(1, 0, -1);
                }
            } else {
                assert (false);
            }
        }
    }
    if (cur.empty()) return "";
    string ans;
    for (auto s = cur.begin()->second; s != nullptr; s = s->cdr) {
        ans += s->car;
    }
    reverse(ALL(ans));
    return ans;
}

// generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
const string YES = "Yes";
const string NO = "No";
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t N;
    int64_t A, B, C;
    cin >> N;
    vector<string> s(N);
    cin >> A >> B >> C;
    REP (i, N) {
        cin >> s[i];
    }
    auto ans = solve(N, A, B, C, s);
    if (ans.empty()) {
        cout << NO << endl;
    } else {
        cout << YES << endl;
        for (char c : ans) {
            cout << c << endl;
        }
    }
    return 0;
}


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

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

	int N;
	cin >> N;

	long long int whole = 0; //バームクーヘンの大きさ
	int* A = new int[N];
	for (int i = 0; i < N; i++){
		cin >> A[i];
		whole += (long long int)A[i];
	}

	long long int one_third = whole / 3;

	int ini = 0;
	long long int piece1 = 0;
	while (piece1 + (long long int)A[ini] <= one_third){
		piece1 += (long long int)A[ini];
		ini++;
	}
	
	int piece2_i = ini;
	long long int piece2 = 0;
	while (1){
		piece2 += (long long int)A[ini];
		ini++;
		if (piece2 >= piece1) break;
	}
	
	int piece3_i = ini;
	long long int piece3 = whole - piece1 - piece2;
	long long int ans = min(piece1, piece3);

	for (int i = 1; i < N; i++){
		if (piece1 == 0){
			piece2 -= (long long int)A[piece2_i];
			piece2_i++;
		}
		else piece1 -= (long long int)A[i-1];

		while (piece1 + (long long int)A[piece2_i] <= one_third){
			piece1 += (long long int)A[piece2_i];
			piece2 -= (long long int)A[piece2_i];
			piece2_i++;
			if (piece2_i == N) piece2_i -= N; //周期的境界条件
		}

		while (piece2 < piece1){
			piece2 += (long long int)A[piece3_i];
			piece3_i++;
			if (piece3_i == N) piece3_i -= N; //周期的境界条件
		}

		piece3 = whole - piece1 - piece2;
		ans = max(ans, min(piece1, piece3));
	}

	cout << ans << "\n";

	delete[] A;
	return 0;
}

Measured memory_bytes: 1532
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

N,V = ilint()
odd = counter()
even = counter()
for i in range(N):
    if i%2==0:
        even.add(V[i])
    else:
        odd.add(V[i])
E = [(k,even[k]) for k in even]+[(0,0)]
O = [(k,odd[k]) for k in odd]+[(0,0)]
E.sort(reverse=True, key=lambda x:x[1])
O.sort(reverse=True, key=lambda x:x[1])
if E[0][0]!=O[0][0]:
    print(N-E[0][1]-O[0][1])
else:
    print(min(N-E[1][1]-O[0][1],N-E[0][1]-O[1][1]))

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


def solve(X: int):
    if X == 2:
        print(X)
        return
    n = X -1
    while True:
        n += 1
        if n % 2 == 0:
            continue
        f = True
        for i in range(3, (n//2)+1, 2):
            if n % i == 0:
                f = False
                break
        if f:
            print(n)
            break

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 62880
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n, k;cin>>n>>k;
  ll ans=0;
  for(int i=0;i<k;i++){
  	int num = (n+1)/k+int(((n+1)%k!=0)&&(n%k>=i));
    if(i==0)num--;
    if((i*2)%k==0)ans += pow(double(num), 3);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
blue = [input() for x in range(n)]
m = int(input())
red = [input() for x in range(m)]

points = []
for i in range(n):
    point = 0
    point += blue.count(blue[i])
    point -= red.count(blue[i])
    points.append(point)
print(max( max(points), 0))

Measured memory_bytes: 3064
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int n{};
	cin>>n;
	vector<ll>v(n);
	For(i,0,n)cin>>v[i];
	ll ans{};
	For(i,1,n)
	{
		if(v[i]<v[i-1])ans+=v[i-1]-v[i],v[i]=v[i-1];
	}
	cout<<ans<<'\n';
//	system("pause");
	return 0;	
}

Measured memory_bytes: 4700
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        // 0:a, 1:b, 2:c
        int[] i = new int[s.Length];
        int c = 0;

        for (int j = 0; j < s.Length; j++)
            i[j] = int.Parse(s[j]);

        for (int j = i[0]; j <= i[1]; j++)
        {
            if ( (i[2] % j) == 0 ) 
                c++;
        }

        Console.WriteLine(c.ToString());
    }
}


Measured memory_bytes: 9240
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<ll> A,B;
const ll INF=1e15;

class DisjointSet{
public:
  vector<int> rank,p;
  vector<int> sz;
 
  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    sz.resize(size,0);
    for(int i=0;i<size;i++) makeSet(i);
  }
 
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
    sz[x]=1;
  }
 
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }
 
  void unite(int x,int y){
    if(same(x,y)) return;
    link(findSet(x),findSet(y));
  }
 
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
      sz[x]+=sz[y];
    }else{
      p[x]=y;
      sz[y]+=sz[x];
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }
 
  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
 
  int findSize(int x){
    return sz[findSet(x)];
  }
};

int main(){
  cin>>N;
  A.resize(N);
  B.resize(N);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>B[i];


  vector<pair<ll,int>> C,D;
  rep(i,N) C.push_back(mkp(A[i],i));
  sort(C.begin(),C.end());
  rep(i,N) D.push_back(mkp(B[i],i));
  sort(D.begin(),D.end());

  DisjointSet us(N+1);
  for(int i=0;i<N;i++){
      if(C[i].first>D[i].first){
          cout<<"No"<<endl;
          return 0;
      }

      int a=C[i].second;
      int b=D[i].second;
      if(us.same(a,b)) continue;
      us.unite(a,b);
  }

  for(int i=0;i<N;i++){
      if(us.findSize(i)!=N){
          cout<<"Yes"<<endl;
          return 0;
      }
  }

  for(int i=1;i<N;i++){
      if(C[i].first<=D[i-1].first){
          cout<<"Yes"<<endl;
          return 0;
      }
  }

  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
const int maxint=200005;
ll a[maxint+100];
map < ll,ll > mp;
ll po[1050];
void init_po(){
	cin >> n;
	for (ll i=1;i<=n;i++){
		cin >> a[i];
		mp[a[i]]++;
	}
	sort(a+1,a+1+n);
	po[0]=1;
	for (ll i=1;i<=62;i++) po[i]=po[i-1]*2;
}
ll have(ll x){
	ll ge;
	for (ge=1;ge<=62;ge++){
		if (po[ge]>x){
			break;
		}
	}
	if (mp[po[ge]-x]==0) return -1;
	return po[ge]-x;
}
void go(){
	init_po();
	ll s=0;
	for (ll i=n;i>=1;i--){
		if (mp[a[i]]>0){
			mp[a[i]]--;
			ll tmp=have(a[i]);
			if (tmp!=-1){
				mp[tmp]--;
				s++;
			}
		}
	}
	cout << s;
}
int main(){
	go();
	return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i=(a),_b=(b);i<_b;++i)

using namespace std;
const int maxn = 100001;
typedef long long ll;
const ll mod  = 1e9 + 7;
ll f[maxn];
int n,k;
vector<int> d[maxn];
void _sieve()
{
    for(int i = 2; i<maxn; ++i)
        for(int j = i ; j<maxn; j+=i)
            d[j].push_back(i);
}
ll _pow(ll A,ll B)
{
    if (B==0) return ll(1);
    ll p  = _pow(A, B/2);
    p = p*p;
    p = p%mod;
    return (B%2==0) ? p : ((A*p)%mod);
}
void solve()
{
    for(int i = k;i>=1; --i)
    {
        f[i] = f[i] + _pow( k /i , n);
        f[i] = f[i]%mod;
        for(int j = i+ i;j<=k; j+=i)
        {
            f[i] -= f[j];
            f[i] = f[i] + mod;
            f[i] = f[i] %mod;
        }
    }
    ll ans = 0;
    _for(i,1,k+1)
    {
        ans = ans + f[i]*ll(i);
        ans = ans%mod;
    }
    cout<<ans;
}
int main()
{
    cin>>n>>k;
    solve();
}


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

int main(void) {
  double N, K; cin >> N >> K;
  double a = 0;
  for (double i = 1; i <= N; i++) {
    double ai = (double)1/(double)N;
    double ii = i;
    while (ii < K) {
      ai /= (double)2;
      ii *= 2;
    }
    a += ai;
  }
  cout << setprecision(12) << a << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        long H = in.l();
        out.println(solve2(H));
    }
    
    static long solve(long h){
        if(h == 1){
            return 1;
        } else {
            return 1+solve(h/2)*2;
        }
    }
    
    static long solve2(long h){
        int bit = 0;
        while(h != 0){
            bit++;
            h >>= 1;
        }
        return (1L<<bit)-1;
    }
   

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 21844
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

int bs(int l, int r, int sum) {
  while(l < r) {
    int mid = l + (r - l + 1) / 2;
    if(sum > ar[mid])
      l = mid;
    else
      r = mid - 1;
  }
  return r;
}

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> ar[i];
  sort(ar + 1, ar + n + 1);
  cout << endl;
  for(int i = 1; i <= n; i++)
    for(int j = i + 1; j <= n; j++)
      ans += bs(j, n, ar[i] + ar[j]) - j;
  cout << ans;
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int x,y,a,b,c;
int p[100007],q[100007],r[100007];
long long ans;
bool cmp(const int &u,const int &v){
	return u>v;
}
struct data{
	int val,id;
}d[200007];
int cnt=0;
bool cmp1(const data &u,const data &v) {
	return u.val<v.val;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>x>>y>>a>>b>>c;
	for (int i=1; i<=a; i++) cin>>p[i];
	for (int i=1; i<=b; i++) cin>>q[i];
	for (int i=1; i<=c; i++) cin>>r[i];
	sort(p+1,p+a+1,cmp);
	sort(q+1,q+b+1,cmp);
	sort(r+1,r+c+1,cmp);
	for (int i=1; i<=x; i++) d[++cnt].val=p[i],d[cnt].id=1,ans+=p[i];
	for (int i=1; i<=y; i++) d[++cnt].val=q[i],d[cnt].id=2,ans+=q[i];
	sort(d+1,d+cnt+1,cmp1);
	int nowc=1;
	int cntid[3];
	cntid[1]=cntid[2]=0;
	for (int i=1; i<=cnt; i++) {
		//if (nowc>c) break;
		if (cntid[1]<x && cntid[2]<y) {
			if (d[i].val<r[nowc]) {
				ans=ans-d[i].val+r[nowc];
				++cntid[d[i].id];
				++nowc;
			}
		}
		else if (cntid[1]<x) {
			if (d[i].id==1 && d[i].val<r[nowc]) {
				ans=ans-d[i].val+r[nowc];
				++cntid[1];
				++nowc;
			}
		}
		else if (cntid[2]<y) {
			if (d[i].id==2 && d[i].val<r[nowc]) {
				ans=ans-d[i].val+r[nowc];
				++cntid[2];
				++nowc;
			}
		}
		if (nowc>c) break; 
		if (cntid[1]>=x && cntid[2]>=y) break;
		if (d[i].val>r[nowc]) break;
 	}
 	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2816
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll hs(n);
  rep(i, n) cin >> hs[i];

  vll dp(n, 0);
  dp[0] = 0;
  repLRE(i, 1, n - 1) {
    if (i == 1)
      dp[i] = abs(hs[i] - hs[i - 1]);
    else
      dp[i] = min(dp[i - 1] + abs(hs[i] - hs[i - 1]),
                  dp[i - 2] + abs(hs[i] - hs[i - 2]));
  }
  cout << dp.back() << endl;

  return 0;
}


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

int main() {
  string a, b, c;
  cin>>a>>b>>c;
  if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.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 (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll p(N);
        rep(i, 0, N) cin >> p[i];
        *max_element(all(p)) /= 2;
        cout << accumulate(all(p), 0) << endl;
}

Measured memory_bytes: 256
from collections import Counter
N,A = map(int, input().split())
X = list(map(int, input().split()))

"""
普通にやると最大で2**50通りなのでTLE
i枚選んだ時に合計がi*Aになる物を考えるとよい
prd_xxxさんの解答に自分向けのコメントつけただけ
https://atcoder.jp/contests/abc044/submissions/3018277
"""

# 0枚からN枚まで選んで、合計値がkeyでその組み合わせの数がvalue
dp = [Counter() for _ in range(N+1)]
dp[0][0] = 1

for i, a in enumerate(X): # i番目のカードまで選べる
    for j in reversed(range(i+1)): # j枚選ぶとき（０～i枚の範囲）、逆順にしないと１枚目にX_iを選んで３枚目にもX_iを選ぶみたいな重複が発生するのでこれを回避するために逆順にする
        for k,v in dp[j].items(): # j枚選んだ時の合計値とその組み合わせの個数についてみていく
            dp[j+1][k+a] += v # j+1枚目としてi番目のカードを選ぶ時に合計がk+aになる個数は、j枚選んでｋになる個数と同じ（それぞれの場合にaを足してできる）

ans = 0
for i, C in enumerate(dp):
    if i >= 1:
        ans += C[i*A]
print(ans)

Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

vi to[200005];
vi ans;

void dfs(int v, int p=-1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main () {
  int n, q;
  cin >> n >> q;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].pb(b);
    to[b].pb(a);
  }
  ans.resize(n);
  rep(i,q) {
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 23552
#include <stdio.h>

char str1[200005];
char str2[200005];

int main() {
  scanf("%s", str1);
  scanf("%s", str2);
  int i=0;
  int diff=0;
  while(str1[i]!='\0') { diff+=!(str1[i]==str2[i]); i++; }
  printf("%d", diff);
  return 0;
}


Measured memory_bytes: 2116
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;

int main(void) {
	string str;
	stack<int> polish;

	while (cin >> str) {
		if (str == "+" || str == "-"
			|| str == "*" || str == "/") {
			int x = polish.top();
			polish.pop();
			int y = polish.top();
			polish.pop();
			switch (str[0]) {
				case '+':
					polish.push(y + x);
					break;
				case '-':
					polish.push(y - x);
					break;
				case '*':
					polish.push(y * x);
					break;
				case '/':
					polish.push(y / x);
					break;
			}
		} else {
			polish.push(atoi(str.c_str()));
		}
	}

	cout << polish.top() << endl;

	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

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

int main() {
    string S;
    cin >> S;
    cout << S[0] << S.size() - 2 << S[S.size() - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    cin >> n;
    ll s = 0;
    rep(i, n) {
        ll x; cin >> x;  s += x-1;
    }
    cout << s;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


NK = str(input()).split()
N = int(NK[0])
K = int(NK[1])
ans = 1

for i in range(N):
  if(N<K**i):
    ans = i
    break

if(N<=K):
  ans = 1


print(ans)



Measured memory_bytes: 38636
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    if (b - a) % 2 == 0 {
        println!("{}", (b - a) / 2);
    } else {
        let left = a - 1;
        let right = n - b;
        if left < right {
            let d = a;
            println!("{}", d + (b - d) / 2);
        } else {
            let d = n - b + 1;
            println!("{}", d + (n - a - d) / 2);
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair <int,int> ii ;
typedef vector < ii > vii ;
typedef vector < vii > viii ;
#define rep(i,n)                   for( int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++) 
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define db double 
#define fi first
#define se second

int calc(int h[], int dp[],int i, int n) {
	if(i>=n) return 0;
	if(dp[i]!=-1) return dp[i];
	dp[i]=min(abs(h[i]-h[i+1])+calc(h,dp,i+1,n), abs(h[i]-h[i+2])+calc(h,dp,i+2,n));
	return dp[i];
}

int main() {
   int n; cin>>n;
   int h[n];
   rep(i,n) cin>>h[i];
   int dp[n];
   memset(dp,-1, sizeof dp);
   cout<<calc(h,dp,0,n-1);
}

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




void sleek()
{
    int n;
	cin >> n;
	
	n = n%10;
	
	string ans;
	
if(n == 0|| n == 1 || n==6|| n==8)
	ans="pon";
else if(n ==3)
	ans="bon";
else
	ans= "hon";

cout<<ans;
    
    
    
}


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


Measured memory_bytes: 3672
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, a, b, c[55] = {0};

  std::cin >> N >> M;

  for (int i = 0; i < M; i ++) {
    std::cin >> a >> b;

    c[-- a] ++;
    c[-- b] ++;
  }

  for (int i = 0; i < N; i ++)
    std::cout << c[i] << ' ' << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> a(n + 1), b(n);
    for(int i = 0; i < n + 1; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];

    int res = 0;
    for(int i = 0; i < n; i++) {
        res += min(a[i], b[i]);
        int tmpA = a[i];
        a[i] = max(a[i] - b[i], (int)0);
        b[i] = max(b[i] - tmpA, (int)0);
        res += min(a[i + 1], b[i]);
        a[i + 1] = max(a[i + 1] - b[i], (int)0);
    }

    cout << res << endl;

    // for(int i = 0; i < n + 1; i++) {
    //     cout << a[i] << " ";
    // }
    // cout << endl;
    // for(int i = 0; i < n; i++) {
    //     cout << b[i] << " ";
    // }
    // cout << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int ary[n];
    rep(i,n) cin >> ary[i];

    int q;
    cin >> q;
    int b[q];
    int c[q];
    rep(i,q) cin >> b[i] >> c[i];

    map<int, int> mp;
    ll sum = 0;
    rep(i,n)
    {
        sum += ary[i];
        if (mp.find(ary[i]) == mp.end())
        {
            mp[ary[i]] = 1;
        }
        else
        {
            mp[ary[i]] += 1;
        }
    }

    rep(i,q)
    {
        int ncnt = mp[b[i]];
        sum += ncnt * (c[i]-b[i]);
        if (mp.find(c[i])==mp.end())
        {
            mp[c[i]] = ncnt;
        }
        else
        {
            mp[c[i]] += ncnt;
        }
        mp.erase(b[i]);
        cout << sum << endl;
    }
}


Measured memory_bytes: 7752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

vector<int> to_prime(int n){
    vector<int> v;
    int tmp = n;
    REP(i, n+1){
        if (i < 2) continue;
        while(tmp % i == 0){
            v.push_back(i);
            tmp /= i;
        }
        if (tmp == 1) break;
    }
    return v;
}

int main() {

    int N;
    cin >> N;
    vector<int> tmpv;
    vector<int> v(102, 0);
    REP(i, N+1){
        if (i < 2) continue;
        tmpv = to_prime(i);
        REP(j, tmpv.size()) v[tmpv[j]]++;
    }
    int tmp2 = 0, tmp4 = 0;
    int tmp14 = 0, tmp24 = 0, tmp74 = 0;
    REP(i, 102){
        if (v[i] >= 4) tmp4++;
        if (v[i] >= 2) tmp2++;

        if (v[i] >= 14) tmp14++;
        if (v[i] >= 24) tmp24++;
        if (v[i] >= 74) tmp74++;
    }
    //REP(i, v.size()) cout << v[i] << " ";
    ll ans = 0;
    ans += (tmp2 - 2) * (tmp4 * (tmp4 - 1)) / 2;
    ans += (tmp4 - 1) * tmp14 + (tmp2 - 1) * tmp24 + tmp74;

    cout << ans << endl;

    return 0;
}

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

using ll = long long;

int main() {
    int H, W;
    std::cin >> H >> W;
    std::vector<std::vector<char>> a(H, std::vector<char>(W));
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            std::cin >> a[h][w];
        }
    }

    for (int w = 0; w < W; w++) {
        bool flag = true;
        for (int h = 0; h < H; h++) {
            if (a[h][w] == '#') {
                flag = false;
                break;
            }
        }
        if (flag) {
            for (int h = 0; h < H; h++) {
                a[h][w] = 'N';
            }
        }
    }


    for (int h = 0; h < H; h++) {
        bool flag = true;
        for (int w = 0; w < W; w++) {
            if (a[h][w] == '#') {
                flag = false;
                break;
            }
        }
        if (flag) {
            for (int w = 0; w < W; w++) {
                a[h][w] = 'N';
            }
        }
    }


    for (int h = 0; h < H; h++) {
        bool flag = true;
        for (int w = 0; w < W; w++) {
            if (a[h][w] == 'N')continue;
            std::cout << a[h][w];
            flag = false;
        }
        if (!flag)std::cout << std::endl;
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt(); //N
		long K = sc.nextLong(); //K

		String Ans = K <= (N + 1) / 2 ? "YES" : "NO";

		System.out.println(Ans);
	}



}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21076
#include <stdio.h>
#include<math.h>
int main()
{
    long long int a,b,n,l,r,x,y;
    while(scanf("%lld %lld",&a,&b)!=EOF)
{
    x=a;
    y=b;
    while(b!=0)
    {
        r=a%b;
        a=b;
        b=r;

    }
    n=a;
    l=(x*y)/n;
    printf("%lld %lld\n",n,l);
}
    return 0;
}

Measured memory_bytes: 1804