akhauriyash/Code-Regression huggingface dataset:
#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 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)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
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 };

/* -----  2019/03/12  Problem: ABC 082 B / Link: http://abc082.contest.atcoder.jp/tasks/abc082_b  ----- */


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


	string s, t; cin >> s >> t;
	SORT(s), RSORT(t);
	LL ans = 0LL;
	FOR(i, 0, min(SZ(s), SZ(t))) {
		if (s[i] < t[i]) {
			ans = 1;
			break;
		}
		else if (s[i] > t[i]) {
			ans = -1;
			break;
		}
	}
	if (!ans) {
		ans = SZ(s) < SZ(t);
	}
	
	
	cout << (ans==1?"Yes":"No") << "\n";

	return 0;
}


Measured memory_bytes: 256
num = list(map(int, input().split()))
ans = 0

while num[0] != num[1] or num[1] != num[2] or num[0] != num[2]:
    num.sort()
    if num[0] + 1 == num[2] and num[1] + 1 == num[2]:
        num[0] += 1
        num[1] += 1

    else:
        num[0] += 2

    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;

char str[30005];

void solve()
{
	int n;
	scanf("%d%s", &n, str);
	
	int flag[10] = { 0 };
	int flag2[100] = { 0 };
	int flag3[1000] = { 0 };
	int i,j;
	for (i = 0; i < n; i++) {
		int tmp = str[i] - '0';
		for (j = 0; j < 100; j++) {
			if (flag2[j]) flag3[j * 10 + tmp] = 1;
		}
		for (j = 0; j < 10; j++) {
			if (flag[j]) flag2[j * 10 + tmp] = 1;
		}
		flag[tmp] = 1;
	}
	int cnt = 0;
	for (i = 0; i < 1000; i++) {
		if (flag3[i]) cnt++;
	}
	printf("%d\n", cnt);
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 256
package main

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

var s = bufio.NewScanner(os.Stdin)

func getInt() int {
	s.Scan()
	a, _ := strconv.Atoi(s.Text())
	return a
}

func main() {
	s.Split(bufio.ScanWords)
	a, b := getInt(), getInt()

	if a-b > 1 {
		fmt.Println(2*a - 1)
	} else if b-a > 1 {
		fmt.Println(2*b - 1)
	} else {
		fmt.Println(a + b)
	}
}


Measured memory_bytes: 640
#include <cstdio>
#include <vector>

int main() {
  size_t N, M;
  int C;
  scanf("%zu %zu %d", &N, &M, &C);

  std::vector<int> b(M);
  for (auto& bi: b) scanf("%d", &bi);

  int res = 0;
  for (size_t i = 0; i < N; ++i) {
    int lhs = C;
    for (size_t j = 0; j < M; ++j) {
      int a;
      scanf("%d", &a);
      lhs += a*b[j];
    }
    if (lhs > 0) ++res;
  }

  printf("%d\n", res);
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
ans = 10**10
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
for i in range(1<<N):
    li = [0]*M
    c = 0
    for j in range(N):
        if i>>j&1:
            c += A[j][0]
            for k in range(M):
                li[k] += A[j][k+1]
    f = True
    for x in li:
        if x < X:
            f = False
            break
    if f:
        ans = min(ans, c)
if ans != 10**10:
    print(ans)
else:
    print(-1)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

ll res = 0;
ll N, C;

void solve(vector<ll> &x, vector<ll> &v){
    vector<ll> M(N, 0);
    ll ma = 0;
    ll V = 0;
    REP(i, N){
        V += v[i];
        chmax(ma, V-x[i]);
        M[i] = ma;
    }
    //dump(M)
    
    ll cum = 0;
    for(int i=N-1;i>=0;i--){
        //dump(cum+M[i])
        chmax(res, cum+M[i]);
        if(i!=N-1) cum -= 2*(x[i+1]-x[i]);
        else cum -= 2*(C-x[i]);
        cum += v[i];
    }
    return;
}

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

    cin >> N >> C;
    vector<ll> x(N), v(N);
    REP(i, N) cin >> x[i] >> v[i];

    solve(x, v);
    //cout << x << endl;
    //cout << v << endl;

    reverse(x.begin(), x.end());
    reverse(v.begin(), v.end());
    REP(i, N) x[i] =  C - x[i];
    solve(x, v);
    //cout << x << endl;
    //cout << v << endl;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)


i64 n,a,b,c,d;

int main()
{
    cin >> n >> a >> b >> c >> d;

    rep(m,0,n - 1)
    {
        if(c * (n - 1 - m) - d * m <= (b - a) && (b - a) <= - c * m + (n - 1 - m) * d)
        {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x = LIST()
print(x.index(0)+1)


Measured memory_bytes: 9976
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
using Graph=vector<vector<int>>;
using EDGES=vector<pair<int,int>>;

vector<bool> seen;

void dfs(Graph G,int v){
    seen[v]=true;
    for(auto next_v:G[v]){
        if(seen[next_v]) continue;
        dfs(G,next_v);
    }
}

int components_count(Graph G,int n)
{
 int cnt=0;
 while(1){
     int s=-1;
     for(int i=0;i<n;i++){
         if(seen[i]==false){
             s=i;
             break;
         }
     }
     if(s==-1){
         return cnt;
         break;
     }
     else{
         cnt++;
         dfs(G,s);
     }
 }
}

int vec_index(vector<int> v,int k)
{
 for(int i=0;i<v.size();i++){
     if(v[i]==k){
         return i;
         break;
     }
 }
 return -1;
}

vector<int> vec_del(vector<int> v,int k)  // vからkを削除
{
 int index=vec_index(v,k);
 if(v[index]==v.back()){
     v[index]=v.front();
     v[0]=v.back();
      v.pop_back();
 }
 else{
     v[index]=v.back();
     v.pop_back();
 }
 return v;
}

int main()
{
 int n,m; cin >> n >> m;
 Graph g(n);
 EDGES Edges;
 for(int i=0;i<m;i++){
     int u,v; cin >> u >> v;
     u-=1;
     v-=1;
     g[u].push_back(v);
     g[v].push_back(u);
     pair<int,int> e=make_pair(u,v);
     Edges.push_back(e);
 }
 int ans=0;
 for(int i=0;i<m;i++){
     seen.assign(n,false);
     pair<int,int> e=Edges[i];
     int u=e.first;
     int v=e.second;
     g[u]=vec_del(g[u],v);
     g[v]=vec_del(g[v],u);
     int cnt=components_count(g,n);
     if(cnt!=1) ans++;
     g[u].push_back(v);
     g[v].push_back(u);
 }
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<vector>
using namespace std;

int count(char a,char b,char c){
  int d=0;
  if(a==b)d++;
  if(b==c)d++;
  if(c==a)d++;
  return d==1?d:d==3?0:2;
}

int  i,j,k,n,h,w,x,y,z,ret;
char a[101],b[101],c[101];
int main(void){
  cin>>n>>a>>b>>c;
  for(i=0;i<n;i++){
    ret+=count(a[i],b[i],c[i]);
  }
  cout<<ret;
  return 0;
}

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

int N;
vector<int> memo, h;

int dp(vector<int> memo, vector<int> h) {
    memo[0] = 0;
    memo[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        int one = memo[i-1] + abs(h[i] - h[i-1]);
        int two = memo[i-2] + abs(h[i] - h[i-2]);
        memo[i] = min(one, two);
    }
    return memo[N-1];
}

int main() {
    scanf("%d", &N);
    memo.resize(N);
    h.resize(N);
    for (int i = 0; i < N; i++) cin >> h[i];
    int MIN = dp(memo, h);
    printf("%d\n", MIN);
}



Measured memory_bytes: 1792
#include <stdlib.h>
#include <iostream>

using namespace std;

void init(int* cards, int n);
void cut(int* cards, int k, int n);
void refullShuffle(int* cards, int n);

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

	int* cards = new int[2 * n];
	init(cards, n);

	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;
		if (k == 0) {
			refullShuffle(cards, n);
		} else {
			cut(cards, k, n);
		}
	}

	for (int i = 0; i < 2 * n; i++) {
		cout << cards[i] << endl;
	}

	return 0;
}

void init(int* cards, int n) {
	for (int i = 0; i < 2 * n; i++) {
		cards[i] = i + 1;
	}
}

void cut(int* cards, int k, int n) {
	int* ncards = new int[2 * n];
	for (int i = 0; i < k; i++) {
		ncards[(2 * n - k) + i] = cards[i];
	}
	for (int i = 0; i < (2 * n - k); i++) {
		ncards[i] = cards[k + i];
	}

	for (int i = 0; i < 2 * n; i++) {
		cards[i] = ncards[i];
	}
}

void refullShuffle(int* cards, int n) {
	int* ncards = new int[2 * n];
	for (int i = 0; i < n; i++) {
		ncards[2 * i] = cards[i];
		ncards[2 * i + 1] = cards[n + i];
	}

	for (int i = 0; i < 2 * n; i++) {
		cards[i] = ncards[i];
	}
}

Measured memory_bytes: 1968
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    long long a,b,c,d=0,i;
    cin>>a>>b;
    if(a==1)
    c=300000;
    else if(a==2)
    c=200000;
    else if(a==3)
    c=100000;
    else
    c=0;
    if(b==1)
    c=c+300000;
    else if(b==2)
    c=c+200000;
    else if(b==3)
    c=c+100000;
    else
    c=c+0;
    if(a==1&&b==1)
    c=c+400000;
    cout<<c;
    return 0;
}


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

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

signed main() {
	int n , m ;cin >> n >> m;
	int ans = n * (n - 1);
	ans /= 2;
	int x = m * (m - 1);
	x /= 2;
	w << ans + x;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main()
{
	int n; ll c; cin>>n>>c;
	ll h[200001];
	for(int i=1; i<=n; i++) cin>>h[i];
	deque<P> line;
	ll dp=0;
	for(int i=1; i<=n; i++){
		if(i>1){
			while(line.size()>1){
				ll a1=line[0].first, b1=line[0].second;
				ll a2=line[1].first, b2=line[1].second;
				if(a1*h[i]+b1<a2*h[i]+b2) break;
				line.pop_front();
			}
			ll a1=line[0].first, b1=line[0].second;
			dp=a1*h[i]+b1+h[i]*h[i]+c;
		}
		if(i==n) break;
		ll a0=-2*h[i], b0=h[i]*h[i]+dp;
		if(!(line.size()>=1 && line.back().first==a0 && line.back().second<=b0)){
			while(line.size()>1){
				ll a1=line[line.size()-1].first, b1=line[line.size()-1].second;
				ll a2=line[line.size()-2].first, b2=line[line.size()-2].second;
				if((b1-b2)*(a1-a0)<(b0-b1)*(a2-a1)) break;
				line.pop_back();
			}
			line.push_back(P(a0, b0));
		}
	}
	cout<<dp<<endl;
	return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
//typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<std::min(n*a,b)<<endl;
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	string s = "";
	cin >> s;

	int m = 0;
	string buf = "";
	string a, b = "";
	for (int i = 2; i < s.size(); i += 2)
	{
		buf = s.substr(0, s.size() - i);
		if (buf.substr(0, buf.size() / 2) == buf.substr(buf.size() / 2))
		{
			int c = buf.length();
			m = max(m, c);
		}
	}

	COUT(m);

	return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a[3];
	int b[101] = {};
	int count = 0;
	cin >> a[0] >> a[1] >> a[2];
	REP(i,3) b[a[i]]++;
	REP(i,101){
		if(b[i]>0) count++;
	}
	cout << count << endl;

	
//////////////////////////////////////////////
}


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

using namespace std;

int main(){
  long long n, m, a[100009], b[100009], h[100009];
  vector<long long> N[100009];
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> h[i];
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    N[a[i]].push_back(b[i]);
    N[b[i]].push_back(a[i]);
  }
  long long cnt=0;
  for(int i=0;i<n;i++){
    bool ok=true;
    for(int j=0;j<N[i].size();j++){
      if(h[i]<=h[N[i][j]]){
        ok=false;
      }
    }
    if(ok)cnt++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 11772
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if(a < b){
    for (int i = 0; i < b; i++) {
      cout << a;
    }
    cout << endl;
  }else{
    for (int i = 0; i < a; i++) {
      cout << b;
    }
    cout << endl;
  }
}


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 2e5 + 5;

int arr[maxr];
int32_t main()
{
	GO;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	map<int, int> m;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += m[i + 1 - arr[i]];
		m[arr[i] + i + 1] ++;
	}
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 27960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp107 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long N = st[0];
            long K = st[1];

            var a = new long[N];
            var b = new long[N];

            var ans = new long[100010];

            for (int i = 0; i < N; i++) {
                var x = Console.ReadLine().Split().Select(long.Parse).ToArray();

                a[i] = x[0];
                b[i] = x[1];

                ans[a[i]] += b[i];
            }



            for (int i = 0; i < 100010; i++) {
                K -= ans[i];

                if (K <= 0) {
                    Console.WriteLine(i);
                    break;
                }
            }

                

        }
    }
}


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

int main() {
  int s;
  cin >> s;
  
  if (s==1 || s==2) cout << 4 << endl;
  else {
    int ans = 1;
    while (s!=4) {
      ans++;
      if (s%2==0) s /= 2;
      else s = s * 3 + 1;
    }
    cout << ans+3 << endl;
  }
}

Measured memory_bytes: 256
n, k, *a = map(int, open(0).read().split())
g = [0] * (k + 1)
for i in range(min(a), k + 1):
	s = set(g[i - x] for x in a if i >= x)
	r = 0
	while r in s:
		r += 1
	g[i] = r
print("First" if g[-1] else "Second")

Measured memory_bytes: 44508
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main 
{
	static int n, k;
	static long[] a, lsum, rsum;
	static long MOD = 1000000007l;
	                //1000000007
	
	static long[] fact;
	static long[] afact;
	
	static long nCr(int n, int r)
	{
		return ((fact[n] * afact[n-r])%MOD * afact[r])%MOD;
	}
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		a = new long[n];
		
		fact = new long[100001];
		afact = new long[100001];
		
		fact[0] = 1;
		BigInteger bimod = new BigInteger(Long.toString(MOD));
		BigInteger bi;
		for(int i = 0; i <= 100000; i++)
		{
			if(i>0)fact[i] = (fact[i-1] * i)%MOD;
			bi = new BigInteger(Long.toString(fact[i]));
			afact[i] = bi.modInverse(bimod).longValueExact();
		}
		
//		System.out.println("Done " + afact[0]);
		
		
		long sum = 0;
		
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextLong();
			sum = (sum + a[i])%MOD;
		}
		
		Arrays.sort(a);
		
		//count rightsums and leftsums
		lsum = new long[n];
		rsum = new long[n];
		
		for(int i = 0; i < n; i++)
		{
			lsum[i] = a[i];
			if(i>0)lsum[i] = (lsum[i] + lsum[i-1])%MOD;
			
			if(i>0)rsum[i] = (rsum[i-1] - a[i-1])%MOD;
			else rsum[i] = sum;
		}
		
//		System.out.println(Arrays.toString(a));
//		System.out.println(Arrays.toString(lsum));
//		System.out.println(Arrays.toString(rsum));
		//count difsums
		
		long an = 0;
		
		if(k>1)
			for(int d = k-1; d < n; d++)
			{
				long difsum = rsum[d] - lsum[n-d-1];
				long ncr = nCr(d-1,k-2);
//				System.out.println("d=" + d + ": difsum " + difsum + " " + ncr + ", n " + (d-1) + ", r " + (k-2));
				an = (an + (difsum*nCr(d-1,k-2))%MOD)%MOD;
			}
		an = an%MOD;
		if(an<0)an+=MOD;
		
		System.out.println(an);
	}

}


