akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[200100], b[200100];

pair<ll, ll> calc(int k0, int k1) {
    ll lb = -1, ub = inf;
    while (ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        ll cnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] <= mid)
                cnt++;
        }
        if (cnt >= k0) {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    ll l = ub;

    lb = -1; ub = inf;
    while (ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        ll cnt = 0;
        for (int i = 0; i < n; i++) {
            if (mid <= b[i])
                cnt++;
        }
        if (cnt >= k1) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    ll r = lb;
    return make_pair(l, r);
}

ll solve() {
    if (n % 2 == 1) {
        pair<ll, ll> p = calc((n+1)/2, (n+1)/2);
        return p.second - p.first + 1;
    } else {
        pair<ll, ll> p0 = calc(n/2, n/2+1);
        pair<ll, ll> p1 = calc(n/2+1, n/2);
        return (p0.second+p1.second) - (p0.first+p1.first) + 1;
    }
}

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

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 6260
#include<bits/stdc++.h>
using namespace std;
char s[110];
char a[3]={'\0','C','F'};
int n=1;
bool flag;
int main()
{
	//freopen("***.in","r",stdin);
	//freopen("***.out","w",stdout);
	gets(s);
	for(int i=0;i<=strlen(s);i++)
	{
		if(n>2)
		{
			flag=true;
			break;
		}
		if(s[i]==a[n])
		{
			n++;
		}
	}
	if(flag)cout<<"Yes";
	else cout<<"No";
	
 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<long long> a(n); long long all = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i]; all ^= a[i];
    }
    long long x = ~all;
    for (int i = 0; i < n; i++) a[i] &= x;
    sort(a.rbegin(), a.rend());
    int base = 0;
    for (int k = 60; k >= 0; k--) {
        for (int i = base; i < n; i++) {
            if (a[i] & (1LL << k)) {
                swap(a[i], a[base]);
                break;
            }
        }
        if (a[base] & (1LL << k)) {
            for (int i = 0; i < n; i++) {
                if (i == base) continue;
                if (a[i] & (1LL << k)) {
                    a[i] ^= a[base];
                }
            }
            base++;
        }
    }
    long long an = 0;
    for (int i = 0; i < n; i++) {
        if (an ^ a[i] > an) an = an ^ a[i];
    }
    cout << an * 2 + all << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    string s;
	cin >> s;
	vector<int> cnt(2);
	rep(i, s.length())
		cnt[s[i]-'0']++;
	cout << min(cnt[0], cnt[1]) * 2 << endl;
}


Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
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 int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

const int MAX_N = (int)2e5 + 77;

ll fenwick[MAX_N];

inline void add(int pos, ll x)
{
	for(; pos < MAX_N; pos |= (pos + 1))
		fenwick[pos] += x;
}

inline ll get(int r)
{
	ll acc = 0;

	for(; r >= 0; r = (r & (r + 1)) - 1)
		acc += fenwick[r];

	return acc;
}

ll a[MAX_N], k;
int n;

ll ord[MAX_N];

