akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
	int N;
	int k[10000];
	while (true){
		cin >> N;
		if (N == 0){
			break;
		}
		int cnt = 0;
		int cnt0 = 0;
		int total = 0;
		bool flag = 0;
		for (int i = 0; i < N; i++){
			cin >> k[i];
			if (k[i]>=1) cnt++;
			if (k[i]>1) flag = 1;
			if (k[i] == 0) cnt0++;
			total += k[i];
		}
		//if (cnt >= N){
			if (flag) cout << N + 1 - cnt0 << endl;
			else if (total < N + 1-cnt0){
				cout << "NA\n";
			}
			else cout << N + 1-cnt0 << endl;
		//}
		//else cout << "NA\n";
	}
	return 0;
}

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

bool is_prime(int x){
  for(int i=2;i*i<=x;i++){
    if(x%i==0) return true;
  }
  return false;
}

int main(void){
  int x; cin >> x;
  int p = x;
  while(is_prime(p)) p++;
  printf("%d",p);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define CYES cout << "Yes" \
                  << "\n";
#define CNO cout << "No" \
                 << "\n";
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const string MM = " ";

int main()
{
    int n;
    cin >> n;
    int m[10][10] = {};
    for (int i = 1; i < n + 1; i++)
    {
        int ms = i / pow(10, (int)log10(i));
        int ls = i % 10;
        m[ms][ls]++;
    }
    int ans = 0;
    for (size_t i = 0; i < 10; i++)
    {
        for (size_t j = 0; j < 10; j++)
        {
            ans += m[i][j] * m[j][i];
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 512
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *
def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1/f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret
def bunsu(n):
    ret = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            tmp = 0
            while(True):
                if n % i == 0:
                    tmp += 1
                    n //= i
                else:
                    break
            ret.append((i, tmp))

    ret.append((n, 1))
    return ret

def solve():
    a,b = getList()
    print(a*b)
def main():
    # n = getN()
    # for _ in range(n):
    solve()
if __name__ == "__main__":
    solve()


Measured memory_bytes: 72580
// 2011/09/29 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		int m;
		cin >> m;
		if(n==0&&m==0)
			break;

		int G[500][500];
		for(int i=0; i<n; i++)
			for(int j=0; j<n; j++)
				G[i][j] = 0;

		for(int i=0; i<m; i++){
			int a, b;
			cin >> a >> b;
			G[a-1][b-1] = G[b-1][a-1] = 1;
		}

		for(int i=0; i<n; i++){
			if(G[0][i]!=1)
				continue;

			for(int j=1; j<n; j++)
				if(G[i][j]==1&&G[0][j]==0)
					G[0][j] = 2;
		}

		int cnt = 0;
		for(int i=1; i<n; i++)
			if(G[0][i]!=0)
				cnt++;

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
#include <vector>
#define re(i,n) for(int i = 0; i < n; i++)

int main() {
	int n;
	int acnt = 0;
	cin >> n;
	int cnt = 0;

	for (int nn = 1; nn <= n; nn += 2) {
		cnt = 0;
		
		for (int i = 1; i <= nn; i++) {
			if (nn % i == 0)cnt++;
		}
		if (cnt == 8) acnt++;
	}
	cout << acnt << endl;
	return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    vector<vector<int>> a(k, vector<int>(n));
    rep(i,k) {
        cin >> d[i];
        a[i].resize(d[i]);
        rep(j, d[i]) {
            cin >> a[i][j];
        }
    }
    vector<int> sunuke(n, 1);
    rep(i,k) {
        rep(j,d[i]) {
            sunuke[a[i][j]-1] = 0;
        }
    }
    int max_score=0;
    max_score = accumulate(sunuke.begin(), sunuke.end(), 0);
    cout << max_score << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;

int h,w,n;
int x1[1000],y1[1000],x2[1000],y2[1000];
bool map[6000][6000];

int compress(int *a,int *b,int w){
  vector<int> xs;

  for(int i=0;i<n;i++){
    for(int d=-1;d<=0;d++){
      int da = a[i] + d;
      if(0 <= da && da < w)xs.push_back(da);
    }
    b[i]--;
    for(int d=0;d<=1;d++){
      int db = b[i] + d;
      if(0 <= db && db < w)xs.push_back(db);
    }
  }

  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());

  for(int i=0;i<n;i++){
    a[i] = find(xs.begin(),xs.end(),a[i]) - xs.begin();
    b[i] = find(xs.begin(),xs.end(),b[i]) - xs.begin();
  }
  return xs.size();
}

int main(){
  int dx[] = {1,0,-1,0};
  int dy[] = {0,1,0,-1};
  while(1){
    cin >> w >> h;
    if(!w && !h)break;

    cin >> n;
    for(int i=0;i<n;i++){
      cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    }
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)map[i][j] = false;
    }

    for(int i=0;i<n;i++){
      for(int j=x1[i];j<x2[i];j++){
	for(int k=y1[i];k<y2[i];k++){
	  map[k][j] = true;
	}
      }
    }
    
    w = compress(x1,x2,w);
    h = compress(y1,y2,h);

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)map[i][j] = false;
    }
    
    for(int i=0;i<n;i++){
      for(int j=x1[i];j<=x2[i];j++){
	for(int k=y1[i];k<=y2[i];k++){
	  map[k][j] = true;
	}
      }
    }

   int ans = 0; 
   for(int i=0;i<h;i++){
     for(int j=0;j<w;j++){
       if(map[i][j])continue;
       ans++;
       queue<pair<int,int> > q;
       
       q.push(make_pair(j,i));
       while(!q.empty()){
	 int x = q.front().first,y = q.front().second;
	 q.pop();
	 for(int k=0;k<4;k++){
	   int sx = x+dx[k],sy = y+dy[k];
	   if(sx<0 || sx>=w || sy<0 || sy>=h)continue;
	   if(map[sy][sx])continue;
	   q.push(make_pair(sx,sy));
	   map[sy][sx] = true;
	 }
       }
     }
   }
   cout << ans << endl;
  }
}

