akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	std::string a, b, c;
	std::cin >> a >> b >> c;
	if (a.back() == b.front() && b.back() == c.front()) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i<n-2; i++){
     if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;   
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
const ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

const int NN=21;
bool a[NN][NN];
ll memo[NN][1<<NN];
unordered_map<int,int> bt;
ll dp(int i, int mask){
	if(mask==0) return 1;
	else if(memo[i][mask]!=-1) return memo[i][mask];
	ll& ret=memo[i][mask]; ret=0;
	for(int j=0;j<NN;++j){
		if(a[i][j] && mask&(1<<j)) ret=(ret+dp(i+1, mask^(1<<j)))%MOD;
	}	
	return ret;
}	
///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());


int n; cin>>n;
memset(memo, -1, sizeof(memo));
for(int i=0;i<n;++i) for(int j=0;j<n;++j) cin>>a[i][j];
for(int i=0;i<NN;++i) bt[1<<i]=i;
cout << dp(0,(1<<n)-1)<<el;


return 0;
}


Measured memory_bytes: 344448
while True:
    h, w = map(int, input().split())
    if h == 0:
        break
    for h_ in range(h):
        if h_ == 0 or h_ == h - 1:
            for w_ in range(w):
                print('#', end = '')
            print()
        else:
            for w_ in range(w):
                if w_ == 0 or w_ == w - 1:
                    print('#', end = '')
                else:
                    print('.', end = '')
            print()
    print()


Measured memory_bytes: 7004
import sys
inp = sys.stdin.readline

D, G = map(int,inp().split())
PC = [list(map(int,inp().split())) for _ in range(D)]

ans = 10**9+7
result = []
for i in range(1 << D):
  point = 0
  cnt = 0
  tmp = []
  for j in range(D):
    if(((i >> j) & 1) == 1):
      point += PC[j][0] * 100 * (j+1) + PC[j][1]
      cnt += PC[j][0]
    else:
      tmp.append(j)
  if(point < G):
    r = G - point
    k = tmp[-1]
    if((PC[k][0]-1) * (k+1) * 100 < r):
      continue
    cnt += -(-r // (100 * (k + 1)))
  ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3064
use std::io::stdin;
use std::io::BufRead;
use std::io::BufReader;

fn main() {
let mut scan = std::io::stdin();
 
let mut line = String::new();
 
let _ = scan.read_line(&mut line);
 
let vec: Vec<&str> = line.split_whitespace().collect();
 
let a: i32 = vec[0].parse().unwrap_or(0);
let b: i32 = vec[1].parse().unwrap_or(0);
//二行目

if (8 < a) | (8 < b)  {
    println!(":(");
}
if !((8 < a) | (8 < b))  {
    println!("Yay!");
}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N, M;
    cin >> N;
    vector<int> A(N);
    cin >> M;
    int sum = 0;
    REP (i, N) {
        cin >> A[i];
        sum += A[i];
    }
    REP(i,N) {
        if (A[i] >= (LD) sum/(4.0*M)) ans++;
    }
    if (ans >= M) yes;
    else no;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc161/abc161_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc161/abc161_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc161/abc161_b && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define inf 1000000000000000007LL
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,m,l;
int val[3005][3005];
int dp[3005][3005][4];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>l;
	for(int i=1;i<=l;i++)
	{
		int r,c,v;
		cin>>r>>c>>v;
		val[r][c]=v;
	}
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			for(int k=0;k<=3;k++)
				dp[i][j][k]=-inf;
	int ans=-inf;
	dp[1][1][0]=0;
	ans=max(ans,0LL);
	if(val[1][1]>0)
	{
		dp[1][1][1]=val[1][1];
		ans=max(ans,val[1][1]);
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=0;k<=3;k++)
			{
				if(i==1&&j==1) continue;
				if(k==0) dp[i][j][k]=max(dp[i][j][k],max(max(dp[i-1][j][0],dp[i-1][j][1]),max(dp[i-1][j][2],dp[i-1][j][3])));
				dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
				if(val[i][j]>0)
				{
					if(k==1) dp[i][j][k]=max(dp[i][j][k],max(max(dp[i-1][j][0],dp[i-1][j][1]),max(dp[i-1][j][2],dp[i-1][j][3]))+val[i][j]);
					if(k!=0) dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+val[i][j]);
				}
				ans=max(ans,dp[i][j][k]);
			}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 355560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    vector<string>v;
    for(int i=0;i<=s.length()-t.length();i++)
    {
        string str="";
        for(int j=i;j<i+t.length();j++)
        {
            string k(1,s[j]);
            str+=k;
        }
        v.push_back(str);
    }
    vector<int>v1;
    for(int i=0;i<v.size();i++)
    {
        int count=0;
        for(int j=0;j<v[i].length();j++)
        {
            if(v[i][j]!=t[j])
            {
                count+=1;
            }
        }
        v1.push_back(count);
    }
    sort(v1.begin(),v1.end());
    cout<<v1[0]<<endl;
}