void solve()
{
	cin >> n >> k;

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

	for(int i = 1; i <= n; ++i)
		a[i] += a[i - 1];

	++n;

	for(int i = 0; i < n; ++i)
		ord[i] = a[i];

	sort(ord, ord + n);

	for(int i = 0; i < n; ++i)
		a[i] = lower_bound(ord, ord + n, a[i]) - ord;

	ll answ = 0;

	for(int i = 0; i < n; ++i)
	{
		answ += get(a[i]);
		add(a[i], 1);
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, M = Scanner.map_int()
    P, S = [str] * M, [str] * M
    for i in range(M):
        P[i], S[i] = Scanner.string().split()
    ac, wa = 0, 0
    acs = defaultdict(bool)
    was = defaultdict(int)
    for i in range(M):
        if S[i] == "AC":
            if not acs[P[i]]:
                ac += 1
                wa += was[P[i]]
                acs[P[i]] = True
        else:
            was[P[i]] += 1
    print(ac, wa)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 77912
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

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

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define M 505
#define MAXN 149
#define INF 1000000000
using namespace std;
int n,m,f[M][M],g[M][M],S,T;
int read(){
	char c=getchar();int ans=0;
    while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=(ans<<1)+(ans<<3)+(c^48),c=getchar();
	return ans;
}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}
int main(){
	n=read(),m=read();
	for (register int i=1;i<=n;i++)
		for (register int j=1;j<=m;j++) f[i][j]=read();
	for (register int i=0;i<=MAXN;i++)
		for (register int j=0;j<=MAXN;j++)
			for (register int k=1;k<=n;k++)
				for (register int l=1;l<=m;l++)
					g[i][j]=max(g[i][j],f[k][l]-k*i-l*j);
	for (register int i=1;i<=n;i++)
		for (register int j=1;j<=m;j++){
			int now=INF;
			for (register int k=0;k<=MAXN;k++)
				for (register int l=0;l<=MAXN;l++)
					now=min(now,k*i+l*j+g[k][l]);
			if (now!=f[i][j]){printf("Impossible");return 0;}
		}
	for (register int i=0;i<=MAXN;i++)
		for (register int j=0;j<=MAXN;j++)
			if (g[i][j]>100){printf("Impossible");return 0;}
	printf("Possible\n%d %d\n",MAXN+MAXN+2,(MAXN+1)*(MAXN+1)+2*MAXN);
	S=1,T=MAXN+MAXN+2;
	for (register int i=1;i<=MAXN;i++) printf("%d %d X\n",i,i+1);
	for (register int i=MAXN+2;i<=MAXN+MAXN+1;i++) printf("%d %d Y\n",i,i+1);
	for (register int i=0;i<=MAXN;i++)
		for (register int j=0;j<=MAXN;j++)
			printf("%d %d %d\n",i+1,T-j,g[i][j]);
	printf("%d %d\n",S,T);
	return 0;
}


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

long long int dp[101][100001];
long long int solve(int **a,int i,long long int w,int n)
{
	if(w==0)
	{
		return(0);
	}
	if(i==n)
	{
		return(0);
	}
	if(dp[i][w]!=-1)
	{
		return(dp[i][w]);
	}
	long long int op1=-1,op2=-1;
	op1=solve(a,i+1,w,n);
	if(w-a[i][0]>=0)
    op2=solve(a,i+1,w-a[i][0],n)+a[i][1];
    
    return(dp[i][w]=max(op1,op2));
}
int main()
{
	long long int n,w,i,j;
	cin>>n>>w;
	int **a=new int*[n];
	for (i = 0; i <n; ++i)
	{
		a[i]=new int[2];
	}
	for (i = 0; i <n; ++i)
	{
		cin>>a[i][0]>>a[i][1];
	}
	for(i=0;i<100;i++)
	{
		for(j=0;j<=100000;j++)
		{
			dp[i][j]=-1;
		}
	}
	cout<<solve(a,0,w,n);
}

Measured memory_bytes: 78336
import collections
# from collections import OrderedDict

N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
# max_vale = c.most_common()[0][1]
max_vale = max(c.values())

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)



# for i in c.most_common():
#     print(i)

Measured memory_bytes: 101968
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function euc(a,m)
	b = m
	x = 1
	u = 0
	while b>0
		q = div(a,b)
		tmp = u
		u = x-q*u
		x = tmp
		tmp = b
		b = a-q*b
		a = tmp
	end
	x<0?x+abs(m):x
end

function main()
	p = 10^9+7
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	d = Dict{Int,Int}()
	for i in 1:n
		x = 2
		y = a[i]
		z = Dict{Int,Int}()
		while y>1&&x<=sqrt(a[i])
			if y%x==0
				if haskey(z,x)
					z[x]+=1
				else
					z[x]=1
				end
				y = div(y,x)
			else
				x += 1
			end
		end
		if y>1
			if haskey(z,y)
				z[y]+=1
			else
				z[y]=1
			end
		end
		for k in keys(z)
			if haskey(d,k)
				d[k]=max(d[k],z[k])
			else
				d[k]=z[k]
			end
		end
	end
	l = 1
	for k in keys(d)
		for i in 1:d[k]
			l = l*k%p
		end
	end
	s = 0
	for i in 1:n
		s = (s+l*euc(a[i],p)%p)%p
	end
	println(s)
end

main()

Measured memory_bytes: 122996
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main(){
    int N,count=0,j=0,count2=0;
    string s;
    cin >>N>>s;
    for(long long int i=0;i<N;i++){
         if(s[i]=='(')count2++;
       if(s[i]==')')count2--;
       if(count2<0){
           count++;
           count2=0;
       }
    }
 
       for(long long int i=0;i<count2;i++){
           s=s+")";
       }

       for(long long int i=0;i<abs(count);i++){
           s="("+s;
       }
   cout<<s;
}



Measured memory_bytes: 256
<?php
define('MOD', pow(10, 9) + 7);

