akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;

vector<ll> vv;
ll lim=3234566670;

void go(ll n,int l)
{
    vv.pb(n);
    if((n*10)<=lim)
    {
        if(l<9)
        {
            go(n*10+(l+1),l+1);
        }
        go(n*10+l,l);
        if(l)
        {
            go(n*10+(l-1),l-1);
        }
    }
}

int main()
{
    idfc;

    int k;
    cin>>k;
    for(int i=1;i<=9;i++)go(i,i);

    sort(vv.begin(),vv.end());
    cout<<vv[k-1];

    return 0;
}

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

using namespace std;

typedef long long ll;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << endl;
}


Measured memory_bytes: 256
data = [int(s) for s in  input().split()]
l = 0
r = 10000000
flag = 0

for i in range(data[1]):
    gate = [int(s) for s in input().split()]
    
    if l < gate[0]:
        l = gate[0]

    if l > r:
        print(0)
        flag = 1
        break
        

    if r > gate[1]:
        r = gate[1]
    if r < l:
        print(0)
        flag = 1
        break
if flag == 0:
    print(r-l +1)
else:
    pass


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;

deque<LL> d,k;
int main(){
    int N;cin >> N;
    vector<LL> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(ALL(a));
    d.push_front(a[0]);
    bool t[N],c[N];
    memset(t,false,sizeof(t));
    memset(c,false,sizeof(c));
    t[0]=true;
    for(int i=0;i<N;i++){
        if(N-2*i-1>=0&&!t[N-2*i-1]){
            d.push_back(a[N-2*i-1]);
            t[N-2*i-1]=true;
        }
        if(N-2*i-2>=0&&!t[N-2*i-2]){
            d.push_front(a[N-2*i-2]);
            t[N-2*i-2]=true;
        }
        if(2*i+1<N&&!t[2*i+1]){
            d.push_back(a[2*i+1]);
            t[2*i+1]=true;
        }
        if(2*i+2<N&&!t[2*i+2]){
            d.push_front(a[2*i+2]);
            t[2*i+2]=true;
        }
    }
    k.push_front(a[N-1]);
    c[N-1]=true;
    for(int i=0;i<N;i++){
        if(2*i<N&&!c[2*i]){
            k.push_back(a[2*i]);
            c[2*i]=true;
        }
        if(2*i+1<N&&!c[2*i+1]){
            k.push_front(a[2*i+1]);
            c[2*i+1]=true;
        }
        if(N-2*i-2>=0&&!c[N-2*i-2]){
            k.push_back(a[N-2*i-2]);
            c[N-2*i-2]=true;
        }
        if(N-2*i-3>=0&&!c[N-2*i-3]){
            k.push_front(a[N-2*i-3]);
            c[N-2*i-3]=true;
        }
    }
    LL ans=0;
    LL s=d.front();d.pop_front();
    for(int i=0;i<N-1;i++){
        ans+=abs(s-d.front());
        s=d.front();
        d.pop_front();
    }
    s=k.front();k.pop_front();
    LL sum=0;
    for(int i=0;i<N-1;i++){
        sum+=abs(s-k.front());
        s=k.front();
        k.pop_front();
    }
    cout << max(sum,ans) << endl;
    return 0;
}


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

