akhauriyash/Code-Regression huggingface dataset:
import io
import os


input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
N, M = [int(x) for x in input().split()]
edges = [[int(x) for x in input().split()] for i in range(M)]

from collections import defaultdict

graph = defaultdict(list)
for u, v in edges:
    graph[u].append(v)
    graph[v]

# https://atcoder.jp/contests/practice2/submissions/16566401
def scc(G):
    preorder = {}
    lowlink = {}
    seen = [False] * N
    scc_queue = []
    i = 0  # Preorder counter
    ans = []
    for source in range(N):
        if seen[source]:
            continue
        queue = [source]
        while queue:
            v = queue[-1]
            if v not in preorder:
                i = i + 1
                preorder[v] = i
            done = True
            for w in G[v]:
                if w not in preorder:
                    queue.append(w)
                    done = False
                    break
            if done:
                lowlink[v] = preorder[v]
                for w in G[v]:
                    if seen[w]:
                        continue
                    if preorder[w] > preorder[v]:
                        lowlink[v] = min([lowlink[v], lowlink[w]])
                    else:
                        lowlink[v] = min([lowlink[v], preorder[w]])
                queue.pop()
                if lowlink[v] == preorder[v]:
                    scc = {v}
                    seen[v] = True
                    while scc_queue and preorder[scc_queue[-1]] > preorder[v]:
                        k = scc_queue.pop()
                        scc.add(k)
                        seen[k] = True
                    ans.append(scc)
                else:
                    scc_queue.append(v)
    return ans


SCC = list(scc(graph))

DEBUG = False
print(len(SCC))
if DEBUG:
    seen = set()
for comp in reversed(SCC):
    print(len(comp), *comp)
    if DEBUG:
        for u in comp:
            for v in graph[u]:
                assert v not in seen
        seen.update(comp)


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	string t1, t2, t3;
	t1 = s1[0];
	t2 = s2[0];
	t3 = s3[0];

	transform(ALL(t1), t1.begin(), ::toupper);
	transform(ALL(t2), t2.begin(), ::toupper);
	transform(ALL(t3), t3.begin(), ::toupper);

	cout << t1 << t2 << t3 <<endl;
	return 0;
}

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

using namespace std;
using namespace atcoder;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

const int MaxVal = 300000;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    segtree<int, op, e> st(MaxVal + 1);
    for (int i = 0; i < n; ++i) {
        int l = max(0, a[i] - k);
        int r = min(MaxVal, a[i] + k) + 1;
        st.set(a[i], st.prod(l, r) + 1);
    }
    cout << st.all_prod() << "\n";
    return 0;
}


