akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
bool is_sorted(vector<int>& A) {
    for (int i = 0; i < A.size()-1; i++) {
        if (A[i] > A[i+1]) return false;
    }
    return true;
}
int main()
{
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    bool ans = false;
    if (is_sorted(A)) ans = true;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            swap(A[i], A[j]);
            if (is_sorted(A)) ans = true;
            swap(A[i], A[j]);
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string s;
    cin >> s;
    char bbefore = 'A';
    char before = 'A';
    REP(i, s.length()) {
        if(s[i] == before) {
            cout << i << " " << i + 1 << endl;
            return 0;
        } else if(s[i] == bbefore) {
            cout << i - 1 << " " << i + 1 << endl;
            return 0;
        } else {
            bbefore = before;
            before = s[i];
        }
    }
    cout << "-1"
         << " "
         << "-1" << endl;
    return 0;
}

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

typedef pair<int, int> P;
#define ll long long
#define int ll
#define INF (1LL<<30)

signed main(){
	int s, c, result;
	cin >> s >> c;

	// sが多い場合
	if (s >= c/2) result = c/2;
	// sが少ない場合
	else result = s + (c - 2*s) / 4;

	cout << result << endl;		

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
void print(vector<Int> as){
  Int n=as.size();
  for(Int i=0;i<n;i++){
    if(i) cout<<' ';
    cout<<as[i];
  }
  cout<<endl;
}

vector<Int> next(vector<Int> as){
  Int n=as.size();
  vector<Int> ds(n+1,0);
  for(Int i=0;i<n;i++){
    // add 1 to [l, r)
    Int l=max(0LL,i-as[i]);
    Int r=min(n,i+as[i]+1);
    // cout<<l<<' '<<r<<endl;
    ds[l]++;
    ds[r]--;
  }

  vector<Int> cs(ds);
  for(Int i=0;i<n;i++) cs[i+1]+=cs[i];
  // print(cs);
  assert(cs[n]==0);

  cs.pop_back();
  return cs;
}

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

  Int n,k;
  cin>>n>>k;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  for(Int i=0;i<k;i++){
    //print(as);
    as=next(as);
    if(as==vector<Int>(n,n)) break;
  }
  print(as);
  return 0;
}


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

using namespace std;

const int MAXN = 2e5 + 10, MOD = (int) 1e9+7;

void add(long long& a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

void sub(long long& a, long long b) {
  a -= b;
  if (a < 0) a += MOD;
}

long long mul(long long a, long long b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}

long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

long long fac[MAXN], inv[MAXN];

void pre() {
  fac[0] = fac[1] = 1;
  inv[0] = inv[1] = power(1, MOD - 2);
  for (int i = 2; i < MAXN; i++) {
    fac[i] = mul(i, fac[i - 1]);
    inv[i] = power(fac[i], MOD - 2);
  }
}

long long ncr(int n, int r) {
  if (r > n) return 0;
  return mul(fac[n], mul(inv[r], inv[n - r]));
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  pre();
  long long h, w, a, b;
  cin >> h >> w >> a >> b;
  long long ans = 0;
  for (int i = b; i < w; i++) {
    int x = h - a - 1, y = i;
    long long w1 = ncr(x + y, x);
    long long w2 = ncr(a + w - i - 2, a - 1);
    add(ans, mul(w1, w2));
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3328
n = int(input())
a = list(map(int, input().split()))
x = list(sorted(set(a)))
n_sub = n * (n + 1) // 2
Li = 0
Ri = len(x)
while Ri > Li + 1:
    i = (Li + Ri) // 2
    xi = x[i]
    UorD = [1 if ak >= xi else -1 for ak in a]
    cnt_sum = [0] * (2 * n + 1)
    cumsum = 0
    cnt_sum[cumsum + n] = 1
    judge = 0
    s = 0
    for uk in UorD:
        cumsum += uk
        if uk == 1:
            s += cnt_sum[cumsum + n] + 1
        else:
            s -= cnt_sum[cumsum + n + 1] - 1
        cnt_sum[cumsum + n] += 1
        judge += s
        if judge >= n_sub // 2:
            Li = i
            break
    else:
        Ri = i
print(x[Li])


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

int main()
{
  int n[5];//WHxyr
  int a;
  for(int i = 0;i<5;i++)
  {
    cin >> n[i];   
  }
  if(n[2]<n[4] || n[2] > (n[0] - n[4]))cout << "No"<<endl;
  else if(n[3]<n[4] || n[3] > (n[1] - n[4]))cout << "No"<<endl;
  else cout << "Yes"<<endl;
  return 0;
}



Measured memory_bytes: 3120
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define pb  push_back
#define mod  1000000007
#define ps(x, y) fixed<<setprecision(y)<<x
#define w(t) int t; cin>>t;while(t--)
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             1e18


int power (int b , int a) {
	int ans = 1;
	a = a % mod;
	while (b != 0) {
		if (b & 1)
		{ans = (ans * a) % mod;}
		b >>= 1; //b/2
		a = a * a;
		a %= mod;

	}
	return ans;
}

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	map<string, int>m;
	while (n--) {
		string s;
		cin >> s;
		m[s]++;
	}

	cout << "AC x " << m["AC"] << "\n";
	cout << "WA x " << m["WA"] << "\n";
	cout << "TLE x " << m["TLE"] << "\n";
	cout << "RE x " << m["RE"] << "\n";


	return 0;

}



Measured memory_bytes: 3656
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    vector<vector<int>> A(3, vector<int>(3, 0));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    vector<int> B(N, 0);
    for (int k = 0; k < N; ++k) {
        cin >> B[k];
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (B[k] == A[i][j]) {
                    A[i][j] = 0;
                }
            }
        }
    }
    bool T = false;
    for (int i = 0; i < 3; ++i) {
        if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) T = true;
    }
    for (int j = 0; j < 3; ++j) {
        if (A[0][j] == 0 && A[1][j] == 0 && A[2][j] == 0) T = true;
    }
    if ((A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) || (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0)) T = true;
    if (T) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
