akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef  long long int ll;
#define ent cout << "\n"
#define pb push_back
#define mp make_pair
#define sz(x) x.size()
#define pair < ll, ll > pp
#define f(a, b) for(auto i = a;i < b;i++)
#define rev_f(a, b) for(auto i = b;i >= a;i--)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define st(x) sort(x.begin(), x.end()) 
#define rv(x) reverse(x.begin(), x.end()) 
#define cintc() ll tc;while(tc--) 
#define deb(x) cout << x << "\n";
#define cin() ll a; cin >> a;
#define cin2() ll a, b; cin >> a >> b
#define cin3() ll a, b, c; cin >> a >> b >> c
#define cinn(vect, n) def_v vect(n); f(0, n) cin >> vect[i]
#define coutn(vect, n)  f(0, n) {cout << vect[i] << " ";}ent;

typedef vector < ll > def_v;
typedef tuple< ll, ll, ll> def_tuple;
ll mod = 1e9 + 7,cnt = 0;

vector < ll > bfs(vector < ll > graph[], vector < ll > vect, ll start, ll flag, ll n)
{

    ll vis[n + 1] = {0};
    vis[start] = 1;
    queue < ll > q;
    q.push(start);
    while(!q.empty())
    {

        ll start = q.front();
        q.pop();
        auto size = ll(graph[start].size());
        for(ll j = 0;j < size;j++)
        {
            ll x = graph[start][j];
            if(!vis[x])
            {
                vis[x] = 1;
                if(x == 1 && flag == 2)
                {
                    flag = 2;
                }
                else
                    q.push(x);
                vect[x] = flag;
            }
        }
    }

    return vect;
}

vector < ll > int_binary(ll n, ll size)
{
    ll cnt = 0;
    def_v str(size);
    while(n > 0)
    {
        str[cnt++] = n%2;
        n = n/2;
    }
    return str;
}
void solve()
{   
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
        
    if(a >= k)
        cout << k << "\n";
    else
    {
        k -= a;
        k -= b;

        if(k <= 0)
            cout << a << "\n";
        else
        {
            cout << a - k << "\n";
        }
    }
    

    return ;
}
int main()
{
    fastio();
    ll tc = 1;
    // cin >> tc;
    while(tc--)
        solve();
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int count = 0;
    int n, m, s;
    cin >> n >> m;
    int i, j;
    vector<int> a(n); //binary each switch
    rep(i, m) {
      int k; //num of switches are connected
      cin >> k;
      rep(j, k) {
        int s;  //switch id
        cin >> s;
        s--; // 0 index
        a[s] |= 1 << i; //state of all switches
      }
    }
    int p = 0;
    rep(i, m) {
      int x;
      cin >> x;
      p |= x << i;
    }
    for (s = 0; s < (1 << n); s++) { //way to put on switches
      int t = 0; // actual light turn on
      rep(i, n) {
        if (s >> i & 1) {
          t ^= a[i];
        }
      }
      if (t == p) {
        count++;
      }
    }

    cout << count << '\n';

  return 0;
}


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

#define rep(i, n) for(i=0;i<(int)(n);i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define bit(n) (1LL<<(n))
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(void){
  char s[10];
  int i,a,b;
  scanf("%3s", s);
  
  for(i=0;i<3;i++){
    if(s[i] == 'A') a++;
    else b++;
  }
  if(a >= 1 && b >= 1) printf("Yes");
  else printf("No");
  
  return 0;
}


Measured memory_bytes: 128
# まだ解いてない配点を nokori として持つ
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    else:
        # 総合スコア、解いた問題数、まだ解いてない問題を更新
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)


Measured memory_bytes: 3064
<?php
$p=[0,0];
$L=(int)trim(fgets(STDIN));

for($i=0;$i<$L;$i++){
  $C=explode(' ',trim(fgets(STDIN)));
  $c=strcmp($C[0],$C[1]);

  if($c<0) $p[1]+=3;
  elseif($c>0) $p[0]+=3;
  else{
    ++$p[0];
    ++$p[1];
  }
}

echo $p[0],' ',$p[1];
?>

Measured memory_bytes: 15500
N = int(input())
A = list(map(int, input().split()))

A = [None] + A
B = [None] + [0] * N