Measured memory_bytes: 18000
/******************************************
*    AUTHOR:         julianferres         *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " \n"[i==n-1];
#define esta(x,c) ((c).find(x) != (c).end())
const int N = 405;
const ll inf = 1LL << 62;

int n; vi a(N);
vector<vi> dp(N, vi(N,-1));
vi pre(1,0);

ll fill(int l, int r){
	if (dp[l][r] != -1)
		return dp[l][r];

	if(l==r) return dp[l][r] = 0;
	if(l+1==r) return dp[l][r] = a[l] + a[r];
	ll actSum = pre[r + 1] - pre[l];
	ll ans = inf;
	forr(i,l,r){
		ll ansl = fill(l,i);
		ll ansr = fill(i+1,r);
		
		ans = min(ans, ansl+ansr+actSum);
	}
	return dp[l][r] = ans;

}

// 10 20 30 40

int main()
{
	FIN;
	cin >> n;
	forn(i,n) cin >> a[i];
	forn(i, n) pre.pb(pre[i] + a[i]);

	// DBGV(pre, n+1);
	cout << fill(0, n - 1) << endl;
	// forn(j, n) DBGV(dp[j], n);

	return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    int a = 0, b = 0, c = 0;
    REP(i, s.size()){
        if(s[i] == 'a') a++;
        else if(s[i] == 'b') b++;
        else c++;
    }

    cout << ( max({abs(a-b), abs(b-c), abs(c-a)}) < 2 ? "YES" : "NO" ) << endl;

    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//シミュレートして，その局面ごとの最善手をうち続ければいい。
//（未完）

int main(void){
	int N;
	cin>>N;
	int a,max=-1,min=9999;
	rep(i,N){
		cin>>a;
		if(a>max)max=a;
		if(a<min)min=a;
	}
	int ans = max-min;	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
const int N = 1e4+10, P = 924844033, G = 5, Gi = 554906420;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}

int lim,l,A[N],B[N],R[N];
void init(int n) {
    for (lim=1,l=0; lim<=n; lim<<=1,++l) ;
    REP(i,0,lim-1) R[i]=(R[i>>1]>>1)|((i&1)<<(l-1));
}

void NTT(int *J, int tp=1) {
    REP(i,0,lim-1) if (i<R[i]) swap(J[i],J[R[i]]);
    for (int j=1; j<lim; j<<=1) {
        ll T = qpow(tp==1?G:Gi,(P-1)/(j<<1));
        for (int k=0; k<lim; k+=j<<1) {
            ll t = 1;
            for (int l=0; l<j; ++l,t=t*T%P) {
                int y = t*J[k+j+l]%P;
                J[k+j+l] = (J[k+l]-y)%P;
                J[k+l] = (J[k+l]+y)%P;
            }
        }
    }
    if (tp==-1) {
        ll inv = qpow(lim, P-2);
        REP(i,0,lim-1) J[i]=(ll)inv*J[i]%P;
    }
}

int n,k,fac[N],ifac[N],a[N],b[N];
int C(int n, int m) {
	if (m>n) return 0;
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}

int main() {
	fac[0] = 1;
	REP(i,1,N-1) fac[i] = (ll)fac[i-1]*i%P;
	ifac[N-1] = inv(fac[N-1]);
	PER(i,0,N-2) ifac[i]=(ll)ifac[i+1]*(i+1)%P;
	scanf("%d%d", &n, &k);
	REP(i,0,n) a[i]=C(n/k-i,i),b[i]=C(n/k+1-i,i);
	init(n+2);
	NTT(a),NTT(b);
	REP(i,0,lim-1) a[i]=qpow(a[i],(k-n%k)*2)*qpow(b[i],n%k*2)%P;
	NTT(a,-1);
	int ans = 0;
	REP(i,0,n) {
		if (i&1) ans=(ans-(ll)a[i]*fac[n-i])%P;
		else ans=(ans+(ll)a[i]*fac[n-i])%P;
	}
	if (ans<0) ans += P;
	printf("%d\n", ans);
}

Measured memory_bytes: 384
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=10**19
###############################################################################\n=17
n,q=INPUT()
A=INPUT()
T=[0]*(n+1)
def update(i,x):
    while(i<=n):
        T[i]+=x
        i+=i&(-i)
def query(i):
    ans=0
    while(i>0):
        ans+=T[i]
        i-=i&(-i)
    return ans
for i in range(n):
    update(i+1,A[i])
#print(*T)

for _ in range(q):
    s,l,r=INPUT()
    if s==0:
        update(l+1,r)
    else:
        print(query(r)-query(l))
    #print()


Measured memory_bytes: 135016
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a; string b; cin>>a>>b;
    for(int i=0; i<b.size(); i++)
        a*=10;
    a+=stoi(b);
    for(int i=0; i*i<=a; i++){
        if(i*i == a){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner ;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in) ;
    int N  =scan.nextInt();
    int arr[] = new int[N];
    for(int i = 0 ;i<N ;i++){
      arr[i] = scan.nextInt();
    }
    int count2 = 1 ;
    for(int i =N-1 ; i>=1 ; i--){
      int count = 0 ;
      for(int j = i-1 ; j>=0;j--){
        if(arr[i]>=arr[j]){
          count++;
        }
      }
      if(count == i){
        count2++;
      }
    }
    System.out.println(count2);
  }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
#define DEBUG printf("%s\n","debug")
using namespace std;
//////////////////////////////////////////////////////
int main(){
	int N; SCD(N);
	vector<int> V;
	REP(i,N){
		int x;SCD(x);
		V.push_back(x);
	}
	
	int vmax = *max_element(V.begin(),V.end());
	int vmin = *min_element(V.begin(),V.end());
	PRINTD(vmax-vmin);
	return 0;
}








Measured memory_bytes: 256
#pragma comment(linker, "/STACK:512000000")
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(__attribute__((unused)) bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
    string s = FILENAME;
//    assert(!s.empty());
    freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
#else
//    freopen(FILENAME ".in", "r", stdin);
//    freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
#ifndef AIM
    cout.sync_with_stdio(0);
    cin.tie(0);
#endif
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        solve(true);
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cout.flush();
    auto end = clock();

    usleep(10000);
    print_stats(end - start);
    usleep(10000);
#endif

    return 0;
}

void precalc() {
}

template<typename T>
inline T nxt() {
    T cur;
    cin >> cur;
    return cur;
}

#define int li
//const int mod = 1000000007;
int mod;

const int C = 1010;
int c[C][C];

int dp[C][C];

int get_res(int n, int k) {
    if (dp[n][k] != -1) {
        return dp[n][k];
    }
    int& res = dp[n][k];
    if (k == 1) {
        return res = 1;
    }
    res = get_res(n, k - 1);
    for (int rest = 0; rest < n; ++rest) {
        int rig = get_res(rest, k);
        res += c[n][rest + 1] * rig % mod * get_res(n - rest - 1, k - 1);
        res %= mod;
    }
    //cout << n << " " << k << " " << res << "\n";
    return res;
}

void solve(__attribute__((unused)) bool read) {
    int n, k;
    cin >> n >> k >> mod;
    for (int i = 0; i < C; ++i) {
        c[i][i] = c[i][0] = 1;
        for (int j = 1; j < i; ++j) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
        }
    }
    memset(dp, -1, sizeof dp);
    cout << get_res(n, k) << "\n";
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  map<string, int> s =
    {
      {"SAT", 1},
      {"FRI", 2},
      {"THU", 3},
      {"WED", 4},
      {"TUE", 5},
      {"MON", 6},
      {"SUN", 7}
    };
    
  string input;
  cin >> input;
  
  cout << s[input] << endl;
  return 0;
}

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

#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define ld long double
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
#define sze(v) (int)(v.size())

typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<vector<int>>Vv;
typedef vector<pair<int,pii> >Vlll;
typedef priority_queue <int, vector<int>, greater<int>>PQL;
typedef unordered_map<int,int>ump;

const int mod=1e9+7;
const int modx=998244353;
const int Nx=1e5+2;
const int inf= (int)(1e19+10LL);

void solve(){
  int n;
  sl(n);
  Vl arr(n);
  ump counter;
  int sum=0;
  for(auto &it:arr){
	  sl(it);
	  sum=sum+it;
	  counter[it]++;
  }
  int q;
  sl(q);
  while(q--){
	  int a,b;
	  sl(a);sl(b);
	  int freq=counter[a];
	  sum=sum-freq*a;
	  counter[b]=counter[b]+freq;
	  sum=sum+freq*b;
	  counter[a]=0;
	  cout<<sum<<endl;
  }
  
}
 
signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();
 
   }
  return 0;
}


Measured memory_bytes: 7684
#include<stdio.h>
#include<iostream>

using namespace std;

//プロトタイプ宣言
char search(char*, int);

int main() {
	const int MAX_N = 100;
	char S[MAX_N];
	int K;
	cin >> S;
	cin >> K;
	cout << search(S, K) << endl;
	return 0;
}

char search(char* S, int K) {
	int i = 0;
	while (S[i] != '\0') {
		if (i < K && S[i] != '1')return S[i];
		else if (i == K - 1 && S[i] == '1')return '1';
		else {
			i++;
			continue;
		}
	}
}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
result = float('inf')
for i in range(n - k + 1):
  if h[i + k - 1] - h[i] < result:
    result = h[i + k - 1] - h[i]
print(result)


Measured memory_bytes: 7384
/**       In the name of Allah, the Gracious, the Merciful.
*               Praise be to Allah, Lord of the Worlds.
*               **************************************
*
*    I have not failed, I have just found 1000 WAYS that won't work.
*                 __________________________________
*                  Author  : Abd El-Twab  M. Fakhry
*                 __________________________________
*/

