akhauriyash/Code-Regression huggingface dataset:
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int C = int.Parse(input[2]);

        if ((A > C && C > B) || (B > C && C > A))
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

#define MAX 100000

struct data {
    char name[10];
    int time;
};

int head = 0, tail = 0;
struct data Q[100000];

int isEmpty()
{
    return head != tail;
}

void enqueue(struct data p)
{
    Q[tail] = p;
    if (tail == MAX - 1) {
        tail = 0;
    } else {
        tail++;
    }
}

struct data dequeue()
{
    struct data x;
    
    x = Q[head];
    if (head == MAX - 1) {
        head = 0;
    } else {
        head++;
    }
    return x;
}

int main(void)
{
    int n, q, i, t = 0;
    struct data p;
    
    scanf("%d %d", &n, &q);
    for (i = 0; i < n; i++) {
        scanf("%s %d", p.name, &p.time);
        enqueue(p);
    }
    while (isEmpty()) {
        p = dequeue();
        if (p.time <= q) {
            t += p.time;
            printf("%s %d\n", p.name ,t);
        } else {
            t += q;
            p.time -= q;
            enqueue(p);
        }
    }
    return 0;
}

Measured memory_bytes: 2160
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n;
vector<vector<vector<double>>> dp;
double rec(int c, int b, int a){
	if(a == 0 && b == 0 && c == 0) return 0;
	double &res = dp[a][b][c];
	if(res > 0) return res;
	
	double e = 0, psum = 1.0 * (a + b + c) / n;
	double p = 1.0 * c / n;
	if(c) e += p * rec(c - 1, b + 1, a);
	
	p = 1.0 * b / n;
	if(b) e += p * rec(c, b - 1, a + 1);
	
	p = 1.0 * a / n;
	if(a) e += p * rec(c, b, a - 1);
	
	return res = (e + 1) / psum;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	cin >> n;
	vi a(n), cnt(3); rep(i, n) cin >> a[i], cnt[a[i] - 1]++;
	
	dp = vector<vector<vector<double>>>(n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1)));
	printf("%.20f\n", rec(cnt[2], cnt[1], cnt[0]));
	return 0;
}

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

struct point{ int x, y, id; };

point init(int pos_x, int pos_y, int index)
{
    point p; 
    p.x = pos_x, p.y = pos_y, p.id = index; 
    return p; 
}

bool cmp_x(const point &P1, const point &P2){ if(P1.x != P2.x){ return P1.x < P2.x; } return P1.y < P2.y; }
bool cmp_y(const point &P1, const point &P2){ if(P1.y != P2.y){ return P1.y < P2.y; } return P1.x < P2.x; }

int cmp_xx(const point &P1, const point &P2){
	if(P1.x != P2.x){
		return (P1.x < P2.x ? 1 : -1);
	}else if(P1.y != P2.y){
		return (P1.y < P2.y ? 1 : -1);
	}
	return 0;
}

int cmp_yy(const point &P1, const point &P2){
	if(P1.y != P2.y){
		return (P1.y < P2.y ? 1 : -1);
	}else if(P1.x != P2.x){
		return (P1.x < P2.x ? 1 : -1);
	}
	return 0;
}

void kd_tree(point *S, point *T, point *U, int left, int right, int d)
{
    if(right - left < 2) return;

    int mid = ((left + right) >> 1);
    int a = left, b = mid + 1, crit;

    if((d & 1) == 0){
        for(int i = left; i < right; i++){
			crit = cmp_xx(T[i], S[mid]);
			if(crit > 0){
				U[a++] = T[i];
			}else if(crit < 0){
				U[b++] = T[i];
			}else{
				U[mid] = T[i];
			}
        }
        for(int i = left; i < right; i++){ T[i] = U[i]; }

    }else{
        for(int i = left; i < right; i++){
			crit = cmp_yy(S[i], T[mid]);
			if(crit > 0){
				U[a++] = S[i];
			}else if(crit < 0){
				U[b++] = S[i];
			}else{
				U[mid] = S[i];
			}
        }
        for(int i = left; i < right; i++){ S[i] = U[i]; }
    }
    kd_tree(S, T, U, left, mid, d + 1);
    kd_tree(S, T, U, mid + 1, right, d + 1);
}

int cnt;

