akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

struct union_find {
    vector<ll> par;
    vector<ll> size;

    union_find(ll n) {
        par.resize(n);
        size.assign(n, 1);
        for(size_t i = 0; i < n; ++i) par[i] = i;
    }

    ll root(ll x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y){
        x = root(x), y = root(y);
        if(x != y){
            if(size[x] > size[y]) swap(x, y);
            par[y] = x;
            size[x] += size[y];
        }
    }

    ll getSize(ll x) {
        return size[root(x)];
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }
};

int main(void) {
    ll n, m;
    cin >> n >> m;
    union_find uf(n);
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        --a, --b;
        uf.unite(a, b);
    }

    set<ll> st;
    rep(i, n) st.insert(uf.root(i));
    co(st.size() - 1);

    return 0;
}

Measured memory_bytes: 8380
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int,vector<int>,less<int>> a;
    rep(i,n){
        int b;
        cin >> b;
        a.push(b);
    }
    rep(i,m){
        int b = a.top();
        b/=2;
        a.pop();
        a.push(b);
    }
    ll ans = 0;
    while(!a.empty()){
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define Max 3010
typedef pair<ll ,ll > p;
int main(){
    int a,b,c,x,y;
    while(~scanf("%d%d%d%d%d",&a,&b,&c,&x,&y))
    {
        	    if(x==y)
        	    {
        	    	int t=min(x*a+b*y,2*c*x);
        	    
        	    	printf("%d\n",t);
				}
				if(x>y)
				{
					int t=2*y*c+a*(x-y);
					int t0=min(2*x*c,a*x+b*y);
					printf("%d\n",min(t,t0));
				}
				if(x<y)
				{
					int t=2*x*c+b*(y-x);
					int t0=min(2*y*c,a*x+b*y);
					printf("%d\n",min(t,t0));
				}
				
	} 
	return 0; 	  
}
 	




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

#define loop(i) for(int i=1;i<=30;i++)
int st[31];

int main(){
  int temp;
  loop(i)st[i]=0;
  loop(i){
    cin>>temp;
    st[temp]=1;
  }
  loop(i){
    if(!st[i])cout<<i<<endl;
  }
  return 0;
}

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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<pair<ll,ll>> range(N);
  for (ll i = 0; i < N; i++) {
    ll x, l; cin >> x >> l;
    range.at(i) = make_pair(x - l, x + l);
  }
  sort(range.begin(), range.end(),
       [&](auto p, auto q) -> bool { return p.second < q.second; });
  ll cur = LLONG_MIN;
  ll count = 0;
  for (ll i = 0; i < N; i++) {
    if (cur <= range.at(i).first) {
      count++;
      cur = range.at(i).second;
    }
  }
  cout << count << endl;

  return 0;
}



Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;
typedef pair<int, int> P;

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

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

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    int num = 0;
    for (int i = 0; i < N; ++i)
    {
        int hi;
        cin >> hi;
        if (hi >= K) ++num;
    }
    cout << num << endl;
}


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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            Console.WriteLine(s.Replace("?","D"));

            Console.Out.Flush();
        }

        // 文字の出現回数をカウント
        public static long CountChar(string s, string c)
        {
            return (s.Length - s.Replace(c, "").Length) / c.Length;
        }

    }
}


Measured memory_bytes: 29124
n = int(input())
A = list(map(int,input().split()))
n4 = 0
n2 = 0
for a in A:
    if a%4 == 0:
        n4 += 1
    elif a%2 == 0:
        n2 += 1
if n2 == 1:
    n2 = 0
l = n4*2 + n2
if l>=n or n4*2+1 == n:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

