akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	cin >> n;
	stack<string>s;
	string t;
	for (int i = 0; i < n; i++) {
		cin >> t;
		if (s.empty())s.push(t);
		else if (s.top() == "A"&&t == "Un") {
			s.pop();
		}
		else s.push(t);
	}
	if (s.empty())cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int f(int a[],int n){
    int dp[n];
    dp[n-1]=0;
    dp[n-2]=abs(a[n-2]-a[n-1]);
    for(int i=n-3;i>=0;i--){
        int x=dp[i+1]+abs(a[i]-a[i+1]);
        int y=dp[i+2]+abs(a[i]-a[i+2]);
        dp[i]=min(x,y);
        }
    return dp[0];
}

int main() {
    

        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
        cin>>a[i];
        
        cout<<f(a,n)<<endl;
        
    
	return 0;
}

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

typedef long long ll;
typedef pair <ll, ll> pii;

#define NL cout<<"\n";
#define ALL(a) a.begin(), a.end()
#define DBG(a) cout<< #a <<" --> "<<(a)<<endl;
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

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

const ll N=3e5+5;
const ll oo=1e9+7;
ll x[N],y[N];
ll yval[N];
int32_t main()
{
    FastIO;
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<n;i++)
    {
        cin>>x[i];
    }
    for(ll i=0;i<m;i++)
        cin>>y[i];
    sort(x,x+n);
    sort(y,y+m);
    ll sum = 0;
    for(ll i=1;i<m;i++)
    {
        yval[i] =( y[i] - y[i-1]) *( (i)*(m-i)%oo) %oo;
        sum+=yval[i];
        sum%=oo;
    }
    ll ans=0;
    for(ll i=1;i<n;i++)
    {
        ans += sum * ( (x[i]-x[i-1]) *( (i)*(n-i) %oo) %oo) %oo;
        ans%=oo;
    }
    ans+=oo;
    ans%=oo;
    cout<<ans<<"\n";


}


Measured memory_bytes: 5120
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	b := make([]int, n-1)

	for i := 0; i < n-1; i++ {
		fmt.Scan(&b[i])
	}

	a := b[0] + b[len(b)-1]
	for i := 1; i < len(b); i++ {
		if b[i] > b[i-1] {
			a += b[i-1]
		} else {
			a += b[i]
		}
	}

	fmt.Println(a)
}


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

using namespace std;

using ll = long long;

vector<vector<ll>> Combination(ll n) {
    vector<vector<ll>> comb(n + 1, vector<ll>(n + 1));
    for (int i = 0; i <= n; ++i) comb[i][0] = comb[i][i] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
    return comb;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << setprecision(8) << setiosflags(ios::fixed); // printf("%.4f", x);

    ll n, a, b;
    cin >> n >> a >> b;

    vector<ll> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());

    ll res = 0;
    auto comb = Combination(n);
    if (v[0] == v[a - 1]) {
        ll num = 0;
        for (int i = 0; i < n; ++i) if (v[0] == v[i]) ++num;
        for (ll i = a; i <= b; ++i)
            res += comb[num][i];
    }
    else {
        ll num = 0, idx = -1;
        for (int i = 0; i < n; ++i)
            if (v[a - 1] == v[i]) {
                ++num;
                if (idx == -1) idx = i;
            }
        res = comb[num][a - idx];
    }

    double ave = accumulate(v.begin(), v.begin() + a, 0ll) / (double)a;
    cout << ave << endl;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

import collections
dict_D = dict(collections.Counter(D))
dict_T = dict(collections.Counter(T))

for k, v in dict_T.items():
    if v <= dict_D.get(k, 0):
        pass
    else:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 131408
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}



Measured memory_bytes: 256
//2020年3月21日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


ll gcd(ll a,ll b){
	ll r = a%b;
	while (r != 0) {
		a = b;
		b = r;
		r = a%b;
	}
	return b;
}