Measured memory_bytes: 85680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			int result = 1;
			for (int i = 0; i < n; i++) {
				result = Math.min(result * 2, result + k);
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 35712
#include <iostream>

int main()
{
  int n;
  long long int y;
  std::cin >> n >> y;
  for ( int i = 0; i <= n; i++ ) {
    for ( int j = 0; j <= n - i; j++ ) {
      long long total = i * 10000 + j * 5000 + (n-i-j) * 1000;
      if ( total == y ) {
        std::cout << i << ' ' << j << ' ' << n - i -j << std::endl;
        return 0;
      }
    }
  }
  std::cout << "-1 -1 -1\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws NumberFormatException,IOException {
		
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder output = new StringBuilder();
		
		int n = Integer.parseInt(input.readLine());
		
		Deque<Integer> List = new ArrayDeque<Integer>();
		
		for (int i = 0; i < n; i++) {
			
			String order = input.readLine();
			
			if(order.charAt(0) == 'i') { List.push(Integer.parseInt(order.substring(7))); }
			else if(order.charAt(6)=='F') { List.removeFirst(); }
			else if(order.charAt(6)=='L') { List.removeLast(); }
			else { List.remove(Integer.parseInt(order.substring(7))); }
		}
		
		output.append(List.poll());
		for(int num2 : List) { output.append(" ").append(num2); }
		System.out.println(output);
	}
}



