akhauriyash/Code-Regression huggingface dataset:
local mma, mmi = math.max, math.min
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = {io.read("*n", "*n")}
  t[i][3] = i
end
local lmaxp, rminp = 1, 1
for i = 2, n do
  if t[lmaxp][1] < t[i][1] then
    lmaxp = i
  end
  if t[i][2] < t[rminp][2] then
    rminp = i
  end
end
local cand = mma(0, t[rminp][2] - t[lmaxp][1] + 1)
do
  local maxlen = 0
  for i = 1, n do
    if i ~= lmaxp and i ~= rminp then
      maxlen = mma(maxlen, t[i][2] - t[i][1] + 1)
    end
  end
  cand = cand + maxlen
end
if lmaxp ~= rminp then
  local l_r, r_l = t[rminp][2], t[lmaxp][1]

  local l_l, r_r = false, t[lmaxp][2]
  table.sort(t, function(a, b) return a[1] > b[1] end)
  for i = 1, n do
    if t[i][3] ~= lmaxp then
      l_l = t[i][1]
      cand = mma(cand, mma(0, l_r - l_l + 1) + mma(0, r_r - r_l + 1))
    end
    if t[i][3] ~= rminp then
      r_r = mmi(r_r, t[i][2])
    end
  end
  cand = mma(cand, mma(0, l_r - l_l + 1) + mma(0, r_r - r_l + 1))
end
print(cand)


Measured memory_bytes: 16376
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int[] a = {0,2,0,1,0,1,0,0,1,0,1,0};
        if(a[x-1]==a[y-1])
            System.out.println("Yes"); else System.out.println("No");
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vpi vector<pair<int,int>>
#define w(t) int t;cin>>t;while(t--)
#define pi pair<int,int>
#define mii map<int,int>
#define pb push_back
#define ff first
#define ss second
#define FOR(i,t,n) for(int i=t;i<n;i++)
#define SCI(x)  scanf("%d",&x)
#define SCL(x) scanf("%lld",&x)

ll factor(ll c){
	ll d  =  1 + 4*c ;
	ll ans =(sqrt(d) - 1 );
//	cout<<ans<<endl;
	return ans/2;
}

map<ll,ll> m;

void primeFactor(ll n){
	for(ll i = 2;i*i 	< n; i++){
		if(n%i == 0){
			ll c = 0;
			while(n%i == 0){
				c++;
				n = n/i;
			}

			m[i] = c;
		}
	}
	if(n > 1){
		m[n] = 1;
	}
}

void solve(){
	ll n;
	cin>>n;
	primeFactor(n);
	ll ans = 0;
	for(auto it : m){
		ans += factor(2*it.ss);
	}
	cout<<ans<<endl;
}


int main()
{

	solve();

//	cout<<factor(8)<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
typedef long long ll;
using namespace std;
 

int main(){
    int n; cin >> n;
    vector<string> a(n);
    rep(i,n) cin >> a[i];
    ll anss=0;

    rep(i,n){
        sort(a[i].begin(),a[i].end());
    }
    map<string,int> c;
    rep(i,n){
        c[a[i]]++;
        if(c[a[i]]) anss+=c[a[i]]-1;
    }
    cout << anss << endl;
return 0;
}


Measured memory_bytes: 18176
#include <iostream>
#include <algorithm>
#include <queue>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;
const ll mod = 1e9+7 ;

ll powmod(ll x,ll y){
    ll res = 1 ;
    for(int i=0;i<y;i++){
        res = res*x%mod ;
    }
    return res ;
}

int main() {

    ll n ;
    cin >> n ;

    ll ans = powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n) ;
	ans %= mod ;
    cout << (ans+mod)%mod << endl ;
    return 0 ;
}

Measured memory_bytes: 3620
n = int(input())
S = input()

def c(s1, s2, s3, i, s):
  cnt = 0
  L = S[:i]
  R = S[i+1:]
  # print(s1, s2, s3, L, R)
  if s == s1:
    lc = 0
    for l in L:
      if l == s2:
        lc += 1
    rc = 0
    for r in R:
      if r == s3:
        rc += 1
    cnt += lc * rc 
  for i, j in zip(R, L[::-1]):
    if s1 == s and i == s3 and j == s2:
      cnt -= 1
  # print(cnt)
  return cnt

ans = 0
for i, s in enumerate(S):
  ans += c("R", "B", "G", i, s) 
  ans += c("R", "G", "B", i, s) 
  ans += c("B", "R", "G", i, s) 
  ans += c("B", "G", "R", i, s) 
  ans += c("G", "R", "B", i, s) 
  ans += c("G", "B", "R", i, s) 