int main(){
	int n;
	cin >> n;
	int ans = 0;
	rep1(i,n)rep1(j,n)rep1(k,n){
		ans+=gcd(gcd(i,j),k);
	}
	prints(ans);

	return 0;
}



Measured memory_bytes: 3228
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    int n;
    cin >> n;
	    
    //処理
  if(n==3 || n==5 || n==7) cout << "YES" << ENT;
    else cout << "NO" << ENT;
    //出力
    return 0;
}

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


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e6 + 10 ;
const ll INF = 1e18 + 10 ;

int main(){
    int n ;
    cin >> n ;
    vector<vector<int> > a(n, vector<int>(n, -1)) ;
    for(int i = 0; i < n; i++){
        int m ;
        cin >> m ;
        for(int j = 0; j < m; j++){
            int x , y ;
            cin >> x >> y ;
            x--;
            a[i][x] = y ;
        }

    }
    for(int i = 0; i < n; i++){
        debug() << range(a[i].begin(), a[i].end() );
    }
    int ans = 0 ;
    for(int mask = 1; mask < (1 << n); mask++){
        vector<int> honest(n) ;
        for(int i = 0; i < n; i++){
            if ( mask & (1 << i) ){
                honest[i] = 1 ;
            }
        }
        debug() << imie(honest) ;
        vector<int> flag(n, -1) ;
        bool ok = true ;
        for(int i = 0; i < n; i++){
            if ( honest[i] ){
                for(int j = 0; j < n; j++){
                    if ( a[i][j] == -1 ) continue ;
                    else if ( flag[j] == a[i][j] ) continue ;
                    else if ( flag[j] == -1 ){
                        flag[j] = a[i][j] ;
                        if ( flag[j] != honest[j] ) ok = false ;
                    }
                    else ok = false ;
                }
            }
        }
        if ( ok ){
            int cnt = 0 ;
            for(int i = 0; i < n; i++){
                if ( honest[i] ) cnt++ ;
            }
            debug() << "TEST " << imie(honest) ;
            ans = max(ans, cnt) ;
        }
    }
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 1000000

int main(void)
{
	int i, n;
	scanf("%d",&n);
	double a[n];
	
	for(i = 0; i < n; i++)
	{
		scanf("%lf",&a[i]);
	}
	double b[n+1];
	for(i = 0; i <= n; i++)
	{
		scanf("%lf",&b[i]);
	}
	double c[n+1][n+1];
	double d[n+1];
	c[0][0]=b[0];
	d[0]=a[0]+b[0];
	
	for(i = 1; i <= n; i++)
	{
		c[i][i] = b[i];
		c[i-1][i] = a[i-1]+(b[i-1]+b[i])*2;
		d[i] = d[i-1]+a[i]+b[i];
	}
	int j , k;
	double e, f;
	for(i = 1;i < n; i++)
	{
		for(j = 0; j < n-i; j++)
		{
			e = c[j][j] + c[j+1][i+j+1];
			for(k = j; k <i+j; k++)
			{
				f = c[j][k+1]+c[k+2][i+j+1];
				if(e>f) 
				{
					e = f;
				}
			}
			c[j][i+j+1] = e + d[i+j] - d[j-1] + b[i+j+1];
		}
	}
	printf("%lf\n",c[0][n]);
	return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int N,K;
string S;
int dp[301][301][301];

int main(){
  cin>>S>>K;
  N=S.size();

  rep(i,301)rep(j,301)rep(k,301)dp[i][j][k]=-100000;
  rep(i,N+1){
    rep(k,K+1)dp[i][i][k]=0;
    if(i<N)rep(k,K+1)dp[i][i+1][k]=1;
  }

  repl(len,2,N+1){
    rep(l,N){
      ll r=l+len;
      if(r>N)continue;
      rep(k,K+1){
        maxch(dp[l][r][k],dp[l][r-1][k]);
        maxch(dp[l][r][k],dp[l+1][r][k]);
        if(S[l]==S[r-1])maxch(dp[l][r][k],dp[l+1][r-1][k]+2);
        if(k>0){
          maxch(dp[l][r][k],dp[l+1][r-1][k-1]+2);
          maxch(dp[l][r][k],dp[l][r][k-1]);
        }
      }
    }
  }



  cout<<dp[0][N][K]<<endl;
  return 0;
}


Measured memory_bytes: 106752
#include <stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs(void);
void dfs_visit(int);


int main(){
  int u, v, k, i, j;

  scanf("%d", &n);
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++) M[i][j] = 0;
  }

  for(i=0 ; i<n ; i++){
    scanf("%d %d", &u, &k);
    u--;
    for(j=0 ; j<k ; j++){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;

  for(v=0 ; v<n ; v++){
    if(M[u][v] == 0) continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }

  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;

  for(u=0 ; u<n ; u++) color[u] = WHITE;
  tt = 0;

  for(u=0 ; u<n ; u++){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(u=0 ; u<n ; u++){
    printf("%d %d %d\n", u+1, d[u], f[u]);
  }
}

Measured memory_bytes: 636
import math
def factrization_prime(number):
    factor = {}
    div = 2
    s = math.sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor[div] = div_cnt
        div += 1
    if number > 1:
        factor[number] = 1
    return factor

N = int(input())
v = list(factrization_prime(N).values())
ans = 0
for i in range(len(v)):
    k = 1
    while(True):
        if v[i] >= k:
            v[i] -= k
            k += 1
            ans += 1
        else:
            break
print(ans)


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

int main()
{
	ll x;
	cin >> x;
	ll y = x%100;
	ll z = (y+4)/5;
	if(x/100>=z)
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> s, t;
  rep(i,n) {
    cin >> a[i];
    if (a[i] < 0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }

  int S = s.size();
  int T = t.size();
  bool ok = false;
  if (S > 0) {
    if (n == k) ok = (T%2==0);
    else ok = true;
  } else {
    ok = (k%2==0);
  }

  mint ans = 1;
  if (!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i,k) ans *= a[i];
  } else {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (k%2 == 1) {
      ans *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while (s.size() >= 2) {
      ll x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.push_back(x);
    }
    while (t.size() >= 2) {
      ll x = t.back(); t.pop_back();
      x *= t.back(); t.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i,k/2) ans *= p[i];
  }

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


Measured memory_bytes: 6416
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,k;
  cin>>n>>k;
  deque<ll> q;
  rep(i,n){
    ll v;
    cin>>v;
    q.push_back(v);
  }
  
  ll ans = 0;
  rep(r,k+1){
    rep(l,k+1){
      rep(d,k+1){
        deque<ll> qq = q;
        priority_queue<ll,vector<ll>,greater<ll>> pq;
        if((r+l)>(int)qq.size()) continue;
        if((r+l+d)>k) continue;
        // show(1);
        rep(i,r){
          pq.push(qq.front());
          qq.pop_front();
        }
        rep(i,l){
          pq.push(qq.back());
          qq.pop_back();
        }
        rep(i,d){
          if(pq.size())
          if(pq.top()<0)pq.pop();
        }
        ll tmp = 0;
        while(!pq.empty()){
          tmp+=pq.top();
          pq.pop();
        }
        // show(tmp);
        maxs(ans,tmp);
      }
    }
  }
  print(ans);
  return 0;
}

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

int main(){
  int X;
  cin >> X;
  int diceA[X],diceB[X];
  int zoro=0;
  bool me=false;
  
  for (int i=0;i<X;i++){
    cin >> diceA[i] >>diceB[i];
    if(diceA[i] == diceB[i]){
      zoro++;
      if(zoro >= 3){
        me = 1;
      }
    }else{
      zoro = 0;
      }
    }
  
  if(me){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 3628
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))
    
m = []
a = []
r = []
c = []
h = []
for i in s:
    if i[0] == 'M':
        m.append(i)
    if i[0] == 'A':
        a.append(i)
    if i[0] == 'R':
        r.append(i)
    if i[0] == 'C':
        c.append(i)
    if i[0] == 'H':
        h.append(i)
        
check = [0 for i in range(5)]
check[0] = len(list(set(m)))
check[1] = len(list(set(a)))
check[2] = len(list(set(r)))
check[3] = len(list(set(c)))
check[4] = len(list(set(h)))


import itertools
ans = 0
for i in itertools.combinations(check, 3):
    ans += i[0]*i[1]*i[2]
    
print(ans)

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

#define	MOD 1000000007

int	main() {
	int N;
	long T;
	cin >>N >>T;
	long S=0;
	long t0=-T;
	for (int i=0; i<N; i++) {
		long t;
		cin >>t;
		S +=min(T, t-t0);
		t0=t;
	}
	cout <<S <<endl;
	return 0;
}



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

int main (){
	int k;
	scanf ("%d", &k);
	char str[101];
	scanf ("%s", &str);
	
	int len = strlen (str);
	if (len <= k){
		printf ("%s", str);
	}	
	else {
		for (int i = 0; i < k; i++){
			printf ("%c", str[i]);
		}
		puts ("...");
	}
	
	return 0;
}

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

int main() {
	string str;
	cin>>str;
	sort(str.begin(),str.end());
	bool kawa=0;
	for(int i=1,n=1,now=0;i<=str.size()&&!kawa;i++){
		if(str[now]!=str[i]&&n%2==1)kawa=1;
		else if(str[now]!=str[i]){
			n=1;
			now=i;
		}
		else n++;
	}
	if(kawa)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int n,m;
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++) n-=read();
	if(n<0) printf("-1\n");
	else printf("%d\n",n);
	return 0;
}


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

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

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

    int tmp, d = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            tmp = abs(a.at(i) - a.at(j));
            if (tmp > d) {
                d = tmp;
            }
        }
    }
    
    cout << d << endl;
}

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