Measured memory_bytes: 3864
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll z(ll a){
  if(a<0)return -a;
  return a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;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;
  }
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(void){
  int n;
  scanf("%d",&n);
  ll a[n],sum=0;
  FOR(n){
    scanf("%lld",&a[i]);
    sum+=a[i];
  }
  ll s=0,ans=INF;
  FOR(n){
    s+=a[i];
    ans=min(z(sum-2*s),ans);
  }
  PRL(ans);
  return 0;
}


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

int main() {
    int a, b;
    string A, B;
    cin >> a >> b;

    for (int i = 0; i < b; i++) {
        A += to_string(a);
    }
    for (int i = 0; i < a; i++) {
        B += to_string(b);
    }

    if (A < B) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }
}

Measured memory_bytes: 3696
import sys
input = sys.stdin.readline
from itertools import permutations
from math import factorial
def main():
    N = int(input())
    xy = [tuple(map(int,input().split())) for _ in range(N)]
    answer = 0
    for perm in permutations(list(range(N))):
        for i in range(N-1):
            answer += ((xy[perm[i+1]][1]-xy[perm[i]][1])**2 + (xy[perm[i+1]][0]-xy[perm[i]][0])**2)**(1/2)
    print(answer/factorial(N))
    return


if __name__ == '__main__':
    main()


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


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

    ll n;
    cin>>n;
    ll d[n];
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    ll ans=0;
    sort(d,d+n);
    ll l=n/2 -1;
    ll r=n/2;
    ans = d[r] - d[l];
    cout<<ans<<endl;
}

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

int main()
{
	int N;
  	cin >> N;
  	vector<int> A;
  	for(int i = 0; i < N; i++){
    	int a;
      	cin >> a;
      	A.push_back(a);
    }
  	while(A.size() > 1){
        sort(A.begin(), A.end());
        if(A.front() > 0){
            int k = A.front();
            for(int i = 1; i < A.size(); i++){
                A[i] = A[i]%k;
                if(A[i] == 0) A.erase(A.begin()+i);
            }
        }
    }
  	cout << A.front() << endl;
}

Measured memory_bytes: 892
Public Class Program
  Shared Sub Main()
    Dim nk As Integer() = Cin.IntArr()
    Dim n As Integer = nk(0)
    Dim k As Integer = nk(1)
    Dim rsp As Integer() = Cin.IntArr()
    Dim t As String = Cin.Str()
    Dim win As String = "spr"
    
    Dim ans As Integer = 0
    Dim u(0 To n - 1) As Char
    For i As Integer = 0 To n - 1
      If i >= k AndAlso u(i - k) = t(i) Then
        u(i) = "?"
      Else
        ans += rsp(win.IndexOf(t(i)))
        u(i) = t(i)
      End If
    Next
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class


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

