akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 400005, M = 998244353;

void por()
{
    int n = 6;
    for (int x = 0; x < (1 << n); ++x)
    {
        int y = x;
        vector<int> v;
        for (int q = 1; q <= n * 2; ++q)
        {
            if (y % 2 == 0)
            {
                y /= 2;
                y += (1 << (n - 1));
            }
            else
            {
                y /= 2;
            }
            if (y == x)
                v.push_back(q);
        }
        if (v.size() > 1)
        {
            printf("%d\n", x);
            for (int i = 0; i < n; ++i)
            {
                if ((x & (1 << i)))
                    printf("1");
                else
                    printf("0");
            }
            for (int i = 0; i < n; ++i)
            {
                if ((x & (1 << i)))
                    printf("0");
                else
                    printf("1");
            }
            printf("\n");
            for (int i = 0; i < v.size(); ++i)
                printf("%d ", v[i]);
            printf("\n");
        }
    }
}

int n;
char x[N];

int solvv(int k)
{
    int ans = 0;
    int ast = 1;
    for (int i = k / 2 - 1; i >= 0; --i)
    {
        if (x[i] == '1')
            ans = (ans + ast) % M;
        ast = (ast * 2) % M;
    }
    bool z = true;
    for (int i = k / 2; i < n; ++i)
    {
        char u;
        if ((i / (k / 2)) % 2 == 0)
            u = x[i % (k / 2)];
        else
            u = ((x[i % (k / 2)] - '0') ^ 1) + '0';
        if (u > x[i])
        {
            z = false;
            break;
        }
        else if (u < x[i])
            break;
    }
    if (z)
        ans = (ans + 1) % M;
    return ans;
}

int q[N];
void solv()
{
    scanf("%d", &n);
    scanf(" %s", x);
    vector<int> v;
    for (int i = 1; i <= n * 2; ++i)
    {
        if ((n * 2) % i == 0 && i % 2 == 0 && (2 * n / i) % 2 == 1)
            v.push_back(i);
    }
    int ans = 0;
    for (int i = 0; i < v.size(); ++i)
    {
        q[i] = solvv(v[i]);
        for (int j = 0; j < i; ++j)
        {
            if (v[i] % v[j] == 0)
                q[i] = (q[i] - q[j] + M) % M;
        }
        ans = (ans + q[i] * 1LL * v[i]) % M;
    }
    printf("%d\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //por();
    //return 0;
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) \
    sort(all((x)));    \
    (x).resize(unique(all((x))) - (x).begin())
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | ";
    __f(comma + 1, args...);
}

ll max(ll a, ll b) { return (a > b ? a : b); }
ll min(ll a, ll b) { return (a < b ? a : b); }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
void yes_or_no(ll x)
{
    if (x)
        cout << "Yes\n";
    else
        cout << "No\n";
}
void solve_test()
{
    ll ans = 0;
    string s;
    ll n;
    cin >> n;
    vector<vector<ll>> d(n, vector<ll>(2));
    for (int i = 0; i < n; i++)
        cin >> d[i][0] >> d[i][1];
    ll mx = 0;
    ll cur = 0;
    for (int i = 0; i < n; i++)
    {
        if (d[i][0] == d[i][1])
            cur++;
        else
        {
            mx = max(mx, cur);
            cur = 0;
        }
    }
    mx = max(mx, cur);
    if (mx >= 3)
        ans = 1;
    yes_or_no(ans);
    //cout << ans << "\n";
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    // cin >> t; while (t--)
    solve_test();
    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const ll inf =1 << 30;
const ll mod= 100000;

int dp[50][3001];

int main(void){
	int n,m,s;
	while(cin >> n >> m >> s,n|m|s){
		clr(dp,0);
		dp[0][0]=1;
		for(int mi=1;mi<=m;mi++){
			for(int ni=n*n-1;ni>=0;ni--){
				for(int si=s-mi;si>=0;si--){
					dp[ni+1][si+mi]=(dp[ni+1][si+mi]+dp[ni][si])%mod;
				}
			}
		}
		cout << dp[n*n][s] << endl;
	}
	return 0;
}

Measured memory_bytes: 1752
def main():

    N, K = map(int, input().split())
    v = [0 for _ in range(N)]
    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for u in A:
            v[u-1] += 1
    ans = 0
    for i in range(N):
        if v[i] == 0: ans += 1
    return ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 67680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3==0) continue;
        if(i % 5==0) continue;
        ans += i;
    }
    cout << ans << endl;
}

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

const int MAX_N = 10000;
long a[MAX_N+2];

int isTwoDiv(long n) {
	int sum = 0;
	for (; !(n%2); ) {
		n = n / 2;
		sum++;
	}
	return sum;
}

