akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <vector>
#include <set>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

LLONG			g_llArraysA[10010];
LLONG			g_llArraysB[10010];

int main(int argc, char* argv[])
{
	LLONG			llLength;
	LLONG			llSumA			= 0;
	LLONG			llSumB			= 0;

	cin >> llLength;

	for (LLONG i = 1; i <= llLength; i++)
	{
		cin >> g_llArraysA[i];
	}

	for (LLONG i = 1; i <= llLength; i++)
	{
		cin >> g_llArraysB[i];
	}

	for (LLONG k = 1; k <= llLength; k++)
	{
		if (g_llArraysA[k] > g_llArraysB[k])
		{
			llSumA += g_llArraysA[k] - g_llArraysB[k];
		}
		else
		{
			llSumB += (g_llArraysB[k] - g_llArraysA[k]) / 2;
		}
	}
	
	if (llSumA <= llSumB)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

#define MAX 101

int main(){

  char s[1000];
  char t;
  int num = 0, stack[MAX];
  int top = 0;
  int a,b;
  while(1){
    scanf("%c", &t);
    if(t >= '0' && t <= '9'){
      num = 0;
      while(1){
	num *= 10;
	num += t-'0';
	scanf("%c", &t);
	if(t < '0' || t > '9'){
	  stack[top] = num;
	  top++;
	  break;
	}
      }
    }
    else if(t == ' '){
    }
    else if(t == '\n'){
      break;
    }
    else{
      a = stack[top-2], b = stack[top-1];
      if(t == '+'){
	stack[top-2] = a + b;
      }
      else if(t == '-'){
	stack[top-2] = a - b;
      }
      else if(t == '*'){
	stack[top-2] = a * b;
      }
      else if(t == '/'){
	stack[top-2] = a / b;
      }
      top--;
    }

  }

  printf("%d\n", stack[0]);
  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

vector<ll> vec;

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

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

    ll N;
    string S;
    cin >> N;

    vec = divisor(N);

    ll ans = LLINF;

    REP(i,vec.size()){
        ll tmp = N / vec.at(i);
        double tmp1 = log10(vec.at(i));
        double tmp2 = log10(tmp);

        ll tmp3 = (ll)(max(tmp1, tmp2));

        ans = min(ans, tmp3+1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3964
MOD = 10**9 + 7
def mySum(a, b):
    return (a + b) * (b - a + 1) // 2 % MOD

N, K = list(map(int, input().split()))
l = mySum(N-K+1, N) - mySum(0, K-1) + 1
res = l
for i in range(K, N+1):
    l = l - i + (N-i)
    res += l
    res %= MOD
print(res)


Measured memory_bytes: 63404
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
using namespace std;
typedef long long ll;

const ll MAX = 200000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

// 二項係数計算
ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
  // 前処理
  COMinit();
  ll h,w,a,b;cin >> h >> w >> a >> b;
  ll ans=COM(h+w-2,h-1);//cout << ans << endl;
  ll m=min(a,b);
  for(int i=0;i<m;i++){
    //cout << 1 << endl;
    ll ans_sub=COM(h-a+b-1,b-i-1)*COM(w-b+a-1,a-i-1)%MOD;
    ans-=ans_sub;
    if(ans<0){
      ans+=MOD;
      //cout << 1 << endl;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
import math
X = int(input())

def isPrime(x):
  if x==2: return True
  for i in range(2, int(math.sqrt(x))):
    if x%i==0:
      return False
  return True

def main(x):
  dx = 0
  while(True):
    if(isPrime(x+dx)):
      return x+dx
    dx+=1

result = main(X)
print(result)

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;

const int N=23;
int f[N][8] = {
    {1,2,3,0,5,6,7,4},
    {2,3,0,1,6,7,4,5},
    {3,0,1,2,7,4,5,6},
    {4,7,6,5,0,3,2,1},
    {5,4,7,6,1,0,3,2},
    {6,5,4,7,2,1,0,3},
    {7,6,5,4,3,2,1,0},
    {0,3,7,4,1,2,6,5},
    {3,7,4,0,2,6,5,1},
    {7,4,0,3,6,5,1,2},
    {4,0,3,7,5,1,2,6},
    {1,5,6,2,0,4,7,3},
    {5,6,2,1,4,7,3,0},
    {6,2,1,5,7,3,0,4},
    {2,1,5,6,3,0,4,7},
    {0,4,5,1,3,7,6,2},
    {4,5,1,0,7,6,2,3},
    {5,1,0,4,6,2,3,7},
    {1,0,4,5,2,3,7,6},
    {3,2,6,7,0,1,5,4},
    {2,6,7,3,1,5,4,0},
    {6,7,3,2,5,4,0,1},
    {7,3,2,6,4,0,1,5},
};

vi normalize(const vi& v)
{
    vi ret(v);

    rep(i,N)
    {
        vi tmp(8);
        rep(j,8) tmp[j] = v[f[i][j]];

        ret = min(ret,tmp);
    }

    return ret;
}

int main()
{
    string s[8];
    while(cin >>s[0])
    {
        for(int i=1; i<8; ++i) cin >>s[i];

        vi a(8);

        map<string,int> col;
        int now=0;
        rep(i,8)
        {
            if(col.find(s[i]) == col.end()) col[s[i]]=now++;
            a[i] = col[s[i]];
        }

        sort(all(a));

        set<vi> octahedra;

        do {
            vi norm = normalize(a);
            octahedra.insert(norm);
        } while(next_permutation(all(a)));

        cout << octahedra.size() << '\n';
    }

    return 0;
}

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

using namespace std;


void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(3*n);
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        x--; y--;
        g[x].emplace_back(y+n);
        g[x+n].emplace_back(y+2*n);
        g[x+2*n].emplace_back(y);
    }
    int s, t; cin >> s >> t;
    s--; t--;
    vector<int> d(3*n, 0);
    auto bfs = [&](){
        queue<int> q;
        d[s] = 0;
        q.emplace(s);
        while (!q.empty()) {
            int u = q.front(); q.pop();
            for (int v: g[u]) {
                if (!d[v]) {
                    d[v] = d[u] + 1;
                    q.emplace(v);
                }
            }
        }
    };
    bfs();
    int res = d[t]? d[t]/3: -1;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,l,sum=0,ans=0,diff;
    scanf("%d %d",&n,&l);
    diff=l;
    int flavour[n];
    for(i=0;i<n;i++)
    {
        flavour[i]=l+(i+1)-1;
        sum+=flavour[i];
        if(flavour[i]==0)diff=0;
        if(flavour[i]<0) diff=l+n-1;
        flavour[i]=abs(flavour[i]);
    }
    //sort(flavour,flavour+n);
    //ans=sum-flavour[0];
    ans=sum-diff;
    printf("%d",ans);
    return 0;
}

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

int main () {
  int N;
  cin >> N;
  
  if ((N % 1000 % 111) == 0 || (N / 10 % 111) == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

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

  char tmp = S[0];
  int count = 0;
  for(int i = 1; i < S.length(); i++) {
    if(tmp != S[i]) {
      count++;
      tmp = S[i];
    }
  }

  cout << count <<endl;
}
  


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

int main() {
    int n;
    cin >> n;
    int ans;
    if(n>=1800) ans = 1;
    else if(n>=1600) ans = 2;
    else if(n>=1400) ans = 3;
    else if(n>=1200) ans = 4;
    else if(n>=1000) ans = 5;
    else if(n>=800) ans = 6;
    else if(n>=600) ans = 7;
    else ans = 8;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if((A == B && A != C) || (B == C && A != B) || (A == C && A != B)) cout << "Yes" << endl;
    else cout << "No" << endl;



	return 0;
}


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

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


def main(args):
    a, b = map(int, input().split())
    ans = '=='
    if a < b:
        ans = '<'
    elif a > b:
        ans = '>'

    print('a {} b'.format(ans))


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

Measured memory_bytes: 7772
#include <iostream>
#include <algorithm>

using namespace std;

int n;
int usea[11];

int dfs(int num, int r_num, int l_num) {
	int res = 0;

	if (usea[num] > r_num) {
		if (num == 9)
			return 1;
		res = dfs(num + 1, usea[num], l_num);
		return res;
	}
	else if (usea[num] >l_num) {
		if (num == 9)
			return 1;
		res = dfs(num + 1, r_num, usea[num]);
		return res;
	}
	else {
		return 0;
	}
}


int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> usea[j];
		}
		if (dfs(0, -1, -1)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3012
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll> > p;

    for(ll i = 0; i < n; i++)
    {
        ll _a, _b;
        cin >> _a >> _b;
        p.push_back(make_pair(_a, _b));
    }    

    sort(p.begin(), p.end());

    ll ans = 0;
    ll cnt = 0;
    for(ll i = 0; i < n; i++)
    {
        while(p[i].second > 0) {
            ans += p[i].first;
            cnt++;
            p[i].second--;
            if (cnt == m) {
                cout << ans << endl;
                exit(0);    
            }
        }
    }    
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int r, d ,x;
    cin >> r >> d >> x;
    int ans = x;
    for(int i = 0; i < 10; i++)
    {
        int tmp = r* x - d;
        cout << tmp << endl;
        x = tmp;
    }
    return 0;
}

Measured memory_bytes: 3148
N, X = map(int, input().split())

def rec(level, X) :
    if level == 0 :
        return 1
        
    if X == 1 :
        return 0
        
    elif X <= 2 ** (level + 1) - 2 :
        return rec(level - 1, X - 1)
        
    elif X == 2 ** (level + 1) - 1 :
        return 2 ** level
        
    elif X <= 2 ** (level + 2) - 4 :
        return 2 ** level + rec(level - 1, X - (2 ** (level + 1) - 1))
        
    else :
        return 1 + (2 ** level - 1) * 2
        
print(rec(N, X))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void solve()
{
  string s;
  cin>>s;
  ll n=s.size();
  if(s[n-1]!='s')
  cout<<s<<"s"<<endl;
  else
  cout<<s<<"es"<<endl;
}


int main()
{
  io;
  ll t;
  t=1;
  //cin>>t;
  while(t--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[57][57];
int main(){
	Lancer();
	ll a, b, t,p,res=0;
	cin >> a >> b;
	for (int i = a; i <= b; i++){
		t = i; p = 0;
		while (t)
		{
			p += (t % 10);
			t /= 10;
			p *= 10;
		}
		p /= 10;
		if (i == p)
			res++;
	}
	cout << res;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3696
//GoHome.cpp (C)
#include <iostream>
#include <string>
using namespace std;

int main(){
  long long x;
  cin >> x;
  int n = 2;
  if(x == 1){
    printf("1\n");
    return 0;
  }else{
    while(true){
      if(n*(n-1)/2 < x && n*(n+1)/2 >= x) break;
      ++n;
    }
  }
  printf("%d\n",n);
  return 0;
}


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

int main()
{
    int N, M;

    scanf("%d %d", &N, &M);

    vector<pair<int, int> > vec;

    for (int i=0; i<M; i++) 
    {
        int x1, x2;
        scanf("%d %d", &x1, &x2);
        vec.push_back({x1, x2});
    }

    sort(vec.begin(), vec.end());

    int cnt = 1;
    int loc = vec[M-1].first;

    for (int i=0; i<M-1; i++)
    {
        if (vec[M-2-i].second <= loc)
        {
            cnt++;
            loc = vec[M-2-i].first;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

int main ()
{
	int t,n,a,b,k;
	cin >> t >>  n >> a >> b;
	
	for (int i = 0 ; ; i++)
    {
      if ( i % 2 == 0)
      {
        a-=n;
      }
      else 
      {
        t-=b;
      }
      if (t <= 0)
      {
        cout << "No";
        break;
      }
      else if (a <= 0)
      {
       cout << "Yes"; 
        break;
      }
    }
	return 0;
}




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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    ll N, M;
    cin >> N >> M;

    if(N == 1) {
        printf("%lld\n", M);
        return 0;
    }
    ll ans = 1;
    for(ll i = M / N; i >= 2; --i) {
        if(M % i == 0) {
            ans = i;
            break;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using ll = long long;

int main() {
    ll sum = 0;
    std::map<ll, ll> ma;
    ll n, a, b, c, q, x;
    std::cin >> n;
    for (ll i = 0; i < n; i++) {
        std::cin >> x;
        ma[x]++;
        sum += x;
    }
    std::cin >> q;
    for (ll t = 0; t < q; t++) {
        std::cin >> b >> c;
        ll k = ma[b];
        ma[b] = 0;
        ma[c] += k;
        sum -= (b * k);
        sum += (c * k);
        std::cout << sum << std::endl;
    }
}


Measured memory_bytes: 9448
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
bool cmp(int a,int b){
	return a>b;
}
int a[105],n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1,cmp);
	int ans=0;
	for(int i=1;i<=k;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


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

def poll(N):
    memo = {}
    max_votes = 1
    for i in range(N):
        Si = input()
        try:
            memo[Si] += 1
            max_votes = max(max_votes, memo[Si])
        except:
            memo[Si] = 1
    max_list = [key for key, value in memo.items() if value == max_votes]
    return max_list

max_list = poll(N)
max_list.sort()
for item in max_list:
    print(item)


Measured memory_bytes: 32096
// Sun May 17 14:33:59 IST 2020      
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353 
#define pb                 push_back
#define f1                 first 
#define s1                 second    
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()
const double pi = 3.141592653589793238;
using namespace std ;     
using namespace __gnu_pbds;
 
typedef tree<pair <int,int>,null_type,less<pair <int,int>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 1e6+3; 
const int INF = INT_MAX;
struct comp{
    bool operator()(const int A,const int& B )const{
        return A > B; 
    }
};    
int tests(){  
    int k,x;
    cin >> k >> x ;
    if(k*500 >= x)
        return cout << "Yes\n",0;
    cout << "No\n";
    return 0;
}  
int32_t main(){
    I__O ;     
    int cases = 1 ;  
    // cin >> cases ;  
    while(cases--){    
        tests(); 
    }
    return 0 ; 
}
 
// -Wall -Wextra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, vector<vector<T>> &v)
{
	for (vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, vector<T> &v)
{
	for (T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n;
	cin >> n;
	ll ans = 0;
	rep(i,1,n+1)
		if(i % 5 != 0 and i % 3 != 0)
			ans += i;	
	cout << ans;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

const int mo=998244353;

int f[4001][4001],s1[2001],s2[2001];
char s[2001];

int main()
{
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++) 
	{
		s1[i+1]=s1[i]+s[i]-'0';
		s2[i+1]=2*(i+1)-s1[i+1];
	}
	f[0][0]=1;
	for(int i=0;i<=s1[n];i++)
		for(int j=0;j<=s2[n];j++)
			if((s1[min(i+j,n)]>=i)&&(s2[min(i+j,n)]>=j))
			{
				if(i) f[i][j]=(f[i][j]+f[i-1][j])%mo;
				if(j) f[i][j]=(f[i][j]+f[i][j-1])%mo;
			}
	cout<<f[s1[n]][s2[n]]<<endl;
	return 0;
}

Measured memory_bytes: 60416
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (auto& r : a) {
		cin >> r;
	}
	vector<vector<int>> dist(h, vector<int>(w, h * w + 10));
	dist[0][0] = (a[0][0] == '#');
	for (int r = 0; r < h; ++r) {
		for (int c = 0; c < w; ++c) {
			if (r < h - 1) {
				dist[r + 1][c] = min(dist[r + 1][c], dist[r][c] + (a[r][c] == '.' and a[r + 1][c] == '#'));
			}
			if (c < w - 1) {
				dist[r][c + 1] = min(dist[r][c + 1], dist[r][c] + (a[r][c] == '.' and a[r][c + 1] == '#'));
			}
		}
	}
	cout << dist[h - 1][w - 1] << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n,m,cnt,ans;
int main()
{
	int i,s,a,b,j,k;
	scanf("%d%d%d",&n,&a,&b);
	if((b-a)%2)printf("Borys");
	else printf("Alice");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///////////////////////////////////////////////////////////////////////////////////////////////////////
int n;
const int maxn=1e5+10;
int a[maxn];
int dp[maxn];
int k;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	fill(dp,dp+n,1e9+10);
	dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=max(i-k,0);j--){
		dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
	}
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>

using namespace std;

int v[20];

int meu[20];

int nrp=0;

int n;

int rez=0;

void rec(int poz)
{
	if(poz==n+1)
	{
		if(nrp>0)
			rez++;
		return;
	}

	for(int t=-1; t<=1; t++)
	{
		meu[poz]=v[poz]+t;
		if(meu[poz]%2==0)
			nrp++;
		rec(poz+1);
		if(meu[poz]%2==0)
			nrp--;
	}
	return;

}

int main()
{
	//freopen("data.in", "r", stdin);


	cin>>n;

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

	rec(1);

	cout<<rez<<"\n";



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

int main(int argc, const char** argv) {
    int n,p[10],q[10],r[10];
    cin >> n;
    rep(i,n) {
        int a;cin>>a;
        p[i]=a;
    }
    rep(i,n) {
        int a;cin>>a;
        q[i]=a;
    }
    rep(i,n) {
        r[i] = i + 1;
    }
    int count=0,pnum,qnum;
    do{
        bool pok=true,qok=true;
        rep(i,n) {
            if(p[i]!=r[i]) {
                pok=false;
            }
        }
        rep(i,n) {
            if(q[i]!=r[i]) {
                qok=false;
            }
        }
        if(pok) pnum=count;
        if(qok) qnum=count;
        count++;
    }while(next_permutation(r,r+n));

    cout<< abs(pnum-qnum) <<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007
#define tp tuple<ll,ll,ll>

vector<vector<ll>> V(3, vector<ll>(100010, 0));

int main() {
	ll N, K, R, S, P;
	cin >> N >> K >> R >> S >> P;
	string T;
	cin >> T;
	ll X;
	ll ans = 0;
	for (ll i = 0;i < K;i++) {
		if (T[i] == 'r') {
			V[2][i] = P;
		}
		else if (T[i] == 's') {
			V[0][i] = R;
		}
		else if (T[i] == 'p') {
			V[1][i] = S;
		}
		ll j;
		//cout << V[0][i] << " " << V[1][i] << " " << V[2][i] << endl;
		for (j = i + K;j < N;j += K) {
			if (T[j] == 'r') {
				V[0][j] = max(V[1][j - K], V[2][j - K]);
				V[1][j] = max(V[0][j - K], V[2][j - K]);
				V[2][j] = max(V[0][j - K], V[1][j - K]) + P;
			}
			else if (T[j] == 's') {
				V[0][j] = max(V[1][j - K], V[2][j - K]) + R;
				V[1][j] = max(V[0][j - K], V[2][j - K]);
				V[2][j] = max(V[0][j - K], V[1][j - K]);
			}
			else if (T[j] == 'p') {
				V[0][j] = max(V[1][j - K], V[2][j - K]);
				V[1][j] = max(V[0][j - K], V[2][j - K]) + S;
				V[2][j] = max(V[0][j - K], V[1][j - K]);
			}
			//cout << V[0][j] << " " << V[1][j] << " " << V[2][j] << endl;
		}
		j -= K;
		ans += max({ V[0][j], V[1][j], V[2][j] });
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main(){
  ll H,W; cin>>H>>W;
  vvi mp(H,vi(W));
  REP(h,H) REP(w,W) cin>>mp[h][w];
  vvi dp(H,vi(W));
  REP(h,H) if(mp[h][0]==0) dp[h][0]=1;
  REP(w,W) if(mp[0][w]==0) dp[0][w]=1;
  FOR(h,1,H) FOR(w,1,W) if(mp[h][w]==0) dp[h][w]=min(min(dp[h-1][w],dp[h][w-1]),dp[h-1][w-1])+1; else dp[h][w]=0;
  ll ans=0; REP(h,H) REP(w,W) ans=max(ans,dp[h][w]*dp[h][w]);
  cout<<ans<<endl;
}

Measured memory_bytes: 33392
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, X, T) = Scanner.Scan<int, int, int>();
            var num = N / X;
            if (N % X > 0) num++;
            var answer = num * T;
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
        }
    }
}


Measured memory_bytes: 28352
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	int n;
	string s;
	cin >> n >> s;

	int ret = 1;
	for (int i = 1; i < n; i++)
	{
		if (s[i-1] != s[i])
		{
			ret++;
		}
	}

	cout << ret;
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
struct edge{ ll to,cost;};
int main(){
  ll n;
  cin>>n;
  vector<vector<edge>> e(n,vector<edge>(0));
  rep(i,n-1){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    edge k;
    k.to=b;
    k.cost=c;
    e[a].pb(k);
    k.to=a;
    e[b].pb(k);
  }
  ll q,k;
  cin>>q>>k;
  vll l(n,INF);
  queue<ll> que;
  k--;
  l[k]=0;
  que.pu(k);
  while(sz(que)){
    ll h=que.front();
    que.pop();
    for(auto y:e[h]){
      if(l[y.to]!=INF) continue;
      l[y.to]=y.cost+l[h];
      que.pu(y.to);
    }
  }
  rep(i,q){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    COUT(l[a]+l[b]);
  }
}


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

int main() {
  int a[3][3];
  bool b[3][3];
  for(int i=0; i< 3; i++) for(int j=0; j < 3; j++){ cin >> a[i][j]; b[i][j] = false;}
  int n; cin >> n;
  for(int q=0; q < n; q++) {
    int t; cin >> t;
    for(int i=0; i< 3; i++) for(int j=0; j < 3; j++) if(a[i][j] == t) b[i][j] = true;
  }
  for(int i=0; i < 3; i++) {
    if(b[i][0] && b[i][1] && b[i][2]) {cout << "Yes" << endl; return 0;}
    if(b[0][i] && b[1][i] && b[2][i]) {cout << "Yes" << endl; return 0;}
  }
  if(b[0][0] && b[1][1] && b[2][2] || b[0][2] && b[1][1] && b[2][0]) {cout << "Yes" << endl;}
  else cout << "No" << endl;
}


Measured memory_bytes: 256
function range(begin, end) {
  return Array.from(Array(end - begin), (e, i) => begin + i);
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift ());
  const p = lines.map(l => l.split(' ')[0]).concat([lines[n-1].split(' ')[1]]).map(Number);

  const m = Array.from(Array(n + 1), () => (Array(n + 1)));
  for (let i = 0; i < n + 1; i++) m[i][i] = 0;

  let i = 0, d = 1;
  for (d = 1; d <= n - 1; d++) {
    for (i = 1; i <= n - d; i++) {
      m[i][i+d] = range(i, i + d).map(
        k => m[i][k] + m[k + 1][i + d] + p[i - 1] * p[k] * p[i + d]
      ).sort((a, b) => a - b)[0];
    }
  }
  console.log(m[1][n]);
})();



Measured memory_bytes: 20492
// $%U%$
// $%D%$/$%M%$/$%Y%$
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n = nxt();
    bool poss = false;
    VI c;
    REP(i, n){
        int a = nxt(), b = nxt();
        if(a == b) c.push_back(1);
        else c.push_back(0);
    }
    REP(i, n-2){
        if(c[i] && c[i+1] && c[i+2]) poss = true;
    }
    if(poss) printf("Yes\n");
    else printf("No\n");
    return 0;
}




Measured memory_bytes: 3704
///
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Mar  4 21:14:02 2018
//
package main

import (
	"fmt"
)

func abs(a int) int {
	if 0 < a {
		return a
	} else {
		return -a
	}
}

type pos struct {
	x, y int
}

func (p pos) dist(q pos) int {
	return abs(p.x-q.x) + abs(p.y-q.y)
}

var H, W, D int
var Q int
var poss []pos

func main() {
	fmt.Scan(&H, &W, &D)

	poss = make([]pos, H*W+1)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			var val int
			fmt.Scan(&val)
			poss[val] = pos{i + 1, j + 1}
		}
	}

	dp := make([]int, H*W+1)
	for i := D + 1; i <= H*W; i++ {
		dp[i] = dp[i-D] + poss[i].dist(poss[i-D])
	}

	fmt.Scan(&Q)
	for i := 0; i < Q; i++ {
		var L, R int
		fmt.Scan(&L, &R)
		fmt.Println(dp[R] - dp[L])
	}
}


Measured memory_bytes: 7844
H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

# 個数制限なしナップサック
# i番目までの魔法を使ったときにHダメージを実現できるときの最小の魔力
dp = [[10**10]*(H+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(H+1):
        # i番目の魔法を使わない時
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        # i番目の魔法を使う時
        dp[i+1][min(H, j+A[i])] = min(dp[i][j]+B[i], dp[i+1][j]+B[i], dp[i+1][min(j+A[i], H)])

print(dp[N][H])


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

	 
	int main()
	{
		string s; bool reversed = false;
		cin >> s;
		int q; cin >> q;
		while (q--) {
			int i; cin >> i;
			if (i == 1) {
				reversed = !reversed;
			}
			else if(i==2){
				int f; char c; cin >> f >> c;
				if (f == 1) {
					if (!reversed)
						s.insert(0, 1, c);
					else s += c;
				}
				else {
					if (!reversed)
						s += c;
					else s.insert(0, 1, c);
				}
			}
		}
		if (reversed) {
			reverse(s.begin(), s.end());
		}
		cout << s;
		return 0;
	}


Measured memory_bytes: 1028
program christmas
  implicit none
  integer :: n, i
  integer(8) :: x, p(0:50) = 0_8, m(0:50) = 0_8
  p(0) = 1_8
  m(0) = 1_8
  read(*,*) n, x
  do i = 1, n
    p(i) = 2_8*p(i-1)+1_8
    m(i) = 2_8*m(i-1)+3_8
  end do
  write(*,'(i0)') eat(n,x)
contains
  recursive function eat(n,x) result(ret)
    integer, intent(in) :: n
    integer(8), intent(in) :: x
    integer(8) :: ret
    if (n == 0) then
      ret = 1_8
    else if (x == 1) then
      ret = 0_8
    else if (x == m(n)) then
      ret = p(n)
    else if (x == m(n-1)+1_8 .or. x == m(n-1)+2_8) then
      ret = p(n-1)+x-m(n-1)-1_8
    else if (x <= m(n-1)) then
      ret = eat(n-1,x-1_8)
    else
      ret = p(n-1)+1_8+eat(n-1,x-m(n-1)-2_8)
    end if
  end
end program christmas

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};


int main() {
    int N; cin >> N;
    vector<int> A(N);

    rep(i,N){
        cin >> A[i];
    }

    int count=1;
    for(auto a: A){
        if(a==count){
            count++;
        }
    }
    int ans = (N-count+1 != N) ? N-count+1 : -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>    // for pair
using namespace std;

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

ll gcd(ll a, ll b){ if (a % b) return (gcd(b, a % b)); else return b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

signed main()
{
    cout << fixed << setprecision(9);

    int N, M; cin >> N >> M;
    vector<ll> A(N); rep(i, N) cin >> A[i];

    ll total = 0;
    rep(i, N) total += A[i];
//    ll limit = total / (4 * M);
//       limit * 4 * M = total
    sort(A.begin(), A.end());

    if (A[N - M] * 4 * M >= total) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

if S[0: (N - 1) // 2] == S[0: (N - 1) // 2][::-1] and S[(N + 3) // 2 - 1: ] == S[(N + 3) // 2 - 1: ][::-1] and S == S[::-1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define min(a,b) ((a)<(b)?a:b);


int main(){
  int n;
  scanf("%d",&n);
  int a[n+1],i;
  for(i=0;i<n+1;i++){
    scanf("%d",&a[i]);
  }
  long int ans=0;
  long int rem=0;
  for(i=0;i<n;i++){
    int temp;
    scanf("%d",&temp);
    ans+=min(a[i],rem);
    a[i]-=min(a[i],rem);
    ans+=min(a[i],temp);
    rem=temp-min(a[i],temp);
    a[i]-=min(a[i],temp);
  }
  ans+=min(a[n],rem);

  printf("%ld",ans);
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 +7;
//constexpr int mod2 = 998244353;
constexpr int MAXNe5 = 1e5 +7;
constexpr int MAXNe6 = 1e6 + 7;
#pragma region 
inline long long read()
{
	char c = getchar();long long flag = 1, ans = 0;
	while(c < '0' || c > '9'){if(c == '-')flag = -1; c = getchar();}
	while(c >= '0' && c <= '9'){ans = ans * 10 + c - '0'; c = getchar();}
	return (ans * flag);
}
#pragma endregion
// C'est la vie
double eps = 1e-12;
int main() {
	long long a, b, c;
    cin >> a >> b >> c;
    // cout << sqrt(a) << " " << sqrt(b) << " " << sqrt(c) << endl;
    long long tmp = __gcd(__gcd(a, b), c);
    a /= tmp;
    b /= tmp;
    c /= tmp;
    if(c - a - b < 0) cout << "No" << endl;
    else {
        long long tmp = (c - a - b) * (c - a - b);
        if(tmp - 4 * a * b > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    #ifndef ONLINE_JUDGE
    system("pause");
    #endif
}

Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>

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

	if(s[0]==s[1] || s[1]==s[2]|| s[2]==s[3])
		std::cout<<"Bad"<<std::endl;
	else
		std::cout<<"Good"<<std::endl;

	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;



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

   int n;
   cin >> n;
   vector<ll> a(n),b(n);
   ll sa=0,sb=0;
   rep(i,n) {
       cin >> a[i] >> b[i];
       sa+=a[i];
       sb+=b[i];
   }
   sort(a.begin(),a.end());
   sort(b.begin(),b.end());
   if (n%2==1) cout << b[n/2]-a[n/2]+1 << endl;
   else {
       cout << b[n/2-1]+b[n/2]-(a[n/2-1]+a[n/2])+1 << endl;
   }

    return 0;
}


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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '

#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
ll n,a[MAXN],ans[MAXN],sum;
int main()
{
    fast_io;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    for(ll i=0;i<n;i+=2)sum+=a[i];
    for(ll i=1;i<n;i+=2)sum-=a[i];
    ans[0]=sum;
    ans[n-1]=(a[n-1]-sum/2)*2;
    for(ll i=n-2;i>0;i--){
        ans[i]=(a[i]-ans[i+1]/2)*2;
    }
    for(ll i=0;i<n;i++)cout<<ans[i]<<sep;
    return 0;
}


Measured memory_bytes: 6272
fun main(args: Array<String>) {
    val abc = (1..3).map { readLine()!!.map { it - 'a' } }
    val cnt = Array(3) { 0 }
    var turn = 0
    while (abc[turn].getOrNull(cnt[turn]) != null) {
        val nextTurn = abc[turn].get(cnt[turn])
        cnt[turn]++
        turn = nextTurn
    }
    println('A' + turn)
}


Measured memory_bytes: 35616
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int a;
  cin >> a;
  double t;
  cin >> t;
  int b = round(t * 100);
  cout << a * b / 100 << "\n";
}



Measured memory_bytes: 3732
import java.util.*;

public class Main {
    static int[] array;
    static int n;
    static int m;
    static int q;
    static int[] a;
    static int[] b;
    static int[] c;
    static int[] d;
    static int ans = 0;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        q = sc.nextInt();
        
        array = new int[n];
        
        a = new int[q];
        b = new int[q];
        c = new int[q];
        d = new int[q];
        for (int i = 0; i < q; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        
        dfs(0, 1);
        
        System.out.println(ans);
    }
    
    public static void dfs(int index, int num) {
        // 終了条件
        if (index == n) {
            int score = 0;
            for (int i = 0; i < q; i++) {
                if (array[b[i]] - array[a[i]] == c[i]) score += d[i];
            }
            ans = Math.max(ans, score);
            return;
        }
        
        // array: 全てが1以上m以下の、広義単調増加の数列
        for (int i = num; i <= m; i++) {
            array[index] = i;
            dfs(index + 1, i);
        }
    }
}

Measured memory_bytes: 36964