using namespace std;

#define ll long long

int main() {
  string s; cin >> s;
  int count=0;
  for(int i=0; i<3; ++i) {
    if(s[i]!='R') continue;
    int ccount=1;
    for(int j=i+1; j<3; ++j) {
      if(s[j]=='R') {
        ++ccount;
      } else {
        break;
      }
    }
    if(ccount > count) {
      count = ccount;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    string S; cin >> S;
    int N = S.size();
    ll dp[100100][14];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1LL;
    rep1(i, N) {
        if(S[i - 1] == '?') {
            rep(k, 10) {
                rep(j, 13) {
                    int l = 10 * j + k;
                    l %= 13;
                    dp[i][l] += dp[i - 1][j];
                    dp[i][l] %= mod;
                }
            }
        } else {
            int k = S[i - 1] - '0';
            rep(j, 13) {
                int l = 10 * j + k;
                l %= 13;
                dp[i][l] += dp[i - 1][j];
                dp[i][l] %= mod;
            }
        }
    }
    ll ans = dp[N][5] % mod;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11472
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+5;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
in main()
{
string s;
cin>>s;
int d=(s[0]-'0')*10+(s[1]-'0');
int d2=(s[2]-'0')*10+(s[3]-'0');
if(!((1<=d&&d<=12)||(1<=d2&&d2<=12)))
{
	cout<<"NA\n";
	return 0;
}
if((1<=d&&d<=12)&&(1<=d2&&d2<=12))
{
	cout<<"AMBIGUOUS\n";
	return 0;
}
if(1<=d&&d<=12)
{
	cout<<"MMYY\n";
	return 0;
}
cout<<"YYMM\n";


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int main(){
  int h, w, n;cin>>h>>w>>n;
  int ans=0;
  int s=h, t=w;
  while(n>0){
    // cout<<s<<" "<<t<<" "<<n<<endl;
    ans++;
  	if(s>t){
      n-=s;t--;
    }else{
      n-=t;s--;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in(argv[1]);
    // cin.rdbuf(in.rdbuf());
    int N, A, B;
    cin >> N >> A >> B;
    int ans = N * A;
    if(ans > B) {
        ans = B;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.*;
     
    class Main {
    public static void main(String[] args){
     
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long ans = 1;
    for(int i = 1;i <= n;i++){
      ans *= i;
      ans = ans % (1000000000+ 7);
    }
     
    System.out.println(ans);
     
    }
    }

Measured memory_bytes: 20820
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
	// freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    int n,a,b;
    while(cin>>n>>a>>b)
    {
    	if(n==1)
    	{
    		if(a!=b)
    		{
    			cout<<0<<endl;
    		}else
    		{
    			cout<<1<<endl;
    		}
    	}else
    	{
    		if(a<=b)
    		{
    			if(n==2)
    			{
    				cout<<1<<endl;
    			}
    			ll ans=1ll*(n-2)*b-1ll*(n-2)*a+1ll;
    			cout<<ans<<endl;
    		}else
    		{
    			cout<<0<<endl;

    		}
    	}
    }
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 504
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    ll n,k;
    cin>>n>>k;
    ll a[114514]={};
    ll s[114514]={};
    ll sb[114514]={};
    s[0]=0;
    sb[0]=0;
    
    for(int i=1;i<=n;i++){
        cin>>a[i];
        s[i]=s[i-1];
        s[i]+=a[i];  
        sb[i]=sb[i-1];
        sb[i]+=max((ll)0,a[i]); 
    }
    ll ans=0;
    for(int i=1;i<=n-k+1;i++){
        ll m=sb[i-1]-sb[0]+max((s[i+k-1]-s[i-1]),(ll)0)+sb[n]-sb[i+k-1];
        ans=max(ans,m);
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int n,l;
	cin >> n >> l;
	int mint=300;
	int ans=0;
	REP(i,n){
		if(abs(mint)>abs(l+i)) mint=l+i;
	}
	REP(i,n){
		ans+=l+i;
	}
	cout << ans-mint << endl;
	
//////////////////////////////////////////////
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int binary_search(const vector<int> &xs, const int val, bool f(const vector<int> &, int, int)) {
    int left = -1, right = (int) xs.size(), mid;
    while (right - left > 1) {
        mid = left + (right - left) / 2;
        if (f(xs, mid, val)) right = mid;
        else left = mid;
    }

    return right;
}

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

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

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    for (int i_b = 0; i_b < N; i_b++) {
        // lower_bound
        int i_a = binary_search(a, b[i_b], [](const vector<int> &xs, int ind, int val) {
                return xs[ind] >= val;
        });
        // upper_bound
        int i_c = binary_search(c, b[i_b], [](const vector<int> &xs, int ind, int val) {
                return xs[ind] > val;
        });
        ans += ((ll) i_a) * ((ll) (c.size() - i_c));
        
        // auto lb1 = lower_bound(a.begin(), a.end(), b[i_b]);
        // auto lb2 = upper_bound(c.begin(), c.end(), b[i_b]);
        // ans += (lb1 - a.begin()) * (c.end() - lb2);

        // cout <<i_a << "," << (((int) c.size()) - i_c) << " - "
        //     << (lb1 - a.begin()) << "," << (c.end() - lb2) << endl;
    }

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


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<bitset>
using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> r(n);
    vector<int> l(n);
    int m = 1e9;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        v[i] = a;
    }
    
    for (int i = 0; i < n; i++)
    {
        if(i>0){
            r[i] = r[i-1]+v[i];
        }else{
            r[i] = v[i];
        }
    }
    
    for (int i = n-1; -1 < i; i--)
    {
        if(i==n-1){
            l[i] = 0;
        }else{
            l[i] = l[i+1]+v[i+1];
        }
    }
    
    for (int i = 0; i < n; i++)
    {
        m = min(m,abs(r[i]-l[i]));
    }

    cout << m <<endl;
    
}


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

namespace Tasks
{
    public class D
    {
        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 = Scanner.Scan<int>();
            var A = Scanner.ScanEnumerable<long>().ToArray();
            var Q = Scanner.Scan<int>();
            var answer = A.Sum();
            var dict = new Dictionary<long, int>();
            foreach (var x in A)
            {
                if (!dict.ContainsKey(x)) dict[x] = 0;
                dict[x]++;
            }
            for (var i = 0; i < Q; i++)
            {
                var (B, C) = Scanner.Scan<int, int>();
                if (!dict.ContainsKey(B)) dict[B] = 0;
                if (!dict.ContainsKey(C)) dict[C] = 0;
                dict[C] += dict[B];
                answer += (C - B) * dict[B];
                dict[B] = 0;
                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>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 55648
nums = list(map(int, list(input().rstrip())))
    
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1, f+'+'+str(nums[i+1]), sum+nums[i+1])
        dfs(i+1, f+'-'+str(nums[i+1]), sum-nums[i+1])
        
dfs(0, str(nums[0]), nums[0])



Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <queue>
using namespace std;


int GetDigit(int n){
	int i = 0;

	while(n > 0){
		n /= 10;
		i++;
	}

	return i;
}
 
int main(){
	vector<int> a(3);
	int n, tmp;

	cin >> n;

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

		if(a[0]*a[0] + a[1]*a[1] == a[2]*a[2]){
			cout << "YES" <<endl;
		}else{
			cout << "NO" <<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s.compare("SUN")==0)
        cout<<7;
    else if(s.compare("MON")==0)
        cout<<6;
    else if(s.compare("TUE")==0)
        cout<<5;
    else if(s.compare("WED")==0)
        cout<<4;
    else if(s.compare("THU")==0)
        cout<<3;
    else if(s.compare("FRI")==0)
        cout<<2;
    else
        cout<<1;
    return 0;
}


Measured memory_bytes: 384
class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2)
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres)
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b%a, a)

n = int(input())
a = list(map(int, input().split()))
s = SegmentTree(n, gcd)
for i in range(n):
    s.update(i, a[i])

ans = 1
for i in range(n):
    left = s.query(0, i)
    right = s.query(i+1, n)
    res = gcd(left, right)
    if ans < res:
        ans = res
print(ans)

Measured memory_bytes: 117784
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#define ls id<<1
#define rs id<<1|1
using namespace std;
typedef long long ll;
int n,d;
int ans,sum;
int x[50][50];

int main(){
	cin>>n>>d;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=d;++j){
			cin>>x[i][j];
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			if(i==j)continue;
			int tmp=0;
			for(int k=1;k<=d;++k){
				tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			int a=sqrt(tmp);
			if(a*a==tmp)ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n;
	ll ans=0LL;
	cin >>n;
	int at=0;
	int a,b;
	vector<ll>c(n+1,0LL);
	vector<vector<int>>d(3,vector<int>(n,0));
	rep(i,3){
		rep(j,n){
			cin >> d[i][j];
		}
		sort(all(d[i]));
	}

	rep(i, 3)
	{
		rep(j, n)
		{
		//	cout << d[i][j]<<" ";
		}
	//cout<<endl;
	}

	rep(i,n){
		a = distance(d[0].begin(), (lower_bound(all(d[0]), d[1][i])));
		//if(d[1][i]==d[0][a-1]){a--;}
		b = distance(upper_bound(all(d[2]), d[1][i]), d[2].end());
		//if(d[1][i]==d[2][b]){
		//	b++;
		//}
			ans += (ll)a *b;
		//	cout<<a<<" "<<b<<endl;
	}
	cout<<ans<<endl;
}

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

#define ARRAY_SIZE 10
#define STRING_SIZE 10

int main()
{
	char inputA[5];
	int dayNumber = 0;
	char weekDays[ARRAY_SIZE][STRING_SIZE] =
	{
		"MON",
		"TUE",
		"WED",
		"THU",
		"FRI",
		"SAT",
		"SUN"
	};
	scanf("%s", &inputA);

	for (int i = 0; i < sizeof(weekDays); i++)
	{
		dayNumber++;
		if (strcmp(weekDays[i], inputA) == 0)
		{
			break;
		}
	}

	if (dayNumber == 7)
	{
		printf("7 \n");
		return 0;
	}

	printf("%d \n", 7 - dayNumber);
	return 0;
}

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

int main(){
	string S;
	cin>>S;
	int backet[26]={0};
	for(int i=0;i<S.length();++i){
		int tmp;
		tmp=S[i]-'a';
		backet[tmp]++;
	}
	int ans=-1;
	for(int i=0;i<26;++i){
		if (backet[i]==0){
			ans=i;
			break;
		}
	}
	if (ans==-1) cout<<"None"<<endl;
	else{ 
		char c='a'+ans;
		cout<<c<<endl;
	}
}


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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ull MOD = 998244353;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-9;

int N;
string s;

auto f = [](int x, int y){
    if(x > y) swap(x, y);
    if(x == -1) return y;
    if(s[y-x-1] == '0') return x;
    else return y;
};

int main(){
    cin >> N >> s;
    vector<int> p(1<<(N+1));
    for(int i=0;i<(1<<N);i++){
        cin >> p[i];
        p[i+(1<<N)] = p[i];
    }
    vector<vector<int> > dp(N+1, vector<int>(1<<(N+1),-1));  // dp[k][i] 人iから数えて2**k人のトーナメントの勝者
    for(int i=0;i<(1<<(N+1));i++){
        dp[0][i] = p[i];
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<(1<<(N+1))-(1<<k);i++){
            dp[k+1][i] = f(dp[k][i],dp[k][i+(1<<k)]);
        }
    }
    for(int i=0;i<(1<<N);i++){
        cout << dp[N][i] << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<bool> use(1e6 + 1, false);
    map<ll, ll> cnt;
    rep(i, N) {
        ll a = A[i];
        if (cnt.count(a) == 0) {
            for (ll j = 2 * a; j <= 1e6; j += a) {
                use[j] = true;
            }
        }
        cnt[a]++;
    }
    ll ans = 0;
    rep(i, N) {
        ll a = A[i];
        if (cnt[a] >= 2) continue;
        if (!use[a]) ans++;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 17392
#include "bits/stdc++.h"

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 999999999
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//================================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	vector<int>vec(3);

	REP(i, 3) {
		cin >> vec[i];
	}

	SORT(vec);

	vector<int>vec2 = {5, 5, 7};

	if (vec == vec2) {
		cout << "YES" << "\n";
	} else {
		cout << "NO" << "\n";
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a[N];
  int Alice = 0;
  int Bob = 0;
  for(int i=0;i<N;i++) cin >> a[i];
  sort(a, a+N, greater<int>());
  for(int i=0;i<N;i++){
    if(i%2==0) Alice += a[i];
	else Bob += a[i];
  }
  cout << Alice-Bob << endl;
  return 0;
}


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

using namespace std;

using i64 = int64_t;

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


signed main(){
    i64 n, m;
    cin >> m >> n;
    vector<i64> cost(m), power(m);
    for(i64 i = 0; i < m; ++i)
        cin >> cost[i] >> power[i];

    vector<i64> time(n), required(n);
    for(i64 i = 0; i < n; ++i)
        cin >> time[i] >> required[i];

    vector<i64> cost_sum(m + 1, 0), power_sum(m + 1, 0), power_diff_sum(m, 0);
    for(i64 i = 0; i < m; ++i){
        cost_sum[i + 1] = cost_sum[i] + cost[i];
        power_sum[i + 1] = power_sum[i] + power[i];
        if(i != m - 1)
            power_diff_sum[i + 1] = power_diff_sum[i] + abs(power[i + 1] - power[i]);
    }

    vector<vector<i64>> abs_sums(m + 1, vector<i64>(m + 1, 0));
    for(i64 j = 0; j <= m; ++j){
        for(i64 k = 0; k <= m; ++k){
            if(k - j >= 2)
                abs_sums[j][k] = abs(power[k - 1] - power[k - 2]);
        }
    }

    vector<vector<i64>> dp(n + 1, vector<i64>(m + 1, -INF));
    dp[0][0] = 0;
    i64 req = 0;
    for(i64 i = 0; i < n; ++i){
        req = max(req, required[i]);
        // for(i64 j = 0; j <= m; ++j){

            i64 now_power = -INF; // dp[i][j];
            i64 now_power_2 = -INF;
            i64 now_power_3 = -INF;
            for(i64 k = 0; k <= m && time[i] >= cost_sum[k]; ++k){
                now_power_3 = dp[i][k];
                if(k){
                    now_power += power[k - 1];
                    now_power_2 += power[k - 1];
                }
                if(k >= 2){
                    now_power += abs(power[k - 1] - power[k - 2]);
                }
                /*
                if(j != k)
                    now_power += power[k - 1];
                if(k - j >= 2)
                    now_power += abs_sums[j][k];
                */
                i64 max_power = max({now_power, now_power_2, now_power_3});
                if(max_power >= req)
                    dp[i + 1][k] = max(dp[i + 1][k], max_power);


                now_power = max(now_power, now_power_2);
                now_power_2 = now_power_3;
                now_power_3 = -INF;
            }
        // }
    }

    for(i64 i = 0; i <= m; ++i){
        i64 money = time.back() - cost_sum[i];
        if(dp.back()[i] >= req){
            cout << money << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}



Measured memory_bytes: 96848
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}


int main(){
    ll A, B, N;
    cin >> A >> B >> N;
    if(N < B){
        cout << floor(A * N / B) - A * floor(N / B) << endl;
    }else{
        cout << floor(A * (B - 1) / B) - A * floor((B - 1) / B) << endl;
    }
}



Measured memory_bytes: 3784
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAX_WID = 35;
const int INF = 1<<24;
int H, W, S;
int T;

bool visited[MAX_WID][MAX_WID][MAX_WID][MAX_WID];
pair<int,int> memo[MAX_WID][MAX_WID][MAX_WID][MAX_WID];
int us[MAX_WID][MAX_WID];
int accum[MAX_WID][MAX_WID];

// [x1,x2), [y1, y2)
int sum(int x1, int y1, int x2, int y2){
	return accum[x2][y2] + accum[x1][y1] - accum[x1][y2] - accum[x2][y1];
}

void init(){
	memset(accum, 0, sizeof(accum));
	memset(visited, 0, sizeof(visited));

	for(int i=0; i<H; i++)for(int j=0; j<W; j++){
		accum[i+1][j+1] = accum[i+1][j] + accum[i][j+1] - accum[i][j] + us[i][j];
	}

	T = accum[H][W] - S;
}

pair<int,int> rec(int x1, int y1, int x2, int y2){
	if(visited[x1][y1][x2][y2]) return memo[x1][y1][x2][y2];
	visited[x1][y1][x2][y2] = true;
	pair<int,int>& ret = memo[x1][y1][x2][y2];
	if(sum(x1,y1,x2,y2) < T){
		return ret = make_pair(-INF,-INF);
	}
	ret = make_pair(1,sum(x1,y1,x2,y2));

	for(int x=x1+1; x<x2; x++){
		pair<int,int> t1 = rec(x1, y1, x, y2), t2 = rec(x, y1, x2, y2);
		pair<int,int> t(t1.first + t2.first, min(t1.second, t2.second));
		ret = max(ret, t);
	}

	for(int y=y1+1; y<y2; y++){
		pair<int,int> t1 = rec(x1, y1, x2, y), t2 = rec(x1, y, x2, y2);
		pair<int,int> t(t1.first + t2.first, min(t1.second, t2.second));
		ret = max(ret, t);
	}

	return ret;
}

void solve(){
	init();
	pair<int,int> ans = rec(0,0,H,W);
	printf("%d %d\n", ans.first, S - (accum[H][W] - ans.second));
}

int main(){
	while(scanf("%d%d%d",&H,&W,&S),H){
		for(int i=0; i<H; i++)for(int j=0; j<W; j++){
			scanf("%d", us[i]+j);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 0