akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define inf 2000000000

int count=0;

void merge(int A[],int left,int mid,int right){
    int i;
    int n1=mid-left;
    int n2=right-mid;
    int L[n1+1],R[n2+1];
    for(i=0;i<=n1-1;i++){
        L[i]=A[left+i];
    }
    for(i=0;i<=n2-1;i++){
        R[i]=A[mid+i];
    }
    L[n1]=inf;
    R[n2]=inf;
    i=0;
    int j=0,s;
    for(s=left;s<=right-1;s++){
        if(L[i]<=R[j]){
            A[s]=L[i];
            i++;
            }
        else{
            A[s]=R[j];
            j++;
            
        }
        count++;
    }
}

void mergeSort(int A[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}


int main(){
    int num;
    scanf("%d",&num);
    int A[num];
    int i;
    for(i=0;i<=num-1;i++)scanf("%d",&A[i]);
    
    mergeSort(A,0,num);
    
    for(i=0;i<=num-2;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[num-1]);
    printf("%d\n",count);
    
    return 0;
}



Measured memory_bytes: 5612
# -*- coding: utf-8 -*-
"""
B - Between a and b ...
https://atcoder.jp/contests/abc048/tasks/abc048_b

"""
import sys


def solve(a, b, x):
    q, r = divmod(b, x)
    b -= r
    a = ((a + x - 1)//x) * x
    if a > b:
        return 0
    return (b - a)//x + 1


def main(args):
    a, b, x = map(int, input().split())
    ans = solve(a, b, x)
    print(ans)


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


Measured memory_bytes: 3064
import java.util.*

data class Mask(val x1:Int, val y1:Int, val x2:Int, val y2:Int){
    constructor(vararg nums:Int):this(nums[0], nums[1], nums[2], nums[3]){}
}
class CoordinateCompresser(coordinates: IntArray){
    private var mArray = coordinates.distinct().sorted().toIntArray()
    operator fun get(coord:Int):Int {
        return mArray.binarySearch(coord)
    }
}

class Map(val height:Int, val width:Int, val masks:Iterator<Mask>){
    private val mArray = Array(height){Array(width){0}}.apply {
        masks.forEach { (x1, y1, x2, y2) ->
            this[y1][x1] += 1
            if (x2 in 0 until width) this[y1][x2] += -1
            if (y2 in 0 until height) this[y2][x1] += -1
            if (x2 in 0 until width && y2 in 0 until height) this[y2][x2] += 1
        }
        for (y in 0 until height){
            for (x in 1 until width){
                this[y][x] += this[y][x - 1]
            }
        }
        for (y in 1 until height){
            for (x in 0 until width){
                this[y][x] += this[y - 1][x]
            }
        }
    }
    private var mAreaCount:Int? = null
    fun areaCount():Int{
        if (mAreaCount == null) mAreaCount = calAreaCount()
        return mAreaCount!!
    }
    private fun calAreaCount():Int {
        var count = 0
        for (x in 0 until width)
            for (y in 0 until height){
                when(mArray[y][x]){
                    0 ->{
                        ++count
                        fillArea(x, y)
                    }
                }
            }
        return count
    }
    private fun fillArea(x:Int, y:Int):Unit{
        val stack = Stack<Point>().apply { push(Point(x, y)) }
        while (stack.size != 0){
            for ((a, b) in stack.pop().neighbor()){
                if (a in 0 until width && b in 0 until height && mArray[b][a] == 0){
                    mArray[b][a] = 1
                    stack.push(Point(a, b))
                }
            }
        }
    }
    private data class Point(val x:Int, val y:Int){
        fun neighbor():List<Point> = listOf(Point(x + 1, y), Point(x - 1, y), Point(x, y + 1), Point(x, y - 1))
    }
}
fun solve(w:Int, h:Int):Unit{
    if (h == 0 && w == 0) return

    Array(readLine()!!.toInt()){
        Mask(*(readLine()!!.split(' ').map(String::toInt).toIntArray()))
    }.let{
        val xCompresser = CoordinateCompresser(it.flatMap {mask -> listOf(mask.x1, mask.x2) }.plus(0).plus(w).toIntArray())
        val yCompresser = CoordinateCompresser(it.flatMap { mask -> listOf(mask.y1, mask.y2)}.plus(0).plus(h).toIntArray())
        println(Map(yCompresser[h], xCompresser[w], it.map{mask -> Mask(xCompresser[mask.x1], yCompresser[mask.y1], xCompresser[mask.x2], yCompresser[mask.y2])}.iterator()).areaCount())
    }
    val (nw, nh) = readLine()!!.split(' ').map(String::toInt)
    solve(nw, nh)
}
fun main(args:Array<String>):Unit{
    val (w, h) = readLine()!!.split(' ').map(String::toInt)
    solve(w, h)
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int P = cin.nextInt();

        int applePiece = A * 3 + P;
        Console.WriteLine(applePiece / 2);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
from decimal import *

n = int(input())
T, A = [], []
for _ in range(n):
    t, a = map(int, input().split())
    T.append(t)
    A.append(a)

Taka = 0
Aoki = 0

for i in range(n):

    if (T[i] >= Taka) and (A[i] >= Aoki):
        Taka = T[i]
        Aoki = A[i]
    elif T[i] == A[i]:
        Taka = max(Taka, Aoki)
        Aoki = Taka
    else:
        Taka_up = -(-Taka//T[i])
        Aoki_up = -(-Aoki//A[i])
        multi = max(Taka_up, Aoki_up)
        Taka = T[i] * multi
        Aoki = A[i] * multi   

ans = int(Taka + Aoki)
print(ans)

Measured memory_bytes: 5076
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;
int main()
{
   
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;

    
    

    return 0;

}


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

int main()
{
    int T;
    long long s[200005];
    cin >> T;
    cin >> s[0];
    long long max1 = -2000000001, min1 = s[0];
    for(int i=1; i<T; i++)
    {
        cin >> s[i];
        max1 = max(max1,s[i]-min1);
        min1 = min(min1,s[i]);
    }
    cout << max1 << endl;
    return 0;
}

Measured memory_bytes: 4636
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(u) for(int i=hd[u],v;v=e[i].v,i;i=e[i].n)
using namespace std;
const int N=2020,INF=1000010000;
int n,ans,fl,u,v;
int hd[N],fa[N],sz[N],f[N],g[N],we[N];
char s[N];
struct edge{int n,v;}e[N<<1];
void add(int u,int v){e[++fl]=(edge){hd[u],v};hd[u]=fl;}
void dfs(int u){
	f[u]=we[u]=0;sz[u]=s[u]^48;
	REP(u)if(v!=fa[u]){
		fa[v]=u;dfs(v);
		f[v]+=sz[v];g[v]+=sz[v];
		if(f[v]>f[we[u]]) we[u]=v;
		f[u]+=f[v];sz[u]+=sz[v];
	}
	g[u]=g[we[u]]>f[u]-f[we[u]]?g[we[u]]-f[u]+f[we[u]]:f[u]&1;
}
void work(int u){
	fa[u]=0;dfs(u);
	if(g[u]==0) ans=min(ans,f[u]/2);
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%s",&n,s+1);ans=INF;
	FOR(i,2,n) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	FOR(i,1,n) work(i);
	cout<<(ans==INF?-1:ans)<<'\n';
}


Measured memory_bytes: 384
n, m = map(int, input().split())
money = []
for i in range(n):
  a, b = map(int, input().split())
  money.append({"a":a, "b":b})

bsum = 0
money.sort(key=lambda x: x["a"])
for i in range(n):
  bsum0 = bsum
  bsum += money[i]["b"]
  if m <= bsum:
    num = i
    break

ans = 0
for j in range(num):
  ans += money[j]["a"] * money[j]["b"]
ans += (m-bsum0) * money[num]["a"]
print(ans)

Measured memory_bytes: 41504
a = int(input())
aa = a % 10
if aa == 0:
    aa = 10**10
    aaa = a
else:
    aaa = (a // 10) * 10 + 10
    
b = int(input())
bb = b % 10
if bb == 0:
    bb = 10**10
    bbb = b
else:
    bbb = (b // 10) * 10 + 10

c = int(input())
cc = c % 10
if cc == 0:
    cc = 10**10
    ccc = c
else:
    ccc = (c // 10) * 10 + 10

d = int(input())
dd = d % 10
if dd == 0:
    dd = 10**10
    ddd = d
else:
    ddd = (d // 10) * 10 + 10


e = int(input())
ee = e % 10
if ee == 0:
    ee = 10**10
    eee = e
else:
    eee = (e // 10) * 10 + 10


t = [a,b,c,d,e]
tt = [aa,bb,cc,dd,ee]
ttt = [aaa,bbb,ccc,ddd,eee]

ans = sum(ttt) - ttt[tt.index(min(tt))] + t[tt.index(min(tt))]
#print(t)
#print(tt)
#print(ttt)



print(ans)


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

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

    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == '1') {
            s.at(i) = '9';
        } else if (s.at(i) == '9') {
            s.at(i) = '1';
        }
    }
    cout << s << endl;

}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, a;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a;
		if(a % 2 == 0){
			if(a % 3 == 0 or a % 5 == 0) continue;
			else{
				cout << "DENIED";
				return 0;
			}
		}
	}
	cout << "APPROVED";

	return 0;
}



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

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

    int front = stoi(S.substr(0, 2));
    int back = stoi(S.substr(2, 2));
    
    bool ym = (back > 0) && (back < 13);
    bool my = (front > 0) && (front < 13);

    string ans = "NA";
    if (ym == true && my == true)
        ans = "AMBIGUOUS";
    else if (ym == true)
        ans = "YYMM";
    else if (my == true)
        ans = "MMYY";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin>>n>>x;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    long long ans=0;
    if(a[0]>x){
        ans=a[0]-x;
        a[0]=x;
    }
    for(int i=1;i<n;i++){
        if(a[i]+a[i-1]>x){
            ans+=a[i]+a[i-1]-x;
            a[i]=x-a[i-1];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int i, j, N, K;
    cin>>N>>K;
    vector<char> ds(K);
    rep(i, K) cin>>ds[i];

    rep(i, 100100) {
        if (i < N) continue;
        string s = to_string(i);
        bool find = true;
        rep(j, K) {
            if (s.find(ds[j]) != string::npos) {
                find = false;
                break;
            }
        }
        if (find) {
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    cin>>N;
    long long int lis[200003];
    for(int i=0;i<N;i++)cin>>lis[i];
    long long int now=lis[0];
    long long int ans=0;
    for(int i=1;i<N;i++){
        if(now<=lis[i]){
            now=lis[i];
        }
        else{
            ans+=now-lis[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4756
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b,p,q=0;
	cin>>a>>b;
	p=b-a;
	for(int i=1;i<p;i++)q+=i;
	cout<<q-a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << 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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, m, x;
  cin >> n >> m >> x;
  vi c(n);
  vii a(n, vi(m));
  ll ctotal;
  vi atotal(m);
  bool z;
  bool y = false;
  ll ans = INF;
  rep(i, n){
    cin >> c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }
  for (ll tmp = 0; tmp < (1 << 12);tmp++){
    bitset<12> s(tmp);
     z= true;
     ctotal = 0;
     rep(i, m){
       atotal[i] = 0;
     }
    rep(i,n){
      if(s[i]==1){
        ctotal += c[i];
        rep(j, m){
          atotal[j] += a[i][j];
        }
      }
    }
    rep(i,m){
      if(atotal[i]<x){
        z = false;
      }
    }
    if(z){
      y = true;
      chmin(ans, ctotal);
    }
  }
  if(y){
    print(ans);
  }
  else{
    print(-1);
  }
}

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

namespace _0259
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string a = Console.ReadLine();
                if (a == "0000") { break; }
                if (a[0] == a[1] && a[1] == a[2] && a[2] == a[3]) { Console.WriteLine("NA"); continue; }
                for (long k = 0; ; k++)
                {
                    if (a == "6174") { Console.WriteLine(k); break; }

                    int[] s = { int.Parse(a.Substring(0, 1)), int.Parse(a.Substring(1, 1)), int.Parse(a.Substring(2, 1)), int.Parse(a.Substring(3, 1)) };
                    Array.Sort(s);
                    long j = (s[3] * 999 + s[2] * 90 - s[1] * 90 - s[0] * 999);
                    a = j.ToString();
                    if (j < 1000) { a = "0" + a; }
                    if (j < 100) { a = "0" + a; }
                    if (j < 10) { a = "0" + a; }
                }
            }
        }
    }
}

Measured memory_bytes: 9548
$num = gets.to_i

a = gets.chomp
$a = a.split()
$b = []
for i in 1..$num do
	$b[i-1] = $a[i-1].to_i
end


$n = 0

$c = []
def merge(left,right)
	if(left >= right)
		return
	end

	mid = (left + right) / 2
	merge(left,mid)
	merge(mid + 1,right)
	
	for i in left..mid do
		$c[i] = $b[i]
	end

	j = right
	for i in mid + 1..right
		$c[i] = $b[j]
		j = j - 1
	end

	i = left
	j = right 

	for k in left..right do
		if $c[i] <= $c[j]
			$b[k] = $c[i]
			i = i + 1
		else
			$n = $n + mid + 1 - i
			$b[k] = $c[j]
			j = j - 1
		end
	end
end

merge(0,$num-1)

puts $n

Measured memory_bytes: 29596
#include <iostream>
using namespace std;
#define Nmax 10000

int main()
{
	int n = 0;
	int a[Nmax] = { 0 };
	do
	{
		cin >> a[n];
	} while (a[n++] != 0);

	for (int i = 0; i < n - 1; i++) {
		cout << "Case " << (i + 1) << ": ";
		cout << a[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  cout<<1-n<<endl;
}

Measured memory_bytes: 3604
def main():
    D = int(input())
    c_list = list(map(int, input().split()))
    s_list = [list(map(int, input().split())) for _ in range(D)]
    t_list = [int(input()) for _ in range(D)]

    basic_bad = sum(c_list)
    #res_list = []
    M = int(input())
    for m in range(M):
        d,q = map(int, input().split())
        t_list[d-1] = q
        res = 0
        
        bad = 0
        last_open = [0] * 26
        for i in range(D):
            t = t_list[i]
            res += s_list[i][t-1]

            # TODO: ここは毎回26ループ回す必要がないところになりうるので改善可能かも(なおすだけで20回分の処理が消せる)
            # bad = 0
            # for ci in range(26):
            #     bad += c_list[ci]*(i+1 - last_open[ci])
            bad += basic_bad - (i+1 - last_open[t-1]) * c_list[t-1]
            last_open[t-1] = i+1

            res -= bad

        print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69872
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class ABallDistribution {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int N, K;
    cin >> N >> K;
    cout << (K == 1 ? 0 : N - K) << endl;
}
};


#undef int
int main() {
	ABallDistribution solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e16;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

ModInt func[2000003];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
ModInt comb(ModInt n, ModInt r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 1;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}
int main() {
	string s;
	lint K;
	cin >> K >> s;
	ModInt ans = 0;
	funcinit(2000003);
	REP(i, K + 1) {
		ModInt inst = mod_pow(25, i);
		inst *= mod_pow(26, K - i);
		ModInt cb = comb(i + SZ(s) - 1, i);
		inst *= comb(i + SZ(s) - 1, i);
		ans += inst;
	}
	cout << ans.a << endl;
}

Measured memory_bytes: 20056
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define bit(n) (1LL<<(n))
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n;string s; cin >> n >> s;
    int hn = n;
    vector<pair<string, string>> br;
    rep(i,bit(hn)){
        string b="",r="";
        rep(j,hn){
            if(bit(j)&i){
                b += s[j];
            } else {
                r += s[j];
            }
        }
        reverse(all(r));
        br.emplace_back(b,r);
    }
    sort(all(br));
    ll ans = 0;
    rep(i,bit(2*n-hn)){
        string b="",r="";
        rep(j,2*n-hn){
            if(bit(j)&i){
                b += s[j+hn];
            } else {
                r += s[j+hn];
            }
        }
        reverse(all(r));
        auto p = make_pair(r,b);
        auto it = lower_bound(all(br),p);
        auto it2 = upper_bound(all(br),p);
        ans += distance(it,it2);
    }
    cout << ans << '\n';
    
}

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

typedef long long LL;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;

const int INF = 1000000007;
const LL INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int MAX = 1e5 + 7;
int tab[MAX], dp[MAX];

int main() {
    _boost;

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> tab[i];

    fill(dp+1, dp+n, INF);

    for(int i = 1; i < n; i++)
        for(int j = 1; j <= min(k, i); j++)
            dp[i] = min(dp[i], dp[i-j]+abs(tab[i-j]-tab[i]));

    cout << dp[n-1];

    return 0;
}


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

#define task "B"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 2e5 + 2;
int n, x[N], X;
ll pre[N];
int main()
{
#ifdef HynDuf
    freopen("B.in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> n >> X;
    rep(i, 1, n)
    {
        cin >> x[i];
        pre[i] = pre[i - 1] + x[i];
    }
    ll ans = 1e18;
    rep(k, 1, n)
    {
        ll res = 0;
        int cnt = 1;
        for (int j = n; j > 0; j -= k)
        {
            int coeffi = (cnt == 1) ? 5 : (2 * cnt + 1);
            cnt++;
            res += (pre[j] - pre[max(0, j - k)]) * coeffi;
            res = min(res, ans);
        }
        ans = min(ans, k * 1LL * X + res);
        //DB(res);
    }
    cout << ans + n * 1LL * X;
    return 0;
}


Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }

int main() {
  int s, w;
  cin >> s >> w;
  if (s <= w) cout << "unsafe" << endl;
  else cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int p, q, a, n;

int solve(int level, int num, int den, int bef)
{
    int i, ret = 0;

    for(i = bef; i * den <= a; i++){
        int left = p * den * i;
        int right = den + num * i;
        if(left < right * q)
            continue;
        if(left == right * q){
            ret++;
            continue;
        }
        if(level < n)
            ret += solve(level + 1, right, i * den, i);
    }
    return ret;
}

int main(void)
{
    while(1){
        scanf("%d %d %d %d", &p, &q, &a, &n);
        if(p == 0 && q == 0 && a == 0 && n == 0)
            break;
        printf("%d\n", solve(1, 0, 1, 1));
    }
    return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

map<P, bool> mp;
ll x[55],y[55];

int main(void){
	int n,i,j,k,ans=INF,tmp;
	ll p,q;
	cin >> n;
	if(n==1){
		cout << 1 << endl;
		return 0;
	}
	for(i=0; i<n; ++i){
		cin >> x[i] >> y[i];
		mp[P(x[i],y[i])] = true;
	}
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			p = x[i]-x[j];
			q = y[i]-y[j];
			if(!(p||q)){
				continue;
			}
			tmp = 0;
			for(k=0; k<n; ++k){
				if(mp[P(x[k]-p,y[k]-q)]){
					continue;
				}
				++tmp;
			}
			ans = min(ans,tmp);
		}
	}
	cout << ans << endl;
	return 0;
}


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

const int N = 2050;
int n, x, y, d[N][N], ans[N];

int dd(int i, int j) {
    return abs(i - j);
}

int dist(int i, int j) {
    return min(dd(i, j), min(dd(i, x) + 1 + dd(y, j), dd(i, y) + 1 + dd(x, j)));
}

main() {
    cin >> n >> x >> y;
    rep(i, 1, n + 1) rep(j, i + 1, n + 1) {
        ans[dist(i, j)]++;
    }
    rep(k, 1, n) {
        cout << ans[k] << '\n';
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] l = new int[N];
        for(int i = 0; i < N; i++){
            l[i] = sc.nextInt();
        }

        Arrays.sort(l);
        int ans = 0;
        for(int i = 0; i < K; i++){
            ans += l[N-1 - i];
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 20948
#include<iostream>
using namespace std;
int main()
{
string str1,str2,str3;
cin>>str1>>str2>>str3;
char ch1=(char)((int)str1[0]-32);
char ch2=(char)((int)str2[0]-32);
char ch3=(char)((int)str3[0]-32);

cout<<ch1<<ch2<<ch3;
}

Measured memory_bytes: 256
import itertools
from collections import defaultdict

def main():
    N = int(input())
    A = defaultdict(int)
    for x in range(1,N+1):
        breakflag = False
        for y in range(1,N+1):
            for z in range(1,N+1):
                a = x**2 + y**2 + z**2 + x*y + y*z + z*x
                # print(x,y,z,a,A)
                if a <= N:
                    A[a] += 1
                else:
                    break
    for i in range(N):
        print(A[i+1])

if __name__ == '__main__':
    main()

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

int main(void){
	int N,T;
	long long X = 0;
	cin >> N >> T;
	int i;
	int t[N];
	for(i=0;i<N;i++)cin >> t[i];
	for(i=1;i<N;i++){
		if(T>=(t[i] - t[i-1])){
			X += t[i] - t[i-1];
		}else{
			X += T;
		}
	}
	X += T;
	cout << X ;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define min(a, b) a < b ? a : b
#define max(a, b) a > b ? a : b

#define MAXN 100000

int main(void)
{
	long long i;
	long long N;
	int ok = 1;
	long long sumn = 0, suma = 0, k;
	long long A[MAXN];
	long long d[MAXN];

	scanf("%lld", &N);

	for (i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
		suma += A[i];
	}

	sumn = N * (N + 1) / 2;
	if ((suma % sumn) != 0) {
		//ok = 0;
		printf("NO\n");
	} else {
		k = suma / sumn;
		for (i = 0; i < N; i++) {
			d[i] = A[(i + 1) % N] - A[i] - k;
		}
		for (i = 0; i < N; i++) {
			/*if (d[i] % N == 0 && d[i] <= 0) {
				ok = 1;
			} else {
				ok = 0;
				break;
			}*/
			//ok = 1;
			if (d[i] % N != 0 || d[i] > 0) {
				ok = 0;
				break;
				/*printf("NO\n");
				return (0);*/
			}
		}
		//printf("YES\n");
		if (ok) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	/*if (ok) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}*/
	return (0);
}

Measured memory_bytes: 1664
N, T = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

ans = 0
min_cost = A[0]
max_value = -Float::INFINITY

A.each do |a|
  v = a - min_cost

  if max_value < v
    max_value = v
    ans = 1
  elsif max_value == v
    ans += 1
  end

  min_cost = a if min_cost > a
end

puts ans


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

int main() {
    int h, w;
    cin >> h >> w;

    string board[50];

    for (int i = 0; i < h; i++) {
        cin >> board[i];
    }

    const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
    const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (board[i][j] == '#') continue;
            
            int num = 0;
            for (int d = 0; d < 8; d++) {
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if (ni < 0 or h <= ni) continue;
                if (nj < 0 or w <= nj) continue;
                if (board[ni][nj] == '#') num ++;
            }

            board[i][j] = char(num + '0');
        }
    }

    for (int i = 0; i < h; i++) {
        cout << board[i] << endl;
    }    

    return 0;
}

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

int main(){
    int s,w;
    cin >>s >>w;
    if(s>w){
        cout << "safe" <<endl;
    }else{
        cout << "unsafe" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
//#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define maxe max_element
#define mine min_element
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<ll,ll>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define debug(x) cerr<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define SIZE 5000 + 1
const ll MAX=1e9;
const ll mod=1e9;

ll expo(ll x,ll n){
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%mod;}
                x=(x*x)%mod;
                n>>=1;
    }
    return ans;
}


void solve()
{
    ll n,m,i;
    cin>>n>>m;
    vl a(m);
    ll sum=0;
    fn(i,m){cin>>a[i];sum+=a[i];}
    if(n-sum>=0)
    cout<<n-sum<<endl;
    else
        cout<<-1<<endl;

}

int main()
{
  boost;
  ll t=1;
 // cin>>t;
  while(t--)
  {

      solve();
  }
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 200000;
int main()
{
  int n,i;
  long long a,res=2e15;
  long long s[N_MAX];
  cin >> n >> a;
  s[0]=a;
  for(i=1;i<n;i++){
    cin >> a;
    s[i]=s[i-1]+a;
  }
  for(i=0;i<n-1;i++)
    res=min(res,abs(s[n-1]-2*s[i]));
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void swap(ll &a, ll &b)
{
	ll temp = a;
	a = b;
	a = temp;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	ll n;
	cin>>n;
	ll a,b;
	cin>>a>>b;
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		if(x<a || x>=b)
			ans++;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 384
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
int n;
int a[200010]; 
int main(){
//  cout<<fixed<<setprecision(1)<<1<<endl;
//system("cls");
	cin>>n;
	cin>>a[0];
	int cnt=0;
	cnt=a[0];
	for(int i=1;i<n;i++){
		cin>>a[i];
		cnt^=a[i];
	}
	for(int i=0;i<n;i++){
		cnt^=a[i];
		cout<<cnt<<" ";
		cnt^=a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 4312
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC169B
    {
        const string FILE = @"..\..\data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            string line;
            string[] sa;
            line = Console.ReadLine();
            int n = int.Parse(line);

            line = Console.ReadLine();
            sa = line.Split(' ');

            long result = 1;
            for (int i = 0; i < n; ++i)
            {
                if (long.Parse(sa[i]) == 0)
                {
                    result = 0;
                }
            }

            if (result > 0)
            {
                long resultPre = result;
                for (int i = 0; i < n; ++i)
                {
                    result *= long.Parse(sa[i]);
                    if (result > 1000000000000000000)
                    {
                        result = -1;
                        break;
                    }
                    else if (result < resultPre)
                    {
                        result = -1;
                        break;
                    }
                    resultPre = result;
                }
            }
            Console.WriteLine(result);

#if DEBUG
            Console.WriteLine("end");
            Console.SetIn(Console.In);
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 39860
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		List<Long> li = new ArrayList<>();
		li.add(2L);
		li.add(1L);
		for (int i = 2; i <= n; i++) {
				li.add(li.get(i-1)+li.get(i-2));
		}
		System.out.println(li.get(n));
	}
}

Measured memory_bytes: 22996
use std::collections::{BTreeSet, VecDeque};

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut graph = vec![vec![]; n];
    let mut parent = vec![0; n];
    for i in 0..n {
        let p = sc.read::<usize>() - 1;
        graph[p].push(i);
        parent[i] = p;
    }

    let mut q = VecDeque::new();
    let mut a = vec![-1; n];
    for i in 0..n {
        let is_leaf = graph[i].is_empty();
        if is_leaf {
            q.push_back(i);
            a[i] = 0;
        }
    }

    let mut reach = vec![0; n];
    while let Some(v) = q.pop_front() {
        let parent = parent[v];
        reach[parent] += 1;
        if reach[parent] == graph[parent].len() {
            let children = graph[parent]
                .iter()
                .map(|&child| a[child])
                .collect::<BTreeSet<_>>();
            a[parent] = (0..).find(|&a| !children.contains(&a)).unwrap();
            q.push_back(parent);
        }
    }

    let v = (0..n).find(|&i| a[i] == -1).unwrap();
    let v_children = graph[v]
        .iter()
        .filter(|&&i| a[i] != -1)
        .map(|&i| a[i])
        .collect::<BTreeSet<_>>();
    let candidates = (0..)
        .filter(|&i| !v_children.contains(&i))
        .take(2)
        .collect::<Vec<_>>();

    for candidate in candidates.into_iter() {
        a[v] = candidate;
        let mut cur = parent[v];
        while cur != v {
            let children = graph[cur].iter().map(|&i| a[i]).collect::<BTreeSet<_>>();
            a[cur] = (0..).find(|&i| !children.contains(&i)).unwrap();
            cur = parent[cur];
        }
        let check = graph[v].iter().map(|&i| a[i]).collect::<BTreeSet<_>>();
        if (0..).find(|&i| !check.contains(&i)).unwrap() == a[v] {
            println!("POSSIBLE");
            return;
        }
    }
    println!("IMPOSSIBLE");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 15896
N, M = map(int, input().split(" "))
A_list = []
B_list = []
total = 0

for i in range(N):
    A, B = map(int, input().split(" "))
    A_list.append(A)
    B_list.append(B)

z = list(zip(A_list, B_list))
z.sort()

for a, b in z:
    if b > M:
        total += M * a
        break
    else:
        total += b * a
        M -= b

print(total)

Measured memory_bytes: 18488
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t A[300000];
bool ng[300000];

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    for (size_t i = 0; i < N; i++)
    {
        in >> A[i];
    }
    std::sort(A, A + N);

    for (size_t i = 0; i < N; i++)
    {
        if (ng[i]) { continue; }

        int64_t v = A[i];
        auto iter = std::lower_bound(A + i + 1, A + N, v);
        while (iter != A + N) {

            while (*iter == v) {

                if (v == A[i]) { ng[i] = true; }
                ng[iter - A] = true;
                ++iter;
            }

            v += A[i];
            iter = std::lower_bound(iter, A + N, v);
        }

    }
    std::cout << std::count(ng, ng + N, false) << endl;

    return 0;
}
#endif


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

int main(){
    ll N;
    cin >> N;
    ll A[N+1];
    ll B[N];
    for(ll i=0;i<N+1;i++){
        cin >> A[i];
    }
    for(ll i=0;i<N;i++){
        cin >> B[i];
    }

    ll count=0;
    for(ll i=0;i<N;i++){
        if(B[i]>A[i]){ //隣町までいける
            count+=A[i];
            B[i]-=A[i];
            A[i]=0;
            if(B[i]>A[i+1]){
                count+=A[i+1];
                A[i+1]=0;
            }else{
                count+=B[i];
                A[i+1]-=B[i];
            }
        }else{
            count+=B[i];
            A[i]-=B[i];
        }
        // cout << i << ':';
        // for(ll j=0;j<N+1;j++){
        //     cout << A[j] << ' ';
        // }
        // cout <<':' << count << endl;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
    var a, b, d, r int
    var f float64

    fmt.Scanf("%d %d", &a, &b)
    d = a /b
    r = a % b
    f = float64(a) / float64(b)

    fmt.Printf("%d %d %.5f\n", d, r, f)
}


Measured memory_bytes: 1188