int main() {
	int N;
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		a[i] = isTwoDiv(a[i]);
	}
	for (int i = 0; i < N; i++)
		sum += a[i];
	cout << sum << endl;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, m;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        m = sc.nextInt();
        solve();
    }

    void solve() {
        long ans = 0;
        if (n > m) {
            int temp = n;
            n = m;
            m = temp;
        }
        if (n == 1) {
            if (m == 1) {
                ans = 1;
            } else {
                ans = m - 2;
            }
        } else {
            ans = (long)(n - 2) * (m - 2);
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            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: 21076
#include <cstdio>
using namespace std;

#define INF 1234567890;
int L[300000], R[300000];
int cnt;

void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = INF;
    R[n2] = INF;

    int i = 0;
    int j = 0;

    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) A[k] = L[i++];
        else A[k] = R[j++];
    }
}

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

int main(void) {
    int n, A[600000];
    cnt = 0;

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

    mergeSort(A, 0, n);

    for (int i = 0; i < n; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", cnt);

    return 0;
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(8e1 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

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

	cout << s[0] << s[1] << s[2] << "\n";
}

	


Measured memory_bytes: 3596
#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 = 1001001001;

int a[12][12];

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> c(n);

  rep(i,n){
    cin>>c[i];
    rep(j,m){
      cin>>a[i][j];
    }
  }
  
  int ans = INF;
  rep(s,1<<n){
    int cost=0;
    vector<int> d(m); //理解度
    rep(i,n){
      if(s>>i&1){ //それぞれが選ばれているか
        cost+=c[i];
        rep(j,m) d[j]+=a[i][j];
      }
    }
    bool ok=true;
    rep(j,m) if(d[j]<x) ok=false;
    if(ok) ans = min(ans,cost);
  }
  if(ans == INF) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

ll N;

void dfs(ll cur, int use, ll &ans) {
    if(cur > N) return;
    if(use == 0b111) ans ++;

    // 7を加える
    dfs(cur*10 + 7, use | 0b001, ans);
    // 5を加える
    dfs(cur*10 + 5, use | 0b010, ans);
    // 3を加える
    dfs(cur*10 + 3, use | 0b100, ans);

}

int main() {

    cin >> N;

    ll ans = 0;
    dfs(0, 0, ans);

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

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

#ifndef ONLINE_JUDGE
	#define ONLINE_JUDGE
#endif

#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define pb push_back
#define mp make_pair
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,j,n) for(i=j;i<=n;i++)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<int> > graph;
const ll maxn = (ll) 2e5+9;
const ll mod = (ll) 1e9+7;
ll func(ll,ll);
ll inversemodulo(ll);
ll fastexpo(ll,ll);

ll factorial[maxn];
void fillfactorial() {
	factorial[0]=1;
	ll i;
	repr(i,1,200005) {
		factorial[i]=(factorial[i-1]*i)%mod;
	}
}
int main()
{
	std::ios::sync_with_stdio(0);
	ll i,j,k,t,A,B,h,w,m,l,r,n;
	fillfactorial();
	cin>>h>>w>>A>>B;
	ll ans=0;
	repr(i,1,w-B) {
		ans=(ans+(func(h-A,B+i)*func(A,w-B-i+1))%mod)%mod;
	}
	cout<<ans<<endl;
}

ll func(ll h,ll w) {
	h--;w--;
	ll ans=1;
	ans=factorial[h+w];
	ans=(ans*inversemodulo(factorial[h]))%mod;
	ans=(ans*inversemodulo(factorial[w]))%mod;
	return ans;
}

ll fastexpo(ll base,ll expo) {
	ll j=base,ans=1;
	for(ll i=0;i<63;i++) {
		if(expo&(1LL<<i)) {
			ans*=j;
			if(ans>=mod)ans%=mod;
		}
		j*=j;
		if(j>=mod)j%=mod;
	}
	return ans;
}

ll inversemodulo(ll n) {
	return fastexpo(n,mod-2);
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
using namespace std;

struct RollingHash {
	int n;
	static const unsigned P = 1000000007U;
	vector<unsigned long long> pow, phash;
	RollingHash() : n(0) {}

	template<typename T>
	RollingHash(const T& s, unsigned long long Q = 1) {
		n = s.size();
		pow.resize(n + 1); phash.resize(n + 1);
		pow[0] = Q; phash[0] = 0;
		for(int i = 0; i < n; i++) {
			pow[i + 1] = pow[i] * P;
			phash[i + 1] = s[i] + phash[i] * P;
		}
	}
	unsigned long long get(int i) const { return phash[i]; }
	unsigned long long get(int i, int j) const { return get(j) - get(i) * pow[j - i]; }
};

int H, W, P;
struct Pat {
	string b[100];
};

string b[1000];
RollingHash h[1000];

Pat ps[8];
RollingHash hs[8][100];

Pat rotate(Pat p) {
	Pat r;
	for(int i = 0; i < P; i++) {
		r.b[i] = string(P, '0');
	}
	for(int i = 0; i < P; i++) {
		for(int j = 0; j < P; j++) {
			r.b[j][P - 1 - i] = p.b[i][j];
		}
	}
	return r;
}

Pat mirror(Pat p) {
	Pat r;
	for(int i = 0; i < P; i++) {
		r.b[i] = string(P, '0');
		for(int j = 0; j < P; j++) {
			r.b[i][P - 1 - j] = p.b[i][j];
		}
	}
	return r;
}

int conv(char c) {
	if('A' <= c && c <= 'Z') return c - 'A';
	if('a' <= c && c <= 'z') return 26 + c - 'a';
	if(isdigit(c)) return 52 + c - '0';
	if(c == '+') return 62;
	return 63;
}

void view(Pat p) {
	for(int i = 0; i < P; i++) {
		cout << p.b[i] << endl;;
	}
	cout << endl;
}

int check(int x, int y, int k) {
	for(int i = 0; i < P; i++) {
		if(h[y + i].get(x, x + P) != hs[k][i].get(0, P)) return false;
	}
	return true;
}

void solve() {
	int cnt = 0;
	for(int i = 0; i < H - P + 1; i++) {
		for(int j = 0; j < W - P + 1; j++) {
			for(int k = 0; k < 8; k++) {
				if(check(j, i, k)) {
					cnt++;
					break;
				}
			}
		}
	}
	cout << cnt << endl;
}

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

	while(cin >> W >> H >> P, W | H | P) {
		for(int i = 0; i < H; i++) {
			b[i] = "";
			string s;
			cin >> s;
			for(int j = 0; j < s.size(); j++) {
				int x = conv(s[j]);
				for(int k = 0; k < 6; k++) {
					b[i] += char('0' + ((x >> (5 - k)) & 1));
				}
			}
			h[i] = RollingHash(b[i]);
		}

		Pat p;
		for(int i = 0; i < P; i++) {
			string s;
			cin >> s;
			for(int j = 0; j < s.size(); j++) {
				int x = conv(s[j]);
				for(int k = 0; k < 6; k++) {
					p.b[i] += char('0' + ((x >> (5 - k)) & 1));
				}
			}
		}

		int cnt = 0;
		for(int i = 0; i < 4; i++) {
			Pat m = mirror(p);
			ps[cnt] = p;
			for(int j = 0; j < P; j++) {
				hs[cnt][j] = RollingHash(p.b[j]);
			}
			cnt++;
			ps[cnt] = m;
			for(int j = 0; j < P; j++) {
				hs[cnt][j] = RollingHash(m.b[j]);
			}
			cnt++;
			p = rotate(p);
		}

		/*for(int i = 0; i < H; i++) {
			cout << b[i] << endl;
			}

			for(int i = 0; i < 8; i++) {
			view(ps[i]);
			}*/

		solve();
	}

}

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

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

    int A, B;
    cin >> A >> B;
    int socket = 1;
    int ans = 0;
    for (; socket < B; ans++) {
        socket--;
        socket += A;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from cmath import exp
from math import radians


def main():
    A, B, H, M = map(int, input().split())

    # 針の位置をA(B) * ext(iθ)で複素数で定義しておく
    # expはmathモジュールでは無く、cmathモジュールを使わないとエラーになる
    h_hand = A * exp(radians((H % 12) * 30 + float(M) / 60.0 * 30.0) * 1j)
    m_hand = B * exp(radians(M / 60 * 360) * 1j)

    ans = abs(m_hand - h_hand)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=2e5+5;
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    int ans=0;
    while(k--)
    {
        int x;scanf("%d",&x);
        ans+=x;
    }
    if(n-ans<0) printf("-1\n");
    else printf("%d\n",n-ans);
}


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

using namespace std;
typedef long long ll;

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

  vector<int> v[3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) {
      int vv;
      cin >> vv;
      v[i].push_back(vv);;
    }
    sort(v[i].begin(), v[i].end());
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll l = lower_bound(v[0].begin(), v[0].end(), v[1][i]) - v[0].begin();
    ll r = n - (upper_bound(v[2].begin(), v[2].end(), v[1][i]) - v[2].begin());
    ans += l * r;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1784
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
p = LI()

p.sort()

ans = sum(p[:K])
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 100010
string s;
int n;
int m;
int a[N];
int b[N];
int c[N];
int f[N];
int fa(int x) {
	if (x == f[x]) return x;
	return f[x] = fa(f[x]);
}

void add(int x, int y) {
	f[fa(x)] = fa(y);
}

int main() {
	cin >> s;
	m = (int) s.length();
	bool er = false;
	if (m%2 == 1) {
		s = s.substr(0, m/2) + s.substr(m/2+1);
		er = true;
		m--;
	}
	// now m is even
	for (int i = 0; i < m/2; i ++) {
		a[i] = ((s[i] - s[m-1-i])%26+26)%26;
		//cout << a[i] << endl;
	}
	for (int i = 0, la = 0; i < m/2; i ++) {
		b[i] = a[i] - la;
		la = a[i];
		//cout << b[i] << endl;
	}
	for (int i = 0; i <= m/2; i ++) f[i] = i;
	
	cin >> n;
	for (int i = 0; i < n; i ++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		
		if (er && x == m/2) x++;
		if (er && y == m/2) y--;
		if (x >= m/2+1 && er) x--;
		if (y >= m/2+1 && er) y--;
		if (x > y) continue;
		
		if (x >= m/2) {
			swap(x, y);
			x = m-1-x;
			y = m-1-y;
		}
		
		if (y >= m/2) {
			if (y-m/2 == m/2-1-x) continue;
			if (y-m/2 > m/2-1-x) {
				swap(x, y);
				x = m-1-x;
				y = m-1-y;
			}
			y = m/2-2-(y-m/2);
		}
		// do something
		//cout << x << " " << y << endl;
		add(x, y+1);
	}
	
	for (int i = 0; i < m/2; i ++)
		c[fa(i)] += b[i];
	bool F = true;
	for (int i = 0; i < m/2; i ++)
		if (i != fa(m/2) && c[i]%26 != 0) F = false;
	puts (F?"YES":"NO");
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i=0;i<k;i++) ans += p[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
n,c=map(int,input().split())
rl=[[0]*2 for _ in range(n+1)]
ls,rs=0,0
xv=[[0,0]]+[list(map(int,input().split())) for _ in range(n)]
for i in range(1,n+1):
    j,k=xv[i]
    rs+=k
    rl[i][0],rl[i][1]=max(rl[i-1][0],rs-j),max(rl[i-1][1],rs-2*j)
ans=rl[n][0]
for i in range(n):
    ls+=xv[n-i][1]
    ans=max(ans,rl[n-i-1][1]+ls-(c-xv[n-i][0]),rl[n-i-1][0]+ls-(c-xv[n-i][0])*2)
print(ans)

Measured memory_bytes: 44004
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    lint n, m;
    cin >> n >> m;
    vector<lint> x(n), y(n), z(n);
    for(lint i = 0 ; i < n ; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    lint ans = 0;
    for(lint i = 0 ; i < 8 ; i++){
        vector<lint> vec(8, 1);
        lint tmp = i, j = 0;
        while(tmp > 0){
            if(tmp % 2 != 0){
                vec[j] = -1;
            }
            tmp /= 2;
            j++;
        }
        vector<lint> solve(n);
        for(lint k = 0 ; k < n ; k++){
            solve[k] = vec[0] * x[k] + vec[1] * y[k] + vec[2] * z[k];
        }
        sort(solve.rbegin(), solve.rend());
        lint t = 0;
        for(lint k = 0 ; k < m ; k++){
            t += solve[k];
        }
        ans = max(ans, t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int pattern1 = 0;
    int pattern2 = 0;
    for(int i = 0; i < s.length(); i++){
        if(i%2==0){
            if(s[i]!='0'){
                pattern1++;
            }else{
                pattern2++;
            }
        }else{
            if(s[i]!='0'){
                pattern2++;
            }else{
                pattern1++;
            }
        }
    }
    int ans = min(pattern1,pattern2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n, k; cin >> n >> k;
  string s; cin >> s;
  s[k-1] += ('a' - 'A');
  cout << s << nl;
  return 0;
}



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

using namespace std;
#define deb(x) cout << #x << " is " << x << "\n"
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n"
#define fo(i, n) for (ll i = 0; i < n; i++)
#define rep(i, k, n) for (ll i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define pb push_back
#define ff first
#define ss second
#define mk make_pair

//-----PREPROCESSORS-------
//Use emplace_back instead of push_back for faster execution...
typedef long long int ll;
const ll INF = 1e18 + 10;
const ll mod = 1000000007;
const double PI = acos(-1);
const int N = 1e7 + 2;
//-----------------------------------------------------------
//Function to return gcd of a and b
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//------------------------------------------
ll power(ll x, ll y, ll p) //x^y %p
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        x = (x * x) % p;
        y >>= 1;
    }
    return res;
}
bool isPrime(ll n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
//-----------------------------------------------
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    int t = 1;
    char c;
    //cin >> t;
    while (t--)
    {  
        cin>>n;k=n%10;
        if(k==3)
        cout<<"bon"<<endl;
        else if(k==0||k==1||k==6||k==8)
        cout<<"pon"<<endl;
        else
        cout<<"hon"<<endl;
        // set<ll> factors;
        // factors.insert(1);
        // factors.insert(n);
        // for(int i=2;i<=sqrt(n)+1;i++)
        // {
        //     if(n%i==0)
        //     {
        //         factors.insert(i);
        //         factors.insert(n/i);
        //     }
        // }
        // auto it = factors.upper_bound(k);
        // --it;
        // ll g = *it;
        // cout<<(n/g)<<"\n";
    }
}



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

#define rep(i, a, b) for(int i = a; i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
using ll = long long;

const int INF = (int) 1e9 + 9;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
//    int a[n];
    vi b(n+1, 0);
    int a = 0;
    rep(i, 1, n) {
        cin >> a; b[a] = i;
    }
    rep(i, 1, n) cout << b[i] << ' ';
    cout << '\n';
    return 0;
}


Measured memory_bytes: 1280
#!/usr/bin/perl

use strict;
use warnings;

my ($n, $k);
{
    my $in = <STDIN>;
    ($n, $k) = split(" ", $in);
}
my ($r, $s, $p);
{
    my $in = <STDIN>;
    ($r, $s, $p) = split(" ", $in);
}
my $t = <STDIN>;
chomp $t;

my @u;
for (my $i=$k; $i<length($t); $i++)
{
    substr($t, $i, 1, "0") if substr($t, $i, 1) eq substr($t, $i - $k, 1);
}
my $ans = 0;
for (my $i=0; $i<length($t); $i++)
{
    $ans += $r if "s" eq substr($t, $i, 1);
    $ans += $s if "p" eq substr($t, $i, 1);
    $ans += $p if "r" eq substr($t, $i, 1);
}
print "$ans\n";

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, k; cin >> n >> k;
	map<int, int> m;
	rep(i, 0, n) {
		int t; cin >> t;
		m[t]++;
	}
	vector<pii> v;
	for (auto p : m) {
		v.push_back({p.second, p.first});
	}
	sort(all(v)); reverse(all(v));
	int ans = n;
	rep(i, 0, min(k, sz(v)))
		ans -= v[i].first;
	cout << ans << endl;
}


Measured memory_bytes: 11764
#include <iostream>
#include <vector>
// #include <algorithm>
// #include <queue>
// #include <cmath>
// #include <string>
// #include <numeric>
// #include <set>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007
// #define INF 1000000001

using namespace std;
// typedef unsigned long long ull;
// typedef long long ll;

void p_() {
    cout << "\n";
}
template<class Head, class... Body>
void p_(Head head, Body... body) {
    cout << head << ",";
    p_(body...);
}


int main(int argc, char const *argv[]) {
    int N, M;
    cin >> N >> M;
    int ans = N;
    for (int i = 0; i < M; ++i) {
        int A;
        cin >> A;
        ans -= A;
    }
    if (ans < 0) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26324
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> //std::priority_queue<int> que; // 4, 3, 2, 1 (defualt, less) : 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N; std::cin >> N;
  std::unordered_map<char,int> L;

  std::array<char, 5> list = { 'M', 'A', 'R', 'C', 'H' };
  for(int i=0; i<N; i++) {
    std::string s; std::cin >> s;
    if ( s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H' ) {
      if ( L.count(s[0]) == 0 ) L[s[0]] = 1;
      else L[s[0]]++;
    }
  }

  ll ans = 0;
  for(int i=0; i<=(0b11111); i++) {
    int num = 0;
    bool ok = true;
    for(int b=0; b<5; b++) {
      if ( (i&(1<<b)) != 0 && L.count(list[b]) == 0 ) ok = false;
      if ( (i&(1<<b)) != 0 ) num++;
    }
    if ( !ok || num != 3 ) continue;

    ll sum = 1;
    for(int b=0; b<5; b++) {
      if ( (i&(1<<b)) != 0 ) sum *= L[list[b]];
    }
    ans += sum;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
from functools import reduce

n, a, b = map(int, input().split())
mod = 10**9 + 7

def fast_comb(a,b,mod):
    up = reduce(lambda x,y: x*y%mod, range(a,a-b,-1))
    down = reduce(lambda x,y: x*y%mod, range(1,b+1))
    return (up * pow(down, mod-2, mod)) % mod

print((pow(2,n,mod) - fast_comb(n,a,mod) - fast_comb(n,b,mod) - 1) % mod)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
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 ll INF = 1LL<<60;
//const int dy[4] = {0, 1, 0, -1};
//const int dx[4] = {1, 0, -1, 0};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

void solve(){
    ll n, k; cin >> n >> k;
    vector<ll> ac(n+1), rac(n+1);
    vector<ll> allocn(n+1);
    for(ll i=0; i<=n; i++) allocn[i] = i%MOD;
    ac[0] = allocn[0]%MOD, rac[n] = allocn[n]%MOD;
    for(ll i=0; i<n; i++){
        ac[i+1] = (ac[i]%MOD + allocn[i+1]%MOD)%MOD;
    }
    for(ll i=n; i>0; i--){
        rac[i-1] = (rac[i]%MOD + allocn[i-1]%MOD)%MOD;
    }
    //cout << ac << endl;
    //cout << rac << endl;
    
    ll res = 0;
    for(ll i=k-1; i<=n; i++){
        ll diff = (rac[n-i] - ac[i])%MOD;
        if(diff < 0) diff += MOD;
        res = res%MOD + (diff + 1)%MOD;
    }
    cout << res << endl;
}

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

Measured memory_bytes: 7920
n,T=map(int,input().strip().split())
arr=[]
for _ in range(n):
    c,t=map(int,input().strip().split())
    arr.append((c,t))
arr=sorted(arr,key=lambda x:x[0])
flag=True
for a,b in arr:
    if b<=T:
        flag=True
        print(a)
        break
    else:
        flag=False 
if flag==False:
    print('TLE')
    


Measured memory_bytes: 3060
import itertools as ite

n=int(input())
count=[0]*5
for i in range(n):
    tmp=input()
    if tmp[0]=="M":
        count[0]+=1
    elif tmp[0]=="A":
        count[1]+=1
    elif tmp[0]=="R":
        count[2]+=1
    elif tmp[0]=="C":
        count[3]+=1
    elif tmp[0]=="H":
        count[4]+=1

ans=0
for i in list(ite.combinations(range(5),3)):
    pattern=1
    for j in i:
        pattern*=count[j]
    ans+=pattern
print(ans)

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

const long long MAXN = 2000 + 10, inf = 1e18;

long long n, x;
long long ans;
long long shift;
long long a[MAXN], b[MAXN];

int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
	   	cin >> a[i];
		b[i] = a[i];
	}
 
	ans = inf;

	for(int k = 0; k < n; k++) {
		shift = k * x;
		
		for (int i = 0; i < n; i++) {
			b[i] = min(b[i], a[(i + n - k) % n]);
			shift += b[i];
		}

		ans = min(ans, shift);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

xs = []
for i in set(s+t):
    x = 0
    for j in s:
        if i == j:
            x += 1
    for k in t:
        if i == k:
            x -= 1
    xs.append(x)
print(max(xs + [0]))

Measured memory_bytes: 3064
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string A = s.Substring(0, (s.Length -1)/2);
            string B = s.Substring((s.Length / 2 )  +1);
            if(A == B)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cassert>

using namespace std;
using ll = long long;

enum class State {
	INCREMENTING, DECREMENTING, SUCCESSION, NONE,
};

bool AreSameGroup(State last, State current) {
	switch (last) {
	case State::INCREMENTING:
		return current == last || current == State::SUCCESSION;
	case State::DECREMENTING:
		return current == last || current == State::SUCCESSION;
	case State::SUCCESSION:
		break;
	case State::NONE:
		return true;
	default:
		break;
	}

	assert(false);
	return false;
}

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

	int ans = 0;
	ll last;
	cin >> last;
	State lastState = State::NONE;

	for (int i = 0; i < n - 1; i++) {
		ll value;
		cin >> value;

		ll diff = value - last;
		State state;
		if (diff > 0) {
			state = State::INCREMENTING;
		} else if (diff < 0) {
			state = State::DECREMENTING;
		} else {
			state = State::SUCCESSION;
		}

		if (!AreSameGroup(lastState, state)) {
			ans++;
			lastState = State::NONE;
		} else {
			if (state != State::SUCCESSION) {
				lastState = state;
			}
		}

		last = value;
	}

	ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n, m) for (int i = n; i <= m; ++i)
#define mem(a, b) memset(a, b, sizeof(a))
#define dbg(x) cout << #x << "=" << x << endl
const int maxm = 1e9 + 7;
const int maxn = 2e5 + 10;
#define gc getchar
#define ll long long
#define P pair<int, int>
template <class I>
inline void read(I &x)
{
    char c;
    I f;
    for (f = 1, c = gc(); c < '0' || c > '9'; c = gc())
        if (c == '-')
            f = -1;
    for (x = 0; c <= '9' && c >= '0'; c = gc())
        x = (x << 1) + (x << 3) + (c & 15);
    x *= f;
}
int main()
{
    int T;
    // read(T);
    T=1;
    while (T--)
    {
        int n;
        cin>>n;
        int x;
        bool flag=1;
        for(int i=1;i<=n;++i)
        {
            cin>>x;
            if(x%2==0)
            {
                if(x%3&&x%5) 
                {
                    flag=0;
                }
            }
        }
        if(flag) puts("APPROVED");
        else puts("DENIED");
    }
}

// abcda
// cbad

Measured memory_bytes: 256
def root(a, x)
  a[x] < 0 ? x : a[x] = root(a, a[x])
end

def unite(a, x, y)
  x, y = root(a, x), root(a, y)
  if x != y
    x, y = y, x if a[y] < a[x]
    a[x] += a[y]
    a[y] = x
  end
end

def connected?(a)
  a.drop(1).min == -N
end

N, M = gets.split.map(&:to_i)
ABs = readlines.map{|l| l.split.map(&:to_i)}

ans = 0
ABs.each do |a, b|
  @p = Array.new(N + 1, -1)
  (ABs - [[a, b]]).each{|c, d| unite(@p, c, d)}
  ans += 1 unless connected?(@p)
end
puts ans

Measured memory_bytes: 1788
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
		long answer = b;

		if(a <= 12) answer /= 2;
		if(a <= 5) answer = 0;

		Console.WriteLine(answer);
	}
}

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define pb push_back

typedef long long ll;

const int N = 2e5;
const int M = 1e9 + 7;

int n;

vector<int> g[N];

ll dp[2][N];

ll dfs(int x, int y, int c) {

    if(dp[c][x] != -1) return dp[c][x];

    ll w = 1;
    if(c) {
        for(auto v : g[x]) if(v != y) {
            w *= dfs(v, x, 1) + dfs(v, x, 0);
            w %= M;
        }
    } else {
        for(auto v : g[x]) if(v != y) {
            w *= dfs(v, x, 1);
            w %= M;
        }
    }
    return dp[c][x] = w % M;
}

int main() {
    cin >> n;
    fore(i, 0, n - 1) {
        int x, y; cin >> x >> y; x--, y--;
        g[x].pb(y);
        g[y].pb(x);
    }
    memset(dp, -1, sizeof(dp));
    if(n == 1) cout << 2 << endl;
    else cout << (dfs(0, 0, 0) + dfs(0, 0, 1)) % M << endl;
}

Measured memory_bytes: 19584
INFTY=10**9+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K==1:
    tot = 0
    for i in range(1,N):
        for j in range(i):
            if A[j]>A[i]:
                tot += 1
else:
    B = [0 for _ in range(2*N)]
    A = A+A
    for i in range(1,2*N):
        cnt = 0
        for j in range(i):
            if A[j]>A[i]:
                cnt += 1
        B[i] = cnt
    tot = 0
    for i in range(N):
        a = B[i]
        d = B[i+N]-B[i]
        tot = (tot + (K*(a-d))%INFTY + ((d*(K+1)*K)//2)%INFTY)%INFTY
print(tot)

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a, ans = 0; cin >> n;
	int test[101] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a;
		test[h] = a;
	}
	for (int h = 0; h < n - 1; h++) {
		for (int i = n - 1; i > 0; i--) {
			if (test[i - 1] > test[i]) {
				int uio = test[i];
				test[i] = test[i - 1];
				test[i - 1] = uio;
				ans++;
			}
		}
	}
	for (int h = 0; h < n; h++) {
		cout << test[h];
		if (h != n - 1) {
			cout << ' ';
		}
	}
	cout << endl; cout << ans << endl;
	cin >> n;
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <string.h>

#define swap(type,a,b) { type temp = a; a = b; b = temp; }
int main(void) {
	// your code goes here
	int n,i,j,d[101];
	char w[101][11];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%s",w[i]);
		d[i]=strlen(w[i]);
	}
	for(i=1;i<n;i++){
		if(w[i+1][0]!=w[i][d[i]-1]){
			printf("No\n");
			return 0;
		}
	}
	for(i=1;i<n;i++){
		for(j=i+1;j<=n;j++){
			if(strcmp(w[i],w[j])==0){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}


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

int main(){
  //input
  int64_t n;
  cin >> n;
  
  //declare array
  vector<int64_t> luc(n+1);
  luc.at(0) = 2;
  luc.at(1) = 1;
  for (int i = 2; i < n+1; i++){
    luc.at(i) = luc.at(i-1) + luc.at(i-2);
  }
  
  //output
  cout << luc.at(n) << endl;
}

Measured memory_bytes: 3632
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <bits/stdc++.h>

using namespace std;

#define BOOST 			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ALL(a) 			(a).begin(), (a).end()
#define SZ(a) 			(int)(a).size()
#define FOR(a, b, c) 	for (int a = (b); a <  (c); a++)
#define FORR(a, b, c) 	for (int a = (b); a >= (c); a--)
#define TRAV(a, b) 		for (auto& a : b)
#define ELO 			exit(0)
#define SORT(a)         sort(ALL(a))
#define REV(a)          reverse(ALL(a))
#define SORTR(a)        SORT(a), REV(a)
#define PB              push_back
using ll = 				long long;
using ld = 				long double; // 'long double' is 2.2 times slower than double
using pii = 			pair<int, int>;
using pll = 			pair<ll, ll>;
using vi = 				vector<int>;
using vll = 			vector<ll>;
using vpii = 			vector<pii>;
using vpll = 			vector<pll>;

template <class T> inline bool setmin(T& a, T b) {if (a > b) return a = b, 1; return 0; }
template <class T> inline bool setmax(T& a, T b) {if (a < b) return a = b, 1; return 0; }

namespace fastio {
    template <class T> istream &operator>>(istream &os, vector<T> & vec){for (auto &u : vec)os >> u;return os;}
    template <class T> ostream &operator<<(ostream &os, const vector<T> & vec){for (auto &u : vec)os << u << " ";return os;}
    template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
    template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }
    template <class T> ostream &operator<<(ostream &os, set<T> & con) { for (auto &u : con) os << u << " "; return os; }

    void re() {}
    template <typename T, typename... args> void re(T& x, args&... tail) { cin >> x; re(tail...); }
    void pr() {}
    template <typename T, typename... args> void pr(T x, args... tail) { cout << x << " "; pr(tail...);}
    template <typename... args> void prln(args... tail) { pr(tail...); cout << "\n";}
}
using namespace fastio;

namespace debug {
    template < typename _T > inline void _debug(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
    template < typename _T, typename... args > void _debug(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _debug(s + 1, a...); }
    
    #if 1
        #define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
        #define cerr cout
    #else
        #define debug(...) 1999
        #define cerr if(0) cout
    #endif
}
using namespace debug;

//////////////_________CODE_________//////////////

constexpr int MOD = 1e9 + 7; // 998244353
constexpr int INF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;

int main() {
    BOOST;
    string s; re(s);
    map<char,int> M;
    TRAV(i, s) M[i]++;

    bool good = SZ(M) == 2;
    if(good) {
        good &= M.begin()->second == 2;
    }

    prln(good ? "Yes" : "No");
    
    ELO;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  int n, q;
  cin >> n;
  vector<int> v;
  for(int i  = 0; i < n; i++){
	   int x;
	   cin >> x;
	   v.push_back(x);  
	} 
  cin >> q;
  int cnt = 0 ;
  vector<int> query;
  for(int i = 0 ; i < q; i++){
	   int val;
	   cin >> val;
	   query.push_back(val);
	}
  for(int i = 0; i < (int)query.size(); i++){
	  int val = query[i];
	  for(int j = 0 ; j < n; j++){
		 if (v[j] == val) {
			 cnt++;
			 break;
		    }
		 }  
	}
  cout << cnt << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



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

int main(){
  int num,i,max,min;
  long long sum;
  cin >> num;
  int x;
  for(i=0;i<num;i++){
    cin >> x;
    if(i==0){
      sum=x;
      max=x;
      min=x;
    }else{
      sum+=x;
      if(max<x){
	max=x;
      }else if(min>x){
	min=x;
      }
    }
  }
  cout << min <<" "<< max<< " " << sum<< endl;
  

}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
	int l,r,d,i,num=0;
	cin >> l >>r >>d;
	for(i=l;i<=r;i++){
		if(i%d==0)num++;
	}
	
	cout <<num<< endl;
	
	
	return 0;
}

Measured memory_bytes: 3588
n=int(input())
a=0
b=0
malti=0
origin=0
for i in range(n):
    s=input()
    if s[0]=="B" and s[-1]=="A":
        malti+=1
    elif s[0]=="B" and s[-1]!="A":
        b+=1
    elif s[0]!="B" and s[-1]=="A":
        a+=1
    for i in range(len(s)-1):
        if s[i]=="A" and s[i+1]=="B":
            origin+=1

if a>=1 and b>=1:
    print(origin+malti+1 +min(a-1,b-1))
elif a==0 and b>=1:
    print(origin+malti)
elif a>=1 and b==0:
    print(origin+malti)
elif a==0 and b==0:
    print(origin+max(malti-1,0))

Measured memory_bytes: 3064