int main()
{
    vector<int> v(3);
    int ans = 0;

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

    sort(v.begin(),v.end());
    ans += v[1]-v[0];
    ans += v[2]-v[1];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = (c + b - 1) / b;
  int y = (a + d - 1) / d;
  if (x <= y) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3652
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

ans = 0
mn = INF
for a in A:
    if a < mn:
        mn = a
        ans += 1
print(ans)


Measured memory_bytes: 25860
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {
	ll n,t;
	ll a[200001];
	ll total=0;

	cin>>n>>t;

	for(ll i=1; i<n+1; ++i){
		cin>>a[i];
	}
	for(ll i=1; i<n+1; ++i){
		if(i==n){
			break;
		}
		if(a[i+1]-a[i]<t){
			total+=a[i+1]-a[i];
		}else{
			total+=t;
		}
	}
	cout<<total+t<<endl;

	return 0;
}


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

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N, C, K;
    cin >> N >> C >> K;

    vector<int> T(N);
    for (int i = 0; i < N; i++) cin >> T[i];
    sort(T.begin(), T.end());

    int ans = 0;
    int time = -1;
    int bus = 0;

    for (int i = 0; i < N; i++) {
        if (time == -1) {
            time = T[i];
            bus = 1;
            ans++;
            continue;
        }
        if (time + K < T[i] || bus == C) {
            time = T[i];
            bus = 1;
            ans++;
            continue;
        }
        bus++;
    }

    cout << ans << endl;

}













































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

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

        int countW,countE;
        countW=countE=0;
        for(auto &&c:s){
                if(c=='W')countW++;
                if(c=='E')countE++;
        }
        int ans = n;
        int lw = 0;
        int le = 0;
        int cw = 0;
        int ce = 0;
        int rw = countW;
        int re = countE;

        for(int i=0;i<n;i++){
                lw+=cw;
                le+=ce;
                cw=0;
                ce=0;
                if(s[i]=='W') {
                        cw++;
                        rw--;
                }else{
                        ce++;
                        re--;
                }
                ans = min(ans,lw+re);
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 900
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    NO_TLE
    LL n,m;
    cin>>n>>m;
    if(n==1&&m==1)cout<<1<<endl;
    else if(n==1&&m!=1)cout<<m-2<<endl;
    else if(n!=1&&m==1)cout<<n-2<<endl;
    else if(n>=2&&m>=2)cout<<(n-2)*(m-2)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	  	String str = sc.next();
	  	int count = 0;
	  	for(int i = 0 ; i<str.length()-1 ; i++){
	    	if(str.charAt(i)!=str.charAt(i+1))
	          count++;
	    }
	  	System.out.println(count);
	}
}

Measured memory_bytes: 25044
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;
#define lol long long


int main()
{
	int N, K;
	string S;
	cin >> N >> K >> S;
	vector<int> R(N+1);
	vector<int> Rui(N + 1);
	int ichi = (N + 2) / 2;
	int t = 0;
	if (S[0] == '0') {
		t = 1;
		R[1]++;
	}
	else {
		R[0]++;
	}
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == S[i + 1]) {
			R[t]++;
		}
		else {
			t++;
			R[t]++;
		}
	}
	Rui[0] = R[0];
	for (int i = 1; i < N + 1; i++) {
		Rui[i] = Rui[i - 1] + R[i];

	}
	int ans = Rui[K * 2];
	for (int i = 1; i < ichi - K; i++) {
		ans = max(ans, Rui[i * 2 + K * 2] - Rui[i * 2 - 1]);
	}
	if (N == 1) {
		cout << 1 << endl;
	}
	else if (N + 1 < K * 2) {
		cout << N << endl;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef struct {
  int first;
  ll second;
  ll third;
}T;
int A,B,Q;

int binary_search(int key,vector<ll> l){
  int left = 0, right = l.size()-1, mid;
  while( l[right-1] > key){
    mid = (left +  right)/2;
    if(l[mid] > key) right = mid;
    else left = mid;
  }
  return right;
}

bool pairCompfirst(T& l, T& r){
  return l.first < r.first;
}

bool pairCompsecond(T& l, T& r){
  return l.second < r.second;
}

int main(void){
  cin >> A >> B >> Q;
  vector<ll> s(A+2),t(B+2);
  vector<T> x(Q);
  int i;
  for(i=1;i<=A;i++) cin >> s[i];
  for(i=1;i<=B;i++) cin >> t[i];
  s[0] = -1e18;
  t[0] = -1e18;
  s[A+1] = 1e18;
  t[B+1] = 1e18;
  int s_index,t_index;
  ll x_,d,j,k,ds,dt;
  ll s_1,s_2,t_1,t_2;
  for(i=0;i<Q;i++){
    x[i].first = i;
    cin >> x[i].second;
  }
  s_index = 0;
  t_index = 0;
  sort(x.begin(),x.end(),pairCompsecond);
  for(i=0;i<Q;i++){
    x_ = x[i].second;
    x[i].third = 1e18;
    for(;x_ > s[s_index];s_index++);
    for(;x_ > t[t_index];t_index++);
    for(j = -1; j<=0 ;j++){
      for(k=-1; k<=0 ;k++){
        ds = abs(x_-s[s_index+j]);
        dt = abs(x_-t[t_index+k]);
        d = abs(s[s_index+j]-t[t_index+k]) + ds + dt - max(ds,dt);
        x[i].third = min(x[i].third,d);
      }
    }
  }
  sort(x.begin(),x.end(),pairCompfirst);
  for(i=0;i<Q;i++) cout << x[i].third << endl;
  return 0;
}

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

struct UnionFind {
private :
    vector<int> data; int sz;
public :
    UnionFind(int sz) : data(sz, -1), sz(sz) { }

    bool unite(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        sz--;
        return true;
    }

    bool is_same(int x, int y) { return root(x) == root(y); }

    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

    size_t size(int x) { return (size_t)-data[root(x)]; }

    size_t size() { return (size_t)sz; }

};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> ans(n, -1);
    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        uf.unite(--s, --t);
        ans[s]--;
        ans[t]--;
    }
    for (int i = 0; i < k; i++) {
        int s, t;
        cin >> s >> t;
        if (uf.is_same(--s, --t)) {
            ans[s]--;
            ans[t]--;
        }
    }
    
    for (int i = 0; i < n; i++) ans[i] += (int)uf.size(i);
    for (auto a : ans) cout << a << endl;
    return 0;
}