#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define  read(arr, l, r)     for(int i = (l); i < (r); cin >> arr[i++])
#define  print(arr, l, r)    for(int i = (l); i < (r); cout << arr[i++] << " \n"[i == r])
#define  rep(i, l, r)        for (int i = l; i < r; i++)
#define  repr(i, r, l)       for (int i = r; i > l; i--)
#define  trav(a, x)          for (auto & a : x)
#define  PQ(T)               priority_queue < T, vector <T> , greater <T> >
#define  Unique(n)           (n).erase(unique(all(n)), (n).end())
#define  endl                '\n'
#define  all(a)              a.begin() , a.end()
#define  NumberOfDigits(n)   ((int)log10(n) + 1)
#define  sz(a)               (int)a.size()
#define  rall(a)             a.rbegin(), a.rend()
#define  rsz(sz)             resize(sz)
#define  ins(x)              insert(x)
#define  debug(x)            cout << #x << " = " << (x) << '\n'
#define  LINE_ON             cout << "line Number = " << __LINE__ << endl
#define  RT(n)               return cout << (n) << endl, 0;
#define  clr(arr, x)         memset(arr, x, sizeof(arr))
#define  F                   first
#define  S                   second
#define  PB                  push_back
#define  EB                  emplace_back
#define  get(n)              find_by_order(n)
#define  indexOf(n)          order_of_key(n)
#define  isPowerOfTwo(x)     (x && !(x & (x - 1)))
#define  Swap(n, k)           n ^= k, k ^= n, n ^= k;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template <class T>
using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
typedef long long            ll;
typedef unsigned int         uint;
typedef unsigned long long   ull;

int Dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 }, Dx4[4] = { 0, 0, 1,-1};
int Dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 }, Dy4[4] = { 1,-1, 0, 0};

const double inf  = 1.0 / 0.0,      pi  = 2 * acos(0.0),   error = 1e-9;
const int    MxsZ = (int)2e6 + 6,   mod = (1 << 30) + 7,      oo = 0x3f3f3f3f;

ll Gcd(ll a, ll b)     { return b ? Gcd(b, a % b) : a; }
ll Lcm(ll a, ll b)     { return a * b / Gcd(a, b); }

void Fast()
{
    cin.sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin.exceptions(cin.failbit);
}

void File()
{
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
}

/**----------------------->>  Template  <<-----------------------**/

int n, k, cnt;

/**------------------>>  Initialization gap  <<------------------**/

int main()
{
    Fast();

    cin >> n >> k; vector <int> v(n); read(v, 0, n);
    rep(i, 0, n) if(v[i] >= k) cnt++;
    RT(cnt);
}


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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  vector<int> alpha(26, 0);
  for(int i = 0; i < S.size(); ++i) {
    for(int j = 0; j < 26; ++j) {
      if(S[i] == 'a'+j) alpha[j]++;
    }
  }
  long long ans=1;
  for(int i = 0; i < 26; ++i) {
    if(alpha[i] == 0) continue;
    ans *= (alpha[i]+1);
    ans %= 1000000007;
  }
  cout << ans-1 << endl;

  return 0;
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var fidnid = 1
    var ai = 0
    for(i in 1..n){
        var ans = 0
        var ins = i
        while(ins % 2 == 0){
            ans++
            ins /= 2
        }
        if(ai < ans){
            ai = ans
            fidnid = i

        }
    }
    println(fidnid)
}



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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
    while(x!=parent[x]){
        parent[x] = parent[parent[x]];
        x = parent[x];
    }
    return x;
}