void find_pt(int *Q, point *S, int sx, int tx, int sy, int ty, int left, int right, int d)
{
    if(left >= right) return;

    int mid = ((left + right) >> 1);
    point p = S[mid];
    int a = p.x, b = p.y;

    if(sx <= a && a <= tx && sy <= b && b <= ty){
        Q[cnt++] = p.id;
    }

    if((d & 1) == 0){
        if((left < mid) && (sx < a || (sx == a && sy <= b))){ find_pt(Q, S, sx, tx, sy, ty, left, mid, d + 1); }
        if((mid + 1 < right) && (a < tx || (a == tx && b <= ty))){ find_pt(Q, S, sx, tx, sy, ty, mid + 1, right, d + 1); }
    }else{
        if((left < mid) && (sy < b || (sy == b && sx <= a))){ find_pt(Q, S, sx, tx, sy, ty, left, mid, d + 1); }
        if((mid + 1 < right) && (b < ty || (b == ty && a <= tx))){ find_pt(Q, S, sx, tx, sy, ty, mid + 1, right, d + 1); }
    }
    return;
}

int main()
{
    point *S, *T, *U;
    int Q[100];
    int i, pos_x, pos_y, n;
    scanf("%d", &n);

    S = new point [n], T = new point [n], U = new point [n];

    for(i = 0; i < n; i++){
        scanf("%d %d", &pos_x, &pos_y);
        S[i] = init(pos_x, pos_y, i);
        T[i] = S[i];
    }
    sort(S, S + n, cmp_x);
    sort(T, T + n, cmp_y);

    kd_tree(S, T, U, 0, n, 0);

    int sx, tx, sy, ty, q;
    scanf("%d", &q);
    while(q){
        cnt = 0;
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        find_pt(Q, S, sx, tx, sy, ty, 0, n, 0);
        sort(Q, Q + cnt);
        for(int i = 0; i < cnt; i++){ printf("%d\n", Q[i]); }
        printf("\n");
        q--;
    }

    return 0;
}

Measured memory_bytes: 18328
import numpy as np
s=input()
n=len(s)
MOD=1000000007
wayA=np.array([0,0,0,0])
wayB=np.array([0,0,0,0])
wayC=np.array([0,0,0,0])
hatena=0
for c in s:
	if c=="A":
		wayA[0]+=1
	if c=="B":
		wayB+=wayA
	if c=='C':
		wayC+=wayB
	if c=='?':
		wayC[1]=wayC[1]+wayB[0]
		wayC[2]=wayC[2]+wayB[1]
		wayC[3]=wayC[3]+wayB[2]
		wayB[1]=wayB[1]+wayA[0]
		wayB[2]=wayB[2]+wayA[1]
		wayA[1]=wayA[1]+1
		hatena+=1
ans=0
for i in range(0,4):
	ans=ans+pow(3,hatena-i)*wayC[i]
	ans=ans%MOD
print(int(ans))

Measured memory_bytes: 21672
import heapq
n,m=map(int, input().split())
s=list(map(int, input().split()))
for i in range(n):
    s[i]*=-1
heapq.heapify(s)
for i in range(m):
    p=heapq.heappop(s)
    p/=2
    heapq.heappush(s,p)
ans=0
for i in range(n):
    ans+=int(-s[i])
print(ans)

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;

int main(){
    int n,m;
    cin>>n>>m;
    map<int,int>w;
    REP(i,n){
        int k;
        cin>>k;
        REP(j,k){
            int a;
            cin>>a;
            w[a]++;
        }
    }
    int cnt=0;
    for(auto p:w){
        if(p.second==n)cnt++;
    }
    OUT(cnt);
    return 0;
}

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

#define STSIZE 100

void push(int);
int pop(void);

int stack[STSIZE];
int top = 0;

int main(){
  int a1,a2,a3,b1,b2,b3,c1,c2,c3,x;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a1 = pop();
      a2 = pop();
      a3 = a1 + a2;
      push(a3);
    } else if ( s[0] == '-' ){
      b1 = pop();
      b2 = pop();
      b3 = b2 - b1;
      push(b3);
    } else if ( s[0] == '*' ){
      c1 = pop();
      c2 = pop();
      c3 = c1 * c2;
      push(c3);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  
  printf("%d\n",pop());

  return 0;
}

void push(int num){
    if (top == STSIZE) {
        /* スタックがいっぱいの場合、エラー処理を行う */
        printf("Stack overflow!\n");
        exit (2);
    }
    stack[top] = num;
    top++;
}

int pop(void){
    if (top == 0) {
        /* スタックが空の場合、エラー処理を行う */
        printf("Stack is empty!\n");
        exit (3);
    }
    top--;
    return stack[top];
}



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

constexpr const int mod = 1000000007;
// constexpr const int mod = 998244353;
class mint {
 public:
  long long x;
  constexpr mint(long long x = 0) noexcept : x((x % mod + mod) % mod) {}
  constexpr int getmod() { return mod; }
  constexpr mint operator-() const noexcept { return mint(-x); }