print(ans)

Measured memory_bytes: 77672
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <sstream> //C++
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)

//scanf("%d",&x);
//printf("%d",x);
//for(i=0;i<N;i++){  }
//if( == ){  }else{  }
//while( ){  }

/*
int N, i;
int H[100];
scanf("%d", &N);
for (i = 0; i < N; i++) scanf("%s", &H[i]);
*/




int main()
{
	int r;

	cin >> r;
	
	cout << 2 * r * 3.14159265;

}




Measured memory_bytes: 3756
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  ll A[N-1],B[N-1];
  Graph G(N);
  REP(i,N-1){
    cin>>A[i]>>B[i];
    A[i]--,B[i]--;
    G[A[i]].PB(B[i]);
    G[B[i]].PB(A[i]);
  }
  
  
  ll DISA[N],DISB[N];
  REP(i,N) DISA[i]=INF,DISB[i]=INF;
  DISA[0]=0,DISB[N-1]=0;
  
  bool SEENA[N],SEENB[N];
  REP(i,N) SEENA[i]=false,SEENB[i]=false;
  SEENA[0]=true,SEENB[N-1]=true;
  
  queue<ll> QA,QB;
  QA.push(0),QB.push(N-1);
  
  while(!QA.empty()){
    ll v=QA.front();
    QA.pop();
    FORE(nv,G[v]){
      if(SEENA[nv]) continue;
      SEENA[nv]=true;
      DISA[nv]=DISA[v]+1;
      QA.push(nv);
    }
  }
  
  while(!QB.empty()){
    ll v=QB.front();
    QB.pop();
    FORE(nv,G[v]){
      if(SEENB[nv]) continue;
      SEENB[nv]=true;
      DISB[nv]=DISB[v]+1;
      QB.push(nv);
    }
  }
  
  
  ll ans=0;
  REP(i,N){
    if(DISA[i]<=DISB[i]) ans++;
  }
  
  if(ans>N/2) cout<<"Fennec"<<endl;	// 先攻
  else cout<<"Snuke"<<endl;			// 後攻
  return 0;
}

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

int main(){
    int N, Y;
    int  res10000 =-1,res5000 = -1, res1000 = -1;
    cin >> N >> Y;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j+i <= N; j++){
            int k = N - i - j;
            int total = 10000*i + 5000*j + 1000*k;
            if(total == Y){
                res10000 = i;
                res5000 = j;
                res1000 = k;
            }
        }
    } 
    
    cout << res10000 << " " << res5000 << " " << res1000 << endl;

return 0;
}


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

int main() {
  long long N;
  cin >> N;
  vector<long long>data(N);
  for (int i=0; i<N; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  long long sum=0;
  for (int i=1; i<N; i++) {
    sum = sum + data.at(i/2);
  }
  cout << sum << endl;
}


Measured memory_bytes: 4824
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2306>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


void dfs(ll n,vector<ll>& use,vector<vector<ll>>& cost,ll& res){
    size_t size = use.size();
    if(size >= 2){
        ll sum = 0;
        for(int i = 0; i < size;i++){
            ll minc = INF;
            for(int j = 0; j < size;j++){
                if(i == j) continue;
                minc = min(minc,cost[use[i]][use[j]]);
            }
            sum += minc;
        }
        res = max(res,sum);
    }
    
    for(ll next = n + 1; next < cost[0].size(); next++){
        [&]{
            for(int i = 0; i < size;i++){
                if(cost[next][use[i]] == 0) return;
            }
            use.push_back(next);
            dfs(next,use,cost,res);
            use.pop_back();
        }();
    }
}
ll solve(){
    ll res = 0;
    ll n,m; cin >> n >> m;
    vector<ll> u(m),v(m),f(m);
    for(int i = 0; i < m;i++){
        cin >> u[i] >> v[i] >> f[i];
        u[i]--; v[i]--;
    }
    vector<vector<ll>> cost(n,vector<ll>(n,0));
    //for(int i = 0; i < n;i++) cost[i][i] = LINF;
    for(int i = 0;i < m;i++){
        cost[u[i]][v[i]] = cost[v[i]][u[i]] = f[i];
    }
    vector<ll> use;
    for(int i = 0; i < n;i++){
        use.clear();
        use.push_back(i);
        dfs(i,use,cost,res);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3284
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String[] tmp = in.nextLine().trim().split("\\s");
        int h = Integer.parseInt(tmp[0]);
        int w = Integer.parseInt(tmp[1]);
        char[][] grid = new char[h][w];
        for(int i = 0; i < h; i++){
            String temp = in.nextLine();
            for(int j = 0; j < w; j++){
                grid[i][j] = temp.charAt(j);
            }
        }

        int[][] dp = new int[h+1][w+1];
        dp[1][1] = 1;
        int MOD = 1_000_000_007;
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                if(grid[i-1][j-1] != '#'){
                    dp[i][j] += (i > 1 && grid[i-2][j-1] != '#') ? dp[i-1][j] : 0;
                    dp[i][j] %= MOD;
                    dp[i][j] += (j > 1 && grid[i-1][j-2] != '#') ? dp[i][j-1] : 0;
                    dp[i][j] %= MOD;
                }
            }
        }
        in.close();
        System.out.println(dp[h][w]);
    }
}

