akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
#define LL long long
LL l, r;
char st[N];
int par[N], n, k;
LL solve(int c, LL r)
{
    LL res = 0;
    if (r <= n)
    {
        for (int i = 1; i <= r; ++ i) if (st[i] == c) res ++;
        return res;
    }
    LL ca = 0, cb = 0;
    for (int i = 1; i <= n - k; ++ i) if (st[i] == c) ca ++;
    for (int i = n - k + 1; i <= n; ++ i) if (st[i] == c) cb ++;
    if (k % (n - k) == 0)
    {
        LL cc = 0;
        for (int i = n - k + 1; i <= n - k + (r - (n - k)) % k; ++ i) if (st[i] == c) cc ++;
        return ca + cb * ((r - (n - k)) / k) + cc;
    }
    else
    {
        LL a = n - k, b = k, cca = ca, ccb = cb;
        for (; a + b <= r; b += a, swap(a, b), cb += ca, swap(ca, cb));
        return ca + solve(c, r - a);
    }
}
int main()
{
    scanf("%s", st + 1);
    n = strlen(st + 1) / 2;
    for (int i = 2; i <= n; ++ i)
    {
        int p = par[i - 1];
        while (p && st[p + 1] != st[i]) p = par[p];
        if (st[p + 1] != st[i]) par[i] = 0; else par[i] = p + 1;
    }
    // printf("%d\n", par[n]);
    k = par[n];
    if (k == 0) k = n, n += n;
    scanf("%lld%lld", &l, &r);
    for (int i = 0; i < 26; ++ i)
        printf("%lld ", solve(i + 'a', r) - solve(i + 'a', l - 1));
}