Measured memory_bytes: 9628
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        long[] A = new long[N+1];
        for (int i = 1; i <= N; i++) {
            A[i] = scanner.nextLong();
        }

        for (int i = K+1; i <= N; i++) {
            if ( A[i-K] < A[i]){
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

    }

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


Measured memory_bytes: 61064
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int,int> p2;
typedef pair<p2,int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 1 + 1e18;
const ll MAX = 5+ 4e2;

ll N,a[MAX];
ll dp[MAX][MAX];

ll sum(int l,int r)
{
    return a[r] - a[l-1];
}

int main()
{
    cin >> N;
    for(int i=1; i<=N; i++)
    {
        cin >> a[i];
        a[i] += a[i-1];
    }
    for(int i=N; i>0; i--)
        for(int j=i+1; j<=N; j++)
        {
            dp[i][j] = INF64;
            for(int k=i; k<j; k++)
                dp[i][j] = min( dp[i][j],dp[i][k] + dp[k+1][j] );
            dp[i][j] += sum(i,j);
        }
    cout << dp[1][N] << endl;
    return 0;
}


Measured memory_bytes: 1536
N = int(input())

alp = 'abcdefghijklmnopqrstuvwxyz'

num = [26**i for i in range(1, 15)]

n1 = 0
n2 = 0

for i, n in enumerate(num):
    n1 += n
    if n1 >= N:
        n3 = N - n2
        k = i + 1
        break
    n2 = n1

ans = ''

if n3 % 26 == 0:
    n3 = n3-1
    for i in range(k):
        i = k-i-1
        if i == 0:
            ans += 'z'
            break
        if  n3 == 26**(i+1):
            ans += 'z'*(i+1)
            break
        n = n3 // 26**i
        n3 %= 26**i
        ans += alp[n]
else:        
    for i in range(k):
        i = k-i-1
        if i == 0:
            ans += alp[n3-1]
            break
        if  n3 == 26**(i+1):
            ans += 'z'*(i+1)
            break
        n = n3 // 26**i
        n3 %= 26**i
        ans += alp[n]

print(ans)


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+ 5;
const int M = 1e7 + 5;
const int INF=1e9+7;
const int mod=1e9+7;
const double eps=1e-9;
typedef long long ll;
typedef pair<int,int>pi;

vector <ll> solve(vector <ll> a){
    ll n = a.size();
    vector <ll> pref(n+2, 0);
    for(int i = 0; i < n; i++){
        int l = max(0LL,i-a[i]);
        int r = min(n-1LL, i+a[i]);
        pref[l]++;
        pref[r+1]--;
    }
    for(int i = 0; i < n; i++){
        if(i) pref[i] += pref[i-1];
        a[i] = pref[i];
    }
    return a;
}

int check(vector <ll> a){
    int n = a.size();
    for(int i = 0; i < n; i++){
        if(a[i] != n) return 0;
    }
    return 1;
}


int main() {
    int x, n;
    cin >> x >> n;
    if(n == 0){
        cout << x;
        return 0;
    }
    vector <int> vec(n);
    set <int> se;
    for(int i = 0; i < n; i++){
        cin >> vec[i];
        se.insert(vec[i]);
    }
    int ans = -1, dif = x;

    for(int i = 0; i <= 101; i++){
        if(!se.count(i)){
            if(ans == -1){
                ans = i;
                dif = abs(x-i);
            } else{
                if(abs(x-i) < dif){
                    ans = i;
                    dif = abs(x-i);
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define MAX 500000
#define N 1000000000

int L[MAX/2+2],R[MAX/2+2];
int c;

void merge(int A[],int n,int l,int m,int r);
void mergeSort(int A[],int n,int l,int r);

int main()
{
	int A[MAX],n,i;
	c=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	
	mergeSort(A,n,0,n);
	
	for(i=0;i<n;i++)
	{
	if(i)
		{
			printf(" ");
		}
		printf("%d",A[i]);
	}
	
	printf("\n");
	printf("%d\n",c);

}

void merge(int A[],int n,int l,int m,int r)
{
	int i,j,k;
	int n1=m-l;
	int n2=r-m;
	
	for(i=0;i<n1;i++)
	{
		L[i] = A[l+i];
	}
	
	for(i=0;i<n2;i++)
	{
		R[i] = A[m+i];
	}
	
	L[n1]=R[n2]=N;
	
	for(i=0,j=0,k=l;k<r;k++)
	{
		c++;
		if(L[i]<=R[j])
		{
			A[k]=L[i++];
		}
		else
		{
			A[k]=R[j++];
		}
	}

}

void mergeSort(int A[],int n,int l,int r)
{
	int m;
	
	if(l+1<r)
	{
		m=(l+r)/2;
		mergeSort(A,n,l,m);
		mergeSort(A,n,m,r);
		merge(A,n,l,m,r);
	}
}


Measured memory_bytes: 5688
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int cardCount = int.Parse(Reader.ReadLine());
        int[] cards = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).OrderByDescending(a => a).ToArray();

        int alice = 0;
        int bob = 0;
        for (int i = 0; i < cards.Length; i++) {
            if(i%2==0) {
                alice += cards[i];
            } else {
                bob += cards[i];
            }
        }
        int ans = alice - bob;
        Console.WriteLine(ans);
    }



    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



4
20 18 2 18



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
// ~zaletaet~

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
struct chash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + RANDOM);
  }
};

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int32_t main() {
  fre("");
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  string s;
  cin >> s;
  cout << s[0] << s[1] << s[2];

  return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation
// gp_hash_table<T, U, chash> -> fast unordered_map
// m.count(x) <-> (m.find(x) != m.end())


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3084
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.12 03:04:53
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;


struct edge { int to, cost; };
long long LLINF = 1e18 + 1;


void bellman_ford(int s, const std::vector< std::vector< edge > > &G, std::vector< long long > &d) {
    const int V = G.size();
    d = std::vector< long long >(V, LLINF);
    d[s] = 0;
    bool update = true;
    int i = 0;
    while (update)
    {
        update = false;
        for (int j = 0; j < V; j++)
        {
            for (const edge &e : G[j])
            {
                if (d[j] != -LLINF && d[j] != LLINF && d[j] + e.cost < d[e.to]) {
                    d[e.to] = d[j] + e.cost;
                    if (i == V - 1) {
                        d[e.to] = -LLINF;
                    }
                    update = true;
                }
                else if (d[j] == -LLINF && d[e.to] != -LLINF) {
                    d[e.to] = -LLINF;
                    update = true;
                }
            }
        }
        if (i < V - 1) i++;
    }
}
int main() {
    int n,m;cin >> n >> m;
    vector<vector<edge>> g(n);
    for (int i = 0; i < m; i++) {
        int a,b,c;cin >> a >> b >> c;
        a--;b--;
        g[a].push_back({b,-c});
    }
    vector<ll> d;
    bellman_ford(0,g,d);
    if (d[n-1] == -LLINF) {
        puts("inf");
    }
    else {
        cout << -d[n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
// be name khoda
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,a,b,d,ans=0;
    cin >> n >> d;
    while (n--) 
    {
        cin >> a >> b;
        if (hypot(a,b)<=d) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3696
function Main(input) {
	var count = 0;
  for(var i = 0; i < input.length; i++){
    var tmp = input.slice(i , i + 1);
    if(tmp == "x"){
       count++;
      if(count >= 8){
         console.log("NO");
        return;
         }
       }
  }
  console.log("YES");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
#include <iostream>
#include<algorithm>
#include<cmath>
using namespace std;
bool a[1000000001];
int main()
{
    int n,m,k=0;
    cin>>n;
    for(int i=0;i<n;i++){cin>>m;a[m]=1;}
    cin>>m;
    for(int i=0;i<m;i++){cin>>n;if(a[n])k++;}
    cout<<k<<endl;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

  vector<int> ans(s.length());

  int count = 0;
  rep(i, s.length()) {
    if(s[i] == 'R') {
      count++;
    } else {
      if(count > 0) {
        ans[i] += count / 2;
        ans[i - 1] += count / 2;
        if(count % 2 == 1) ans[i - 1]++;
      }
      count = 0;
    }
  }

  count = 0;
  rrep(i, s.length()) {
    if(s[i] == 'L') {
      count++;
    } else {
      if(count > 0) {
        ans[i] += count / 2;
        ans[i + 1] += count / 2;
        if(count % 2 == 1) ans[i + 1]++;
      }
      count = 0;
    }
  }

  rep(i, s.length()) {
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


ll N;

bool is_753(ll n) {
	ll flag[3] = { 0 };
	rep(i, 12) {
		ll tmp = n;
		rep(j, i) tmp /= 10;
		tmp %= 10;
		if (tmp == 7) ++flag[0];
		if (tmp == 5) ++flag[1];
		if (tmp == 3) ++flag[2];
	}
	if (flag[0] == 0 || flag[1] == 0 || flag[2] == 0) return false;
	else return true;
}

ll dfs(ll n) {
	if (n > N) return 0;

	ll ret = 0;
	if (is_753(n)) ++ret;

	ret += dfs(n * 10 + 7);
	ret += dfs(n * 10 + 5);
	ret += dfs(n * 10 + 3);

	return ret;

}


int main() {
	cin >> N;

	cout << dfs(0) << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X;
ll mo=998244353;
ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X;
	int n1,n2;
	ll ret=0;
	
	// S<X
	for(n1=0;n1<=N;n1++) for(n2=0;n1+n2<=N&&n1+n2*2<X;n2++) {
		(ret+=comb(N,n1)*comb(N-n1,n2))%=mo;
	}
	// all 2
	if(X%2) {
		for(n2=0;n2<=N;n2++) if(2*n2>X) (ret+=comb(N,n2))%=mo;
	}
	for(n2=1;n2<=N&&n2*2<X-1;n2++) {
		int lef=X-1-2*n2;
		for(n1=1;n1<=lef;n1++) {
			if((lef-n1)%2) continue;
			int n22=(lef-n1)/2;
			if(n1+n22+2*n2>N) continue;
			(ret+=comb(n1+n22,n22)*comb(N,n1+n22+2*n2))%=mo;
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;
    int cnt[n] = {};
    rep(i, 0, n) {
        int a;
        cin >> a;
        cnt[a - 1]++;
    }

    sort(cnt, cnt + n);
    int ans = 0;
    rep(i, 0, n - k) ans += cnt[i];

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


Measured memory_bytes: 1024
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
int main() {
  std::cout.tie(0); std::ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.length();
  S.push_back('R');
  vector<int> ans(N, 0);
  int l = 0, r = 1;
  int pos = 0;
  for (int i = 1; i <= N; ++i) {
    if (S[i] == 'R')++r;
    else if (S[i] == 'L')++l;
    if (S[i - 1] == 'R' && S[i] == 'L')pos = i - 1;
    else if (S[i - 1] == 'L' && S[i] == 'R') {
      --r;
      ans[pos] = ans[pos + 1] = (r + l) / 2;
      if ((r + l) % 2 == 1)++ans[pos + (r % 2 ? 0 : 1)];
      l = 0, r = 1;
    }
  }
  for (auto& v : ans)cout << v << " ";
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

struct P {
    int hp;
    int atk;
};

int main()
{
    P t, a;
    cin >> t.hp >> t.atk >> a.hp >> a.atk;

    while (t.hp > 0 || a.hp > 0) {
        a.hp -= t.atk;
        if (a.hp <= 0) {
            cout << "Yes" << endl;
            break;
        }
        t.hp -= a.atk;
        if (t.hp <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    char a;
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i,k) ans += p[i];
    cout << ans << endl;
}


Measured memory_bytes: 3668
def main():
    N = input()
    W = list(map(int, input().split()))
    diff_abs = float('inf')
    for i in range(1, len(W)):
        temp_diff_abs = abs(sum(W[:i]) - sum(W[i:]))
        if temp_diff_abs < diff_abs:
            diff_abs = temp_diff_abs
    print(diff_abs)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;


#define pi 3.141592653589793

vector<pair<int64_t,int64_t>> soinsuu(int64_t n){
    vector<pair<int64_t,int64_t>> ret;
    for(int64_t i=2;i*i<=n;i++){
        if(n%i !=0) continue;
        int64_t ex=0;
        while(n%i ==0){
            ex++;
            n /= i; //n変更することで、それ以降の約数で割り切れることはない
        }
        ret.push_back(make_pair(i,ex));
    }
    //nが素数だった場合
    if(n!=1) ret.push_back(make_pair(n,1));
    return ret;
}

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
  if(A.size()==n+1){
    int now=0;
    rep(i,0,q){
      if(A[b[i]]-A[a[i]]==c[i]) now+=d[i];
    }
    ans=max(ans,now);
    return;
  }

  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }

}
int main(int argc,char **argv){
  int a,p;cin>>a>>p;

  cout<<(3*a+p)/2<<endl;
  }

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int N;
string S;

vector<int> z_algorithm(string s){
    int len = s.length();
    vector<int> Z(len);
    int L, R;
    L = 0, R = 0;
    Z[0] = len;

    for(int i = 1; i < len; i++){
        if(i >= R){
            L = R = i;
            //while(R < len && R-L < L && s[R-L] == s[R]) R++;
            while(R < len && s[R-L] == s[R]) R++;
            Z[i] = R - L;
        }
        else if(i + Z[i-L] < R){
            Z[i] = Z[i-L];
        }
        else{
            L = i;
            //while(R < len && R-L < L && s[R-L] == s[R]) R++;
            while(R < len && s[R-L] == s[R]) R++;
            Z[i] = R - L;
        }
    }

    return Z;
}

int main(){
    cin >> N >> S;

    int ans = 0;
    REP(i,N){
        vector<int> Z = z_algorithm(S);
        int tmp = 0;
        for(int k = 1; k < Z.size(); k++){
            if(Z[k] <= k)
                chmax(tmp, Z[k]);
        }
        //cout << tmp << endl;
        chmax(ans, tmp);
        S.erase(S.begin());
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(void) {
	int i;
	int lena, lenb;
	char buf[128], *ch;
	char a[32], b[32], c[32];

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	sprintf(a, "%s", ch);
	ch = strtok(NULL, " ");
	sprintf(b, "%s", ch);
	ch = strtok(NULL, " ");
	sprintf(c, "%s", ch);

	lena = strlen(a);
	lenb = strlen(b);

	if(a[lena - 1] == '\n') {
		lena -= 1;
	}
	if(b[lenb - 1] == '\n') {
		lenb -= 1;
	}
	if(a[lena - 1] == b[0] && b[lenb - 1] == c[0]) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 1948
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans;
  cin>>N>>H>>W;
  ans=min(N,W);
  N-=ans;
  W-=ans;
  ans=min(H,W);
  H-=ans;
  W-=ans;
  cout<<N<<" "<<H<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<P,P> PP;
vector<PP> vc,nvc;
bool e[51][51][4];
bool vis[51][51][4][2][11];
void dfs(int x,int y,int d,bool m,int t){		//m=magatta
	if(vis[x][y][d][m][t]) return;
	vis[x][y][d][m][t]=1;
	if(t==0){
		nvc.pb(PP(P(x,y),P(d,m)));
	}
	if(!m){
		for(int i=d+1;i<=d+3;i+=2){
			if(e[x][y][i%4]) dfs(x,y,i%4,1,t);
		}
	}
	if(t&&e[x][y][d]){
		int nx=x+dx[d],ny=y+dy[d];
		dfs(nx,ny,d,0,t-1);
	}
}
int main(){
	int N,sx,sy,T;
	cin>>N>>sx>>sy>>T;
	rep(i,N){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(a==c){
			if(b>d) swap(b,d);
			for(int j=b;j<d;j++) e[a][j][1]=e[a][j+1][3]=1;
		}else{
			if(a>c) swap(a,c);
			for(int j=a;j<c;j++) e[j][b][0]=e[j+1][b][2]=1;
		}
	}
	rep(i,4) vc.pb(PP(P(sx,sy),P(i,1)));
	rep(tt,T){
		rep(i,51) rep(j,51) rep(k,4) rep(l,2) rep(m,11) vis[i][j][k][l][m]=0;
		int t;
		char c;
		cin>>t>>c;
		int dir=-1;
		if(c=='E') dir=0;
		if(c=='N') dir=1;
		if(c=='W') dir=2;
		if(c=='S') dir=3;
		for(PP pp:vc){
			dfs(pp.fs.fs,pp.fs.sc,pp.sc.fs,pp.sc.sc,t);
		}
		vc.clear();
		for(PP pp:nvc){
			if(pp.sc.fs==dir) vc.pb(pp);
		}
		nvc.clear();
	}
	vector<P> ans;
	for(PP pp:vc) ans.pb(pp.fs);
	sort(all(ans));
	ans.erase(unique(all(ans)),ans.end());
	for(P p:ans){
		cout<<p.fs<<" "<<p.sc<<endl;
	}
}

Measured memory_bytes: 1540
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	A=[II() for _ in range(5)]
	print(5+(n-1)//min(A))









if __name__ == "__main__":
	main()


Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int comb[4000][4000];
int main() {
    int s;
    cin >> s;
    const ll MOD = 1e9 + 7;
    ll ans = 0;
    for (int i = 0; i < 4000; i++) {
        for (int j = 0; j < 4000; j++) {
            comb[i][j] = 0;
        }
    }
    comb[0][0] = 1;
    for (int i = 1; i < 4000; i++) {
        comb[i][0] = 1;
        for (int j = 1; j < 4000; j++) {
            comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % MOD;
        }
    }
    for (int i = 1; i * 3 <= s; i++) {
        int n = s - 3 * i;
        ans += comb[n+i-1][i-1];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 66128
import numpy as np
import math
#import pdb

tmp = list(map(int, input().strip().split(' ')))
N = tmp[0]
K = tmp[1]
A = list(map(int, input().strip().split(' ')))

N = N - K
cnt = 1
cnt += math.ceil(N / (K - 1))
print(cnt)


Measured memory_bytes: 23368
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll arr[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> arr[i];

    ll ans = 1000000000;
    //第一項目が正の場合

    ll sum = 0, cnt = 0;
    for (int i = 0; i < n; ++i)
    {
        if (i % 2 == 0) //偶数項が正
        {
            if (sum + arr[i] <= 0)
            {
                cnt += 1 - (sum + arr[i]);
                sum = 1;
            }
            else
            {
                sum = sum + arr[i];
            }
        }
        else //奇数項が負
        {
            if (sum + arr[i] >= 0)
            {
                cnt += 1 + (sum + arr[i]);
                sum = -1;
            }
            else
            {
                sum = sum + arr[i];
            }
        }
    }

    ans = cnt;
    sum = 0;
    cnt = 0;

    for (int i = 0; i < n; ++i)
    {
        if (i % 2 == 0) //偶数項が負
        {
            if (sum + arr[i] >= 0)
            {
                cnt += 1 + (sum + arr[i]);
                sum = -1;
            }
            else
            {
                sum = sum + arr[i];
            }
        }
        else //奇数項が正
        {
            if (sum + arr[i] <= 0)
            {
                cnt += 1 - (sum + arr[i]);
                sum = 1;
            }
            else
            {
                sum = sum + arr[i];
            }
        }
    }

    cout << min(ans, cnt) << endl;
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string Input;
            int a_inp, b_inp;
            int a, b;
            int A = 0;
            string A_str;
            int B = 0;
            string B_str;

            Input = Console.ReadLine();
            a = int.Parse(Input.Split(' ')[0]);
            b = int.Parse(Input.Split(' ')[1]);

            a_inp = a;
            b_inp = b;

            //aをb回
            for(int i = 0; i < b_inp; i++)
            {
                A += a;
                a *= 10;
            }

            //bをa回
            for (int i = 0; i < a_inp; i++)
            {
                B += b;
                b *= 10;
            }

            A_str = A.ToString();
            B_str = B.ToString();

            if (string.Compare(A_str,B_str) == -1)
            {
                Console.WriteLine(A_str);
            }
            else
            {
                Console.WriteLine(B_str);
            }
        }

    }
}


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

int main()
{
    int d, t, s;
    cin >> d >> t >> s;

    if (d - t * s <= 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
const int MAXN=100005;
int n;
string s[MAXN];

void pitaj(int x){
	if(s[x]!="")return;
	cout<<x<<"\n"<<flush;
	cin>>s[x];
}

int main(){
	cin>>n;
	pitaj(0);
	if(s[0]=="Vacant")return 0;
	int low=1,high=n-1,mid;
	while(low<high){
		mid=(low+high)>>1;
		pitaj(mid);
		if (s[mid]=="Vacant")return 0;
		if (mid%2==0&&s[0]==s[mid]||
		mid%2==1&&s[0]!=s[mid])
			low=mid+1;
		else
			high=mid-1;
	}
	pitaj(low);
	return 0;
}

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define list_input(x, n) x[n]; rep(i,n){ cin >> x[i];}
#define ll long long

int main(){
  ll result = 0;
  int N;
  cin >> N;
  ll A[N];
  rep(i, N){
    cin >> A[i];
  }
  rep(i, N){
    while (true) {
      if (A[i] % 2 == 0) {
        A[i] /= 2;
        result += 1;
      }else{
        break;
      }
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100009
#define MAXM 30001
#define MOD 1000000007
#define INF 1000000009
#define EPS 1e-7
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int, int> ii;
typedef long long ll;

vector<int> sons[55];
int p[55], m[55];
ll sz[55], cost[55];

void dfs(int u) {
	sz[u] = 1;
	cost[u] = m[u];

	FOR(i, sons[u].size()) {
		int v = sons[u][i];
		dfs(v);
		sz[u] += sz[v];
		cost[u] += cost[v];
	}
}

struct item {
	ll m, cost, rem;
	bool operator < (const item& a) const {
		return m*a.cost > cost*a.m;
	}
};

item greedy[55];

ll kp[55*55*55];

int main() {
	int n, x, d;
	scanf("%d %d %d", &n, &x, &d);
	scanf("%d", &m[1]);
	for (int i = 2; i <= n; i++) {
		scanf("%d %d", &m[i], &p[i]);
		sons[p[i]].pb(i);
	}
	dfs(1);

	for (int i = 1; i <= n; i++) {
		ll rem = 0;
		if (i == 1) rem = x;
		else rem = d - min(n, d);

		greedy[i-1].m = sz[i]; greedy[i-1].cost = cost[i]; greedy[i-1].rem = rem;
	}
	sort(greedy, greedy + n);
//	for (int i = 0; i < n; i++) printf("%lld %lld\n", greedy[i].m, greedy[i].cost);

	for (int profit = 1; profit <= n*n*n; profit++) kp[profit] = INF;

	for (int i = 1; i <= 1; i++) {
		for (int profit = n*n*n; profit >= 0; profit--) {
			for (int b = 1; b <= n && cost[i]*b <= x && sz[i]*b <= profit; b++) {
				kp[profit] = min(kp[profit], kp[profit - sz[i]*b] + cost[i]*b);
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		for (int profit = n*n*n; profit >= 0; profit--) {
			for (int b = 1; b <= min(n, d) && cost[i]*b <= x && sz[i]*b <= profit; b++) {
				kp[profit] = min(kp[profit], kp[profit - sz[i]*b] + cost[i]*b);
			}
		}
	}

	ll ans = 0;
	for (int profit = n*n*n; profit >= 0; profit--) {
		if (kp[profit] > x) continue;
	//	printf("%d %lld\n", profit, kp[profit]);
		ll acum = profit, rem = x - kp[profit];
		for (int i = 0; i < n; i++) {
			if (rem == 0) break;
			acum += greedy[i].m* min(greedy[i].rem, rem/greedy[i].cost);
			rem -= greedy[i].cost*min(greedy[i].rem, rem/greedy[i].cost);
		}
		ans = max(ans, acum);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1280
#include<stdio.h>

#define MAX 251


int main()
{
  int i,a;
  int key[MAX];
  
  scanf("%d",&a);
  
  for(i=1; i<=a; i++)scanf("%ld", &key[i]);
  for(i=1; i<=a; i++){    
    printf("node %d: key = %d, ", i, key[i]);    
    if(i!=1)printf("parent key = %d, ", key[i/2]);
    if(2*i<=a){
      printf("left key = %d, ", key[2*i]);
      if(2*i+1<=a)printf("right key = %d, ", key[2*i+1]);
    }
    
    printf("\n");
    
  }
  
  return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

vector<long long> ww;
vector<vector<long long>> wc;
long long best;

void solve(long long step, long long w, long long v) {
	if (step == ww.size()) {
		best = max(best, v);
	}
	else {
		long long i;
		solve(step + 1, w, v);
		for (i = 0; (i < wc[step].size()) && ((i + 1) * ww[step] <= w); i++) {
			solve(step + 1, w - (i + 1) * ww[step], v + wc[step][i]);
		}
	}
}

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

	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	s1[0] -= 'a' - 'A';
	s2[0] -= 'a' - 'A';
	s3[0] -= 'a' - 'A';
	cout << s1[0] << s2[0] << s3[0] << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  REP(i, n) {
    int s;
    cin >> s;
    a[i] = make_pair(s, i + 1);
  }
  sort(a.begin(), a.end());
  REP(i, n) {
    cout << a[i].second;
    if (i != n - 1) {
      cout << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 1664
n, m = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(m)]

flag = True

if n == 1 and m == 0:
    print(0)
elif n == 1 and m != 0:
    if len(set(sc)) != 1:
        print(-1)
    else:
        print(sc[0][1])
        
        
elif n > 1 and m == 0:
    print(10**(n-1))
    
elif n > 1 and m != 0:
    for i in range(10**(n-1), 10**n):
        i_str = str(i)
        i_list = list(i_str)
        for item in set(sc):
            if i_list[item[0]-1] != str(item[1]):
                break
        else:
            print(i)
            flag = False
            break
    if flag:
        print(-1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const long long mod=1e9+7;
template<class T> T extgcd(T a, T b, T& x, T& y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; }
ll mod_inv(ll a, ll m) { ll x, y; extgcd<ll>(a, m, x, y); return (m + x % m) % m; }

long long nck(int n, int k){
    long long p=1,q=1,r=1;
    rep(i,1,n+1) (p*=i)%=mod;
    rep(i,1,k+1) (q*=i)%=mod;
    rep(i,1,n-k+1) (r*=i)%=mod;
    return p*mod_inv(q,mod)%mod*mod_inv(r,mod)%mod;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
     
    int x,y,n,m;cin >> x >> y;
    n=(2*y-x)/3; m=(2*x-y)/3;
    long long ans;
    if((x+y)%3==0 and n>=0 and m>=0 ){
        ans=nck(n+m,n);
    }
    cout << ans << endl;
 } 

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, K; cin >> N >> K;
	cout << (N - K + 1) << endl;

	return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            char[] n = sc.next().toCharArray();
            for(int i=0;i<10;i++) {
                n[i]-='0';
            }
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 9 - i; j++) {
                    n[j]=(char) ((n[j]+n[j+1])%10);
                }
            }
            System.out.println((char)(n[0]+'0'));
        }
    }
}


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

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

    while (1) {
        if (n % 4 == 0 || n % 7 == 0) {
            cout << "Yes" << endl;
            break;
        } else if (n > 4) {
            n = n - 4;
            continue;
        } else {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

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

int		main(void)
{
	map<int, int> A;
	int N;

	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		int tmp;

		cin >> tmp;
		A[i] = tmp;
	}
	int cnt = 0;

	for (int i = 1; i <= N; i++)
	{
		int a = A[i];

		if (A[a] == i)
			cnt++;
	}
	cout << cnt / 2 << endl;
}



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

const int maxn = 1e5 + 5;
int x,cnt[3],n;//1 2 4

int main()
{
    while(scanf("%d",&n)==1){
        memset(cnt,0,sizeof cnt);
        for(int i=1;i<=n;i++){
            scanf("%d",&x);
            if(x%4==0) cnt[0]++;
            else if(x%2==0) cnt[1]++;
            else cnt[2]++;
        }
        if(cnt[1]) cnt[1]--;
        else if(cnt[2]) cnt[2]--;
        if(cnt[0]>=cnt[2]) puts("Yes");
        else puts("No");
    }
    return 0;
}


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

int main () {

    int N;
    cin >> N;

    string S;
    cin >> S;

    vector<int> array(N, 0);
    for (int i = 0; i < N; i++) {
        if (S[i] == 'W') {
            array[i] = -1;
        } else {
            array[i] = 1;
        }
    }

    for (int i = 1; i < N; i++) {
        array[i] += array[i-1];
    }

    int max_index = 0;
    int max_sum = array[0];
    for (int i = 1; i < N; i++) {
        if (max_sum < array[i]) {
            max_index = i;
            max_sum = array[i];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i == max_index) continue;

        if ((i < max_index && S[i] == 'W') || (i > max_index && S[i] == 'E')) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1924
class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)

        if i == j:
            return

        if i > j:
            i, j = j, i

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

    def roots(self):
        return [self.root(i) for i in range(self.N)]

    def groupcount(self):
        return len(set(self.roots()))

N, M, K = map(int, input().split())

notfriend = [set() for _ in range(N)]
forest = UnionFind(N)

# friend
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    notfriend[a].add(b)
    notfriend[b].add(a)

    forest.unite(a, b)

# block
for i in range(K):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    if forest.same(a, b):
        notfriend[a].add(b)
        notfriend[b].add(a)

ans = ' '.join([str(forest.size(i) - 1 - len(notfriend[i])) for i in range(N)])
print(ans)

Measured memory_bytes: 74652
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;int l=s.size();
    if(s[0]==s[l-1]) if(l&1) puts("Second");else puts("First");
    else if(!(l&1)) puts("Second");else puts("First");
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	 if(W<x+r || x-r<0 || H<y+r || y-r<0){
	 	printf("No\n");
	 }else{
	 	printf("Yes\n");
	 }
	
	return 0;
}

Measured memory_bytes: 580
using System;

	public class Class1
	{
		public static void Main()
		{   
			
			int n =int.Parse(Console.ReadLine());
			string dataSet=Console.ReadLine();
			string[] data=dataSet.Split();
			int[] a=new int[n];
			for(int i=0;i<n;i++)
			{
				a[i]=int.Parse(data[n-1-i]);
					Console.Write(a[i]);
				if(i!=n-1)
				{
					Console.Write(" ");
				}
			}
			Console.WriteLine();
		
		
		}
	}

Measured memory_bytes: 9044
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                result++;
            }

        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 41300
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
   
    int main() {
     int w,h,x,y,r;
     cin >> w>>h>>x>>y>>r;
     
     if(r<=x && x<=w-r && r<=y && y<=h-r) cout << "Yes" << '\n';
     else	cout << "No" << '\n';
    
     return 0;
    }


Measured memory_bytes: 3092