fscanf(STDIN, "%d %d", $N, $K);

$ans = [];

for ($i = 1; $i <= $K; $i++) {
    
    $rs = $i;
    $rb = $N - $K - ($i - 1);
	
	if ($rb < 0) {
		$ans[] = 0;
	} else {
    	$r = pascal($rs + $rb, $rb);

    	$bs = $i - 1;
    	$bb = $K - $i;
    	$b = pascal($bs + $bb, $bb);

    	$ans[] = ($r * $b) % MOD;
	}
}
echo implode(PHP_EOL, $ans);

function pascal($x, $y) {
    global $memo;
    if (isset($memo[$x][$y])) {
        return $memo[$x][$y];
    }

    if($y === 0 || $y === $x) {
        $tmp = 1;
        $memo[$x][$y] = $tmp;
        return $tmp;    
    } else {
        $tmp = pascal($x - 1, $y - 1) + pascal($x - 1, $y);
        $tmp %= MOD;
        $memo[$x][$y] = $tmp;
        return $tmp;
    }
}


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

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        A--;
        B--;
        int t = 1, y = 1;
        String S[][] = new String[100][100];
        for (int i = 0; i < 50; i++) {
            for (int j = 0; j < 100; j++) {
                S[i][j] = "#";
            }
        }
        for (int i = 50; i < 100; i++) {
            for (int j = 0; j < 100; j++) {
                S[i][j] = ".";
            }
        }
        while (A-- > 0) {
            S[t][y] = ".";
            y += 2;
            if (y > 100) {
                t += 2;
                y = 1;
            }
        }
        t = 51;
        y = 1;
        while (B-- > 0) {
            S[t][y] = "#";
            y += 2;
            if (y > 100) {
                t += 2;
                y = 1;
            }
        }
        System.out.println("100 100");
        for (int i = 0; i < 100; i++) {
            for (int j = 0; j < 100; j++) {
                System.out.print(S[i][j]);
            }
            System.out.println();
        }
    }

}

Measured memory_bytes: 25300
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#define INF (1e9 + 7)
#define dist(x1, y1, x2, y2) sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
typedef long long int ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

ll gcd_(ll a, ll b){
    if(a < b){  
        swap(a, b);
    }
    if(b == 0){
        return a;
    }
    return gcd_(b, a % b);
}
 
ll gcd(ll a, ll b, ll c){
    ll ans = a;
    ans = gcd_(ans, b);
    ans = gcd_(ans, c);
    return ans;
}

int main(){
    
    ll ans, K;
    ans = 0;
    cin >> K;
    rep2(i, 1, K + 1){
        rep2(j, 1, K + 1){
            rep2(k, 1, K + 1){
                ans += gcd(i, j, k);
            }
        }
    }
           
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 3632
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

typedef pair<int, int> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.second > secondElof.second;
}