bool cmp(const pair<ll, ll>& p, const pair<ll, ll>& q) {
    if (p.first != q.first)
        return p.first < q.first;
    else
        return p.second > q.second;
}
int main() {
    int N, T;
    cin >> N >> T;

    vector<pair<ll,ll>> food(N);
    for (int i = 0; i < N; i++)
        cin >> food[i].first>>food[i].second;
    sort(food.begin(), food.end(),cmp);

    vector<vector<ll>> dp(N + 1, vector<ll>(T + 1,-1));   
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= T; j++) {
            if (dp[i][j] == -1) continue;
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j != T) {
                if (j + food[i].first < T)
                    dp[i + 1][j + food[i].first] = max(dp[i + 1][j + food[i].first], dp[i][j] + food[i].second);
                else
                    dp[i + 1][T] = max(dp[i + 1][T], dp[i][j] + food[i].second);
            }
        }
    }

   // cout << "sorted" << endl;
    /*
    for (int i = 0; i < N; i++) {
        cout << food[i].first << " " << food[i].second << endl;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= T; j++) {
            if (dp[i][j] == -1) continue;
            printf("dp[%d][%d]=%lld ", i, j, dp[i][j]);
        }
        cout << endl;
    }
    */
    ll ans = 0;
    for (int i = 0; i <= T; i++)
        ans = max(ans, dp[N][i]);

    cout << ans << endl;

}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

ll h[MX], dp[MX];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N; cin >> N;

    F0R(i,N) cin >> h[i];

    memset(dp,63,sizeof dp);

    dp[0] = 0;
    FOR(x,1,N) {
        dp[x] = min(dp[x],min((x-1 >= 0) ? dp[x-1]+abs(h[x]-h[x-1]) : INF, (x-2 >= 0) ? dp[x-2]+abs(h[x]-h[x-2]) : INF));
    }

    cout << dp[N-1] << "\n";
}


Measured memory_bytes: 2560
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class MainClass
{
	public static void Main()
	{
		int N = int.Parse(Console.ReadLine());
		int[] d = new int[110];

		for(var i =0; i<N; i++)
		{
			d[i] = int.Parse(Console.ReadLine());
		}

		int[] num = new int[110];
		for(var i = 0; i< N;i++)
		{
			num[d[i]]++;
		}

		int cnt = 0;
		for (var i =1; i<=100; i++)
		{
			if(num[i]>0)
			{
				cnt++;
			}
		}
		Console.WriteLine(cnt);
	}
}





Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
// const int inf = 1e9;
const int inf = 1e12;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