Measured memory_bytes: 47572
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
const LL MOD = 1000000007;
LL modpow(LL a, LL b, LL p){
    if(b==0) return 1;
    else if(b%2==0){
        LL d = modpow(a, b/2, p);
        return (d*d)%p;
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    int r,c;
    cin >> r >> c;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;

    LL f[550], inv_f[550];
    f[0] = 1;
    REP(i, 549){
       f[i+1] = (f[i]*(i+1))%MOD;
    }
    inv_f[500] = modpow(f[500], MOD-2, MOD);
    for(int i=499; i>=1; i--){
        inv_f[i] = (inv_f[i+1]*(i+1))%MOD;
    }

    int xm = min({abs(sx-gx), abs(r-gx), gx+1});
    int xp = 0;
    if(xm == abs(sx-gx)) xp++;
    if(xm == abs(r-gx)) xp++;
    if(xm == gx+1) xp++;
    int ym = min({abs(sy-gy), abs(c-gy), gy+1});
    int yp = 0;
    if(ym == abs(sy-gy)) yp++;
    if(ym == abs(c-gy)) yp++;
    if(ym == gy+1) yp++;

    int ans = xm+ym;
    LL ptn = xp*yp;
    ptn = (ptn*f[xm+ym])%MOD;
    ptn = (ptn*inv_f[xm])%MOD;
    ptn = (ptn*inv_f[ym])%MOD;
    if(ptn == 0) ptn = max(xp, yp);
    cout << ans << " " << ptn << endl;
}

  



Measured memory_bytes: 3100
#include<cstdio>
#include<cctype>
#include<iostream>
#include<string>
using namespace std;

int main() {
    string str;

    
    while(1) {
        int sum = 0;
        cin >> str;
        if (str == "0") break;
        
        for (int i = 0; i < str.size(); i++) {
            if (str[i] == '1') sum += 1;
            if (str[i] == '2') sum += 2;
            if (str[i] == '3') sum += 3;
            if (str[i] == '4') sum += 4;
            if (str[i] == '5') sum += 5;
            if (str[i] == '6') sum += 6;
            if (str[i] == '7') sum += 7;
            if (str[i] == '8') sum += 8;
            if (str[i] == '9') sum += 9;
            if (str[i] == '0') sum += 0;
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var str string
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &str)
	chars := strings.Split(str, "")

	set := NewStrSet()
	for _, c := range chars {
		set.Add(c)
	}
	if set.Size() == 3 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

type StringSet struct {
	set map[string]struct{}
}

func NewStrSet() *StringSet {
	return &StringSet{
		set: make(map[string]struct{}),
	}
}

func (s *StringSet) Add(str string) {
	s.set[str] = struct{}{}
}

func (s *StringSet) Contains(str string) bool {
	_, e := s.set[str]
	return e
}

func (s *StringSet) Size() int {
	return len(s.set)
}

func (s *StringSet) IsEmpty() bool {
	return s.Size() == 0
}

func (s *StringSet) Entries() map[string]struct{} {
	return s.set
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll mod=1e9+7;
    int n=nxt();
    vector <ll> v(n);
    generate(all(v),nxtl);
    ll test=0;
    for(int i=0;i<62;i++)
    {
        ll c0=0,c1=0;
        for(int j=0;j<n;j++)
        {
            if(v[j]%2)
                c1++;
            else
                c0++;
            v[j]/=2;
        }
        test=(test+(power(2,i,mod))*((c0*c1)%mod))%mod;
    }
    cout<<test<<endl;
    

    return 0;   
}


 
 


Measured memory_bytes: 2560
from collections import deque

def lower_bound(al, key):
    """
    一般に左側が満たしておらず、右側は満たしている判定基準(境目は一つ)ならlower_boundになる
    (条件を満たすもののうち、最小のインデックスを返す)
    単調にさえなっていれば、左右が逆になっていても検索には使える(ng/okも一緒に逆にする必要がある)
    """
    def isOk(a):
        # alの中でkey以上のアイテムのうち最小のインデックスを返す
        # upper_boundにする時にはa>key
        return a>=key

    ng = -1
    ok = len(al)

    while abs(ok-ng)>1:
        mid = (ok+ng)//2

        if isOk(al[mid]):
            ok = mid
        else:
            ng = mid

    return ok

n = int(input())
l = deque()

for _ in range(n):
    a = int(input())

    if len(l)==0:
        l.append(a)
        continue

    idx = lower_bound(l,a)
    if idx<1:
        l.appendleft(a)
    else:
        l[idx-1] = a

print(len(l))


Measured memory_bytes: 7364
/*
 * 二つの整数 A, B が入力されます。A+B の値を出力してください。
 * 
 * ただし、A+B が 10 以上の場合は、代わりに error と出力してください。
 */

import java.util.*;
	public class Main{
		public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            
            if(a+b<10){
            	System.out.println(a+b);
            }else{
            	System.out.println("error");
            }
            sc.close();
		}
    }
	

Measured memory_bytes: 23764
# coding: utf-8
A = []
for _ in range(3):
    A.extend(input().rstrip().split(' '))
n = int(input())
lst = [input() for _ in range(n)]

C = [0 for i in range(9)]

for s in lst:
    for t in range(9):
        if s == A[t]:
            C[t] = 1
Ans = 'No'
Cset = max(C[0] + C[1] + C[2], C[3] + C[4] + C[5], C[6] + C[7] + C[8],C[0] + C[3] + C[6], C[1] + C[4] + C[7], C[2] + C[5] + C[8], C[0] + C[4] + C[8], C[2] + C[4] + C[6])
if Cset == 3:
  Ans = 'Yes'
print(Ans)

Measured memory_bytes: 3064
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		for (int i=1; i <= 9; i++) {
			for (int j=1; j <= 9; j++) {
				System.out.println(i + "x" + j + "=" + (i*j));
			}
		}
	}

}

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

