akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(register int (i) = (a); (i) <= (b); ++(i))
#define ForDown(i, a, b) for(register int (i) = (a); (i) >= (b); (i)--)
using namespace std;
template<class Tp>
Tp F() {
	register Tp x = 0, ch = getchar(), f = 0;
	while(!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
template<class Tp>
bool chkmin(Tp &a, Tp b) {
	return b > a ? a = b, 1 : 0;
}
template<class Tp>
bool chkmax(Tp &a, Tp b) {
	return b < a ? a = b, 1 : 0;
}
int a, b, c;
int main() {
	a = F<int>(), b = F<int>(), c = F<int>();
	int sum = a + b + c;
	if(sum >= 22) puts("bust");
	else puts("win");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int x,a,b,c;
	scanf("%d %d %d %d",&a,&b,&c,&x);
	int num=0;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
	{
		if(i*500+j*100+k*50==x) num++;
	}
	printf("%d",num);
}

Measured memory_bytes: 128
n,m = map(int, input().split());
l = list(map(int, input().split()))

num = 0;
th = sum(l)/(4*m);
for i in range(len(l)):
    if l[i] >= th:
        num += 1;
if num >= m:
    print('Yes');
else:
    print('No');


Measured memory_bytes: 3060
using System;

namespace test
{
    class program
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int d = a / b;
            int r = a % b;
            double f = (double)a / b;
            Console.WriteLine("{0} {1} {2:f5}", d, r, f);
        }
    }
}

Measured memory_bytes: 9164
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ss <- replicateM n getLine
    print . sum . map (\x -> comb (length x) 2) . group . sort $ map sort ss

comb n r | n < r = 0
         | otherwise = iterate (scanl1 (+)) [1, 1..] !! (n - r) !! r

Measured memory_bytes: 114044
n=int(input())
#n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  b=[a[i-1],a[i],a[i+1]]
  b.sort()
  if b[1]==a[i]:ans+=1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define L long long
#define LL long long
#define SS string
#define PB push_back
#define pp pair<L,L>
#define N 100005
using namespace std;
L a[N] ,h[N];
L visited[N];
L recursivedpFindminimum(L stone)
{
    if (stone <= 1)
    return 0;
    if (visited[stone])
    return a[stone];
    visited[stone] = 1;
    a[stone] = min(recursivedpFindminimum(stone-1) + abs(h[stone] - h[stone-1]),
    recursivedpFindminimum(stone-2) + abs(h[stone] - h[stone-2]));  
    return a[stone];
}
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    L n;
    cin >> n;
    L i;
    for (i = 1 ; i <= n ; i++)
    {
        cin >> h[i];
    }
    h[0] = h[1];
    cout << recursivedpFindminimum(n);
    return 0; 
}

Measured memory_bytes: 4224
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		//String word_before = sc.next();
		int N = sc.nextInt();
		int num_arr[] = new int[N];
		boolean flag = true;
		for (int i = 0; i < num_arr.length; i++) {
			num_arr[i] = sc.nextInt();
		}
		Arrays.sort(num_arr);
		for (int i = 0; i < num_arr.length-1; i++) {
			if(num_arr[i] ==num_arr[i+1]){
				flag = false;
				break;
			}
		}
		if (flag) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
      	
		
      	
    }
		
}

Measured memory_bytes: 65916
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int m;
	int q;
	int x;
	int i,j;
	int cnt;
	int box[10001];
	cin>>n;
	for(i=0;i<n;i++)	cin>>box[i];
	cin>>q;
	cnt=0;
	for(i=0;i<q;i++){
		cin>>x;
		box[n]=x;
		j=0;
		while(x!=box[j])	j++;
		if(j<n)	cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        public static void Main()
        {
            while (true)
            {
                List<int> sss = new List<int>();
                var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (a[0] == 0 && a[1] == 0) break;

                for(int b = 1; b < a[0] - 1; b++)
                {
                    for(int c = b + 1; c < a[0]; c++)
                    {
                        if ((a[1] - b - c) == c||c> (a[1] - b - c)) break;
                        else if ((a[1] - b - c) - 1 == c) { sss.Add(b); sss.Add(c); sss.Add(a[1] - b - c); break; }
                        else if ((a[1] - b - c) > a[0]) continue;
                        else { sss.Add(b); sss.Add(c); sss.Add(a[1] - b - c); }
                    }
                }
               { Console.WriteLine(sss.Count/3); }

            }
        }
    }
}

Measured memory_bytes: 9716
n,x=map(int, input().split())
min_cost=float('inf')
cnt=0
for i in range(n):
    mi = int(input())
    x -= mi
    cnt += 1
    min_cost = min(min_cost,mi)
while x >= min_cost:
    x -= min_cost
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <vector>
#define ll long long int
#define mod 1000000007
using namespace std;
ll dp[2001][100001];
int main()
{
ll s,n;cin>>n>>s;
ll v[n],w[n];
for(int i=0;i<n;i++)
{
	cin>>w[i]>>v[i];
	//sum+=w[i];
}
for(int i=0;i<=s;i++)
{
	if(i-w[0]>=0)
	dp[0][i]=v[0];
}
for(int i=1;i<n;i++)
{
	for(int j=0;j<=s;j++)
	{
		if(j-w[i]>=0)
		{
			dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
		}
		else
		{
			dp[i][j]=dp[i-1][j];
		}
	}
}
cout<<dp[n-1][s];

}








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

