akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long 
	while (true) {
		int d, w;
		cin >> d >> w;
		if (d == 0) return 0;
		int cnter[20][20] = {};
		for (int i = 0; i < d; ++i) {
			for (int q = 0; q < w; ++q) {
				cin >> cnter[i][q];
			}
		}
		int ans = 0;
		REP(i, d) {
			REP(q, w) {
				for (int j = i+2; j < d; ++j) {
					for (int t = q+2; t < w; ++t) {
						int now_max = 100000;
						int now_minnest = 0;
						int geko = 0;
						int cnt = 0;
						for (int tea = i; tea <= j; ++tea) {
							for (int p = q; p <= t; ++p) {
								if (tea == i || tea == j || p == q || p == t) {
									now_max = min(now_max, cnter[tea][p]);
								}
								else {
									now_minnest = max(now_minnest, cnter[tea][p]);
									geko += cnter[tea][p];
									cnt++;
								}
							}
						}
						if (now_minnest < now_max) {
							ans = max(ans, now_max * cnt - geko);
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
}



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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  cout << n * n * n << endl;
}

Measured memory_bytes: 256
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = (int)8 * 1000 * 1000 * 1000 + 200;
const int MAXN =  100 * 1000 + 10;
const int MLOG = 80;
const int NMAX = 20;

signed main() {
	IO;
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	set <int> mp;
	int ans = 0, srt[n], sr = 0, lst[n];
	for(int i = 1; i < n; i++) if(a[i] < a[i - 1]) lst[i] = i; else lst[i] = lst[i - 1];
    for(int i = k - 1; i < n; i++){
      if(lst[i] <= i - k + 1) srt[i] = true;
   	  else srt[i] = false;
	  //cout << lst[i] << '-' << srt[i] << '-' << i - k << ' ';
    }
	//cout << endl;
	for(int i = 0; i < k; i++) mp.insert(a[i]);
	//for(int i = k - 1; i < n; i++) srt[i] = is_sorted(a + i - k + 1 , a + i + 1);
	sr = srt[k - 1];
	for(int i = k; i < n; i++){
		int tmp = a[i - k];
		mp.erase(a[i - k]);
		int mn = *mp.begin(), mx = *mp.rbegin();
		//cout << mn << ' ' << mx << ' ' << (tmp > mn) << ( a[i] < mx) <<  (!srt[i]) <<endl;
		ans += (tmp > mn || a[i] < mx) && (!srt[i]);
		sr |= srt[i];
		sr |= srt[i - 1];
		mp.insert(a[i]);
	}
	cout << ans + !srt[k - 1] + sr;
}

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

int main(){
  ll n,k,i;
  double ans;
  cin >> n >> k;
  double a[n];
  ans=1;
  for(i=0;i<n;i++){
    cin >> a[i];
    if(i>=k){
      ans=ans*a[i]/a[i-k];
      if(ans>1){
        cout << "Yes" << endl;
        ans=1;
      }
      else{
        cout << "No" << endl;
        ans=1;
      }
    }
  }
}

Measured memory_bytes: 5280
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


from itertools import combinations
from collections import Counter as cc
def main():
    def check(a, b, c):
        return a+b > c

    n = ii()
    l = li()
    l = cc(l)
    x = list(combinations(l.keys(), 3))

    cnt = 0
    for a, b, c in x:
        if check(a, b, c) and check(b, c, a) and check(c, a, b):
            cnt += l[a]*l[b]*l[c]
    print(cnt)



if __name__ == '__main__':
    main()

Measured memory_bytes: 20752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<string, string> P;

string s;

void dfs(int i, int end, const string& lTemp, const string& rTemp, vector<P> &x)
{
    if (i == end)
    {
        x.push_back(make_pair(lTemp, rTemp));
        return;
    }

    dfs(i + 1, end, lTemp + s[i], rTemp, x);
    dfs(i + 1, end, lTemp, s[i] + rTemp, x);
}

int main(void)
{
    int n;
    cin >> n;
    cin >> s;
    reverse(s.begin() + n, s.end());

    vector<P> vl;
    vector<P> vr;
    dfs(0, n, "", "", vl);
    dfs(n, 2 * n, "", "", vr);
    sort(vl.begin(), vl.end());
    sort(vr.begin(), vr.end());

    long long score = 0;
    auto ir_lower = vr.begin();
    for (auto il = vl.begin(); il < vl.end(); ++il)
    {
        ir_lower = lower_bound(ir_lower, vr.end(), *il);
        auto ir_upper = upper_bound(ir_lower, vr.end(), *il);

        score += ir_upper - ir_lower;
    }

    cout << score << endl;
    return 0;
}


Measured memory_bytes: 60396
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){
}
void jury(){
}
void solve(){
    int n = scan!int;
    long[] as = scan!long(n);

    long tmp = as[0];
    foreach(a; as) tmp = gcd(tmp, a);
    if(tmp > 1){
        "not coprime".writeln;
        return;
    }

    auto f = new Factorizer(1_000_009);
    bool[] us = new bool[1_000_009];
    foreach(a; as) foreach(p; f(a, 0)) if(us[p]){
        log("a:", a, "p:", p, "us:", us[0 .. 20].to!(int[]));
        "setwise coprime".writeln;
        return;
    }
    else us[p] = 1, log("a:", a, "p:", p, "us:", us[0 .. 20].to!(int[]));

    "pairwise coprime".writeln;

}


/// 最大公約数。最大の公約数。
/// 例 gcd(12, -18) = 6, gcd(-12, -18) = 6, gcd(12, 0) = 12, gcd(0, 0) = 0
/// ※本当は gcd(0, 0) は存在しないが便宜上 0 を返している
long gcd(long a, long b){
	if(a < 0) a = -a;
	if(b == 0) return a;
	if(b < 0) return gcd(a, -b);
	if(a % b == 0) return b;
	if(a < b) return gcd(b, a);
	else return gcd(b, a % b);
}

// n 以下の自然数を素因数分解する
// 準備に O(m^2) ただし m は素数の個数（=O(log n) ）
// 1回の実行に O(log a) ただし a は引数
class Factorizer{
    long[] ds; // ds[i]: i を割り切る最小の素数
    this(long n){
        ds = new long[](n + 1);
        foreach(i; 0 .. n + 1) ds[i] = i;
        foreach(i; 2 .. n + 1){
            if(ds[i] < i) continue;
            for(long u = i * 2; u <= n; u += i) if(ds[u] > i) ds[u] = i;
        }
    }

    // 素因数分解（重複度に応じる 例：f(12) = [2, 2, 3]）
    long[] opCall(long a){
        long[] res;
        while(a > 1) res ~= ds[a], a /= ds[a];
        return res;
    }

    // 素数の約数の列挙（重複度は無視 例：f(12, 0) = [2, 3]）
    long[] opCall(long a, bool canDuplicate){
        if(canDuplicate) return opCall(a);
        long[] res;
        while(a > 1){
            if(res.length == 0 || res[$ - 1] < ds[a]) res ~= ds[a];
            a /= ds[a];
        }
        return res;
    }

}

Measured memory_bytes: 54916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll=long long;
using namespace std;
int main(){
long long a,b,c,d;
cin>>a>>b>>c>>d;
cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		string[] s = Input();
		int m = int.Parse(s[0]);
		int d = int.Parse(s[1]);
		int c = 0;
		for(int i = 0; i < m; i++)
		{
			int tuki = i + 1;
			for(int j = 1; j <= d; j++)
			{
				if(j<20)
					continue;
				
				int d1 = j % 10;
				int d10 = j / 10;
				
				if(d1 >= 2 && d10 >= 2 && d1 * d10 == tuki)
				{
					c++;
				}
			}
		}
		Console.WriteLine(c);
	}
	
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



Measured memory_bytes: 13140
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll n, k;
int main(){
	IOS;
	cin >> n >> k;	
	cout << (n % k != 0);
	
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int n,k;
    cin >> n >> k;
    vector<int> a(n+1);

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

    int cost[n+1];
    cost[1] = 0;
    cost[2] = abs(a[2] - a[1]);

    for(int i = 3; i<n+1; i++){
        cost[i] = INF;
    }

    for(int i = 3; i<n+1; i++){
        for(int dec = 1; dec<=k; dec++){
            if(i-dec > 0) cost[i] = min(cost[i-dec] + abs(a[i] - a[i-dec]), cost[i]);
        }
    }

    cout << cost[n] << "\n";

    return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int n;
  cin>>n;
  cout<<n*n*n<<endl;

  return 0;
}


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

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

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

bool check(VL &a, int n, ll x){
    if (x < 0) return false;
    ll s = 0;
    REP(i,n){
        s += (a[i] + x + 1) / (n + 1);
    }
    // cout << x << " " << s << endl;
    return s <= x;
}

int main(void){
    int n;
    cin >> n;
    VL a(n);
    REP(i,n) cin >> a[i];

    sort(ALL(a));
    if (a[n-1] <= n-1){
        cout << 0 << endl;
        return 0;
    }

    ll ok = 1e18, ng = 0;
    while (ok - ng > 1){
        ll mi = (ok + ng) / 2;
        if (check(a, n, mi)) ok = mi;
        else ng = mi;
    }

    for (ll i = ok-100000; i <= ok; i++){
        if (check(a, n, i)){
            ok = i;
            break;
        }
    }

    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
v = [int(e) for e in input().split()]
m = min(n, k)
result = 0
for i in range(m + 1):
  for j in range(i + 1):
    t = v[:j]
    t.extend(v[n - (i - j):])
    t.sort()
    l = k - i
    while len(t) > 0 and l > 0 and t[0] < 0:
      t.pop(0)
      l -= 1
    m = sum(t)
    if m > result:
      result = m
print(result)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    ll n,a=0;
    cin>>n;
    ll p[22];
    rep(i,n){
        cin>>p[i];
    }
    rep(i,n-2){
        if(p[i]>p[i+1]&&p[i+1]>p[i+2]) a++;
        else if(p[i]<p[i+1]&&p[i+1]<p[i+2]) a++;
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
/*
* sq(a) + sq(b) < sq(c)
* a + b + 2*sq(a)sq(b) < c
* 2*sq(a)*sq(b) < c - a - b
* if(c-a-b > 0)
* 4*a*b < (c-a-b)^2
*/

#include<stdio.h>

int main(){
  long long a, b, c, x;
  
  scanf("%lld %lld %lld", &a, &b, &c);
  
  x = c - (a + b);
  if(x > 0 &&  4*a*b < x*x ){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}


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

const int mod = 1e9 + 7;
int n, k;
vector<vector<int>> e;
int ans = 1;

void dfs(int node, int brother, int parent, int root = 0) {
	int mul = max(0ll, k - brother - 2 + root);
	ans *= mul;
	ans %= mod;
	int child = 0;
	for (int x : e[node]) {
		if (x == parent);
		else if (root == 0) { dfs(x, child, node); ++child; }
		else { dfs(x, child, node, root - 1); ++child; }
	}
}

signed main() {

	cin >> n >> k;
	e.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	dfs(0, 0, 0, 2);
	cout << ans << endl;
}

Measured memory_bytes: 11520
fun main() = Thread(null, ::abc173b, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc173b() {
    val n = readLine()!!.toInt()
    val sList = Array(n) { readLine()!! }

    val grouped = sList.groupingBy { it }.eachCount()

    val answer = listOf("AC", "WA", "TLE", "RE").map { it to (grouped[it] ?: 0) }
        .joinToString(System.lineSeparator()) { "${it.first} x ${it.second}" }

    println(answer)
}


Measured memory_bytes: 62120
//B - Extension
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
//#define P 998244353

int main()
{
  long long int a,b,c,d,i,j,x[3100][3100],P=998244353;
  scanf("%lld %lld %lld %lld", &a,&b,&c,&d);

  x[a][b]=1;  //a,c:Tate, b,d:Yoko
  for(i = a; i <= c-1; i++) {
    x[i+1][b]=(x[i][b]*b)%P;
  }
  for(j = b; j <= d-1; j++) {
    x[a][j+1]=(x[a][j]*a)%P;
  }
  for(i = a; i <= c-1; i++) {
    for(j = b; j <= d-1; j++) {
      x[i+1][j+1]=(((x[i+1][j]*(i+1))%P) + ((x[i][j+1]*(j+1))%P) - ((x[i][j]*i*j)%P))%P;
    }
  }

  if (x[c][d]>=0){
    printf("%lld\n", x[c][d]);
  }
  else{
    printf("%lld\n", x[c][d]+P);
  }
  return 0;
}


Measured memory_bytes: 74392
from bisect import bisect_right

n, d, a = map(int, input().split())
lxh = [tuple(map(int, input().split())) for _ in range(n)]

lxh.sort()
lx, lh = [], []
for x, h in lxh:
    lx.append(x)
    lh.append(h)

n_bomb = 0
total_damage = 0
subtract = [0 for _ in range(n + 1)]

for i in range(n):
    total_damage -= subtract[i]

    x = lx[i]
    h = lh[i] - total_damage

    if h > 0:
        n_bomb += -(-h // a)
        damage = -(-h // a) * a
        total_damage += damage

        i_sub = bisect_right(lx, x + 2 * d)
        subtract[i_sub] += damage

print(n_bomb)


Measured memory_bytes: 47476
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for (auto e: v) os << e << ",";
    os << "]";
    return os;
}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

int H, A;

void solve()
{
    cout << H / A + (H % A == 0 ? 0 : 1) << endl;
}

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

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define MAX 1e9+7
#define MIN -1e9-7
#define int long long
#define endl "\n"
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define s(n) scanf("%d",&n)
#define mem memset(a, 0, sizeof(a))
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
typedef vector<int> vi;
typedef vector<string> vs;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
		  freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
    #endif
   
   int n;
   cin>>n;
   int d;
   cin>>d;
   int ans=0;
   while(n--)
   {
   int a,b;
   cin>>a>>b;
   if(sqrt(a*a+b*b)<=d)
   {
       //cout<<a*a+b*b<<endl;
       ans++;
   }

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


Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <set>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

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

    string divide[4] = {"maerd", "remaerd", "esare", "resare"};

    reverse(s.begin(), s.end());


    bool can = true;
    for(int i = 0; i < s.size();){
        bool can2 = false;
        for(int j = 0; j < 4; j++){
            string d = divide[j];
            if(s.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            }

        }
        if(!can2){
            can = false;
            break;
        }
    }

    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;




}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kenji
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC092D solver = new ABC092D();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC092D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();

            int[][] m = new int[100][100];
            for (int i = 0; i < 100; i++) {
                for (int j = 0; j < 100; j++) {
                    if (i < 50) {
                        m[i][j] = 0;
                    } else {
                        m[i][j] = 1;
                    }
                }
            }

            for (int i = 0; i < B - 1; i++) {
                int height = i / 50;
                m[height * 2][i % 50 * 2] = 1;
            }

            for (int i = 0; i < A - 1; i++) {
                int height = i / 50;
                m[99 - height * 2][i % 50 * 2] = 0;
            }

            out.println("100 100");
            for (int i = 0; i < 100; i++) {
                for (int j = 0; j < 100; j++) {
                    if (m[i][j] == 0) {
                        out.print('.');
                    } else {
                        out.print('#');
                    }
                }
                out.println();
            }
        }

    }
}



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

ll g1(ll n, int p) {
  if (n == 0) return 0;
  return n/p + g1(n/p,p);
}
ll g2(ll n, int p) {
  if (n%2 == 1) {
    return g1(n,p) - g2(n-1,p);
  }
  ll res = g1(n/2,p);
  if (p == 2) res += n/2;
  return res;
}

int main()
{
  ll n;
  cin >> n;
  ll ans = min(g2(n,2), g2(n,5));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

mint on[61], off[61];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        ll a;
        cin >> a;
        rep(j,61){
            if(a>>j & 1) on[j] += 1;
            else off[j] += 1;
        }
    }
    mint ans = 0, two = 1;
    rep(j,61){
        ans += on[j] * off[j] * two;
        two *= 2;
    }
    cout << ans.x << endl;
    return 0;
}


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

int main()
{
  int d, n;
  cin >> d >> n;
  if (n == 100)
    n++;
  for (int i = 0; i < d; ++i)
    n *= 100;

  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

long long npow(int K, int N) {
	long long ans = 1;
	for (int i = 0;i < N;i++) {
		ans *= K;
	}
	return ans;
}

int main() {
	int N, K;
	cin >> N >> K;
	
	long long ans = K * npow(K - 1, N - 1);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
char k;
set <string> s;
bool b;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string c;
		cin>>c;
		if(s.find(c)!=s.end() || (i!=0 && c[0]!=k))
			b=true;
		else
			s.insert(c);
		k=c[c.size()-1];
	}
	if(b)
		cout<<"No";
	else
		cout<<"Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}
vector<ll> dp(100001, -1);
void dfs(ll s, vector< vector<ll> > &adj, vector<bool> &v)
{
    v[s] = true;
    ll child = 0;
    for(auto c: adj[s])
    {
        if(!v[c])
        {
            dfs(c, adj, v);
        }
        // if(dp[c] == -1)
        //     continue;
        dp[s] = max(dp[s], dp[c] + 1);
        child += 1;
    }
    if(!child)
    {
        dp[s] = 0;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n,m;
    cin>>n>>m;
    vector< vector<ll> > adj(n + 1);
    vector<bool> vis(n + 1, false);
    for (ll i = 0; i < m; i++)
    {
        /* code */
        ll v1,v2;
        cin>>v1>>v2;
        adj[v1].push_back(v2);
    }
    ll ans = 0;
    for(ll i=1; i<=n; i++)
    {
        if(!vis[i])
            dfs(i, adj, vis);
    }
    for(ll i=1; i<=n; i++)
    {
        ans = max(ans, dp[i]);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 12892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef vector< pair< ll,ll > > ii;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int main(void)
{
    char s;
    cin >> s;
    cout << (char)((int)s+1);
    return 0;
}

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

int main() {
  int N = 0;
  cin >> N;
  vector<int> arrival(N);
  vector<int> rearrival(N);
  for(int i = 0;i < N;i++) {
    cin >> arrival.at(i); 
  }
  for(int i = 0;i < N;i++) {
    rearrival.at(arrival.at(i)-1) = i + 1;
  }
  for(int i = 0;i < N;i++) {
    cout << rearrival.at(i) << " ";
  }
}


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

int main() {
	int n; cin >> n;
	int ans = 1;
	int precnt = 0;
	for (int i = 1; i <= n; i++) {
		int cnt = 0;
		int tmp = i;
		while (tmp % 2 != 1) { cnt++; tmp /= 2; }
		if (cnt > precnt) { ans = i; precnt = cnt; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> H(N), W(N);
  for (int i = 0; i < N; i++){
    cin >> H[i] >> W[i];
  }
  vector<vector<char>> C(4, vector<char>(4));
  for (int i = 0; i < 4; i++){
    for (int j = 0; j < 4; j++){
      cin >> C[i][j];
    }
  }
  string S = "RGB";
  set<pair<int, int>> st;
  for (int i = 0; i < N; i++){
    for (int j = 1 - H[i]; j < 4; j++){
      for (int k = 1 - W[i]; k < 4; k++){
        for (int l = 0; l < 3; l++){
          int add = 0;
          int sub = 0;
          for (int m = 0; m < H[i]; m++){
            for (int n = 0; n < W[i]; n++){
              int y = j + m;
              int x = k + n;
              if (0 <= y && y < 4 && 0 <= x && x < 4){
                if (C[y][x] == S[l]){
                  add |= 1 << (y * 4 + x);
                } else {
                  sub |= 1 << (y * 4 + x);
                }
              }
            }
          }
          st.insert(make_pair(add, sub));
        }
      }
    }
  }
  vector<int> d(65536, -1);
  d[0] = 0;
  queue<int> Q;
  Q.push(0);
  while (!Q.empty()){
    int c = Q.front();
    Q.pop();
    for (auto P : st){
      int c2 = c & ~P.second | P.first;
      if (d[c2] == -1){
        d[c2] = d[c] + 1;
        Q.push(c2);
      }
    }
  }
  cout << d[65535] << endl;
}


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

bool judgePrimeNumber( int a )
{
    if( a == 1 )
        return false;
    for( int i = 2; i <= sqrt(a); i++ )
        if( a % i == 0 )
            return false;
    return true;
}


int main()
{
    int n, p;
    vector<int> v, w;

    while( cin >> n >> p )
    {
        if( n == -1 && p == -1 )
            break;

        int i = n + 1, cnt = 0;
        while( cnt != 100 )
        {
            if( judgePrimeNumber( i ) )
            {
                v.push_back(i);
                cnt++;
            }
            i++;
        }

        for( i = 0; i < v.size() / 4; i++ )
            for( int j = i; j < v.size() / 4; j++ )
                w.push_back( v[i] + v[j] );

        for( i = 0; i < w.size(); i++ )
            for( int j = w.size() - 1; j >= i + 1; j-- )
                if( w[j] < w[j-1] )
                {
                    int t = w[j];
                    w[j] = w[j-1];
                    w[j-1] = t;
                }
        cout << w[p-1] << endl;
        v.clear();
        w.clear();
    }
    return 0;
}



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

const int N = 2020;

typedef long long ll;

int n, MOD, dp[3*N][6*N];

void add(int &x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

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

    for (int bal = 0; bal <= 3*n; bal++) dp[0][3*N+bal] = 1; 

    for (int x = 1; x <= 3*n; x++) {
        for (int bal = -3*n; bal <= 3*n; bal++) {
            dp[x][3*N+bal] = 0;
            ll ways = 1;
            for (int y = 1; y <= min(x,3); y++) {
                int dbal = 0;
                if (y == 1) dbal = 1;
                if (y == 2) dbal = -1;
                add(dp[x][3*N + bal], ways * dp[x-y][3*N + bal + dbal] % MOD);
                ways *= x-y;
            }
        }
    }
    cout << dp[3*n][3*N] << endl;
    return 0;
}


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

#define ll long long		

const ll mod = (ll) 1e9 + 7;

int main() {
	//freopen("C.in", "r", stdin);
	//freopen("C1.out", "w", stdout);
	
	
	
	int n;
	cin >> n;
	vector<int> a(n + 1);


	vector<ll> s(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s[i] = s[i - 1] + a[i];
	}
	
	/*
	
	i = 1 ... n - 1, j = i + 1 ... n    sigma( ai * aj )
	
	( a1 * a2 + a1 * a3 + .. + a1 * an ) + ( a2 * a3 + a2 * a4 + ... + a2 * an ) + ( a3 * a4 + a3 * a5 + ... )
	use prefix sum
	
	
	a1 * ( a2 + a3 + ... + an ) + a2 * ( a3 + a4 * ... + an ) + a3 * ( a4 + a5 + a6 + ... + an ) + ...
	
	*/
	
	
	ll ans = 0;
	
	for (int i = 1; i < n; i++) {
		ans = (ans + (s[n] - s[i]) % mod * a[i]) % mod;
		
		//cout << (s[n] - s[i]) % mod * a[i] << endl;
		// 2 * 1e9 * 1e9 * 1e5 > LLONG_MAX
	}
	
	cout << ans;
}


Measured memory_bytes: 5560
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N, K;
    cin >> N >> K;
    vector<int> A(N+1);

    for (int i=1; i <= N; ++i) {
        cin >> A[i];
    }

    for (int i=K+1; i <= N; ++i) {
        cout << (A[i-K] < A[i] ? "Yes" : "No") << endl;
    }


    return 0;
}


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

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

    int a[n], b[n];
    long long ans = 0;

    priority_queue<pair<int, int> > q;

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

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

        if(b[i] > a[i]){
            q.push({b[i], i});
        }
    }

    while(!q.empty()){
        //cout << b[0] << " " << b[1] << " " << b[2] << endl;
        int x = q.top().second;
        q.pop();

        if(q.empty()){
            if((b[x] % (b[(x - 1 + n) % n] + b[(x + 1) % n])) == (a[x] % (b[(x - 1 + n) % n] + b[(x + 1) % n]))){
                cout << ans + (b[x] - a[x]) / (b[(x - 1 + n) % n] + b[(x + 1) % n]) << endl;
                return 0;
            }

            else{
                cout << -1 << endl;
                return 0;
            }
        }

        else{
            int y = b[(x - 1 + n) % n] + b[(x + 1) % n];
            //cout << y << endl;
            int c = b[x];
            b[x] %= y;
            if(b[x] < a[x]){
                if((a[x] % y) == (b[x] % y)) b[x] = a[x];
                else{
                    cout << -1 << endl;
                    return 0;
                }
            }

            if(b[x] == c){
                cout << -1 << endl;
                return 0;
            }

            ans += ((c - a[x]) / y);

            if(b[x] > a[x]) q.push({b[x], x});
        }

        //cout << ans << endl;
    }

    cout << ans << endl;

}


Measured memory_bytes: 3700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int[] H = new int[N];
			int max = 0;
			int count = 0;
			for(int i = 0; i < N; i++) {
				H[i] = in.nextInt();
				if(max <= H[i]) {
					count++;
					max = H[i];
				}
			}
			out.println(count);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;	

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

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

		public char nextChar() {
			return next().charAt(0);
		}

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

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
typedef long long ll;
const int N=20000005;
int n,k,x,t,a,b;
string s;
vector<int>v;
int main(){

	cin >>s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes";
	}else{
		cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define M 100

typedef struct edge {
    int w, f, t;
} edge;
edge E[M*M/2];
 
int A[M][M];
int group[M];
int comp(const void*,const void*); 
int kru(int);

int main(int argc,char * argv[])
{
    int i, j, n, s;
    scanf("%d", &n);
     
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            scanf("%d", &A[i][j]);
        }
    }
     
    s=kru(n);
    printf("%d\n", s);
    return 0;
}

int comp(const void *x, const void *y)
{
    return ((edge*)x)->w - ((edge*)y)->w;
}
 
int kru(int n)
{
    int i, j, en, s, from, to;
    for(i=0; i<n; i++) group[i]=i;
    en=0;
    for(i=0; i<n; i++) {
        for(j=0; j<i; j++) {
            if(A[i][j]!=-1) {
                E[en].w=A[i][j];
                E[en].f=i;
                E[en].t=j;
                en++;
            }
        }
    }
    qsort(E, en, sizeof(edge), comp);
     
    s=0;
    for(i=0; i<en; i++) {
        from=group[E[i].f];
        to=group[E[i].t];
        if(from != to) {
            s+=E[i].w;
            for(j=0; j<n; j++) {
                if(group[j]==from) group[j]=to;
            }
            for(j=1; j<n && group[j-1]==group[j]; j++);
            if(j==n) break;
        }
    }
      return s;
}

Measured memory_bytes: 780
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int n;
char res[20];
 
void dfs(int index, int used) {
  if (index == n) {
    print(res);
    return;
  }
  rep(i,used+1) {
    res[index] = 'a'+i;
    dfs(index+1, max(used,i+1));
  }
}

int main() {
    cin>> n;
    res[n] = 0;
    dfs(0, 0);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#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(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){	
	int N,K,x,sum=0;
	cin>>N>>K;

	REP(i,N){
		cin>>x;
		sum+=min(2*x,abs(K-x)*2);
	}
	cout<<sum<<endl;

	
	return 0;
}



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

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    int sum=0;
    vector<int> v;
    while(t--){
        int a,b,k;
        cin>>a>>b>>k;
        int i;
        for(i=1;i<=min(a,b);i++){
            if(a%i==0 && b%i==0) v.pb(i);
        }
        int n=v.size();
        cout<<v[n-k];
    }
}
    

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
struct point {
    int b, e;
    bool operator<(const point &p)const{
        return e-b<p.e-p.b;
    }
}w[5010];
int n;
long long Res, D[5010][5010][2];
int main(){
    int i, j, k;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&w[i].b,&w[i].e);
        w[i].b = -w[i].b;
    }
    sort(w+1,w+n+1);
    Res = 1e18;
    for(i=0;i<=n;i++)for(j=0;i+j<=n;j++)for(k=0;k<2;k++)D[i][j][k]=1e18;
    D[0][0][0] = 0;
    for(i=0;i<n;i++){
        for(j=0;j+i<n;j++){
            int x = n-i-j;
            D[i][j][1] = min(D[i][j][1], D[i][j][0] + 1ll*(n/2)*(w[x].e-w[x].b));
            for(k=0;k<2;k++){
                int x = n-i-j-k;
                D[i+1][j][k] = min(D[i+1][j][k], D[i][j][k] + w[x].e + 1ll*(w[x].e-w[x].b)*i);
                D[i][j+1][k] = min(D[i][j+1][k], D[i][j][k] + -w[x].b + 1ll*(w[x].e-w[x].b)*j);
            }
        }
    }
    if(n%2==0){
        for(i=0;i<=n;i++)Res = min(Res, D[i][n-i][0]);
        printf("%lld\n",Res);
    }
    else{
        printf("%lld\n",D[n/2][n/2][1]);
    }
}

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

int main(){
  string s;
  cin >> s;
  
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2] ) 
    cout << "Yes" << endl;
  else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1] ) 
    cout << "Yes" << endl;
  else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1] ) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag,                    //if using ll change int to ll
        tree_order_statistics_node_update> pbset;
