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

namespace Task {

const int MAXN = 100000;
#define long long long

std::multiset<long> setL, setR;
int a[MAXN + 1], b[MAXN + 1];
long f[MAXN + 1];

inline void solve() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    register int n;
    std::cin >> n;
    for (register int i = 1; i <= n; i++) std::cin >> a[i] >> b[i];
    setL.insert(a[1]), setR.insert(a[1]);
    register long tl = 0, tr = 0, ans = 0, nl, nr;
    for (register int i = 2; i <= n; i++) {
        tl += b[i] - a[i], tr += b[i - 1] - a[i - 1];
        nl = *setL.rbegin(), nr = *setR.begin();
        if (nl - tl > a[i]) {
            ans += std::abs(nl - tl - a[i]), setL.erase(--setL.end());
            setL.insert(setL.insert(a[i] + tl), a[i] + tl);
            setR.insert(nl - tl - tr);
        } else if (a[i] > nr + tr) {
            ans += std::abs(nr + tr - a[i]), setR.erase(setR.begin());
            setR.insert(setR.insert(a[i] - tr), a[i] - tr);
            setL.insert(nr + tr + tl);
        } else {
            setL.insert(a[i] + tl), setR.insert(a[i] - tr);
        }
    }
    std::cout << ans;
}

#undef long
}

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

Measured memory_bytes: 10368
# 122A

# 文字列b：標準入力
# bはA, C, G, T のいずれか
b = input()

# A と T、C と G がそれぞれ対
# bと対になる塩基を表す文字を出力する

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'C':
    print('G')
elif b == 'G':
    print('C')

Measured memory_bytes: 8964
#include <iostream>
#include <string>
#include <algorithm>
int main(void)
{
    std::string str1;
    std::string str2;
    std::cin >> str1 >> str2;
    int l1 = str1.size();
    int l2 = str2.size();
    int A[l1 + 1][l2 + 1] = {};
    for (int i = 0; i <= l1; i++)
    {
        for (int j = 0; j <= l2; j++)
        {
            if (i == 0)
            {
                A[i][j] = j;
            }
            else if (j == 0)
            {
                A[i][j] = i;
            }
            else
            {
                A[i][j] = std::min(A[i - 1][j] + 1, A[i][j - 1] + 1);
                if (str1[i - 1] == str2[j - 1])
                {
                    A[i][j] = std::min(A[i - 1][j - 1], A[i][j]);
                }
                else
                {
                    A[i][j] = std::min(A[i - 1][j - 1] + 1, A[i][j]);
                }
            }
            //std::cout << A[i][j] << " ";
        }
        //std::cout << "\n";
    }
    std::cout << A[l1][l2] << "\n";
    return 0;
}


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

Amax = max(max(A),10)
K = [0] * (Amax+1)

for a in A:
  K[a] += 1

ans = 1

for i in range(Amax - 1):
  ans = max(ans, K[i] + K[i+1] + K[i+2])

print(ans)
    

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

void push(int );
int pop();
int st[100],sp=0;


int main(){
  int x;
  char s[100];
  int num1,num2;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      num1 = pop();
      num2 = pop();
      push(num2+num1);

    } else if ( s[0] == '-' ){
      num1 = pop();
      num2 = pop();
      push(num2-num1);

    } else if ( s[0] == '*' ){
      num1 = pop();
      num2 = pop();
      push(num2*num1);

    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}



void push(int a){
  st[sp++]=a;
}

int pop(){
  return st[--sp];
}

Measured memory_bytes: 548
N=int(input())
L=[list(map(int,input().split())) for _ in range(N-1)]

for i in range(N-1):
    tmp=0
    for j in range(i,N-1):
        c,s,f=L[j]
        if tmp<=s:
            tmp=s+c
        else:
            if (tmp-s)%f==0:
                tmp+=c
            else:
                tmp+=f-(tmp-s)%f+c
    print(tmp)