void sunion(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx != ry){
        if(Size[rx] > Size[ry]){
            parent[ry] = parent[rx];
            Size[rx] += Size[ry];
        }
        else{
            parent[rx] = parent[ry];
            Size[ry] += Size[rx];
        }
    }
}
*/

const ld PI = 3.141592653589793238;

int main(){
    cout << fixed << showpoint;
    cout << setprecision(6);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        ld r;
        cin >> r;
        ld area = 2.0*PI*r;
        cout << area << "\n";
    }
    return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,q,a,b,c;

int sz;
int seg[400010]={};
int get_size(int n);
int unit();
int func(int a,int b);
int build(int n);
int update(int k,int x); //0-indexed
int _get(int a,int b,int k,int l,int r);
int get(int a,int b); //[a,b)

int main(){
	cin >> n >> q; build(n);
	REP(i,0,q){
		cin >> a >> b >> c;
		if(a) cout << get(b,c+1) << endl;
		else update(b,c);
	}
	
	return 0;
}

int get_size(int n){
	int res=0;
	while(n) n=n>>1,res++;

	return (1<<res);
}

int unit(){
	return (1LL<<31)-1;
}

int func(int a,int b){
	return min(a,b);
}

int build(int n){
	sz=get_size(n);
	REP(i,0,2*sz) seg[i]=unit();
	return 0;
}

int update(int k,int x){
	k+=sz-1;
	seg[k]=x;
	while(k){
		k=(k-1)>>1;
		seg[k]=func(seg[k*2+1],seg[k*2+2]);
	}

	return 0;
}

int _get(int a,int b,int k,int l,int r){
	if(b<=l||r<=a) return unit();
	if(a<=l&&r<=b) return seg[k];

	return func(_get(a,b,2*k+1,l,(l+r)>>1), _get(a,b,2*k+2,(l+r)>>1,r));
}

int get(int a,int b){
	return _get(a,b,0,0,sz);
}

Measured memory_bytes: 4124
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
#from collections import deque
from collections import defaultdict
# from collections import Counter
from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n,k=map(int,input().split())
	A=list(map(int,input().split()))
	S=[0]+list(accumulate(A))
	for i in range(n+1):
		S[i]-=i
		S[i]%=k
	
	dct=defaultdict(int)
	
	ans=0
	for j in range(n+1):
		dct[S[j]]+=1
		if j>=k:
			dct[S[j-k]]-=1
		ans+=dct[S[j]]-1
	print(ans)
	
if __name__ == "__main__":
		main()


Measured memory_bytes: 43708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

using p = pair<int, int>;

int main(void)
{
    int N;
    cin >> N;
    auto A = vc(p, N);
    int temp;
    lpn(i, N)
    {
        cin >> temp;
        A[i] = {temp, i+1};
    }
    sort(all(A));
    cout << A[0].second;
    lpsb(i, 1, N) cout << " " << A[i].second;
    cout << endl;
    return 0;
}

Measured memory_bytes: 1536
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    X = int(input())

    ans = 0
    x = 100
    while x < X:
        ans += 1
        x = int(x * 1.01)

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9168
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>