Measured memory_bytes: 125168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int a=s.size(),b=t.size();
    int dp[a+1][b+1],i,j;
    //cout<<a<<b;
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            if(j==0 || i==0)
            {
                dp[i][j]=0;
            }
            else if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string n;
    //cout<<dp[a][b] ;
    i=a; j=b;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            n=n+s[i-1];
            i--; j--;
        }
        else if(dp[i-1][j]==dp[i][j])
        {
            i--;
        }
        else
        j--;
        //cout<<i<<j<<endl;
    }
    reverse(n.begin(),n.end());
    cout<<n;
 
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll n,m;
cin>>n>>m;
ll x=0,y=0,a,j=n*(-1)+1;
for(int i=0;i<n;i++){
cin>>a;
x+=a*j;
j+=2;
}
x%=1000000007;
j=m*(-1)+1;
for(int i=0;i<m;i++){
cin>>a;
y+=a*j;
j+=2;
}
y%=1000000007;
cout<<x*y%1000000007;
}

Measured memory_bytes: 256
S = input()

move = 10**100
RL = []
maxlen = 0
l = 0
SS = 'R'
Smember = []
rr = 0
ll = 1
mem = 0
nowR = True
for i,c in enumerate(S):
    if nowR and c=='L':
        nowR = False
    elif not nowR and c=='R':
        # calc
        a = 0
        b = 0
        for i in range(max(rr,ll)):
            if i % 2 == 0:
                a += int(rr>0)
                b += int(ll>0)
            else:
                a += int(ll>0)
                b += int(rr>0)
            rr -= 1
            ll -= 1
        Smember.append(a)
        Smember.append(b)
        rr = 1
        ll = 1
        nowR = True
    else:
        if c == 'R':
            rr += 1
        else:
            ll += 1