for n in range(N, 0, -1):
    s = sum(B[i] for i in range(n + n, N + 1, n))
    B[n] = A[n] ^ (s % 2)

B = [i for i, b in enumerate(B) if b == 1]
print(len(B))
for i in B:
    print(i)


Measured memory_bytes: 12212
n = int(input())
A = list(map(int,input().split()))
money = 1000
stock = 0
for i in range(n-1):
  if A[i]<A[i+1]:
    stock += int(money/A[i])
    money -= A[i]*int(money/A[i])
  if A[i]>A[i+1]:
    money += A[i]*stock
    stock = 0
money += A[n-1]*stock
print(money)

Measured memory_bytes: 9200
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long//防爆int 
const int inf=0x3f3f3f3f3f3f3f3f;
const int N=100000;
int n/*小熊个数*/,m/*终点*/,s/*小熊被Shik碰到至生产金币之间的秒数*/;
int a[N+1];//小熊的位置 
int dp[N+1];//dp[i]表示Shik收完了前i个小熊的金币并回到了位置a[i]所花的最小秒数 
int q[N],head,tail;//对于第1个min维护的单调队列 
signed main(){
	cin>>n>>m>>s;
	for(int i=1;i<=n;i++)cin>>a[i];
	q[tail++]=0;//i=1,j=0满足2a[j+1]>=2a[i]-t，归第1个min，于是压入单调队列 
	int now=-1/*第2个min取的j构成的区间（前缀）的右端点*/,mn=inf/*当前的前缀最小值*/;
	for(int i=1;i<=n;i++){
		while(now+1<i&&2*a[now+2]<2*a[i]-s)now++,mn=min(mn,dp[now]-a[now]-2*a[now+1]);//将now往后移 
		while(head<tail&&q[head]<=now)head++;//维护单调队列，弹出过时元素 
		while(head<tail&&dp[q[tail-1]]-a[q[tail-1]]>=dp[i-1]-a[i-1])tail--;//维护单调队列队尾严格单调递增性 
		q[tail++]=i-1;//将j=i-1入队 
		dp[i]=min(dp[q[head]]-a[q[head]]+a[i]+s,mn+3*a[i]);//状态转移方程 
	}
	cout<<dp[n]+m-a[n]<<"\n";//目标 
	return 0;
}
/*1
3 9 1
1 3 8
*/
/*2
3 9 3
1 3 8
*/
/*3
2 1000000000 1000000000
1 999999999
*/

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n, m;
	while (cin >> n >> m&&n&&m) {
		vector<int>v(n);
		//for (int i = 1; i <= n; i++)printf("%3d", i); cout << endl;
		for (int i = 0; i < n; i++)v[i] = 0;
		int cnt = 1;
		int tom = 0;
		int index;
		for (int i = 0; cnt != n + 1; i++) {
			if (v[i%n] == 0) {
				tom++;
			}

			if (tom == m) {
				v[i%n] = cnt++;
				index = i%n + 1;
				tom = 0;
			}
			//for (int j = 0; j < n; j++)printf("%3d", v[j]);
			//cout << "index is " << index << endl;
		}
		cout << index << endl;
	}
	return 0;
}

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

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N; cin >> N;
	int K; cin >> K;
	int array[N]; for(int i=0;i<N;i++) cin >> array[i];
	cout << ceil((double)(N-1)/(K-1));
	return 0;
}


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

int n;
vector<int> l;