int main(void){

#ifdef __McDic__ // Local testing I/O
    freopen("VScode/IO/input.txt", "r", stdin);
    freopen("VScode/IO/output.txt", "w", stdout);
#endif

    // Get input
    typedef long long int lld;
    const lld MOD = 1000 * 1000 * 1000 + 7;
    int n; std::string line; std::cin >> n >> line;
    std::vector<bool> isWhite(2*n);
    for(int i=0; i<2*n; i++) isWhite[i] = (line[i] == 'W');
 
    // Edge case
    if(isWhite[0] || isWhite[2*n-1]){
        printf("0\n");
        return 0;
    }

    /*// DP initialize
    std::vector<lld> dp[2][2];
    for(int i=0; i<2; i++) for(int j=0; j<2; j++)
        dp[i][j] = std::vector<lld>(2*n, -1); 

    // Do dp
    dp[false][false][0] = 1; // Initial state
    for(int loc=1; loc<2*n; loc++){
        for(int b1=0; b1<2; b1++) for(int b2=0; b2<2; b2++){
            bool odd_
        }
    }*/

    // Determine startpoint and endpoint
    std::vector<bool> should_start_here(2*n, false);
    should_start_here[0] = true;
    int passing = 1;
    for(int loc=1; loc<2*n; loc++){
        should_start_here[loc] = (((passing + 1000 * 1000) % 2 == 1) == isWhite[loc]);
        if(should_start_here[loc]) passing++;
        else passing--;
    }

    // Check start points
    int startpoints = 0;
    for(int i=0; i<2*n; i++) if(should_start_here[i]) startpoints++;

    // Special 2: Passing is not correct
    if(passing != 0 || startpoints != n){
        printf("0\n");
        return 0;
    }

    // ending_after_this[loc] = number of ending loc, loc+1, ...
    std::vector<int> ending_after_this(2*n, 0);
    ending_after_this[2*n-1] = 1;
    for(int loc=2*n-2; loc>=0; loc--){
        ending_after_this[loc] = ending_after_this[loc+1];
        if(!should_start_here[loc]) ending_after_this[loc]++;
    }

    //printf("Start/End: "); for(bool start: should_start_here) printf("%c", start ? 'S':'E'); printf("\n");

    // Pairing
    lld answer = 1;
    int used_pair = 0;
    for(int loc=2*n-1; loc>=0; loc--){
        if(!should_start_here[loc]) continue;
        else if(ending_after_this[loc] <= used_pair){ // Overused
            printf("0\n");
            return 0;
        }
        //printf("Multiplying %lld\n", ending_after_this[loc] - (lld)used_pair);
        answer *= ending_after_this[loc] - used_pair;
        answer %= MOD;
        used_pair++;
    }

    // Permutation order
    for(int i=1; i<=n; i++) answer = answer * i % MOD;

    printf("%lld\n", answer);
    return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

const double EPS = 1e-5;

double dp[51][5000];
int X, Y, Z, V[4];
int event[51], event_A[51];

int main(){
    while(cin >> X >> Y >> Z, X||Y||Z){
        for(int i = 0; i < X; i++){
            cin >> V[i];
        }
        fill(event, event+51, 0);
        for(int i = 0; i < Z; i++){
            int a, b, c;
            cin >> a >> b >> c;
            event[a] = b, event_A[a] = c;
        }
        for(int i = 0; i <= Y; i++){
            fill(dp[i], dp[i]+5000, 0);
        }
        dp[0][0] = 1;
        for(int i = 0; i < Y; i++){
            for(int j = 0; j < 5000; j++){
                for(int k = 0; k < X; k++){
                    if(abs(dp[i][j])==0) continue;
                    int nx = min(Y, i + V[k]), mn = j;
                    if(event[nx] == 2) mn += event_A[nx];
                    else if(event[nx] == 3) mn = max(0, j-event_A[nx]);
                    else if(event[nx] == 1) nx = min(Y, nx + event_A[nx]);
                    dp[nx][mn] += dp[i][j] / X;
                }
            }
        }
        double ans = 0;
        for(int i = 0; i < 5000; i++) ans += i * dp[Y][i];
        printf("%d\n", (int)(ans+EPS));
    }
    return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include<list>
using namespace std;

int main() {
  int DIV = 1e+9 + 7;
  int H, W; cin >> H >> W;
  bool A[H][W]; string str;
  for (int i = 0; i < H; i++) {
    cin >> str;
    for (int j = 0; j < W; j++) {
      A[i][j] = (str[j] == '.');
    }
  }
  long dp[H][W];
  dp[0][0] = 1;
  for (int j = 1; j < W; j++) dp[0][j] = A[0][j] * dp[0][j-1];
  for (int i = 1; i < H; i++) dp[i][0] = A[i][0] * dp[i-1][0];
  for (int i = 1; i < H; i++) {
    for (int j = 1; j < W; j++) {
      dp[i][j] = (A[i][j] * (dp[i-1][j] + dp[i][j-1])) % DIV;
    }
  }
  cout << dp[H-1][W-1] << endl;
}

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

int main()
{
    int n; cin >> n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];

    vector<int> v(n);
    iota(v.begin(), v.end(), 1);
    
    int i = 1;
    int a,b;
    do {
        if(p == v) a = i;
        if(q == v) b = i;
        i++;
    } while( next_permutation(v.begin(), v.end()));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class B {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string  s;
	    in>>s;
	    vector<ll> ans;
	    rep(i,s.size()){
	        if(s.at(i)!='B'){
	            ans.push_back(s.at(i)-'0');
	        } else if(ans.size()>0){
	            ans.pop_back();
	        }

	    }
	    rep(i,ans.size()){
	        out<<ans.at(i);
	    }
	}
};


int main() {
	B solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

const int INF = 1000000000;

void Main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N, vector<int>(N, INF));
    vector<pair<pair<int, int>, int>> edges;
    for (int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        graph[a][b] = c;
        graph[b][a] = c;
        edges.push_back(make_pair(make_pair(a, b), c));
    }
    for (int i = 0; i < N; ++i) {
        graph[i][i] = 0;
    }

    vector<vector<int>> minPath = graph;
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                minPath[i][j] = min(minPath[i][j], minPath[i][k] + minPath[k][j]);
            }
        }
    }

    //// As editorial
    //int ans = 0;
    //for (auto e : edges) {
    //    int a = e.first.first;
    //    int b = e.first.second;
    //    int c = e.second;
    //    bool found = false;
    //    for (int i = 0; i < N; ++i) {
    //        for (int j = 0; j < N; ++j) {
    //            if (minPath[i][j] == minPath[i][a] + c + minPath[b][j]) {
    //                found = true;
    //            }
    //        }
    //    }
    //    if (!found) {
    //        ++ans;
    //    }
    //}
    //cout << ans << endl;

    int ans = 0;
    for (auto e : edges) {
        int a = e.first.first;
        int b = e.first.second;
        int c = e.second;
        if (minPath[a][b] < c) {
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs; }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

constexpr ll MOD = 1e9+7;

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
  }

  modint<MOD> ans = 0;

  rep(i, n) {
    ans += a[i]%MOD*(n-1);
  }

  rep(i, 60) {
    ll cnt = 0;
    rep(j, n) {
      if (a[j] & 1LL<<i) cnt++;
    }
    ans -= static_cast<ll>(pow(2, i+1))%MOD*(cnt*(cnt-1)/2);
  }

  cout << ans.a << endl;
}