Measured memory_bytes: 896
/**
 *   author: malviyanshiv
 *   created: 09 January 2019  23:27:27
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define MAX 100005

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

void fastscan(int &x){
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-'){
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}

void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int dp[MAX][2][2][2];
int h[MAX][3];

int cal(int idx, int a, int b, int c){
    if( idx < 0 )
        return 0;
    int &res = dp[idx][a][b][c];
    if( res )
        return res;
    if( a != 1 )
        res = max( res, cal(idx-1, a+1, 0, 0) + h[idx][0] );
    if( b != 1 )
        res = max( res, cal(idx-1, 0, b+1, 0) + h[idx][1] );
    if( c != 1 )
        res = max( res, cal(idx-1, 0, 0, c+1) + h[idx][2] );
    return res;
}

int main(){
	optimizeIO();
    int n, a, b, c;
    cin >> n;
    REP(i, 0, n)
        cin >> h[i][0] >> h[i][1] >> h[i][2];

    cout << max( max( cal(n-2, 0, 0, 1) + h[n-1][2], cal(n-2, 1, 0, 0) + h[n-1][0]) , cal(n-2, 0, 1, 0) + h[n-1][1] ) << endl;
	
	return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    int n,k;
  	cin >> n >> k;
  
  	cout << (n % k == 0 ? 0 : 1) << endl;
    return 0;
}

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

/// read the question correctly (is y a vowel?)
/// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
#define fi first
#define se second
#define SZ 1000005
const int mx = 1234567;
const double eps = 1e-6;
const int md = 1e9+7;
const double pi = acos(-1.0);

typedef long long ll;

int dr[8] = {-1,-1,+0,+1,+1,+1,+0,-1};// counter clockwise
int dc[8] = {+0,-1,-1,-1,+0,+1,+1,+1};

int ar[mx],xar[mx],uses[mx];
ll arr[mx];
int tab[1000][1000];
string st[1000];
map<int ,int>mpii;
map<int ,char>mpic;
map<char ,int>mpci;
pair<int, int>pr[mx];

int ar1[mx],ar2[mx],ar3[mx],ar4[mx];

int main(){

    int tk=1,n,m;
//    freopen("in.txt","r", stdin);
//    freopen("out.txt","w", stdout);

//    while(scanf("%d",&n)==1){
//
//    }
    map<int,int>mp;
    scanf("%d",&n);
    int a, f = 0;
    for(int i = 0; i < n; i++){
        scanf("%d",&a);
        mp[a]++;
        if(mp[a] > 1) f = 1;
    }
    if(f == 0){
        cout<<"YES"<<endl;
    }else
    cout<<"NO"<<endl;
    return 0;
}


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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double ang_a = (30 * h) + (m / 2);
  double ang_b = 6*m;

  double ang = abs(ang_a - ang_b);
  if (ang > 180)
  {
    ang = 360 - ang;
  }
  
  double rad = (ang / 180) * M_PI;

  double length = sqrt(a*a + b*b - 2*a*b*cos(rad));
  
  cout << fixed << setprecision(12);
  cout << length << endl;
  
  return 0;
}

Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

i64 MOD = 1e9 + 7;

i64 pow(i64 x, i64 n)
{
  i64 r = 1;
  for (i64 i = 0; i < n; i++)
    r = r * x % MOD;
  return r;
}

int main()
{
  i64 N;
  cin >> N;
  i64 ans = pow(10LL, N) + pow(8LL, N) - pow(9LL, N) * 2;
  cout << (ans + MOD * 2) % MOD << endl;
  return 0;
}


Measured memory_bytes: 3640
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = nextInt()
	}
	fs := make([]int, n)
	for i := 0; i < n; i++ {
		fs[i] = nextInt()
	}

	sort.Ints(as)
	sort.Sort(sort.Reverse(sort.IntSlice(fs)))

	lb, ub := -1, int(1e18)
	for ub-lb > 1 {
		mid := (lb + ub) / 2
		if check(mid, k, as, fs) {
			ub = mid
		} else {
			lb = mid
		}
	}
	fmt.Println(ub)
}

func check(t, k int, as, fs []int) bool {
	n := len(as)
	for i := 0; i < n; i++ {
		a := as[i]
		f := fs[i]
		d := t / f
		if d < a {
			k -= a - d
		}
	}
	return 0 <= k
}

var sc = bufio.NewScanner(os.Stdin)

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


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

int main() {
    ll n, k;
    cin >> n >> k;
    if(n == k) {
        cout << 0 << endl;
        return 0;
    }
    if(n < k) {
        cout << min(n, abs(k - n));
        return 0;
    }
    if(n % k == 0) {
        cout << 0 << endl;
        return 0;
    }
    if(n % k != 0) {
        ll d = n % k;
        cout << min(n, abs(k-d));
        return 0;
    }


}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define arr array

template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e18;


void pre(){



}



void solve(){

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max(a*c,a*d);
    umax(ans , b*c);
    umax(ans , b*d);
    cout << ans;
}

int32_t main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3644
let (|>) x f = f x ;;
let n = Scanf.scanf "%d\n" (fun n -> n) ;;
let s = Scanf.scanf "%s\n" (fun s -> s) ;;

let string_to_list str =
  let id_to_int c =
    if c = 'I' then 1
    else -1
  in
  let rec loop idx arr=
    if idx = -1 then arr
    else loop (idx-1) ((id_to_int (String.get str idx))::arr)
  in
  loop (n-1) []
;;

let solve arr =
  let rec sim ma v arr = 
    match arr with
    | [] -> ma
    | h::t ->
      let w = v + h in
      let new_max = max ma w in
      sim new_max w t
  in
  sim 0 0 arr
;;

let () =
  s
  |> string_to_list
  |> solve
  |> Printf.printf "%d\n"


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

using namespace std;

int main(){
  string S,T;
  cin>>S;
  cin>>T;
  int i,atsuki=0;
  for(i=0;i<3;i++){
    if(S[i]==T[i]) atsuki++;
  }
  cout << atsuki << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    if (a < b){
        printf("a < b\n");
    }
    else if (a > b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
}


Measured memory_bytes: 2112
#include <stdio.h>
#include <string.h>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define ifb(N, n) if(N & (1 << n))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define V [0x1000] 
#define AV = malloc(0x8000) 
#define VZ(v) memset(v, 0, 0x1000)
#define addv(a,b) a = (unsigned long long)a + (unsigned long long)b
#define assv(a,b) a = (unsigned long long)b
#define vi 0x7fffffffffffffff

typedef void * v;
typedef unsigned long long ull;

int main(void) {
    int n, m, x;

    scanf("%d %d %d", &n, &m, &x);

    v cc V;
    v *aaa V;

    rep(i, n) {
        v c;
        scanf("%d", &c);
        cc[i] = c;
        v *aa AV;
        rep(j, m) {
            v a;
            scanf("%d", &a);
            assv(aa[j], a);
        }
        aaa[i] = aa;
    }


    v ans = vi;
    rep(b, 1 << n) {
        v t V;
        VZ(t);
        int sum = 0;
        rep(i, n) {
            ifb(b, i) {
                sum += cc[i];
                rep(j, m) {
                    addv(t[j], aaa[i][j]);
                }
            }
        }
        rep(i, m) {
            if(t[i] < x) goto owari;
        }
        ans = MIN(sum, ans);
owari:;
    }
    
    printf("%d", ans);
}

Measured memory_bytes: 2248
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,a;
    cin >> h >> a;
    int cnt = 0;
    while(1){
        if(h - a > 0)
        {
            cnt++;
            h -= a;
        }
        else
        {
            cnt++;
            break;
        }
        
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(10)]
    """
    備忘録としてワ―シャルフロイドによる実装も試してみる。
    wikipediaの解説が意外とわかりやすい？
    """
    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])
    
    d = defaultdict(int)
    for _ in range(H):
        A = list(map(int, input().split()))
        for a in A: d[a] += 1
    ans = 0
    for i in range(10): ans += C[i][1] * d[i]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74084
#include<bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define INF 1e9
#define MOD 1000000007
#define All(x) (x).begin(),(x).end()
#define Cout(x) cout << (x) << endl
typedef long long ll;
using namespace std;

ll f(ll n,ll x){
  if(n==-1)return 0;
  else return n/x+1;
}

int main(void){
  ll a,b,x;
  cin>>a>>b>>x;
  ll ans=f(b,x)-f(a-1,x);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int x,y,x1,y1;
    double z,z1;
    scanf("%d %d",&x,&y);
    x1=x/y;
    y1=x%y;
    z1=x;
    z=z1/y;
    printf("%d %d %f\n",x1,y1,z);
    return 0;
}


Measured memory_bytes: 2104
import numpy as np
a = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)] 

a = np.array(a,  dtype=np.int64).reshape(9)
b = np.array(b, dtype=np.int64)

for i in range(N):
    for j in range(len(a)):
        if b[i] == a[j]:
            a[j] = -1

if a[0] == a[1] == a[2] == -1 or a[3] == a[4] == a[5] == -1 or a[6] == a[7] == a[8] == -1:
    print('Yes')
elif a[0] == a[3] == a[6] == -1 or a[1] == a[4] == a[7] == -1 or a[2] == a[5] == a[8] == -1:
    print('Yes')
elif a[0] == a[4] == a[8] == -1 or a[2] == a[4] == a[6] == -1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14472
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } 
using ll=long long;
 int main(){
   ll a=-200 ,b=-200,X;
   cin>>X;
   rep(i,400){
     a++;
     b=-200;
   rep(j,400){
   b++;
     if(a*a*a*a*a-b*b*b*b*b==X){
     cout<<a<<" "<<b<<endl;
      return 0;
     }
   }
   
   }
}


Measured memory_bytes: 3568
def main():
    k = int(input())
    if k<10:
        print(k)
        return
    que = [i for i in range(1,10)]
    cnt = 0
    while True:
        q = que.pop(0)
        cnt += 1
        if cnt==k:
            print(q)
            return
        if q%10==0:
            que.append(q*10)
            que.append(q*10+1)
        elif q%10==9:
            que.append(q*10+9-1)
            que.append(q*10+9)
        else:
            que.append(q*10+q%10-1)
            que.append(q*10+q%10)
            que.append(q*10+q%10+1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 18568
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int N; cin >> N; int a[N], A = 0, B = 0;
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a, a+N, greater<int>());
    for (int i = 0; i < N; i++) (i&1) ? (B += a[i]) : (A += a[i]);
    cout << A-B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    char c[n + 2][m + 2];
    fill(c,'x');
    repi(i, 1, n + 1){
        string s;
        cin >> s;
        repi(j, 1, s.length() + 1)c[i][j] = s[j - 1];
    }
    /*rep(i,n + 2){
        rep(j,m + 2){
            cout << c[i][j];
        }
        cout << "\n";
    }*/
    repi(i, 1, n + 1){
        repi(j, 1, m + 1){
            intl cnt = 0;
            if(c[i][j] == '#'){
                cout << '#';
                continue;
            }
            repi(k, -1, 2){
                repi(l, -1, 2){
                    if(c[i + k][j + l] == '#')cnt++;
                }
            }
            cout << cnt;
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
///////////////////////////////////////////////////////////////////////////
// /*Dis = size of the program || TLE. */
/*
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
*/
// #pragma GCC target("avx,avx2,fma")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops") /* D = Too many loops */

#include <sys/time.h>  // for CLOCKS_PER_SEC

#include <ctime>     // for clock
#include <iostream>  // for operator<<, ostream, istream, basic_ostream
#include <unordered_set>
using namespace std;
#define endl '\n'
typedef long long ll;

//////////////////////////////////////////////////////////////////////////
/* Custom function starts here */

/* Custom function ends here: */
//////////////////////////////////////////////////////////////////////////////

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

  /* MAIN Code STARTS here: */
  unordered_set<long long int> ss;
  unordered_set<long long int> dup;
  long n;
  cin >> n;
  for (long i = 0; i < n; i++) {
    ll num;
    cin >> num;
    if (ss.find(num) != ss.end()) {
      dup.insert(num);
    } else {
      ss.insert(num);
    }
  }
  if (dup.empty() == true) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  /* MAIN Code ENDS here: */
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}

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

using i64 = int64_t;

int main(){
    i64 x;
    cin >> x;
    i64 sum = 0, ans;
    for(ans=1;sum<x;++ans){
        sum += ans;
    }
    cout << ans-1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <string.h>
using namespace std;
int edge[100005];
struct Node{
	int edge;
	int id;
	Node(int x, int y){
		edge = y;
		id = x;
	}
	Node(){edge = 0; id = 0;}
}node[100005];
vector<Node> v[100005];
int maxn;
void dfs(int now, int last)
{
	int ed = 1;
	for(int j = 0; j < v[now].size(); j++)
	{
		if(edge[v[now][j].edge] != 0)
			continue;
		if(ed != last)
		{
			edge[v[now][j].edge] = ed;
			dfs(v[now][j].id, ed++);
		}
		else
		{
			ed++;
			j--;
		}
	}
}
int main(void)
{
	int n, x, y;
	scanf("%d", &n);
	for(int i = 1; i < n; i++)
	{
		scanf("%d %d", &x, &y);
		v[x].push_back(Node(y, i));
		v[y].push_back(Node(x, i));
	}
	for(int i = 1; i <= n; i++)
	{
		if(v[i].size() > maxn)
			maxn = v[i].size();
	}
	printf("%d\n", maxn);
	dfs(1, 0);
	for(int i = 1; i < n; i++)
	{
		printf("%d\n",edge[i]);
	}
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int x, y;
    cin >> x >> y;
    
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int n = (2 * y - x) / 3;
    int m = (2 * x - y) / 3;

    COMinit();
    cout << COM(n + m, n) << endl;

    return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;
bool sr(ll a,ll b){
	return a>b;
}
bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(ll n) {
	int count = 0;
	while (n > 0) {
		n /= 10;
		count++;
	}
	return count;
}
template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}

int main()
{
	ll n;
	cin>>n;
	int dig=digits(n);
	cpp_int tmp=0;
	rep(i,dig){
		tmp+=mp::pow((cpp_int)10,i)*9;
	}
	rep(i,9){
		if(tmp<=n){
			cout<<9*(dig-1)+(9-i)<<endl;
			break;
		}
		tmp-=mp::pow((cpp_int) 10,dig-1);
		if(tmp<=n){
			cout<<9*(dig-1)+(9-i-1)<<endl;
			break;
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int c1,c2,c3,c,i,count=0;
	
	while(scanf("%d%d%d",&c1,&c2,&c3)!=EOF){
	c=c1+c2;
	for(i=1;i<=10;i++){
	if(c+i<=20 && c1!=i && c2!=i && c3!=i)count++;
	}
	if(count*100/7>=50)printf("YES\n");
	else printf("NO\n");
	count=0;
	}
	return 0;
}

Measured memory_bytes: 1008
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min(a + b, min(b + c, c + a)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
ll power(ll x,ll y,ll p) 
{ 
    ll res=1;  
    x=x%p;
    while (y > 0) 
    { 
        if(y&1) 
            res=(res*x)%p; 
        y=y>>1;
        x=(x*x)%p;   
    } 
    return res; 
}
const ll L = 1e5 + 5;
ll arr[105], n;
ll dp[L][5];
ll mv = 1e18;
ll rec(ll k, ll t)
{
	ll i;
	if(mv > k)
		return dp[k][t] = -1;
	if(dp[k][t] != 0)
		return dp[k][t];
	for(i=0;i<n;i++)
	{
		if(k >= arr[i] && rec(k - arr[i], 1 - t) == -1)
			return dp[k][t] = 1;
	}
	return dp[k][t] = -1;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll i,k;
 	cin >> n >> k;
 	for(i=0;i<n;i++)
 		cin >> arr[i], mv = min(mv,arr[i]);
	if(rec(k,0) == 1)
		cout << "First" << endl;
	else
		cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;

bool check_element(vector<int> &v, int element) {
	bool res = false;
	for (auto itr = v.begin(); itr != v.end(); ++itr) {
		if (*itr == element) {
			res = true;
			break;
		}
	}

	return res;
}

void next(map<int, vector<int>> g, int point, vector<int> visited, int max, int &ans) {
	if (g[point].empty()) {
		return;
	}

	for (auto itr = g[point].begin(); itr != g[point].end(); ++itr) {
		if (check_element(visited, *itr)) {
			continue;
		}
		else {
			visited.push_back(*itr);
			if (visited.size() == max) {
				ans++;
				return;
			}
			else {
				next(g, *itr, visited, max, ans);
				visited.pop_back();
			}
		}
	}

	return;
}

int main(){
    int N, M;
    cin >> N >> M;
    map<int, vector<int>> g;
    int ans = 0;
    REP(i, M) {
    	int a, b;
    	cin >> a >> b;
    	g[a].push_back(b);
    	g[b].push_back(a);
    }

    vector<int> visited;
    visited.push_back(1);
    next(g, 1, visited, N, ans);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
const int MAX_N = 100010;

int par[MAX_N];
int Rank[MAX_N];
int size;
int K[100010];
void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        Rank[i] = 0;
    }
    size = n;
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    size--;
    if (Rank[x] < Rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (Rank[x] == Rank[y]) {
            Rank[x]++;
        }
    }
}
bool same(int x, int y) {
    return find(x) == find(y);
}
int a[100010], b[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    init(N);
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    int ans[100010] = {};
    int tmp = 0;
    rep(i, N) K[i] = 1;
    RREP(i, M - 1, 0) {
        ans[i] = N * (N - 1) / 2 - tmp;
        if (!same(a[i], b[i])) {
            int num[2];
            num[0] = K[find(a[i])];
            num[1] = K[find(b[i])];
            tmp += (K[find(a[i])] * K[find(b[i])]);
            int t = K[find(b[i])] + K[find(a[i])];
            unite(a[i], b[i]);
            K[find(a[i])] = t;
        }
    }
    rep(i, M) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 6016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a = 0;
      while (sc.hasNext()) {
        String h = sc.next();
        if (h.equals("-")) {
          a = 0;
          break;
        }
        int n = sc.nextInt();
        while (sc.hasNextInt()) {
          int m = sc.nextInt();
          String latter = h.substring(m);
          String former = h.substring(0,m);
          h = latter + former;
          a = 1;
        }
        if (a == 1) System.out.println(h);
      }

    }
}


Measured memory_bytes: 26640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N,ans=0; cin >> N;
  v<int> A(N),B(N),C(N);
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  rep(i,N) cin >> C[i];
  sort(A.begin(),A.end());
  sort(C.begin(),C.end());
  rep(i,N){
    ans+=(lower_bound(A.begin(),A.end(),B[i])-A.begin())*(C.end()-upper_bound(C.begin(),C.end(),B[i]));
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=0;
	ll rem;
	ans=n/(a+b)*a;
	rem=n%(a+b);
	ans+=min(rem,a);

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int N;
double a[8];
int main(){
	while(true){
		cin>>N;
		if(N==0) break;
		rep(i,N+3) cin>>a[i];
		int ans=N+2;
		rep(i,N+2){	//0,..i-1,i+1,..N+1
			double sum=0;
			rep(j,N+2){
				if(i==j) continue;
				double tmp=a[j];
				rep(k,N+2){
					if(i==k||j==k) continue;
					tmp*=(double)(N+2-k)/(j-k);
				}
				sum+=tmp;
			}
//			show(i);
//			show(sum);
			if(abs(a[N+2]-sum)<1e-3) ans=i;
		}
		cout<<ans<<endl;
	}
}

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

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

using namespace std;

int main(){
	string s; cin>>s;
	int n=s.length();
	for(int i=0;i<n;i+=2) cout<<s[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 512
n, x = map(int, input().split())
a = list(map(int, input().split()))
d = a[:]
ans = float('inf')
for i in range(n):
    ans = min(ans, sum(d) + x * i)
    for j in range(n):
        d[j] = min(d[j], a[(j - (i + 1) + n) % n])
print(ans)


Measured memory_bytes: 44012
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long int lli;

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

  int len = 0;
  int ans = 0;
  for(auto s:S){
    if(s=='A'||s=='C'||s=='G'||s=='T'){
      len++;
      ans = max(ans,len);
    }
    else
      len = 0;
  }

  cout << ans << endl;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	int i;
	int cnt = 0;
	for (i = 0; i < s.length();i++)
	{
		if (s.at(i) != s.at(s.length() - 1 - i))
			cnt++;
	}
	cout << cnt / 2 << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int x=n%10;
    if(x==2||x==5||x==4||x==7||x==9)cout<<"hon";
    else if(x==3)cout<<"bon";
    else cout<<"pon";
    return 0;
}

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

int main(){
    string S;
    int count=0;
    cin >> S;
    rep(i,3){
        if(S.at(i)=='R'){
            count++;
        }
    }
    if(count==2){
        if(S.at(0)=='R' && S.at(2)=='R'){
            count = 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    ull N;
    cin >> N;
    vint a(N + 1);//1-indexed
    rep(i,N)
    {
        cin >> a[i+1];
    }
    int j = 1,ans=0;
    rep2(i,1, N+1)
    {
        if(a[i] != j)
        {
            ans++;
        }
        else
            j++;
    }
    if(ans < N)
    cout << ans;
    else
        cout << -1;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]

candies = [0 for _ in range(N)]

for i in range(N):
    candies[i] += sum(A[0][m] for m in range(i + 1))
    candies[i] += sum(A[1][m] for m in range(i, N))

print(max(candies))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */


const ll MAX_V = 2020;
const ll MAX_E = 2020;
ll n, m;
ll a[MAX_E], b[MAX_E], c[MAX_E], d[MAX_V];
ll ans = INF;
bool neg[MAX_V];

void bf(){
    repr(i, 1, n+1){
        d[i] = INF;
    }
    d[1] = 0;
    rep(i, n+1){
        neg[i] = 0;
    }
    for(ll i = 0; i < n; i++){
        rep(j, m){
            ll u = a[j];
            ll v = b[j];
            if(d[u] != INF && d[v] > d[u] + c[j]){
                d[v] = d[u] + c[j];
            }
        }
        ans = -d[n];
    }
}
void negloop(){
    for(ll i = 0; i < 2*n; i++){
        rep(j, m){
            ll u = a[j];
            ll v = b[j];
            if(d[v] != INF && d[v] > d[u] + c[j]){
                d[v] = d[u] + c[j];
                if(i >= n) neg[v] = 1;
            }
            if(neg[u]) neg[v] = 1;
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        c[i] *= -1;
    }
    bf();
    negloop();
    if(neg[n]){
        cout << "inf" << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 384
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/09/20 20:59:36
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  vector<int> graph[n];
  for (int i = 0; i < m; i++) {
    int a,b; cin>>a>>b; a--; b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  struct State {
    set<int> h;
    int c;
  };
  queue<State> qs;
  qs.push({{}, 0});
  int ans = 0;
  while (not qs.empty()) {
    auto q = qs.front(); qs.pop();
    q.h.insert(q.c);
    for (auto t:graph[q.c]) {
      if (q.h.count(t))
        continue;
      if (q.h.size()+1 == n) {
        ans++;
        continue;
      }
      qs.push({q.h, t});
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2048
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_B&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        x = int(input())
        if x == 0:
            break

        digit_sum = 0
        while x:
            digit_sum += x % 10
            x //= 10
        print(digit_sum)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7684
#include <stdio.h>
#include <string.h>
int main() {
    char vetor[110];
    scanf("%s",vetor);
    int valor = 0;
    for(int x =0;x<strlen(vetor);++x){
        if((x+1)%2==0){
            if(vetor[x]!='L' && vetor[x]!='U' && vetor[x]!='D'){
                valor = 1;
                break;
            }
        }
        else{
            if(vetor[x]!='R' && vetor[x]!='U' && vetor[x]!='D'){
                valor = 1;
                break;
            }
        }
    }
        
    if(valor==1)
        printf("No");
    else
        printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>

using namespace std;

int A,B,C,K;


int main(){
    scanf("%d%d%d%d",&A,&B,&C,&K);

    int ans=0;
    int take=min(A,K);
    K-=take;
    ans+=take;

    take=min(B,K);
    K-=take;

    take=min(C,K);
    ans-=take;

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

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii; 
ll p1[200010];
ll p2[200010];
string s;
ll ans,nw; 
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	p1[0]=1;
	p2[0]=1;
	for(int i=1;i<200005;i++){
		p1[i]=p1[i-1]*2%1000000007;
		p2[i]=p2[i-1]*3%1000000007;
	}
	cin>>s;
	nw=1;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1'){
			ans=(ans+(ll)nw*p2[s.size()-1-i]%1000000007)%1000000007;
			nw=nw*2%1000000007;
		}
	}
	ans=(ans+nw)%1000000007;
	cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include<functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>

#define LL long long
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e,v) for(auto e:v)
#define rep(i, a, n) for(LL i = a; i < n;i++)

using namespace std;

int inp(){
	int x;
	scanf("%d",&x);
	return x;
}
LL linp(){
	LL x;
	scanf("%lld",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}


int gcd(int i,int j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;

}

int ABC_swap(){
	LL X =linp();
	LL Y =linp();
	LL Z =linp();

	printf("%lld %lld %lld", Z, X, Y);
	return 0;
}

int Popular_vote(){

	 LL N ,M;

	 N = linp();
	 M = linp();

	 priority_queue<LL, vector<LL> > que;

	 int sumV = 0;

	 rep(i , 0, N){
		 LL in = linp();
		que.push(in);
		 sumV += in;
	 }


	 int count = 0;
	 double canV = (double)sumV /( 4.0 * M);

	 while(que.top() >= canV && !que.empty()){
	 	 	count++;
	 	 	que.pop();
	 }

	 if(count >= M){
		 printf("Yes\n");
	 }
	 else{
		 printf("No\n");
	 }


	 return 0;
}

int Replacing_Integer(){

	LL N,K;
	cin >> N >> K;

	loutp(min(N % K, K - N%K));

}


void Lunlun(LL i, priority_queue<LL, vector<LL>,greater<LL>>* que, LL limit){

	if(i <= limit){
		que->push(i);

		int x = i%10;//最右桁

		if(x < 0)
			x += 10;//正数に直す

		if(x >= 1)
			Lunlun(10*i + (x - 1),que,limit);

		Lunlun(10*i + x,que,limit);

		if(x <= 8)
			Lunlun(10*i + (x + 1),que,limit);
	}
	return;
}

int Lunlun_Number(){
	LL K = linp();

	priority_queue<LL, vector<LL>,greater<LL>> que;

	rep(i, 1, 10)
		Lunlun(i, &que, (LL) 3234566667); //各桁につき大体30個くらいあるし

	LL answer;
	rep(i, 0, K){
		answer = que.top();
		if(que.empty()) break;

		que.pop();
	}

	loutp(answer);

	return 0;
}
signed main() {

	//ABC_swap();
	//Popular_vote();
	//Replacing_Integer();
	Lunlun_Number();
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define mod pow(10,9)+7
#define lim pow(10,7)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,l;
	cin>>n>>l;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int flag=0;
	for(int i=0;i<n-1;i++)
		if(a[i]+a[i+1]>=l)
			flag=i+1;
	if(flag)
	{
		cout<<"Possible"<<endl;
		for(int i=n-1;i>flag;i--)
			cout<<i<<endl;
		for(int i=1;i<=flag;i++)
			cout<<i<<endl;
	}
	else
		cout<<"Impossible"<<endl;
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 double a,b,c,d;
 cin >> a >> b >> c >> d;
 if((int)ceil(a/d)>=(int)ceil(c/b))
 cout << "Yes";
 else
 cout << "No";
 return 0;
}

Measured memory_bytes: 3724
parseInt(x) = parse(Int, x)

function main()
	n = parseInt(readline())
	a = Array{Int}(n)
	for i in 1:n
		a[i] = readline() |> parseInt
	end
	flg = 0
	for i in 1:n
		if a[i] % 2 == 1
			flg = 1
			break
		end
	end
	if flg == 1
		print("first")
	else
		print("second")
	end
end

main()

Measured memory_bytes: 123304
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int d, t, s;
    cin >> d >> t >> s;
    if (s * t < d) {
        cout << "No" << newl;
    } else {
        cout << "Yes" << newl;
    }
}

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

int main() {
    int n, k;
    bool d[10]{};
    cin >> n >> k;
    for(int i=0;i<k;i++){
        int x;
        cin >> x;
        d[x] = true;
    }
    for(int i=n;;i++){
        int m = i;
        bool ng = false;
        while(m > 0){
            ng |= d[m%10];
            m /= 10;
        }
        if(!ng){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


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


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

    for(int i=0; i<s.size(); i++){
        if(i == s.size()-1){
            k %= 26;
            if((int)(s[i]+k) > 122) s[i] = (char)(s[i]+k-26);
            else s[i] = (char)(s[i]+k);
        }
        else{
            if(s[i] == 'a') continue;

            if(123 - (int)s[i] <= k){
                k -= (123 - (int)s[i]);
                s[i] = 'a';
            }
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	x, y, z := iScan(), iScan(), iScan()
	fmt.Println((x - z) / (y + z))
}


Measured memory_bytes: 1776
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	double a,b,c,degree,S;
	scanf("%lf %lf %lf",&a,&b,&degree);
	S = (0.5)*a*b*sin(M_PI*degree/180);
	c = sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
	printf("%.8lf\n",S);
	printf("%.8lf\n",a+b+c);
	printf("%.8lf\n",2*S/a);
}



Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
#include <numeric>
using namespace std;

int main(){
    long long int n, a;
    vector<long long int> v;
    cin >> n;
    
    long long int i;
    
    for(i = 0; i < n; i++){
        cin >> a;
        v.push_back(a);
    }
    
    sort(v.begin(), v.end());
    
    long long int ans;
    long long int sum1 = 0;
    long long int sum2 = 0;
    long long int minus = 0;
    long long int plus = 0;
    
    if(n%2 == 0){
        for(i = 0; i <= n/2 - 1; i++){
            if(i == n/2 - 1){
                minus += v[i];
            }else{
                minus += 2 * v[i];
            }
        }
        for(i = n/2; i < n; i++){
            if(i == n/2){
                plus += v[i];
            }else{
                plus += 2 * v[i];
            }
        }
        ans = plus - minus;
    }else{
        for(i = 0; i <= n/2 - 1; i++){
            minus += 2 * v[i];
        }
        for(i = n/2; i < n; i++){
            if(i == n/2 || i == n/2 + 1){
                plus += v[i];
            }else{
                plus += 2 * v[i];
            }
        }
        sum1 = plus - minus;
        
        plus = 0;
        minus = 0;
        for(i = 0; i <= n/2; i++){
            if(i == n/2 - 1 || i == n/2){
                minus += v[i];
            }else{
                minus += 2 * v[i];
            }
        }
        for(i = n/2 + 1; i < n; i++){
            plus += 2 * v[i];
        }
        sum2 = plus - minus;
        
        if(sum1 > sum2){
            ans = sum1;
        }else{
            ans = sum2;
        }
    }
    
    cout << ans << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d)
    cout << "Left" << endl;
  else if (a + b < c + d)
    cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> d(M, 0);
    for (ll i = 0; i < N; i++) {
        ll K;
        cin >> K;
        for (ll j = 0; j < K; j++) {
            ll A;
            cin >> A;
            d[A - 1]++;
        }
    }

    ll ans = 0;
    for (ll e : d) {
        if (e == N) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(raw_input())
def gb(s):
	bal = 0
	m = 0
	for l in s: 
		bal += 1 if l == '(' else -1
		m = min(m, bal)
	return (bal,m)


rs = [gb(raw_input()) for _ in range(n)]
rs.sort(key = lambda x: (0,-x[1], -x[0]) if x[0]>=0 else (1,x[1] - x[0], -x[0]))

def f(rs):
	s = 0
	for aa,bb in rs:
		if s + bb < 0: return False
		s += aa
	return s == 0

print 'Yes' if f(rs) else 'No'

Measured memory_bytes: 231204