string S;

int main() {
    cin >> S;
    int N = S.length();

    int a = 0, b = 0, c = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'a') a++;
        else if (S[i] == 'b') b++;
        else c++;
    }

    if (N/3 <= min(a, min(b, c)) && max(a, max(b, c)) <= ceil((double)N/3)) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// #define int int
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int inf = 1e9+7;
const int N = 1e5+5;
int n, k, id=0;
int A[N], p[N];

bool solve()
{
	int i, j, a=0, b=0, ans = 1;
	cin>>n>>k;
	rep(i, 0, n) cin>>A[i];
	sort(A, A+n);
	i = 0;
	while(i<n && k-A[i] >= 0) k-= A[i], i++;
	if(i==n && k>0)
	cout<<n-1;
	else{
		cout<<i;
	} 
}

signed main()
{
	ios
	int i, t=1, j, x;
	// cin>>t;
	while(t--) 
		solve();
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static bool CheckRec(int[] data)
        {
            if (data.Sum() == 0) return true;

            for (int j = 0; j < 7; j++)
            {
                if (data[j] <= 0 || data[j + 1] <= 0 || data[j + 2] <= 0) continue;
                data[j]--;
                data[j + 1]--;
                data[j + 2]--;
                if (CheckRec(data)) return true;
                data[j]++;
                data[j + 1]++;
                data[j + 2]++;
            }

            for (int j = 0; j < 9; j++)
            {
                if (data[j] < 3) continue;
                data[j] -= 3;
                if (CheckRec(data)) return true;
                data[j] += 3;
            }

            return false;
        }

        static bool Check2(int[] data, int[] buf)
        {
            for(int j = 0; j < 9; j++)
            {
                Array.Copy(data, buf, data.Length);
                if (buf[j] < 2) continue;
                if (buf.Max() > 4) continue;
                buf[j] -= 2;
                if (CheckRec(buf)) return true;
            }
            return false;
        }
        static IEnumerable<int> Check(int[] data)
        {
            for (int i = 0; i < 9; i++)
            {
                data[i]++;
                if (Check2(data, new int[data.Length]))
                    yield return i;
                data[i]--;
            }
        }
        static void Main(string[] args)
        {
            string line;
            var data = new int[9];
            while((line = Console.ReadLine()) != null)
            {
                Array.Clear(data, 0, data.Length);
                foreach(var c in line)
                {
                    data[c - '1']++;
                }
                var a = string.Join(" ", Check(data).Select(x => ((char)(x + '1')).ToString()).ToArray());
                Console.WriteLine(string.IsNullOrEmpty(a) ? "0" : a);
            }
        }
    }
}

Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N,K; cin >> N >> K;
    vector<int> v(N+10);
    for(int i=0;i<N;i++){int n; cin >> n; v[n]++;}
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int ans =0;
    for(int i=K;i<N+10;i++){
        ans+=v[i];
        if(v[i] == 0) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
#define F first
#define S second
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef pair<int,int>pii;
struct data{
    int cnt;
    vvi fld;
    data(){}
    data(int a,vvi b):cnt(a),fld(b){}

};
data check(vvi fld){
    int c=fld[0][0];
    int h=fld.size();
    int w=fld[0].size();
    int dx[]={0,-1,0,1};
    int dy[]={-1,0,1,0};
    queue<pii>Q;
    Q.push(pii(0,0));
    int cnt=0;
    while(Q.size()){
        int y=Q.front().F,x=Q.front().S;
        Q.pop();
        if(y<0||y>=h||x<0||x>=w)continue;
        if(fld[y][x]!=c)continue;
        fld[y][x]=-1;
        cnt++;
        for(int i=0;i<4;i++)Q.push(pii(y+dy[i],x+dx[i]));
    }

    return data(cnt,fld);
}

vvi chenge(vvi fld,int to){
    int h=fld.size();
    int w=fld[0].size();
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            if(fld[i][j]==-1)fld[i][j]=to;

    return fld;
}
int main(){
    int h,w,c;
    while(cin>>h>>w>>c,h||w||c){
        vvi fld(h,vi(w));
        c--;
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++){
                cin>>fld[i][j];
                fld[i][j]--;
            }

        int ma=0;
        queue<data>Q;
        Q.push(data(0,fld));
        while(Q.size()){
            data d=Q.front();
            Q.pop();
            if(d.cnt>=5){
                if(d.fld[0][0]==c){
                    ma=max(ma,check(d.fld).cnt);
                }
                continue;
            }
            vvi next=d.fld;
            next=check(next).fld;
            for(int i=0;i<6;i++){
                Q.push(data(d.cnt+1,chenge(next,i)));
            }
        }
        cout<<ma<<endl;
    }

    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    rep(i, S.size()) {
        if (i % 2 == 0) {
            if (S[i] != 'h') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] != 'i') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    if (S[S.size() - 1] == 'i') cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int n,m,x,y;cin>>n>>m>>x>>y;
    int z=x+1;
    rep(i,0,n){
        int a;cin>>a;
        z=max(z,a+1);
    }
    if(z>y){
        cout<<"War"<<endl;return 0;
    }
    rep(j,0,m){int b;cin>>b;
        if(z>b){
           cout<<"War"<<endl;return 0;
        }
    }
    cout<<"No War"<<endl;return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if (a<=5){
        cout << 0;
        return 0;
    }
    else if (a<13){
        cout << b/2;
        return 0;
    }
    cout << b;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
        int x=ni(),n=ni(),arr[]=new int[n+1];
        HashSet<Integer> set = new HashSet<Integer>();
        for(int i=1;i<=n;i++){set.add( arr[i]=ni());};

        int diff=Integer.MAX_VALUE,res=Integer.MAX_VALUE;
        for(int i=0;i<=2000;i++){
            if(!set.contains(i)){
                if(Math.abs(x-i)<diff){
                    diff=Math.abs(x-i);
                    res=i;
                }
                else if(diff==Math.abs(x-i))
                    res=Math.min(res, i);
            }
        }
        pn(res);
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
//        t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 36688
n = int(input())
w = [w for w in map(int, input().split(' '))]

total = sum(w)
half = total // 2

ans = total
tmp = 0
for i in range(len(w)):
  tmp += w[i]
  ans = min(ans, abs(tmp - (total-tmp)))
  

# print(n, w)
print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];
ll dp[101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>d(n);
	map<ll, ll>mp;
	rep(i, n) {
		cin >> d[i];
		mp[d[i]]++;
	}
	ll m;
	cin >> m;
	vector<ll>b(m);
	rep(i, m) {
		cin >> b[i];
		mp[b[i]]--;
	}
	for (auto p : mp) {
		ll x = p.second;
		if (x < 0) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}


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

int main()
{
    int i,k,h;
    char a[1000];
    gets(a);

    k=strlen(a);
    h=0;
    for(i=0; i<k; i++)
{
    if(a[i]=='+')
            h+=1;

        if(a[i]=='-')
            h-=1;

    }
    printf("%d\n",h);
    return 0;
}

Measured memory_bytes: 128
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n = S()
t = int(n[-1])

if t==2 or t==4 or t==5 or t==7 or t==9:
    print("hon")
elif t==0 or t==1 or t==6 or t==8:
    print("pon")
else:
    print("bon")

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<ll> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	sort(A.begin(), A.end());
	ll sp = 0;
	int x = 0;
	for (int i = 0; i < n; i++)
	{
		if (sp * 2 < A[i]) x = i;
		sp += A[i];
	}
	cout << n - x << '\n';
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main() {
  int N, X;
  cin >> N >> X;

  int min = INT_MAX;
  int sum = 0;
  for (int i=0; i<N; i++) {
    int tmp;
    cin >> tmp;
    sum += tmp;
    if (tmp < min) {
      min = tmp;
    }
  }

  int ans = N;
  ans += (X - sum)/min;

  std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> cnt(4,0);
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if(S == "AC"){
      cnt[0]++;
    }
    if(S == "WA"){
      cnt[1]++;
    }
    if(S == "TLE"){
      cnt[2]++;
    }
    if(S == "RE"){
      cnt[3]++;
    }
  }
  cout << "AC x " << cnt[0] << endl;
  cout << "WA x " << cnt[1] << endl;
  cout << "TLE x " << cnt[2] << endl;
  cout << "RE x " << cnt[3] << endl;
}


Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	int a, b, x;
	scanf("%d%d", &a, &b);
	x = (a + b) / 2;

	if ((a + b) % 2 > 0) {
		printf("%d", x + 1);
	}
	else {
		printf("%d", x);
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [0]+list(map(int,input().split()))
temp = A[0]
sm = 0
for a in A[1:]:
    sm += abs(a-temp)
    temp = a
sm += abs(A[-1])

for i in range(1,N):
    if (A[i-1]> A[i] and A[i]> A[i+1]) or (A[i-1]< A[i] and A[i]< A[i+1]):
        print(sm)
    else:
        print(sm - abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]))