  constexpr mint& operator+=(const mint& a) noexcept {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr mint& operator-=(const mint& a) noexcept {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr mint& operator*=(const mint& a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint& operator/=(const mint& a) noexcept {
    return (*this) *= a.inv();
  }

  constexpr mint operator+(const mint& a) const noexcept {
    return mint(*this) += a;
  }
  constexpr mint operator-(const mint& a) const noexcept {
    return mint(*this) -= a;
  }
  constexpr mint operator*(const mint& a) const noexcept {
    return mint(*this) *= a;
  }
  constexpr mint operator/(const mint& a) const noexcept {
    return mint(*this) /= a;
  }

  constexpr mint inv() const noexcept { return pow(mod - 2); }
  constexpr mint pow(long long t) const noexcept {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  friend istream& operator>>(istream& is, mint& a) noexcept {
    return is >> a.x;
  }
  friend ostream& operator<<(ostream& os, const mint& a) noexcept {
    return os << a.x;
  }
};

int main() {
  ll n, a;
  cin >> n;

  mint ans = 1;
  vector<int> d(3);
  rep(i, n) {
    cin >> a;
    int tmp = 0;
    rep(j, 3) if (d[j] == a) tmp++;
    rep(j, 3) if (d[j] == a) {
      d[j]++;
      break;
    }
    ans *= tmp;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(){
	int n, m, l;
	cin >> n >> m >> l;
    int a[n][m], b[m][l];
	long c[n][l];

	for (int i = 0; i < n ; i++)
		for (int j = 0; j < m ; j++)
            cin >> a[i][j];
    
	for (int i = 0; i < m ; i++)
		for (int j = 0; j < l ; j++)
            cin >> b[i][j];

	for (int i = 0; i < n ; i++){
    	for (int j = 0; j < l ; j++){
    	    c[i][j] = 0;
        	for (int k = 0; k < m ; k++)
        	    c[i][j] += a[i][k] * b[k][j];
        	cout << c[i][j];
        	if(j != l-1) cout << " ";
        	else cout << endl;
    	}
	}

	return 0;
}



Measured memory_bytes: 3160
program example
	implicit none

	integer(8) N,K
    
    read(*,*) N,K

    if(mod(N,K)==0) then
        write(*,*) 0

    else if(mod(N,K)<dble(K)/2.0d0) then
        write(*,*) mod(N,K)

    else
        write(*,*) K-mod(N,K)
    end if


!    do
!    	if(abs(N-K)>=N) then
!        	write(*,*) N
!            exit
!        else
!        	N=abs(N-K)
!        end if
!    end do

end program example


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

int main(void) {
	int a, b, c,k;
	long long sum = 0;
	cin >> a >> b >> c;
	cin >> k;
	for (int i = 0; i < k; i++) {
		if (a > b) {
			if (a > c) { // aが最大
				a *= 2;
			}else {		//cが最大
				c *= 2;
			}
		}else {
			if (b > c) { //bが最大
				b *= 2;
			}else { //cが最大
				c *= 2;
			}
		}
	}
	cout << a + b + c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = INF;

int main()
{
ll n , x ;
cin >> n >> x ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
vector<vector<ll>> v(n, vector<ll>(n,0) );
rep(i,n){
  ll mi;
  rep(j,n){
    mi=min(mi,a[(i-j+n)%n]);
    v[i][j]=mi;
  }
}
rep(i,n){
  ll sum=0;
  rep(j,n){
    sum+=v[j][i];
  }
  ans=min(ans,sum+i*x);
}
cout << ans << endl;

return 0;
}

Measured memory_bytes: 31616
i = [input() for i in range(3)]
#print(i)
l = []
count = 0
for n in i:
    if count != 1:
        n = int(n)
    l.append(n) 
    count += 1
#print(l)
s = l[1]
#print(type(s[l[2]]))

for i in range(l[0]):
    
    if s[i] != s[l[2]-1]:
        s = list(s)
        s[i] = '*'
        s = "".join(s)
        #s = s[:i+1] + '*' + s[i+2:]
print(s)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
	int n, m, x;
	int l[10], r[10], s[10];
	while(cin >> n >> x >> m){
		for(int i=0;i<m;i++){
			cin >> l[i] >> r[i] >> s[i];
		}
		x++;
		int end = 1;
		for(int i=0;i<n;i++) end *= x;
		int maxSum = -1;
		int ans[10];
		int res[10];
		for(int i=0;i<end;i++){
			int t = i;
			for(int j=0;j<n;j++){
				ans[j] = t%x;
				t /= x;
			}
			bool check = true;
			for(int j=0;j<m;j++){
				int sum = 0;
				for(int k=l[j];k<=r[j];k++){
					sum += ans[k-1];
				}
				if(sum != s[j]) check = false;
			}
			if(check){
				int allSum = 0;
				for(int j=0;j<n;j++) allSum += ans[j];
				if(allSum > maxSum){
					maxSum = allSum;
					for(int j=0;j<n;j++) res[j] = ans[j];
				}
			}
		}
		if(maxSum >= 0){
			for(int i=0;i<n-1;i++) cout << res[i] << " ";
			cout << res[n-1] << endl;
		} else {
			cout << -1 << endl;
		}
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

bool is_YYMM(string s){
	int month = (s[2] - '0') * 10 + (s[3] - '0');
	return month >= 1 && month <= 12;
}

bool is_MMYY(string s){
	int month = (s[0] - '0') * 10 + (s[1] - '0');
	return month >= 1 && month <= 12;
}

int main(){
	string s;
	cin >> s;
	if(is_YYMM(s) && is_MMYY(s)){
		cout << "AMBIGUOUS";
	}else if(is_YYMM(s)){
		cout << "YYMM";
	}else if(is_MMYY(s)){
		cout << "MMYY";
	}else{
		cout << "NA";
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    if ( A <= 8 && B<= 8) {
      System.out.println("Yay!");
    } else {
      System.out.println(":(");
    }
  }
}

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

bool has3(int x){
    while(x){
        if (x % 10 == 3) return true;
        x /= 10 ;
    }
    return false;
}
void call(int n){
    for (int x =1; x <= n; x ++){
        if (x%3 == 0 || has3(x)){
            cout << " "<< x;
        }
    }
    cout << endl;
}
int main(){
    int n;
    cin>> n;
    call(n);
    
    return 0;
    
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
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 repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int h, w;
int c[11][11];
int a[205][205];

int main() {
    cin >> h >> w;
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    rep(i, h) rep(j, w) cin >> a[i][j];

    rep(k, 10) rep(i, 10) rep(j, 10) {
        chmin(c[i][j], c[i][k] + c[k][j]);
    }

    int ans = 0;
    rep(i, h) rep(j, w) {
        if (a[i][j] < 0) continue;
        ans += c[a[i][j]][1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3760
#include <stdio.h>

int main(void){
    long long int N,A,B,C,D;
    scanf("%lld %lld %lld %lld %lld",&N,&A,&B,&C,&D);
    int flag=0;
    for(int i=0;i<N;i++){
        if(i*D-(N-i-1)*C>=B-A&&i*C-(N-1-i)*D<=B-A){flag=1;break;}
    }if(flag==1)printf("YES");else printf("NO");
    return 0;
}


Measured memory_bytes: 128
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ; 
const ll INF = 1e9 + 10;
ll n;
vector<double>h;
double dfs(ll i){
	if(i>=n)return 1;
	double choice1 = h[i] * dfs(i+1);
	double choice2 = (1-h[i]) * dfs(i+1);
	return choice1+choice2;
}
int main(){
	fastio;
	ll n;
	cin>>n;
	ll ar[n+1];
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	ll ar2[n+1];
	for(int i=1;i<=n;i++){
		ar2[ar[i]]=i;
	}
	for(int i=1;i<=n;i++){
		cout<<ar2[i]<<" ";
	}
}	

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

#define ft first
#define sd second
#define sz(x) ((int)x.size())

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef double de;



string s, t;
int n, l, r, m;

void cc() {
	if (s == "Vacant" || t == "Vacant")
		exit(0);
}

int main() {
	cin >> n;
	cout << 0 << endl;
	cin >> s;
	cc();
	l = 0, r = n;
	while (1) {
		m = ((r + l) >> 1);
		cout << m << endl;
		cin >> t;
		cc();
		if (s == t) {
			if ((m - l) & 1)
				r = m;
			else
				l = m;
		}
		else {
			if ((m - l) & 1)
				l = m, s = t;
			else
				r = m;
		}
	}
	return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/9/2018
 
 12:50-13:22 analysis
 13:37 1WA
 13:45 give up (not optimal.. dp?)
 
 
 
 */


// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int H,W;
LL A[MAX_N],B[MAX_N];
void solve_wrong() {
  priority_queue<LL, vector<LL>, greater<LL>> Q1,Q2;
  REP(i,W) Q1.emplace(A[i]);
  REP(i,H) Q2.emplace(B[i]);
  LL res=0;
  while(SZ(Q1)||SZ(Q2)) {
    const LL Inf=1e15;
    int r=H-SZ(Q2),c=W-SZ(Q1);
    
    LL cost1=Inf,cost2=Inf;
    if(SZ(Q1)) {
      cost1=Q1.top()*(1LL*H+1-r);
    }
    if(SZ(Q2)) {
      cost2=Q2.top()*(1LL*W+1-c);
    }
    if(cost1<cost2) Q1.pop();
    else Q2.pop();
    res+=min(cost1,cost2);
  }
  cout<<res<<endl;
}

void solve() {
  priority_queue<pair<LL,int>, vector<pair<LL,int>>, greater<pair<LL,int>>> Q;
  REP(i,W) Q.emplace(A[i],i);
  REP(i,H) Q.emplace(B[i],i+W);
  LL res=0;
  int r=0,c=0;
  while(SZ(Q)) {
    LL d; int p; tie(d,p)=Q.top(); Q.pop();
    if(p<W) {
      res+=d*(1LL*H+1-r);
      ++c;
    } else {
      res+=d*(1LL*W+1-c);
      ++r;
    }
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>W>>H;
  REP(i,W) cin>>A[i];
  REP(i,H) cin>>B[i];
  solve();
  return 0;
}


Measured memory_bytes: 8048
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    VI v(n + 1);
    VI box(n + 1, 0);
    int m = 0;
    rep(i, n) cin >> v[i + 1];
    for (int i = n; i >= 1; i--)
    {
        int sum = 0;
        int j = 2;
        while (i * j <= n)
        {
            sum += box[i * j];
            j++;
        }
        cerr << i << " " << sum << endl;
        box[i] = (v[i] + sum % 2) % 2;
        m += box[i];
    }
    cout << m << endl;
    rep(i, 1, n + 1)
    {
        if (box[i] == 1)
        {
            cout << i << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define mp make_pair
#define X  first
#define Y  second
#define N 100000

int main()
{
    int l, r, d;
    cin>>l>>r>>d;
    if(l%d==0)
    {
        int x=((r/d)-(l/d)+1);
        cout<<(x);
    }
    else{
        cout<<(r/d)-(l/d);
    }

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,k,i;
    cin >> n >> k;
    ll p[n];
    double ex[n],maxsum=0.0,sum=0.0;
    for(i=0;i<n;i++) {
    	cin >> p[i];
    	ex[i] = (double)(p[i]*(p[i]+1))/(double)(2*p[i]);
    }
    for(i=0;i<k;i++) {
    	sum+=ex[i];
    	maxsum=max(maxsum,sum);
    }
    for(i=k;i<n;i++) {
    	sum+=ex[i];
    	sum-=ex[i-k];
    	maxsum=max(maxsum,sum);
    }
    cout << fixed << setprecision(6) << maxsum << "\n";
    return 0;
}



Measured memory_bytes: 3456
#1
n = int(input())
a = [0]

for i in range(n):
    a.append(int(input()))

cnt = 0
b = 1
ans = 0

for j in range(n+1):
    cnt += 1
    b = a[b]
    
    if b == 2:
        ans = 1
        break
if ans == 1:
    print(cnt)

else:
    print("-1")
    

Measured memory_bytes: 7080
#include<bits/stdc++.h>
using namespace std;
int a,now,ans;
char u;
int main()
{
	cin>>a;
	for(int s=0;s<a;s++)
	{
		cin>>u;
		if(u=='I')now++;
		else
		now--;
		ans=max(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// ll dp[100005][3]

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m,x; cin>>n>>m>>x;
  set<ll> a; rep(i,m) {ll b; cin>>b; a.insert(b);}
  
  ll ans=LINF;
  ll tmp=0;
  ll now=x-1;
  while(now){
    if(a.count(now)) tmp++;
    now--;
  }
  chmin(ans, tmp);
  
  tmp=0;
  now=x+1;
  while(now<n){
    if(a.count(now)) tmp++;
    now++;
  }
  chmin(ans, tmp);
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
a = int(input())
b = a % 10;
if b == 2 or b == 4 or b == 5 or b == 7 or b == 9:
    print("hon")
if b == 0 or b == 1 or b == 6 or b == 8:
    print("pon")
if b == 3:
    print("bon")

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

long long knap(long  long W,long long wt[],long long v[],long long n)
{
   long long i, w;
   long long K[n+1][W+1];

   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(v[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }

   return K[n][W];
}

int main()
{
    int q,a,b;
   long long ans;
    long long n,m;


        cin>>n>>m;
        long long w[n];
    long long v[n];
        for(int j=0;j<n;j++)
        {
         cin>>w[j];
            cin>>v[j];
        }
        ans=knap(m,w,v,n);

    cout<<ans;
}


Measured memory_bytes: 79104
import math

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

mod = 10 ** 9 + 7
x, y = list(map(int, input().split()))

def mod_fact(frm, to):
	ans = 1
	for i in range(frm, to + 1):
		ans = (ans * i) % mod
	return ans



if (x + y) % 3 == 0 and x <= y * 2 and y <= x * 2:
	n = (y * 2 - x) // 3
	m = (x + y) // 3
	#print(n, m)
	#print(mod_fact(m - n + 1, m))
	#print(mod_fact(1, n))

	print((mod_fact(m - n + 1, m) * (mod_inv(mod_fact(1, n), mod)) % mod))
else:
	print(0)


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <tuple>

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::vector<std::pair<int, size_t>> ab(N);
  for (size_t i = 0; i < N; ++i)
    scanf("%d %zu", &ab[i].first, &ab[i].second);

  std::sort(ab.begin(), ab.end());
  for (const auto& p: ab) {
    int a;
    size_t b;
    std::tie(a, b) = p;
    if (b >= K)
      return !printf("%d\n", a);

    K -= b;
  }
  return 1;
}

Measured memory_bytes: 1792
#include <iostream>


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

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

    //?????????????????¢???????????????
    if (x < 0 || x > W || y < 0 || y > H) {
        in = false;
    } else if ((y - r) < 0 || (y + r) > H) { //??????????????¨?????????????????????
        in = false;
    } else if ((x - r) < 0 || (x + r) > W) {
        in = false;
    } else {
        in = true;
    }


    if (in) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

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

	bool spade[13] = { false };
	bool hart[13] = { false };
	bool club[13] = { false };
	bool diamond[13] = { false };


	for (int i = 0; i < count; i++)
	{
		string mark;
		int no;

		cin >> mark >> no;
		int no_minus = no - 1;
		
		if (mark == "S") spade[no_minus] = true;
		if (mark == "H") hart[no_minus] = true;
		if (mark == "C") club[no_minus] = true;
		if (mark == "D") diamond[no_minus] = true;
	}
	for (int i = 0; i < 13; i++)
	{
		if (!spade[i]) cout << "S " << i + 1 << endl;
	}
	for (int i = 0; i < 13; i++)
	{
		if (!hart[i]) cout << "H " << i + 1 << endl;
	}
	for (int i = 0; i < 13; i++)
	{
		if (!club[i]) cout << "C " << i + 1 << endl;
	}
	for (int i = 0; i < 13; i++)
	{
		if (!diamond[i]) cout << "D " << i + 1 << endl;
	}
}


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

int main(){
    int N = 0;
    cin >> N;
    string S;
    cin >> S;
    int maxa= 0;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        if(S[i] =='I'){
            count++;
        }
        else{
            count--;
        }
        if (maxa < count)
        {
            maxa = count;
        }
    }
    cout << maxa << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;
}

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

		
int main(){
	long long int n, a, b;
	long long int mod = 1e9+7;
	cin >> n >> a >> b;
	long long int num = modpow(2,n,mod) - 1;
	num %= mod;
	long long int p = 1, q = 1;
	for(long long int i=1;i<=a;i++){
		p *= n+1-i;
		p%=mod;
		p *= modinv(i,mod);
		p %= mod;
	}
	for(long long int i=1;i<=b;i++){
		q *= n+1-i;
		q%=mod;
		q *= modinv(i,mod);
		q %= mod;
	}
	long long int ans = num - p - q;
	while(ans < 0){
		ans += mod;
	}
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;

int n,m;
int sum;
int date[10000000];
void dfs(int a=0,int b=0){
  if(b>=3) date[sum]=a,sum++;
  if(b<m){
    dfs(a*10+3,b+1);
    dfs(a*10+5,b+1);
    dfs(a*10+7,b+1);
  }
}
 
int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    int c=n,d=0;
    while(true){
      if(c==0) break;
      m++;
      c/=10;
    }
    dfs();
    for(int i=0;i<sum;i++){
      if(date[i]<=n&&date[i]!=0){
	int e=0,f=0,g=0;
	while(true){
	  if(date[i]==0) break;
	  if(date[i]%10==3) e=1;
	  if(date[i]%10==5) f=1;
	  if(date[i]%10==7) g=1;
	  date[i]/=10;
	}
	if(e+f+g==3) d++;
      }
    }
    cout<<d<<"\n";
 
 return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

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

s = set()

for i in range(0, K):
    d = int(input())
    As = map(int, input().split())
    for a in As:
        s.add(a)

# print(s)
# print(len(s))
print(N - len(s))


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

 int main() {

 int N,A;
 cin>>N>>A;
 int L=A;
 int R=A+N-1;

 int eat;
 if(R<=0)eat=R;
 else if(L>=0)eat=L;
 else eat=0;

 int answer=(R+L)*(R-L+1)/2-eat;

 cout<<answer<<endl;

 return 0;

 }

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int N,K;

class RootedNode{
public:
	vector<ll> parent;
	ll depth,dist;
	RootedNode():depth(0),dist(0){}
};

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

int mod = 1e9+7;
class RootedTree{
	int parent_size;

	ll DFS(ConnectNodeInfo& connection,ll child,ll parent,ll dep,ll dist){
		node[child].parent[0] = parent;
		node[child].depth = dep;
		node[child].dist = dist;

		ll color_num;
		if(parent==-1) color_num = K-1;
		else color_num = K-2;

		if(connection[child].size()>K) return 0;
		else{
			ll case_num = 1;
			for(auto& x:connection[child]){
				if(x.first==parent) continue;
				case_num *= color_num;
				case_num %= mod;
				color_num--;
			}
			for(auto& x:connection[child]){
				if(x.first==parent) continue;
				case_num *= DFS(connection,x.first,child,dep+1,dist+x.second);
				case_num %= mod;
			}
			return case_num;
		}
	}
public:
	ll total_num;
	vector<RootedNode> node;

	RootedTree(ConnectNodeInfo& connection){
		auto connection_size = connection.size();
		parent_size = 1;
		while((1LL<<parent_size)<connection_size) parent_size++;

		node.resize(connection_size);
		for(auto& x:node) x.parent.resize(parent_size);
		total_num = K*DFS(connection,0,-1,0,0);
		total_num %= mod;
	}
};

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

	N=in(),K=in();
	ConnectNodeInfo connection(N);
	REP(i,N-1){
		int u=in(),v=in();
		connection.AddConnection(u-1,v-1,1);
	}
	RootedTree tree(connection);

	cout << tree.total_num << endl;
	return 0;
}


Measured memory_bytes: 29696
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if(a >= 13)
  {
    cout << b;
  }
  else if(a >= 6)
  {
    cout << b / 2;
  }
  else
  {
    cout << 0;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    //fast;
    long long n,i;
    cin>>n;
    string s;
    map<string,long long> m;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;

    cout<<"WA x "<<m["WA"]<<endl;

    cout<<"TLE x "<<m["TLE"]<<endl;

    cout<<"RE x "<<m["RE"]<<endl;

}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    vector<int>P(N);rep(i,N)cin>>P[i];
    sort(all(P));
    P[N-1]/=2;
    cout<<accumulate(all(P),0ll)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 1e5 + 5 ;
const ll mod = 1e9 + 7 ;
int n , k ;
ll a[maxn] ;
ll f[maxn] ;
void init()
{
	f[0] = 1 ;
	for(int i = 1 ; i <= 1e5 ; i ++)
	  f[i] = f[i - 1] * ll(i) % mod ;
}
ll qpow(ll a , ll b)
{
    ll ans = 1 ; 
    while(b)
    {
        if(b & 1)
          ans = (ans * a) % mod ;
        b >>= 1 ;
        a = (a * a) % mod ;
    }
    return ans % mod ;
}
ll solve(ll x)
{
	return qpow(x , mod - 2) % mod ; //qpow�ǿ����ݡ�
}
ll C(ll x , ll y)
{
	if(x < y)  return 0 ;
	if(x == y)  return 1 ;
	return f[x] * solve(f[y] * f[x - y] % mod) % mod ;
}
int main()
{
	init() ;
	scanf("%d%d" , &n , &k) ;
	for(int i = 1 ; i <= n ; i ++)
	  scanf("%lld" , &a[i]) ;
	sort(a + 1 , a + n + 1) ;
	ll ans = 0 ;
	for(int i = 1 ; i <= n ; i ++)
	  ans += (C(i - 1 , k - 1) - C(n - i , k - 1)) * a[i] % mod , ans %= mod ;
	printf("%lld\n" , ans) ;
	return 0 ;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a,b;
  int p;
  int cnt[3] = {};
  cin >> n >> a >> b;
  for(int i=0;i<n;i++){
    cin >> p;
    if(p <= a) cnt[0]++;
    else if(p >= b+1) cnt[2]++;
    else cnt[1]++;
  }
  int ans = 100000;
  for(int i=0;i<3;i++) ans = min(ans,cnt[i]);
  cout << ans << endl;
}

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

int P, Q, R;
void solve()
{
	int abc = P + Q;
	int acb = R + Q;
	int bca = Q + R;
	int bac = P + R;
	int cab = R + P;
	int cba = Q + P;
	int ans = min(abc, acb);
	ans = min(ans, bca);
	ans = min(ans, bac);
	ans = min(ans, cab);
	ans = min(ans, cba);
	cout << ans << endl;
}
int main()
{
	cin >> P >> Q >> R;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if ((1 <= i && 10 > i) || (100 <= i && 1000 > i) || (10000 <= i && 100000 > i)) {
			ans++;
		}
		else continue;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

ll N;
ll F[110][11];
ll P[110][11];
ll ctl[10] = {0,1,2,3,4,5,6,7,8,9};
ll ans = -inf;

int main() {
    cin >> N;
    rep(i,N){
        rep(j,10){
            cin >> F[i][j];
        }
    }
    rep(i,N){
        rep(j,11){
            cin >> P[i][j];
        }
    }
    for (ll i=1; i<1<<10; i++){
        ll temp = 0;
        vector<ll> num(110,0);
        rep(j,10){
            if (i & 1<<j){
                rep(x,N){
                    num[x] += F[x][j];
                }
            }
        }
        rep(p,N){
            temp += P[p][num[p]];
        }
        ans = max(ans,temp);
        
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_D
  * ????¨?
  * ?§???????????????? SS ???????????????????????§???hh:mm:ss ?????¢?????????????????????????????????????????????????????§???hh ????????????mm ??? 60 ???????????????ss ??? 60 ??????????§???¨????????????
  */
object Main {
  def main(args: Array[String]): Unit = {
    val seconds = io.StdIn.readInt()
    val hh = seconds / (60 * 60)
    val mm = (seconds - hh * 60 * 60) / 60
    val ss = seconds - hh * 60 * 60 - mm * 60
    println(s"$hh:$mm:$ss")
  }
}

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

int main() {
    int N; cin >> N;
    vector<int> num(N + 2);
    rep(i, N) {
        int a, b; cin >> a >> b;
        if (a > N + 1) continue;
        num[a - 1]++; num[min(b, N + 1)]--;
    }
    int maxi = 0;
    for (int i = 1; i < N + 2; ++i) {
        num[i] += num[i - 1];
        if (num[i] >= i) maxi = i;
    }
    cout << maxi << endl;
}

Measured memory_bytes: 3108
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! chmin {
    ( $ x : expr , $ y : expr ) => { if $ x > $ y { $ x = $ y ; true } else { false } };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n]
    }

    let cum = Cum::new(&a);
    let mut ret = 1i64 << 60;
    for i in 1..n {
        chmin!(ret, (cum.sum(0,i) - cum.sum(i,n)).abs());
    }
    println!("{}", ret);
}

#[derive(Debug)]
#[allow(dead_code)]
struct Cum {
    s: Vec<i64>,
}
#[allow(dead_code)]
impl Cum {
    fn new(a: &Vec<i64>) -> Cum {
        let mut s = vec![0; a.len() + 1];
        for i in 0..a.len() {
            s[i + 1] = s[i] + a[i];
        }
        Cum { s: s }
    }
    #[doc = " [l,r)"]
    fn sum(&self, l: usize, r: usize) -> i64 {
        self.s[r] - self.s[l]
    }
}

Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
typedef pair <int,int>gu;
int main(){
  int N,temp,tamp,min=10005,z;
  cin>>N;
  vector<gu> A(N);
  for(int i=0;i<N;i++){
    cin>>z;
    A[i]=make_pair(z,i+1);
  }
   sort(A.begin(),A.end());
  for(int h=0;h<N;h++) {
    cout<<A[h].second;
    if(h!=N-1)cout<<" ";
  }
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int n,m;
vector<int> ans;
string s;
int main(){
    cin>>n>>m>>s;
    for(int i=n,j;i>0;i-=j){
        for(j=min(m,i);s[i-j]=='1';){
            j--;
        }if(i!=0&&j==0){
            cout<<-1<<endl;
            return 0;
        }
        //cout<<j<<endl;
        ans.push_back(j);
    }
    for(int i=ans.size()-1;i>=0;i--){
        cout<<ans[i];
        if(i)cout<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1144
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define LOCAL  1
#define UPLOAD 2
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';

#define ll long long

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  int n = input();
  vector<int> p;
  for(int i=0;i<n;i++){
    p.push_back(input());
  }

  int counter = 0;
  for(int i=0;i<n-2;i++){
    if(p[i+1] > p[i] && p[i+1] < p[i+2]){
      counter++;
    }
    if(p[i+1] > p[i+2] && p[i+1] < p[i]){
      counter++;
    }
  }

  output(counter);

  return 0;
}

Measured memory_bytes: 256
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
i = int(input())
print(l[i-1])

Measured memory_bytes: 3060
""" AtCoder """

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB = sorted(AB)

ans = 0
i = 0
while True:
    if M <= AB[i][1]:
        ans += AB[i][0] * M
        print(ans)
        exit()
    ans += AB[i][0] * AB[i][1]
    M -= AB[i][1]
    i += 1


Measured memory_bytes: 28648
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int N;
    cin >> N;
    array<int, 3> dp = {0, 0, 0};

    for (int i = 0; i < N; i++) {
        int happy[3];

        for (int a = 0; a < 3; a++)
            cin >> happy[a];

        array<int, 3> next_dp = {0, 0, 0};

        for (int a = 0; a < 3; a++)
            for (int b = 0; b < 3; b++)
                if (a != b)
                    next_dp[b] = max(next_dp[b], dp[a] + happy[b]);

        dp = next_dp;
    }

    cout << *max_element(dp.begin(), dp.end()) << '\n';
}


Measured memory_bytes: 256