a = 0
b = 0
for i in range(max(rr,ll)+1):
    if i % 2 == 0:
        a += int(rr>0)
        b += int(ll>0)
    else:
        a += int(ll>0)
        b += int(rr>0)
    rr -= 1
    ll -= 1
Smember.append(a)
Smember.append(b)

i = 0
flg = False
for a,b in zip(S,S[1:]):
    if a == 'R' and b == 'L':
        print(Smember[i], end=' ')
        flg = True
        i += 1
    elif flg:
        print(Smember[i], end=' ')
        flg = False
        i += 1
    else:
        print(0, end=' ')
if flg:
    print(Smember[-1])
else:
    print(0)

Measured memory_bytes: 4976
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    double p[n + 1], dp[n + 1][n + 1], h = 0;
    for (int i = 1; i <= n; i++) cin >> p[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        dp[i][i] = dp[i - 1][i - 1] * p[i];
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j < i; j++)
        {
            dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
        }
    }
    for (int i = n / 2 + 1; i <= n; i++) h += dp[n][i];
    cout << fixed << setprecision(10) << h;
}

Measured memory_bytes: 49812
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;


int h, w;
const int H = 501;
string s[H];
string r[H], b[H];

int main(void){
  cin >> h >> w;
  REP(i, 0, h) {
    cin >> s[i];
    r[i] = b[i] = s[i];
  }
  REP(i, 1, h - 1) {
    if (i % 2 == 0) {
      REP(j, 1, w - 1) {
	r[i][j] = '#';
      }
    } else {
      REP(j, 1, w - 1) {
	b[i][j] = '#';
      }
    }
  }
  REP(i, 1, h - 1) {
    r[i][w - 1] = '#';
  }
  REP(i, 1, h - 1) {
    b[i][0] = '#';
  }
  REP(i, 0, h) {
    cout << r[i] << endl;
  }
  cout << endl;
  REP(i, 0, h) {
    cout << b[i] << endl;
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,d){
        res += s[i][now[i]];
        last[now[i]] = i;
        rep(j,26) res -= c[i] * (i - last[j]);
    }
    return res;
}

