akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Array.Unboxed
import Data.Array.ST
import Control.Monad.ST

main = do
    s <- BS.getLine
    t <- BS.getLine
    putStrLn . solve s t (BS.length s - 1) (BS.length t - 1) $ makeTable s t

makeTable s t = runSTUArray $ do
    let n = BS.length s
        m = BS.length t
    arr <- newArray ((-1,-1),(n-1,m-1)) 0 :: ST s (STUArray s (Int, Int) Int)
    forM_ [0..n-1] $ \i -> do
        forM_ [0..m-1] $ \j -> do
            let x = BS.index s i
                y = BS.index t j
            if x == y then do
                l <- readArray arr (i-1, j-1)
                writeArray arr (i, j) (l + 1)
            else do
                li <- readArray arr (i-1, j)
                lj <- readArray arr (i, j-1)
                writeArray arr (i,j) (max li lj)
    return arr

solve s t i j table = reverse $ loop i j
    where loop (-1) _ = []
          loop _ (-1) = []
          loop i j | si == tj = si : loop (i-1) (j-1)
                   | i1j == ij = loop (i-1) j
                   | otherwise = loop i (j-1)
                   where si = BS.index s i
                         tj = BS.index t j
                         i1j = table ! (i-1,j)
                         ij = table ! (i,j)

Measured memory_bytes: 71804
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 11111111111;
const int c_mINF = -11111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };

int main() {
	int N, A[100000],X[100000];
	//入力
	scanf("%d", &N);
	for (int i = 0; i < N; i++)scanf("%d", &A[i]);

	for (int i = 0; i < N; i++)X[i] = 0;

	for (int i = 0; i <  N/2;i++)X[0] += A[2*i] - A[2*i+1];
	X[0] += A[N - 1];
	X[0] /= 2;
	//printf("%d\n",X[0]);

	for (int i = 0; i < N - 1; i++) {
		X[i + 1] = A[i] - X[i];
	}
	for (int i = 0; i < N; i++)printf("%d ", 2*X[i]);

	/*
			for i in range(N - 1) :
				X.aappend(A[i] - X[i])

				print(X)

	*/




}


/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
ll n,a[222222];
ll ans=0;
int main()
{
	cin>>n>>a[0];
	rep2(i,1,n)
	{
		cin>>a[i];
		if(a[i]<a[i-1]) ans+=a[i-1]-a[i],a[i]=a[i-1];
	}
	re(ans)
	return 0;}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
string s, t;
int n, m;
int cnt1[26];
int cnt2[26];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> s >> t;
    n = s.size();
    m = t.size();
    for(int i=0;i<n;i++)cnt1[s[i] - 'a']++;
    for(int i=0;i<m;i++)cnt2[t[i] - 'a']++;
    int kol = 0;
    char c;
    for(int i=0;i<26;i++){
        if(cnt1[i] == cnt2[i])continue;
        if(cnt1[i] > cnt2[i])return cout << "No" ,0;
        c = char(i + 'a');
        kol += cnt2[i] - cnt1[i];
    }
//    cout << c << endl;
    if(t[m - 1] == c)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using interval = pair<int, int>;

int main() {
    int _, m; cin >> _ >> m;
    vector<interval> jobs(m);
    for (auto &p: jobs) cin >> p.first >> p.second;
    sort(jobs.begin(), jobs.end(), [](interval &a, interval &b) {
        return a.second < b.second;
    });
    int cnt = 0, lst = 0;
    for (auto &p: jobs) if (lst <= p.first) lst = p.second, cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
c = [list(map(int, input().split())) for _ in range(3)]
    
b1b2 = c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2]
b1b3 = c[0][0]-c[2][0] == c[0][1]-c[2][1] == c[0][2]-c[2][2]
b2b3 = c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2]

if b1b2 and b1b3 and b2b3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    a = list(map(int,input().split()))

    res = 0
    for _ in range(N-1):
        a = sorted(a, key=lambda x: -x)
        res = (a[-1]+a[-2])/2
        a.pop()
        a.pop()
        a.append(res)
    print(a[0])
if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
N, M = [int(x) for x in input().split()]
H_list = [int(x) for x in input().split()]
bad_list = []
for _ in range(M):
    A, B = [int(x) for x in input().split()]
    if H_list[A - 1] < H_list[B - 1]:
        bad_list.append(A)
    elif H_list[A - 1] > H_list[B - 1]:
        bad_list.append(B)
    else:
        bad_list.append(A)
        bad_list.append(B)

print(N - len(set(bad_list)))


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