Measured memory_bytes: 1664
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var s = strShift();
  var t = strShift();
  
  s = s.split(NOSP).sort().join(NOSP);
  t = t.split(NOSP).sort().reverse().join(NOSP);
  
  if(s==t)return"No";
  return [s,t].sort()[0]==s?"Yes":"No";
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
zzz
zzzz
`);

Measured memory_bytes: 7500
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>

#define for0(i, n)    for (int i = 0  ; i <  (n); ++i)
#define for1n(i, n)   for (int i = 1  ; i <= (n); ++i)
#define for1(i, n)    for (int i = 1  ; i <  (n); ++i)
#define forn(i, n)    for (int i = 0  ; i <= (n); ++i)
#define forx(i, n, x) for (int i = (x); i <  (n); ++i)

using namespace std;

typedef long long ll;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll> ,greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;


int main(void){

    ll N;
    
    cin >> N;

    cout << N * (N - 1) / 2;
    
    
    // if (N % 2 == 1){
    //     cout << N * (N / 2);
    // } else {
    //     ll k = 0;
    
    //     for1n(i, N){
    //         k += i % (N - i + 1);
    //     }
    //     cout << k;
    // }

    return 0;
}


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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(X) (X).begin(), (X).end()
#define sz(X) (int)X.size()

using ll = long long;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

class DSU
{
private:
    vector<int> p, rk, sz;
    int num_disjoint_sets;
public:
    DSU(int n) : num_disjoint_sets(n)
    {
        rk.assign(n, 0), p.assign(n, 0), sz.assign(n, 1);
        for (int i = 0; i < n; ++i) p[i] = i;
    }
    int find_set(int i)
    {
        while (p[i] != i) i = p[i];
        return i;
    }
    int set_size(int i) { return sz[find_set(i)]; }
    int num_sets() { return num_disjoint_sets; }
    void union_set(int i, int j)
    {
        int x = find_set(i), y = find_set(j);
        if (rk[x] < rk[y]) swap(x, y);
        if (x != y)
        {
            --num_disjoint_sets;
            p[y] = x;
            rk[x] += (rk[x] == rk[y]);
            sz[x] += sz[y];
        }
    }
};

int main()
{ _
    int n; cin >> n;
    vector x(n, 0), y(n, 0);
    for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];

    vector I(n, 0); iota(all(I), 0);
    sort(all(I), [&x](int i, int j){ return x[i] > x[j]; });

    set<pair<int, int>> S;

    DSU dsu(n);

    for (auto i : I)
    {
        auto iter = S.upper_bound(pair(y[i], 0));
        while (iter != S.end())
        {
            int j = iter->second;
            dsu.union_set(i, j);
            ++iter;
            if (iter != S.end()) S.erase(prev(iter));
        }
        S.insert(pair(y[i], i));
    }

    for (int i = 0; i < n; ++i)
        cout << dsu.set_size(i) << endl;

    exit(0);
}



Measured memory_bytes: 12568
function Main(input) {
	input =  input.split("\n");
	var turn = ['Sunny','Cloudy','Rainy'];
	var nextnum = 0;

  	for (var i = 0; i < turn.length; i++){
		if (input[0] === turn[i]) {
			nextnum = i + 1;
			if (nextnum === turn.length) {
				nextnum = 0;
			}
			break;
		}
	}
	
	console.log(turn[nextnum]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dist[333][333];
bool f[333][333];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)scanf("%lld", &dist[i][j]);
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < num; j++)
		{
			for (int k = 0; k < num; k++)
			{
				if (dist[j][i] + dist[i][k] < dist[j][k])
				{
					printf("-1\n");
					return 0;
				}
				if (dist[j][i] + dist[i][k] == dist[j][k] && j != i&&i != k)f[j][k] = true;
			}
		}
	}
	ll sum = 0;
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)if (!f[i][j])sum += dist[i][j];
	printf("%lld\n", sum / 2);
}

Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,X,A;
	while(cin>>N>>M>>X) {
		VI m(N+1);
		REP(i, M) {
			cin>>A;
			m[A]=1;
		}
//		DD(m);
		ll a=0,b=0;
		RANGE(i, X, N+1) a+=m[i];
		RANGER(i, 0, X) b+=m[i];
		cout<<min(a, b)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
def sp(a,b,c,xq,yq):
    xr = xq - 2*a*(a*xq+b*yq+c)/(a**2+b**2)
    yr = yq - 2*b*(a*xq+b*yq+c)/(a**2+b**2)
    print xr,yr

while True:
    try:
        x1,y1,x2,y2,xq,yq = map(float, raw_input().split(","))
        sp(y2-y1,-(x2-x1),x2*y1-x1*y2,xq,yq)
    except:
        break    

Measured memory_bytes: 4256
#include <stdio.h>

int main(){
int toki[3],tokide[3],fun[3],funde[3],byou[3],byoude[3];
int i,f,t;
int kekkat[3],kekkaf[3],kekkab[3];

for(i=0;i<3;i++){
scanf("%d %d %d %d %d %d",&toki[i],&fun[i],&byou[i],&tokide[i],&funde[i],&byoude[i]);
}
for(i=0;i<3;i++){
f=0;
t=0;
kekkab[i]=byoude[i]-byou[i];
if(kekkab[i]<0){
kekkab[i]=60+kekkab[i];
f++;
}
kekkaf[i]=funde[i]-fun[i]-f;
if(kekkaf[i]<0){
kekkaf[i]=60+kekkaf[i];
t++;
}
kekkat[i]=tokide[i]-toki[i]-t;

printf("%d %d %d\n",kekkat[i],kekkaf[i],kekkab[i]);

}
return 0;
}

Measured memory_bytes: 600
import heapq
N=int(input())
alist=list(map(int,input().split()))

sum1=0
hq1=[]
for i in range(N):
  sum1+=alist[i]
  heapq.heappush(hq1,alist[i])
sum1_list=[sum1]
for i in range(N,2*N):
  heapq.heappush(hq1,alist[i])
  min_s1=heapq.heappop(hq1)  
  sum1+=alist[i]-min_s1
  sum1_list.append(sum1)
#print(sum1_list)  
  
alist_rev=alist[::-1]  
sum2=0
hq2=[]
for i in range(N):
  sum2+=alist_rev[i]
  heapq.heappush(hq2,-alist_rev[i])
sum2_list=[sum2]
for i in range(N,2*N):
  heapq.heappush(hq2,-alist_rev[i])
  max_s2=-heapq.heappop(hq2)
  sum2+=alist_rev[i]-max_s2
  sum2_list.append(sum2)
sum2_list.reverse()
#print(sum2_list)  

answer=-float("inf")
for i in range(N+1):
  answer=max(answer,sum1_list[i]-sum2_list[i])

print(answer)

Measured memory_bytes: 120208
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a + b >= a - b && a + b >= a * b) {
		cout << a + b << endl;
	}
	else if (a - b >= a + b && a - b >= a * b) {
		cout << a - b << endl;
	}
	else {
		cout << a * b << endl;
	}
	return 0;
}

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

class Matatabi
{
public:
  int x1, y1, x2, y2;
  Matatabi(int _x1 = 0, int _y1 = 0, int _x2 = 0, int _y2 = 0)
    :x1(_x1), y1(_y1), x2(_x2), y2(_y2) {}
};

bool isMatatabi(const vector<Matatabi>& m, int x1, int y1, int x2, int y2)
{
  for (unsigned int i = 0; i < m.size(); ++i) {
    if ((m[i].x1 == x1 && m[i].y1 == y1 && m[i].x2 == x2 && m[i].y2 == y2) ||
	(m[i].x1 == x2 && m[i].y1 == y2 && m[i].x2 == x1 && m[i].y2 == y1))
      return true;
  }
  return false;
}

int main()
{
  int T;
  scanf("%d", &T);
  for (int t = 0; t < T; ++t) {
    int gx, gy;
    scanf("%d %d", &gx, &gy);
    int p;
    scanf("%d", &p);
    vector<Matatabi> m;
    for (int i = 0; i < p; ++i) {
      int x1, y1, x2, y2;
      scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
      m.push_back(Matatabi(x1, y1, x2, y2));
    }

    vector<vector<int> > dp(gy+1, vector<int>(gx+1, 0));
    dp[0][0] = 1;
    for (int i = 0; i <= gy; ++i) {
      for (int j = 0; j <= gx; ++j) {
	if (i == 0 && j == 0)
	  continue;
	if (i != 0) {
	  if (!isMatatabi(m, j, i-1, j, i))
	      dp[i][j] += dp[i-1][j];
	}
	if (j != 0) {
	  if (!isMatatabi(m, j-1, i, j, i))
	    dp[i][j] += dp[i][j-1];
	}
      }
    }

    if (dp[gy][gx] == 0)
      printf("Miserable Hokusai!\n");
    else
      printf("%d\n", dp[gy][gx]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main()
{
	int z;
	int s[13]={0},h[13]={0},c[13]={0},d[13]={0};
	char n;
	int di;
	int s_cnt=0,h_cnt=0,c_cnt=0,d_cnt=0;

	cin>>z;
	while(z--){
	cin >> n >> di;
		if (n=='S'){
			s_cnt++;
			if(di==1) s[0]=1;
			else if(di==2) s[1]=2;
			else if(di==3) s[2]=3;
			else if(di==4) s[3]=4;
			else if(di==5) s[4]=5;
			else if(di==6) s[5]=6;
			else if(di==7) s[6]=7;
			else if(di==8) s[7]=8;
			else if(di==9) s[8]=9;
			else if(di==10) s[9]=10;
			else if(di==11) s[10]=11;
			else if(di==12) s[11]=12;
			else if(di==13) s[12]=13;
		}

		if (n=='H'){
			  h_cnt++;
			  if(di==1) h[0]=1;
			else if(di==2) h[1]=2;
			else if(di==3) h[2]=3;
			else if(di==4) h[3]=4;
			else if(di==5) h[4]=5;
			else if(di==6) h[5]=6;
			else if(di==7) h[6]=7;
			else if(di==8) h[7]=8;
			else if(di==9) h[8]=9;
			else if(di==10) h[9]=10;
			else if(di==11) h[10]=11;
			else if(di==12) h[11]=12;
			else if(di==13) h[12]=13;
		}
		if (n=='C'){
			 c_cnt++;
			 if(di==1) c[0]=1;
			else if(di==2) c[1]=2;
			else if(di==3) c[2]=3;
			else if(di==4) c[3]=4;
			else if(di==5) c[4]=5;
			else if(di==6) c[5]=6;
			else if(di==7) c[6]=7;
			else if(di==8) c[7]=8;
			else if(di==9) c[8]=9;
			else if(di==10) c[9]=10;
			else if(di==11) c[10]=11;
			else if(di==12) c[11]=12;
			else if(di==13) c[12]=13;
		}
		if (n=='D'){
			 d_cnt++;
			 if(di==1) d[0]=1;
			else if(di==2) d[1]=2;
			else if(di==3) d[2]=3;
			else if(di==4) d[3]=4;
			else if(di==5) d[4]=5;
			else if(di==6) d[5]=6;
			else if(di==7) d[6]=7;
			else if(di==8) d[7]=8;
			else if(di==9) d[8]=9;
			else if(di==10) d[9]=10;
			else if(di==11) d[10]=11;
			else if(di==12) d[11]=12;
			else if(di==13) d[12]=13;
		}
	}
	for(int i=0 ; i<13 ; i++){
	if(s[i]==0){
		cout<<"S "<<i+1<<endl;
	}
	}
	for(int i=0 ; i<13 ; i++){
	if(h[i]==0){
		cout<<"H "<<i+1<<endl;
	}
	}
	for(int i=0 ; i<13 ; i++){
	if(c[i]==0){
		cout<<"C "<<i+1<<endl;
	}
	}
	for(int i=0 ; i<13 ; i++){
	if(d[i]==0){
		cout<<"D "<<i+1<<endl;
	}
	}
	return 0;

}



Measured memory_bytes: 3100
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int N = sc.nextInt();
        int K = sc.nextInt();
        var l = sc.ArrayInt(N);
        WriteLine(l.OrderByDescending(i => i).Take(K).Sum());
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13396
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>

using namespace std;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};

long long int a[100000],b[100000],c[100000];
int main(){
	long long int n;
	long long int ans=0LL;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	for(int i=0;i<n;i++){
		cin>>c[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	for(long long int i=0;i<n;i++){
		if(a[0]>=b[i] or b[i]>=c[n-1LL]){continue;}
		else{
			long long int aS=0LL;long long int aMorL=n;
			while(aMorL-aS>1LL){
				long long int temp=(aS+aMorL)/2LL;
				if(a[temp]<b[i]){
					aS=temp;
				}
				else{
					aMorL=temp;
				}
			}		
			long long int bSorM=-1LL;long long int bL=n-1LL;
			while(bL-bSorM>1LL){
				long long int temp=(bSorM+bL)/2LL;
				if(c[temp]<=b[i]){
					bSorM=temp;
				}
				else{
					bL=temp;
				}
			}
			long long temp=(aS+1LL)*(n-bL);
			ans+=temp;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100;
struct code{
	int num;
	int dis;
	int pos;
}a[N+5];
int b[N+5];
int c[N+5];
int main(){
	
	int x;
	cin>>x;
	for(int i=1;i<=x;i++){
		cin>>a[i].num;
		a[i].pos=i;
		a[i].dis=0;
	}
	int n=0,flag;
	for(int i=0;i<x;i++){
		flag=0;
		for(int j=x;j>0;j--){
			if(a[j].num==a[j].pos-a[j].dis&&c[j]==0){
				b[n++]=a[j].num;
				c[j]=1;
				flag=1;
				for(int k=j+1;k<=x;k++){
					a[k].dis++;
				}
				break;
			}
		}
		if(flag==0){
			break;
		}
	}
	if(flag==0){
		cout<<"-1"<<endl;
	}else{
		for(int i=x-1;i>=0;i--){
			cout<<b[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int judge(int x){
	if(x < 2) return 0;
	else if(x ==2)return 1;
	
		if(x%2==0)return 0;
		for(int i =3;i*i <= x;i +=2){
			if(x%i == 0)return 0;
		}
	return 1;

}
int main(void){
	int n,a;
	int count = 0;
	
	scanf("%d",&n);
	
	for(int i = 0;i < n;i++){
		scanf("%d",&a);
		count +=judge(a);
	}
	printf("%d\n",count);
	return 0;
	
}




Measured memory_bytes: 2100
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct UnionFind {
    vector<int> par;
	vector<int> cnt;

    UnionFind(int N) : par(N), cnt(N) {
        for (int i = 0; i < N; i++) {par[i] = i; cnt[i] = 1;}
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    void merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
		cnt[ry] = cnt[rx] + cnt[ry];
    }

	int count(int x) {
		return cnt[root(x)];
	}
};

int main() {
//	cout << fixed << setprecision(15);
	ll n, m;
	cin >> n >> m;
	vll a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	UnionFind uf(n);
	vll ans(m);
	ans[0] = n * (n - 1) / 2;
	rep(i, m-1) {
		if(uf.issame(a[i], b[i])) {
			ans[i+1] = ans[i];
		}
		else {
			ans[i+1] = ans[i] - uf.count(a[i]) * uf.count(b[i]);
		}
		uf.merge(a[i], b[i]);
	}
	reverse(ans.begin(), ans.end());

	for(auto i: ans) cout << i << endl;
}


Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

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

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


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N,M,K;
  cin >> N >> M >> K;

  int flag = 0;
  REP(i,N+1){
    REP(j,M+1){
      if(i*M+j*N-2*i*j==K){
        flag = 1;
        break;
      }
    }
  }
  if(flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using P = pair<int,int>;

const ll INF = 1LL<<60;

//#define __DBG__


void solve(void){

  int H, N;
  cin >> H >> N;
  
  vector<ll> DP(H+1, INF);

  DP[0] = 0;
  
  REP(i,N){
    int A, B;
    cin >> A >> B;
    REP(j,H){
      int NJ = min(j+A, H);
      DP[NJ] = min(DP[NJ],DP[j]+B);
    }
  }
  
  cout << DP[H] << endl;

  return;
}

int main(int argc, const char * argv[]) {


    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}





Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int N, M;

int G[710][710];
bool OK[710][710];
int C[710];

struct node {
    int idx;
    int c;
};

PP process(int n, bool &ok) {
    int o = 0, e = 0;
    queue<node> P;
    node p;
    p.idx = n;
    p.c = 1;
    C[n] = 1;
    o++;
    P.push(p);
    PP res;
    while (P.size() > 0) {
        node r = P.front();
        P.pop();
        int id = r.idx;
        int c = r.c;
        int d = 3 - c;
        for (int i = 0;i < N;i++) {
            if (i == id) continue;
            if (G[i][id] == 0) {
                if (C[i] == c) {
                    ok = 0;
                    return res;
                }
                if (C[i] == d) continue;
                C[i] = d;
                if (d == 2) e++;
                else o++;
                node m;
                m.idx = i;
                m.c = d;
                P.push(m);
            }
        }
    }
    return make_pair(e, o);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    memset(G, 0, sizeof(G));
    memset(C, 0, sizeof(C));
    for (int i = 0;i < M;i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a][b] = 1;
        G[b][a] = 1;
    }
    vector<PP> ans;
    for (int i = 0;i < N;i++) {
        if (C[i] != 0) continue;
        int c = 0;
        for (int j = 0;j < N;j++) c += G[i][j];
        if (c != N - 1) {
            bool ok = 1;
            PP p = process(i, ok);
            ans.push_back(p);
            if (!ok) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    int assign = 0;
    for (auto p : ans) {
        assign += p.first + p.second;
    }
    int rem = N - assign;
    memset(OK, 0, sizeof(OK));
    OK[0][0] = 1;
    for (int i = 0;i < ans.size();i++) {
        for (int j = 0;j <= N;j++) {
            if (OK[i][j] == 1) {
                OK[i + 1][j + ans[i].first] = 1;
                OK[i + 1][j + ans[i].second] = 1;
            }
        }
    }
    vector<int> ava;
    for (int i = 0;i <= N;i++) {
        if (OK[ans.size()][i] == 1) ava.push_back(i);
    }
    int sol = M;
    for (auto x : ava) {
        int y = assign - x;
        for (int i = 0;i <= rem;i++) {
            int j = rem - i;
            sol = min(sol, (x + i) * (x + i - 1) / 2 + (y + j) * (y + j - 1) / 2);
        }
    }
    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
using namespace std;
#define pi M_PI

int main(){
    int x, a, b;
    cin >> x >> a >> b;

    x -= a;
    int n = x / b;
    x = x - b*n;
    cout << x << endl;
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(10) << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  VL p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(rall(p));
  sort(rall(q));
  sort(rall(r));
  VL s;
  s.insert(s.end(), p.begin(), p.begin() + x);
  s.insert(s.end(), q.begin(), q.begin() + y);
  s.insert(s.end(), r.begin(), r.end());
  sort(rall(s));
  out(accumulate(s.begin(), s.begin() + x + y, 0LL));

  return 0;
}


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

#define MAX 100000

int N, K;
int  h[MAX];

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

	sort( h, h + N );
	int ans = INT32_MAX;
	for( int i = 0; i < N - (K-1); i++ ) {
		ans = min( ans, h[i + K - 1] - h[i] );
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.000000001
#define ld long double
#define inf 5e18
#define N 1000001

int dp[N];
 
 
 
int32_t main()
{
    IOS;

    memset(dp,0,sizeof(dp));
    int arr[6];
    int x;
    cin >> x;
    for(int i = 0;i < 6;i++)
    {
        arr[i] = 100 + i;
        dp[100 + i] = 1;
    }
    for(int i = 106;i <= x;i++)
    {
        for(int j = 0;j < 6;j++)
        {
            dp[i] |= dp[ i - arr[j]];
        }
    }
    if(dp[x])
        cout << 1;
    else
        cout << 0;
    return 0;
 
}

Measured memory_bytes: 8192
#include <stdio.h>
int main(void){

    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    
    
    
  
    
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H )    printf("Yes\n");
    else  printf("No\n");
   

    return 0;
    

    
}





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

typedef long long ll;

ll a[222222];

int main(void)
{
	ll n, i, ans = 0;

	scanf("%lld", &n);
	for (i = 1; i <= n; i++)
		scanf("%lld", &a[i]);

	for (i = 2; i <= n; i++)
	{
		if (a[i] < a[i - 1])
		{
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}

	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < n - 2; ++i) {
    ans += s.substr(i, 3) == "ABC"s;
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int n = s.length();
        int[] st = new int[n+1];
        for(int i=0; i<n; i++){
            st[i] = s.charAt(i) - 'A';
        }
        
        long ans = 0;
        int[] usb = new int[n+3];
        
        for(int i=0; i<n; i++){
            if(st[i] == 0){
                //前のんと+1
                usb[i+1] += usb[i]+1;
            }else if(st[i]==1 && st[i+1]==2){
                int tmp = usb[i];
                ans += tmp;
                usb[i+2] += tmp;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 30876
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	sc.Split(bufio.ScanWords)
	foods := make([]int, 5, 5)
	for i := 0; i < 5; i++ {
		foods[i] = nextInt()
	}
	ss := 10
	big := -1
	for i := 0; i < 5; i++ {
		if foods[i]%10 != 0 && foods[i]%10 < ss {
			ss = foods[i] % 10
			big = i
		}
	}
	if big == -1 {
		big = 0
	}
	time := 0
	for i := 0; i < 5; i++ {
		if i == big {
			continue
		}
		time += foods[i]
		if time%10 != 0 {
			time += 10 - (time % 10)
		}
	}
	time += foods[big]
	fmt.Println(time)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    float x;
    cin>>n;
    float a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    x=a[0]+a[1];
    x=x/2;
    for(i=2;i<n;i++)
    {
        x=(x+a[i])/2;
    }
    cout<<x;


}


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

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (size_t i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
	}
}

int main() {
	bool debug = false;
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	if (debug) {
		cout << "\x1b[41m" << "Debug Mode " << endl;
	}
	(debug) ? DebugMain() : Main();
	return 0;
}

inline void Main(){
	int N;
	cin >> N;
	cout << (int)(N * 0.5 - 1 + 0.5) << endl;
}

Measured memory_bytes: 256
import sys
import socket
import itertools

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    P = read_int_list()
    Q = read_int_list()
    i = 1
    for p in itertools.permutations(range(1, N+1)):
      if P == list(p):
        a = i
      if Q == list(p):
        b = i
      i += 1
    res = abs(a - b)
    print(res)


main()


Measured memory_bytes: 3572
import numpy as np
import sys
buf = sys.stdin.buffer

N, M, Q = map(int, buf.readline().split())
city = np.zeros((N + 1, N + 1), np.int32)
LRpq = np.array(buf.read().split(), np.int32)

L = LRpq[:2 * M:2]
R = LRpq[1:2 * M:2]
p = LRpq[2 * M::2]
q = LRpq[2 * M + 1::2]

np.add.at(city, (L, R), 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)

p -= 1
answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
print('\n'.join(answer.astype(str)))

Measured memory_bytes: 45828