int main(){
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd(0,25);

    cin >> d;
    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);now.resize(d);
    rep(i,d){now[i] = i%26;t[i] = now[i];}
    best = score();
    rep(_,10){
        rep(i,d)now[i] = rnd(mt);
        ll now_s = score();
        if(best < now_s){
            best = now_s;
            swap(t,now);
        }
    }


    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int main(){
  long long int m,rd,cd,rr,cr;
  cin>>m>>rd>>rr>>cd>>cr;
  long long int l;
  long long int r;
  long long int x;
  long long int y;


  if(cd==0){
    x=-1;
  }else{
  l=0;
  r=1000000000002LL;
  x=r/2;
  while(r-l>1){
    //cout << x <<" "<<x*rd/100<<" "<<l<<" "<<r<<" "<<endl;
    if(x*rd/100>=cd){
      r=x;
    }else{
      l=x;
    }
    x=(l+r)/2;
  }
}

if(cr==0){
  y=-1;
}else{
  l=0;
  r=1000000000002LL;
  y=r/2;
  while(r-l>1){
    if(y*rr/100>=cr){
      r=y;
    }else{
      l=y;
    }
    y=(l+r)/2;
  }
}

  x++;
  y++;
  //cout <<m<<" "<<x<<" "<<y<<endl;
  long long int ans=m-x-y+((((x*rd/100)-cd)*100/rd)+(((y*rr/100)-cr)*100/rr));
  if(m-x-y<0){
    cout << -1 << endl;
    return 0;
  }

if(ans<0){
  cout << -1 << endl;
}else{
  cout << ans << endl;
}

  return 0;
}