int main(){
	int n, a[52],f;
	char suit[52];
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> suit[i] >> a[i];
	}
	char suitX[] = {'S','H','C','D'};
	for (int s = 0; s < 4; s++){
		for (int t = 1; t < 14; t++){
			f = 0;
			for (int i = 0; i < n; i++){
				if (suitX[s] == suit[i] && t == a[i])f++;
			}
			if (f == 0)cout << suitX[s] << ' ' << t << endl;
		}
	}
	return 0;
}


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

const int mod=1e9+7;

signed main(){
    vector<int> air(3);
    rep(i,3)cin >> air[i];
    sort(all(air));
    int ans=0;
    ans=air[1]+air[0];
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ma = 0;
  for(int i=1;i<33;i++){
    int j = i*i;
    for(int k=0;k<35;k++){
      if(j<=n){
        ma = max(ma,j);
        j *= i;
      }
      else break;
    }
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

#define  MOD 1000000007
int main(){
    string s;
    cin >> s;

    ll dp[100010][5];
    rep(i, 100010)rep(j, 5)dp[i][j] = 0;
    dp[0][0] = 1;

    rep(i, s.size()){
        rep(j, 5){
            if(s[i] == '?')dp[i+1][j] = (dp[i+1][j] + dp[i][j]*3%MOD)%MOD;
            else dp[i+1][j] = (dp[i+1][j] + dp[i][j])%MOD;
        }
        if(s[i] == 'A' || s[i] == '?')dp[i+1][1] = (dp[i+1][1] + dp[i][0])%MOD;
        if(s[i] == 'B' || s[i] == '?')dp[i+1][2] = (dp[i+1][2] + dp[i][1])%MOD;
        if(s[i] == 'C' || s[i] == '?')dp[i+1][3] = (dp[i+1][3] + dp[i][2])%MOD;
    }

    cout << dp[s.size()][3] << endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int K;
	cin >> K;
	vector<int> ANS(50);

	if (K <= 50)
	{
		rep(i, 0, K)
		{
			ANS[i] = 50 - i;
		}
	}
	else
	{
		rep(i, 0, 50)
		{
			ANS[i] = 50 - i + (K / 50) - 1;
		}
		rep(i, 0, K % 50)
		{
			ANS[i]++;
		}
	}

	cout << 50 << endl;
	for (auto v : ANS)
	{
		cout << v << " ";
	}
	cout << endl;

	return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int i,n,k;
    unordered_set<int>st;
    sf(n);
    rep0(i,n)
    {
        sf(k);
        st.insert(k);
    }
    puts(sz(st)==n?"YES":"NO");
}


Measured memory_bytes: 8520
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <set>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    vector<int> a(m, 0), b(m, 0);
    vector<vector<int>> list(n+1);
    rep(i, m) {
        cin >> a[i] >> b[i];
        list[a[i]].push_back(b[i]);
        list[b[i]].push_back(a[i]);
    }
    int ans = 0;
    map<int, int> mp;
    for(int i = 0; i < n; i++) {
        int mx = h[i];
        int flag = 0;
        for(auto j : list[i+1]) {
            if(mx <= h[j-1]) {
                flag = 1;
                break;
            }
        }
        if(flag == 0) {
            mp[i+1] = 1;
            ans++;
        }
    }
    for(int i = 1; i <= n; i++) {
        if(list[i].size() == 0 && mp[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13428
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1e5 + 20 ;
int n , a[N] , b[N] , ord[N] ;
ll ans ;

inline bool cmp (int i , int j) { 
	return a[i] + b[i] > a[j] + b[j] ;
}

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

	cin >> n ;

	for (int i = 0 ; i < n ; i ++) cin >> a[i] >> b[i] , ans -= b[i] ;

	iota(ord , ord + n , 0) ;
	sort(ord , ord + n , cmp) ;

	for (int i = 0 ; i < n ; i += 2) ans += a[ord[i]] + b[ord[i]] ;

	cout << ans << '\n' ;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void)
{
  	int n;
	  scanf("%d",&n);

	  int i,v[n],c[n];

	  for(i=0;i<n;i++)
   	      scanf("%d",&v[i]);
	  for(i=0;i<n;i++)
	    scanf("%d",&c[i]);

  	int A=0;
 	   for(i=0;i<n;i++)
    	if(v[i]-c[i]>0)
      		A += v[i]-c[i];

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


}



Measured memory_bytes: 128
A, B, C, X = [int(input()) for _ in range(4)]

ans = 0
for i in range(A+1):
    if 500*i > X:
        break
    for j in range(B+1):
        if 500*i + 100*j > X:
            break
        if X - 500*i - 100*j <= 50*C:
            ans += 1

print(ans)

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

int main(void){
    long long a,b,c,k,h,ans;
    h = 1000000000000000000;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(k%2==0){
        ans = a - b;
    }else{
        ans = b - a;
    }
    if(abs(ans) > h){
        printf("Unfair");
    }else{
        printf("%d",ans);
    }
    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e12
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n, r;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

ll calc(ll a) {
	if (a == 1)return 1;
	return calc(a / 2) * 2 + 1;
}

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

	cin >> n >> r;
	chmin(n, 10);

	cout << r + 100 * (10 - n) << endl;

}

Measured memory_bytes: 256
N, D = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i):
        d = sum((x - y)**2 for x, y in zip(P[i], P[j]))
        x = int(d**.5)
        if x**2 == d:
            ans += 1
print(ans)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		DiceOri dice=new DiceOri(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
		String com=sc.next();
		for(int i=0;i<com.length();i++) {
			switch(com.substring(i,i+1)) {
			case "N":
				dice.TurnN();
				break;
			case "W":
				dice.TurnW();
				break;
			case "S":
				dice.TurnS();
				break;
			case "E":
				dice.TurnE();
				break;
			}
		}
		System.out.println(dice.Top);
	}

}

class DiceOri{
	int Top;
    int Bottom;
    int Nth;
    int Sth;
    int Wst;
    int Est;
    DiceOri(int a, int b, int c, int d, int e, int f) {
        Top = a;
        Sth = b;
        Est = c;
        Wst = d;
        Nth = e;
        Bottom = f;
    }
	public void TurnN() {
		int empty=Top;
		Top=Sth;
		Sth=Bottom;
		Bottom=Nth;
		Nth=empty;
	}
	public void TurnW() {
		int empty=Top;
		Top=Est;
		Est=Bottom;
		Bottom=Wst;
		Wst=empty;
	}
	public void TurnS() {
		int empty=Top;
		Top=Nth;
		Nth=Bottom;
		Bottom=Sth;
		Sth=empty;
	}
	public void TurnE() {
		int empty=Top;
		Top=Wst;
		Wst=Bottom;
		Bottom=Est;
		Est=empty;
	}
}


Measured memory_bytes: 26400
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

long[Tuple!(long, long)] mem;
immutable long MOD = 10^^9 + 7;

long dp(long s, long x) {
    Tuple!(long, long) t = tuple(s, x);
    if (t in mem)
        return mem[t];
    if (s == 0)
        return 1;
    else if (s == 1) {
        mem[t] = (dp(s/2, x/2) + dp((s-1)/2, (x-1)/2)) % MOD;
        return mem[t];
    }
    mem[t] = (dp(s/2, x/2) + dp((s-1)/2, (x-1)/2) + dp((s-2)/2, x/2)) % MOD;
    return mem[t];
}

void main() {
    long N = readln.chomp.to!long;
    dp(N, N).writeln;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
  string s;
  cin >> s;
  vector<int> cnt(3);
  for(int i = 0; i < s.size(); i++) {
    cnt[s[i] - 'a']++;
  }
  int mi = *min_element(all(cnt));
  int ma = *max_element(all(cnt));
  if (ma - mi > 1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

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

public class Program{
    public static void Main(){
        int N=int.Parse(Console.ReadLine());
        int ans;
        if(N>0 && N<10){
            ans=N;
        }else if(N>=10 && N<100){
            ans=9;
        }else if(N>=100 && N<1000){
            ans=N-90;
        }else if(N>=1000 && N<10000){
            ans=909;
        }else if(N>=10000 && N<100000){
            ans=N-9090;
        }else{
            ans=90909;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
N = input()
A = map(int, raw_input().split())
A.sort()
cnt = [0 for _ in xrange(9)]
for a in A:
    cnt[min(a/400, 8)] += 1

m = 0
for c in cnt[:-1]:
    if c > 0:
        m += 1
if m == 0 and cnt[:-1] > 0:
    print 1, cnt[-1]
else:
    print m, m + cnt[-1]


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

int main() {
  ll L0 = 2;
  ll L1 = 1;
  int N; cin >> N;
  if (N == 1) { cout << 1 <<  endl; return 0;} 
  ll ans;
  rep(i,N-1){
    ans = L0 + L1;
    swap(L0, L1);
    L1 = ans;
//    cout << ans << " ";
  }
// cout << endl;
  cout << ans << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, M;
vector<vector<int>> graph;
vector<int> deg, order;

void toporo(){
  queue<int> que;
  REP(i, N){
    if(deg[i] == 0){
      que.push(i);
    }
  }
  while(!que.empty()){
    int v = que.front(); que.pop();
    order.push_back(v);

    for(auto nv : graph[v]){
      --deg[nv];
      if(deg[nv] == 0) que.push(nv);
    }
  }
  reverse(order.begin(), order.end());
}

int main(){
  cin >> N >> M;
  deg.resize(N);
  graph.resize(N);
  vector<vector<int>> in(N);

  REP(i, N+M-1){
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[b].push_back(a);
    deg[a]++;
  }
  toporo();
  vector<int> depth(N);
  REP(i, N){
    depth[order[i]] = i;
  }
  REP(i, N){
    int oya = 0, d = -1;
    for(auto v :graph[i]){
      if(d < depth[v]){
        d = depth[v];
        oya = v+1;
      }
    }
    cout << oya << endl;
  }
  return 0;
}


Measured memory_bytes: 9976
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0023&lang=jp

"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline


def main(args):
    N = int(input())
    for _ in range(N):
        x_a, y_a, r_a, x_b, y_b, r_b = map(float, input().split())

        distance = sqrt((x_a - x_b) ** 2 + (y_a - y_b) ** 2)
        if r_a + r_b < distance:
            result = 0
        elif r_a > distance + r_b:
            result = 2
        elif r_b > distance + r_a:
            result = -2
        else:
            result = 1
        print(result)


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

Measured memory_bytes: 7752
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s[i];

  vector<string> t(h+w, string(h+w, '.'));
  REP(i, h) REP(j, w) {
    t[j+i][j-i+h-1] = s[i][j];
  }

  // REP(i, h+w) cout << t[i] << endl;

  ll n = h+w;
  auto cnt1 = make_v<ll>(n, n);
  REP(i, n) {
    if(t[i][0] == '#') cnt1[i][0] = 1;
    FOR(j, 1, n) {
      cnt1[i][j] += cnt1[i][j-1] + (t[i][j]=='#'?1:0);
    }
  }
  auto cnt2 = make_v<ll>(n, n);
  REP(i, n) {
    if(t[0][i] == '#') cnt2[0][i] = 1;
    FOR(j, 1, n) {
      cnt2[j][i] += cnt2[j-1][i] + (t[j][i]=='#'?1:0);
    }
  }

  ll ret = 0;
  REP(i, n) {
    REP(l, n) {
      if(t[i][l] == '.') continue;
      FOR(r, l+1, n) {
        if(t[i][r] == '.') continue;
        if(i-(r-l) >= 0) {
          ret += cnt1[i-(r-l)][r] - (l==0?0:cnt1[i-(r-l)][l-1]);
        }
        if(i+(r-l) < n) {
          ret += cnt1[i+r-l][r] - (l==0?0:cnt1[i+r-l][l-1]);
        }
      }
    }
  }
  REP(i, n) {
    REP(l, n) {
      if(t[l][i] == '.') continue;
      FOR(r, l+1, n) {
        if(t[r][i] == '.') continue;
        if(i-(r-l) >= 0) {
          ret += cnt2[r-1][i-(r-l)] - (l==0?0:cnt2[l][i-(r-l)]);
        }
        if(i+(r-l) < n) {
          ret += cnt2[r-1][i+r-l] - (l==0?0:cnt2[l][i+r-l]);
        }
      }
    }
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<int> c(h,0);
    string inp;
    for(int i=0;i<h;i++){
        cin >> inp;
        for(int j=0;j<w;j++){
            if(inp.at(j)=='#'){
                c.at(i)++;
            }
            c.at(i)=c.at(i)<<1;
        }
        c.at(i)=c.at(i)>>1;
    }
    // for(int i=0;i<h;i++){
    //     cout << c.at(i) << endl;
    // }
    
    int count =0;
    int ans=0;
    int temp;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            count =0;
            for(int m=0;m<h;m++){
                if(((i>>m)&1 )== true){
                    // cout << c.at(m);
                    temp=(c.at(m) & j);
                    // cout << c.at(m) << endl;
                    for(int l=0;l<w;l++){
                        if((temp>>l )&1 )count++;
                    }
                }
            }
            // cout << i <<" " << j << endl;
            if(count == k)ans++;

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

Measured memory_bytes: 3144
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, m := scanInt(), scanInt()
	price := make([]int, m)
	keys := make([]int, m)

	for i := 0; i < m; i++ {
		a, b := scanInt(), scanInt()
		price[i] = a
		for j := 0; j < b; j++ {
			t := 1
			c := scanInt()-1
			for k := 0; k < c; k++ {
				t*=2
			}
			keys[i] += t
		}
	}

	dp := make([][]int, m+1)

	for i := 0; i < m+1; i++ {
		dp[i] = make([]int, (1 << uint(n)))
		for j := 0; j < (1 << uint(n)); j++ {
			dp[i][j] = -1
		}
	}

	dp[0][0] = 0

	for i := 1; i < m+1; i++ {
		for j := 0; j < (1 << uint(n)); j++ {
			if dp[i-1][j] == -1 {
				continue
			}

			if dp[i][j] != -1 {
				dp[i][j] = min(dp[i][j], dp[i-1][j])
			} else {
				dp[i][j] = dp[i-1][j]
			}

			if dp[i][j|keys[i-1]] != -1 {
				dp[i][j|keys[i-1]] = min(dp[i][j|keys[i-1]], dp[i-1][j] + price[i-1])
			} else {
				dp[i][j|keys[i-1]] = dp[i-1][j] + price[i-1]
			}
		}
	}
	
	// for i := 0; i < m+1; i++ {
	// 	printInts(dp[i]...)
	// }

	fmt.Println(dp[m][(1<<uint(n))-1])
	
}

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

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


Measured memory_bytes: 33792
S=str(input())
X=[int(i) for i in S]
n=len(X)-1
sum=0
s=''

for i in range(2**n):
    s=str(X[0])
    for j in range(n):
        if i>>j&1:
            sum+=int(s)
            s=str(X[j+1])
        else:
            s=s+str(X[j+1])
    else:
        sum+=int(s)
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int a,b,m;
  cin>>a>>b>>m;
  vector<int> as(a),bs(b);
  for(int i=0;i<a;i++) cin>>as[i];
  for(int i=0;i<b;i++) cin>>bs[i];

  int ans=*min_element(as.begin(),as.end())+*min_element(bs.begin(),bs.end());
  for(int i=0;i<m;i++){
    int x,y,c;
    cin>>x>>y>>c;
    x--;y--;
    chmin(ans,as[x]+bs[y]-c);
  }

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


Measured memory_bytes: 1024
#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;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

#define MAX 100005
const long long mod = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void Com_init(){ //##O(MAX)##
    fac[0] = fac[1] = 1; // x!
    finv[0] = finv[1] = 1; // (x!)^-1
    inv[1] = 1; //x^-1
    for(int i=2;i<MAX;i++){
        fac[i] = (fac[i-1] * i) % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}
long long Combination(int n, int k){ //calc nCk, ##O(1)##
    if(n<k || (n<0||k<0))return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    Com_init();
    int n,k;
    scanf("%d%d",&n,&k);
    ll a[100005]={};
    REP(i,n)scanf("%lld",&a[i]);
    ll times[100005]={};
    REP(i,n-k+1)times[i]= Combination(n-i-1, k-1);
    ll max = 0;
    ll min = 0;
    sort(a,a+n);
    REP(i,n)min += (a[i]*times[i])%mod;
    sort(a,a+n, std::greater<ll>());
    REP(i,n)max += (a[i]*times[i])%mod;
    printf("%lld\n",(max-min)%mod);
    return 0;
}

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

bool func(string S){
    int N = S.length();
    for(int i = 0; i <= N / 2; i++){
        if(S[i] != S[N - 1 - i]){
            return false;
        }
    }
    return true;
}

int main(){
    string S;
    cin >> S;
    int N = S.size();
    string str_before = S.substr(0, N / 2), str_after = S.substr((N + 1) / 2, N / 2);
    bool kaibun = func(S);
    bool kaibun_before = func(str_before);
    bool kaibun_after = func(str_after);

    if (kaibun && kaibun_before && kaibun_after){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
        }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,ans=0;
  cin>>n;
  std::vector<int> vec(n);
  for(auto&& e: vec) 
  {
    cin>>e;
  }
  bool flag=true;
  while(flag)
  {
    for(const auto& e: vec) 
    {
      if(e%2!=0) flag=false;
    }
    if(flag)
    {
      for(auto&& e: vec) 
      {
        e/=2;
      }
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)

n, m, k = map(int, input().split())

F = [[] for i in range(n)]   #Friend list
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    F[a].append(b)
    F[b].append(a)


gnum = 1    #group number
#DFS
def DFS_func(a:int, gnum:int):   #Target, Data
        if G[a] == 0:
            G[a] = gnum
            for i in range(len(F[a])):
                DFS_func(F[a][i], gnum)
        else:
            pass
G = [0 for i in range(n)]   #it has Group numbers       
for i in range(n):
    if G[i] == 0:
        DFS_func(i, gnum)
        gnum += 1
    else:
        pass

B = [0 for i in range(n)]   #How many Blocks in the same Group
for i in range(k):
    c, d = map(int, input().split())
    c, d = c-1, d-1
    if G[c] == G[d]:
        B[c] , B[d] = B[c]+1, B[d]+1
    else:
        pass

GS = [0 for i in range(gnum)]   #Group Size
for i in range(n):
    GS[G[i]] += 1

for i in range(n):
    if G[i] == 0:
        ans = 0
    else:
        ans = GS[G[i]]-len(F[i])-B[i]-1
    print(ans, end = ' ')

Measured memory_bytes: 44820
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

bool seen[2000000]{};
bool finished[2000000]{};
int d[2000000]{};
int dfs(const Graph &G, int now){
    if(seen[now] == true) return d[now];
    seen[now] = true;
    for(auto e : G[now]){
        if(seen[e] && !finished[e]){
            cout << -1 << endl;
            exit(0);
        }
        d[now] = max(d[now], dfs(G, e)+1);
    }
    finished[now] = true;
    return d[now];
}

int encode(int i,int j){
    if(i < j) swap(i, j);
    return 1000 * i + j;
}


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

	int N;
    cin >> N;
    Graph G(2000000);
    rep(i,N){
        int now = 0;
        rep(j,N-1){
            int k;
            cin >> k;
            --k;
            int next = encode(i, k);
            G[now].push_back(next);
            now = next;
        }
    }
    cout << dfs(G, 0) << endl;
}

Measured memory_bytes: 74496
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <queue>
using namespace std;

typedef pair<int, char> p;

int partition(vector<p> &v, int p, int r){
  int x = v[r].first;
  int i = p-1;
  for(int j=p;j<r;j++){
    if(v[j].first <= x){
      swap(v[++i], v[j]);
    }
  }
  swap(v[i+1], v[r]);

  return i+1;
}

void quickSort(vector<p> &v, int p, int r){
  if(p < r){
    int q = partition(v, p, r);
    quickSort(v, p, q-1);
    quickSort(v, q+1, r);
  }
}

int main(void){
  int n;
  cin >> n;
  vector<p> v(n);
  vector<p> b(n);

  for(int i=0;i<n;i++){
    cin >> v[i].second >> v[i].first;
    b[i].first = v[i].first;
    b[i].second = v[i].second;
  }
  
  quickSort(v, 0, n-1);

  for(int i=1;i<n;i++){
    if(v[i].first == v[i-1].first){
      int k,l;
      for(k=0;k<n;k++){
        if(v[i-1].first == b[k].first && v[i-1].second == b[k].second){
          break;
        }
      }
      for(l=0;l<n;l++){
        if(v[i].first == b[l].first && v[i].second == b[l].second){
          break;
        }
      }
      if(k > l){
        cout << "Not stable" << endl;
        break;
      }
    }
    if(i == n-1)
      cout << "Stable" << endl;
  }
  for(int i=0;i<n;i++){
    cout << v[i].second << " " << v[i].first << endl;
  }
  return 0;
}

Measured memory_bytes: 2588
def input_int_list():
    return [int(thing) for thing in input().split(" ")]

def int_input():
    return int(input())


def print_ans(string):
    print(string)
    exit()

def yes():
    print("Yes")
    exit()

def no():
    print("No")
    exit()

if __name__ == '__main__':
    A,B,N=input_int_list()
    x=min(B-1,N)
    ans=A*x//B-A*(x//B)
    print_ans(ans)

Measured memory_bytes: 9200
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s  = sc.next();
		String t  = sc.next();
		String res = "No";
		String s2 = s;
		while (true) {
			s2 = s2.substring(s2.length()-1, s2.length()) + s2.substring(0, s2.length()-1);
			if (t.equals(s2)) {
				res = "Yes";
				break;
			}else if (s.equals(s2)) {
				break;
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
ll ceil(ll a,ll b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k,a,b,i;
    cin>>k>>a>>b;
    if((a-b)>=-2 || k<=a)
    {
        cout<<1+k<<endl;
    }
    else
    {
        //k++;
        k=k-(a-1);
        ll sum=0;
        sum+=((b-a)*(k/2));
        sum+=k%2;
        sum+=a;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
l = [0 for i in range(n)]
for i in range(n):
    a1 = int(input())
    l[n-1-i] = a1
h = [l[0]]
ans = 1
for i in range(1,n):
    a = bisect.bisect_right(h,l[i])
    if ans == a:
        ans += 1
        h.append(l[i])
    else:
        h[a] = l[i]
print(ans)

Measured memory_bytes: 7876
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

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.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int n;
    cin>>n;

    vi v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    sort(all(v));
    reverse(all(v));

    int ans=v[0];
    int cur=1;
    for(int i=2;i<n;i+=2)
    {
        if(i==n-1)
            ans+=v[cur];
        else
            ans+=2*v[cur];

        ++cur;
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<typename T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int sum(VI a) { int ret = 0; for (int i : a)ret += i; return ret; }
struct p { int from, to, num; };

int main() {
    init();

    int n;
    cin >> n;
    vector<p> edge(n - 1);
    int a, b;
    FOR(i, 0, n - 1) {
        cin >> a >> b;
        edge[i] = { --a,--b,i };
    }
    VI c(n);
    cin >> c;

    rSORT(c, greater<int>());
    vector<bool> ever(n, false);
    VI ans(n, 0);
    ans[0] = c[0]; ever[0] = true;
    FOR(i, 1, n)FOR(j, 0, n - 1) {
        if (ever[edge[j].from] != ever[edge[j].to]) {
            ever[edge[j].from] = true;
            ever[edge[j].to] = true;
            chmax(ans[edge[j].from], c[i]);
            chmax(ans[edge[j].to], c[i]);
            break;
        }
    }
    cout << sum(ans) - c[0] << "\n";
    FOR(i, 0, n)cout << ans[i] << (i == n - 1 ? "\n" : " ");
}

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

typedef long long ll;
typedef double d;

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>=0; i--)

#define be(a) a.begin(),a.end()
#define sz(x) x.size()

#define sp " "
#define nl cout<<'\n';
#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    su;
    int n;
    cin>>n;
    ll a[n];
    lo(i,0,n)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    if(a[0]==0)
    {
        cout<<0;
        nl;
        return 0;
    }
    ll s=1;
    lo(i,0,n)
    {
        if(a[i]<=1000000000000000000/s)
            s*=a[i];
        else
        {
            cout<<-1;
            nl;
            return 0;
        }
    }
    cout<<s;
    nl;
    return 0;
}


Measured memory_bytes: 4400
#include <stdio.h>
#include <string.h>
 
int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    if(n==25) {
        printf("Christmas\n");
    }
    else if(n==24) {
        printf("Christmas Eve\n");
    }
    else if(n==23) {
        printf("Christmas Eve Eve\n");
    }
    else if(n==22) {
        printf("Christmas Eve Eve Eve\n");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){

  int N;  cin >> N;
  vector<long long> A(N);
  for(int i = 0 ; i < N ; i++)	cin >> A[i];

  long long a = 0;
  for(int i = 0 ; i < N ; i++){
    if(!(i % 2))
      a += A[i];
    else
      a -= A[i];
  }

  cout << a << " ";
  long long keep = a;
  for(int i = 1 ; i < N ; i++){
      keep = A[i - 1]  * 2 - keep; 
      cout << keep << " ";
  }
      
  return 0;
}


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

int main(){
  long long int n,i,kotae=0,bonus=0;
  string s;
  cin>>s;
  n=s.length();
  for(i=0;i<n;i++){
    if(bonus==0){
      if(s[i]-'0'<=4){
        kotae+=s[i]-'0';
      }else if(s[i]-'0'==5){
        if(i==n-1){
          kotae+=s[i]-'0';
        }else if(s[i+1]-'0'>=5){
          kotae+=11-s[i]+'0';
          bonus=1;
        }else{
          kotae+=s[i]-'0';
        }
      }else{
        kotae+=11-s[i]+'0';
        bonus=1;
      }
    }else{
      if(s[i]-'0'<=3){
        kotae+=s[i]-'0';
        bonus=0;
      }else if(s[i]-'0'==4){
        if(i==n-1){
          kotae+=s[i]-'0';
          bonus=0;
        }else if(s[i+1]-'0'>=5){
          kotae+=9-s[i]+'0';
        }else{
          kotae+=s[i]-'0';
          bonus=0;
        }
      }else{
        kotae+=9-s[i]+'0';
      }
    }
  }
  cout<<kotae;
}


Measured memory_bytes: 1540
<?php
  declare(strict_types=1);

  class M
  {
      public $a, $b, $c;
      public function __construct($a, $b, $c)
      {
          $this->a = $a;
          $this->b = $b;
          $this->c = $c;
      }

      public function add($x)
      {
          $a = $this->a + $x->a;
          $b = $this->b + $x->b;
          $c = $this->c + $x->c;
          return new M($a, $b, $c);
      }

      public function is_generative()
      {
          return $this->a === $this->b; // && $this->c > 0;
      }
  }

  fscanf(STDIN, "%i %i %i", $n, $ma, $mb);
  for ($i = 0; $i < $n; ++$i)
  {
      fscanf(STDIN, "%i %i %i", $a, $b, $c);
      $store[$i] = new M($a * $mb, $b * $ma, $c);
  }

  $minimize = function (&$value, $candidate)
  {
      if (!isset($value) || $value > $candidate)
      {
          $value = $candidate;
      }
  };

  $dp[0][0][0] = 0;
  for ($i = 0; $i < $n; ++$i)
  {
      $other_hand = $i & 1 ^ 1;
      unset($dp[$other_hand]);
      foreach ($dp[$i & 1] as $a => $inner)
      {
          foreach ($inner as $b => $c)
          {
              $minimize($dp[$other_hand][$a][$b], $c);

              $bought = (new M($a, $b, $c))->add($store[$i]);
              if (isset($answer) && $bought->c >= $answer)
              {
                  continue;
              }

              if ($bought->is_generative())
              {
                  $minimize($answer, $bought->c);
              }
              else
              {
                  $minimize($dp[$other_hand][$bought->a][$bought->b], $bought->c);
              }
          }
      }
  }

  echo ($answer ?? -1),PHP_EOL;


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

using namespace std;

const int maxn = 5*(int)1e5+100;
int n, a[maxn], b[maxn], t[maxn*50], lt[maxn*50], rt[maxn*50], tVal[maxn*50], tot;
int lst[maxn];    //记录离散化后数组的上次出现位置
int q;

void init() {
    tot = 0;
    memset(lst, -1, sizeof(lst));
}
int build(int l, int r) {
    int node = ++tot;
    tVal[node] = 0;
    int mid = (l + r) >> 1;
    if (l < r) {
        lt[node] = build(l, mid);
        rt[node] = build(mid+1, r);
    }
    return node;
}
int update(int l, int r, int par, int p, int val) {
    int node = ++tot;
    lt[node] = lt[par]; rt[node] = rt[par]; tVal[node] = tVal[par] + val;
    int mid = (l + r) >> 1;
    if (l < r) {
        if (p <= mid) lt[node] = update(l, mid, lt[par], p, val);
        else rt[node] = update(mid+1, r, rt[par], p, val);
    }
    return node;
}
int query(int l, int r, int p, int node) {
    if (l == r) return tVal[node];
    int mid = (l + r) >> 1;
    if (p <= mid) return (query(l, mid, p, lt[node]) + tVal[rt[node]]);
    else return query(mid+1, r, p, rt[node]);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    init();
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    int len = unique(b + 1, b + 1 + n) - b;
    for (int i = 1; i <= n; ++i)
        a[i] = lower_bound(b + 1, b + 1 + len, a[i]) - b;

    t[0] = build(1, n);
    for (int i = 1; i <= n; ++i) {
        if (lst[a[i]] == -1) t[i] = update(1, n, t[i-1], i, 1);
        else {
            int temp = update(1, n, t[i-1], lst[a[i]], -1);
            t[i] = update(1, n, temp, i, 1);
        }
        lst[a[i]] = i;
    }
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << query(1, n, l, t[r]) << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main() {
    uint64_t x;
    std::cin >> x;

    uint64_t ans = (x / 11) * 2;
    const uint64_t r = x % 11;
    if (1 <= r && r <= 6) {
        ans += 1;
    } else if (7 <= r && r <= 10) {
        ans += 2;
    }

    std::printf("%lu\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<functional>
#include<set>
using namespace std;

int main(){
    set<int> S;
    int N;
    int a;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a;
        if(S.find(a)!=S.end()){
            S.erase(a);
        }
        else{
            S.insert(a);
        }
    }
    cout<<S.size()<<endl;
}

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

int main(){
	int n;
	scanf("%d", &n);
	int a[n+1];
	int answer[n+1];
	for(int i=1; i<n+1; i++){
		scanf("%d", &a[i]);
		answer[a[i]] = i;
	}
	for(int i=1; i<=n; i++){
		printf("%d ", answer[i]);
	}
	
	
	return 0;
}

Measured memory_bytes: 1536