#define fob(x) find_by_order(x)
#define ook(x) order_of_key(x)
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
        cout<<k;
    }
    else if(k<=a+b)
    {
        cout<<a;
    }
    else
    {
        k=k-a-b;
        cout<<a-k;
    }

	return 0;
}


Measured memory_bytes: 3640
K, N = map(int, input().split())
A = list(map(int, input().split()))
max = 0
for i in range(N):
    len = 0
    if i == 0:
        len = int(A[i] + (K - A[N - 1]))
    else:
        len = int(A[i] - A[i - 1])

    if len > max:
        max = len

print(K - max)

Measured memory_bytes: 26444
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>

using namespace std;
int a,b,c,x,y,ans;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(2*c<a+b)
	{
		while(x>=1&&y>=1)
		{
			ans+=c*2;
			x--;
			y--;
		}
		if(x>0)
		{
			if(2*c<a) ans+=x*2*c;
			else ans+=x*a;
		}
		if(y>0)
		{
			if(2*c<b) ans+=y*2*c;
			else ans+=y*b;
		}
	}
	else
	{
		ans=a*x+b*y;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
N=int(input())

W_list=[int(x) for x in input().split()]

#print(W_list)

sa_list=[]

for i in range(1,N):
    list1=W_list[0:i]
    list2=W_list[i:N+1]
    
    wa1=sum(list1)
    wa2=sum(list2)

    #print(wa1)
    #print(wa2)
    
    sa=abs(wa1-wa2)
    
    #print(sa)
    
    sa_list.append(sa)
    
print(min(sa_list))

Measured memory_bytes: 3064
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac


X, Y = map(int, input().split())
# 後の、n, mの大小を一定にするため
if X > Y:
    X, Y = Y, X
dist = X + Y

if dist % 3 != 0:
    print(0)
else:
    # (+1,+2) の移動の回数を n、(+2,+1) の移動の回数を m とする)
    # total = n + m
    # 以下の式は、2n + m = X, n + 2m = Y の連立方程式を解いた結果
    total = int((X+Y) / 3)
    n = X - total

    # n < 0 もしくは m < 0 の場合、たどり着けない
    # Y > X なので、m > n
    # n < 0 → 2X - Y < 0
    if Y > 2*X:
        print(0)
    else:
        MOD = 10**9 + 7

        fac, ifac = make_tables(MOD, total)
        ans = cmb(total, n, MOD, fac, ifac)
        print(ans)

Measured memory_bytes: 82336
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	long long int a, b, x;
	cin >> a >> b >> x;
	long long int ans = b / x - (a - 1) / x;
	if (a == 0 && x != 1)ans++;
	cout << ans;
}


Measured memory_bytes: 256