signed main(void)
{
	string s, t;
	cin >> s >> t;
	int n = s.size();
	vector<int>si(n), ti(n);
	rep(i, n) {
		si[i] = s[i] - 'a';
		ti[i] = t[i] - 'a';
	}
	vector<int>sc(26), tc(26);
	rep(i, n) {
		sc[si[i]]++;
		tc[ti[i]]++;
	}

	sort(sc.begin(), sc.end());
	sort(tc.begin(), tc.end());

	rep(i, 26) {
		if (sc[i] - tc[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ld double
    #define vv vector<ll>
    #define pp pair<ll,ll>
    #define ff first
    #define ss second
    #define vp vector<pp>
    #define pb push_back
    #define mp make_pair
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define maxn 105
    const ll mod=1e9+7;
    #define N 2750135
    bool prime[N];
    ll p[N];
    ll n,m;
    void isprime()
    {
        memset(prime,true,N);
        memset(p,-1,sizeof(p));
        for(ll i=2;i<N;i++)
        {
            if(p[i]==-1)
            {
            	p[i]=i;
                for(ll j=i*i;j<N;j+=i)
                {
                    if(p[j]==-1)
                    {
                    	p[j]=i;
					}
                }
            }
        }
    }
    ll power(ll a,ll n)
    {
        ll ans=1;
        a=a%mod;
        while(n>0)
        {
            if(n&1)
            {
                ans=(ans*a)%mod;
            }
            n=n>>1;
            a=(a*a)%mod;
        }
        return ans;
    }
    ll gcd(ll a,ll b)
    {
        if(b==0)
        return a;
        
        return gcd(b,a%b);
    }
    

    int main()
    {
    	fast;
        ll n,d;
        cin>>n>>d;
        vector<double> p[n];
        for(ll i=0;i<n;i++)
        {
        	for(ll j=0;j<d;j++)
        	{
        		double x;
        		cin>>x;
        		p[i].pb(x);
			}
		}
		ll ans=0;
		for(ll i=0;i<n;i++)
		{
			for(ll j=i+1;j<n;j++)
			{
				double sum=0;
				for(ll k=0;k<d;k++)
				{
					sum=sum+pow(p[i][k]-p[j][k],2);
				}
				if(floor(sqrt(sum))-sqrt(sum) == 0)
				{
					ans++;
				}
				
			}
		}
		cout<<ans;
        
		return 0;
	}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<stdio.h>
#include<cstring>

int main(){
    
    char str1[201], str2[101];
    scanf("%s", str1);
    strcpy(str2, str1);
    strcat(str1, str2);
    
    char str3[101];
    scanf("%s", str3);
    if ( strstr(str1, str3) == NULL ) printf("No\n");
    else printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <cstdio>
#include <iterator>
#include <algorithm>
#include <map>
#include <string>
using namespace std;

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

  int n, k;
  cin >> n >> k;
  int ans = 0;
  while(n > 0){
    n/=k;
    ans++;
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        long a = scan.nextLong();
        long b = scan.nextLong();
        long k = scan.nextLong();
        
        if(a >= k){
            a = a - k;
        }else{
            b = b - k + a; 
            a = 0;
        }
        if(a < 0 || b < 0){
            a = 0;
            b = 0;
        }
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 21844
import math
n, d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(n):
        if i <= j:
            continue
        temp = 0
        for k  in range(d):
            temp += abs(x[i][k]-x[j][k]) ** 2
        dist = math.sqrt(temp)
        if dist == int(dist):
            cnt += 1
print(cnt)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/03  Problem: 019_agc_b / Link: https://agc019.contest.atcoder.jp/tasks/agc019_b ----- */
/* ------問題------

英小文字からなる文字列 A=A1A2…An があります。
あなたは 1≤i≤j≤n であるような任意の二つの添字 i,j を選び、A のうち部分文字列 AiAi+1…Aj を反転することができます。
この操作は一回まで行うことができます。
これによって得られる文字列は何通りあるでしょうか？

-----問題ここまで----- */
/* -----解説等-----

アルファベットについての累積和を取ると、部分問題として見れるので、重複数え上げがないようにすればよい。
[str] +'a'のとき、aを含む反転をして一致するのは反転の区間の左端がaとなる場合である。
ex: strstrstr|abca| -> strstrstr|abca|
なぜなら、[str]内の計算で cを右端とした場合にbc->cbを事前に計算終えているからである。
したがって文字列の先頭から走査し、現在見ている文字を両端としない場合は反転をしてuniqueになることが保証あされるので、
これを答えとしてよい。
この方法では反転するものしか数えないので、全く反転しない場合の数1を加える。


----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	string s;
	cin >> s;

	VVI cnt(SZ(s) + 1, VI(26, 0));
	FOR(i, 0, SZ(s)) {
		FOR(j, 0, 26) {
			cnt[i + 1][j] += cnt[i][j] + (s[i] - 'a' == j);
		}
	}
	ans = 1;
	FOR(i, 0, SZ(s)) {
		ans += i - cnt[i][s[i] - 'a'];
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 27028
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

typedef long long int ll;
const int maxn = 1e5+7;
const ll mod = 1e9+7;

bool compare(const pair<ll,ll>& x, const pair<ll,ll>& y) {
    if(x.second == y.second) return x.first < y.first;
    return x.second < y.second;
}

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) {
            res = (res*a)%mod;
        }
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

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

ll max_v = 1000;

ll N;
ll W;
ll wv[105][2];
ll dp [105][100005];

int main() {
    cin >> N >> W;
    for(int i=0;i<N;i++) {
        cin >> wv[i][0] >> wv[i][1];
    }
    for(int i=0;i<=N;i++) {
        for(int j=0;j<=100001;j++) {
            dp[i][j] = 2e15;
        }
    }
    dp[0][0] = 0;
    for(int i=1;i<=N;i++) {
        for(int j=0;j<=N*max_v;j++) {
            ll prevValue = j - wv[i-1][1];
            if(prevValue < 0) {
                dp[i][j] = dp[i-1][j];
            } else if(dp[i-1][prevValue]+wv[i-1][0] > W) {
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = min(dp[i-1][j],dp[i-1][prevValue] + wv[i-1][0]);
            }
        }
    }
    ll ans = 0;
    for(int i=N*max_v;i>=0;i--) {
        if(dp[N][i] < 2e15) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80128
main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  hs <- map read . words <$> getLine :: IO [Int]
  print . fst . foldl step (0, 0) $ hs

step :: (Int, Int) -> Int -> (Int, Int)
step l@(k, m) h = if h >= m then (succ k, h) else l


Measured memory_bytes: 508
use std::collections::HashMap;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n:usize,
        an:[i64;n],
    }
    let ans = std::cmp::min(solve(true, &an), solve(false, &an));
    println!("{}", ans);
}
fn solve(mut flag: bool, an: &Vec<i64>) -> i64 {
    let mut sum = 0;
    let mut ans = 0;
    for &a in an {
        sum += a;
        if !flag && sum >= 0 {
            let diff = sum - -1;
            ans += diff;
            sum -= diff;
        } else if flag && sum <= 0 {
            let diff = 1 - sum;
            ans += diff;
            sum += diff;
        }
        flag = !flag;
    }
    ans
}

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

int main(){
  long long N;
  cin >> N;
  vector<pair<int,int>> E;
  long long ans = N*(N*N+3*N+2)/6;
  for(int i = 1; i < N; ++i){
    long long u, v;
    cin >> u >> v;
    --u,--v;
    E.emplace_back(u,v);
    if(u > v) swap(u,v);
    // L <= u < v <= R
    ans -= (u+1)*(N-v);
  }
  cout << ans << endl;
}


Measured memory_bytes: 5356
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}
import scala.util.Random
import java.util.Date

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val D = in.next().toInt
  val c = new Array[Long](26+1)
  val s = Array.ofDim[Long](D+1, 26+1)

  for (i <- 1 to 26) {
    c(i) = in.next().toInt
  }
  for (d <- 1 to D) {
    for (i <- 1 to 26) {
      s(d)(i) = in.next().toInt
    }
  }

  // optional
  val t = new Array[Int](D+1)
  for (i <- 1 to D) {
    t(i) = in.next().toInt
  }


  def calcScore(t: Array[Int]): Long = {
    var res = 0L

    val last = new Array[Int](26+1)
    for (day <- 1 to D) {
      val now = t(day)
      last(now) = day

      res += s(day)(now)
      for (contest <- 1 to 26) {
        res -= c(contest) * (day - last(contest))
      }
      pw.println(res)
    }

    res
  }

  calcScore(t)
  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 54844
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, K;
	cin >> N >> K;
	vector<string> S(N+1);
	for(int i = 0; i <= N; i++) cin >> S[i];
	vector< vector< vector<int> > > cnt(N+1);
	for(int i = 0; i <= N; i++) cnt[i].resize(1<<i, vector<int>(i+1, 0));
	for(int i = 0; i < (1<<N); i++) for(int j = 0; j <= N; j++) cnt[N][i][j] = S[N][i]-'0';
	for(int d = N-1; d >= 0; d--) {
		for(int i = 0; i < (1<<d); i++)
			cnt[d][i][d] = cnt[d+1][2*i][d+1] + cnt[d+1][2*i+1][d+1] + S[d][i]-'0';
		for(int i = 0; i < (1<<d); i++) for(int j = d-1; j >= 0; j--) {
			int l = i>>(d-j), r = i&((1<<(d-j))-1), c = (i>>(d-1-j))&1;
			cnt[d][i][j] = cnt[d+1][((2*l+1-c)<<(d-j))+r][j+1] + cnt[d][i][j+1];
		}
	}
	for(int d = N; d >= 0; d--) for(int i = 0; i < (1<<d); i++) if(cnt[d][i][0] >= K) {
		string ans;
		for(int j = d-1; j >= 0; j--) ans += '0'+((i>>j)&1);
		cout << ans << "\n";
		return 0;
	}
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 245824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i) = 0; (i) < (n); (i)++)
int main(){
  int N, M;
  cin >> N >> M;
  int64_t ans = 0;
  int now = 0;
  rep(i,M){
    int Ai;
    cin >> Ai;
    ans += Ai;
  }
  if (N >= ans){
    cout << N - ans << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A,B,K;cin>>A>>B>>K;
    if(A<=K){
        K-=A;
        A=0;
    }else{
        A-=K;
        K=0;
    }
    
    if(B<=K){
        K-=B;
        B=0;
    }else{
        B-=K;
        K=0;
    }
    
    cout<<A<<" "<<B<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin>>s;
  vector<uint64_t> a(s+1,0);
  if(s==0){
    cout<<1<<endl;
  }else if(s<3){
    cout<<0<<endl;
  }else{
    a.at(0)=1;
    uint64_t sum;
    for(int i=1;i<s+1;i++){
      if(i>=3){
        a.at(i)=a.at(i-3)+a.at(i-1);
        a.at(i)%=1000000007;
      }
    }
    cout<<a.at(s)<<endl;
  }
}
      

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

signed main() {
  int n, q, key; cin >> n;
  vector<int> s(n);
  for(int i = 0; i < n; i++) cin >> s.at(i);

  int sum = 0;
  cin >> q;
  for(int i = 0; i < q; i++) {
    cin >> key;
    int j = 0;
    s.push_back(key);
    s.at(n) = key;      // 番兵
    while(s.at(j) != key) j++;
    if(j != n) sum++;
  }

  cout << sum << endl;
}



Measured memory_bytes: 3152
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n, x;
int a[100100];
ll sum;

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

    if(a[0] > x){
        sum += a[0] - x;
        a[0] = x;
    }
    for(int i = 1; i < n; ++i){
        if(a[i] + a[i - 1] > x){
            sum += (a[i] + a[i - 1]) - x;
            a[i] = x - a[i - 1];
        }
    }
    return sum;
}

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

    cout << solve() << "\n";
    
    return 0;
}


Measured memory_bytes: 640
A, B, C ,X, Y = map(int, input().split())

ans = 10 ** 20
for i in range(max(X, Y)+1):
    kari = 2*i*C + A*max(0, (X-i)) + B*max(0, (Y-i))
    ans = min(ans, kari)

print (ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, char> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;

ll M, d[200010], c[200010], sum, len, S;

int main(void)
{
	cin >> M;

	for (int i = 0; i < M; i++)
	{
		cin >> d[i] >> c[i];

		if (d[i] == 0)
		{
			len += c[i];
			continue;
		}

		sum += (d[i] * c[i] - 1) / 9;
		if (d[i] * c[i] % 9 == 0)
		{
			S += 9;
		}
		else
		{
			S += d[i] * c[i] % 9;
		}
		len += c[i];
	}
	
	sum += len - 1;
	sum += (S - 1) / 9;

	cout << sum << endl;

	int xxx;
	cin >> xxx;
}



Measured memory_bytes: 3328
#include <stdio.h>

int gcd(int x, int y){
	/* euclid algorithm */
    int r;
	while((r=x%y)!=0) x=y, y=r;
	return y;
}

int lcm(int x, int y){
    if(x == 0 || y == 0) return 0;
    return x/gcd(x, y)*y; /* ツ静ヲツづ謁ツ掛ツつッツづゥツづ暗ャツづェツづゥ */
}

int main(void){
	int a,b;
	while(scanf("%d %d",&a,&b)==2) printf("%d %d\n",gcd(a,b),lcm(a,b));
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
pair<long,int> Je[200000];
vector<long> G[100000];
vector<long> G2[100000];
pair<long,int> O[100000];
int MaxThree[100000];
long ans[200001];
void Calc(){
	int N = rei();
	int K = rei();
	for(int i=0;i<N;i++){
		int c = rei()-1;
		long v = rei();
		Je[i] = {v,c};
	}
	sort(Je,Je+N);
	for(int i=N-1;i>=0;i--){
		G2[Je[i].second].push_back(Je[i].first);	
	}
	for(int i=0;i<K;i++){
		O[i] = {-G2[i][0]-G2[i][1],i};
	}
	sort(O,O+K);
	for(int i=0;i<K;i++){
		G[i] = G2[O[i].second];
	}
	MaxThree[K-1] = K;
	MaxThree[K] = K;
	for(int i=K-2;i>=0;i--){
		MaxThree[i] = MaxThree[i+1];
		if(G[i+1].size() >= 3 && (MaxThree[i] == K || G[i+1][0]+G[i+1][1]+G[i+1][2] >= G[MaxThree[i]][0]+G[MaxThree[i]][1]+G[MaxThree[i]][2])){
			MaxThree[i] = i+1;
		}
	}
	fill(ans,ans+N,-1);
	priority_queue<long> X;
	if(MaxThree[0] != K){
		ans[3] = G[MaxThree[0]][0] + G[MaxThree[0]][1] + G[MaxThree[0]][2];
	}
	long sum = G[0][0]+G[0][1];
	long min = 10000000000000000;
	for(int i=2;i<G[0].size();i++){
		X.push(G[0][i]);
	}
	ans[2] = sum;
	if(MaxThree[0] != K && N >= 5){
		ans[5] = sum + G[MaxThree[0]][0] + G[MaxThree[0]][1] + G[MaxThree[0]][2];
	}
	int p = 1;
	bool wait = false;
	for(int c=3;c<=N;c++){
		if(X.empty() && min == 10000000000000000){
			if(wait){
				wait = false;
				sum += G[p][0] + G[p][1];
				for(int i=2;i<G[p].size();i++){
					X.push(G[p][i]);
				}
				p++;
			}
			else{
				wait = true;
				continue;
			}
		}
		else{
			if(p < K && (X.empty() || min + X.top() < G[p][0] + G[p][1])){
				sum += G[p][0] + G[p][1] - min;
				X.push(min);
				min = 10000000000000000;
				for(int i=2;i<G[p].size();i++){
					X.push(G[p][i]);
				}
				p++;
			}
			else{
				sum += X.top();
				min = X.top();
				X.pop();
			}
		}
		ans[c] = max(ans[c],sum);
		if(c+3 <= N && MaxThree[p] != K){
			ans[c+3] = max(ans[c+3],sum + G[MaxThree[p]][0] + G[MaxThree[p]][1] + G[MaxThree[p]][2]);
		}
	}
	for(int i=1;i<=N;i++){
		cout << ans[i] << "\n";
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) cin >> s[i];
    for (int i = 0; i < N; i++) sort(s[i].begin(), s[i].end());
    sort(s.begin(), s.end());
    int ans = 0, count = 1;
    string before = s[0];
    for (int i = 1; i < N; i++) {
        if (before == s[i]) {
            ++count;
        } else {
            if (count >= 2) {
                for (int i = 1; i <= count - 1; i++) ans += i;
                count = 1;
            }
            before = s[i];
        }
    }
    if (count >= 2) {
        for (int i = 1; i <= count - 1; i++) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7296
n, k = map(int, input().split())

# サイコロを振ってそれぞれの目が出る確率
p = 1/n

ans = 0
for i in range(1, n+1):
    cnt = 0
    score = i
    while score < k:
        score *= 2
        cnt += 1
    ans += p * ((1/2)**cnt)

print(ans)

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

using namespace std;

int main(){
    int n,a,b,c,d;
    string s;
    bool match = true;
    cin>>n>>a>>b>>c>>d>>s;
    a--;b--;c--;d--;

    for(int i=a;i<max(c,d);i++){
        if(s[i]=='#'&&s[i+1]=='#')
            match=false;
    }

    if(c>d){
        for(int i=b;i<=d;i++){
            if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
                match = true;
                break;
            }
            match = false;
        }
    }

    if(match)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, k;
  cin >> n >> k;
  cout << n-k+1 << newl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 998244353
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

ll pow_mod(ll a, ll b) {
  ll r = 1;
  REP(i, b) {
    r *= a;
    r %= MOD;
  }
  return r;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  vector<ll> d(n);
  vector<ll> cnt;
  REP(i, n) cin >> d[i];
  if (d[0] == 0)
    cnt.push_back(1);
  else {
    cout << "0\n";
    return 0;
  }
  sort(ALL(d));

  for (ll i = 1; i < n; i++) {
    if (d[i] - d[i - 1] > 1 || d[i] == 0) {
      cout << "0\n";
      return 0;
    } else if (d[i - 1] != d[i])
      cnt.push_back(1);
    else
      cnt.back()++;
  }
  ll ans = 1;
  for (ll i = 1; i < cnt.size(); i++) {
    ans *= pow_mod(cnt[i - 1], cnt[i]);
    ans %= MOD;
  }

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


Measured memory_bytes: 4916
X, K, D = map(int, input().split())
if X < 0:
    X=-X  # これにより、X>=0の場合だけ考えればよい

#+D or -D
# X + D*(K-n) + (-D) *n ;0<=n <=K
# -> X + D*(K-2*n)
# 1, X>=K*D-> K回全部（-D）移動に使うことが最適->n=K
# 2, X < K*D ->
# X >= p*D を満たす最大のpを探す -> p回（-D）移動に使うことが最適
# 残り(K-p)%2=0なら行ったり来たりで消化できる.
# 残り回数が奇数の場合、R=X-D*pとすると、min(R+D,abs(R-D))

n = 0  # 負方向移動の回数
result = X + D*(K-2*n)

# if X == 0:
#     if K % 2 == 0:
#         n = K/2
#         print(result)
#     else:
#         print(D)

if X >= D*K:
    print(X-D*K)

elif X < D*K:
    p = int(X/D)  # X/D回負の方向に移動すれば、原点に最も近い正の値になる。
    result=X-D*p
    if (K-p) % 2 == 0:
        print(result)
    elif (K-p)%2 ==1:
        print(abs(result-D))

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

using namespace std;

#define ll long long

int main(){
	ll n, k;
	cin >> n >> k;
	vector<pair<ll,ll>> v;
	for(int i = 0; i < n; ++i){
		ll a, b;
		cin >> a >> b;
		v.push_back({a,b});
	}
	sort(v.begin(), v.end());
	int i = 0;
	ll sum = 0;
	while(sum < k){
		sum += v[i].second;
		++i;
	}
	cout << v[i-1].first;

	return 0;
}


Measured memory_bytes: 5308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int x,y,z,p;
int main(){
int n,a,b;
cin>>n>>a>>b;
for(int i=0;i<n;i++){
  cin>>p;
  if(p<=a) x++;
  else if( p>b) z++;
  else y++;
}
  cout<<min({x,y,z});
}

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

std::vector<std::vector<std::pair<int, double>>> g;
int n;

double solve(){
	std::vector<double> min_cost(n, 1e18);
	std::priority_queue<std::pair<double, int>, std::vector<std::pair<double, int>>, std::greater<std::pair<double, int>>> qu;
	qu.push({0, 0}); min_cost[0] = 0;
	
	while(!qu.empty()){
		auto p = qu.top(); qu.pop();
		
		for(auto e : g[p.second]){
			if(p.first + e.second >= min_cost[e.first]) continue;
			min_cost[e.first] = p.first + e.second;
			qu.push({min_cost[e.first], e.first});
		}
	}
	
	return min_cost[1];
}

int main(){
	int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
	cin >> n; n += 2; g.resize(n);
	std::vector<double> a(n), b(n), c(n);
	for(int i = 2; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	a[0] = sx, b[0] = sy, c[0] = 0;
	a[1] = gx, b[1] = gy, c[1] = 0;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < i; j++){
			double dist = sqrt((a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]));
			double circle = c[i] + c[j];
			dist = std::max(0.0, dist - circle);
			
			g[i].push_back({j, dist});
			g[j].push_back({i, dist});
		}
	}
	
	cout << std::fixed << std::setprecision(10);
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 21764
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N,Y;
    cin >> N >> Y;

    int A,B,C;
    for(A = 0;A<=N;A++){
        for(B = 0;B<=N;B++){
            C = N-A-B;
            if(0<=C && C<=N && A*10000+B*5000+C*1000==Y){
                cout << A  << " " << B  << " " << C << endl;
                return 0;
            }
        }
    }
    
    cout << "-1" << " " <<  "-1" << " " << "-1" << endl;
    return 0;
}



Measured memory_bytes: 764
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    print(N*(N-1)//2 + M*(M-1)//2)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include "iostream"
using namespace std;

int main(){
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if ((0<=x-r) &&( x+r<=W )&& (0<=y-r )&&( y+r<=H)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    int cnt = 0;
    rep(i, n)
    {
        if (s[i] == "A")
            cnt++;
        else
            cnt--;
        if (cnt < 0)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << (cnt == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3236
// Author:Eleus Ahammad, CSE, KUET
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define vi vector<int>
#define F first
#define S second
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ifile freopen("input.txt", "r", stdin)
#define ofile freopen("output.txt", "w", stdout)
#define MOD 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b);}
ll modpow(ll a, ll b, ll m)
{
    if (b == 0) return 1%m;
    ll u = modpow(a, b / 2, m);
    u = (u * u)%m;
    if (b%2) u = (a * u)%m;
    return u;
}
ll egcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll x1, y1;
    ll d = egcd(b, a%b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
// Code begins here

void solve()
{
    int n, m;
    cin >> n >> m;
    vi a(n);
    double sum = 0;
    for (auto &x:a) {
        cin >> x;
        sum += x;
    }
    sort(a.rbegin(), a.rend());
    sum = (double) sum / (4.0 * m);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (sum <= a[i]) cnt++;
        else break;
    }
    if (cnt >= m) puts("Yes");
    else puts("No");
}


int main()
{
    fastio;
    int t = 1;
    //cin >> t;

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



Measured memory_bytes: 256