print(0)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int n,k;
vector<int> v;
int mem[100005];
int dp(int i)
{
	if(i==0)
	return 0;
	if(mem[i]!=-1)
	return mem[i];
	int ans=INT_MAX;
	for(int j=1;j<=k;j++)
	{
		if(i-j>=0)
		ans = min(ans,dp(i-j)+abs(v[i]-v[i-j]));
	}
	mem[i]=ans;
//	cout<<i<<" : "<<ans<<endl;
	return ans;
}
int main()
{
	cin>>n>>k;
	memset(mem,-1,sizeof(mem));
	v.clear();
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
	}
	int ans = dp(n-1);
	cout<<ans;
}

Measured memory_bytes: 7416
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

ab=[list(map(int,input().split())) for i in range(3)]
lst=[0]*4
for i in range(3):
    a,b=ab[i]
    lst[a-1]+=1
    lst[b-1]+=1

for i in range(4):
    if lst[i]==0 or lst[i]==3:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 68772
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
   ll n,a,b;
   cin>>n>>a>>b;
   ll p = a+b;

   ll x = n/p;
   ll ans = x*a;
   ll y = n%p;

   if(y>a)
   {
       ans+=a;
   }
   else
   {
       ans+=y;
   }
   cout<<ans<<endl;
}


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