print(sm if (0> A[-1] and A[-1]> A[-2]) or (0< A[-1] and A[-1]< A[-2]) else sm-abs(A[-1])-abs(A[-1]-A[-2])+abs(A[-2]))

Measured memory_bytes: 14040
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0 

for i in range(N): 
    d = min(A[i], B[i]) 
    ans += d 
    A[i] -= d 
    B[i] -= d 
    d = min(A[i + 1], B[i]) 
    ans += d 
    A[i + 1] -= d 
    B[i] -= d 

print(ans)

Measured memory_bytes: 19116
#include<stdio.h>
#include<math.h>
int main()
{
   int yen;
   scanf("%d",&yen);
  
   int temp=0;
   while(yen > 0)
   {
      temp = yen - 1000;
      yen = temp;
   }
   temp = abs(temp);
   printf("%d",temp);


}

Measured memory_bytes: 2148
function Main(input) {
	input = input.split("\n")
	var str = input[0];
	input.shift();
 	 input.shift();
	var n = 1;
	for(var i=0;i<input.length;i++){
		var mem = input[i].split(" ");
		if(mem[0]==1){
			n *= -1;
		}else{
			switch(mem[1]-0){
				case 1:
				switch(n){
					case -1:
					str += mem[2];
					break;
					case 1:
					str = mem[2] += str;
					break;
				}
				break;
				case 2:
				switch(n){
					case 1:
					str += mem[2];
					break;
					case -1:
					str = mem[2] += str;
					break;
				}
				break;
			}
		}
     // console.log(str,n)
	}
if(n==1){
	console.log(str)
}else{
	console.log(str.split("").reverse().join(""))
}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 56324
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

bool dp[10][100005];

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

    int x;
    cin >> x;
    vector<int> a(6);
    for(int i = 0; i <= 5; ++i){
        a[i] = 100 + i;
    }

    dp[0][0] = true;
    for(int i = 0; i < 6; ++i){
        for(int j = 0; j <= (int)1e+5; ++j){
            if(j - a[i] >= 0){
                dp[i+1][j] |= dp[i][j] | dp[i+1][j-a[i]];
            }
            else{
                dp[i+1][j] |= dp[i][j];
            }
        }
    }

    if(dp[6][x]){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

ll n, m;
vector<ll> a;

ll ch(ll x) {
    ll res = 0;
    for(ll i = 0; i < n; i++) {
        ll id = lower_bound(ALL(a), x - a[i]) - a.begin();
        res += n - id;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    a.resize(n);
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(ALL(a));
    vector<ll> sum(n + 1);
    for(ll i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + a[i];
    }

    ll ok = 0, ng = 1e6;
    while(llabs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        (ch(mid) >= m ? ok : ng) = mid;
    }
    ll ans = 0, cnt = 0;
    for(ll i = 0; i < n; i++) {
        ll id = lower_bound(ALL(a), ng - a[i]) - a.begin();
        cnt += n - id;
        ans += sum[n] - sum[id] + (n - id) * a[i];
    }
    ans += ok * (m - cnt);
    cout << ans << endl;
}

Measured memory_bytes: 1792
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	s <- getLine
	t <- getLine
	let
		l = length s
	putStrLn $ which "Yes" "No" $ s == take l t

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

struct P{
	double x, y;
	P operator+(const P p) const;
	P operator-(const P p) const;
};

P operator*(const double k, const P p){return {k * p.x, k * p.y};}
P P::operator+(const P p) const{return {x+p.x, y+p.y};}
P P::operator-(const P p) const{return {x-p.x, y-p.y};}

typedef P Vector;

const P ORIGIN_P = {0, 0};
const double EPS = 1e-10;

double abs(double d){
	return (d>0)?d:-d;
}

double abs(P p){
	return sqrt(p.x*p.x + p.y*p.y);
}

double dotProduct(Vector v1, Vector v2){return v1.x*v2.x + v1.y*v2.y;}
double crossProduct(Vector v1, Vector v2){return v1.x*v2.y - v1.y*v2.x;}

Vector createUnitVector(Vector v){
	double dist = abs(v);
	if(dist < EPS){
		return {0, 0};
	}
	return (1/dist) * v;
}

//直線ab上に点cはあるか
bool is_point_on_line(P a, P b, P c){
	return (crossProduct(b-a, c-a) < EPS &&
					dotProduct(b-a, c-a) > -EPS &&
					dotProduct(a-b, c-b) > -EPS);
}

//直線abと点P間の距離
double distance_line_p(P a, P b, P p){
	if(dotProduct(b-a, p-a) < EPS)return abs(p-a);
	if(dotProduct(a-b, p-b) < EPS)return abs(p-b);
	return abs(crossProduct(a-b, p-a)) / abs(a-b);
}
 
class UFO{
public:
	P p;
	double r, v;
	Vector unit_v;
	UFO(P _p, double _r, double _v);
};

UFO::UFO(P _p, double _r, double _v)
	:p(_p), r(_r), v(_v){
	unit_v = createUnitVector(p);
}

double R;
int n;

bool comp(const UFO& l_ufo, const UFO& r_ufo){
	return abs(l_ufo.p) < abs(r_ufo.p);
}

void shoot(std::vector<UFO> &uv){//最も近いUFOの中心に向けてLazerを発射する
	std::sort(uv.begin(), uv.end(), comp);
 
	UFO attacked_u = uv[0];
	
	for(int i=0;i<uv.size();i++){
		UFO u = uv[i];
		double dist = distance_line_p(R * attacked_u.unit_v, 100000 * attacked_u.unit_v, u.p);

		if(dist < u.r + EPS){//破壊
			uv.erase(uv.begin() + i);
			i--;
		}
	}
}

void moveUFO(std::vector<UFO> &uv){//UFOの移動
	std::sort(uv.begin(), uv.end(), comp);

	int uv_size = uv.size();
	for(int i=0;i<uv_size;i++){
		UFO &u = uv[i];
		if(abs(u.p) > abs(-u.v * u.unit_v)){
			u.p = u.p - u.v * u.unit_v;
		}else{
			u.p = {0, 0};
		}
	}
}
int countUFO(std::vector<UFO> &uv){//生存確定したUFOの数を返す
	std::sort(uv.begin(), uv.end(), comp);

	int res = 0;
	for(int i=0;i<uv.size();i++){
		if(abs(uv[i].p) < R + EPS){
			uv.erase(uv.begin() + i);
			i--;
			res++;
		}

	}
	return res;
}

int main(){
	while(std::cin >> R >> n, n){
		std::vector<UFO> uv;
		for(int i=0;i<n;i++){
			P p;
			double r, v;
			std::cin >> p.x >> p.y >> r >> v;
			UFO u(p, r, v);
			uv.push_back(u);
		}

		std::sort(uv.begin(), uv.end(), comp);

		int res = 0;//生き残ったUFO
		while(!uv.empty()){
			moveUFO(uv);
			res += countUFO(uv);
			shoot(uv);
		}

		std::cout << res << std::endl;
	}
}

Measured memory_bytes: 1256
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;



public class Main{
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	/*
	 int n=sc.nextInt();
	 int A[]=new int[n];
	 for(int i=0;i<n;i++) {
		 A[i]=sc.nextInt();
	 }
	 Arrays.sort(A);
	 int q=sc.nextInt();
	 int B[]=new int[q];
	 for(int i=0;i<q;i++) {
		 B[i]=sc.nextInt();
	 }
	 
	 for(int i=0;i<q;i++) {
		 int temp=0;
		 for(int j=0;j<n;j++) {
			 temp+=A[j];
			 if(temp>B[i]) {
				 System.out.println("no");
				 break;
			 }else if(temp==B[i]) {
				 System.out.println("yes");
				 break;
			 }
		 }
		 
	 }*/
	 
	 int n=sc.nextInt();
	 int N1;
	 int N2;
	 int result=0;
	 if(n==0||n==1) {
		 System.out.println(1);
	 }else {
		 N1=1;
		 N2=1;
		 int i=1;
		 while(i<n) {
			 result=N1+N2;
			 N2=N1;
			 N1=result;
			 i++;
		 }
		 System.out.println(result);
	 }
	 
	
	 
	 
	 
 }
	


}




Measured memory_bytes: 26212
import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        val size = readInt;
        val m = new Array[Array[Int]](size);
        (0 until size).foreach {  i => m(i) = readLine.trim.split(" ").map( a => if (a.toInt == -1) Int.MaxValue else a.toInt)}
        val g = new Graph(size, m);
        val (parent, distance) = g.prim;
        println(distance.sum)
    }
}
case class Graph(size: Int, matrix: Array[Array[Int]]) {
    val INFINITY = Int.MaxValue
    def prim(): (Array[Int], Array[Int]) = {
        // WHITE : 未訪問, GRAY: MTS候補ノード, BLACK: MTS追加済みノード
        val WHITE = 0; val GRAY = 1; val BLACK = 2;
        val color = new Array[Int](size); // 訪問状態リスト(WHITE, GRAY, BLACK)
        val distance = new Array[Int](size).map( e => INFINITY); //  重みリスト
        val parents = new Array[Int](size); //  親ノードリスト
        def _prim(curr: Int): Unit = {
            // MTSに属する頂点の集合から最も近いノードの index を取得する
            val idx = (0 until size).foldLeft(-1) { (minidx, i) =>
                if (color(i) != BLACK) {
                    // curr の子ノードをMTS候補ノードに追加
                    if (matrix(curr)(i) != -1) {
                        color(i) = GRAY;
                    }
                    if (color(i) == GRAY) {
                        // すでに登録されている重みよりも curr からの重みのほうが小さい場合は
                        // 親ノードと重みを更新する
                        if (matrix(curr)(i) < distance(i)) {
                            distance(i) = matrix(curr)(i);
                            parents(i) = curr;
                        }
                        if (minidx == -1 || distance(i) < distance(minidx)) i else minidx;
                    } else { // color(i) == WHITE
                        // 現時点のMTSに隣接していないノードは評価しない
                        minidx;
                    }
                } else { // color(i) == BLACK 
                    // すでにMTSに追加されているノードは評価しない
                    minidx;
                }
            }
            if (idx != -1){
                // MTSから最も距離の近いノードを追加
                color(idx) = BLACK;
                _prim(idx);
            }
        }
        distance(0) = 0;
        parents(0) = -1;
        color(0) = BLACK;
        _prim(0);
        (parents, distance);
    }
}


Measured memory_bytes: 49508
'use strict';
function main(input) {
    var args = input.split('\n').map((n) => parseInt(n, 10));
  	let cnt = 0
    for (var i = 0; i <= args[0]; i++) {
      for (var j = 0; j <= args[1]; j++) {
        for (var k = 0; k <= args[2]; k++) {
            const t = i * 500 + j * 100 + k * 50
            if (t === args[3]) cnt = cnt + 1
        }
      }
    }
  	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372