static_assert(sizeof(long) >= 8, "sizeof(long) >= 8");
int eval(int s, int cl, int cr) {
    // fprintf(stderr, "%d %d %d %d\n", s, cl, cr, abs(s) + max(0, cr - max(0, s)) * 2 + max(0, cl - max(0, -s)) * 2);
    return max(0, cr - max(0, s)) * 2 + max(0, cl - max(0, -s)) * 2;
}
// static_assert(eval(-10, 5, 5) == 20);
// static_assert(eval(10, 5, 5) == 20);
// static_assert(eval(10, 0, 11) == 12);
// static_assert(eval(-10, 11, 0) == 12);
char a[6000], b[6000];
int ll[6000], lr[6000];
pair<int, int> c[2000];
int main() {
    scanf("%s%s", a, b);
    int n = strlen(a);
    if (strcmp(a, b) == 0) {
        puts("0");
        return 0;
    }
    if (!strchr(b, '1')) {
        puts("-1");
        return 0;
    }
    copy_n(a, n, a + n);
    copy_n(a, n, a + 2 * n);
    copy_n(b, n, b + n);
    copy_n(b, n, b + 2 * n);
    for (int i = 1; i < 2 * n; i++)
        ll[i] = b[i] == '1' ? 0 : ll[i - 1] + 1;
    for (int i = 3 * n - 2; i >= n; i--)
        lr[i] = b[i] == '1' ? 0 : lr[i + 1] + 1;
    int ans = 2 * n;
    for (int s = -n; s <= n; s++) {
        int cur = abs(s), m = 0;
        for (int i = n; i < 2 * n; i++)
            if (a[i] != b[i + s]) {
                cur++;
                if (a[i] == '1')
                    c[m++] = make_pair(ll[i], lr[i]);
            }

        if (m) {
            sort(c, c + m);
            int cur1 = eval(s, c[m - 1].first, 0);
            for (int i = m - 1, cr = 0; i >= 0; i--) {
                cr = max(cr, c[i].second);
                cur1 = min(cur1, eval(s, i ? c[i - 1].first : 0, cr));
            }
            cur += cur1;
        }
        ans = min(ans, cur);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int A, B;
    cin >> A >> B;
    
    string ans="Yes";
    if(A%2==0) ans="No";
    if(B%2==0) ans="No";

    cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

const int N = 2e5 + 5;
int n, a[N], f[N], last[N], ans[N], nxt[N];
char s[N];

int main() {
    while (~scanf("%s", s)) {
        int len = strlen(s);
        for (int i = 0; i < 26; ++i) last[i] = len;
        for (int i = 0; i <= len; ++i) f[i] = (1 << 30);
        f[len + 1] = 0;
        for (int i = len - 1; ~i; --i) {
            last[s[i] - 'a'] = i;
            for (int j = 0; j < 26; ++j)
                if (f[last[j] + 1] + 1 < f[i]) {
                    // printf("%d %d\n", i, j);
                    f[i] = f[last[j] + 1] + 1;
                    ans[i] = j, nxt[i] = last[j] + 1;
                }
        }
        for (int i = 0; i < len; i = nxt[i]) putchar(ans[i] + 'a');
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int iIn1,iIn2,iIn3;

int main()
{
        cin>>iIn1>>iIn2>>iIn3;
        if(iIn2-iIn1==iIn3-iIn2)
                cout<<"YES"<<endl;
        else
                cout<<"NO"<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << #x <<": "<<x<<endl
#define debug2(x,y) cerr << #x <<": "<< x <<", "<< #y <<": "<< y << endl
#define answer(x) cout << x <<endl
#define answer_fixed(x, p) cout << fixed << setprecision(p) << x << endl
using namespace std;

int main() {
  string s;
  cin >> s;
  cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;cin>>n;
    string s,t;
    cin>>s>>t;
    for(int i=n;i>0;i--){
        if(s.substr(n-i,n)==t.substr(0,i)){
            cout<<2*n-i<<endl;
            return 0;
        }
    }
    cout<<2*n<<endl;
return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define PI 3.1415926535

int main(void)
{
    int n, m;
    cin >> n >> m;

    //条件指定がない時
    if(m==0){
        if(n==1)
            cout << 0;
        else if(n==2)
            cout << 10;
        else
            cout << 100;
        cout << endl;
        return 0;
    }

    map<int, int> num;

    //valueを−1で初期化
    for (int i = 1; i <= 3; i++)
        num[i] = -1;

    rep(i, m){
        int s, c;
        cin >> s >> c;

        //最上位桁が0の場合は−１出力
        if (s == 1 && c == 0){
            //1桁のとき
            if (n == 1)
                cout << 0 << endl;
            else
                cout << -1 << endl;
            return 0;
        }
        //すでに指定桁の値が決まっていて、その値が違う時
        if (num[s] != -1 && num[s] != c){
            cout << -1 << endl;
            return 0;
        }

        num[s] = c;
    }

    string ans = "";

    for (int i = 1; i <= n; i++){
        //一番左の時
        if (i == 1){
            //条件の指定がないとき
            if (num[i] == -1){
                ans += '1';
                continue;
            }
            ans += to_string(num[i]);
            continue;
        }

        //条件の指定がないとき
        if ((num[i] == -1)){
            ans += '0';
            continue;
        }
        ans += to_string(num[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

int n, m, l[N], r[N], cnt[N];

map < int, int > mp;

void solve() {

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

    rep(i, 1, n) scanf("%d %d", &l[i], &r[i]);

    rep(i, 0, m - 1) mp[i] = i;

    cnt[0] = m;

    int ans = 0;

    rep(i, 1, n) {

        l[i]--; r[i]--;

        auto it = mp.lower_bound(l[i]);

        int pos = -1;

        while(it != mp.end() && it->fir <= r[i] + 1) {

            pos = max(pos, it->sec);

            cnt[it->fir - it->sec]--;

            it = mp.erase(it);

        }

        if(pos >= 0 && r[i] + 1 < m) {

            mp[r[i] + 1] = pos;

            cnt[r[i] + 1 - pos]++;

        }

        while(!cnt[ans] && ans < m) ans++;

        if(ans == m) puts("-1");

        else printf("%d\n", i + ans);

    }

}


int main() {

//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


Measured memory_bytes: 15184
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	n := iScan()
	ans := repeatPow(10, n, lp1) - repeatPow(9, n, lp1)*2 + repeatPow(8, n, lp1)
	ans %= lp1
	if ans < 0 {
		ans += lp1
	}
	fmt.Println(ans)
}
func repeatPow(x, y, d int) int {
	if y == 0 {
		return 1
	} else if y == 1 {
		return x
	} else {
		z := repeatPow(x, y/2, d)
		if y%2 == 0 {
			return z * z % d
		} else {
			return z * z % d * x % d
		}
	}
}


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

if N==1:
    print("a")
    exit()

from collections import deque
from collections import Counter
abc="abcdefghijklmnopqrstuvwxyz"
ans=["a"]

for i in range(1,N):
    d=deque(ans)
    ans=[]
    while d:
        temp=d.popleft()
        temp2=list(temp)
        cnt=Counter(temp2)
        L=len(cnt)
        for j in range(L+1):
            ans.append(temp+abc[j])

for a in ans:
    print(a)







Measured memory_bytes: 13172
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=[0]*n
for i in range(n):
    cnt[i]=b[i]-a[i]
cnt.sort()
p=n-1
for i in range(n):
    while cnt[i]<0:
        if cnt[p]<=1:
            print("No")
            exit()
        elif cnt[p]-abs(cnt[i])*2>=2:
            cnt[p]-=abs(cnt[i])*2
            cnt[i]=0
        elif cnt[p]-abs(cnt[i])*2>=0:
            cnt[p]-abs(cnt[i])*2
            cnt[i]=0
            p-=1
        else:
            x=cnt[p]//2
            cnt[i]+=x
            p-=1
print("Yes")


Measured memory_bytes: 41328
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;
bool checkIsGoodObservatory(
    const vector< vector<int> >& obs_road_vec,
    const vector<long int>& obs_height_vec,
    const int check_obs
) {
    bool is_good = true;

    long int height = obs_height_vec[check_obs];
    //for (int road_to_i : obs_road_vec[check_obs]){
    for (int road_i = 0; road_i < obs_road_vec[check_obs].size(); ++road_i){
        int connected_idx = obs_road_vec[check_obs][road_i];
        if (height <= obs_height_vec[connected_idx]){
            is_good = false;
            break;
        }
    }

    return is_good;
}

int main() {
    int observatory_num;
    int road_num;
    cin >> observatory_num >> road_num;

    vector<long int> obs_height_vec(observatory_num, 0);
    vector< vector<int> > obs_road_vec(observatory_num);

    for(int obs_i = 0; obs_i < observatory_num; ++obs_i) {
        cin >> obs_height_vec[obs_i];
    }
    for (int road_i = 0; road_i < road_num; ++road_i) {
        int obs_i, obs_j;
        cin >> obs_i >> obs_j;
        // 入力indexが1始まりなので配列indexに沿う形に修正
        obs_i--;
        obs_j--;
        obs_road_vec[obs_i].push_back(obs_j);
        obs_road_vec[obs_j].push_back(obs_i);
    }
    
    // 良い展望台線形サーチ
    int cnt = 0;
    for(int obs_i = 0; obs_i < observatory_num; ++obs_i) {
        bool is_good;
        is_good = checkIsGoodObservatory(obs_road_vec, obs_height_vec, obs_i);
        if(is_good) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 8688
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}



signed main()
{
	fio
	inp(n) inp(m) inp(a) inp(b)
	int ans[n][m];
	fo(i,n-b)
	{
		fo(j,a)
			ans[i][j]=0;
		for(int j=a;j<m;j++)
			ans[i][j]=1;
	}
	for(int i=n-b;i<n;i++)
	{
		fo(j,a)
			ans[i][j]=1;
		for(int j=a;j<m;j++)
			ans[i][j]=0;
	}
	fo(i,n)
	{
		fo(j,m)
			cout<<ans[i][j];
		cout<<'\n';
	}
	printclock;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
int cost[11][11];
int grid[205][205];
void floyd()
{
    for(int k=0; k<=9; k++){
        for(int i=0; i<=9; i++){
            for(int j=0; j<=9; j++){
                if(cost[i][j]> (cost[i][k] + cost[k][j])){
                    cost[i][j]= (cost[i][k] + cost[k][j]);
                }
            }
        }
    }
}
int main()
{
    int n,m;
    scanf("%d%d", &n, &m);
    for(int i=0;i<=9; i++){
        for(int j=0; j<=9; j++){
            scanf("%d", &cost[i][j]);
        }
    }
    floyd();
    map<int, int> mp;
    for(int i=1;i<=n; i++){
        for(int j=1; j<=m; j++){
            scanf("%d", &grid[i][j]);
            if(grid[i][j]!=-1 && grid[i][j]!=1);
            mp[grid[i][j]]++;
        }
    }
    ll ans = 0;
    map<int, int> :: iterator it = mp.begin();
    while(it!=mp.end()){
        ans = ans + (cost[it->first][1])*(it->second);
        it++;
    }
    cout<<ans<<endl;
    return 0;
}



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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::cout << (n / 111 + !!(n % 111)) * 111 << '\n';
	return 0;
}


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

#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll lcm(ll a,ll b){

	return (a*b)/(__gcd(a,b));
}


void solve()
{
ll x,k,d;
cin>>x>>k>>d;
if(x<0){
	x=-x;
}
ll r=x/d;

if(r>k){
	cout<<x-(k*d);
	return;
}
x=x-(r*d);
k=k-r;
if(k%2){
	cout<<abs(x-d);
	return ;
}
cout<<x;
}



int   main(){
	solve();
	cout<<endl;


}

Measured memory_bytes: 3632
def inpl(): return [int(i) for i in input().split()]

N, K = inpl()
import numpy as np
H = np.zeros((K,K), dtype = np.int32)
for _ in range(N):
    x, y, c = input().split() 
    x = int(x)
    y = int(y)
    t = c == 'B'
    x %= 2*K
    y %= 2*K
    if x >= K:
        x -= K
        t = not t
    if y >= K:
        y -= K
        t = not t
    if t:
        H[x][y] += 1
        continue
    H[x][y] -= 1

H = H.cumsum(axis=0)
H = H.cumsum(axis=1)

checkH = H[K-1][K-1] + 2*H
for i in range(K):
            checkH[i] -= H[i][K-1]
checkH = checkH.T 
H = H.T
for i in range(K):
            checkH[i] -= H[i][K-1]
Hans = (N - checkH[K-1][K-1])//2 + checkH

print(max(np.amax(Hans), N-np.amin(Hans)))

Measured memory_bytes: 35876
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int main () {
  int N, M = 0, ans;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int A,B;
    cin >> A >> B;
    if (chmax(M,A)) ans = A+B;
  }
  cout << ans << endl;
}
    
    


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

using namespace std;

int main(void){
  
  string name1, name2, name3;
  
  cin >> name1 >> name2 >> name3;
  
  //name0 = name1[0] + name2[0] + name3[0];
  
  cout << name1.at(0) << name2.at(0) << name3.at(0); 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(llong i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(llong i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
llong mod = 1000000007;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};


int main(){
  llong N;cin>>N;
  vector<llong> A(N);
  priority_queue<llong> que;
  llong max,max2;
  REP(i,N){
    cin >> A[i];
    que.push(A[i]);
  }
  int tmp = que.top();
  REP(i,N){
    if(A[i] == que.top()){
      que.pop();
      cout << que.top()<<endl;
      que.push(tmp);
    }else{
      cout <<que.top()<<endl;
    }
  }

}


Measured memory_bytes: 4848
// -*- coding:utf-8-unix -*-

use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a
fn main() {
    input! {
        k: usize,
        a: usize,
        b: usize,
    }
    let mut ans = false;
    if a % k == 0 || b % k == 0 {
        ans = true;
    } else if b - a >= k {
        ans = true;
    } else if a % k > b % k {
        ans = true;
    }

    if ans == true {
        println!("OK");
    } else {
        println!("NG");
    }
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

int main(){
	IOS;
	int q=1,c=1;
	//cin>>q;
	while(q--){
		int f=0,s=0;
		for(int i=0;i<3;i++){
			int x;cin>>x;
			if(x==5) f++;
			if(x==7) s++;
		}			
		if(f==2&&s==1)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int[] ans = new int[N];

        for(int i=1;i<N;i++){
            for(int j=i+1;j<=N;j++){
                int minDistance = N;
                minDistance = Math.min(minDistance,j-i);
                minDistance = Math.min(minDistance,Math.abs(i-X)+Math.abs(j-Y)+1);
                minDistance = Math.min(minDistance,Math.abs(i-Y)+Math.abs(j-X)+1);
               // System.out.println(minDistance);
                ans[minDistance-1]++;
            }
        }

        for(int i=0;i<N-1;i++){
            System.out.println(ans[i]);
        }

    }

}









Measured memory_bytes: 22484
p=1000003
def inv(x):
    return pow(x,p-2,p)
def exponen(a,b):
    return pow(a,b,p)
Fact=[0 for i in range(p)]
Fact[0]=1
for i in range(p-1):
    Fact[i+1]=((i+1)*Fact[i])%p
def fact(k):
    if 0<=k<p:
        return Fact[k]
    else:
        return 0
def solve(x,d,n):
    if x==0:
        return 0
    if d==0:
        return exponen(x,n)
    a=(x*inv(d))%p
    check=(-a)%p
    if 0<=check<=n-1:
        return 0
    return (exponen(d,n)*(fact(n-1+a)*inv(fact(a-1)))%p)%p

Q=int(input())
for i in range(Q):
    xi,di,ni=map(int,input().split())
    print(solve(xi,di,ni))

    


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

const int INF = 1e9;

string s, t;
vector < vector < int > > dp(3001, vector < int > (3001, 0));

void ans(int is, int it)
{
	if(is == 0 || it == 0)
		return;
	
	if(dp[is - 1][it] == dp[is][it])
	{
		ans(is - 1, it);
	}
	else if(dp[is][it - 1] == dp[is][it])
	{
		ans(is, it - 1);
	}
	else
	{
		ans(is - 1, it - 1);
		cout << s[is - 1];
	}
}

int main()
{
	cin >> s;
	cin >> t;
	
	for(int is = 1; is <= s.size(); is++)
	{
		for(int it = 1; it <= t.size(); it++)
		{
			dp[is][it] = max(dp[is][it - 1], dp[is - 1][it]);
				
			if(s[is - 1] == t[it - 1])
			{
				dp[is][it] = dp[is - 1][it - 1] + 1;
			}
		}
	}
	
	ans(s.size(), t.size());
	
	return 0;
}

Measured memory_bytes: 35712
"""
メモ用
ビット全探索
正直な人の証言がすべて一致するかどうかという方針でやればok。
"""

N = int(input())
l = [] # 証言リスト
m = [] # 証言の個数リスト
li = [0] # 成り立った時の正直者の数リスト

# ↓入力
for _ in range(N):
  n = []
  a = int(input())
  m.append(a)

  for _ in range(a):
    b = list(map(int, input().split()))
    n.append(b)
  l.append(n)
# ↑入力
for i in range(2 ** N):
  cnt = 0 # 正直な人の数
  cnt1 = 0 # -1なら成り立たない
  for j in range(N):
    if ((i >> j) & 1):
      cnt += 1 #人jが正直だったときにcnt += 1
      for k in range(m[j]):
        if ((i >> (l[j][k][0]-1)) & 1) == l[j][k][1]:
          pass
        else:
          cnt1 = -1
  if cnt1 == 0:
    li.append(cnt)
print(max(li))

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

int main(){
    int n;
    cin>>n;
    char s[n];
    string a="Three";
    for(int i=0;i<n;i++)
    cin>>s[i];
    for(int i=0;i<n;i++){
        if(s[i]=='Y')
        a="Four";
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 

def main():
    n, m= getList()
    one = 1900 * m + 100 * (n - m)
    print(one * (2 ** m))

 
if __name__ == "__main__":
    main()
   

Measured memory_bytes: 65516
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" " + x);
			} else {
				String value = String.valueOf(x);
				for (int index = value.length(); index > 0; index--) {
					if (x / (int) Math.pow(10, index - 1) % 10 == 3) {
						System.out.print(" " + x);
						break;
					}
				}
			}
		}
		System.out.println();
		sc.close();
	}
}


Measured memory_bytes: 29172
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s : &str = &read::<String>();  // &str型
    let t = &read::<String>();

    let mut count = 0;

    for i in 0..s.len()
    {
        eprintln!("({}): {:x}, {:x}", i, s.as_bytes()[i], t.as_bytes()[i]);

        if s.as_bytes()[i] != t.as_bytes()[i]
        {
            count+=1;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 4288
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> g;
int n;

vector<int> bfs(int s){
	vector<int> dist(n, -1);
	queue<int> que;
	dist[s] = 0;
	que.push(s);

	while(!que.empty()){
		auto v = que.front();
		que.pop();
		for(auto nv : g[v]){
			if(dist[nv] != -1)continue;
			dist[nv] = dist[v] + 1;
			que.push(nv);
		}
	}

	return dist;
}


int main(){
  int x, y;
  cin >> n >> x >> y;
  --x;
  --y;
  g.resize(n);
  for(int i = 0; i < n - 1; ++i){
  	g[i].push_back(i + 1);
  	g[i + 1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);

  map<int, int> dist_map;
  vector<vector<int>> dists(n, vector<int>(n));
  for(int i = 0; i < n - 1; ++i){
  	dists[i] = bfs(i);
  }

  for(int i = 0; i < n - 1; ++i){
  	for(int j = i + 1; j < n; ++j){
  		++dist_map[dists[i][j]];
  	}
  }

  for(int i = 1; i < n; ++i){
  	cout << dist_map[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  if(a==1) a+=13;
  if(b==1) b+=13;
  if(a==b){
    cout << "Draw" << endl;
  }else if(a>b){
    cout << "Alice" << endl;
  }else{
    cout <<  "Bob" << endl;
  }
}



Measured memory_bytes: 256
#include <stdio.h>
 
signed main(){
char a[200001]={};
char b[200001]={};
scanf("%s %s",a,b);
  int i;
  int count=0;
  for(i=0;i<200001;i++){
   if(a[i]!=b[i]){
   	count++;
   }
  }
printf("%d\n",count);
  
  
  
 
return 0;
}

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

int main() {
  int K;
  cin >> K;
  int A,B;
  cin >> A >> B;
  int a,b,c,d;
  a=A/K;
  b=B/K;
  c=A%K;
  d=B%K;

  if(a==b&&c==0){cout << "OK" << endl;}
  else if(a==b){
    cout << "NG" << endl;
  }
  else{cout << "OK" << endl;}
}


Measured memory_bytes: 3624
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int a[200010],b[200010],c[200010],cnt[2][200010] = {};
vector<int> v[200010],u[200010],w[200010],wa,wb;
int main(){
    int i,j,n; cin >> n;
    for(i=0;i<n;i++) cin >> a[i];
    for(i=0;i<n;i++) cin >> b[i];
    for(i=0;i<n;i++) cnt[0][a[i]]++,cnt[1][b[i]]++;
    for(i=1;i<=n;i++){
        if(cnt[0][i] + cnt[1][i]>n){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(i=0;i<n;i++) v[a[i]].push_back(i),u[b[i]].push_back(i);
    for(i=1;i<=n;i++){
        if(cnt[0][i] && cnt[1][i]){
            w[cnt[0][i] + cnt[1][i]].push_back(i);
        }
    }
    for(i=0;i<n;i++){
        if(!cnt[1][a[i]]) wa.push_back(a[i]);
        if(!cnt[0][b[i]]) wb.push_back(b[i]);
    }
    w[0].push_back(0);
    int f = n,s = n;
    //cout << wa.size() << " " << wb.size() << endl;
    for(i=0;i<n;i++){
        while(w[f].size()==0) f--;
        int k,l; bool f0 = false,f1 = false;
        if(f==0) k = wa.back(),wa.pop_back();
        else k = w[f].back(),w[f].pop_back(),f0 = true;
        while(w[s].size()==0) s--;
        if(s==0) l = wb.back(),wb.pop_back();
        else l = w[s].back(),w[s].pop_back(),f1 = true;
        int ind1,ind2;
        if(v[k].size() && u[l].size()){
            ind1 = v[k].back(); v[k].pop_back(); 
            ind2 = u[l].back(); u[l].pop_back();
        }else{
            cout << " a " << endl;
            cout << i << " " << f << " "<< s << endl;
            cout << k << " " << l << endl;
            for(int j:wa) cout << j << " ";
            cout << endl;
            for(int j:wb) cout << j << " ";
            cout << endl;
            exit(1);
        }
        //cout << k << " "<< l << " b " << ind1 << " " << ind2 << endl;
        c[ind1] = b[ind2];
        if(v[k].size() && u[k].size()){
            w[f - 1].push_back(k); 
        }else{
            if(f0) for(j=0;j<v[k].size();j++) wa.push_back(k);
            if(f0) for(j=0;j<u[k].size();j++) wb.push_back(k);
        }
        if(v[l].size() && u[l].size()){
            w[s - 1].push_back(l);
        }else{
            if(f1) for(j=0;j<v[l].size();j++) wa.push_back(l);
            if(f1) for(j=0;j<u[l].size();j++) wb.push_back(l);
        }
    }
    for(i=0;i<n;i++) cout << c[i] << " ";
    cout << endl;
}

Measured memory_bytes: 35648
#include <iostream>
using namespace std;
typedef long long ll;

int n;
ll a, b;
ll h[100004];

bool able(ll k){
    ll bd = b * k;
    ll le = 0;
    for(int i = 0; i < n; i++){
        if(h[i] > bd){
            le += (h[i] - bd - 1) / (a - b) + 1;
        }
    }
    if(le <= k) return true;
    return false;
}

int main()
{
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    ll i = 536870912;
    ll next = 268435456;
    while(next){
        if(able(i)) i -= next;
        else i += next;
        next /= 2;
    }
    if(able(i)) cout << i << endl;
    else cout << i + 1 << endl;
}

Measured memory_bytes: 1024
import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val input = new Scanner(in)

    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val N = input.nextLine().toInt
      val ns = 1.to(N).map(_ => input.nextLine().toInt)
      println(ns.sum - ns.max/2)
    }

  }

}


Measured memory_bytes: 27444
#include<stdio.h>

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

                        printf("NO\n");
                }
        }
        return 0;
}

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

X = []
for i, a in enumerate(A):
    X.append([a, i])

X.sort()

# Biになり得るのはX[m-1] or X[m] (m=N//2)
m = N//2
itoj = {}
for j in range(N):
    x, i = X[j]
    itoj[i] = j
for i in range(N):
    j = itoj[i]
    if j < m:
        print(X[m][0])
    else:
        print(X[m-1][0])

Measured memory_bytes: 123464
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using Graph = vector<VE>;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h, a; cin >> h >> a;
	cout << (h + a - 1) / a << endl;
	return 0;
}

Measured memory_bytes: 256
fun main() {
    val x = nextInt()
    println(1000 * (x / 500) + 5 * (x % 500 / 5))
}

val scanner = java.util.Scanner(System.`in`)
fun next(): String = scanner.next()
fun nextInt() = scanner.nextInt()
fun nextLong() = scanner.nextLong()
fun nextList() = readLine()!!.split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")

fun main(args: Array<String>) = main()

Measured memory_bytes: 31264
N, M, X, Y = map(int, input().split())
xlist = sorted([int(x) for x in input().split()])
ylist = sorted([int(y) for y in input().split()])

flg = 'War'
if X >= Y:
    pass    
else:
    for z in range(X+1, Y+1):
        if xlist[-1] < z and ylist[0] >= z:
            flg = 'No War'

print(flg)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstring>
#include <climits>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long

int dp[3001][3001];

void solve_ite(string a, string b) {
	
	for (int i = 1; i <= a.length(); ++i) {
		for (int j = 1; j <= b.length(); ++j) {
			if (a[i-1] == b[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
}

string lcs(string a, string b, int n, int m) {

	solve_ite(a, b);

	string ans = "";
	int i = a.length(), j = b.length();

	while (i > 0 and j > 0) {

		if (a[i-1] == b[j-1]) {
			ans = a[i-1] + ans;
			i--;
			j--;
		} else if (dp[i-1][j] > dp[i][j-1]) {
			i--;
		} else {
			j--;
		}
	}
	return ans;
}

int main() {

	string a, b;
	cin >> a >> b;

	memset(dp, 0, sizeof(dp));
	cout << lcs(a, b, a.length(), b.length());

	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
using namespace std;

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 long long INF = 1LL << 60;

int main()
{
	long long A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	long long res = INF;

	long long sum = 0;

	for (long long i = 0;i <= 2*max(X,Y);i+=2) {
		int as = X - i / 2;int bs = Y - i / 2;
		if (X - i/2 >= 0 && Y - i/2 >= 0) {
			sum = C * i + A * as + B * bs;
			chmin(res, sum);
		}
		else {
			if (as < 0) {
				as = 0;
			}
			if (bs < 0) {
				bs = 0;
			}
			sum = C * i + A * as + B * bs;
			chmin(res, sum);
		}
	}

	cout << res << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int R = sc.nextInt();
        int I = R;
        if(N < 10){
            I = R + 100 * (10 - N);
        }
        System.out.println(I);
    }

}

Measured memory_bytes: 22996
use whiteread::parse_line;

fn main() {
    let (n, k): (usize, usize) = parse_line().unwrap();
    let s: Vec<u32> = parse_line().unwrap();
    let mut maxsum = 0;
    let mut maxi = 0;
    let mut ans = 0.0;

    for i in 0..n - k + 1 {
        let sum = s[i..i + k].iter().sum();
        if sum > maxsum {
            maxsum = sum;
            maxi = i;
        }
    }
    for i in 0..k {
        ans += (1..=s[maxi + i]).sum::<u32>() as f64 / s[maxi + i] as f64;
    }
    println!("{}", ans);
}


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

int main(int argc, char const* argv[]) {
    string s = "";
    int n;
    cin >> n;
    while (n) {
        if (n % -2 == 0) {
            n /= -2;
            s += "0";
        } else {
            n -= 1;
            n /= -2;
            s += "1";
        }
    }
    if (s.length() == 0) {
        cout << "0" << endl;
    } else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
number_of_people = gets.chomp!.to_i
wating_time = gets.chomp!.split(" ").map(&:to_i)
comparison_array = []

wating_time.max.times do |num|
    wasting_stamina = 0
    wating_time.each do |j|
        wasting_stamina += (j-(num+1))**2
    end
    comparison_array << wasting_stamina
end

p comparison_array.min

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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 100005;

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n >> k;
	int a[n];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int dp[n];
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n && j <= i + k; j++) {
			dp[j] = min(dp[j] , dp[i] + abs(a[i] - a[j]));
		}
	}
	cout << dp[n - 1];
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 1792
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())
    if N % 2 == 0:
        ans = N // 10
        d = 50
        while N // d > 0:
            ans += N // d
            d *= 5
        print(ans)
    else:
        print(0)


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

char c[55][55]; int H, W, cnt;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int lower = max(A, C);
	int upper = min(B, D);
	
	{
		cout << max(0,upper-lower) << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)

int main() {
	int money;
	int value[4] = { 10, 50, 100, 500 };
	int pay[4];
	int ret[4];

	bool flag = true;
	while (cin >> money, money) {
		if (!flag) cout << endl;
		flag = false;
		
		int sum = 0;
		int coin[4];
		
		REP(i, 0, 4) cin >> coin[i];

		int min = 20 * 20 * 20 * 20;
		int minC[4];
		REP(i, 0, 4) minC[i] = 0;
		for (pay[0] = 0; pay[0] <= coin[0]; pay[0]++) {
			for (pay[1] = 0; pay[1] <= coin[1]; pay[1]++) {
				for (pay[2] = 0; pay[2] <= coin[2]; pay[2]++) {
					for (pay[3] = 0; pay[3] <= coin[3]; pay[3]++) {
						REP(i, 0, 4) ret[i] = 0;

						sum = 0;
						REP(i, 0, 4) sum += value[i] * pay[i];
						if (sum < money) continue;

						sum -= money;
						RREP(i, 0, 4) {
							while (sum >= value[i]) {
								sum -= value[i];
								ret[i]++;
							}
						}

						int remain = 0;
						REP(i, 0, 4) remain += coin[i] - pay[i] + ret[i];
						if (remain < min) {
							min = remain;
							REP(i, 0, 4) minC[i] = pay[i];
						}
					}
				}
			}
		}

		REP(i, 0, 4) {
			if (minC[i] > 0) cout << value[i] << " " << minC[i] << endl;
		}

	}
	return 0;
}

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

int main(){
    int n;
    int x[100];
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d",&x[i]);
    }
    long long int power = 1000000000;
    for(int i = 0;i < 100;i++){
        long long int min = 0;
        for(int j = 0;j < n;j++){
            min += (x[j] - i)*(x[j] - i);
        }
        if(power > min) power = min;
    }
    printf("%lld",power);
    return 0;
}


Measured memory_bytes: 128