int f(int b, int n) {
    if (n < b) return n;
    return f(b, n / b) + n % b;
}

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

    int n, s;
    cin >> n >> s;

    if (n == s) {
        cout << n + 1 << endl;
        return 0;   // <----!!!!!!!!!!!!!
    }

    // b <= sqrt(n) は全探索
    for (int b = 2; b * b <= n; b++) {
        if (f(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }

    // b > sqrt(n)のとき
    // nはb進数で高々2桁なので、 <---!!!!!!!!!
    // n = pb+q
    // s = p+q
    // -> n-s = p(b-1)
    // ∴ bはn-sの約数+1
    int ans = inf;
    for (int d = 1; d * d <= n - s; d++) {
        if ((n - s) % d == 0) {
            int b = d + 1;
            if (f(b, n) == s) {
                ans = min(ans, b);
            }
            b = (n - s) / d + 1;
            if (f(b, n) == s) {
                ans = min(ans, b);
            }
        }
    }

    cout << (ans == inf ? -1 : ans) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[2000001],b[2000001];


void CountingSort(int n){
  int c[10001]={};
  for(int i=0;i<n;i++) c[a[i]]++;
  for(int i=1;i<=10000;i++) c[i]+=c[i-1];
  for(int i=n-1;i>=0;i--) {
    b[c[a[i]]-1]=a[i];
    c[a[i]]--;
  }
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  CountingSort(n);
  for(int i=0;i<n-1;i++) cout << b[i]<<" ";
  cout <<b[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 16828
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	int poyo[101] = { 0 };
	int input;
	int max = 0;
	int i;
	while (scanf("%d",&input)!=EOF){
		poyo[input]++;
		if (max < poyo[input]) max = poyo[input];
	}

	for (i = 1; i < 101; i++){
		if (max == poyo[i]){
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


template<typename A>
bool cmp(const A& data, const A& key) {
	// data < keyを判定する
	return data < key;
}

template<typename A>
size_t customSearch(const vector<A>& data, const size_t& N, const A& key) {
	int lo = 0;
	int hi = N; // data array size
	while (lo < hi) {							// lo=hiの１点に収束するまで続ける
		int mid = (lo + hi) / 2;				// loとhiの中間地点の値を確認
		if (cmp(data[mid], key)) lo = mid + 1;	// LISの値より入力が大きかったら、loを持ち上げる
		else               hi = mid;			// LISの値が入力より小さかったら、hiを下げる
	}
	return lo; // lo：input <= key となる最初のindex
}




map<long long, long long> fract;

int main() {

	long long X;
	cin >> X;

	long long max_range = sqrt(sqrt(X));
	long long A = 0;
	long long B = 0;

	for (long long i = 0; i < max_range; i++) {
		fract.insert(make_pair(pow(i, 5),i));
	}


	while (true) {

		A++;

		long long A5 = pow(A,5);

		long long key = A5 - X;

		//要素の検索
		map<long long, long long>::iterator ite;
		ite = fract.find(abs(key));
		if (ite != fract.end()) {
			//値の取得
			B = ite->second;
			if (key < 0) B = -1 * B;
			break;
		}
	}


	cout << A << " " << B << endl;

	return 0;

}


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

int main(){
	for(int i = 1; i < 10; i++ ){
		for(int j = 1; j < 10; j++ ){
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
	
	return 0; 
}

Measured memory_bytes: 1116
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int X;
  cin >> X;
  if (X >= 30) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<>();
		for(int i = 0 ; i < n ; i++) {
			if(map.containsKey(a[i]) && map.get(a[i]) == 1) {
				map.put(a[i], 0);
			} else {
				map.put(a[i], 1);
			}
		}
		int ans = 0;
		for(int key : map.keySet()) {
			if(map.get(key) != 0) ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 54512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<double> P(N);
	rep(i, N) {
		cin >> P[i];
		P[i] = (P[i] + 1) / 2.0;
	}
	vector<double> Sm(N, 0);

	for (int i = 0; i < K; ++i) {
		Sm[0] += P[i];
	}
	double max_sum = Sm[0];
	int idx = 0;

	for (int i = 1; i <= (N - K); ++i) {
		Sm[i] = Sm[i - 1] - P[i - 1] + P[i + K - 1];
		if (Sm[i] > max_sum) {
			idx = i;
			max_sum = Sm[i];
		}
	}
	cout << fixed << setprecision(10) << max_sum << endl;
	return 0;
} 

Measured memory_bytes: 6476
#include <stdio.h>

int main() {
    int i, j, k, a, b, dice[2][7],
    side[5] = {2,3,5,4,2},
    n = 0;
    
    for (i=0; i<2; i++)
        for (j=1; j<7; j++)
            scanf("%d", &dice[i][j]);
    
    for (i=0; i<6; i++) {
        if (dice[0][1]==dice[1][1])
            for (j=0; j<4; j++) {
                
                //一致判定
                for(k=1; k<7; k++)
                    if (dice[0][k]!=dice[1][k]) break;
                
                if(k==7) {
                    printf("Yes\n");
                    return 0;
                }
                
                //スピン
                dice[1][0] = dice[1][2];
                dice[1][2] = dice[1][3];
                dice[1][3] = dice[1][5];
                dice[1][5] = dice[1][4];
                dice[1][4] = dice[1][0];
                
                
            }
        
        //回転
        
        dice[1][0] = dice[1][1];
        
        switch(i) {
                
            case 2:
                dice[1][1] = dice[1][3];
                dice[1][3] = dice[1][6];
                dice[1][6] = dice[1][4];
                dice[1][4] = dice[1][0];
                break;
                
            default:
                dice[1][1] = dice[1][2];
                dice[1][2] = dice[1][6];
                dice[1][6] = dice[1][5];
                dice[1][5] = dice[1][0];
                break;
                
        }
    }
    
    printf("No\n");
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	int a[n];

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

	int dp[n-1]={0};
	dp[0] = 0;
	for(int i=1;i<n;i++){
		int temp = INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j >= 0){
				temp = min(temp, dp[i-j] + abs(a[i]-a[i-j]));
			}
		}
		dp[i] = temp;
	}

	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 4312
#include <stdio.h>
#define MAX 100000
typedef struct {
  char name[10];
  int t;
} QUEUE;

QUEUE que[MAX];
int front, rear;

void Enqueue(QUEUE x) {
  if (rear == MAX)
    rear = 0;
  que[rear] = x;
  rear++;
}

QUEUE Dequeue(void) {
  if (MAX == front)
  front = 0;
  return que[front++];
}

int main(int argc, char const *argv[]) {
  int i, n, q, exet = 0;
  QUEUE queue;
  scanf("%d %d", &n, &q);
  for (i = 0; i < n; i++) {
    scanf("%s %d", queue.name, &queue.t);
    Enqueue(queue);
  }

  while (n != 0) {
    queue = Dequeue();
    if (queue.t > q) {
      queue.t = queue.t - q;
      exet = exet + q;
      Enqueue(queue);
    } else {
      exet = exet + queue.t;
      printf("%s %d\n", queue.name, exet);
      n--;
    }
  }
  return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int N = 555555;
const int K = 26;
const int M = 20;

int nx[K][N];
int nxw[K][N];
int nxz[M][N];

int main(){

	string s;
	cin >> s;
	
	int n = s.length();
	for (int i = 0; i < K; ++i) {
		char c = 'a' + i;
		if (i == 0) {
			for (int j = 0; j < n; ++j) {
				nx[i][j] = (s[j] == c ? j + 1 : -1);
			}
			continue;
		}
		for (itn j = 0; j < n; ++j) {
			if (s[j] > c) {
				nx[i][j] = -1;
			} else if (s[j] == c) {
				nx[i][j] = j + 1;
			} else if (nx[i - 1][j] == -1 || nx[i - 1][j] == n) {
				nx[i][j] = -1;
			} else {
				nx[i][j] = nx[i - 1][nx[i - 1][j]];
			}
		}
	}

	for (int i = 0; i < K; ++i) {
		nxw[i][n - 1] = nx[i][n - 1];
	}
	nxz[0][n - 1] = -1;
	for (int i = n - 2; i >= 0; --i) {
		int c = s[i] - 'a';
		int lst = i + 1;
		while (c < K && nx[c][i] > -1) {
			nxw[c][i] = nx[c][i];
			lst = nx[c][i];
			++c;
		}
		while (c < K) {
			if (lst == n || lst == -1) {
				nxw[c][i] = -1;
			} else {
				nxw[c][i] = nxw[c - 1][lst];
				lst = nxw[c - 1][lst];
			}
			++c;
		}
		if (nxw[25][i] == -1 || nxw[25][i] == n) {
			nxz[0][i] = -1;
		} else {
			nxz[0][i] = nxw[25][nxw[25][i]];
		}
		c = 0;
		lst = nxz[0][i];
		while (c < s[i] - 'a') {
			if (lst == -1 || lst == n) {
				nxw[c][i] = -1;
			} else {
				nxw[c][i] = nxw[c][lst];
			}
			++c;
		}
	}

	for (int i = 1; i < M; ++i) {
		for (int j = 0; j < n; ++j) {
			if (nxz[i - 1][j] == -1 || nxz[i - 1][j] == n) {
				nxz[i][j] = -1;
			} else {
				nxz[i][j] = nxz[i - 1][nxz[i - 1][j]];
			}
		}
	}

	// for (int i = 0; i < n; ++i) {
	// 	cerr << nx[24][i] << " ";
	// }
	// cerr << "\n";
	// for (int i = 0; i < n; ++i) {
	// 	cerr << nxz[0][i] << " ";
	// }
	// cerr << "\n";
	// for (int i = 0; i < n; ++i) {
	// 	cerr << nxz[1][i] << " ";
	// }
	// cerr << "\n";
	// for (int i = 0; i < n; ++i) {
	// 	cerr << nxz[2][i] << " ";
	// }
	// cerr << "\n";

	int q = nxt();
	while (q--) {
		int l = nxt() - 1, r = nxt();
		// cerr << l << " " << r << "\n";
		for (int i = M - 1; i >= 0; --i) {
			if (nxz[i][l] > -1 && nxz[i][l] <= r) {
				l = nxz[i][l];
			}
			if (l == r) {
				break;
			}
		}
		// cerr << l << " .. " << r << "\n";
		if (l == r) {
			puts("Yes");
		} else {
			puts("No");
		}
	}

	return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  int ans = 0;
  vector<int> check(n);
  rep(i,n) check[i]=-1;
  rep(i,m){
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0){
      if (n==1) check[s-1]=0;
      else{
        ans = -1;
        break;
      }
    }
    if (check[s-1]!=-1){
      if (check[s-1]==c) continue;
      else {
      ans = -1;
      break;
      }
    }
    
    ans += pow(10,(n-s))*c;
    check[s-1]=c;
  }
  if (ans>=0 && n>1 && ans<pow(10,n-1)) ans += pow(10,n-1);
  cout << ans;
}
    

Measured memory_bytes: 256
#include<stdio.h>

struct student{
	int m;
	int f;
	int r;
};

void judge(struct student *a){
	if (a->m == -1 || a->f == -1)
		printf("%c\n", 'F');
	else if ((a->m + a->f) >= 80)
		printf("%c\n", 'A');
	else if ((a->m + a->f) >= 65)
		printf("%c\n", 'B');
	else if ((a->m + a->f) >= 50)
		printf("%c\n", 'C');
	else if ((a->m + a->f) >= 30)
		if (a->r >= 50)
			printf("%c\n", 'C');
		else
			printf("%c\n", 'D');
	else
		printf("%c\n", 'F');
}

int main(void){
	struct student a[50];
	int i = 0;
	while (1){
		scanf("%d %d %d", &a[i].m, &a[i].f, &a[i].r);
		if (a[i].m == -1 && a[i].f == -1 && a[i].f == -1)
			break;

		i++;
	}

	int n = i;
	for (i = 0; i < n; i++){
		judge(&a[i]);
	}


	return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int n;
  long double ans=0, a;
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> a;
    ans += (long double)1/a;
  }
  printf("%.6Lf\n", (1.0/ans));
}


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


int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    string s1;
    string s2;
    cin>>s1>>s2;
    if (s1.length()+1==s2.length()){
        for (int i=0; i<s1.length(); i++){
            if (s1[i]!=s2[i]){
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

void coco(vector<int>& v) {
    size_t n = v.size();
    vector<pair<int, int>> t(n);
    for (int i = 0; i < n; i++) {
        t[i] = { v[i], i };
    }
    sort(t.begin(), t.end());
    int k = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0 && t[i].first != t[i - 1].first) k++;
        v[t[i].second] = k;
    }
}

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

    int n;
    cin >> n;

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

    coco(a);
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        c[a[i]]++;
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        r += c[i] % 2;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1408
#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++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

vector<vector<int>> G;
vector<int> way;
int N;

bool dfs(int from, int pos){
    if(pos == N-1){
        way.push_back(N-1);
        return true;
    }
    
    for(auto next: G[pos]){
        if(next == from) continue;

        if(dfs(pos,next)){
            way.push_back(pos);
            return true;
        }
    }
    return false;
}

struct UnionFind{
    vector<int> data;
    //data[i] = -x ... iが根であり、サイズがx
    //data[i] = x ... iの親がx

    //最初は全員根
    UnionFind(int size): data(size,-1){}

    bool union_set(int x, int y){//サイズがx>yになるようにしてから、xにyをつなげる
        x=root(x);
        y=root(y);
        if(x != y){
            if(data[y] < data[x]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find_set(int x, int y){//ルートが一致するかどうかを返す
        return root(x) == root(y);
    }
    int root(int x){//根を見つける。ついでに深さ2にしちゃう
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

int main() {
    cin >> N;
    G.assign(N,{});
    vector<int> A(N-1);
    vector<int> B(N-1);
    REP(i,N-1){
        int a,b; cin >> a >> b;
        a--;
        b--;
        A[i] = a;
        B[i] = b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(-1,0);
    
    int n = way.size();
    reverse(ALL(way));
    UnionFind uf(N);
    if(n%2==0){
        REP(i,N-1){
            if(min(A[i],B[i])==min(way[n/2-1],way[n/2]) && max(A[i],B[i])==max(way[n/2-1],way[n/2])) continue;
            uf.union_set(A[i],B[i]);
        }
    }else{
        REP(i,N-1){
            if(min(A[i],B[i])==min(way[n/2],way[n/2+1]) && max(A[i],B[i])==max(way[n/2],way[n/2+1])) continue;
            uf.union_set(A[i],B[i]);
        }
    }
    if(uf.size(0) > uf.size(N-1)) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    
    return 0;
}

Measured memory_bytes: 16572
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);

  int a,b,c;
  
  cin >> a >> b >> c;
  
  if(a==b){
    cout << c << endl;
  } else if(a==c){
    cout << b << endl;
  } else {
    cout << a << endl;
  }

  return 0;
}

Measured memory_bytes: 256
while 1:
    n=int(raw_input())
    if n==0:break
    if n==1:
        print(1)
        continue
    dp=[0]*(n+1)
    dp[0]=dp[1]=1
    dp[2]=2
    for i in xrange(2,n):
        dp[i+1]=dp[i]+dp[i-1]+dp[i-2]
    print(dp[n]/3650+1)

Measured memory_bytes: 6272
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
    ll res=1;
    while(b)
    {
        if(b&1LL)
            res=(res*a)%c;
        a=(a*a)%c;
        b>>=1;
    }
    return res;
}

int main()
{
    FASTIO;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   
   char ch;
    cin>>ch;

    cout<<++ch<<"\n";

    
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 query(i64 u, i64 v) {
  i64 ans;
  cout << "? " << u << " " << v << endl;
  cin >> ans;
  return ans;
}

int main() {
  i64 N, s, t;
  cin >> N >> s >> t;
  i64 len = query(s, t);
  vector<pair<i64, i64>> vec;
  for(int i = 1;i <= N;i++) {
    i64 a = query(s, i);
    i64 b = query(i, t);
    if(a + b == len) {
      vec.push_back({a, i});
    }
  }
  sort(all(vec));
  vector<i64> ans;
  ans.push_back(vec[0].second);
  i64 now = 0;
  i64 idx = 1;
  while(idx < vec.size()) {
    i64 a = vec[now].second;
    i64 b = vec[idx].second;
    if(vec[now].first + query(a, b) == vec[idx].first) {
      now = idx;
      ans.push_back(b);
    }
    idx++;
  }
  cout << "! ";
  for(int i = 0;i < ans.size();i++) {
    cout << ans[i] << " \n"[i + 1 == ans.size()];
  }
}



Measured memory_bytes: 4652
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            double x1 = scn.nextDouble();
            double y1 = scn.nextDouble();
            double x2 = scn.nextDouble();
            double y2 = scn.nextDouble();
            double ans = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
            System.out.println(ans);
        }
    }
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    rep(i,0,n) cin >> A[i] >> B[i];
    sort(all(A));
    sort(all(B));
    if(n%2 == 1) {
        cout << B[n/2] - A[n/2]+1 << endl;
    }else {
        cout << B[n/2-1] + B[n/2] - A[n/2-1] - A[n/2]+1 << endl;
    }
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll  n;
	cin>>n;
	ll a[n],b[n];
	for(int  i=0 ;i<n;i++)
		cin>>a[i];

	b[1] = abs(a[1]-a[0]);
    b[0] = 0;
	for(int i=2;i<n;i++){
		b[i] = min( abs(a[i]- a[i-2])+ b[i-2] , abs(a[i]- a[i-1])+ b[i-1]); 
	} 
	cout<<b[n-1];
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s,t;
	cin >> s >> t;
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));
	for(i=0;i<s.size();i++) if (s[i]!=t[i]) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3816
h,w=map(int,input().split())
s=[input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            if (i>0 and s[i-1][j]=="#") or (i<h-1 and s[i+1][j]=="#") or (j<w-1 and s[i][j+1]=="#") or (j>0 and s[i][j-1])=="#":
                pass
            else:
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
#pragma GCC optimize("O2")
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
#include <iomanip>
#include <bitset>
#include <iomanip>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
 
/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
///////////////////////////////
#define int long long

void solve(){
	
	int a , b , c , d;
	cin>>a>>b>>c>>d;
	
	int ans = a*c;
	ans = max(ans , b*d);
	ans = max(ans , a*d);
	ans = max(ans , b*c);
	
	if(ans < 0){
		
		if(a <= 0 && b >=0)
			ans = 0;
		if(c <= 0 && d >= 0)
			ans = 0;
	}
	cout<<ans<<endl;
}

signed main(){
 
	fast;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int>a(q);
	vector<int>h(n,k);
	vector<int>z(n,0);
	for (int i = 0; i < q; i++) {
		cin >> a[i];
		h[a[i]-1]++;
	}
	for (int j = 0; j < n; j++) {
		h[j] -= q;
	}
	for (int j = 0; j < n; j++) {
		if (h[j]>0) {
			cout << "Yes" << endl;
		}
		
		else {
			cout << "No" << endl;
		}
	

		
	}


	
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<stack>
#include<sstream>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
    int n;
    cin >>n;
    string s1 = "Eve";
    cout << "Christmas";
    for(int i = 25; i > n; i --)
    {
        cout << " " << s1;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> da(n);
	for (int i = 0;i < n;i++) {
		cin >> da[i];
	}
	vector<int> ans(n,0);
	int gg = 0;
	for (int i = n - 1;i > -1;i--) {
		int co = 0;
		int j = i + 1;
		while (n + 1 > j) {
			if (ans[j-1]) {
				co++;
			}
			j += i + 1;
		}
		if (co % 2 != da[i]) {
			ans[i] = 1;
		}
	}
	vector<int> an(0);
	for (int i = 0;i < n;i++) {
		if (ans[i]) {
			an.push_back(i + 1);
			gg++;
		}
	}
	cout << gg << endl;
	for (int i = 0;i < gg;i++) {
		if (i == gg - 1) {
			cout << an[i] << endl;
		}
		else {
			cout << an[i] << ' ';
		}
	}
}


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);
  int N;
  int[][] AB;

  void input() {
    N = sc.nextInt();
    AB = new int[N][];
    for (int i = 0; i < N; i++) {
      AB[i] = new int[] {sc.nextInt(), sc.nextInt()};
    }
  }

  void solve() {
    Arrays.sort(AB, (int[] a, int[] b) -> -((a[0] + a[1]) - (b[0] + b[1])));
    long v = 0;
    for (int i = 0; i < N; i++) {
      if (i % 2 == 0) {
        v += AB[i][0];
      } else {
        v -= AB[i][1];
      }
    }
    System.out.println(v);
  }

  void start() {
    input();
    solve();
  }

  public static void main(String[] args) throws Exception {
    new Main().start();
  }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2) {
        cout << min(n - b, a - 1) + 1 + (b - a - 1) / 2 << '\n';
    } else cout << (b - a) / 2 << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
long long sum, s, r = 1e18;
int n, w[201000];
int main() {
	int i;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		sum += w[i];
	}
	for (i = 1; i < n; i++) {
		s += w[i];
		r = min(r, abs(s * 2 - sum));
	}
	printf("%lld\n", r);
}

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

int M;
int a[7];
int s, g;
int N[301];

bool isChecked[301];
set<int> milestone[301];  //そのマスで出せばゴールにたどり着ける目を格納する

int iabs(int x){ return x >= 0 ? x : -x; }

bool search(int now){
	if (isChecked[now]) return false;
	else if (now == g)  return true;

	isChecked[now] = true;
	for (int dice = 1; dice <= 6; dice++){
		if (now + a[dice] <= M && search(now + a[dice] + N[now + a[dice]])){
			milestone[now].insert(a[dice]);
		}
		if (now - a[dice] >= 1 && search(now - a[dice] + N[now - a[dice]])){
			milestone[now].insert(-a[dice]);
		}
	}

	return milestone[now].size() > 0 ? true : false;
}

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

	cin >> M;
	for (int i = 1; i <= 6; i++){
		cin >> a[i];
	}
	cin >> s >> g;
	for (int i = 1; i <= M; i++){
		cin >> N[i];
	}
	bool canGoal = search(s);

	int now = s; //自分が今いるマスの番号
	for (;;){
		int dice;
		cin >> dice;

		if (milestone[now].count(a[dice]) > 0){
			now = now + a[dice] + N[now + a[dice]];
			cout << 1 << endl;
		}
		else if (milestone[now].count(-a[dice]) > 0){
			now = now - a[dice] + N[now - a[dice]];
			cout << -1 << endl;
		}
		else cout << 0 << endl;
		cout.flush();

		if (now == g) return 0;
	}
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> C(N, vector<int>(3));
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < 3; ++j)
      cin >> C[i][j];

  for (int j = 0; j < 3; ++j) {
    for (int i1 = 0; i1 < N; ++i1) {
      int A = C[i1][j];
      for (int i2 = i1 + 1; i2 < N; ++i2)
        if (A == C[i2][j])
          C[i1][j] = 0, C[i2][j] = 0;
    }
  }

  for (int i = 0; i < N; ++i)
    cout << C[i][0] + C[i][1] + C[i][2] << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	LL arr[86];
	int n;
	cin>>n;
	 arr[0]=2L;
	 arr[1]=1L;
	for(int i=2;i<=n;i++){
		arr[i]=arr[i-2]+arr[i-1];
	}
	cout<<arr[n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 101
int equals(char s[],char t[]){
  int i;
  for(i=0;;i++){
    if(s[i]!=t[i]){
      return 0;
    }
    if(s[i]==0 || t[i]==0){
      break;
    }
  }
  return 1;
}

int main(){
  char s[N]={},t[N]={},temp,ct=0;
  int i,j,n,f=0;
  scanf("%s%s",s,t);
  for(i=0;;i++){
    if(s[i]==0){
      n=i;
      break;
    }
  }
  while(ct<n){
    temp=s[n-1];
    for(i=n-1;i>0;i--){
      s[i]=s[i-1];
    }
    s[0]=temp;
    ct++;
    if(equals(s,t)==1){
      f=1;
      break;
    }
  }
  if(f){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n;
  cin >> n;
  vector<pair<i64, i64>> v(n); // B, A
  for (i64 i = 0; i < n; ++i) {
    i64 a, b;
    cin >> a >> b;
    v[i] = { b, a };
  }
  sort(begin(v), end(v));

  i64 x = v.back().first;
  for (i64 i = n - 1; i >= 0; --i) {
    x = min(x, v[i].first);
    x -= v[i].second;
  }
  if (x >= 0) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}



Measured memory_bytes: 3328
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
// using namespace atcoder;
using ll = long long;
const int mod = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i, n) cin >> s[i] >> t[i];
    string x;
    cin >> x;
    int ans = 0;
    bool ok = false;
    rep(i, n)
    {
        if (s[i] == x)
        {
            ok = true;
            continue;
        }
        if (ok)
            ans += t[i];
    }
    cout << ans << endl;
}

int main()
{
    // srand((unsigned)time(NULL));
    // int t = clock();
    solve();
    // double et = 1.0 * (clock() - t) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */


int main() {
    string s;
    cin >> s;
    bool be[30];
    fill(be,be+30,false);
    rep(i, s.size()) be[s[i]-'a'] = true;
    rep(i, 26) if(!be[i]) {
        cout << char(i+'a') << endl;
        return 0;
    }
    cout << "None" << endl;
    
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int N;
 cin>>N;
 vector<int>A(N);
 for(int i=0;i<N;i++){
   cin>>A[i];
 }
 sort(A.begin(),A.end());
 int64_t ans=1;
 if(N%2!=0){
  if(A[0]!=0){cout<<0<<endl;return 0;}
  int ju=2;
  for(int i=1;i<N;i+=2){
   ans*=2;ans%=1000000007;
   if(A[i]!=ju||A[i+1]!=ju){cout<<0<<endl;return 0;}
   ju+=2;
  }
   cout<<ans<<endl;return 0;
  }
  else{
    int ju=1;
    for(int i=0;i<N;i+=2){
      ans*=2;ans%=1000000007;
      if(A[i]!=ju||A[i+1]!=ju){cout<<0<<endl;return 0;}
      ju+=2;
    }
    cout<<ans<<endl;return 0;
  }
 return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include <iomanip>

using namespace std;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    int A[N];
    for(int i = 0; i < N; i++)scanf("%d", &A[i]);
    vector<pair<int, int>> s;
    int B[M], C[M];
    for(int i = 0; i < M; i++){
        cin >> B[i] >> C[i];
        pair<int, int> tmp;
        tmp.first = B[i];
        tmp.second = C[i];
        s.push_back(tmp);
    }
    //for(int i = 0; i < M; i++)cout << s[i].first << "&" << s[i].second << " ";
    sort(s.begin(), s.end(), compare_by_b);
    sort(A, A+N);
    
    vector<long> bnc;
    int nbnc = 0;
    for(int i = 0; i < N && nbnc < M; i++){
        for(int j = 0; j < s[nbnc].first; j++){
            bnc.push_back(s[nbnc].second);
            i++;
        }
        i--;
        nbnc++;
    }
    cout << endl;
    //for(int i = 0; i < bnc.size(); i++)cout << bnc[i] << ",";

    long ans = 0;
    for(int i = 0; i < N; i++){
        if(i < bnc.size()){
            if(bnc[i] > A[i])A[i] = bnc[i];
        }
        ans += A[i];
    }
    
    cout << ans;
}

Measured memory_bytes: 4340