Measured memory_bytes: 3100
import sys
input = sys.stdin.readline

import itertools
from collections import defaultdict
import numpy as np

N = int(input())
X = set(int(x) for x in input().split())

# 2は素数でないとして扱って
U = 10**7 + 100
is_prime = np.zeros(U,dtype=np.bool)
is_prime[3::2] = 1
for p in range(3,U,2):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::p+p] = 0

# imosで値を入れないといけない場所
X ^= set(x+1 for x in X)

EV = set(x for x in X if x%2 == 0)
OD = set(x for x in X if x%2 == 1)

# 1手でとれるペアを見つける：最大マッチング
# 奇点から偶点に辺を貼る
source = -1
sink = -2
graph = defaultdict(dict)
for x in EV:
    graph[x][sink] = 1
    graph[sink][x] = 0
for x in OD:
    graph[source][x] = 1
    graph[x][source] = 0
for x,y in itertools.product(OD,EV):
    if is_prime[abs(x-y)]:
        graph[x][y] = 1
        graph[y][x] = 0

def bfs():
    level = defaultdict(int)
    q = [source]
    level[source] = 1
    d = 1
    while q:
        d += 1
        if level[sink] != 0:
            break
        qq = []
        for x in q:
            for y,cap in graph[x].items():
                if cap==0 or level[y]!=0:
                    continue
                level[y] = d
                qq.append(y)
        q = qq
    return level

def dfs(v,f,level,itr):
    if v == sink:
        return f
    for w,cap in itr[v]:
        if cap==0 or level[w]!=level[v]+1:
            continue
        d = dfs(w,min(f,cap),level,itr)
        if d:
            graph[v][w] -= d
            graph[w][v] += d
            return d
    return 0

def max_flow():
    flow = 0
    while True:
        level = bfs()
        if level[sink] == 0:
            return flow
        itr = {v:iter(graph[v].items()) for v in graph}
        while True:
            f = dfs(source,10**9,level,itr)
            if f == 0:
                break
            flow += f

f = max_flow()