int main(void)
{
    int N;
    cin >> N;
    vector<string> s(N);

    for (int i = 0; i < N; i++)
    {
        string input;
        cin >> input;
        sort(input.begin(), input.end());
        s[i] = input;
    }

    sort(s.begin(), s.end());

    vector<int> counts(0);
    counts.push_back(1);
    for(int i = 1; i < N; i++){
        if(s[i] != s[i-1]){
            counts.push_back(1);
        } else {
            counts[counts.size() - 1]++;
        }
    }

    ll result = 0;
    for(int i = 0; i < counts.size(); i++){
        ll val = counts[i];
        result += val * (val - 1) / 2;
    }

    cout << result << endl;
    return 0;
}


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

int y(int x){
  int s=0;
  for(int i=1;i<=sqrt(x);i++){
    if(x%i==0) s++;
  }
  s*=2;
  int p=sqrt(x);
  if(p*p==x) s--;
  return(s);
}

int main(){
  int n;
  cin >> n;
  int ans=0;
  for(int i=n-1;i>0;i--){
    ans+=y(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3676
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include <iomanip>

#define rep0(i,N) for(int i=0;i<N;i++)
#define rep1(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005

using namespace std;

int main(){
	double a,b;
	cin>>a>>b;
	cout<< fixed << setprecision(8) <<1/(1/a+1/b);

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=15;
const int inf=0x3f3f3f3f;
#define endl '\n'

int v[N],has[N],mt[N][N],n,m,x,ans,sum;

void dfs(int idx){
	if(idx>=n) return;
	sum+=v[idx];
	bool flag=1;
	for(int i=0;i<m;i++){
		has[i]+=mt[idx][i];
		if(has[i]<x) flag=0; 
	}
	if(flag) ans=min(ans,sum);
	else dfs(idx+1);
	sum-=v[idx];
	for(int i=0;i<m;i++)
	has[i]-=mt[idx][i];
	dfs(idx+1);
}

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>v[i];
		for(int j=0;j<m;j++)
		cin>>mt[i][j];
	}
	memset(has,0,sizeof(has));
	ans=inf;
	sum=0;
	dfs(0);
	if(ans==inf) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.io.IOException;

public class Main {
    static class Store implements Comparable<Store> {
        int index;
        String name;
        int score;

        Store(int index, String name, int score) {
            this.index = index;
            this.name = name;
            this.score = score;
        }

        @Override
        public int compareTo(Store s) {
            if(name.equals(s.name)) return s.score - score;
            return name.compareTo(s.name);
        }
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        PriorityQueue<Store> stores = new PriorityQueue<>();
        for(int i = 0; i < n; i++) {
            String[] in = br.readLine().split(" ");
            stores.add(new Store(i, in[0], Integer.parseInt(in[1])));
        }

        while(!stores.isEmpty()) {
            Store s = stores.poll();
            System.out.println(s.index + 1);
        }

        br.close();
    }
}

Measured memory_bytes: 21204
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s1[100000];
    int i,n;
    
    scanf("%s",s1);
    n=strlen(s1);
    
    for(i=0;i<n;i=i+2)
        printf("%c",s1[i]);    
        
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

ll m;
ll fact[100010], fact_inv[100010];

ll mod_pow(ll x, ll n, ll mo){
	if(n==0) return 1;
	ll res = mod_pow(x * x % mo, n / 2, mo);
	if(n & 1) res = res * x % mo;
	return res;
}

void fact_(ll a){
	fact[0]=1;
	for(ll i=0;i<a;i++){
		fact[i+1]=fact[i]*(i+1)%MOD;
	}
	fact_inv[a]=mod_pow(fact[a], MOD-2, MOD);
    for(ll i=a-1;i>=0;i--){
    	fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
    }
    return ;
}

ll nCr(ll n, ll r){
	if(r==0) return 1;
	else return (((fact[n]*fact_inv[r])%MOD)*fact_inv[n-r])%MOD;
}

ll aa, me[100010], f, s;

int main(){
	cin >> m;
	for(ll i=1;i<=m+1;i++){
		cin >> aa;
		if(me[aa]==0){
			me[aa] = i;
		}else{
			f = me[aa];
			s = i;
			break;
		}
	}
	fact_(m);
	cout << m << endl;
	for(ll k=2;k<=m-1;k++){
		if(m-s+f >= k-1) cout << (nCr(m-1, k) + nCr(m-1, k-1)*2 + nCr(m-1, k-2) - nCr(m-s+f, k-1) + MOD) % MOD << endl;
		else cout << (nCr(m-1, k) + nCr(m-1, k-1)*2 + nCr(m-1, k-2) + MOD) % MOD << endl;
	}
	if(m!=1){
		if(s-f==1){
			cout << m << endl;
		}else{
			cout << m+1 << endl;
		}
	}
	cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 3584
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define debug(...) (cerr<<"'"<<__FUNCTION__<<"': "),fprintf(stderr,__VA_ARGS__)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,m;
set<pair<int,int> >st;
int main()
{
	getii(n,m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		getii(x,y);
		st.insert(MP(x,y));
		st.insert(MP(y,x));
	}
	for(int i=1;i<=n;i++)
	{
		if(st.find(MP(1,i))!=st.end()&&
		   st.find(MP(i,n))!=st.end())
		{
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
		   
	return 0;
}

Measured memory_bytes: 19072
import fractions
def f(a, b, p):
    return b // p - (a - 1) // p
a, b, c, d = map(int, input().split())
l = c * d // fractions.gcd(c, d)
print((b - a + 1) - f(a, b, c) - f(a, b, d) + f(a, b, l))

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) cout << '+' << endl;
	else if (a * b == 15) cout << '*' << endl;
	else cout << 'x' << endl;
	return 0;
}

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

int main(){
    uint_fast64_t N, K;
    constexpr uint_fast64_t M(1000000007);
    scanf("%llu%llu", &N, &K);
    vector<uint_fast64_t> ans(K + 1), bef(K + 1);
    ans[K] = 1;
    for(uint_fast64_t i = 0, a; i < N; ++i){
        scanf("%lld", &a);
        swap(ans, bef);
        partial_sum(bef.begin(), bef.end(), bef.begin());
        for(uint_fast64_t j = 0; j <= K; ++j){
            if(!j){
                ans[j] = bef[j + a];
            }else if(j + a <= K){
                ans[j] = bef[j + a] - bef[j - 1];
            }else{
                ans[j] = *bef.rbegin() - bef[j - 1];
            }
            ans[j] %= M;
        }
    }
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
  int root(int x) {
        if (data[x] < 0) return x;
        else return data[x] = root(data[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int n,m;
  cin>>n>>m;
  vi red(n,0),ball(n,1);
  red[0] = 1;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    ball[b]++;
    ball[a]--;
    if(red[a]){
      red[b] = 1;
    }
    if(ball[a] ==0)red[a] = 0;
  }
  int ans=0;
  rep(i,n){
    ans+=(red[i]>0);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
n = gets.chomp.to_i
vs = gets.chomp.split(' ').map(&:to_i).sort
max_value = (vs[0]+vs[1])/2.to_f
if n == 2
    puts max_value
    exit
end

2.upto(n-1) do |i|
    max_value = (max_value+vs[i])/2.to_f
end
puts max_value


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> v;
    long long int sum=0;
    for(int i=0;i<m;i++)
    {
        int data;
        cin>>data;
        sum+=data;
        v.push_back(data);
    }
    if(sum>n)
    cout<<-1;
    else
    cout<<abs(sum-n);
    
    
}

Measured memory_bytes: 3732
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    long[Pair] edge;
    foreach (i; iota(n))
    {
        foreach (j; iota(i, n))
        {
            if (i != j)
                edge[Pair(i + 1, j + 1)] = 1;
        }
    }
    auto t = n + (n + 1) % 2;
    // t.writeln();
    foreach (i; iota(1, n + 1))
    {
        if (Pair(i, t - i) in edge)
            edge.remove(Pair(i, t - i));
    }
    writeln(edge.length);
    foreach (key, value; edge)
    {
        writefln("%s %s", key.x, key.y);
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2556
#pragma GCC optimize("O2,unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s, t;
	cin >> s;
	for(auto i : s) {
		if(i == 'S') t.pb(i);
		else if(t.size() && t.back() == 'S') t.pop_back();
		else t.pb(i);
	}
	cout << t.size();
}


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

using namespace std;

typedef long long ll;

const int N = 100 * 1000 + 10;

vector<int> g[N];
int par[N];
int n, k;
int res;

int dfs(int v) {
    int max_h = 0;
    for (int to : g[v])
        max_h = max(max_h, dfs(to));
    if (max_h == k - 1 && par[v] != 0) {
        res++;
        max_h = -1;
    }
    return max_h + 1; 
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    int x;
    cin >> x;
    if (x != 1)
        res++;
    for (int i = 1; i < n; i++) {
        cin >> x;
        x--;
        par[i] = x;
        g[x].push_back(i);
    }
    dfs(0);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
const ll MOD = 1e9 + 7;
using ld = long double;
vector<vector<ld>> dp(3000 + 10, vector<ld>(3000 + 10));
int main(){
    dp[0][0] = 1;
    ll N;
    cin >> N;
    for(ll i = 1; i <= N; i++){
        ld p;
        cin >> p;
        dp[i][0] = dp[i - 1][0] * (1 - p);
        for(ll j = 1; j <= i; j++) dp[i][j] = p * dp[i - 1][j - 1] + (1 - p) * dp[i - 1][j];
    }
    ld ans = 0;
    for(ll i = N / 2 + 1; i <= N; i++) ans += dp[N][i];
    printf("%.10Lf\n", ans);
    return 0;
}


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

int n,f[100000],q,g[50000];
int x=0;

int main(){
	cin >> n;
	for(int i=0;i<n;i++) cin >> f[i];
	cin >> q;
	for(int i=0;i<q;i++) cin >> g[i];
	for(int i=0;i<q;i++){
		for(int j=0;j<n;j++){
			if(g[i]==f[j]){
				x++;
				break;
			}
		}
	}
	cout << x <<endl;
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll P[100005];

ll modpow(ll n, ll r) {
    ll p = n;
    ll ret = 1;
    while (r > 0) {
        if (r & 1)
            ret = (ret * p) % MOD;
        p = (p * p) % MOD;
        r >>= 1;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll k = K; k > 0; --k) {
        ll n = K / k;
        ll p = modpow(n, N);
        for (ll j = k; j <= K; j += k) {
            p = (MOD + p - P[j]) % MOD;
        }
        ans = (ans + k * p) % MOD;
        P[k] = p;
    }

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

Measured memory_bytes: 4316
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int array[][] = new int [3][3];

		boolean ans[][] = new boolean [3][3];




		for(int i = 0;i<3;i++){
			for(int j = 0;j<3;j++){
				array[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();

		for(int i = 0;i<n;i++){
			int tmp = sc.nextInt();
			for(int j = 0;j<3;j++){
				for(int k = 0;k<3;k++){
					if(array[j][k] == tmp){
						ans[j][k] = true;
					}
				}
			}
		}

		boolean a = false;
		for(int i = 0;i<3;i++){
			if((ans[i][0] && ans[i][1] && ans[i][2]) || (ans[0][i] && ans[1][i] && ans[2][i])){
				a= true;
				break;
			}
		}

		if(!a){
			if((ans[0][0] && ans[1][1] && ans[2][2]) || (ans[0][2] && ans[1][1] && ans[2][0])){
				a= true;
			}
		}

		if(a){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}

	}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
ll n,s;
ll minans=1e12;

ll anydecimalB(ll n,ll decimal)
{
  ll ret=0;
  //string expre="";
  while(n>=decimal)
    {
      ret+=(n%decimal);
      //expre=expre+to_string(n%decimal);
      n/=decimal;
    }
  if(n>0)
    {
      ret+=n;
      //expre=expre+to_string(n);
    }
  //reverse(expre.begin(),expre.end());
  //cout << ret << endl;
  //cout << expre << endl;
  return ret;
}
int main(void)
{
  cin >> n >> s;
  if(n==s)
    {
      cout << n+1 << endl;
    }
  else
    {
      for(ll i=2;i<=sqrt(n);i++)
	{
	  if(anydecimalB(n,i)==s)
	  {
	    cout << i << endl;
	    return 0;
	  }
	}
      for(ll p=1;p<sqrt(n);p++)
	{
	  if((n-s)>0)
	    {
	      ll b=(n-s)/p +1;
	      //cout << b << endl;
	      if(b==1 && n==s)
		{
		  minans=min(minans,n);
		}
	      else if(b==1 && n!=s) continue;
	      else if(anydecimalB(n,b)==s)
		{
		  minans=b;
		}
	    }
	}
      if(minans==1e12)
	{
	  cout << -1 << endl;
	}
      else
	{
	  cout << minans << endl;
	}
    }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a, b, c, x, y, sma;
int main(void){
    // Your code here!
    cin >> a >> b >> c >> x >> y;
    if ((x > y && a > c * 2) || (x < y && b > c * 2)) {
        cout << 2 * c * max(x, y) << endl;
    } else if (a + b > c * 2) {
        cout << (x < y ? b * (y - x) + c * x * 2 : a * (x - y) + c * y * 2) << endl;
    } else {
        cout << a * x + b * y << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int INF = (int) 1e9;
#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

    ll n, a, b;
    cin >> n >> a >> b;
    ll h[n];
    rep(i, n) cin >> h[i];

    auto simulate = [&](int x) {
        ll wide_damage = b * x;
        ll cnt = 0;
        rep(i, n) {
            if (h[i] - wide_damage > 0) cnt += CEIL(h[i] - wide_damage, a - b);
        }
        return cnt <= x;
    };

    ll lo = 0, hi = INF;
    while (hi - lo > 1) {
        ll mi = (lo + hi) / 2;
        if (simulate(mi)) hi = mi;
        else lo = mi;
    }
    cout << hi << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M, std::vector<long long> A)
{
    priority_queue<ll> q;
    for (int i = 0; i < N; i++)
    {
        q.push(A[i]);
    }

    for (int i = 0; i < M; i++)
    {
        ll item = q.top();
        q.pop();

        item /= 2;
        q.push(item);
    }
    ll ans = 0;

    while (!q.empty())
    {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int x; cin >> x;
	if (x >= 1800)cout << 1;
	else if (x >= 1600)cout << 2;
	else if (x >= 1400)cout << 3;
	else if (x >= 1200)cout << 4;
	else if (x >= 1000)cout << 5;
	else if (x >= 800)cout << 6;
	else if (x >= 600)cout << 7;
	else cout << 8;
	cout << "\n";

	return 0;
}

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

int main(){
    ll n,m;
    cin >> n >> m;
    cout << abs((n-2)*(m-2)) << endl;
}

Measured memory_bytes: 256
#include <stdint.h>
#include <array>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> v(N);
  REP(i, N) {
    ll A;
    cin >> A;
    v[i] = make_pair(A, i);
  }
  sort(ALL(v));
  ll count = 0;
  REP(i, N) {
    if ((v[i].second % 2) != (i % 2)) {
      count++;
    }
  }
  std::cout << count / 2 << std::endl;
}


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

int main() {
  
  string s;
  cin >> s;
  
  int counter = 0;
  
  if(s[0] == 'o')counter++ ;
   if(s[1] == 'o') counter++ ;
   if(s[2] == 'o') counter++ ;
    
  cout << 700 + (counter * 100) << endl;
  
}


           

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] % 2 == 0){
      if(A[i] % 3 != 0 && A[i] % 5 != 0){
        cout << "DENIED";
        return 0;
      }
    }
  }
  cout << "APPROVED";
  
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read::<usize>() - 1).collect();

    let mut cnt = 0;
    let mut b = 0;
    loop {
        cnt = cnt + 1;
        if a[b] == 1 {
            println!("{}", cnt);
            break;
        }
        if cnt >= n {
            println!("-1");
            break;
        }
        b = a[b];
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include <stdio.h>
int main()
{
  int n,m;
  scanf("%d",&n); scanf("%d",&m);
  int a[n];
  int i,flag=0;
    int sum=0;
    for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum = sum + a[i];
  }
  for(i=0;i<n;i++){
    if(a[i]*4*m<sum) flag = flag + 1;
  }
  if(n-m<flag) printf("No");
  else printf("Yes");
  return 0;
}


Measured memory_bytes: 1708
#include <iostream>
#include <algorithm>
#include <string>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int K, c = 0;
string s;

bool find(string target) {
    if (target != "") {
        if (s.find(target) == string::npos)
            return false;
        else {
            c++;
            if (c == K) {
                cout << target << endl;
                return true;
            }
        }
    }

    for (char c = 'a'; c <= 'z'; c++) {
        if (find(target + c))
            return true;
    }
    return false;
}

int main() {
    cin >> s >> K;
    find("");
    return 0;
}

Measured memory_bytes: 256
package main

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

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.Int()
	k := next.Int()
	x := next.Int()
	y := next.Int()

	if n >= k {
		fmt.Println(k*x + (n-k)*y)
	} else {
		fmt.Println(n * x)
	}
}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

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

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

class Edge {
public:
	ll source, target, cost;
	Edge(ll source = 0, ll target = 0, ll cost = 0) :
		source(source), target(target), cost(cost) {}
	bool operator<(const Edge &e)const {
		return cost < e.cost;
	}
};

ll kruskal(ll N, vector<Edge> &edges) {
	ll totalCost = 0;
	sort(edges.begin(), edges.end());
	union_find uni(N);
	ll source, target;
	for (ll i = 0; i < edges.size(); i++) {
		Edge e = edges[i];
		if (!uni.same(e.source, e.target)) {
			totalCost += e.cost;
			uni.unite(e.source, e.target);
		}
	}
	return totalCost;
}

ll calc(P p1, P p2){
	ll res = abs(p1.first - p2.first);
	chmin(res, (ll)abs(p1.second - p2.second));
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<Edge> es;
	vector<pair<P, int>> xy, yx;
	rep(i,n){
		int x, y;
		cin >> x >> y;
		x--; y--;
		xy.emplace_back(make_pair(x, y), i);
		yx.emplace_back(make_pair(y, x), i);
	}
	sort(xy.begin(), xy.end());
	sort(yx.begin(), yx.end());
	rep(i,n-1) es.push_back(Edge(xy[i].second, xy[i+1].second, calc(xy[i].first, xy[i+1].first)));
	rep(i,n-1) es.push_back(Edge(yx[i].second, yx[i+1].second, calc(yx[i].first, yx[i+1].first)));
	ll ans = kruskal(n, es);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10920
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, W;
    cin >> N >> W;

    vector<vector<int>> table(4);

    int base_w = -1;
    for (int i = 0; i < N; i++) {
        int w, v;
        cin >> w >> v;

        if (i == 0) {
            base_w = w;
        }

        table[w - base_w].push_back(v);
    }

    for (int i = 0; i < 4; i++) {
        sort(table[i].begin(), table[i].end(), greater<int>());
    }

    vector<vector<int>> S(4);
    for (int i = 0; i < 4; i++) {
        S[i].resize(table[i].size() + 1, 0);
        for (int j = 0; j < table[i].size(); j++) {
            S[i][j+1] = S[i][j] + table[i][j];
        }
    }

    int ret = -1;

    for (int i = 0; i <= table[0].size(); i++) {
        for (int j = 0; j <= table[1].size(); j++) {
            for (int k = 0; k <= table[2].size(); k++) {
                for (int l = 0; l <= table[3].size(); l++) {
                    if (i + j + k + l > N) continue;
                    if (base_w * i + (base_w + 1) * j + (base_w + 2) * k + (base_w + 3) * l > W) continue;
                    ret = max(ret, S[0][i] + S[1][j] + S[2][k] + S[3][l]);
                }
            }
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256