akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll n,ans=0;
    string s[200001];
    cin>>n;
    rep(i,n) cin>>s[i];
    ll num[10]={0};
    rep(i,n){
        if(s[i][0]=='M') num[0]++;
        if(s[i][0]=='A') num[1]++;
        if(s[i][0]=='R') num[2]++;
        if(s[i][0]=='C') num[3]++;
        if(s[i][0]=='H') num[4]++;
    }
    rep(i,32){
        vec A;
        int p=i;
        rep(j,5){
            if(p%2) A.push_back(num[j]);
            p/=2;
        }
        ll a=1;
        if(A.size()==3){for(auto j:A) a=a*j;ans+=a;}
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 6912
from typing import List


def query(S: List[str], l: int, r: int) -> int:
    return ac[r - 1] - ac[l - 1]


if __name__ == "__main__":

    N, Q = [int(x) for x in input().split(" ")]
    S = list(input())

    ac = [0]
    count = 0
    for i, s in enumerate(S):
        if i == 0:
            continue

        if S[i - 1] == "A" and S[i] == "C":
            count += 1

        ac.append(count)

    for _ in range(Q):
        l, r = [int(x) for x in input().split(" ")]
        print(query(S, l, r))


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   string s;cin >>s;
   string pre="";
   int ans=0;
   int n=s.size();
   int i=0;
    while(i<n){
        string c="";
        c+=s[i];
        if(pre==c){
            i++;
            if(i==n)break;
            c+=s[i];
        }
        pre=c;
        ans++;
        i++;
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3740
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let MOD = 1000000007L

/// n! (mod p) を求める
/// O(n)
let rec factorial n p =
    let rec loop a n p =
        match n with
        | 0L | 1L -> a
        | _ -> loop ((a * n) % p) (n - 1L) p
    loop 1L n p

/// x ^ n (mod p) を求める
/// O(log n)
let rec pownMod x n p =
    if n = 0L then
        1L
    elif n % 2L = 0L then
        let a = pownMod x (n / 2L) p
        (a * a) % p
    else
        let a = pownMod x (n - 1L) p
        (x * a) % p

/// C(n, k) (mod p) を求める
/// O(n + k + log p)
let comb n k p =
    if n < 0L || k < 0L || n < k then
        0L
    elif n = 0L || k = 0L then
        1L
    else
        let a = factorial n p
        let b = factorial k p
        let c = factorial (n - k) p
        let pb = pownMod b (p - 2L) p
        let pc = pownMod c (p - 2L) p
        // (a * pownMod b (p - 2L) p * pownMod c (p - 2L) p) % p
        ((a * pb % p) * pc) % p

[<EntryPoint>]
let main _ =
    let [X;Y] = reads int

    if (X + Y) % 3 <> 0 then
        0L
    else
        let m = (2 * X - Y) / 3 |> int64
        let n = (-X + 2 * Y) / 3 |> int64
        comb (m + n) n MOD
    |> printfn "%i"

    0

Measured memory_bytes: 14160
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
vector<pii> q;
set<int> edge[N];
set<pii> inq;
int fa[N],n;
int F(int x){return fa[x]==x?x:fa[x]=F(fa[x]);}
void add(int u,int v){
    auto it = edge[u].find(v);
    if(it == edge[u].end()) edge[u].insert(v);
    else {
        edge[u].erase(it);
        if(u>v) swap(u,v);
        if(!inq.count(mp(u,v)))
            inq.insert(mp(u,v)),q.pb(mp(u,v));
    }
}

int main(){
    scanf("%d",&n);
    rep(i,0,2) rep(j,1,n){
        int u,v;
        scanf("%d%d",&u,&v);
        --u;--v;
        add(u,v);
        add(v,u);
    }
    rep(i,0,n) fa[i]=i;
    rep(i,0,sz(q)){
        int u=F(q[i].fi),v=F(q[i].se);
        if(sz(edge[u])<sz(edge[v])) swap(u,v);
        fa[v]=u;
        for(auto w:edge[v]) {
            edge[w].erase(v);
            add(u,w);
            add(w,u);
        }
        edge[v].clear();
    }
    puts(sz(q) + 1 == n ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 25216
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    // How to generate the number
    queue<long long> nums;
    for(int i = 1; i < 10; ++i) {
        nums.push(i);
    }
    long long num = 1;
    for(int i = 0; i < K; ++i) {
        num = nums.front();
        nums.pop();
        long long r = num % 10;
        if(r != 0) nums.push(num * 10 + r - 1);
        nums.push(num * 10 + r);
        if(r != 9) nums.push(num * 10 + r + 1);
    }
    cout << num << "\n";
    return 0;

}



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

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var hmhmk = ReadLongArray();
		var h1 = hmhmk[0];
		var m1 = hmhmk[1];
		var h2 = hmhmk[2];
		var m2 = hmhmk[3];
		var k = hmhmk[4];

		Console.WriteLine((h2 - h1) * 60 + (m2 - m1) - k);
	}

	/// <summary>最大公約数</summary>
	long gcd(long a, long b) => (a == 0) ? b : gcd(b % a, a);

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


Measured memory_bytes: 27548
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main(){
 
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    ll n;
    cin >> n;
    ll arr[n+1]={};    
    for(ll i=1; i<=n; i++){
        for(ll j=i; j<=n; j+=i){
            arr[j]++;
        }
    }
    ll ans=0;
    for(ll i=1; i<=n; i++){
        ans+=(arr[i])*i;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 81616
import java.util.*;
public class Main {
		
	static int MOD = 1_000_000_007;
	static int MAX = 100_000;
	static long[] fac = new long[MAX+1];
	static long[] finv = new long[MAX+1];
	static long[] inv = new long[MAX+1];
	
	static void COMinit() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i = 2; i <= MAX; i++) {
			fac[i] = fac[i-1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
			finv[i] = finv[i-1] * inv[i] % MOD;
		}
	}
	
	static long combination(int n, int k){
		if(n < k || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
	}
	
	public static void main(String[] args) {
		COMinit();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] A = new long[N];
		Arrays.setAll(A, i -> sc.nextInt());
		Arrays.sort(A);
		long ans = 0;
		for(int i = 0; i < N; i++) {
			ans += A[N-1-i]*(combination(N-1-i, K-1)-combination(i, K-1));
			ans %= MOD;
		}
		System.out.println(ans);


	}

}

Measured memory_bytes: 63056
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  vector<int> array;   
  array.push_back(A + B);
  array.push_back(A - B);
  array.push_back(A * B);
  sort(array.begin(), array.end());
  cout<<array.back()<<endl;
  return 0;
  
}


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

vector<pair<int, int> > ans;

long long solve(vector<int> &pos, vector<int> &neg) {
    if (pos.size() == 1) {
        long long tmp = pos[0];
        for (int i = 0; i < neg.size(); i++) {
            ans.push_back({tmp, neg[i]});
            tmp -= neg[i];
        }
        return tmp;
    } else {
        int a = pos.back(); pos.pop_back();
        int x = solve(neg, pos);
        ans.push_back({a, x});
        return a - x;
    }
}

int main() {
    int n; cin >> n;
    vector<int> pos, neg;
    int z = 0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (a > 0) pos.push_back(a);
        else if (a < 0) neg.push_back(a);
        else z++;
    }
    if (pos.empty() && z) for (int i = 0; i < z; i++) pos.push_back(0);
    else if (z) for (int i = 0; i < z; i++) neg.push_back(0);
    sort(pos.begin(), pos.end(), greater<int>());
    sort(neg.begin(), neg.end());
    if (pos.empty()) {
        int x = neg.back();
        neg.pop_back();
        pos.push_back(x);
    } else if (neg.empty()) {
        int x = pos.back();
        pos.pop_back();
        neg.push_back(x);
    }
    cout << solve(pos, neg) << endl;
    for (auto x : ans) cout << x.first << ' ' << x.second << endl;
}


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

typedef long long ll;

const ll N = 1e6 + 10, mod = 998244353;
ll d[N], cnt[N];

ll mul(ll a, ll b) {
  	return ((a * b) % mod + mod) % mod;
}

int main() {
  	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  	ll n;
  	cin >> n;
  	for (int i = 0; i < n; i++)
      	cin >> d[i];
 	for (int i = 0; i < n; i++)
      	cnt[d[i]]++;
 	ll ans = (cnt[0] == 1? 1: 0);
  	if (d[0] ^ 0)
      	ans = 0;
  	for (int i = 1; i < n; i++)
      	if (cnt[i] && !cnt[i - 1])
          	ans = 0;
  	for (int i = 0; i < n; i++)
     	if (d[i])
      		ans = mul(ans, cnt[d[i] - 1]);
 	cout << ans << "\n";
  	return 0;
}

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

int main(){
  int N,K,Q;
  cin >> N >> K >> Q;
  vector<int> tp(N,0);
  rep(i,Q){
    int in;
    cin >> in;
    tp.at(in - 1)++;
  }
  rep(i,N){
    if(Q - tp.at(i) < K) cout << "Yes" <<  endl;
    else cout << "No" << endl;
  }
}


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


int main() {
    int N;
    string S;
    string al = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    cin >> N;
    cin >> S;
    for (int i = 0; i < S.size(); ++i) {
        for (int j = 0; j < 26; ++j) {
            if (S[i] == al[j]) {
                if (j >= 26-N) {
                    S[i] = al[j - (26 - N)];
                } else {
                    S[i] = al[j+N];
                    break;
                }
            }
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, c[505], s[505], f[505];
int main() {
	int i, j, t, r;
	cin>>n;
	for(i=0; i<n-1; i++) {
		cin>>c[i]>>s[i]>>f[i];
	}
	for(i=0; i<n-1; i++) {
		t =s[i] + c[i];
		for(j=i+1; j<n-1; j++) {
			if(t < s[j]) t = s[j];
			else {
				r = t%f[j];
				if(r>0) t += f[j]-r;
			}
			t += c[j];
		}
		printf("%d\n", t);
	}
	puts("0");
	return 0;
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n, m;
	cin >> n >> m;

	if(n > m) swap(n, m);

	if(n != 1){
		cout << (n-2)*(m-2) << endl;
	}else{
		if(m == 1){
			cout << 1 << endl;
		}else{
			cout << m-2 << endl;
		}
	}

	return 0;
}


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}
int h, w, k, ans;
string s[6];
int main()
{
	fast;
	cin >> h >> w >> k;
	fork(i, h)
	{
		cin >> s[i];
	}
	fork(i, 1 << h)
	{
		fork(j, 1 << w)
		{
			int c = 0;
			fork(i2, h)
			{
				fork(j2, w)
				{
					if (i >> i2 & 1 && j >> j2 & 1 && s[i2][j2] == '#')
						c++;
				}
			}
			if (c == k)
				ans++;
		}
	}
	cout << ans << en;
}

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

int main()
{
  int N, A, odd_count = 0;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> A;
    if (A % 2 == 1)
      odd_count++;
  }
  if (odd_count % 2 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 ll N;
  ll M;
  cin >>N>>M;
  vl A(N);
  vl B(N);
  rep(i,N) {
cin >>A.at(i)>>B.at(i);
  }
  vector<pair<ll,ll>> vec(N);
  rep(i,N) {
    vec.at(i).first=A.at(i);
    vec.at(i).second=B.at(i);
   
  }
  sort(all(vec));
 
  vl C(N);
  rep(i,N) {
    C.at(i)=(vec.at(i).first)*(vec.at(i).second);
  }
 
  
  ll ctot=0;
ll tter=0;
  ll a=0;
rep(i,N) {
  if(ctot+vec.at(i).second<=M) {
    ctot+=vec.at(i).second;
   
    tter+=C.at(i);
    a++;
  }
  else if(ctot+vec.at(i).second>M) {
    break;
  }
}


  
  if(ctot==M) {
   cout<<tter<<endl;
   
  }
  
  else if(ctot<M) {
   
    tter+=(M-ctot)*(vec.at(a).first);
    cout<<tter<<endl;
    
     
  }
        
    
}




Measured memory_bytes: 4224
# C
n = int(input())
h = list(map(int, input().split()))
ans = True
pre = -1
for num in h:
    if num > pre:
        pre = num-1
    elif num == pre:
        pre = num
    else:
        ans = False
        break
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63856
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);
    if (a < b &&  b < c) {
        console.log('Yes');
    } else {
        console.log('No');
    }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15520
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define PD pair<double,double>
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vector<PD> v;
  rep(i,n){
    double x,y;
    cin>>x>>y;
    v.PB(PD(x,y));
   
  }

  sort(all(v),[](P a,P b){return atan2(a.S,a.F)<atan2(b.S,b.F);});

  double ans=0;
  rep(i,n){
    double x=0,y=0;
    rep(j,n){
      PD p=v[(i+j)%n];
      x+=p.F;
      y+=p.S;

      ans=max(ans,sqrt(x*x+y*y));
    }
  }

  cout<<ans<<endl;

}

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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI M_PI
#define bf printf("\n");

int main(void){
    int a, t, s;
    scanf("%d%d%d",&a, &t, &s);

    if((double)a/s <=t){
        printf("Yes");
    } else{
        printf("No");
    }
    
    
    return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;

set<char> D;

void check(string s){
    for(int j = 0; j < s.size(); j++){
        D.insert(s[j]);
    }
}


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

    if(s.size() == 26){
         string s2 = s;
         string s3 = s;
         sort(s2.begin(),s2.end());
         next_permutation(s.begin(), s.end());

        if(s2 == s){
            printf("-1\n");
        }
        else{
           string ans = "";
           for(int i = 0; i < s.size(); i++){
               ans.push_back(s[i]);
               if(s[i] != s3[i]){
                   break;
               }
           }
           cout << ans << endl;
        }
    }
    else{
        check(s);
        for(char i = 'a'; i <= 'z'; i++){
            if(D.find(i) == D.end()){
                s.push_back(i);
                break;
            }
        }

        cout << s << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int sum = 0;
  while(1){
	string str;
	cin >> str;
	if(str=="0") break;

	int sum = 0;
	for(int i=0; i<(int)str.size(); i++){
	  sum += str[i] - '0';
	}
	cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<ll> a, b;
int main() {
	ll n;
	string s,t;
	cin>>n>>s>>t;
	for(int i=0;i<s.size();i++){
		if(s[i]==t[i]){
			a.push_back(1);
		}
		else{
			a.push_back(2);
			i++;
		}
	}
	if(a[0]==1){
		b.push_back(3);
	}
	else{
		b.push_back(6);
	}
	for(int i=1;i<a.size();i++){
		if(a[i]==1){
			if(a[i-1]==1){
				b.push_back(2);
			}
			else{
				b.push_back(1);
			}
		}
		else{
			if(a[i-1]==1){
				b.push_back(2);
			}
			else{
				b.push_back(3);
			}
		}
	}
	ll ans=1;
	for(int i=0;i<b.size();i++){
		ans*=b[i];
		ans%=inf;
	}
	cout <<ans;
    // your code goes here
	return 0;
}

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

   int N ;
   cin >> N ;
   vector<int> A(N) ;
   int ans = 0  ; 
   rep(i,N) cin >> A.at(i)  ;
   sort(A.begin(),A.end())  ;
   //rep(i,N) cout << A.at(i)  ;
   rep(i,N-1) ans += A.at(i);
   if( ans > A[N-1] ) cout << "Yes" << endl;
   else cout << "No" << endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct StarrySky {
  vector<int> data, plus;
  int sz;
  StarrySky(int n) {
    sz = 1; while(sz < n) sz <<= 1;
    data.resize(2*sz-1, 0);
    plus.resize(2*sz-1, 0);
  }
  void add(int a, int b, int x, int k, int l, int r) {
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) {
      plus[k] += x;
      return;
    }
    add(a, b, x, 2*k+1, l, (l+r)/2);
    add(a, b, x, 2*k+2, (l+r)/2, r);
    data[k] = min(data[2*k+1]+plus[2*k+1], data[2*k+2]+plus[2*k+2]);
  }
  void add(int a, int b, int x) {
    add(a, b, x, 0, 0, sz);
  }
  int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return data[k]+plus[k];
    return min(query(a, b, 2*k+1, l, (l+r)/2),
	       query(a, b, 2*k+2, (l+r)/2, r)) + plus[k];
  }
  int query(int a, int b) {
    return query(a, b, 0, 0, sz);
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, Q;
  string s;
  cin >> N >> Q >> s;
  StarrySky ss(N);
  set<int> st;
  rep(i, N) {
    if(s[i] == '(') {
      ss.add(i, N, 1);
    } else {
      ss.add(i, N, -1);
      st.insert(i);
    }
  }
  while(Q--) {
    int q; cin >> q; q--;
    //cout<<s[q]<<endl;
    if(s[q] == '(') {
      s[q] = ')';
      st.insert(q);
      ss.add(q, N, -2);
      int idx = *st.begin();
      s[idx] = '(';
      st.erase(idx);
      ss.add(idx, N, 2);
      cout << idx+1 << endl;
    } else {
      s[q] = '(';
      st.erase(q);
      ss.add(q, N, 2);
      int lb = 0, ub = q;
      while(lb+1 < ub) {
	int mb = (lb+ub)/2;
	if(ss.query(mb, N) > 1) ub = mb;
	else lb = mb;
      }
      //cout<<ss.query(ub, N)<<endl;
      s[ub] = ')';
      st.insert(ub);
      ss.add(ub, N, -2);
      cout << ub+1 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 26496
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll k;

  cin >> k;

  map<ll,ll> check;

  //cout << k % 2 << endl;

  if(k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  ll count = 1;
  ll current = 7 % k;

  while(1) {
    //cout << current << endl;
    if(current % k == 0) break;

    count++;

    if(check[current] == 1) {
      cout << -1 << endl;
      return 0;
    }
    check[current] = 1;
    current = ( current * 10 + 7 ) % k;
  }

  cout << count << endl;
}


Measured memory_bytes: 66108
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

LL a[51];
int main() {
	int N;
	cin >> N;
	LL mx=-1e6,mn=1e6;
	int mxi,mni;
	for(int i=1;i<=N;i++){
		int a;
		cin >> a;
		if(a>mx){
			mxi=i;
			mx=a;
		}
		if(a<mn){
			mni=i;
			mn=a;
		}
	}
	cout << 2*N-2 << endl;
	if(abs(mx)>=abs(mn)){
		for(int i=1;i<=N;i++){
			if(i!=mxi){
				cout << mxi << " " << i << endl;
			}
		}
		for(int i=2;i<=N;i++){
			cout << i-1 << " " << i << endl;
		}
	}
	else{
		for(int i=1;i<=N;i++){
			if(i!=mni){
				cout << mni << " " << i << endl;
			}
		}
		for(int i=N-1;i>=1;i--){
			cout << i+1 << " " << i << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>

int main(void){
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int>> job(m);
    for(int i = 0; i < n; i++){
        int a, b;
        std::cin >> a >> b;
        if(a > m) continue;
        job[m-a].push_back(b);
    }
    std::priority_queue<int> q;
    int ans = 0;
    for(int i = m-1; i >= 0; --i){
        for(int j : job[i]){
            q.push(j);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 8372
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll sans[31];
//--MAIN-----------------------------------
void Main() {
    ll Q;
    cin>>Q;
    sans[0]=1;
    rep(i,30){
        sans[i+1]=sans[i]*3;
    }
    while(Q--){
        ll a,b,c,d; cin>>a>>b>>c>>d; --a,--b,--c,--d;
        ll ans=abs(a-c)+abs(b-d);
        repr(i,29,0){
            ll x1=(a/sans[i]);
            ll y1=(b/sans[i]);
            ll x2=(c/sans[i]);
            ll y2=(d/sans[i]);
            if(x1==x2 and x1%3==1 and abs(y1-y2)>=2){
                ans=abs(b-d)+min(a%sans[i]+c%sans[i]+2, sans[i]-(a%sans[i]) + sans[i]-(c%sans[i]));
                break;
            }

            if(y1==y2 and y1%3==1 and abs(x1-x2)>=2){
                ans=abs(a-c)+min(b%sans[i]+d%sans[i]+2, sans[i]-(b%sans[i]) + sans[i]-(d%sans[i]));
                break;
            }
        }
        cout<< ans <<"\n";
    }
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll = long long;

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

    std::priority_queue<double, std::vector<double>, std::greater<double>> que;
    int N;
    cin >> N;
    for (int i=0; i<N; i++){
        int v;
        cin >> v;
        que.push(v);
    }
    for (int i=0; i<N-1; i++){
        double v1, v2;
        v1 = que.top();
        que.pop();
        v2 = que.top();
        que.pop();
        que.push((double)(v1+v2)/2);
    }
    cout << que.top() << endl;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Graph {
    ArrayList<Integer>[] graph;

    @SuppressWarnings("unchecked")
    Graph(int n) {
        graph = new ArrayList[n];
        for(int i = 0; i < n; i++) {
            graph[i] = new ArrayList<>();
        }
    }
    public void addEdge(int u, int v) {
        graph[u].add(v);
    }
    public ArrayList<Integer> neighbors(int u) {
        return graph[u];
    }
}

public class Main {
    static Graph g;
    static boolean[] visited;
    static int distance[];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();

        g = new Graph(n);
        visited = new boolean[n];
        distance = new int[n];

        for(int i = 0; i < m; i++) {
            int u = in.nextInt(), v = in.nextInt();
            u--; v--;
            g.addEdge(u, v);
        }
        int mx = 0;
        for(int i = 0; i < n; i++) {
            if(!visited[i]) {
                distance[i] = 0;
                mx = Math.max(mx, go(i));
                visited[i] = true;
            }
        }

        System.out.println(mx);
    }

    private static int go(int u) {
        if(visited[u]) return distance[u];
        visited[u] = true;
        for (int v : g.neighbors(u)) {
            distance[v] = go(v);
            distance[u] = Math.max(distance[u], distance[v] + 1);
        }
        return distance[u];
    }

}

Measured memory_bytes: 106344
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long t = sc.nextLong();
        if (x > t) {
            System.out.println(x - t);
            return;
        }
        System.out.println(0);
    }

}


Measured memory_bytes: 23124
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
         
        int[] a = new int[10000];
        int[] b = new int[10000];
        while(true){
            String[] tmp = stdIn.nextLine().split(",");
            if(tmp.length!=2){
                break;
            }
            else{
                a[Integer.parseInt(tmp[0])]++;
            }
        }
        while(stdIn.hasNext()){
            String[] tmp = stdIn.nextLine().split(",");
            b[Integer.parseInt(tmp[0])]++;
        }
        for(int i=0;i<a.length;i++){
            if(a[i]>0&&b[i]>0){
                System.out.println(i+" "+(a[i]+b[i]));
            }
        }
    }
}

Measured memory_bytes: 12000
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

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

} 
  
for(int i = 0;i<m;i++){
     
  cin >> b[i];
//  cout << b[i] << endl;
} 
int ans = 0;
  
for(int i = x+1;i<=y;i++){
  
  int flag = 0;
  
 //  cout << i << endl;
  
   for(int j = 0;j<n;j++){
    // cout << a[j] << endl;
     
    if(a[j]<i){
      
        flag = flag+1;
      }

  } 
  
  for(int j = 0;j<m;j++){
     
    if(b[j]>=i){
      
       flag = flag+1;
      
     }

   } 
  
  if(flag==n+m){
    
    ans = 1;
    break;
  }
  
  
}
  if(ans==1){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
  
   
  return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 1000000007;
const ll i2 = (MOD + 1) / 2;
const int MX = 200010;

ll inv[MX], fact[MX], ifact[MX];
ll p2[MX], ip2[MX];

void init() {
    inv[1] = 1;
    for (int i = 2; i < MX; ++i) {
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    }

	p2[0] = ip2[0] = 1;
	for (int i = 1; i < MX; ++i) {
		p2[i] = p2[i-1] * 2 % MOD;
		ip2[i] = ip2[i-1] * i2 % MOD;
	}

    fact[0] = ifact[0] = 1;
    for (int i = 1; i < MX; ++i) {
        fact[i] = fact[i-1] * i % MOD;
        ifact[i] = ifact[i-1] * inv[i] % MOD;
    }
}

ll comb(int n, int r) {
    if (n < 0 || r < 0 || r > n) return 0;
    return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

int B, W;
bool rev;
ll ans[MX];

int main() {
	init();

	cin >> B >> W;
	if (B < W) {
		swap(B, W);
		rev = true;
	}

	if (W == B) {
		rep(i, B + W) {
			cout << i2 << "\n";
		}
		return 0;
	}

	for (int i = 1; i <= W; ++i) {
		ans[i] = i2;
	}

	ll s = 0;
	for (int j = 0; j < W; ++j) {
		s += comb(W, j);
		if (s >= MOD) s -= MOD;
	}

	ll f = ip2[W];

	for (int i = W; i < B; ++i) {
		ll u = p2[i] - s;
		if (u < 0) u += MOD;
		f = u * ip2[i] % MOD;

		ans[i+1] = (1 + u * ip2[i]) % MOD * i2 % MOD;
		s = (s * 2 - comb(i, W-1)) % MOD;
		if (s < 0) s += MOD;
	}

	s = 0;
	for (int j = 1; j < W; ++j) {
		s = s + comb(B, j);
		if (s >= MOD) s -= MOD;
	}

	for (int i = B; i < W + B; ++i) {
		f = (f + comb(i-1, W-1) * ip2[i]) % MOD;
		ans[i+1] = (f + s * ip2[i+1]) % MOD;

		s = (s * 2 - comb(i, i-B+1) - comb(i, W-1)) % MOD;
		if (s < 0) s += MOD;
	}

	if (rev) {
		for (int i = 1; i <= B + W; ++i) {
			ans[i] = 1 - ans[i];
			if (ans[i] < 0) ans[i] += MOD;
		}
	}

	for (int i = 1; i <= B + W; ++i) {
		cout << ans[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 11392
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	string s;
	cin >> s;
	int n = s.length();
	vector<bool>flag(26);
	rep(i, n) {
		flag[s[i] - 'a'] = true;
	}
	rep(i, 26) {
		if (!flag[i]) {
			char x = i + 'a';
			cout << x << endl;
			return 0;
		}
	}
	puts("None");
	return 0;
}


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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }


//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);

  int q; cin >> q;

  bitset<100001> sieve;
  sieve.set();
  for(int i = 2; i*i <= 100000; ++i){
    if (sieve[i]){
      for (int j = i*i; j <= 100000; j += i) {
        sieve[j] = 0;
      }
    }
  }
  sieve[0] = 0;
  sieve[1] = 0;


  ll counter[100001];
  memset(counter, 0, sizeof(counter[0])*100001);

  for(int i = 1; i <= 100000; ++i){

    counter[i] = counter[i-1];
    if(i%2 && sieve[i] && sieve[(i+1)/2]) counter[i]++;
  }


  for (int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    std::cout << counter[r] - counter[l-1] << std::endl;
  }

  return 0;
}



Measured memory_bytes: 1408
n,m=map(int,input().split())
a=list(map(int,input().split()))
da=[9,8,7,6,5,4,3,2,1]
db=[6,7,3,6,5,4,5,5,2]
ka=set(())
d={}
for i in range(9):
  if  da[i] in a and db[i] not in ka:
    d[da[i]]=db[i]
    ka.add(db[i])
dr={v:k for k,v in d.items()}
a=[d.keys()]
a.sort(reverse=True)

dp=[0]*(n+1)
dp[0]=''
import sys
sys.setrecursionlimit(10**7)
def maxret(d1,d2):
  if len(d1)>len(d2):return d1
  if len(d1)<len(d2):return d2
  if d1>d2:return d1
  if d1<d2:return d2
def func(k):
  if k==0:return ''
  if dp[k]!=0:return dp[k]
  ret=''
  for x in d:
    if k-d[x]<0:continue
    tmp=func(k-d[x])
    tmp+=str(x)
    if tmp[0]=='-':continue
    t=maxret(ret,tmp)
    ret=t
  if ret=='':
    dp[k]='-'
  else:
    dp[k]=ret
  return dp[k]
ddd=func(n)
print(ddd)


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

using namespace std;

int cnt[27];

int main() {
    bool ok = true;
    string s; cin>>s;
    for(char c : s){
        cnt[c - 'a']++;
    }
    for(int i = 0 ; i < 27; ++i){
        ok &= (cnt[i] % 2 == 0);
    }
    cout<<(ok?"Yes":"No")<<endl;
}

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

int main()
{
  int N;
  string S;
  cin >> N;
  cin >> S;
  int te = 0;
  int tw = 0;
  int sum_e[N],sum_w[N];
  for(int i = 0;i < N;i++){
    if(S[i] == 'E') te++;
    sum_e[i] = te;
    if(S[i] == 'W') tw++;
    sum_w[i] = tw;
  }

  int left,right,min1;
  min1 = 10000000;
  for(int i = 0;i < N;i++){
    left = 0;
    right = 0;
    if(S[i] == 'E'){
      right = sum_e[N-1] - sum_e[i];
      left = sum_w[i];
    } else if(S[i] == 'W'){
      right = sum_e[N-1] - sum_e[i];
      left = sum_w[i] - sum_w[0];
    }
    min1 = min(min1,(left + right));
  }
  cout << min1 << endl;
  return 0;
}


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

const int MAXN = 5e5 + 5;
const int blockSize = 707;

int a[MAXN];
int freq[MAXN];
int answer;
int ans[MAXN];

void add(int v) {
    freq[v]++;
    if (freq[v] == 1)
    	answer++;
}
 
void rem(int v) {
    freq[v]--;
    if (freq[v] == 0)
    	answer--;
}
 
 
struct Query {
    int l, r, id;
 
    bool operator<(Query const& q) const {
        if (l / blockSize != q.l / blockSize) {
            return l / blockSize < q.l / blockSize;
        }
        return r < q.r;
    }
};
 
int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++) scanf("%d", a+i);
    
    vector<Query> queries(q);
    for (int i = 0; i < q; i++) {
        scanf("%d%d", &queries[i].l, &queries[i].r);
        queries[i].l--;
        queries[i].r--;
        queries[i].id = i;
    }
    sort(queries.begin(), queries.end());

    int l = 1, r = 0;
    for (int i = 0; i < q; i++) {
    	Query& query = queries[i];
        while (r < query.r) add(a[++r]);
        while (r > query.r) rem(a[r--]);
        while (l < query.l) rem(a[l++]);
        while (l > query.l) add(a[--l]);
        ans[query.id] = answer;
    }
 
    for (int i = 0; i < q; i++) {
        printf("%d\n", ans[i]);
    }
}

Measured memory_bytes: 15404
n,k,q=map(int,input().split())
p=[0 for i in range(n)]
if k>q:
    for i in range(n):
        print("Yes")
else:
    for i in range(q):
        a=int(input())
        p[a-1]+=1
    for i in p:
        if i<q-k+1:
            print("No")
        else:
            print("Yes")


Measured memory_bytes: 9904
#include <iostream>
#include<cmath>

using namespace std;

int ketasum(int num){
    int sum=0;
    while(num!=0){
        sum+=num%10;
        num=num/10;
    }
    return sum;
}

int main() {
  int N;
  cin>>N;
  if(N%ketasum(N)==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, i;
  int Fibo[50];

  scanf("%d", &n);

  Fibo[0] = Fibo[1] = 1;

  for ( i = 2; i <= n; i++ )
    Fibo[i] = Fibo[i-1] + Fibo[i-2];

  printf("%d\n", Fibo[n]);

  return 0;
}


Measured memory_bytes: 2108
H = gets.chop.to_i


def cnt(n, acc)
  a = n / 2

  if a >= 1
    acc += 1
    cnt(a, acc)
  else
    return acc
  end
end


if H == 1
  puts 1
else
  count = cnt(H, 0)
  arr = []

  (1..count).each do |i|
    if i == 1
      arr.push(2)
    else
      arr.push(arr[i-2] * 2) 
    end
  end

  puts arr.inject(:+) + 1
end


Measured memory_bytes: 1788
p_flg = Array.new(1000000, true)
p_flg[0] = p_flg[1] = false
p = Array.new

for i in 2..1000000
  next if !p_flg[i]

  p.push(i)

  j = i + i
  while j <= 1000000
    p_flg[j] = false
    j += i
  end
end

while s = gets
  n = s.to_i
  i = 0
  ans = 0

  while i < p.size && p[i] <= n
    ans += 1
    i += 1
  end

  puts ans
end

Measured memory_bytes: 10812
#include<bits/stdc++.h>
using namespace std;
#define FF first.first
#define FS first.second
typedef pair<int,int>P;
typedef pair<P,int>PP;
char map1[51][51];
int main(void)
{
	int H,W;
	int i,j;
	int yy,xx,cost;
	int cnt=0;
	int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
	bool flg=false;
	queue<PP> que;
	cin>>H>>W;
	for(i=1;i<=H;i++){
		for(j=1;j<=W;j++){
			cin>>map1[i][j];
			if(map1[i][j]=='#'){
				cnt++;
			}
		}
	}
	
	//cout<<cnt<<endl;

	int X=0;
	cost=0;
	que.push(PP(P(1,1),cost));
	while(!que.empty()){
		//cout<<" hoshi "<<endl;
		PP q=que.front();
		que.pop();

		if(map1[q.FF][q.FS]!='#'){
			//cout<<" hoshi1 "<<endl;
			if(q.FF==H&&q.FS==W){
			//	cout<<q.second<<endl;
				X=q.second;
				flg=true;
				break;
			}
			/*for(i=0;i<R;i++){
				for(j=0;j<C;j++){
					cout<<map1[i][j];
				}	
				cout<<endl;
			}*/
			for(i=0;i<4;i++){
					yy=q.FF+dy[i];
					xx=q.FS+dx[i];
					cost=q.second;
					if(xx>=1&&yy>=1&&xx<=W&&yy<=H&&map1[yy][xx]!='#'){
					//	cout<<" yy= "<<yy<<" xx= "<<xx<<" "<<cost<<endl;
						que.push(PP(P(yy,xx),cost+1));
					}	
				}
		}
	
		map1[q.FF][q.FS]='#';

	}
	
	int MAX=H*W;
	//cout<<MAX<<endl;
	MAX=MAX-cnt-X;
	
	cout<<((flg)?MAX-1:-1)<<endl;
	
	return 0;
}

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

int main(){
  int i,n,sum = 0;
  int pt[1000];
  while(cin>>n,n){
    sum = 0;
    for(i = 0;i<n;i++) cin>>pt[i];
    sort(pt,pt + n);
    for(i = 1;i<n-1;i++){
      //cout<<pt[i]<<endl;
      sum += pt[i];
    }
    int tmp = sum/(n-2);
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
import scala.io.StdIn.{readLine,readInt}
 
object Main extends App {
 
 
  def exec(w:String):Unit =  {
    val len = w.length
 
    def shuffle(i:Int, cnt:Int):String =
      if(i == 0) (w drop (cnt%len))+(w take (cnt%len)) else { val m = readInt;shuffle(i-1, cnt+m) }
 
    if(w=="-") return else { val n = readInt;println(shuffle(n,0));exec(readLine) }
 
  }
  exec(readLine)
}

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

int main()
{
    int k, n;
    cin >>k>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    int d;
    vector<int> &A = a;
    vector<int> sa(n);
    for (int j = 0; j < n; j++)
    {
        if (j == n-1)
        {
            sa.at(j) = A.at(0) + k - A.at(n-1);
        }
        else
        {
            sa.at(j) = A.at(j + 1) - A.at(j);
        }
    }
    sort(sa.begin(), sa.end());
    cout << k - sa.at(n-1) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int ALP='Z'-'A'+1,INF=1e8;
int cnt[ALP],ans[ALP];
int main(){
	int n;
	cin>>n;
	fill(ans,ans+ALP,INF);
	REP(i,n){
		string s;
		cin>>s;
		fill(cnt,cnt+ALP,0);
		REP(j,(int)s.size()){
			cnt[s[j]-'a']++;
		}
		REP(j,ALP){
			ans[j]=min(ans[j],cnt[j]);
		}
	}
	REP(i,ALP){
		REP(j,ans[i]){
			cout<<(char)(i+'a');
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

const int N=500009;

typedef set<int>::iterator it;

int n,k;
int p[N],q[N],deg[N];
set<int> front,back;
vector<int> g[N];

int main()
{
	n=read();
	k=read();
	for(int i=1;i<=n;i++)
		q[p[i]=read()]=i;

	for(int i=1;i<k;i++)
		front.insert(p[i]);

	for(int i=1;i<=n;i++)
	{
		if(i)
			front.erase(p[i-1]);
		if(i+k-1<=n)
			front.insert(p[i+k-1]);

		back.insert(p[i]);
		if(i-k>=1)
			back.erase(p[i-k]);

		it tmp=front.upper_bound(p[i]);
		if(tmp!=front.end())
			g[q[(*tmp)]].push_back(i),deg[i]++;
		tmp=back.upper_bound(p[i]);
		if(tmp!=back.end())
			g[q[(*tmp)]].push_back(i),deg[i]++;
	}

	front.clear();
	for(int i=1;i<=n;i++)
		if(!deg[i])
			front.insert(-i);

	int top=0;
	while(!front.empty())
	{
		int u=-(*front.begin());
		p[++top]=u;
		front.erase(front.begin());
		for(int i=0,e=g[u].size();i<e;i++)
			if(--deg[g[u][i]]==0)
				front.insert(-g[u][i]);
	}
    
	for(int i=1;i<=n;i++)
        q[p[i]]=n-i+1;
    for(int i=1;i<=n;i++)
        printf("%d\n",q[i]);
	return 0;
}


Measured memory_bytes: 60800
using System;

class Atcoder35
{
    public static void Main()
    {
        string haiku = Console.ReadLine();

        if (haiku == "5 5 7" || haiku == "5 7 5" || haiku == "7 5 5") {
            Console.WriteLine("YES");
        }
        else {
            Console.WriteLine("NO");
        }
    }
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == -1) break;
		
		double angle = 0.0, x = 1.0, y = 0.0;
		n--;
		while (n--) {
			double base = hypot(x, y);
			double l = hypot(base, 1.0);
			angle += atan2(1.0 , base);
			x = l * cos(angle);
			y = l * sin(angle);
		}
		printf("%lf\n%lf\n", x, y);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  N = N % 10;
  switch(N){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
}


Measured memory_bytes: 3600
N=int(input())
a=list(map(int,input().split()))
M=max(a)
data=[0 for i in range(N)]
for i in range(N):
    data[a[i]]+=1

if M%2==0:
    check="Possible"
    for i in range(M//2+1,M+1):
        if data[i]<2:
            check="Impossible"
    if data[M//2]!=1:
        check="Impossible"
    print(check)
else:
    check="Possible"
    for i in range((M+1)//2+1,M+1):
        if data[i]<2:
            check="Impossible"
    if data[(M+1)//2]!=2:
        check="Impossible"
    print(check)


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

#define M 1000000

bool isTrue(int val, vector<int> list) {
	
	for(int x: list) {
		if(val%x != x-1) {
			return false;
		}
	}
	return true;
}


void solve()
{	
	int n,num,m = INT_MIN,val;
	vector<int> list;
	cin >> n;
	while(n-- && cin >> num) {
		list.emplace_back(num);
		m = max(m,num);
	}
	//cout << m << endl;
	val = m-1;
	while(1) {
		if(isTrue(val, list)) {
			cout << val << endl;
			break;
		} 
		val += m;
	}
}

bool perfectSquare(long long int n) {
	double long s = sqrt(n);
	
	if(s == floor(s)) {
		return true;
	}
	return false;
}

void answer() {
	long long int len,num;
	vector<long long int> list;
	cin >> len;
	
	while(len-- && cin >> num) {
		list.emplace_back(num);
	}
	
	bool prime[M+1];
	
	memset(prime, true, sizeof(prime));
	
	for(int i=2;i<=sqrt(M);i++) {
		if(prime[i]) {
			for(int j=i*i;j<=M;j+=i) {
				prime[j] = false;
			}
		}
	}
	
	for(long long int x: list) {
		if(perfectSquare(x)) {
			long long int p = sqrt(x);
			if(prime[p]) {
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		} else {
			cout << "NO" << endl;
		}
	}
}

void result() {
	long long int n,res=0,num;
	cin >> n;
	while(n-- && cin >> num) {
		res += num-1;
	}
	
	cout << res << endl;
}
			
		

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	result();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>


int main() {

    int w, h, n, x1, y1, x2, y2, rez;
    scanf("%d%d%d", &w, &h, &n);
    x1 = 1;
    y1 = 1;
    x2 = w;
    y2 = h;
    for (int i = 1; i <= n; i++) {
        int x, y, a;
        scanf("%d%d%d", &x, &y, &a);

        if (a == 1 && x + 1 > x1)
            x1 = x + 1;
        else if (a == 2 && x < x2)
            x2 = x;
        else if (a == 3 && y + 1 > y1)
            y1 = y + 1;
        else if (a == 4 && y < y2) {
            y2 = y;
        }
    }

    rez = (x2 - x1 + 1) * (y2 - y1 + 1);
    if (x2 - x1 < 0 || y2 - y1 < 0)
        rez = 0;
    printf("%d", rez);
    return 0;
}


Measured memory_bytes: 128