od = len(OD); ev = len(EV)
answer = f
od -= f; ev -= f
answer += 2*(od//2); od %= 2
answer += 2*(ev//2); ev %= 2
if od:
    answer += 3
print(answer)

Measured memory_bytes: 22488
/*input
1000000
*/
/**
    Author: Kristopher Paul
    Date Created: 08-09-2020
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

//Uncomment for File I/O
//ifstream fin("input.in")

//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    int fac[n+1] = {};
    FOR(i,1,n+1){
        fac[i] = 1;
    }
    fac[1] = 1;
    FOR(i,2,n+1){
        for(int j = i;j <= n;j += i){
            fac[j]++;
        }
    }
    int ans = 0;
    FOR(i,1,n){
        ans += fac[i];
    }
    cout << ans << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 11408
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
#include <cstring>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
using Graph = vector<vector<ll>>;
using P = pair<ll, ll>;

/* 4 方向への隣接頂点への移動を表すベクトル */
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int MAX_A = 100000;
const int MAX_B = 1000000000;
ll H, W;
ll sX, sY, gX, gY;
ll N, M;
vector<int> graph;
ll X[MAX_A];
ll L[MAX_A];
P ps[MAX_A];

int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
int main() {
	cin >> N;
	Graph armWidth = Graph(N,vector<ll>(2));
	rep(i,N) {
		cin >> X[i] >> L[i];
	}
	rep(i,N) {
		ps[i] = P(X[i] + L[i], X[i] - L[i]);
	}
	sort(ps, ps + N);
	int cur = -MAX_B;
	int ans = 0;
	rep(i,N) {
		if (cur<=ps[i].second) {
			ans++;
			cur = ps[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11860
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn make_count_vec(s: &Vec<char>) -> (Vec<i32>, Vec<i32>) {
    let mut s_a_count = vec![0; s.len() + 1];
    let mut s_b_count = vec![0; s.len() + 1];

    for (i, &c) in s.iter().enumerate() {
        s_a_count[i + 1] = s_a_count[i];
        s_b_count[i + 1] = s_b_count[i];
        if s[i] == 'A' {
            s_a_count[i + 1] += 1;
        } else {
            s_b_count[i + 1] += 1;
        }
    }
    (s_a_count, s_b_count)
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let t = read::<String>().chars().collect::<Vec<_>>();

    let mut group_0 = HashSet::new();
    group_0.insert((1, 0));
    group_0.insert((0, 2));
    group_0.insert((2, 1));

    let mut group_1 = HashSet::new();
    group_1.insert((0, 1));
    group_1.insert((2, 0));
    group_1.insert((1, 2));

    let mut group_2 = HashSet::new();
    group_2.insert((2, 2));
    group_2.insert((1, 1));
    group_2.insert((0, 0));

    let (s_a_count, s_b_count) = make_count_vec(&s);
    let (t_a_count, t_b_count) = make_count_vec(&t);

    let search_group = |a_count: i32, b_count: i32| -> usize {
        let a_mod = a_count % 3;
        let b_mod = b_count % 3;
        if group_0.contains(&(a_mod, b_mod)) {
            return 0;
        }
        if group_1.contains(&(a_mod, b_mod)) {
            return 1;
        }
        if group_2.contains(&(a_mod, b_mod)) {
            return 2;
        }
        unreachable!();
    };

    let q: usize = read();
    for i in 0..q {
        let v = read_vec::<usize>();
        let (s_start, s_end, t_start, t_end) = (v[0] - 1, v[1] - 1, v[2] - 1, v[3] - 1);
        let s_a = s_a_count[s_end + 1] - s_a_count[s_start];
        let s_b = s_b_count[s_end + 1] - s_b_count[s_start];
        let t_a = t_a_count[t_end + 1] - t_a_count[t_start];
        let t_b = t_b_count[t_end + 1] - t_b_count[t_start];

        if search_group(s_a, s_b) == search_group(t_a, t_b) {
            println!("YES");
        } else {
            println!("NO");
        }
    }
}


Measured memory_bytes: 6652
#include <iostream>
#include <map>

using namespace std;

int h[1501],w[1501];
int main(){
  int N,M;
  while(cin>>N>>M&&(N>0&&M>0)){
    for(int i=0;i<N;++i){
      cin>>h[i];
    }
    for(int i=0;i<M;++i){
      cin>>w[i];
    }

    map<int,int> hmap,wmap;
    for(int i=0;i<N;++i){
      int hsum = 0;
      for(int j=i;j<N;++j){
        hmap[hsum+=h[j]]++;
      }
    }
    for(int i=0;i<M;++i){
      int wsum = 0;
      for(int j=i;j<M;++j){
        wmap[wsum+=w[j]]++;
      }
    }

    long num = 0;
    for(const auto &p:hmap){
      num += wmap[p.first]*p.second;
    }
    cout<<num<<endl;
  }
  return 0;
}

Measured memory_bytes: 34332
#include<bits/stdc++.h>
using namespace std;
main()
{	
  int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0)
    cout<<1;
 else if(x2==0)
    cout<<2;
  else if(x3==0)
    cout<<3;
  else if(x4==0)
    cout<<4;
  else if(x5==0)
    cout<<5;
}

Measured memory_bytes: 3596
n,q = map(int,input().split())
s= input()
ans = [int(s[i:i+2]=='AC') for i in range(n)]
ans = [0] + ans
from itertools import accumulate
ans = list(accumulate(ans))
for _ in range(q):
  l,r = map(int,input().split())
  print(ans[r-1]-ans[l-1])



Measured memory_bytes: 8556
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        long[][] lr=new long[n][2];
        for(int i=0;i<n;i++){
            long x=fsc.nextLong();
            long l=fsc.nextLong();
            lr[i][0]=x-l;
            lr[i][1]=x+l;
        }
        fsc.close();
        Arrays.sort(lr, (u, v)->u[1]>v[1]?1:u[1]<v[1]?-1:0);
        int i=0;
        int ans=0;
        L:while(i<n){
            ans++;
            for(int j=i+1;j<n;j++){
                if(lr[j][0]>=lr[i][1]){
                    i=j;
                    continue L;
                }
            }
            break;
        }
        System.out.println(ans);
    }
    

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 29284
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
  ll A, B, C, K;
  cin >> A >> B >> C>> K;
  ll num = min(K, A);
  ll ans = num;
  K -= num;
  num = min(K, B);
  K -= num;
  num = min(C, K);
  ans -= num;
  cout<< ans << endl;
    return 0;
}


Measured memory_bytes: 3608
N,D = map(int,input().split())
List=[list(map(int,input().split())) for i in range(N)]

def distance(lst1, lst2):
  dis = 0
  for i in range(len(lst1)):
    dis += (lst1[i] - lst2[i])**2
  dis = dis**(1/2)
  return dis

def comb(lst):
  res = 0
  for i in range(len(lst)-1):
    for j in range(i+1, len(lst)):
      if distance(lst[i], lst[j]).is_integer():
        res += 1
  return res

print(comb(List))

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

int	main() {
	int X, Y;
	cin >>X >>Y;
	int S=0;
	if (X<4)
		S +=4-X;
	if (Y<4)
		S +=4-Y;
	if (X+Y==2)
		S +=4;
	cout <<S;
	if (S>0)
		cout <<"00000" <<endl;
	cout <<endl;
	return 0;
}



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

 main() {
vector<pair<int,int>>a(5);
for(int i=0;i<5;i++){
    int z;
    cin >>z;

    int zz = z%10;
    if(zz!=0){
        zz = 10-zz;
    }
    a.at(i)=make_pair(zz,z);
}
sort(a.begin(),a.end());
int ans =0;
for(int i=0;i<5;i++){
    if(i==4){
        ans+=a.at(i).second;
        break;
    }
    else{
        ans+=a.at(i).first+a.at(i).second;
    }
}
cout << ans <<endl;
 }




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int, int> P;


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

	int N, cou = 0;
	cin >> N;
	map<string, int> mp;
	rep(i,N){
		string S;
		cin >> S;
		if(!mp[S]) cou++;
		mp[S]++;
	}
	cout << cou << endl;
}

Measured memory_bytes: 19272
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int R, G;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> R >> G;

    // (R + b)/2 = G
    // R + b = 2G
    // b = 2G - R

    int ans = 2 * G - R;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	int ans = N / 500 * 1000;
	N %= 500;
	ans += N / 5 * 5;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n,m,x;
	scanf("%lld%lld%lld",&n,&m,&x);
	ll s1=0,s2=0;
	rep(i,0,m){
		ll t;
		scanf("%lld",&t);
		if(t<x)s1++;
		else s2++;
	}
	printf("%lld",min(s1,s2));
}

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

using namespace std;

const int MAX_N = 100000;

int n, a[MAX_N + 1], aSort[MAX_N + 1];

int binSearch(int x) {
    int l = 1, r = n, m;

    while (r - l > 1) {
        m = (l + r) / 2;

        if (aSort[m] > x) {
            r = m;
        } else {
            l = m;
        }
    }

    for (int i = l; i <= r; i++) {
        if (aSort[i] == x) {
            return i;
        }
    }
}

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

    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }

    for (int i = 1; i <= n; i++) {
        aSort[i] = a[i];
    }

    sort(aSort + 1, aSort + n + 1);

    for (int i = 1; i <= n; i++) {
        a[i] = binSearch(a[i]);
    }

    int ans = 0;

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

    ans /= 2;

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

    return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}, k;
	cin >> k;

	cout << a[k - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
i = 0
while True:
    if not x-i in p:
        print(x-i)
        break
    elif not x+i in p:
        print(x+i)
        break
    i += 1


Measured memory_bytes: 9172
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        if(X < A) {
            System.out.println(0);
        }else {
            System.out.println(10);
        }
    }
}

Measured memory_bytes: 21972