Measured memory_bytes: 2560
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
signed main(){
  ll a,b;
  cin >> a >> b;
  cout << a/gcd(a,b)*b<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,i[1000],p[1000],q[1000],r[1000],P,Q,R,C;
	while(1){
		int counter = 0;
		cin >> n;
		if(n==0)break;
		for(int j=0 ; j<n ; ++j){
			cin >> i[j] >> p[j] >> q[j] >> r[j];
		}
		cin >> P >> Q >> R >> C;
		for(int j=0 ; j<n ; ++j){
			if(p[j]<=P && q[j]<=Q && r[j]<=R && (p[j]+r[j])*4+q[j]*9<=C){
				cout << i[j] << endl;
				counter += 1;
			}
		}
		if(counter==0)cout << "NA\n";
	}
	return 0;
}

Measured memory_bytes: 1172
loop do
  l=gets.split.map(&:to_i).sort!
  break if l[0]==0
  min_rad=((l[0]*0.5)**2+(l[1]*0.5)**2)**0.5
  gets.to_i.times do
    puts gets.to_i>min_rad ? "OK" : "NA"
  end
end

Measured memory_bytes: 8748
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll n,k; cin>>n>>k;
    queue<ll> p;
    for (int i = 0; i < n; ++i) {
        ll a; cin >> a;
        if (p.size() < k){
            p.push(a);
        } else {
            if(p.front() < a){
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
            p.pop();
            p.push(a);
        }
    }
    return 0;
}

Measured memory_bytes: 5240
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>

#define llong long long
#define rep(i,l,n) for(llong (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a) ((a)>0?(a):(-(a)))

using namespace std;

llong P = 1000000007;
llong fact[10000]={1};
llong inv[10000]={1};

llong mpow(llong a,llong b){
	llong ans = 1;
	while(b){
		if( b&1 ) ans=ans*a%P;
		b = b>>1; a=a*a%P;
	}
	return ans;
}
void init(){
	for(int i=1;i<10000;i++){
		fact[i]=fact[i-1]*i%P;
		inv[i] =mpow(fact[i],P-2);
	}
	return;
}
llong mseq(llong a,llong b){
	return fact[a]*inv[a-b]%P;
}
llong mcom(llong a,llong b){
	return mseq(a,b)*inv[b]%P;
}

int main(){
	init();
	int S;
	cin >> S;
	llong ans=0;
	for(int n=1;;n++){
		int s = S - n*3;
		if( s<0 ) break;
		ans = (ans+mcom(s+n-1,n-1))%P;
	}
	cout << ans;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    unordered_set<string> ans;
    vector<int> b(n),e(n);
    
    b[0] = 0; e[n-1] =0;
    for(int i = 1; i < n; i++){
        b[i] = b[i-1] | (1 << s[i-1]-'0');
        e[n-i-1] = e[n-i] | (1 << s[n-i]-'0');
    }
    for(int i = 1; i < n-1; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                if((b[i] & (1 << j)) && (e[i] & (1 << k))){
                    char x = '0'+j, y = '0'+k;
                    ans.insert({x,s[i],y});
                }
            }
        }
    }

    cout << ans.size() << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define     mod             1000000007
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n" 
#define     ll              long long int 
#define     vi              vector<int> 
#define     vvi             vector<vector<int>>
using namespace std;


void solve(){
	char str;
	cin>>str;
	if(str >= 'A' && str <= 'Z')
		cout<<'A';
	else if(str >= 'a' && str <= 'z')
		cout<<'a';
}
 

int32_t main()
{
    IOS;

    solve();

}

Measured memory_bytes: 3608
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String strs = sc.next();
    String strp = sc.next();
    int snum = strs.length();
    int psum = strp.length();
    
    for(int p = 0; p < snum; p++){
      String str1 = "";
      String str2 = "";
      String str3 = "";
      for(int q = p; q < snum; q++){
        char c1 = strs.charAt(q);
        str1 += c1;
      }
      for(int r = 0; r < p; r++){
        char c2 = strs.charAt(r);
        str2 += c2;
      }
      for(int s = 0; s < psum; s++){
        char c3 = (str1+str2).charAt(s);
        str3 += c3;
      }
      
      if(str3.equals(strp)){
        System.out.println("Yes");
        break;
      }else if(p == snum-1){
        System.out.println("No");
      }
    }
  }
}