typedef vector<int> V;
typedef vector<V> VV;

int main () {
    int n, m;

    while (cin >> n >> m, n + m) {
        V h1(n), h2(m), d(21), c(21);
        for (auto &i : h1) cin >> i;
        for (auto &i : h2) cin >> i;

        for (int i = 0; i < n; i++) {
            d[h1[i]]++;
            c[h1[i]]++;            
        }

        for (int i = 0; i < m; i++) {
            if (c[h2[i]] == 0) d[h2[i]]++;
            else c[h2[i]]--;
        }

        int res = 0;
        for (int i = 0; i < d.size(); i++) {
            res += d[i] * i;
        }

        cout << res << endl;
    } 
    return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
int main(){
  int flag=1,i,j,n,a[100],v,cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  i =0;
  while(flag){
    flag = 0;
    for(j=n-1;j>0;j--){
      if(a[j]<a[j-1]){
	v=a[j];
	a[j]=a[j-1];
	a[j-1]=v;
	flag=1;
	cnt++;
      }
    }
  }for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",cnt);
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    int k;cin>>k;
    int sum=0;
    rep(i,n){
        int x;cin>>x;
        sum+=min(x*2,(k-x)*2);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int number1;
	scanf("%d", &number1);
	int number2;
	scanf("%d", &number2);
	int number3;
	scanf("%d", &number3);
	(number1 + number2 + number3 >= 22) ? puts("bust") : puts("win");
	
	return 0;
}

Measured memory_bytes: 1600
import java.util.HashMap

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aa = HashMap<Int, Int>(n shl 1)
    val amaper = { a: Int ->
        aa[a] = aa.getOrElse(a) { 0 } + 1
    }
    readLine()!!.split(' ').forEach {
        val a = it.toInt()
        amaper(a - 1)
        amaper(a)
        amaper(a + 1)
    }
    println(aa.values.max())
}


Measured memory_bytes: 62376
using System;
using System.Collections.Generic;
namespace Aoj
{
  class Aoj0013
  {
    static void Main()
    {
      string s;
      var st = new Stack<string>();
      while((s = Console.ReadLine()) != null)
      {
        if(int.Parse(s) == 0)
          Console.WriteLine(st.Pop());
        else
          st.Push(s);
      }
    }
  }
}

Measured memory_bytes: 5616
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int n=cin.nextInt(),m=cin.nextInt();
		int A[][]=new int[100][100];
		int B[]=new int[100];
		
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				int x=cin.nextInt();
				A[i][j]=x;
			}
		}
		
		for(int i=0;i<m;i++) {
			int x=cin.nextInt();
			B[i]=x;
		}
		
		for(int i=0;i<n;i++) {
			int sum=0;
			for(int j=0;j<m;j++) {
				sum+=A[i][j]*B[j];
			}
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 41348
from itertools import combinations

N, M, X = map(int, input().split())
books = []
for _ in range(N):
    books.append(list(map(int, input().split())))

prices = []
for i in range(1, N+1):
    for to_buy in combinations(books, i):
        _b = list(zip(*to_buy))
        _price = sum(_b[0])
        _points = _b[1:]
        if all([True if sum(x) >= X else False
                for x in _points]):
            prices.append(_price)

print(min(prices) if len(prices) else '-1')

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int k;
	cin>>k;
	cout<<a[k];
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,a,b,c,lj;
int swh(int a)
{
	int i=0;
	while(a!=0)
	{
		i+=a%10;
		a/=10;
	}
	return i;
}
int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		if(swh(i)>=a&&swh(i)<=b) lj+=i;
	}
	cout<<lj<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  vector<vector<char>> b(a, vector<char>(10));
  rep(i,a)rep(j,10)
    cin>>b[i][j];
  rep(i,a)
    sort(all(b[i]));
         int c=1,d=0;
  sort(all(b));
  rep(i,a-1){
         if(b[i]!=b[i+1]){
           d+=(c*(c-1))/2;
           c=1;
           }
    else{
    c++;
      }
    
           }
  d+=(c*(c-1))/2;
         cout<<d<<endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

#define LIMIT 1000000007

int main(){
   int i,j,k,n;
   long ans,sum,a[200000];

   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%ld",&a[i]);
   sum=ans=0;
   for (i=n-1;i>0;i--) {
      sum=(sum+a[i])%LIMIT;
      ans=(ans+sum*a[i-1])%LIMIT;
   }
   printf("%ld\n",ans);
   return 0;
}


Measured memory_bytes: 3240
n = gets.to_i
h = gets.split.map(&:to_i)

rh = h.reverse

if n == 1
  puts "Yes"
  exit
end

(h.size - 1).times do |i|
  if rh[i + 1] > rh[i]
    rh[i + 1] -= 1
  end
  if rh[i + 1] > rh[i]
    puts "No"
    exit
  end