int main(){
    // 多角形でも三角形成立の原理と考えは同じ
    cin >> n;
    for(int i = 0; i < n; ++i){
        int buffer;
        cin >> buffer;
        l.emplace_back(buffer);
    }

    sort(l.begin(), l.end(), greater<int>());

    int other = 0;

    for(int i = 1 ; i < n; ++i){
        other += l[i];
    }

    // 最も長い辺がその他の合計よりも短いなら書ける
    if(l[0] < other){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
            }

            int[] digits = Input.ReadIntArray();
            Array.Sort(digits);
            int[] digitsPieces = new[] { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
            int[] pieces = digits.Select(d => digitsPieces[d]).ToArray();

            int[] DP = new int[N + 1];
            for (int i = 0; i <= N; i++)
            {
                DP[i] = -1;
            }
            DP[0] = 0;

            for (int i = 0; i <= N; i++)
            {
                foreach(int d in pieces)
                {
                    if (i >= d && DP[i - d] != -1)
                    {
                        DP[i] = Math.Max(DP[i], DP[i - d] + 1);
                    }
                }
            }

            {
                int i = N;
                while (i > 0)
                {
                    foreach (var a in digits.Reverse())
                    {
                        int d = digitsPieces[a];
                        if (i >= d && DP[i - d] == DP[i] - 1)
                        {
                            Console.Write(a);
                            i -= d;
                            break;
                        }
                    }
                   
                }
            }
            Console.WriteLine();

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13372
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    pair<int,int>p[n];
    for(int x=0;x<n;x++){
        cin>>p[x].F>>p[x].S;
    }
    sort(p,p+n);
    int r=p[0].F+p[0].S;
    int ans=1;
    for(int x=1;x<n;x++){
        if(p[x].F-p[x].S>=r){
            ans++;
            r=p[x].F+p[x].S;
        }else{
            if(p[x].F+p[x].S<r){
                r=p[x].F+p[x].S;
            }
        }
    }
    cout<<ans;








	
return 0;
}


Measured memory_bytes: 1792
N = int(input())
a = list(map(int, input().split()))

checked = [False] * N
ans = 0
for i in range(N):
    if not checked[i]:
        if a[a[i]-1]-1 == i:
            ans += 1
            checked[i] = True
            checked[a[i]-1] = True

print(ans)

Measured memory_bytes: 14008
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
 
auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}
 
void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}
bool test(long[] a, long l, long u, long k, long q) {
  /*
  return a.split!(x => x < l)
          .filter(x => x.length >= k)
          .map!(x => min(x.count!(y => y <= u), x.length.to!long - k + 1))
          .sum >= q;
          */
  long seg_len;
  long cnt_le_u;
  foreach(i; iota(a.length)) {
    if(a[i] < l) {
      if(seg_len >= k) {
        q -= min(seg_len - k + 1, cnt_le_u);
      }
      seg_len = 0;
      cnt_le_u = 0;
    } else {
      ++seg_len;
      if(a[i] <= u) {
        ++cnt_le_u;
      }
    }
  }
  if(seg_len >= k) {
    q -= min(seg_len - k + 1, cnt_le_u);
  }
  return q <= 0;
}
 
void main(){
  long n, k, q;
  readlnTo(n, k, q);
  auto a = readLongs();
  long ans = long.max / 2;
  foreach(i; iota(n)) {
    long l = a[i]-1;
    long u = 3_000_000_000;
    while(l + 1 < u) {
      auto m = (l+u)/2;
      if(test(a, a[i], m, k, q)) {
        u = m;
      } else {
        l = m;
      }
    }
    ans = min(ans, u-a[i]);
  }
  writeln(ans);
}