Measured memory_bytes: 33624
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

constexpr ll mod = 1000000007LL;

int main(void){
	int N; cin >> N;
	vector<int> T(N), A(N);
	for (auto& ti : T) cin >> ti;
	for (auto& ai : A) cin >> ai;
	if (T[N - 1] != A[0]){
		cout << 0 << endl;
		return 0;
	}
	vector<int> d(N, 0);
	d[0] = T[0];
	d[N - 1] = A[N - 1];
	for (int i = 1; i < N; ++i){
		if (T[i] > T[i - 1] && d[i] == 0) d[i] = T[i];
		else if (T[i] > T[i - 1] && d[i] != T[i]){
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < N - 1; ++i){
		if (A[i] > A[i + 1] && d[i] == 0)
			d[i] = A[i];
		else if (A[i] > A[i + 1] && d[i] != A[i]){
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < N; ++i){
		if (d[i] > T[i] || d[i] > A[i]){
			cout << 0 << endl;
			return 0;
		}
	}
	ll res = 1;
	for (int i = 0; i < N; ++i)
		if (d[i] == 0)
			res = (res * min(A[i], T[i])) % mod;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4556
#include<stdio.h>
int arr[23];
int main(){
    int n,i;
    scanf("%d",&n);
    i=4;
    while(i--){
    	arr[i]=n%10;
    	n/=10;
    }
    if(arr[0]==arr[1] && arr[1]==arr[2])	printf("Yes\n");
    else if(arr[1]==arr[2] && arr[2]==arr[3])	printf("Yes\n");
    else	printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(A);CIN(B);
    if(A == 1)A = 14;
    if(B == 1)B = 14;
    if(A > B){
        COUT("Alice");
    }else if(A == B){
        COUT("Draw");
    }else{
        COUT("Bob");
    }
    return 0;
}


Measured memory_bytes: 256
program prob1
    implicit none
    character(len=107)::a,b
    integer::la, lb, i
    read(*,*) a,b
    la = len_trim(a)
    lb = len_trim(b)
    if(la > lb) then
        write(*,'(a)') "GREATER"
        stop
    else if(la < lb) then
        write(*,'(a)') "LESS"
        stop
    else
        do i = 1, la
            if(a(i:i) > b(i:i)) then
                write(*,'(a)') 'GREATER'
                stop
            else if(a(i:i) < b(i:i)) then
                write(*,'(a)') "LESS"
                stop
            end if
        end do
    end if
    write(*,'(a)') 'EQUAL'
    stop
end program

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

using  namespace std;

int main() {

        int n, m;
        cin >> n >> m;
        long long sum = 0;
        for(int i=0; i <m ;i++) {

            int x;
            cin >> x;
            sum += x;
        }
        int ans = n - sum;
        if(ans < 0) {
            cout << -1 << endl;
        }
        else {
            cout << ans << endl;
        }
        return 0;
}


Measured memory_bytes: 3572
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-2-18 21:04:53
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int c[100][100];
  for (auto i = 0; i < 3; i++)
  {
    for (auto j = 0; j < 3; j++)
    {
      cin >> c[i][j];
    }
  }
  for (auto i = 0; i < 2; i++)
  {
    if (!(c[i+1][0] - c[i][0] == c[i+1][1] - c[i][1]
        && c[i+1][1] - c[i][1] == c[i+1][2] - c[i][2])) {
      cout << "No" << endl;
      return 0;
    }
  }
 for (auto i = 0; i < 2; i++)
  {
    if (!(c[0][i+1] - c[0][i] == c[1][i+1] - c[1][i]
        && c[1][i+1] - c[1][i] == c[2][i+1] - c[2][i])) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

const int MAX = 12;
int m[MAX][MAX];
string t[12];
const int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};

int main ()
{
    while (cin >> t[0]) {
        for (int i = 1; i < 12; i++) {
            cin >> t[i];
        }

        int res = 0;
        for (int i = 0; i < 12; i++) {
            for (int j = 0; j < 12; j++) {
                if (t[i][j] == '1') {
                    res++;
                    pair<int,int> p;
                    queue<pair<int,int> > v;
                    p = pair<int,int>(i,j);
                    v.push(p);
                    t[i][j] = '0';
                    while (!v.empty()) {
                        auto q = v.front(); v.pop();
                        int x = q.first, y = q.second;
                        for (int k = 0; k < 4; k++) {
                            int nx = x + dx[k], ny = y + dy[k];
                            if (0 <= nx && nx < 12 && 0 <= ny && ny < 12 && t[nx][ny] == '1') {
                                t[nx][ny] = '0';
                                v.push(pair<int,int>(nx,ny));
                            }
                        }
                    }
                }
            }
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1192