end

puts "Yes"

Measured memory_bytes: 9348
// Problem : 
// 			C - Walking Takahashi
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
   

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
void solve()
{
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll div=min(k,x/d);
	x-=(d*div);
	k-=div;
	if(k%2)
		x=abs(x-d);
	cout<<x<<endl;
}
int main()
{
    KAMEHAMEHA
	int t=1;
	//cin>>t;
	for(int cn=1;cn<=t;cn++)
	{
		solve();
	}
    return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    int ans=0;
    if(a>=b){
        ans +=a;
        a--;
    }else{
        ans+=b;
        b--;
    }
    if(a>=b){
        ans +=a;
        a--;
    }else{
        ans+=b;
        b--;
    }
    cout << ans << endl;
}

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

int main()
{
	char word[10];
	cin >> word;
	int wordLength = strlen(word);
	for(int i = 0;i < wordLength;i++)
	{
		if (word[i] >= 'A' && word[i] <= 'Z')
			word[i] -= 'A' - 'a';
	}
	int number = 0;
	while(true)
	{
		char text[1000];
		cin.getline(text, 1000);
		if (strcmp(text, "END_OF_TEXT") == 0)
			break;
		int textLength = strlen(text);
		for(int i = 0;i < textLength;i++)
		{
			if (text[i] >= 'A' && text[i] <= 'Z')
				text[i] -= 'A' - 'a';
		}
		int limit = textLength - wordLength + 1;
		for (int i = 0; i < limit; i++)
		{
			if (text[i] == word[0])
			{
				bool HasFind = true;
				for (int j = 1; j < wordLength; j++)
				{
					if (text[(i + j)] != word[j])
						HasFind = false;
				}
				if (HasFind)
				{
					if (text[i - 1] == ' ' || i == 0)
						if (i + wordLength >= textLength)
							number++;
						else if (text[i + wordLength] == ' ')
							number++;
				}
			}
		}
	}
	cout << number << endl;
	return 0;
}


Measured memory_bytes: 3088
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import defaultdict
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    
    dd = defaultdict(int)
    #Aを昇順にソートしておく
    #昇順にすることで前から値iを取り出して以降のある範囲のiの倍数をもれなくチェックすることができる
    #チェックされた回数が2以上の値は自分以外の要素の倍数である（自分は自分自身の倍数であるからどの値も少なくとも1回はチェックされる）
    A.sort()

    #mx:=Aの最大値
    mx = A[-1]
    for i in A:
        #mxまでのiの倍数を調べる
        j = i
        while j <= mx:
            dd[j] += 1
            j += i
    cnt = 0
    for e in A:
        #チェックされた回数が1の要素つまり与えられた配列の中で自分自身でしか割り切れない要素の数が答え
        cnt += (dd[e] == 1) 
    print(cnt)
if __name__ == '__main__':
    main()


Measured memory_bytes: 229204
#include <stdio.h>

int main()
{
  int a, x, y, z;

  scanf("%d%d",&x, &y);
  
  if(x < y){
    a = x;
    x = y;
    y = a;
  }

  while(y > 0){
    z = x % y;
    x = y;
    y = z;
  }
    
  printf("%d\n",x);
  
  return 0;
}

Measured memory_bytes: 592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

	public static void main(String[] args) throws IOException {
		Main main = new Main();
		main.run();
	}

	private void run() throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] values = br.readLine().split(" ");
		int K = Integer.parseInt(values[0]);
		int N = Integer.parseInt(values[1]);
		values = br.readLine().split(" ");
		int max = 0;
		for(int i = 0; i < N-1; i++) {
			int dif = Integer.parseInt(values[i+1]) - Integer.parseInt(values[i]);
			if(dif > max) {
				max = dif;
			}
		}
		int dif = K+Integer.parseInt(values[0]) - Integer.parseInt(values[N-1]);
		if(dif > max) {
			max = dif;
		}
		int result = K - max;
		out.println(result);
		out.flush();
		br.close();
	}
}

