akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (int i = 0; i < a; i++) { cin >> p[i]; }
    for (int i = 0; i < b; i++) { cin >> q[i]; }
    for (int i = 0; i < c; i++) { cin >> r[i]; }
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    priority_queue<int, vector<int>, greater<int>> qp, qq;
    priority_queue<int, vector<int>, less<int>> qr;
    for (int i = 0; i < x; i++) { qp.push(p[i]); }
    for (int i = 0; i < y; i++) { qq.push(q[i]); }
    for (int i = 0; i < x + y; i++) {
        if (r.size() == i) break;
        qr.push(r[i]);
    }
    while (!qr.empty() && (qp.top() < qr.top() || qq.top() < qr.top())) {
        if (qp.top() < qq.top()) {
            qp.pop();
            qp.push(qr.top());
            qr.pop();
        } else {
            qq.pop();
            qq.push(qr.top());
            qr.pop();
        }
    }
    long long ans = 0;
    while (!qp.empty()) {
        ans += qp.top();
        qp.pop();
    }
    while (!qq.empty()) {
        ans += qq.top();
        qq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 2936
open System 

type Explicit =          
    static member inline ($) (_:int32, _:Explicit) = int
    static member inline ($) (_:int64, _:Explicit) = int64

let inline convert (value:'a): 'b = 
    (Unchecked.defaultof<'b> $ Unchecked.defaultof<Explicit>) value

let inline fromInt (x: int): 'a = convert x

module NumericLiteralG =
    let inline FromZero(): ^a = LanguagePrimitives.GenericZero
    let inline FromOne(): ^a = LanguagePrimitives.GenericOne
    let inline FromInt32 n = fromInt n

let R() = Console.ReadLine()

let f (s: string): bool =
    let isP s = s = new string(s.ToCharArray() |> Array.rev)
    let f = s.Substring(0, s.Length - 1 / 2)
    let b = s.Substring((s.Length + 3) / 2 - 1)
    let f1 = isP s 
    let f2 = isP f 
    let f3 = isP b 
    f1 && f2 && f3 

let S = R() 

f S 
|> function 
| true -> "Yes"
| _ -> "No"
|> printfn "%s"

Measured memory_bytes: 29604
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include<cstdio>
// #define MOD 1000000007
// #define MOD2 1000000014000000049LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;
const int n = 100000;

class ModFact {
    int inv[100001];
    int fact[100001];
public:
    constexpr ModFact() : fact(), inv() {
        ll f = 1;
        fact[0] = f;
        for (int i = 0; i < n + 1; i++) {
            f = f*(i+1)%MOD;
            fact[i+1] = f;
        }
        f = power(f, MOD-2);
        for (int i = n; i >= 0; i--) {
            inv[i] = fact[i] * f % MOD;
            f = f * (i+1) % MOD;
        }
    }
    inline constexpr ll power(ll a, ll b) {
        ll r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%MOD;
            a = (a*a)%MOD;
            b >>= 1;
        }
        return r;
    }
	int operator[](int n) {
		return inv[n];
	}

	int getfact(int n) {
		return fact[n];
	}
    
} fact;

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
    ll ans = 0, d;
    int a, N, prev, now;
    N = getint();
    prev = getint();
    REP(i, N-1) {
        now = getint();
        d = now - prev;
        prev = now;
        a = (a + fact[i]) % MOD;
        ans += a * d % MOD;
    }
    printf("%lld\n", ((ans%MOD)*fact.getfact(N-1))%MOD);
	return 0;
}


Measured memory_bytes: 256
import sys,math,collections,itertools
input = sys.stdin.readline

K=int(input())
A=list(map(int,input().split()))

min_child = 2
max_child = 2

for i in range(K-1,-1,-1):
    if math.ceil(min_child/A[i])>0 and math.floor(max_child/A[i])>0 and math.floor(max_child/A[i])-math.ceil(min_child/A[i])>=0:
        min_child = math.ceil(min_child/A[i])*A[i]
        max_child =math.floor(max_child/A[i])*A[i]+A[i]-1
    else:
        print(-1)
        exit()
print(min_child,max_child)


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

int main(){
    int n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    ll ans = 0;
    while(true){
        ll sum = 0;
        ll b[n];
        for(int i = 0; i < n; i++){
            sum += a[i]/n;
            b[i] = a[i]/n;
            a[i] %= n;
        }
        if(sum == 0)    break;
        for(int i = 0; i < n; i++){
            a[i] += sum-b[i];
        }
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = (int)1e5 +10;
 
int arr[maxn];
int brr[maxn];
 
int main()
{
    int n;
    cin>>n;
    ll ans = 0;
    for(int i = 0; i <= n; i++)
    {
        cin>>arr[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin>>brr[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(brr[i]>arr[i])
        {
            ans+=arr[i];
            brr[i]-=arr[i];
            if(brr[i]>=arr[i+1])
            {
                ans += arr[i+1];
                arr[i+1] = 0;
            }
            else
            {
                ans += brr[i];
                arr[i+1] -= brr[i];
            }
        }
        else
        {
            ans += brr[i];
        }
    }
    cout<<ans<<endl;
 
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n, m;
  cin >> n >> m;
  for (ll z = 0; z <= m / 1000 && z <= n; ++z) {
    for (ll y = 0; y <= m / 5000 && y <= n; ++y) {
      ll x = n - (y + z);
      if (x < 0) continue;
      if (m == 1000*z + 5000*y + 10000*x) {
        cout << x << " " << y << " " << z <<endl;
        return 0;
      }
    }
  }
  cout << -1 << " " <<  -1 << " " <<  -1 << endl;
  return 0;
}

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

bool check_triangle(int a, int b, int c);

int main()
{
	int n;
	int a,b,c;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> a >> b >> c;
		if (check_triangle(a,b,c))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}

	return 0;
}

bool check_triangle(int a, int b, int c)
{
	
	vector<int> edges;
	edges.push_back(a);
	edges.push_back(b);
	edges.push_back(c);
	sort(edges.begin(),edges.end());

	if (edges[0]*edges[0] + edges[1]*edges[1] == edges[2]*edges[2])
		return true;
	else
		return false;		
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define MAX 1001
void solve(void);
int q,count[MAX][MAX]={},xlength,ylength;
char X[MAX],Y[MAX];
 
void solve(void){
  int i,j;
 
  xlength=strlen(X);
  ylength=strlen(Y);
   
  for(i=1;i<=xlength;i++){
    for(j=1;j<=ylength;j++){
      if(X[i-1]==Y[j-1]) count[i][j]=count[i-1][j-1]+1;
      else if(count[i-1][j]>=count[i][j-1]) count[i][j]=count[i-1][j];
      else count[i][j]=count[i][j-1];
    }
  }
}
     
int main()
{
  int i;
   
  scanf("%d",&q);
 
  for(i=1;i<=q;i++){
    scanf("%s",X);
    scanf("%s",Y);
    solve();
    printf("%d\n",count[xlength][ylength]);
  }
 
  /*for(i=0;i<q;i++){
    printf("%d\n",count[][]);
    }*/
 
  return 0;
}

Measured memory_bytes: 6644
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){

    vector<int> arr(3);
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr.begin(),arr.end(),greater<int>()  );

    cout << arr[0] * 10 + arr[1] + arr[2] << endl;


    return 0;
}

Measured memory_bytes: 256
def solve(x,n,p):
    if x not in p:
        return x
    tmps = x-1
    tmpl = x+1
    while True:
        if tmps not in p:
            return tmps
        if tmpl not in p:
            return tmpl
        tmps -= 1
        tmpl += 1

    

if __name__ == '__main__':
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    print(solve(x,n,p))

Measured memory_bytes: 61872
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    
    cin >> a >> b;
    if (a > b)
      cout << "a > b" << endl;
    else if (a < b)
      cout << "a < b" << endl;
    else
      cout << "a == b" << endl;
   
    return 0;
}


Measured memory_bytes: 3084
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().decode('utf8').rstrip()
L = len(S)
ans = 0
for left in range(L):
    for right in range(left, L):
        T = S[left:right + 1]
        if set(T) <= set('ACGT'):
            ans = max(ans, right - left + 1)

print(ans)


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

int main(){
    int y,m,d;
    scanf("%d/%d/%d", &y,&m,&d);
    if(y < 2019) cout << "Heisei ";
    else if(m < 5) cout << "Heisei ";
    else cout << "TBD ";    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String args[]){
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int k = scan.nextInt();
    int[] snake = new int[n];
    for(int i=0; i<n; i++) {
    	snake[i]= scan.nextInt();
    }
    for(int i=0; i<n-1; i++) {
    	for(int j = 0; j < n-1-i; j++) {
    		if(snake[n-1-j]>snake[n-2-j]) {
        		int l = snake[n-1-j];
        		snake[n-1-j]=snake[n-2-j];
        		snake[n-2-j]=l;
    		}
    	}
    }
    int max = 0;
    for(int i=0; i<k; i++) {
    	max+=snake[i];
    }
    System.out.println(max);
	}
}

Measured memory_bytes: 27056
# coding: utf-8

while True:
    tate,yoko = (int(x) for x in input().split())
    if tate == 0 and yoko == 0:
        exit()

    for i in range(tate):
        for j in range(yoko):
            if j == 0 or j == yoko - 1 or i == 0 or i == tate - 1:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7012
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    vint l(n); vin(l);
    sort(all(l));
    int ans = 0;
    rep(i, n - 2) {
        repi(j, i + 1, n - 1) {
            ans += lower_bound(all(l), l[i] + l[j]) - l.begin() - (j + 1);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL w;
    cin >> n >> w;
    vector<pair<LL, LL>> wv(n+1);
    for(LL i=1; i<=n; i++){
        cin >> wv[i].first >> wv[i].second;
    }
    vector<vector<LL>> dp(n+1, vector<LL>(w+1,0));
    for(LL i=1; i<=n; i++){
        for(LL j=1; j<=w; j++){
            dp[i][j]=dp[i-1][j];
            if(wv[i].first>j){
                continue;
            }
            //cout << wv[i].first << " " << wv[i].second << endl;
            dp[i][j]=max(dp[i][j], dp[i-1][j-wv[i].first]+wv[i].second);
            //cout << dp[i][j] << " " << dp[i-1][j] << " " << dp[i-1][j-wv[i].first] << " " << wv[i].first << " " << wv[i].second << endl;
        }
    }

    LL ans=0;

    for(LL i=0; i<=w; i++){
        //cout << i << " " << dp[n][i] << endl;
        ans=max(ans, dp[n][i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 83236
#include <stdio.h>

#define MAX 128

int fibonacci(int);
int FI[MAX];

int main(){
        int i, n;
        scanf("%d", &n);

        for(i = 0 ; i < MAX ; i++){
                FI[i] = 0;
        }
        printf("%d\n", fibonacci(n));
        return 0;
}

int fibonacci(int n){
        int i;
        if(n == 0 || n == 1)return FI[n] = 1;   
        if(FI[n] != 0)return FI[n];
        return FI[n] = fibonacci(n-2) + fibonacci(n-1);
}



Measured memory_bytes: 2112
#include <iostream>
#include <string>
using namespace std;
int main(){
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
while(cin >>a){
if(a==0){break;}
cin >>b;
cin >>c;
cin >>d;
cin >>e;
cin >>f;
cin >>g;
cin >>h;
cin >>i;
cin >>j;
cout << a-b-c-d-e-f-g-h-i-j<<endl;
}
}

Measured memory_bytes: 1160
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

char a[55][55];
int s[55][5];

int main(void){
	          int i,j;

	          int N,M;
	          cin >> N >> M;
	          for(i=1;i<=N;i++){
	        	  for(j=1;j<=M;j++){
	        		  cin >> a[i][j];
	        		  if(a[i][j]=='W') s[i][0]++;
	        		  if(a[i][j]=='B') s[i][1]++;
	        		  if(a[i][j]=='R') s[i][2]++;
	        	  }
	          }

	          for(i=1;i<=N;i++){
	        	  for(j=0;j<=2;j++){
	        		  s[i][j]+=s[i-1][j];
	        	  }
	          }

	          int ans=1e9;
	          for(i=1;i<=N-2;i++){
	        	  for(j=i+1;j<=N-1;j++){
	        		  int x=N*M-s[i][0]-(s[j][1]-s[i][1])-(s[N][2]-s[j][2]);
	        		 ans=min(ans,x);
	        	  }
	          }

	          cout << ans << endl;

	          return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define float double
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vc = vector<char>; using vvc = vector<vc>;
using vf = vector<float>; using vvf = vector<vf>; using vd = vector<double>; using vvd = vector<vd>;
using str = string; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pff = pair<float, float>; using pdd = pair<double, double>;
using psl = pair<string, ll>; using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7; static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline int ord(char c) {return (int)c;}
static inline char chr(int n) {return (char)n;}
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}
template <typename... Args>
static inline string format(const string& fmt, Args... args) {size_t len = snprintf( nullptr, 0, fmt.c_str(), args...);
vector<char> buf(len + 1); snprintf(&buf[0], len + 1, fmt.c_str(), args...); return string(&buf[0], &buf[0] + len);}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    string S,T; cin>>S>>T;
    int SL = S.size(), TL = T.size();

    string s = S;
    bool match = False;
    for (int i = SL-TL; i>=0; i--) {
        match = True;
        FOR(j, i, i+TL) {
            if (s[j] == '?' or s[j] == T[j-i])
                continue;
            else {
                match = False;
                break;
            }
        }
        if (match) {
            FOR(j, i, i+TL)
                s[j] = T[j-i];
            break;
        }
    }
    //EPR(s);
    if (match) {
        REP(i,SL)
            if (s[i] == '?')
                s[i] = 'a';
    }

    str ans = match ? s : "UNRESTORABLE";
    cout << ans << endl;


    return 0;
}


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

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, n) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	vi nums;
	int now = a.at(0);
	int cnt = 0;
	rep(i, n) {
		if (now == a.at(i)) {
			cnt++;
		}
		else {
			nums.push_back(cnt);
			cnt = 1;
			now = a.at(i);
		}
	}
	if (cnt != 0) {
		nums.push_back(cnt);
	}

	sort(nums.begin(), nums.end());
	int ans = 0;
	rep(i, (int)max(0,(int)nums.size() - k)) {
		ans += nums.at(i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define F first
#define S second
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxp 22
#define EPS (ld)(1e-18)
#define mod (int)(1e9+7)
#define N (int)(1e5+1)


int main (){
fastio;

int i;
for(i=0;i<5;i++){
    int temp;
    cin>>temp;
    if(temp==0){
        cout<<i+1;
        return 0;
    }
}



}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int row = 0;
		int high = 0;
		for(int i = 0; i < M; i++) {
			if(X > sc.nextInt()) {
				row++;
			}else {
				high++;
			}
		}
		System.out.println(Math.min(row, high));
	}
}


Measured memory_bytes: 27020
//
// Created on 2020/08/13.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    int n,m,c;
    cin>>n>>m>>c;
    int ans = 0;
    vector<ll>b(m);
    for (int i = 0; i < m; ++i) {
        cin>>b[i];
    }
    for (int i = 0; i < n; ++i) {
        ll sum = 0;
        for (int j = 0; j < m; ++j) {
            ll a;
            cin>>a;
            sum += a * b[j];
        }
        sum += c;
        if(sum > 0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// cout << fixed << setprecision(10);
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int main(){
    int N; cin >> N;
    long long a;
    map<int,int> mp;
    for (int i = 0; i < N; i++){
        cin >> a;
        if (a % 2 == 0){
            if (a % 4 == 0) mp[4]++;
            else mp[2]++;
        } else {
            mp[1]++;
        }
    }
    if (mp[4] == 0 && mp[1] > 0){
        cout << "No" << endl;
        return 0;
    }
    if (mp[2] == 0){
        if (mp[4] + 1 >= mp[1]){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        } 
    } else {
        mp[1]++;
        if (mp[4] + 1 >= mp[1]){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){	
	string s;
	cin>>s;
	ll a,z;
	for(int i=s.size()-1;i>=0;--i){
		if(s[i]=='Z'){
			z=i;
			break;
		}
	}
	rep(i,s.size()){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	cout<<z-a+1<<endl;
}


Measured memory_bytes: 640
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        long a;
        double b;

        a = scanner.nextLong();
        b = scanner.nextDouble();

        BigDecimal bigA = BigDecimal.valueOf(a);
        BigDecimal bigB = BigDecimal.valueOf(b);

        BigDecimal bigResult = bigA.multiply(bigB);

        BigDecimal roundBigResult = bigResult.setScale(0, BigDecimal.ROUND_DOWN);

        System.out.print(roundBigResult);
    }
}


Measured memory_bytes: 29172
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
void solve(){
    ll n;
    cin>>n;
    ll x[n],y[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        a[i]=x[i]+y[i];
        b[i]=x[i]-y[i];
    }
    ll ans1=INT_MIN;
    ll mn=INT_MAX,mx=INT_MIN;
    for(int i=0;i<n;i++){
        mn=min(mn,a[i]);
        mx=max(mx,a[i]);
    }
    ans1=mx-mn;
    mn=INT_MAX,mx=INT_MIN;
    for(int i=0;i<n;i++){
        mn=min(mn,b[i]);
        mx=max(mx,b[i]);
    }
    ll ans2=mx-mn;
    cout<<max(ans1,ans2)<<"\n";
}
int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int64_t>a(n+1); for(auto&&i:a)cin>>i;
	vector<pair<int64_t,int64_t>>b(n+1);
	for(int i=0;i<n;++i)b.at(i).second=a.at(i);
	b.back()={a.back(),a.back()};
	bool yes=true;
	for(auto i=b.rbegin()+1;i!=b.rend();++i){
		i->first=((i-1)->first+1)/2;
		i->second+=(i-1)->second;
		if(i->first>i->second)yes=false;
	}
	int64_t ans=0,j=1;
	for(int i=0;i<=n;++i){
		if(j<b.at(i).first)yes=false;
		ans+=min(j,b.at(i).second);
		if(j<=4e18){
			j-=a.at(i);
			j*=2;
		}
	}
	cout<<(yes?ans:-1)<<"\n"s;
}

Measured memory_bytes: 5556
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

string s;

bool check(int l, int r){
	int rev;
	//cout<<l<<' '<<r<<endl;
	if((r-l+1)%2==0){
		rev = (r-l+1)/2;
	}else{
		rev = (r-l+1)/2+1;
	}
	stack<char> S;
	rep(i,(r-l+1)/2){
		S.push(s[i+l]);
	}
	rev +=l;
	//cout<<rev<<endl;
	for(int i = rev; i<=r; i++){
		char t = S.top();
		S.pop();
		if(s[i] == t)continue;
		return false;
	}
	return true;
}

int main(){
	cin>>s;
	int n = s.size()-1;
	//cout<<n<<endl;
	//cout<<((check((n+3)/2,n))?"Yes":"No")<<endl;
	
	if(check(0,n) && check(0,(n-1)/2) && check((n+3)/2,n)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

constexpr int MAX_TE = 1441, MAX_N = 100;

int main(){
    int ans = -1;
    int n, t, e;

    std::cin >> n >> t >> e;

    int begin = t - e, end = t + e;

    for(int i = 0; i < n; ++i){
        int x;
        std::cin >> x;

        int j = 0;
        if(ans == -1){
            while(true){
                ++j;
                int now_x = x * j;
            
                if(now_x >= begin && now_x <= end){
                    ans = i + 1;
                    break;
                }

                if(now_x > end)
                    break;
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

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

using namespace std;

int N, M, ans, ind[309], ap[309], frq[309], a[309][309];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M), ans = N;
for (int i=1; i<=N; i++)
    for (int j=1; j<=M; j++)
        scanf ("%d", &a[i][j]);
for (int i=1; i<=M; i++)
    ap[i] = 1;
for (int i=1; i<=N; i++)
    ind[i] = 1;
while (1)
{
    for (int i=1; i<=M; i++)
        frq[i] = 0;
    bool stopNow = 0;
    for (int i=1; i<=N; i++)
    {
        while (ap[a[i][ind[i]]] == 0 && ind[i] <= M) ind[i] ++;
        if (ind[i] > M)
        {
            stopNow = 1;
            break;
        }
        frq[a[i][ind[i]]] ++;
    }
    if (stopNow) break;
    int maxi = 0;
    for (int i=1; i<=M; i++)
        if (ap[i] > 0 && frq[i] > maxi)
            maxi = frq[i];
    if (maxi == 0) break;
    if (maxi < ans)
        ans = maxi;
    for (int i=1; i<=M; i++)
        if (ap[i] == 1 && frq[i] == maxi)
            ap[i] = 0;
}
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main()
{
    int N;
    int i;
    scanf("%d", &N);
    char name[N+1][100];
    for(i=1;i<=N;i++) scanf("%s", &name[i][0]);
    long countM = 0, countA = 0, countR = 0, countC = 0, countH = 0;
    for(i=1;i<=N;i++){
        if(name[i][0] == 'M') countM += 1;
        if(name[i][0] == 'A') countA += 1;
        if(name[i][0] == 'R') countR += 1;
        if(name[i][0] == 'C') countC += 1;
        if(name[i][0] == 'H') countH += 1;
    }
    long result = 0;
    result += (countM*countA*(countR+countC+countH));
    result += (countM*countR*(countC+countH));
    result += (countM*countC*countH);
    result += (countA*countR*(countC+countH));
    result += (countA*countC*countH);
    result += (countR*countC*countH);
    printf("%ld", result);
    return 0;
}

Measured memory_bytes: 9984
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.ABC123.D
{
    class Program
    {
        static void Main()
        {
            Solve1();
        }

        static void Solve1()
        {
            var str = Console.ReadLine().Split(' ');
            var X = int.Parse(str[0]);
            var Y = int.Parse(str[1]);
            var Z = int.Parse(str[2]);
            var K = int.Parse(str[3]);
            var A = new long[X];
            var B = new long[Y];
            var C = new long[Z];
            var aa = Console.ReadLine().Split(' ');
            var bb = Console.ReadLine().Split(' ');
            var cc = Console.ReadLine().Split(' ');
            for (var i = 0; i < X; ++i)
            {
                A[i] = long.Parse(aa[i]);
            }
            for (var i = 0; i < Y; ++i)
            {
                B[i] = long.Parse(bb[i]);
            }
            for (var i = 0; i < Z; ++i)
            {
                C[i] = long.Parse(cc[i]);
            }
            var AB = new long[X * Y];
            int count = 0;
            for (var i = 0; i < X; ++i)
            {
                for (var j = 0; j < Y; ++j)
                {
                    AB[count++] = A[i] + B[j];
                }
            }
            Array.Sort(AB);
            Array.Reverse(AB);
            var ABs = AB.Take(K);
            var ABC = new long[ABs.Count() * Z];
            count = 0;
            foreach (var ab in ABs)
            {
                for (var j = 0; j < Z; ++j)
                {
                    ABC[count++] = ab + C[j];
                }
            }
            Array.Sort(ABC);
            Array.Reverse(ABC);
            var ABCs = ABC.Take(K);
            foreach (var res in ABCs)
            {
                Console.WriteLine(res);
            }
        }

        static bool IsMax(long[] A, long[] B, long[] C, int x, int y, int z)
        {
            if (x == 0)
            {
                return false;
            }
            var aa = A[x - 1];
            var bb = y == 0 ? -1 : B[y - 1];
            var cc = z == 0 ? -1 : C[z - 1];
            return aa >= bb && aa >= cc;
        }

        static long Min(long[] nums)
        {
            var min = long.MaxValue;
            foreach (var n in nums)
            {
                min = min < n ? min : n;
            }
            return min;
        }
    }
}



Measured memory_bytes: 44768
INF = 10**18

N, S = map(int, input().split())
A = list(map(int, input().split()))

res = INF

rt = 0
s = 0

for lt in range(N):
    while rt < N and s < S:
        s += A[rt]
        rt += 1
    if s >= S:
        res = min(res, rt - lt)
    s -= A[lt]

print(res if res != INF else 0)


Measured memory_bytes: 16376
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define mp make_pair
#define ll long long
#define pb push_back

void solve()
{

  int d,ti,s;
  cin>>d>>ti>>s;

  if(ti*s >= d)
  {
      cout<<"Yes";
  }
  else
    cout<<"No";

  return;
}

int main()
{

  int t = 1;
  //cin>>t;

  while(t--)
    solve();

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t a, b;
    cin >> a >> b;
    if (a > 0 && b > 0) {
        cout << "Positive" << endl;
    } else if (a <= 0 && b > 0) {
        cout << "Zero" << endl;
    } else {
        int64_t sa = abs(a - b);
        if (sa % 2 == 0) {
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
const int maxn=100010;
typedef long long ll;
int main()
{
    ll s;
    scanf("%lld", &s);
	ll a=0,b=0,c=0,d=0;
    a=d=sqrt(s);
    //cout << a << d << endl;
	while(s>a*d)
    {
		if(a < d) a++;
		else d++;
	}
	ll k=a*d-s;
	for(int i=1;i<=sqrt(k);i++)
    {
		if(!(k%i))
        {
			if(i<=1e9&&k/i<=1e9)
            {
				b=i;
				c=k/i;
				break;
			}
		}
	}
	printf("0 0 %lld %lld %lld %lld\n", a, b, c, d);
    return 0;
}

Measured memory_bytes: 3780
#include<iostream>
#include<cstring>

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

int main(){
	int n;
	char m[5] = {'m','c','x','i'};
	int num[4] = {1000,100,10,1};

	std::cin >> n;

	rep(h,n){
		char str[2][9];
		int ans[2] = {0,0}, answer;

		rep(i,2){
			memset(str[i],'0',8);
			std::cin >> str[i];
			char mjk;
			rep(j,8){
				mjk = str[i][j];
				if(mjk == '\0')break;
				rep(k,4){
					if(mjk == m[0] || mjk == m[1] ||mjk == m[2] ||mjk == m[3]){
						if (j > 0 && mjk == m[k] && str[i][j - 1] - '0' > 1 && str[i][j - 1] - '0' < 10) {
							ans[i] += (str[i][j - 1]-'0') * num[k];
							break;
						}else if(mjk == m[k]){
							ans[i] += num[k];
							break;
						}
					}
				}
			}
		}
		answer = ans[0] + ans[1];
		rep(i,4){
			if(answer / num[i] > 1){
				std::cout << answer/num[i] << m[i] << std::flush;
				answer %= num[i];
			}else if(answer / num[i] == 1){
				std::cout << m[i] << std::flush;
				answer %= num[i];
			}
		}
		std::cout << std::endl;
	}
	return 0;
}

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

int
main(int argc, char**argv) {
    int N;
    int V[50] = {0}, C[50] = {0};

    std::cin >> N;
    for (auto i = 0; i < N; i++) {
       std::cin >> V[i];
    }
    for (auto i = 0; i < N; i++) {
       std::cin >> C[i];
    }

    int X, Y;
    X = Y = 0;
    for (auto i = 0; i < N; i++) {
       if (V[i] > C[i]) {
          X += V[i];
          Y += C[i];
       }
    }
    std::printf("%d\n", X- Y);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int m, d, ans = 0;
    cin >> m >> d;
    for (int i = 1; i <= m; i++) {
        for (int j = 10; j <= d; j++) {
            if (j / 10 >= 2 && j % 10 >= 2 && i == (j / 10) * (j % 10)) ans++;
        }
    }

    cout << ans << endl;


}

/* 
g++ -std=c++14 _main.cpp
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10; 
map<string ,int> m; 
int main()
{
	int n;
	int mx=0;
	vector<string> v;
	cin>>n;
	for(int i=0;i<n;i++)
	{	
		string a;
		cin>>a;
		m[a]++;
		mx=max(mx,m[a]);
	}
	for(map<string ,int>::iterator  it=m.begin();it!=m.end();it++)
	{
		if(it->second==mx)
			v.push_back(it->first);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<endl;
		
		

	return 0;
}

Measured memory_bytes: 26868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

const int MOD = 998244353;

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
	if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += MOD-a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[200005];

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> l(k), r(k);
	rep(i,k) cin >> l[i] >> r[i];
	vector<mint> v(n+1, 0);
	v[1] = 1;
	dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < k; j++) {
			int x = max(i - l[j], 0);
			int y = max(i - r[j] - 1, 0);
			mint z = v[x] - v[y];
			dp[i] += z;
		}
		v[i] = v[i-1] + dp[i];
	}
	cout << dp[n] << endl;
}

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

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	long long n,k;cin>>n>>k;
	long long a[n];for(long i=0;i<n;i++)cin>>a[i];
	long long b=1;
	for(long i=k;i<n;i++){
		if(a[i]>a[i-k])cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
/* S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
__gcd()　lower_bound(a+l,a+r,x)-a でindex
// 配列  -> min/max({}) 
// vector-> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
clock()/CLOCKS_PER_SEC で秒数
vector v.push_back(x),v.pop_back()
q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
<deque>(push/pop)_(front/back)/fornt/back/insert/
priority_queue 宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに*/
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repl(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i,n) for(int (i)=(n)-1;(i)!=-1;(i)--)
#define vep(i,v) for(auto (i)=v.begin();(i)<(v.end());(i)++)
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; }
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
typedef pair<int,int> PI;
typedef std::vector<int> vi;
typedef std::vector<long long> vl;
typedef std::vector<bool> vb;
typedef std::vector<std::vector<bool>> vvb;
using Graph = std::vector<std::vector<int> >;
const long long inf = 10e17;
const long long mod = 1000000007;
//int |x|<=2*10**9     long |x|<= 9*10**18
//printf(".(小数点以下の桁数)lf(double時、float ならf)")
#define ll long long
#define print(i) std::cout << (i) << '\n'
int n;
int main(){
cin>>n;
vl x(n),y(n),p(n);
vi xs,ys,unused;
ll pow3=1ll;
rep(i,n){cin>>x[i]>>y[i]>>p[i];pow3*=3;}

vl res(n+1,inf);
for(ll t=0ll;t<pow3;t++){
    xs.clear();
    ys.clear();
    unused.clear();
    ll i=t;
    rep(j,n){
        switch(i%3){
            case 0:
                unused.emplace_back(j);
                break;
            case 1:
            xs.emplace_back(j);
            break;
            case 2:
            ys.emplace_back(j);
        }
        i/=3;
    }
    ll dist=0ll;
    for(int uin:unused){
        ll ret=min(abs(x[uin]),abs(y[uin]));
        for(int xin:xs){
            ret=min(ret,abs(x[uin]-x[xin]));
        }
        for(int yin:ys){
            ret=min(ret,abs(y[uin]-y[yin]));
        }
    dist+=ret*p[uin];
    }
    res[xs.size()+ys.size()]=min(res[xs.size()+ys.size()],dist);

}
for(auto h:res)print(h);
}

Measured memory_bytes: 3604
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;

	if(n%1000==0)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<ceil(n/(long double)1000)*1000-n<<endl;
	}

}

Measured memory_bytes: 3812
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);

	if (a + b == c || a + c == b || b + c == a) {
		printf("Yes");
	}
	else {
		printf("No");
	}






}

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

int main() {
  int N;
  cin>>N;
  if (N % 1111 == 0) {
    cout << "Yes" << endl;
  }
  else if (N / 10 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  } 
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int N;
	int A[200000];
	int i, j;
	int tmp, max, min;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	max = A[1] - A[0];
	min = A[0];
	for (i = 1; i < N; i++) {
		tmp = A[i] - min;
		max = tmp > max ? tmp : max;
		min = min < A[i] ? min : A[i];
	}

	printf("%d\n", max);

	return 0;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
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);
        CSwitches solver = new CSwitches();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSwitches {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int m = in.nextInt();
            ArrayList<Integer>[] list = new ArrayList[m];
            for (int i = 0; i < m; i++) {
                list[i] = new ArrayList<>();
                int k = in.nextInt();
                for (int j = 0; j < k; j++) {
                    list[i].add(in.nextInt() - 1);
                }
            }

            boolean[] p = new boolean[m];
            for (int i = 0; i < m; i++) {
                p[i] = in.nextInt() == 0;
            }

            // 電灯はn個あるから状態数は2^N
            int cnt = 0;
            for (int i = 0; i < Math.pow(2, n); i++) {
                // 電球がonかどうかのflag
                boolean[] f = new boolean[m];
                System.arraycopy(p, 0, f, 0, m);
                for (int j = 0; j < n; j++) {
                    // j番目のbitが立っていれば
                    if ((i & (int) Math.pow(2, j)) == (int) Math.pow(2, j)) {
                        for (int k = 0; k < list.length; k++) {
                            // リストに入っていれば
                            // 偶数個なので=!でいい
                            if (list[k].contains(j)) f[k] = !f[k];
                        }
                    }
                }

                boolean allon = true;
                for (int j = 0; j < m; j++) {
                    if (!f[j]) {
                        allon = false;
                        break;
                    }
                }
                if (allon) cnt++;

            }

            out.println(cnt);


        }

    }
}



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

signed main(){
	int N,C; cin>>N>>C;
	vector<vector<int>> D(C,vector<int>(C));
	for(int i=0;i<C;i++){
		for(int j=0;j<C;j++){
			cin>>D[i][j];
		}
	}
	vector<vector<int>> col(3,vector<int>(C));
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			int tmp; cin>>tmp; tmp--;
			col[(i+j)%3][tmp]++;
		}
	}
	int ans=10000000000;
	for(int i=0;i<C;i++){
		for(int j=0;j<C;j++){
			for(int k=0;k<C;k++){
				if(i==j or i==k or j==k)continue;
				int t=0;
				vector<int>num(3);
				num[0]=i; num[1]=j; num[2]=k;
				for(int p=0;p<3;p++){
					for(int r=0;r<C;r++){
						t+=D[r][num[p]]*col[p][r];
					}
				}
				ans=min(ans,t);
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=205;
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	if(2*k>n+1)
	{
		printf("-1");
		return 0;
	}
	int l=n/2,r=2*n-1;
	for(int i=3*n-1;i>=2*n;i--)
	{
		printf("%d %d %d\n",l+k,r+k,i+k);
		r-=2;
		if(r<n) r=2*n-2;
		l++;
		if(l==n) l=0;
	}
	return 0;
}

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

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

  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a,a+n,greater<>());
  int alice = 0;
  for (int i = 0; i < (n+1) / 2; i++) {
    alice += a[2*i];
  }
  int bob = 0;
  for (int i = 0; i < n / 2; i++) {
    bob += a[2*i + 1];
  }
  cout << alice - bob << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n; 
  int p[n];
  scanf("%d",&n);
  int x=0;
 
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for (int i=1;i<n-1;i++){
    if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i+1]<p[i]&&p[i]<p[i-1])){
    x=x+1;
     // printf("%d",i);
    }
  }
  printf("%d\n",x);
    
}
    

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,b,c,d,e,f;
  cin>>a>>b>>c;
  d=max(a,max(b,c));
  e=min(a,min(b,c));
  f=a+b+c-d-e;
  cout<<d*10+e+f<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n,m;
  scanf("%d %d",&n, &m);
  int a = n + m;
  if(n==0)n=1;
  if(m==0)m=1;
  printf("%d", n*(n-1)/2+m*(m-1)/2);

  return 0;
}


Measured memory_bytes: 128