akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.*;
public class Main{
	
	
	
	public static void main(String[] args) {
		
		FastScanner fs = new FastScanner();
		String s= fs.next();
		char c=s.charAt(s.length()-1);
		if(c=='s')
			s+="es";
		else
			s+="s";
		System.out.println(s);
	}
	
	
	
	static class FastScanner 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	

}


Measured memory_bytes: 36652
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define pb push_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int H,W;cin>>H>>W;
    char A[H][W];
    REP(i,H){
        REP(j,W)cin>>A[i][j];
    }
    bool ok=true;
    REP(i,H){
        REP(j,W){
            if(A[i][j]=='#'&&(i-1<0||A[i-1][j]=='.')&&(j-1<0||A[i][j-1]=='.')&&(i+1>=H||A[i+1][j]=='.')&&(j+1>=W||A[i][j+1]=='.')){
                ok=false;
            }
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b,c,d = LI()

while 1:
    if c - b <= 0:
        print('Yes')
        quit()
    if a - d <= 0:
        print('No')
        quit()
    c -= b
    a -= d

Measured memory_bytes: 65316
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to) : from(-1), to(to), cost(-1) {}
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<vector<T>> warshall(matrix<T> &g){
  vector<vector<T>> dist(g.size());
  rep(i,g.size()){
    dist[i].resize(g.size());
    rep(j,g.size())dist[i][j] = (i == j ? 0 : g[i][j]);
  }
  rep(k,g.size()){
    rep(i,g.size()){
      rep(j,g.size()){
        if(dist[i][k] == INF || dist[k][j] == INF)continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  return dist;
}

#define warshall warshall<int>// matの初期化でINFを詰めておく



////////////////////////////////////////////////////////////////////

int h,w;matrix<int> g(10);
vector<vector<int>> dist;
signed main(){
  cin>>h>>w;
  rep(i,10){
    g[i].resize(10);
    rep(j,10){
      int c;cin>>c;
      g[i][j] = c;
    }
  }
  dist = warshall(g);
  int ans = 0;
  rep(i,h)rep(j,w){
    int a;cin>>a;
    if(a == -1)continue;
    ans += dist[a][1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int main()
{
	auto conv = [](char c)
	{
		switch (c)
		{
		case 'I':
			return 1;
		case 'V':
			return 5;
		case 'X':
			return 10;
		case 'L':
			return 50;
		case 'C':
			return 100;
		case 'D':
			return 500;
		case 'M':
			return 1000;
		default:
			return 0;
		}
	};
	for (std::string str; std::cin >> str;)
	{
		str.push_back(' ');
		int sum = 0;
		for (auto itr = str.begin(), end = str.end() - 1; itr != end; itr++)
		{
			sum += conv(*itr) * (conv(*itr) >= conv(*(itr + 1)) ? 1 : -1);
		}
		std::cout << sum << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3172
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <utility>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n,costs=0,costl=0;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=accumulate(a.begin(),a.end(),0);
    int aves=sum/n,avel=(sum+n-1)/n;
    for(int i=0;i<n;i++){
        costs+=(abs(a[i]-aves))*(abs(a[i]-aves));
    }
    for(int i=0;i<n;i++){
        costl+=(abs(a[i]-avel))*(abs(a[i]-avel));
    }
    cout<<min(costs,costl);
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
a, b = [0] * 1000005, [0] * 1000005
for i in range(len(v)):
    if i % 2: a[v[i]] += 1
    else: b[v[i]] += 1
a2, b2 = [], []
for i in range(1000001):
    a2.append([a[i], i])
for i in range(1000001):
    b2.append([b[i], i])
a2.sort()
a2.reverse()
b2.sort()
b2.reverse()

#a2 = [[2, 3], [1, 1], [0, 2], ...]
#b2 = [[2, 3], [1, 2], [0, 1], ...]
if a2[0][1] != b2[0][1]:
    print(n - a2[0][0] - b2[0][0])
else:
    print(n - max(a2[1][0] + b2[0][0], a2[0][0] + b2[1][0]))

#print(a2[:3])
#print(b2[:3])

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


int main(){
    ll n;cin>>n;
    char c[333][333];
    rep(i,0,n)rep(j,0,n)cin>>c[i][j];
    ll an=0,ok=1;
    rep(i,0,n){
        ok=1;
        rep(j,0,n){
            rep(k,0,n){
                if(j==k)continue;
                if(c[(j+i)%n][k]!=c[(i+k)%n][j])ok=0;
            }
        }
        if(ok)an+=n;
    }
    cout<<an<<endl;
}

    









Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    const ll MOD = 998244353;
    int N;
    cin >> N;
    vector<ll> a(N);
    ll S = 0;
    for(auto& x: a){
        cin >> x;
        S += x;
    }

    ll W = 90010;
    Vvec<ll> dp(N+1, vector<ll>(W));
    dp[0][0] = 1;
    for(int i=0; i<N; i++){
        for(int j=0; j<W; j++){
            dp[i+1][j] = dp[i][j]*2;
            if(j-a[i]>=0) dp[i+1][j] += dp[i][j-a[i]];
            dp[i+1][j] %= MOD;
        }
    }

    ll ans = 1;
    for(int i=0; i<N; i++){
        ans *= 3;
        ans %= MOD;
    }

    for(int j=(S-1)/2+1; j<=S; j++){
        ans -= 3*dp[N][j];
        ans = (ans >= 0) ? ans%MOD : (MOD - (-ans%MOD)) % MOD;
    }
    if(S%2==0){
        Vvec<ll> dp2(N+1, vector<ll>(W));
        dp2[0][0] = 1;
        for(int i=0; i<N; i++){
            for(int j=0; j<W; j++){
                dp2[i+1][j] = dp2[i][j];
                if(j-a[i]>=0) dp2[i+1][j] += dp2[i][j-a[i]];
                dp2[i+1][j] %= MOD;
            }
        }
        ans += dp2[N][S/2]*3;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 424512
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

ll cleanse(ll n) {
  for(ll i = 2; i*i*i<=n; i++) {
    ll x = i*i*i;
    while(n%x==0) n/=x;
  }
  return n;
}

map<ll, int> dp;

set<ll> used;

int countOther() {
  int ret = 0;
  for(auto x: dp) {
    if(used.count(x.first)) continue;
    // x == p * q*q
    ll pComp = 1;
    ll qComp = 1;
    ll amt = x.first;
    for(ll i = 2; i * i * i <= amt; i++) {
      if(amt%i) continue;
      if(amt%(i*i)==0) {
        qComp *= i;
        amt /= i*i;
      }
      else {
        pComp *= i;
        amt /= i;
      }
    }
    ll leftover = (ll)sqrt(amt);
    if(leftover * leftover != amt) {
      // printf("a %lld %d\n", x.first, x.second);
      // used.insert(x.first);
      // ret += x.second;
      continue;
    }
    if(pComp >= 100000) {
      // printf("b %lld %d\n", x.first, x.second);
      // used.insert(x.first);
      // ret += x.second;
      continue;
    }
    qComp *= leftover;
    ll real = pComp * pComp * qComp;
    if(dp.count(real)) {
      ret += max(dp[real], dp[x.first]);
      used.insert(real);
      used.insert(x.first);
    }
    else {
      used.insert(x.first);
      ret += x.second;
    }
  }
  return ret;
}

int main() {
  int n;
  scanf("%d", &n);
  while(n--) {
    ll t;
    scanf("%lld", &t);
    dp[cleanse(t)]++;
  }
  int ret = 0;
  if(dp.count(1)) {
    dp.erase(1);
    ret++;
  }
  ret += countOther();
  for(auto x: dp) {
    if(!used.count(x.first)) {
      ret += x.second;
    }
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; i++) {
    int num = i;
    double p = 1;
    while (num < k) {
      num *= 2;
      p /= 2;
    }
    ans += p/n;
  }
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
// #define mp make_pair
// #define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define show(x) cout << #x << " = " << x << endl;

int main(){
  int n, k;
  cin >> n >> k;
  ll ans = 0;

  for(int b = 1; b <= n; b++){
    ll tmp2 = (n/b)*max(0,b-k) + max(0,(n%b)-k+1);
    if(k >= b){
      continue;
    }
    ll tmp = n / b * (b-k);
    if(n / b * b + k <= n)tmp += n - (n / b * b + k) + 1;

    ans += tmp;
  }

  if(k==0){
    ans -= n;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<"\n";
	return 0;
}


Measured memory_bytes: 3604
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  n %= 10;
  if(n==3){
    cout <<"bon"<<endl;
  }else if(n==0||n==1||n==6||n==8){
    cout <<"pon"<<endl;
  }else{
    cout <<"hon"<<endl;
  }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const int inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int rangesum(int lo, int hi, vi& pre) {
	if(lo==0)
		return pre[hi]%MOD;
	return (pre[hi]-pre[lo-1]+MOD)%MOD;
}
int32_t main(void)
{
	IOS;
	int n; cin>>n;
	vi a(n);
	for(int i = 0; i < n; i++)
		cin>>a[i];
	int dp[n+1][n]={};
	for(int i = 2; i <= n; i++) {
		for(int j = 0; j <= n-i; j++) {
			int lo=j, hi=j+i-1;
			int mx=inf, sum=0;
			for(int k = lo; k <= hi; k++)
				sum += a[k];
			for(int k = lo; k < hi; k++)
				mx=min(mx, dp[k-lo+1][lo]+dp[hi-k][k+1]+sum);
			dp[i][j]=mx;
		}
	}
	cout<<dp[n][0]<<endl;
	time();
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
int main(){
    fast_io

    int h, w;
    cin>>h>>w;
    char s[h][w];
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
        }
    }
    int dx[4]={0, 1, 0, -1};
    int dy[4]={1, 0, -1, 0};

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            
            if(s[i][j]=='#'){
                bool flag=false;
                for(int k=0;k<4;k++){
                    int nw=j+dx[k];
                    int nh=i+dy[k];
                    if(s[nh][nw]=='#'){
                        flag=true;
                    }
                }
                if(flag==false){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

N, K = l_inpl()

max_K = (N-1)*(N-2)//2
if K>max_K:
    print("-1")
else:
    ans = [[1, x] for x in range(2, N+1)]
    cnt = max_K - K
    c = list(combinations(list(range(2, N+1)), 2))
    for i in range(cnt):
        ans.append(list(c[i]))
    print(len(ans))
    for a in ans:
        print("{} {}".format(a[0], a[1]))


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

typedef long long ll;


ll lu[100];

ll lucas(ll l)
{
  ll l1, l2;
  if(l==0) return 2LL;
  if(l==1) return 1LL;
  if(lu[l-1]<0){lu[l-1]=lucas(l-1);}
  if(lu[l-2]<0){lu[l-2]=lucas(l-2);}
  return lu[l-1]+lu[l-2];
}

int main()
{
  for(int i = 0;i < 100; i++) {
    lu[i] = -1;
  }
  ll n;
  cin >> n;
  
  cout << lucas(n) << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main() {
  double a, b, c, d, e, f, x, y;
  while (scanf("%lg %lg %lg %lg %lg %lg", &a, &b, &c, &d, &e, &f) != EOF) {
    x = (c * e - b * f) / (a * e - b * d); y = (c * d - a * f) / (b * d - a * e);
    printf("%.3f %.3f\n", 0.0005 <= x || x <= -0.0005 ? x : 0, 0.0005 <= y || y <= -0.0005 ? y : 0);
  }
  return 0;
}

Measured memory_bytes: 652
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;

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

void solve(){
  int s = rint;
  if(s < 1200) "ABC".writeln;
  else if(s < 2800) "ARC".writeln;
  else  "AGC".writeln;
}


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

int main () {
  int x, y, z; // 椅子の幅, 1人が使う幅, 人との隙間
  cin >> x >> y >> z;
  x -= z; // 左端を開ける
  int ans = 0;
  while (1) {
    x -= y + z;
    if (x < 0) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n;
string pre[11], aft[11];
string s, g;

string change(string str, int id){
    string res = str;
    size_t pos = res.find(pre[id]);    
    while(pos != string::npos){
        res.replace(pos, pre[id].size(), aft[id]);
        pos = res.find(pre[id], pos + aft[id].size());
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> n, n){
        rep(i, 0, n){
            cin >> pre[i] >> aft[i];
        }
        cin >> s >> g;
        queue<string> q;
        map<string, int> mp;
        q.push(s);
        mp[s] = 1;
        while(!q.empty()){
            string now = q.front(); q.pop();
            rep(i, 0, n){
                string tmp = change(now, i);
                if(tmp.size() > g.size()) continue;
                if(mp.count(tmp)) continue;
                // cout << i << ' ' << now << ' ' << tmp << endl;                
                mp[tmp] = mp[now] + 1;
                q.push(tmp);
            }
        }
        cout << mp[g] - 1 << endl;
    }
}


Measured memory_bytes: 3464
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

long long int MOD = 1000000007;
int N;
int dpa1[35],dpb1[35];

int main(){
	cin>>N;
	vector<ll> hoga,hogb,A(N),B(N);
	ll a;
	for(int i=0;i<N;i++){
		cin>>a;
		hoga.pb(a);
	}
	for(int i=0;i<N;i++){
		cin>>a;
		hogb.pb(a);
	}
	ll fuga=2;
	ll ans=0;
	for(int i=0;i<32;i++){
		for(int j=0;j<N;j++){
			A[j]=hoga[j]%fuga;
			B[j]=hogb[j]%fuga;
		}
		sort(B.begin(),B.end());
		int cnt=0;
		for(int j=0;j<N;j++){
			cnt+=lower_bound(B.begin(),B.end(),fuga-A[j])-
					lower_bound(B.begin(),B.end(),fuga/2-A[j]);
			cnt+=lower_bound(B.begin(),B.end(),2*fuga-A[j])-
					lower_bound(B.begin(),B.end(),3*(fuga/2)-A[j]);
		}
		if(cnt%2)ans+=fuga/2;
		fuga=fuga*2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8048
// Vivek Rai
// Blazer_007

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

#define fastio    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl      '\n'

typedef long long int ll;
const int hell = 1e9 + 7 ;

istream &operator>>(istream &in, vector<int> &arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
    	cin >> arr[i];
    return in;
}

ostream &operator<<(ostream &os, vector<int> arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cout << arr[i] << " ";
    cout << endl;
    return os;
}

signed main() {

    fastio

    int temp;
    cin >> temp;
    if (temp >= 30)
    	cout << "Yes" << endl;
    else
    	cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int A, B;
  cin >> A >> B;
  for (int64_t i = 1; i <= 100000; i++) {
    int64_t j = A * i;
    if (j % B == 0) {
      cout << j << endl;
      break;
    }
  }   
}

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

typedef long long LL;

// Find the biggest m that m(m+1)/2 <= n. (1+2+...+(m-1)+m <= n)
LL calc(LL n)
{
	n <<= 1LL;
	LL x = __builtin_sqrt(n);
	if(x * (x + 1LL) > n) return x - 1LL;
	if((x + 1LL) * (x + 2LL) <= n) return x + 1LL;
	return x;
}

int main(int argc, char** argv)
{
	LL n, ans = 0LL;
	scanf("%lld", &n);
	int t = __builtin_sqrt(n);
	for(LL i=2LL; i<=t; i++)
	{
		LL cnt = 0LL;
		while(n % i == 0LL)
			n /= i, cnt ++;
		if(cnt > 0LL)
			ans += calc(cnt);
	}
	printf("%lld\n", (n > 1LL)? (ans + 1LL): ans);
	return 0;
}

Measured memory_bytes: 2072
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
typedef pair<int,int> II;
typedef pair<double,int> DI;
int main(void){
    string s;
    string t[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    cin>>s;
    for(int i=0;i<7;i++){
        if(s==t[i])cout<<7-i;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
	
	int count = 0;//???????????°
	int n;//??°????????°
	int i,j;//????????????
	int a[100]={0};
	int min;
	int temp;
	
	scanf("%d\n",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	
	for(i=0;i<n-1;i++){
		min = i;
		for(j=i;j<n;j++){
			if(a[min]>a[j]) min = j;
			else{}
			

		}
			if (i != min){
				temp = a[i];
				a[i] = a[min];
				a[min] = temp;
				
				count++;
			}
			else{}
	}
	
	for(i=0;i<n;i++){
		printf("%d",a[i]);
		if (i != n-1) printf(" ");
		else{}
	}
	
	printf("\n%d\n",count);
	
	return 0;
}

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

typedef struct{
	string name;
	long s; //start
	long e; //end
}era;
	
int main(){
	while(1){
		int n, q;
		era a[1000];
		
		scanf(" %d %d", &n, &q);
		if(n==0 && q==0) break;
		
		for(int i=0; i<n; ++i){
			long le;
			cin >> a[i].name;
			scanf(" %ld %ld", &le, &a[i].e);
			a[i].s=a[i].e-le+1;	
		}
		
		for(int i=0; i<q; ++i){
			long query;
			scanf(" %ld", &query);
			
			bool found=false;
			for(int j=0; j<n; ++j){
				if(a[j].s<=query && query<=a[j].e){
					cout << a[j].name << " " << query-a[j].s+1 << endl;
					found=true;
					break;	
				}
			}
			
			if( !found ) printf("Unknown\n");
		}
		
	}
}
	

Measured memory_bytes: 1312
# n = int(input())
# H = list(map(int,input().split()))


A1 = list(input().split())
A2 = list(input().split())
A3 = list(input().split())
n = int(input())

if n <= 2:
    print("No")
    exit()

B = []
for _ in range(n):
    B.append(input())

for i in B:
    if i in A1:
        A1[A1.index(i)] = "#"
    if i in A2:
        A2[A2.index(i)] = "#"
    if i in A3:
        A3[A3.index(i)] = "#"


flag = 0
for i in range(3):
    if A1[i] == "#":
        flag += 1
    if A2[i] == "#":
        flag += 1
    if A3[i] == "#":
        flag += 1
    if flag != 3:
        flag = 0
    if flag == 3:
        print("Yes")
        exit()

if A1[0] == "#" and A1[1] == "#" and A1[2] == "#":
    print("Yes")
    exit()

if A2[0] == "#" and A2[1] == "#" and A2[2] == "#":
    print("Yes")
    exit()

if A3[0] == "#" and A3[1] == "#" and A3[2] == "#":
    print("Yes")
    exit()

if A1[0] == "#" and A2[1] == "#" and A3[2] == "#":
    print("Yes")
    exit()

if A3[0] == "#" and A2[1] == "#" and A1[2] == "#":
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < n; ++i)
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
constexpr int MAX = 444;


ll n, k, a[MAX], b[MAX];
ll c[MAX][MAX];


ll rec(int l, int r) {
	if (c[l][r] != INF) return c[l][r];
	if (l == r) return 0;

	ll res = INF;
	for (int i = l; i < r; ++i) {
		res = min(res, b[r + 1] - b[l] + rec(l, i) + rec(i + 1, r));
	}
	return c[l][r] = res;
}

int main() {
	cin >> n;
	REP(i, n) cin >> a[i];
	REP(i, n) b[i + 1] = a[i] + b[i]; // [l, r)
	REP(i, MAX) REP(j, MAX) c[i][j] = INF;
	cout << rec(0, n - 1);
}

Measured memory_bytes: 1792
N = int(input())

# N:奇数ならば0
# N:偶数の場合 10が何個登場するか (素因数分解したときに2,5のペアが何個登場するか)
# 偶数の場合のみ考えているので 5 << 2と考えて5が何回登場するかを考える。
# 2で割ると(N//2)!になる
# 5 >> 2を仮定するとN//2までの5の倍数となっている数が答え。。。では無い
# 5の2乗,3乗の倍数をカウントできていないのでそれらを足す？
if N % 2 != 0:
    print(0)
    exit()

cnt = 0
current = 5
while (N // 2 >= current):
    cnt += (N // 2 // current)
    current *= 5

print(cnt)

Measured memory_bytes: 9168
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int n;
int a,b,c;
int ins[1010][3];
bool pa[1010];

int st[1010];

int main(){
while(1){
    scanf("%d%d%d",&a,&b,&c);
if(a == 0)
    break;
scanf("%d",&n);
    REP(i,n){
        REP(j,3){
            scanf("%d",&ins[i][j]);
            ins[i][j]--;
        }
        scanf("%d",pa + i);
    }
    int d = a + b + c;
    REP(i,d)
        st[i] = 2;
    REP(i,n){
        if(pa[i]){
            REP(j,3)
                st[ins[i][j]] = 1;
        }
    }
    //while(true){
        //bool update = false;
        REP(i,n){
            if(pa[i])
                continue;

            int e = 0;
            REP(j,3)
                e += (st[ins[i][j]] < 2);
            if(e != 2)
                continue;

            e = 0;
            int f[2],g;
            REP(j,3){
                if(st[ins[i][j]] < 2)
                    f[e++] = st[ins[i][j]];
                else
                    g = j;
            }
            if(f[0] == 1 && f[1] == 1){
                st[ins[i][g]] = 0;
                //update = true;
            }
        }
        //if(!update)
            //break;
    //}
    REP(i,d)
        printf("%d\n",st[i] );
}

    return 0;
}

Measured memory_bytes: 3244
from collections import deque


# 幅優先と深さ優先でトポロジカルソート


def topologicalSortBfs(n):
    for i in range(n):
        color[i] = WHITE

    for i in range(0, n):
        if indeg[i] == 0 and color[i] == WHITE:
            bfs(i)


def bfs(s):
    Q.appendleft(s)
    color[s] = GRAY
    while Q:
        u = Q.popleft()

        out.append(u)

        for v in G[u]:
            indeg[v] -= 1
            if indeg[v] == 0 and color[v] == WHITE:
                color[v] = GRAY
                Q.append(v)


def topologicalSortDfs(n):
    for i in range(n):
        color[i] = WHITE

    for s in range(0, n):
        if color[s] == WHITE:
            dfs(s)


def dfs(u):
    color[u] = GRAY
    for v in G[u]:
        if color[v] == WHITE:
            dfs(v)
    out.appendleft(u)


n, e = map(int, input().split())
G = {}
for i in range(n):
    G[i] = []
indeg = [0] * n
for i in range(e):
    s, t = map(int, input().split())
    indeg[t] += 1
    G[s].append(t)
color = [None] * n
out = deque([])
WHITE = 0
GRAY = 1
Q = deque([])

topologicalSortDfs(n)
print(*out)
# 031452
# dfsがおかしい



Measured memory_bytes: 9884
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	long long n,k,ans=1;
	cin >> n >> k;

	while (n >= k)
	{
		n /= k;
		ans++;
	}
	
	cout << ans << endl;

	
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def n():
    return int(input())

N = n()
ans = ''
if N == 0:
    print(0)
    exit()

while N != 0:
    if abs(N%2) == 1:
        ans = '1' + ans
        N -= 1
    else:
        ans = '0' + ans
    N = N//(-2)

print(ans)


Measured memory_bytes: 5676
N, M = map(int,input().split())

for i in range(M):
  if i % 2 == 0:
    i = i // 2
    print("{0} {1}".format(i+1, N-i))
  else:
    i = i // 2
    mi = (N + 1) // 2
    print("{0} {1}".format(mi - 1 - i, mi + 1 + i))

Measured memory_bytes: 9212
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    vector<vector<int64>> rgb(3);
    for (int i=0; i<n; i++) {
        switch(s[i]) {
            case 'R':
                rgb[0].push_back(i);
                break;
            case 'G':
                rgb[1].push_back(i);
                break;
            case 'B':
                rgb[2].push_back(i);
                break;
        }
    }
//    debug(rgb);

    int64 ans = 0;

    vector p = {0,1,2};
    do {
//        debug(p);
        const auto& r = rgb[p[0]];
        const auto& g = rgb[p[1]];
        const auto& b = rgb[p[2]];

/*
        for (int i=0; i<r.size(); i++) {
            for (int j=0; j<g.size(); j++) {
                for (int k=0; k<b.size(); k++) {
                    if (!(r[i] <= g[j] && g[j]<=b[k])) continue;
                    if (b[k]-g[j] != g[j]-r[i]) ans++;
                }
            }
        }
*/
//        for (int i=0; i<r.size(); i++) {
//            int ri = r[i];
//            auto it1 = lower_bound(g.begin(), g.end(), ri);
//            if (it1 == g.end()) continue;
//            for (auto it = it1; it<g.end(); it++) {
//                auto it2 = lower_bound(b.begin(), b.end(), *it1);
//                if (it2 == g.end()) continue;
//                ans += b.end() - it2;
////                cout << ri << " "<<  *it << " " << *it2 << endl;
//                auto it3 = lower_bound(b.begin(), b.end(), *it + (*it-ri));
//                if (it3 != b.end() && *it3 == *it +(*it-ri)) ans--;
//            }
//        }

        for (int64 gi : g) {
            auto it1 = lower_bound(r.begin(), r.end(), gi);
            if (it1 == r.begin()) continue;
            auto it2 = lower_bound(b.begin(), b.end(), gi);
            if (it2 == b.end()) continue;
            ans += (it1 - r.begin()) * (b.end() - it2);
//            if (*it2 - *it1 == *it1 - gi) ans--;

            for (auto it=it2; it!=b.end(); it++) {
                auto it3 = lower_bound(r.begin(), r.end(), gi-(*it-gi));
                if (it3 != r.end() && *it-gi == gi-*it3) ans--;
            }
        }
//        debug(ans);

    } while (next_permutation(p.begin(), p.end()));

    cout << ans << endl;
}

Measured memory_bytes: 3196
#include <stdio.h>

int main() 
{
    int a, b, x;
    scanf("%d %d", &a, &b);

    if (a > b) {
        do {
            x = b;
            b = a % b;
            a = x;
        } while (b != 0);
        printf("%d\n", a);
    } else {
        do {
            x = a;
            a = b % a;
            b = x;
        } while (a != 0);
        printf("%d\n", b);
    }
    

    return 0;
}

Measured memory_bytes: 592
#include <queue>
#include <string>
#include <iostream>
using namespace std;
int main() {
  string cmd; // while の外側で定義して一つの変数を再利用する
  priority_queue<int> Q;
  int m;
  while (cin >> cmd && cmd != "end") {
    if (cmd == "insert") {
      cin >> m;
      Q.push(m);
      // 何かする
    } else if (cmd == "extract") {
      
      cout << Q.top() << endl;
      Q.pop();
      // 何かする
    }
  }
}


Measured memory_bytes: 6964
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

n,m = map(int,input().split())
Permutation = list(map(int,input().split()))
Replace = [list(map(int,input().split())) for i in range(m)]

uf = UnionFind(n+1)
count = 0

for i in range(m):
    uf.union(Replace[i][0],Replace[i][1])

for i in range(1,n+1):
    if uf.same(Permutation[i-1],i):
        count += 1

print(count)

Measured memory_bytes: 32356
N,K = map(int, input().split())
P = [int(p) for p in input().split()]
C = [int(c) for c in input().split()]

ans = max(C)
for i in range(N):
    used = [0]*N
    used[i] = 1
    loop = [C[i]]
    j = P[i]-1
    while used[j] == 0:
        used[j] = 1
        loop.append(loop[-1]+C[j])
        j = P[j]-1
    M = len(loop)
    if K >= M:
        if K%M == 0:
            t = 0
        else:
            t = max(loop[:K%M])
            t = max(t, 0)
        num = max(loop[-1]*(K//M)+t, max(loop), loop[-1]*(K//M-1)+max(loop))
    else:
        num = max(loop[:K])
    ans = max(ans, num)
if max(C) <= 0:
    ans = max(C)
print(ans)

Measured memory_bytes: 91800
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main() {
  int N,i{1},a{},b{};
  cin >> N;
  vector<int> P(N), Q(N), I(N);
  for (auto &p: P) {
    cin >> p;
  }
  for (auto &q: Q) {
    cin >> q;
  }

  iota(begin(I),end(I),1);
  do {
    if(!a && equal(begin(I),end(I),begin(P))) a = i;
    if(!b && equal(begin(I),end(I),begin(Q))) b = i;
    if (a && b) break;
    ++i;
  }
  while(next_permutation(begin(I),end(I)));

  cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll h;cin >> h;
  vector<ll> t(50);
  t[0]=1;
  for(int i=1;i<50;i++){
    t[i]=t[i-1]*2;
  }
  ll ans=0,cnt=0;
  while(h!=0){
    h/=2;
    ans+=t[cnt];
    cnt++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  set<int> water, suger;
  for(int i=0; 100*a*i<=3000; i++){
    for(int j=0; 100*a*i+100*b*j<=3000; j++){
      water.insert(100*a*i+100*b*j);
    }
  }
  water.erase(0);
  for(int i=0; c*i<=e*30; i++){
    for(int j=0; c*i+d*j<=e*30; j++){
      suger.insert(c*i+d*j);
    }
  }

  int max_water = 0;
  int max_suger = 0;
  double r = -1.0;
  for(int w : water){
    for(int s : suger){
      if(w+s <= f && s <= (w/100)*e){
        if(chmax(r, (double)s/(w+s))){
          max_water = w;
          max_suger = s;
        }
      }
    }
  }

  cout << max_water + max_suger << " " << max_suger << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include <list>
#include <cstdlib>
using namespace std;

int main(){
    int N;
    cin >> N;
    string op;
    int key;
    list<int>L;
    for(int i=0;i<N;i++){
        cin >> op;
        if(op.at(0)=='i'){
            cin >> key;
            L.push_front(key);
        }
        else if(op.size()>=7 && op.at(6)=='F'){
            L.pop_front();
        }
        else if(op.size()>=7 && op.at(6)=='L'){
            L.pop_back();
        }
        else{
            cin >> key;
            for(list<int>::iterator itr=L.begin();itr!=L.end();itr++){
                if(*itr==key){
                    L.erase(itr);
                    break;
                }
            }
        }
    }
    N=0;
    for(list<int>::iterator itr=L.begin();itr!=L.end();itr++){
        if(N++){
            cout << " ";
        }
        cout << *itr;
    }
    cout << endl;
}


Measured memory_bytes: 34284
/*
▄▄▄▄▄▄   ▄▄▄▄                      ▄▄▄▄▄                               
██▀▀▀▀██ ▀▀██                      ██▀▀▀██                             
██    ██   ██    ██    ██  ▄████▄  ██    ██  ▄████▄  ██▄████▄  ▄████▄  
███████    ██    ██    ██ ██▄▄▄▄██ ██    ██ ██▀  ▀██ ██▀   ██ ██▄▄▄▄██ 
██    ██   ██    ██    ██ ██▀▀▀▀▀▀ ██    ██ ██    ██ ██    ██ ██▀▀▀▀▀▀ 
██▄▄▄▄██   ██▄▄▄ ██▄▄▄███ ▀██▄▄▄▄█ ██▄▄▄██  ▀██▄▄██▀ ██    ██ ▀██▄▄▄▄█ 
▀▀▀▀▀▀▀     ▀▀▀▀  ▀▀▀▀ ▀▀   ▀▀▀▀▀  ▀▀▀▀▀      ▀▀▀▀   ▀▀    ▀▀   ▀▀▀▀▀  
*/
# include <cstdio>
# include <iostream>
# include <cmath>

using namespace std ; 

typedef long long lint ; 
typedef long double ntrl ; 

# define MAXN 100010
# define MAXM 100010
# define INF 0x3f3f3f3f

///global variable///
ntrl h , w , n ; 
/////*/

///basic function///
// inline lint min ( lint x , lint y ) { return x < y ? x : y ; }
// inline lint max ( lint x , lint y ) { return x > y ? x : y ; }
inline void swap ( lint &x , lint &y ) { x ^= y , y ^= x , x ^= y ; }
inline bool isltr ( char x ) { return ( 'A' <= x && x <= 'Z' ) || ( 'a' <= x && x <= 'z' ) ; }
inline bool isnum ( char x ) { return ( '0' <= x && x <= '9') ; }
/////*/

///fast read///
inline lint readlint ( )
{
	lint val = 0 , sign = 1 ; char tmp = getchar ( ) ; 
	while ( ! isnum ( tmp ) ) { if ( tmp == '-' ) { sign = - sign ; } tmp = getchar ( ) ;  } 
	while ( isnum ( tmp ) ) { val = ( val << 1 ) + ( val << 3 ) + tmp - 48 ; tmp = getchar ( ) ; } 
	return val * sign ; 
}
inline char readlter ( ) 
{
	char tmp = getchar ( ) ; 
	while ( ! isltr ( tmp ) )
		tmp = getchar ( ) ; 
	return tmp ; 
}
/////*/

int main ( )
{
	h = readlint ( ) ; 
	w = readlint ( ) ; 
	n = readlint ( ) ; 

	printf ( "%.0Lf" , ceil ( n / max ( h , w ) ) ) ; 
	
	printf ( "\n" ) ; 
	return 0 ; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N,i,j;
	int ans;
	scanf("%d\n",&N);
	int d[N];
	for(i=0;i<N;i++){
		scanf("%d",&d[i]);
	}
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j++){
			ans=ans+(d[i]*d[j]);
		}
	}
	printf("%d",ans);
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> imos(n + 1);
    for (int i = 0; i < m; i++) {
        int l, r; cin >> l >> r; l--;
        imos[l]++; imos[r]--;
    }
    for (int i = 0; i < n; i++) imos[i + 1] += imos[i];
    int cnt = 0;
    for (int i = 0; i < n; i++) if (imos[i] == m) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int h, w;
int d[55][55];
char s[55][55];

void BFS(){
    rep(i, 55)rep(j, 55)d[i][j] = INF;
    d[0][0] = 0;
    queue<int> q;
    q.push(0);q.push(0);
    while(q.size()){
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();
        for(int i = 0;i < 4; i++){
            int xx = x + dx[i];
            int yy = y + dy[i];
            if(0 <= xx && xx <= w && 0 <= yy && yy <= h && s[yy][xx] == '.'){
                s[yy][xx] = '#';
                d[yy][xx] = min(d[yy][xx], d[y][x] + 1);
                q.push(xx);q.push(yy);
            }
        }
    }
}

int main(){
    int cnt = 0;
    cin >> h >> w;
    rep(i, h)rep(j, w){
        cin >> s[i][j];
        if(s[i][j] == '.')cnt++;
    }
    h--; w--;
    BFS();
    if(d[h][w] == INF)cout << -1 << endl;
    else cout << max(0, cnt - d[h][w] - 1)<< endl; 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1){r=(r*a)%m;}
        b=b>>1;
        a=(a*a)%m;
    }
    return r%m;
}
int main(){
    string s; cin>>s;
    ll cnt = 0;
    ll n  = s.size()/2,i=0, l = s.size();
    while(n>0)
    {
        if(s[i]!=s[l-1-i])cnt++;
        i++;
        n--;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256