Measured memory_bytes: 50652
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 262144
pair<long long, long long> seg_memo[2000000] = {};
pair<long long, long long> seg_find(long long now, long long w_l, long long w_r, long long n_l, long long n_r) {
	if (w_l >= n_r||w_r <= n_l) return make_pair(999999, 0);
	if (w_l <= n_l&&n_r <= w_r) return seg_memo[now];
	pair<long long, long long> a = seg_find(now * 2, w_l, w_r, n_l, (n_l + n_r) / 2),b = seg_find(now * 2 + 1, w_l, w_r,(n_l + n_r) / 2,n_r);
	if (a.first < b.first) {
		return a;
	}
	else {
		return b;
	}
}
long long setting(long long now) {
	if (seg_memo[now * 2].first < seg_memo[now * 2 + 1].first) {
		seg_memo[now] = seg_memo[now * 2];
	}
	else {
		seg_memo[now] = seg_memo[now * 2 + 1];
	}
	if(now != 1) setting(now / 2);
	return 0;
}
int main() {
#define int long long
	int n;
	cin >> n;
	for (int i = 0;i <= seg_size * 2;++i) {
		seg_memo[i].first = 999999;
	}
	for (int i = 0;i < n;++i) {
		cin >> seg_memo[seg_size + i].first;
		seg_memo[seg_size + i].second = i;
		setting((seg_size + i) / 2);
	}
	long long ans = 0;
	queue<pair<long long, long long>> gekogeko;
	gekogeko.push(make_pair(0, n));
	while (gekogeko.empty() == false) {
		pair<long long, long long> now = gekogeko.front();
		gekogeko.pop();
		pair<long long, long long> returned = seg_find(1, now.first, now.second, 0, seg_size);
		long long genya = returned.first * (returned.second - now.first + 1);
		genya *= (now.second - returned.second);
		ans += genya;
		if (returned.second != now.first) {
			gekogeko.push(make_pair(now.first, returned.second));
		}
		if (returned.second + 1 != now.second) {
			gekogeko.push(make_pair(returned.second + 1, now.second));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31744
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> arrL(N);
    for (int i = 0; i < N; i++) cin >> arrL[i];

    int d = 0;
    int cnt = 1;
    for(int j = 0; j < N; j++){
        d += arrL[j];
        if (d > X) break;

        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n;

void maxHeapify(int node[],int i){
  int l =2*i;
  int r = 2*i+1;
  int largest;
  int temp;

  if(l <= n && node[l] > node[i]){
    largest =l;
  }
  else{
    largest = i;
  }
  if(r <= n && node[r] > node[largest]){
    largest = r; 
  }
  if(largest != i){
    temp = node[i];
    node[i] = node[largest];
    node[largest] = temp;
    maxHeapify(node,largest);
  }
}

void buildMaxHeap(int node[]){
  int i;
  for(i=n/2;i>0;i--){
    maxHeapify(node,i);
  }
}

int main(){
  int i,node[500000];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&node[i]);
  }

  buildMaxHeap(node);

  for(i=1;i<n;i++){
    printf(" %d",node[i]);
  }
  printf(" %d\n",node[n]);

  return 0;
}
   

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int t[2];
int st;
vector<int> v,p,o,c,f,g,v2;
vector<vector<int>> G,s;
void dfs(int i){
    if(v[i])return;
    v[i]=true;
    for(auto e:G[i])dfs(e);
    o.push_back(i);
}
void rdfs(int i,int k){
    if(c[i]!=-1)return;
    c[i]=k;
    rdfs(p[i],k);
}
int grundy(vector<int>& vv){
    sort(all(vv));
    vv.erase(unique(all(vv)),vv.end());
    if(vv[0]>0){
        return 0;
    }
    for(int j=0;j<(int)vv.size()-1;j++){
        if(vv[j+1]>vv[j]+1){
            return vv[j]+1;
        }
    }
    return vv.back()+1;
}
void dfs2(int i){
    if(G[i].size()==0){
        g[i]=0;
        return;
    }
    vector<int> vv;
    for(auto e:G[i]){
        dfs2(e);
        vv.push_back(g[e]);
    }
    g[i]=grundy(vv);
}
bool dfs3(int i,int k){
    if(i!=st){
        vector<int> vv;
        for(auto e:G[i]){
            vv.push_back(g[e]);
        }
        int gg=grundy(vv);
        if(p[i]==st){
            if(k==0){
                return gg!=t[0];
            }else{
                return gg==t[0];
            }
        }else{
            g[i]=gg;
        }
    }else{
        g[i]=t[k];
    }
    return dfs3(p[i],k);
}
int main(){
    int n;cin>>n;
    G.resize(n+10);
    g.resize(n+10);
    p.resize(n+10);
    v.resize(n+10);
    c.resize(n+10,-1);
    s.resize(n+10);
    f.resize(n+10);
    for(int i=0;i<n;i++){   
        cin>>p[i];--p[i];
        G[p[i]].push_back(i);
    }
    for(int i=0;i<n;i++){
        dfs(i);
    }
    reverse(all(o));
    int co=0;
    for(auto i:o){
        if(c[i]==-1)rdfs(i,co),co++;
    }
    for(int i=0;i<n;i++){
        s[c[i]].push_back(i);
    }
    if(co==1){
        if(n%2==0){
            cout<<"POSSIBLE"<<endl;
        }else{
            cout<<"IMPOSSIBLE"<<endl;
        }   
        return 0;
    }
    for(int i=0;i<co;i++){
        if(s[i].size()<=1)continue;
        for(auto k:s[i]){
            f[k]=true;
        }
        for(auto k:s[i]){
            if(G[k].size()>1){
                st=k;
            }
            for(auto e:G[k]){
                if(!f[e])dfs2(e);
            }
        }
        vector<int> vv;
        for(auto e:G[st]){
            if(!f[e])vv.push_back(g[e]);
        }
        t[0]=grundy(vv);
        vv.push_back(t[0]);
        t[1]=grundy(vv);
        if(dfs3(st,0)||dfs3(st,1)){
            cout<<"POSSIBLE"<<endl;
        }else{
            cout<<"IMPOSSIBLE"<<endl;
        }
        return 0;
    }
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

constexpr ll INF = 1LL << 60;

ll N, K;

int main(void) {
    cin >> N >> K;
    vecll h(N);
    rep(i, N) cin >> h[i];

    vecll dp(N + 1, INF);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for (int i = 0; i < N; ++i) {
        for (int k = 1; k <= K; ++k) {
            if (i + k >= N) break;
            dp[i + k] = min(dp[i + k], dp[i] + abs(h[i + k] - h[i]));
        }
    }

    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
  static class Data {
    public final long price;
    public final int count;

    public Data(long price, int count) {
      this.price = price;
      this.count = count;
    }
  }

  public static void main(String... args) {

    try (Scanner sc = new Scanner(System.in)) {
      int N = sc.nextInt();
      int M = sc.nextInt();
      List<Data> list = new ArrayList<>();
      for (int i = 0; i < N; ++i) {
        list.add(new Data(sc.nextLong(), sc.nextInt()));
      }
      list.sort(Comparator.comparingLong(o -> o.price));

      long total = 0;
      for (Data d : list) {
        if (d.count < M) {
          total += d.price * d.count;
          M -= d.count;
        } else {
          total += d.price * M;
          break;
        }
      }
      System.out.println(total);
    }
  }

}

Measured memory_bytes: 92716
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define endl "\n"
inline bool EQ(double a, double b)
{
    return fabs(a - b) < 1e-9;
}
const int INF = 1 << 29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n)
{
    int res = 0;
    while (n && ++res)
        n -= n & (-n);
    return res;
}
template <class T>
void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
void chmin(T &a, const T &b) { a = min(a, b); }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    n = n % 1000;
    if (n != 0)
        cout << 1000 - n << endl;
    else
        cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void MAX(T &x,T y){if(y>x)x=y;}
template<class T>inline void MIN(T &x,T y){if(y<x)x=y;}
template<class T>inline void rd(T &x){
	x=0;char o,f=1;
	while(o=getchar(),o<48)if(o==45)f=-f;
	do x=(x<<3)+(x<<1)+(o^48);
	while(o=getchar(),o>47);
	x*=f;
}
const int M=5005;
int n,m,A[M],mxL[M][M],mxR[M][M];
bool dpL[M][M],dpR[M][M];

int main(){
#ifndef ONLINE_JUDGE
//	freopen("jiedai.in","r",stdin);
//	freopen("jiedai.out","w",stdout);
#endif
	rd(n),rd(m);
	for(int i=1;i<=n;i++)rd(A[i]);
	dpL[0][0]=dpR[n+1][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<m;j++){
			if(dpL[i-1][j])dpL[i][j]=1;
			if(dpL[i-1][j]&&j+A[i]<m)dpL[i][j+A[i]]=1;
		}
	}
	for(int i=n;i>=1;i--){
		for(int j=0;j<m;j++){
			if(dpR[i+1][j])dpR[i][j]=1;
			if(dpR[i+1][j]&&j+A[i]<m)dpR[i][j+A[i]]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<m;j++){
			mxL[i][j]=mxL[i][j-1];
			mxR[i][j]=mxR[i][j-1];
			if(dpL[i][j])mxL[i][j]=j;
			if(dpR[i][j])mxR[i][j]=j;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int res=0;
		for(int j=0;j<m;j++)MAX(res,mxL[i-1][j]+mxR[i+1][m-1-j]);
		if(res+A[i]<m)ans++;
	}
	printf("%d\n",ans);
	return (0-0);
}


Measured memory_bytes: 244864
import java.util.Scanner;

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

		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());

		//		int[] x = new int[n];
		//
		//		for (int i = 0; i < n; i++) {
		//			x[i] = Integer.parseInt(sc.next());
		//		}
		int sum = 0;

		if (x == 1) {
			sum += 300000;
		} else if (x == 2) {
			sum += 200000;
		} else if (x == 3) {
			sum += 100000;
		}

		if (y == 1) {
			sum += 300000;
		} else if (y == 2) {
			sum += 200000;
		} else if (y == 3) {
			sum += 100000;
		}

		if (x == 1 && y == 1) {
			sum += 400000;
		}

		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 22228
x, n = list(map(int, input().split()))
al = list(map(int, input().split()))
INF = float("inf")
ans = INF
sa = INF
for i in range(102):
    if i not in al:
        if sa > abs(x-i):
            sa = abs(x-i)
            ans = i
print(ans)


Measured memory_bytes: 61676
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n;

int main() {
    while (cin >> n) {
        if (n == 0) break;
        int res = 0;
        while (n >= 1) {
            res += n/5;
            n /= 5;
        }
        cout << res << endl;
    }
    return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<long long> A(N);
    for(int i=0; i<N; ++i) cin>>A[i];
    
    long long mod=1e9+7,ans=0,x=0;
    for(int i=0; i<N; ++i){
        ans = (ans + A[i]*x)%mod;
        x = (x + A[i])%mod;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4812
S,T=[0,0].map{(?0+gets).chars.map{|c|$.-=~c.count(?A)}};$<.map{|l|a,b,c,d=l.split.map &:to_i;d&&puts((S[b]-S[a-1]-T[d]+T[c-1])%3<1?:YES: :NO)}

Measured memory_bytes: 23020
#include <iostream>
#include <iomanip>
 
using namespace std;
 
int main(){

int a,b;
int d,r;
double f;

cin >> a >> b;

d = a/b;
r = a%b;
f = (double)a/b;

cout << d << " " << r << " " << fixed << setprecision(10) << f << endl;


return 0;
}

Measured memory_bytes: 1248
#include <stdio.h>

int main(void)
{
	int n;
	int h[100];
	int i, j;
	int d, prev;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		n++;
		
		for (i = 0; i < n; i++){
			scanf("%d", &h[i]);
		}
		
		for (i = 0; i < n; i++){
			prev = 0;
			d = 0;
//printf("(i=%d)", i);
			for (j = 0; j < n; j++){
				if (j == i){
					continue;
				}
				if (prev == 0){
					prev = h[j];
					continue;
				}
				if (d == 0){
					d = h[j] - prev;
					if (d == 0){
						break;
					}
					prev = h[j];
					continue;
				}
				if (h[j] != prev + d){
					break;
				}
				prev = h[j];
			}
			if (j == n){
				printf("%d\n", h[i]);
				break;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();

        long x = nextLong();

        long fiveHundred = x/500;
        long five = (x - fiveHundred*500)/5;
        System.out.println(fiveHundred*1000 + five*5);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}


Measured memory_bytes: 21332
menu_time=[]
total_time = 0
last_time = 9
for i in range(0,5):
    a = int(input())
    menu_time.append(a)
for i in range(0,5):
    if menu_time[i]%10==0:
        total_time+=menu_time[i]
    else:
        total_time+=(menu_time[i]//10+1)*10
for i in range(0,5):
    if menu_time[i]%10!=0 and menu_time[i]%10<last_time:
        last_time = menu_time[i]%10
    else:
        dum=0
if menu_time[0]%10==menu_time[1]%10==menu_time[2]%10==menu_time[3]%10==menu_time[4]%10==0:
    dum = 0
else:
    total_time+=last_time-10
print(total_time)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n,m;
vector<P> es;
double p;
double dp[1<<14];

int main(){
  cin>>n>>m>>p;
  p/=100.0;
  rep(i,m){
    int a,b;
    cin>>a>>b;a--;b--;
    es.push_back(P(a,b));
  }
  repl(S,1,1<<n){
    dp[S]=1.0;
    ll v=0;
    for(;!((S>>v)&1);v++);
    for(ll T=S-1;T>=0;T--){
      T&=S;
      if(!((T>>v)&1))continue;
      ll _T=S-T;
      double pp=dp[T];
      rep(i,m){
        if((((T>>es[i].fi)&1)&&((_T>>es[i].se)&1))||(((_T>>es[i].fi)&1)&&((T>>es[i].se)&1)))pp*=p;
      }
      dp[S]-=pp;
    }
  }
  printf("%.10f\n", dp[(1<<n)-1]);
  return 0;
}



Measured memory_bytes: 3344
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  int n;
  while(cin >> n, n) {
    unsigned long long a[4100] = {};
    vi in(n);
    rep(i, n) {
      int p, q, r; cin >> p >> q >> r;
      a[p] += q*r;
      in[i] = p;
    }

    bool b = false;
    rep(i, n) {
      if(a[in[i]] >= 1000000) {
        cout << in[i] << endl;
        a[in[i]] = 0;
        b = true;
      }
    }
    if(!b) cout << "NA" << endl;
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define SLAY ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.141592653589793238
#define ll long long
#define pii pair<int , int>
#define pll pair<long long , long long>
#define INPUT freopen("travel_restrictions_validation_input.txt", "r", stdin);
using namespace std;
int dx[] = { 0 , 0 , 1 , -1};
int dy[] = { 1 , -1 , 0 , 0};
int getmod(int x, int y , int mod ){return (((x - y)%mod)+mod)%mod;}
int main(){SLAY
	int _=1 , tc=1;
	// cin>>_;
	while(_--){
		ll n,a,b,c;
		string str;
		ll ans=0;
		cin>>n;
		for(int i = 1;i<=n ; i++){
			ll y = n/i;
			ans += i*y*(y+1)/2;
		}
		cout<<ans;
		cout<<endl;
	}
	return 0;
}


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

int main(){
    string S;
    cin>>S;
    int cnt=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='x'){
            cnt++;
        }
    }
    if(cnt>7){
        cout<<"NO"<<endl;
    }
    if(cnt<8){
        cout<<"YES"<<endl;

    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
G = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    G[a-1].append(H[b-1])
    G[b-1].append(H[a-1])

ans = 0
for i in range(N):
    if not G[i]:
        ans += 1
    elif H[i] > max(G[i]):
        ans += 1

print(ans)       

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


int main(){
  ull n;
  cin >> n;
  vector<ull> vec(n);
  map<ull,ull> a;//ボールの番号ごとの個数
  for(int i=0;i<n;i++){
	ull num;
    cin >> num;
    vec.at(i) = num;
    a[num]++;
  }
  vector<pair<ull,ull>> m(a.size());//aをvalueでソートするためにpairへ
  int c=0;
  for( auto p : a ){
    m.at(c).first = p.second;
    m.at(c).second = p.first;   
    c++;
  }
  sort(m.begin(),m.end());
  reverse(m.begin(),m.end());// mをボールの個数の大きい順にソート
  
  ull sum=0;
  for(int j=0;j<m.size();j++){
    ull k = m.at(j).second;//ボールに書かれた数字
    ull v = m.at(j).first;//数字がkのボールの個数
    if( v < 2 ) break;
     sum += v*(v-1)/2;
  }
  for(int i=0;i<n;i++){
    ull num = a[vec.at(i)];
    if( num >= 2 ){
      cout << sum-(num-1) << endl;
    }else{
      cout << sum << endl;
    }
  }

  
 

  return 0;
}

Measured memory_bytes: 14080
import sys
from operator import itemgetter
 
inf = 1 << 30
 
def solve():
    n = int(sys.stdin.readline())
 
    # r_max = MAX, b_min = MIN にしたとき
 
    r_max = b_max = 0
    r_min = b_min = inf

    p = []
 
    for i in range(n):
        xi, yi = map(int, sys.stdin.readline().split())

        if xi > yi:
            xi, yi = yi, xi

        p.append((xi, yi))

        r_max = max(r_max, yi)
        r_min = min(r_min, yi)
        b_max = max(b_max, xi)
        b_min = min(b_min, xi)
 
    ans1 = (r_max - r_min) * (b_max - b_min)
 
    # r_max = MAX, r_min = MIN にしたとき
 
    ans2 = (r_max - b_min)

    p.sort(key=itemgetter(0))

    b_min = p[0][0]
    b_max = p[-1][0]

    y_min = inf

    dif_b = b_max - b_min
 
    for i in range(n - 1):
        y_min = min(y_min, p[i][1])

        b_min = min(p[i + 1][0], y_min)
        b_max = max(b_max, p[i][1])

        dif_b = min(dif_b, b_max - b_min)
 
    ans2 *= dif_b
 
    ans = min(ans1, ans2)
 
    print(ans)
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 33896
n,k = map(int, input().split())
s = input()

ans = 0
flag = 0

for i in range(n-1):
    if s[i] == s[i+1]:
        ans += 1

for i in range(n-1):
    if s[i] != s[i+1]:
        flag += 1

if k > flag//2:
    ans = n-1
elif flag > 1:
    ans += 2*k
else:
    ans += 1

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string s;
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b)%3==0 || a%3==0 || b%3==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n, m, l;
int A[100][100], B[100][100];
long C[100][100]={0};
int i, j, k;
cin >> n >> m >>l;
for(i = 0; i < n; i++){
for(j = 0; j < m; j++){
cin >> A[i][j];
}
}
for(i = 0; i < m; i++){
for(j = 0; j < l; j++){
cin >> B[i][j];
}
}
for(i = 0; i < n; i++){
for(j = 0; j < l; j++){
for(k = 0; k < m; k++){
C[i][j] += A[i][k] * B[k][j];
}
}
}
for(i = 0; i < n; i++){
for(j = 0; j < l; j++){
cout << C[i][j];
if(j != l -1){
cout << " ";
}
}
cout << endl;
}
return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> S(100010, 0);
	Int sum = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		sum += a;
		++S[a];
	}
	int Q;
	cin >> Q;
	vector<Int> ans(Q);
	for (int i = 0; i < Q; ++i) {
		Int b, c;
		cin >> b >> c;

		sum += c * S[b] - b * S[b];
		ans[i] = sum;
		S[c] += S[b];
		S[b] = 0;
	}

	for (auto v : ans) { cout << v << endl; }

	return 0;
}


Measured memory_bytes: 4232
def lucas(n):
    global nlist
    if n==0:
        return 2
    if n==1:
        return 1
    if nlist[n]!=0:
        return nlist[n]
    else:
        nlist[n]=lucas(n-1)+lucas(n-2)
        return lucas(n-1)+lucas(n-2)
    
nlist=[0 for a in range(100)]
print(lucas(int(input())))


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

int main()
{
    int n;
    cin >> n;
    if (n == 1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

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

  vector<ll> a(n);
  vector<ll> sums(n + 1);
  sums[0] = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sums[i + 1] = sums[i] + a[i];
  }

  map<ll, ll> cnts;
  for (int i = 0; i <= n; ++i) {
    cnts[sums[i] % m]++;
  }

  long long ans = 0;
  for (auto e: cnts) {
    long long add = ((e.second - 1) * e.second) / 2;
    ans += add;
  }

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



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


#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define pair < int , int > pii

const int N = 1e5 + 100;
int n, a[N], ans, t = 1;
set < int > s;

int main(){
	
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a+n);
	for(int i = 1; i <= n; i++){
		if(a[i] != a[i-1])
			ans += (a[i-1] == t? 0: a[i-1] > t? t: t-a[i-1]), t = 1;
		else
			t++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

vector<int> f(int x, vector<int> ary){

}

int main(){
    int odd = 1;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n){ cin >> a.at(i);}

    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 1){
            odd *= 1;
        }else{
            odd *= 2;
        }
    }

    put(int(pow(3,n) - odd));
}

Measured memory_bytes: 256
H = int(input())
num = {}
lis = [H]

h = H
while h > 1:
    h //= 2
    num[h] = 0
    lis = [h] + lis

num[1] = 1

for n in lis[1:]:
    num[n] = 2*num[n//2] + 1

print(num[H])


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 3000000000000000000; //3*10^18
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

ll po(ll a, ll b){
    ll res = 1;
    ll tmp = a;
    while(b > 0){
        if(b % 2 == 1) res = res * tmp % MOD;
        b = b / 2;
        tmp = tmp*tmp % MOD; 
    }
    return res;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N),b(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    map<pair<ll,ll>, pair<ll,ll>> M;
    ll tmp;
    ll cnt = 0;
    for (ll i = 0; i < N; i++) {
        if(a[i] < 0 && b[i] < 0){
            a[i] = -1*a[i];
            b[i] = -1*b[i];
        }
        if(b[i] < 0){
            a[i] = -1*a[i];
            b[i] = -1*b[i];
        }
        if(a[i] == 0 && b[i] == 0){
            cnt += 1;
            continue;
        }
        else if(b[i] == 0){
            if(!M.count(make_pair(INF,0))){
                M[make_pair(INF,0)] = make_pair(zero,zero);
            }
            M[make_pair(INF,0)].first++;
        }
        else if(a[i] == 0){
            if(!M.count(make_pair(INF,0))){
                M[make_pair(INF,0)] = make_pair(zero,zero);
            }
            M[make_pair(INF,0)].second++;
        }
        else{
            tmp = __gcd(abs(a[i]), b[i]);
            a[i] = a[i] / tmp;
            b[i] = b[i] / tmp;
            if(a[i] > 0){
                if(!M.count(make_pair(a[i],b[i]))){
                    M[make_pair(a[i],b[i])] = make_pair(zero,zero);
                }
                M[make_pair(a[i],b[i])].first++;
            }
            else{
                a[i] = -1*a[i];
                if(!M.count(make_pair(b[i],a[i]))){
                    M[make_pair(b[i],a[i])] = make_pair(zero,zero);
                }
                M[make_pair(b[i],a[i])].second++;
            }
        }

    }
    ll ans;
    ans = 1;
    for (pair<pair<ll,ll>, pair<ll,ll>> p : M){
        if(p.second.first == 0){
            tmp = po(2, p.second.second) % MOD;
        }
        else if(p.second.second == 0){
            tmp = po(2, p.second.first) % MOD;
        }
        else{
            tmp = (po(2, p.second.first)%MOD + po(2, p.second.second)%MOD +MOD - 1) % MOD;
        }
        ans = ans * tmp % MOD;
    }
    ans = (MOD + ans - 1) % MOD;
    ans = (ans + cnt) %MOD;
    printf("%lld\n", ans);

    
}


Measured memory_bytes: 21912
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[100], b[100], c, d, tmp, m, h, w, x, y, sum, k, q;
ll dp[ohara][20];

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

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

  // dp[mask][i]
  // maskで1のやつを既に並べてある時の最小
  //を知りたかったが、cost計算の際に、
  //最後にaddしたindexである所のi必要なので添え字に組み込む

  rep(i, ohara) rep(j, 20) dp[i][j] = LINF;
  rep(i, n) { dp[(1LL << i)][i] = 0; }
  ll lim = (1LL << n);
  rrep(i, 1, lim) {
    rep(j, n) {
      if (!(i & (1LL << j))) continue;
      rep(k, n) {
        if (i & (1LL << k)) continue;
        // sorted判定
        ll tatu = __builtin_popcount(i);
        ll before, after, dis, cost = 0;

        dis = abs(j - (tatu - 1));
        if (dis % 2 == 0) {
          //表
          before = a[j];
        } else {
          before = b[j];
        }

        dis = abs(k - tatu);
        if (dis % 2 == 0) {
          //表
          after = a[k];
        } else {
          after = b[k];
        }

        if (before > after) continue;

        rrep(z, k + 1, n) {
          if (i & (1LL << z)) {
            cost++;
          }
        }

        dp[(i | (1LL << k))][k] = min(dp[(i | (1LL << k))][k], dp[i][j] + cost);
      }
    }
  }

  ans = LINF;
  rep(i, 20) { ans = min(ans, dp[lim - 1][i]); }
  if (ans == LINF) ans = -1;
  Cout(ans);
  return 0;
}

Measured memory_bytes: 156544
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long int a,b=0;bool flag=false;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a%2==0) flag=true;
    while(1){
      if(a%2!=0) break;
      a/=2;
      b++;
    }
  }
  if(!flag) cout << 0<<endl;
  else{
     cout << b<<endl;
  }

}


Measured memory_bytes: 256