int main() {
  vector<int> x(5);
  int num = 0;
  cin >> x[1] >> x[2] >> x[3] >> x[4] >> x[5];
  for (int i = 1; i <= x.size(); i++) {
    if (x[i] == 0) {
      num = i;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 3644
a,b,c,x,y=map(int,input().split())

#a,bピザをx,y用意する
#シンプルに用意する場合a*x+b*y
#abピザがa+bより安い場合代替する

ans1 = c*2*(max(x,y))
ans2 = a*x+b*y
ans3 = c*2*y+max((x-y),0)*a
ans4 = c*2*x+max((y-x),0)*b

print(min(ans1,ans2,ans3,ans4))

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

int n; string s;
int val[100005];

void read(int x) {
	cout << x << endl;
	cin >> s;
	if (s == "Vacant")
		exit(0);
	if (s == "Male")
		val[x] = 1;
	else
		val[x] = 2;
}

void proc(int l, int r) {
	int mid = (l+r)/2;
	read(mid);

	if ((mid+l)%2 == (val[l] + val[mid])%2)
		proc(mid, r);
	else
		proc(l, mid);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;

	read(0);
	read(n-1);

	proc(0, n-1);
}

Measured memory_bytes: 980
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

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

int main()
{


    set<string> st;
    int n ; cin>>n;

    rep(i , n){
        string s; cin>>s;
        st.insert(s);
    }

    cout << st.size()<<endl;
    return 0;
}


Measured memory_bytes: 19220
let solve k =
  let q = Queue.create () in
  let rec f i =
    if i < 10 then (
      Queue.push i q;
      f (i + 1)
    )
  in
  f 1;
  let rec f i =
    if i <= k then (
      let x = Queue.pop q in
      let m = x mod 10
      and j = ref i in
      let g y =
        if !j = k then print_int y
        else Queue.push y q;
        j := !j + 1
      in
      if m <> 0 then g (10 * x + m - 1);
      g (10 * x + m);
      if m <> 9 then g (10 * x + m + 1);
      f !j
    )
  in
  f 10

let ans k =
  if k < 10 then print_int k
  else solve k

let () = ans (read_int ())


Measured memory_bytes: 5760
#include<iostream>
#define rep(k,p) for(int i=k;i<p;i++)
using namespace std;int main(){int s[5],g[4];while(1){rep(0,4)g[i]=0;int n=0,v=0;rep(0,5){cin>>s[i];if(!s[i])break;if(!g[s[i]]){n++;g[s[i]]=1;if(v-1==(s[i]%3)||!v)v=s[i];}}if(!*s)break;rep(0,5)cout<<(n==2?(v==s[i]?1:2):3)<<endl;}return 0;}

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

int main() {
	int n,m,a=0;
	cin>>n;
	int t[n];
	for(int i=0;i<n;i++){
		cin>>t[i];
	}
	cin>>m;
	int p[m],x[m],tmp;
	for(int i=0;i<m;i++){
		cin>>p[i]>>x[i];
		tmp=t[p[i]-1];
		t[p[i]-1]=x[i];
		for(int j=0;j<n;j++){
			a=a+t[j];
		}
		cout<<a<<endl;
		a=0;
		t[p[i]-1]=tmp;
	}
	
	// your code goes here
	return 0;
}

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

using namespace std;

using ll = long long;

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

    set<int> c;
    for (int i = 0, a; i < 3; ++i) {
        cin >> a;
        c.insert(a);
    }

    cout << c.size() << endl;

    return 0;
}


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

int main()
{
	int h, w;
	cin >> h >> w;
	vector<vector<char>> v(h + 2, vector<char>(w + 2, '.'));
	for (int i = 1; i <= h; i++) {
		v[i][0] = v[i][w + 1] = '.';
		for (int j = 1; j <= w; j++) {
			cin >> v[i][j];
		}
	}
	for (int i = 0; i <= h + 1; i++) {
		for (int j = 0; j <= w + 1; j++) {
		}
	}
	for (int i = 1; i <= h; i++) {
		string s_i = "";
		for (int j = 1; j <= w; j++) {
			if (v[i][j] == '#') {
				s_i.push_back('#');
			}
			else {
				int count = 0;
				for (int k = i - 1; k <= i + 1; k++) {
					for (int l = j - 1; l <= j + 1; l++) {
						if (v[k][l] == '#') {
							count++;
						}
					}
				}
				char num = '0' + count;
				s_i.push_back(num);
			}
		}
        cout << s_i << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(i=0;i<n;i++)
map<int,int> m;
void initialise() {
	int i,temp;
	for(i=1;i<=999;i++) {
		temp=(i*(i+1))/2;
		m[i]=temp;
	}
}
int main() {
	initialise();
	int a,b,i;
	cin>>a>>b;
	for(i=1;i<999;i++) {
		if(m[i]>=a && m[i+1]>=b && (m[i]-a)==(m[i+1]-b)) break; 
	}
	cout<<m[i]-a<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n = 0; unsigned long long  z = 0; int k = 0; int p = 0;
	unsigned long long dp[21][105] = { 0 };
	cin >> n;
	cin >> k;
		dp[k][0] = 1;
	for (int i = 1; i < n-1; i++) {
		cin >> p;
		for (int j = 0; j < 21; j++) {
			if (j - p >= 0)dp[j][i] += dp[j - p][i - 1];
			if (j + p<= 20)dp[j][i]+= dp[j + p][i - 1];
		}
	}
	cin >> p;
	cout << dp[p][n-2] << endl;

    return 0;
}


Measured memory_bytes: 3120
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    long double a,b,x;cin >> a >> b >> x;
    cout << fixed << setprecision(10) << (b<=2*x/(a*a)?atan((b-x/(a*a))/(a/2))*180/pi:atan(b/((2*x)/(a*b)))*180/pi) << endl;
    return 0;
}

Measured memory_bytes: 3820
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
 
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);	
 
	int n;
	cin>>n;

	ll sum = 0;
	for(int i=1;i<=n;i++) {
		if(i%3 && i%5)
			sum += i;
	}

	cout<<sum;

 
 
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

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

	if (s == "Sunny")
		cout << "Cloudy";
	else if (s == "Cloudy")
		cout << "Rainy";
	else
		cout << "Sunny";

	return 0;
}


Measured memory_bytes: 256
void main()
{
    long n = rdElem;
    long[] a = 5.rdCol;

    long amin = a.reduce!min;
    long m = (n + amin - 1) / amin;

    writeln(m + 4);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
a=int(input())
li = list(map(int,input().split()))
count = 0

while(True):
  for i in li:
    if i % 2 == 1:
      break
  else:
    count += 1
    for index, x in enumerate(li):
      li[index] = x / 2
    continue
  break

print(count)

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

using namespace std;


int main(int argc, char *argv[])
{
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    
    string target, line, op, word;
    int q, operand1, operand2;
    cin >> target;
    cin >> q;
    cin.ignore(1024, '\n');
    while (q--) {
        getline(cin, line);
        istringstream iss(line);
        iss >> op;
        if (op == "replace") {
            iss >> operand1 >> operand2 >> word;
            target.replace(operand1, operand2 - operand1+1, word);
        }
        else if (op == "reverse"){
            iss >> operand1 >> operand2;
            reverse(target.begin()+operand1, target.begin()+operand2+1);
        }
        else {
            iss >> operand1 >> operand2;
            cout << target.substr(operand1, operand2-operand1+1) << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

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

    vector<vector<int>> dp(d+10, vector<int>(n+10, 0));

    for(int i=1; i<d; i++){
        for(int j=0; j<n; j++){
            for(int k=0; k<n; k++){
                if(a[k] <= t[i] && t[i] <= b[k] && a[j] <= t[i-1] && t[i-1] <= b[j]){
                    dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abs(c[k] - c[j]));
                }
            }
        }
    }

    int ans = 0;
    for(int i=0; i<=n; i++){
        ans = max(ans, dp[d][i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3236
// finish date: 2018/07/16
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    string S;
    cin >> S;
    string checker = "";
    rep(i, S.size()) {
        if (S[i] != 'x') checker += S[i];
    }
    string cr = checker;
    reverse(cr.begin(), cr.end());
    if (checker != cr) {
        cout << -1 << endl;
        return 0;
    }
    vi cntX(checker.size() + 1, 0);
    int idx = 0;
    rep(i, S.size()) {
        if (S[i] == 'x') {
            cntX[idx]++;
        } else {
            idx++;
        }
    }
    int ans = 0;
    rep(i, (checker.size() + 1) / 2) {
        ans += abs(cntX[i] - cntX[cntX.size() - 1 - i]);
    }
    cout << ans << endl;

    return 0;
}



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

int main(){
	/*input*/
	int n;	cin >> n;
	/*calculation*/
	int tmp = 0;
	bool flag = false;
	for(; !flag; n++){
		tmp = n;
		int mod = tmp%10;
		for(int i = 0; i < 3; i++){
			if(mod == tmp%10){
				flag = true;
				tmp = (tmp - tmp%10)/10;
			}else{
				flag = false;
				break;
			}
		}
	}
	/*output*/
	cout << --n << endl;;
}


Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
using ll = long long;
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

ll powmod(ll x, ll y, ll m) {
    assert (0 <= x and x < m);
    assert (0 <= y);
    ll z = 1;
    for (ll i = 1; i <= y; i <<= 1) {
        if (y & i) z = z * x % m;
        x = x * x % m;
    }
    return z;
}
ll modinv(ll x, ll p) {
    assert (x % p != 0);
    return powmod(x, p - 2, p);
}
template <int32_t MOD>
int32_t fact(int n) {
    static vector<int32_t> memo(1, 1);
    while (n >= memo.size()) {
        memo.push_back(memo.back() *(int64_t) memo.size() % MOD);
    }
    return memo[n];
}
template <int32_t PRIME>
int32_t inv_fact(int n) {
    static vector<int32_t> memo(1, 1);
    while (n >= memo.size()) {
        memo.push_back(memo.back() *(int64_t) modinv(memo.size(), PRIME) % PRIME);
    }
    return memo[n];
}
template <int MOD>
int choose(int n, int r) {
    assert (0 <= r and r <= n);
    return fact<MOD>(n) *(ll) inv_fact<MOD>(n - r) % MOD *(ll) inv_fact<MOD>(r) % MOD;
}

constexpr int mod = 1e9 + 7;
int solve(int n, int k) {
    if (k == 1) return 1;
    auto dp = vectors(n + 1, n + 1, int());
    dp[0][0] = 1;
    REP3 (i, 1, n + 1) {
        REP (j, i + 1) {
            if (i - 1 >= 0) {
                dp[i][j] += dp[i - 1][j];
            }
            if (j - 1 >= 0) {
                int remaining = (n - i) + (k - 1) * (n - (j - 1));
                dp[i][j] += dp[i][j - 1] *(ll) choose<mod>(remaining - 1, k - 2) % mod;
            }
            if (dp[i][j] >= mod) {
                dp[i][j] -= mod;
            }
        }
    }
    return dp[n][n] *(ll) fact<mod>(n) % mod;
}

int main() {
    int n, k; cin >> n >> k;
    cout << solve(n, k) << endl;
    return 0;
}


Measured memory_bytes: 57956
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll C[600];

int main(){
  ll N;
  cin >> N ;
  rep(i,N){
    ll A;
    cin >> A;
    ll T=0;
    while(A>0){
      if(A%2==1){
        C[T]++;
      }
      A/=2;
      T++;
    }
  }
  ll ans = 0;
  ll T = 1;
  rep(i,61){
    ll  A;
    A =  C[i]*(N-C[i]);
    A %= MOD;
    T %= MOD;
    A *= T;
    ans += A;
    ans %= MOD;
    T*=2;
  }
  cout << ans << endl;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  if(abs(A-B)%2==1){
    cout << "IMPOSSIBLE" << endl;
  }
  else{
    cout << (A+B)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
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
 */
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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int ans = 0;

            if (k <= a) {
                ans = k;
            } else if (k <= a + b) {
                ans = a;
            } else {
                ans = a - (k - a - b);
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 35892
n = int(input())
F = [list(map(int,input().split())) for _ in range(n)]
P = [list(map(int,input().split())) for _ in range(n)]
ans = -1e100
for i in range(1,2**10):
    A = [0]*10
    profit = 0
    j = 0
    while i > 0:
        A[j] += i&1
        j += 1
        i = i >> 1
    for j in range(n):
        dup = 0
        for a,f in zip(A,F[j]):
            dup += a&f
        profit += P[j][dup]
    ans = max(ans,profit)
print(ans)


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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int times = 0;
    while(b <= a){ b *= 2; times += 1; }
    while(c <= b){ c *= 2; times += 1; }

    if(times <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    System.out.println( Math.abs(x - a) < Math.abs(x - b) ? "A" : "B" );

  }
}


Measured memory_bytes: 21716
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    set<int> st;
    int A,B,C; cin>>A>>B>>C;
    st.insert(A);
    st.insert(B);
    st.insert(C);

    if(st.size()==2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdint.h>
#define ii pair<int,int>
#define mp make_pair
#define int long long int
using namespace std;

int32_t main(){
	int n,m,x,y,c=0;
	cin>>n>>m;
	vector<ii> pri,data;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		data.push_back(mp(x,y));
		pri.push_back(mp(y,i));
	}
	sort(pri.begin(),pri.end(),greater<pair<int,int> >());
	set<int>opendays;
	for(int i=1;i<=m;i++)opendays.insert(i);
	for(int i=0;i<n;i++){
		int index=pri[i].second;
		int last=data[index].first;
		set<int>::iterator itr=opendays.lower_bound(last);
		if(itr!=opendays.end()){
			c+=pri[i].first;
			opendays.erase(itr);
		}
	}
	cout<<c;
}


Measured memory_bytes: 8036
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
   int n;
   cin >> n;
   int a[n];
   int sum1 = 0;
   int sum2 = 0;
   for(int i=0; i<n; i++){
   	cin >> a[i];
   }
   sort(a,a+n);
   reverse(a,a+n);
   for(int i=0; i<n; i++){
   		if(i%2 != 0){
   			sum1+=a[i];
   		}else{
   			sum2+=a[i];
   		}
   }
   cout << abs(sum1 - sum2) << "\n";
   return 0;
}


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

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

    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, n) cout << s.at(i) << t.at(i);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
//#define ll __int64
#define ll long long
#define P pair<ll,ll>
const ll mod=1000000007;
int n,m;
ll x[111111],y[111111];
ll rx[111111],ry[111111];
ll a1,a2;

int main(){
	cin>>n>>m;
	rep(i,n)cin>>x[i];
	rep(i,m)cin>>y[i];
	rep(i,n)rx[i]=(i-(n-1))+i;
	rep(i,m)ry[i]=(i-(m-1))+i;
	rep(i,n)a1=(a1%mod+(rx[i]*x[i])%mod)%mod;
	rep(i,m)a2=(a2%mod+(ry[i]*y[i])%mod)%mod;
	cout<<(a1*a2)%mod<<endl;
}	


Measured memory_bytes: 3328
#include  <iostream>
#include <math.h>
using namespace std;

int main() {
	int  a, b, c;
	double d;
	float f;
	a = 0;
	b = 0;
	c = 0;
	cin >> a;
	cin >> b;

	if (b >= 100) {
		a = a * 1000;
		c = a + b;
	}else if(b>=10){
		a = a * 100;
		c = a + b;
	}
	else {
		a = a * 10;
		c = a + b;
	}

	d = sqrt(c);
	f = d;

	if (d==f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

const int N = 200005;

int main() {
   
   string s;
   int n, k;
   cin >> s;
   n = s.length();

   cin >> k;
   vector <string> v;

   for(int i = 0; i < n; i++) {
      for(int len = 1; len <= k; len++) {
         if(i + len - 1 < n) {
            v.push_back(s.substr(i, len));
         }
      }
   }   
   // sort(v.begin(), v.end());
   set <string> S(v.begin(), v.end());
   vector <string> V(S.begin(), S.end());
   cout << V[k - 1] << endl;
   return 0;
}


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=57;
const ll mod=1e9+7;
ll n,k;
struct mat{
	ll a[N][N];
	mat(){memset(a,0,sizeof(a));}
};

mat operator *(mat a,mat b){
	mat res;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				res.a[i][j]=(res.a[i][j]+(a.a[i][k]*b.a[k][j])%mod)%mod;
			}
		}
	}
	return res;
}

mat powmod(mat a,ll k){
	mat res;
	for(int i=1;i<=n;i++) res.a[i][i]=1;
	while(k){
		if(k&1) res=res*a;
		a=a*a;
		k>>=1;
	}
	return res;
}


int main(){
	n=input(),k=input();
	mat a;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			a.a[i][j]=input();

	a=powmod(a,k);

	ll Ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			Ans=(Ans+a.a[i][j])%mod;

	printf("%lld\n",Ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,saidai=0;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin>>a.at(i);
    }
    int b=0;
    for(int i=0;i<n;i++){
        b=max(b,a[i]);
    }
    int c=0,d=0;
    for(int i=0;i<n;i++){
        if(a[i]==b){
            if(d)
            c=max(c,a[i]);
            else
            d=1;
        }
        else
        c=max(c,a[i]);
    }
    for(int i=0;i<n;i++){
        if(b==a.at(i)){
            cout<<c<<endl;
        }else{
            cout<<b<<endl;
        }
    }
    
}


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

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

Measured memory_bytes: 256
# 素直に全探索したほうが楽
H,W = (int(T) for T in input().split())
minSH = H*W
minSW = H*W
for TH in range(1,H):
    BlockA = TH*W

    if TH<=(H-2):
        BlockB1 = ((H-TH)//2)*W
        BlockC1 = H*W-(BlockA+BlockB1)
        BigSCa1 = max(BlockA,BlockB1,BlockC1)
        SmlSCa1 = min(BlockA,BlockB1,BlockC1)
        DifSCa1 = BigSCa1-SmlSCa1
    else:
        DifSCa1 = H*W

    if W>=2:
        BlockB2 = (H-TH)*(W//2)
        BlockC2 = H*W-(BlockA+BlockB2)
        BigSCa2 = max(BlockA,BlockB2,BlockC2)
        SmlSCa2 = min(BlockA,BlockB2,BlockC2)
        DifSCa2 = BigSCa2-SmlSCa2
    else:
        DifSCa2 = H*W

    if min(DifSCa1,DifSCa2)<minSH:
        minSH = min(DifSCa1,DifSCa2)

for TW in range(1,W):
    BlockA = H*TW

    if TW<=(W-2):
        BlockB1 = H*((W-TW)//2)
        BlockC1 = H*W-(BlockA+BlockB1)
        BigSCa1 = max(BlockA,BlockB1,BlockC1)
        SmlSCa1 = min(BlockA,BlockB1,BlockC1)
        DifSCa1 = BigSCa1-SmlSCa1
    else:
        DifSCa1 = H*W

    if H>=2:
        BlockB2 = (H//2)*(W-TW)
        BlockC2 = H*W-(BlockA+BlockB2)
        BigSCa2 = max(BlockA,BlockB2,BlockC2)
        SmlSCa2 = min(BlockA,BlockB2,BlockC2)
        DifSCa2 = BigSCa2-SmlSCa2
    else:
        DifSCa2 = H*W

    if min(DifSCa1,DifSCa2)<minSW:
        minSW = min(DifSCa1,DifSCa2)

print(min(minSH,minSW))

Measured memory_bytes: 9308
n=gets.to_i
dp=Array.new(n+9){|i|i}
[6,9].each{|k|
  p=1
  while p<=n
    p*=k
    0.upto(n-p){|i|
      dp[i+p]=[dp[i+p],dp[i]+1].min
    }
  end
}
puts dp[n]

Measured memory_bytes: 2556
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [M1;D1] = reads int
    let [M2;D2] = reads int
    if D2 = 1 then
        printfn "1"
    else
        printfn "0"
    0

Measured memory_bytes: 13660
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	
	int ans=0;
	for(int i=1;i<=a[n-1];i++)
	{
		int ind = lower_bound(a,a+n,i) - a;
		if(ind==n/2)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll a[N];

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n, greater<ll>());
    ll ans = 0;
    for (int i = k; i < n; i++) {
        ans += a[i];
    }
    cout << ans << '\n';
    return 0;
}


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

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(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> s(n);
  REP(i, n) cin >> s[i];
  sort(s.begin(), s.end());
  int total = 0;
  REP(i, n) total += s[i];
  if (total % 10 != 0){
    cout << total << endl;
    return 0;
  }
  REP(i, n){
    int now = total - s[i];
    if (now % 10 != 0){
      cout << now << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}



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

int main()
{
    int fg=0,i,j;
     string S;
    cin>>S;
    for(i=0;i<S.size();i++)
    {
        if(S[i]>=65&&S[i]<=91)
            return -1;
       for(j=0;j<S.size();j++)
       {
           if(i!=j&&S[i]==S[j])
           {
               fg=0;
               break;
           }
           else
               fg=1;
       }
       if(fg==0)
        break;
    }
    if(fg==1)
        cout<<"yes"<<endl;
    else
      cout<<"no"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N, K;
    cin >> N >> K;
    vec A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    Rep (i, N-K) {
        if (A[i] < A[i+K]) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}

Measured memory_bytes: 4780
#include<iostream>
using namespace std;
int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int ans = 0;
	for (int i = 0; i <= A; ++i) {
		for (int j = 0; j <= B; ++j) {
			for (int k = 0; k <= C; ++k) {
				if (500 * i + 100 * j + 50 * k == X)
					ans++;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define hell 1000000007
        using namespace std;

        void solve()
        {
         int i,j,k,n,m;
         cin>>m>>n;
         set < int > st;
         for(i=0;i<=200;i++) st.insert(i);
         vector < int > v(n);
         rep(i,0,n)
         {
             cin>>k;
             if(st.count(k))
             st.erase(k);
         }
         int y=100;
         int ans=0;
         for(auto it : st)
         {
             if(abs(it-m)<y)
             {
                 y=abs(it-m);
                 ans=it;
             }
         }
         cout<<ans;
    }

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


Measured memory_bytes: 3684
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int M, D;
	cin >> M >> D;
	int ans = 0;
	for (int i = 1; i <= M; i++) {
		for (int j = 1; j <= D; j++) {
			int a = j / 10, b = j % 10;
			if (a >= 2 && b >= 2 && a*b == i) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  vector<pair<int,int>> b(n);
  rep(i,n)
    cin >> a[i].second >> a[i].first;
  sort(all(a));
  reverse(all(a));
  rep(i,n)
    cin >> b[i].first >> b[i].second;
  sort(all(b));
  
  int c=0;
  rep(i,n){
    rep(j,n){
      if((b[i].first>a[j].second)&&(b[i].second>a[j].first)){
        a[j]=make_pair(300,300);
        c++;
        break;
      }
    }
  }
  
  cout << c << endl;
}
      
    


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

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

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}
struct data{
  ll id,ac,pn;
  vector<ll> wa;
  bool operator<(const data& d){
    if(ac == d.ac && pn == d.pn){
      return id < d.id;
    }
    if(ac == d.ac){
      return pn < d.pn;
    }
    return ac > d.ac;
  }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll t,r,p;
  while(cin >> t >> p >> r && t+r+p ){
    vector<data> vd(t);
    rep(i,t){
      vd[i].id = i+1;
      vd[i].wa.resize(p);
    }
    ll ti,pi,time;
    string mes;
    rep(i,r){
      cin >> ti >> pi >> time >> mes;
      --ti,--pi;
      if(mes == "WRONG"){
        vd[ti].wa[pi]++;
      }
      else{
        vd[ti].ac++;
        vd[ti].pn += vd[ti].wa[pi] * 1200 + time;
      }
    }
    sort(all(vd));
    rep(i,t){
      cout << vd[i].id << ' ' << vd[i].ac << ' ' << vd[i].pn << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3148
use std::io::Read;

fn main() {
    let n: usize = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().parse().unwrap()
    };
    let a: Vec<f64> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.split_whitespace().map(|a|a.parse().unwrap()).collect()
    };
    let result: f64 = 1_f64 / a.iter().fold(0.0_f64, |sum, &cur| sum + 1.0_f64 / cur);
    println!("{}", result)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MAX = 1e9;
ll x1,x2,x3,y4,y2,y3;
ll s;
int main()
{
	cin >> s;
	x2=y2=0;
	x1=y3=sqrt(s);
	while(s>x1*y3)
	{
		if(x1<y3)	x1++;
		else y3++;
	}
	ll m = x1*y3-s;
	for(int i=1;i<=sqrt(m);i++)
	{
		if(m%i==0)
		{
			if(i<=MAX&&m/i<=MAX)
			{
				y4=i;
				x3=m/i;
				break;
			}
		}
	}
	cout << x1<<" "<<y4<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 3672
from bisect import bisect_left

N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = sum(abs(a) for a in A)
if A[0] >= 0:
    ans -= 2 * A[0]
elif A[-1] < 0:
    ans += 2 * A[-1]
print(ans)
nonneg_idx = bisect_left(A, 0)
if nonneg_idx == 0:
    nonneg_idx = 1
elif nonneg_idx == N:
    nonneg_idx = N - 1
acc = A[nonneg_idx - 1]
for a in A[nonneg_idx + 1 :]:
    print(acc, a)
    acc -= a
print(A[nonneg_idx], acc)
acc = A[nonneg_idx] - acc
for a in A[: nonneg_idx - 1]:
    print(acc, a)
    acc -= a


Measured memory_bytes: 20748
from collections import defaultdict as dd
def solve():
  h, w, m = map(int, input().split())
  
  targets = set()
  rows = dd(int)
  cols = dd(int)
  for _ in range(m):
    r, c = map(int, input().split())
    rows[r] += 1
    cols[c] += 1
    targets.add((r, c))
    
  best_rows = []
  best_cols = []
  best_row = max(rows.values())
  best_col = max(cols.values())
  best = best_row + best_col - 1
  for k, v in rows.items():
    if v == best_row:
      best_rows.append(k)
  for k, v in cols.items():
    if v == best_col:
      best_cols.append(k)
  
  for row in best_rows:
    for col in best_cols:
      if (row, col) not in targets:
        print (best + 1)
        return
  print (best)
solve()


Measured memory_bytes: 238776