Measured memory_bytes: 380
def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    answer = [0 for i in range(N+1)]

    for i in range(0, N):
        for j in range(i+1, N):
            answer[min(abs(j-i), abs(X-i)+1+abs(j-Y))] += 1

    for i in range(1, N):
        print(answer[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
	string s;
	cin>>s;
	for(ll i=0;i<s.length();i++)
	{
		if(s[i]=='?')
		cout<<'D';
		else
		cout<<s[i];
	}
	return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


const int MAX_N = 202020;
vector<int>e[MAX_N + 5];
vector<int>ap;
vector<pair<int, int>>br;
int ord[MAX_N + 5], low[MAX_N + 5], state[MAX_N + 5];
int cnt = 0;
void orddfs(int now,int parent) {
	state[now] = 1;
	ord[now] = cnt;
	cnt++;
	int ccnt = 0;
	int appended = 0;
	int clow = 1e9 + 5;
	int ordlow = 1e9 + 5;
	fore(x, e[now]) { 
		if (state[x] == 1) {
			//後退辺はx→uを含まない
			if(x != parent)ordlow = min(ordlow, ord[x]);
		}
		else {
			orddfs(x,now);
			clow = min(clow,low[x]);
			//関節点(根以外)
			if (parent != -1 && low[x] >= ord[now] && appended == 0) {
				ap.pb(now);
				appended = 1;
			}
			//橋
			if (low[x] > ord[now])br.pb({min(now,x),max(now,x)});
			ccnt++;
		}
	} 
	if (parent == -1 && ccnt >= 2)ap.pb(now);
	low[now] = min(min(clow,ordlow),ord[now]);
}

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

	int V, E;
	cin >> V >> E;
	for (int i = 0; i < E; i++){
		int s, t;
		cin >> s >> t;
		e[s].pb(t);
		e[t].pb(s);
	}
	orddfs(0,-1);
	sort(all(br));
	fore(x, br)cout << x.first << " " << x.second << endl;


	return 0;
}


Measured memory_bytes: 9616
colors = list("PWGY")
dict = {}
for c in colors:
    dict[c] = False
N = int(input())
for x in input().split():
    dict[x] = True
ans = 0
for c in colors:
    ans += 1 if dict[c] else 0
if ans == 3:
    print("Three")
else:
    print("Four")


Measured memory_bytes: 2940
#include<stdio.h>
#include<malloc.h>
int main(void)
{
	int n, s = 0;
	scanf("%d", &n);
	int* p;
	p = (int*)malloc(sizeof(int) * n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &p[i]);
	}
	for (int i = 1; i < n - 1; i++)
	{
		if ((p[i]<p[i + 1] && p[i]>p[i - 1]) || (p[i] > p[i + 1] && p[i] < p[i - 1]))
		{
			s++;
		}
	}
	printf("%d", s);
	free(p);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
int main(void){
  int K,T;
  int i,tmp;
  cin>>K>>T;
  vector<int> a(T);

  for(i=0;i<T;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  tmp=a[T-1];
  for(i=T-2;i>=0;i--){
    tmp-=a[i];
  }
  if(tmp<=1) cout<<"0\n";
  else  cout<<tmp-1<<endl;
  return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
id = [list(map(int, input().split())) for _ in range(M)]
L = []
R = []
for i in range(M):
    L.append(id[i][0])
    R.append(id[i][1])
if max(L) <= min(R):
    print(min(R) - max(L) + 1)
else:
    print(0)


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

int main(){
    // 入力
    int n,m,k;
    std::cin >> n >> m >> k;
    std::vector<long long> A(n),B(m);
    for(int i = 0;i < n;i++) std::cin >> A.at(i);
    for(int i = 0;i < m;i++) std::cin >> B.at(i);

    // 累積和
    std::vector<long long> sumA(n+1,0),sumB(m+1,0);
    for(int i = 0;i < n;i++) sumA.at(i+1) = sumA.at(i) + A.at(i);
    for(int i = 0;i < m;i++) sumB.at(i+1) = sumB.at(i) + B.at(i);

    long long ans = 0;
    // 二分探索
    for(int i = 0;i < n+1;i++){
        if(sumA.at(i) > k)break;
        long long j = std::upper_bound(sumB.begin(), sumB.end(), k - sumA.at(i)) - sumB.begin();
        ans = std::max(ans, i+j-1);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 9576
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999

ll N,K,t;

int main(){
  scanf("%lld %lld ",&N,&K);
  REP(i,N)scanf("%lld",&t);
  N--;
  cout << (N+(K-2))/(K-1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0)); 
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int ab[100010];

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n, m;
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        ab[b] = max(ab[b], a);
    }

    int k = 1;
    int ans = 0;
    REP(i, 2, n+1){
        if(ab[i] >= k){
            k = i;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N,T;
  cin>>N>>T;
  vector<int>c(N);
  vector<int>t(N);
  int ans=0;
  bool A=false;
  for(int i=0;i<N;i++){
    cin>>c[i]>>t[i];
    if(t[i]<=T){
      if(ans==0){
        ans=c[i];
        A=true;
      }
      else{
        ans=min(ans,c[i]);
      }
    }
  }
  if(A==false){
    cout <<"TLE"<<endl;
  }
  else{
    cout<<ans<< endl;
  }
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n;
	cin >> n;
	
	vector<int> A(n);
	
	rep(i,n){
		cin >> A[i];
	}
	int ans = A[0];
	
	rep(i,n){
		ans = __gcd(ans,A[i]);
	}
	cout << ans << endl;
}

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

int main(){
	int H,W,i,j;
	cin >> H >> W ;
	while(H!=0||W!=0){
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			cout << '#';
		}
		cout << endl;
	}
		cout << endl;
		cin >> H >> W ;
	}
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i, m) cin >> x[i];
  sort(x.begin(), x.end());
  
  vector<int> d(m-1);
  rep(i, m-1) {
    d[i] = x[i+1] - x[i];
  }
  sort(d.begin(), d.end());
  
  int sum = 0;
  rep(i, (m-1) - (n-1)) {
    sum += d[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3992
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main
{
	public static void main (String[] args) throws java.lang.Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int k = scn.nextInt();
		int[] arr = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			arr[i] = scn.nextInt();
		} int[] memo = new int[n + 1];
		Arrays.fill(memo, -1);
 
		System.out.println(mincostKjump_memoized(1, arr, k, memo));
	}
 
	public static int mincostKjump_memoized(int idx, int[] heights, int k, int[] memo) {
		if (idx == heights.length - 1)return memo[idx] = 0;
		if (memo[idx] != -1)return memo[idx];
		int ans = Integer.MAX_VALUE;
		for (int i = 1; i <= k && idx + i < heights.length; i++) {
			int cba = mincostKjump_memoized(idx + i, heights, k, memo) + Math.abs(heights[idx + i] - heights[idx]);
			ans = Math.min(ans, cba);
		}
		return memo[idx] = ans;
	}
}

Measured memory_bytes: 69860
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 11916
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ll = long long;
using ii = pair<int,int>;

constexpr int MAXN = 5+2e5;
const int INF = numeric_limits<int>::max();

int h,w,K;
vector<vector<char>> mat;

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

bool ok(int x, int y) {
  return x >= 0 && y >= 0 && x < h && y < w;
}

struct Dist {
  int dist, rem;
  bool operator<(const Dist& o) const {
    if (dist == o.dist) return rem > o.rem;
    return dist < o.dist;
  }
  bool operator==(const Dist& o) const {
    return dist == o.dist && rem == o.rem;
  }
  bool operator!=(const Dist& o) const {
    return !(*this == o);
  }
};

vector<vector<Dist>> d[4];

int dijkstra(const ii& s, const ii& t) {
  // dist, x, y, lastdir.
  priority_queue<array<int,5>, vector<array<int,5>>, greater<array<int,5>>> pq;

  foi (i,0,4) {
    d[i][s.first][s.second] = Dist{0,0};
    pq.push({0, 0, i, s.first, s.second});
  }


  while (!pq.empty()) {
    auto p = pq.top(); pq.pop();

    int x = p[3], y = p[4], ld = p[2], dist = p[0], rem = -p[1];
    if (Dist{dist, rem} != d[ld][x][y]) continue;

    foi (k,0,4) {
      int newx = x + dx[k], newy = y + dy[k];

      if (ok(newx, newy) && mat[newx][newy] != '@') {
        Dist newd{1+d[ld][x][y].dist, K-1};

        if (k == ld && d[ld][x][y].rem > 0) {
          newd.dist = d[ld][x][y].dist;
          newd.rem = d[ld][x][y].rem-1;
        }

        if (newd < d[k][newx][newy]) {
          d[k][newx][newy] = newd;
          pq.push({newd.dist, -newd.rem, k, newx, newy});
        }
      }
    }
  }

  int ans = numeric_limits<int>::max();
  foi (i,0,4) {
    ans = min(ans, d[i][t.first][t.second].dist);
  }
  if (ans == numeric_limits<int>::max()) ans = -1;
  return ans;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  ii st, en;
  cin >> h >> w >> K;
  cin >> st.first >> st.second >> en.first >> en.second;
  mat.assign(h, vector<char>(w));

  foi (i,0,4) d[i].assign(h, vector<Dist>(w, Dist{INF,INF}));

  foi (i,0,h) foi (j,0,w) cin >> mat[i][j];
  st.first--; st.second--; en.first--; en.second--;
  cout << dijkstra(st, en) << '\n';
  return 0;
}


Measured memory_bytes: 43256
s = input()

dicts = {'N':0, 'S':0, 'W':0, 'E':0}
for i in s:
    dicts[i] += 1

if dicts['N'] != 0 and dicts['S'] == 0 or dicts['N'] == 0 and dicts['S'] != 0:
    print('No')
elif dicts['W'] != 0 and dicts['E'] == 0 or dicts['W'] == 0 and dicts['E'] != 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;


int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    vector<int> s(n);
    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    sort(s.begin(),s.end());
    s.erase(s.end()-1);
    s.erase(s.begin());
    int sum=0,avg;
    for(int i=0;i<s.size();i++){
      sum+=s[i];
    }
    avg=sum/s.size();
    cout<<avg<<endl;
  }
  return 0;
}



Measured memory_bytes: 3032
def f1():
    t = 0
    for y in range(len(M)):
        for x in range(len(M[0])):
            if M[y][x] == '1':
                f2(x, y)
                t += 1
    return t


def f2(x, y):
    if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:
        return
    if M[y][x] == '1':
        M[y][x] = '0'
        f2(x, y-1)
        f2(x, y+1)
        f2(x+1, y)
        f2(x-1, y)


M = []
while True:
    try:
        line = input()
        if line == '':
            print(f1())
            M = []
        else:
            M.append(list(line))
    except EOFError:
        print(f1())
        break

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

int main() {
  int N;
  cin >> N;
  int X[N];
  for (int i = 0; i < N; ++i) {
    cin >> X[i];
  }

  int ans = 0;
  int min_score = 1 << 30;
  for (int i = 1; i <= 100; ++i) {
    int s = 0;
    for (int j = 0; j < N; ++j) {
      s += (X[j] - i) * (X[j] - i);
    }
    if (s < min_score) {
      min_score = s;
      ans = i;
    }
  }
  cout << min_score << endl;
  return 0;
}


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

int main(){
    int N, K;
    std::cin >> N >> K;
    std::vector< int > A(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    
    for(int i=0; i<N-K; i++){
        if(A[i] < A[i+K]){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
    }
    
    return 0;
    
}


Measured memory_bytes: 4048
import numpy as np
from numpy.fft import rfft, irfft

N, M = map(int, input().split())
*A, = map(int, input().split())
B = np.zeros(5*10**5)
for a in A:
    B[a] += 1

L = 5*10**5
FB = rfft(B, L)
C = np.rint(irfft(FB*FB)).astype(int)

ans = 0
for i in range(2*10**5, -1, -1):
    c = C[i]
    if not c:
        continue
    if M - c > 0:
        ans += i*c
        M -= c
    else:
        ans += i*M
        break
print(ans)


Measured memory_bytes: 55872
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <numeric>
using namespace std;


main()
{
    int a,b,c,d; cin>>a>>b>>c>>d;
    int ta=(c+b-1)/b;
    int ao=(d+a-1)/d;
    if(ao<ta) cout << "No" << "\n";
    else cout << "Yes" << "\n";
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int d = sc.nextInt();
			int s = 0;
			for(int i = 1; i * d < 600; i++) {
				s += (i * d) * (i * d) * d;
			}
			System.out.println(s);
		}
		sc.close();
	}
}


Measured memory_bytes: 25884
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

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

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<string>s(n);
	vector<ll>a(5);
	rep(i, n) {
		cin >> s[i];
		if (s[i][0] == 'M')a[0]++;
		else if (s[i][0] == 'A')a[1]++;
		else if (s[i][0] == 'R')a[2]++;
		else if (s[i][0] == 'C')a[3]++;
		else if (s[i][0] == 'H')a[4]++;
	}
	ll ans = 0;
	rep(i, 5) {
		for (ll j = i + 1;j < 5;++j) {
			for (ll k = j + 1;k < 5;++k) {
				ans += a[i] * a[j] * a[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6376
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g $PROGRAM -o $OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m;
	cin >> n >> m;
	VII h(n+1);
	for (int i = 1; i <= n;++i)
		cin >> h[i];

	vector<set<int>> st(n+1);
	while(m--)
	{
		int x, y;
		cin >> x >> y;
		st[x].insert(h[y]);
		st[y].insert(h[x]);
	}
	int cnt = 0;
	for (int i = 1; i <= n;++i)
	{
		auto it = st[i].lower_bound(h[i]);
		if(it==st[i].end())
		{
			cnt++;
		}
	}
	cout << cnt;

#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}


Measured memory_bytes: 17720
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

bool p[55000];

void prime() {
  fill(p, p+55000, true);
  p[0] = false;
  p[1] = false;

  for(int i = 2; i < 55000; i++) {
    if(p[i]) {
      for(int j = 2; i*j < 55000; j++) {
	p[i*j] = false;
      }
    }
  }
}

int main() {
  int n, min, max;
  prime();
  
  while(cin >> n) {
    max = 2;
    for(int i = 3; i < n; i++) {
      if(p[i] && max < i) max = i;
    }
    for(int i = n+1; i < 55000; i++) {
      if(p[i]) {
	min = i;
	break;
      }
    }
    cout << max << ' ' << min << endl;
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
const int MN = 1e6+5, MOD=1e9+7, LOG=33;
ll lcm (ll a, ll b) {return a*b/__gcd(a,b);}
ll multiplyMod(ll a, ll b) { return (a % MOD * b % MOD) % MOD; }
ll addMod(ll a, ll b) { return (a % MOD + b % MOD) % MOD; }
ll subMod(ll a, ll b) { return (a % MOD - b % MOD) % MOD; }
ll fpow(ll b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
int h, a;
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> h >> a;
    cout << (h+a-1)/a<< "\n";
    return 0;

}

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

string s, t;

int main(){
  cin >> s;
  cin >> t;

  string s_double = s + s;
  vector<int> chr_idx[26];

  for(int i = 0; i < s_double.size(); i++){
    chr_idx[s_double[i] - 'a'].push_back(i);
  }

  long long rep = 0, resid = 0;
  for(int i = 0; i < t.size(); i++){
    auto itr = lower_bound(chr_idx[t[i] - 'a'].begin(),
			   chr_idx[t[i] - 'a'].end(),
			   resid);
    if(itr == chr_idx[t[i] - 'a'].end()){
      cout << -1 << endl;
      return 0;
    }
    resid = *itr + 1;
    if(resid >= s.size()){
      resid -= s.size();
      rep++;
    }
  }
  cout << 1LL * s.size() * rep + resid << endl;

}


Measured memory_bytes: 1980
#include <stdio.h>
#include <string.h>
int main()
{
    char s[100000],a[50000];
    int i,j=0;
    gets(s);
    for(i=0;s[i];i++)
        if((i+3)%2==1)
            a[j++]=s[i];
    a[j]='\0';
    puts(a);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

int main() {
	string s; cin >> s;
	ll cnt;
	string t = "keyence";

	bool ok = false;
	rep(i, 0, s.size()) {
		if (s.substr(i, 7) == t) {
			ok = true;
		}
	}

	if (!ok) {
		if (s.substr(0, 1) == "k" && s.substr(s.size() - 6, 6) == "eyence" ||
			s.substr(0, 2) == "ke" && s.substr(s.size() - 5, 5) == "yence" ||
			s.substr(0, 3) == "key" && s.substr(s.size() - 4, 4) == "ence" ||
			s.substr(0, 4) == "keye" && s.substr(s.size() - 3, 3) == "nce" ||
			s.substr(0, 5) == "keyen" && s.substr(s.size() - 2, 2) == "ce" ||
			s.substr(0, 6) == "keyenc" && s.substr(s.size() - 1, 1) == "e"
			)
		{
			ok = true;
		}
		else {
			ok = false;
		}
	}

	if (ok) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	int n, i;
	int a, b, c;
	
	scanf("%d", &n);
	
	for (i=0; i<n; i++)
	{
		scanf("%d %d %d", &a, &b, &c);
		
		// find maximum
		if (a > b && a > c)
		{
			if (a*a == b*b + c*c)
			{
				printf("YES\n");
			}else
			{
				printf("NO\n");
			}
		}
		else if (b > a && b > c)
		{
			if (b*b == a*a + c*c)
			{
				printf("YES\n");
			}else
			{
				printf("NO\n");
			}
		}
		else
		{
			if (c*c == b*b + a*a)
			{
				printf("YES\n");
			}else
			{
				printf("NO\n");
			}
		}
	}
}

Measured memory_bytes: 1008
#include <iostream>
#define int long long int
using namespace std;
 
int X;
 
signed main(){
  cin >> X;
  for(int i = -200; i <= 200; i++){
    for(int j = -200; j <= 200; j++){
      if(i * i * i * i * i - j * j * j * j * j == X){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
const ll mod=1000000007;

main(){
  int n;cin >> n;
  int a[n];for(int i=0;i<n;i++) cin >> a[i];
  ll ans=0;
  for(int i=0;i<n-1;i++){
    if(a[i]>a[i+1]){
      int diff=0;
      diff=a[i] - a[i+1];
      a[i+1]+=diff;
      ans+=diff;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4396
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)
#define int ll

signed main(){
	int n,a;
	cin>>n>>a;
	
	vector<int> x(n);
	rep(i,n)cin>>x[i];
	
	
	static int dp[51][51][2600];
	rep(i,51)rep(j,51)rep(k,2600)dp[i][j][k] = 0;
	
	
	dp[0][0][0] = 1;
	
	for(int i=1;i<=n;i++){
		rep(j,51){
			rep(k,2600){
				dp[i][j][k] = dp[i-1][j][k];
				if(k-x[i-1]>=0&&j-1>=0)dp[i][j][k] += dp[i-1][j-1][k-x[i-1]];
			}
		}
	}
	
	ll ans = 0;
	for(int j=1;j<=n;j++){
		ans+=dp[n][j][j*a];
	}
	
	cout<<ans<<endl;
	
	
}

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

using namespace std;

const int N=1e5+5;

int arr[N];
int dp[N][22];
int n,l,q;

int get(int a,int x)
{
	for(int i=21;i>=0;i--)
	{
		if(x&(1<<i))
			a=dp[a][i];
	}
	return a;
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	cin >> l >> q;
	int r=0;
	for(int i=0;i<n;i++)
	{
		if(r<i) r=i;
		while(r+1<n&&arr[r+1]-arr[i]<=l) r++;
		dp[i][0]=r;
	}
	for(int j=1;j<22;j++)
		for(int i=0;i<n;i++)
			dp[i][j]=dp[dp[i][j-1]][j-1];
	while(q--)
	{
		int a,b;
		cin >> a >> b;
		a--; b--;
		if(a>b) swap(a,b);
		int st=1,en=n,ans=n;
		while(st<=en)
		{
			int mid=(st+en)/2;
			//cout << a << " " << mid << " " << get(a,mid) << endl;
			if(get(a,mid)>=b)
			{
				ans=mid; en=mid-1;
			}
			else
				st=mid+1;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 9856
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	
	int n, ans, out;
	
	string str;
	
	bool base[3];
	
	cin >> n;
	
	for(int loop = 0; loop < n; loop++){
		
		base[0] = false;
		base[1] = false;
		base[2] = false;
		
		ans = 0;
		out = 0;
		
		while(true){
			
			cin >> str;
			
			if(str == "HIT"){
				if(base[2]){
					ans++;
				}
				if(base[1]){
					base[2] = true;
				}else{
					base[2] = false;
				}
				if(base[0]){
					base[1] = true;
				}else{
					base[1] = false;
				}
				base[0] = true;
			}else if(str == "HOMERUN"){
				ans++;
				if(base[2]){
					ans++;
				}
				if(base[1]){
					ans++;
				}
				if(base[0]){
					ans++;
				}
				base[0] = false;
				base[1] = false;
				base[2] = false;
			}else if(str == "OUT"){
				out++;
			}
			if(out >= 3){
				break;
			}
		}
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin >> n >> k;
	long long int ans = 0;
	for(int i = 0; i < k; i++){
		long long int tmp = n / k;
		if ( n % k >= i && i > 0 ) tmp++;
		if ( i * 2 % k != 0 ) continue;
		ans += tmp * tmp * tmp;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
//Solution by Zhusupov Nurlan
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define endl '\n'
#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base LL(1e9 + 7)
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define mp make_pair

LL a[sz], A, B, n;

bool check(LL x) {
  LL t = 0;
  for (int i = 1; i <= n; i++) {
    t += (max(0ll, a[i] - B*x) + (A - B - 1))/(A - B);
  }
  return t <= x;
}

int main()
{
//    freopen(fname"in", "r", stdin);
//    freopen(fname"out", "w", stdout);

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cin >> n >> A >> B;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  LL l = 0, m, r = 1e9 + 1;
  while (r - l > 1) {
    m = (l + r) >> 1;
    if (check(m))
      r = m;
    else
      l = m;
  }
  cout << r;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((10*g+b)%4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256