akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(20);
  int N;
  cin >> N;
  vector<double> p(N);
  for (int i = 0; i < N; i++){
    cin >> p[i];
  }
  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++){
    for (int j = 0; j <= i; j++){
      dp[i + 1][j] += dp[i][j] * (1 - p[i]);
      dp[i + 1][j + 1] += dp[i][j] * p[i];
    }
  }
  double sum = 0;
  for (int i = (N + 1) / 2; i <= N; i++){
    sum += dp[N][i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 70656
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int a, b, t;
    scan(a, b, t);
    writeln(t / a * b);
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int a[110];
int main(void)
{
  int n;cin>>n;
  rep(i,n)cin >> a[i];
  int ans=-1;
  for(int i=-100;i<=100;i++) {
    int v=0;
    rep(j,n){
      v+=(a[j]-i)*(a[j]-i);
    }
    if(ans<0||v<ans) ans=v;
  }
  cout<<ans<<endl;
}
//スマホより

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int modInverse(int a, int m) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        int q = a / m; 
        int t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 

int mod=1e9+7;
int fac[2000005];
int ncr(int n,int r)
{
   if(n<r)
      return 0;
   int z=1;
   z=(fac[n]);
   z=(z*modInverse(fac[r],mod))%mod;
   z=(z*modInverse(fac[n-r],mod))%mod;
   return z;
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int r1,c1,r2,c2;
   cin>>r1>>c1>>r2>>c2;
   fac[0]=1;
   for(int i=1;i<=2000002;i++)
   {
      fac[i]=(fac[i-1]*i)%mod;
   }
   int ans=0;
   // cout<<(ncr(2,1)+ncr(3,1)*2+ncr(4,2))<<'\n';
   for(int i=r1;i<=r2;i++)
   {
      int z1=ncr(i+c2+1,i+1);
      int z2=ncr(i+c1,i+1);
      ans+=(z1-z2+mod)%mod;
      ans%=mod;
   }
   cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 15872
// 0 - BLACK
// 1 - WHITE

#include <iostream>
#include <vector>

using namespace std;

const long long MOD = 1e9+7;
const int maxN = 1e5+2;

int n;
vector<int> v[maxN];

bool vis[maxN];
long long dp[maxN][2];

void dfs(int nod){
    vis[nod] = true;
    dp[nod][0] = dp[nod][1] = 1;

    for(auto it : v[nod]){
        if(vis[it] == false){
            dfs(it);
            int toAdd = (dp[it][1] + dp[it][0]);
            dp[nod][1] = (dp[nod][1] * toAdd) % MOD;
            
            dp[nod][0] = (dp[nod][0] * dp[it][1]) % MOD;
        }
    }
}

int main(){
    cin >> n;
    for(int i = 1; i < n; i++){
        int x,y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    dfs(1);

    cout << (dp[1][0] + dp[1][1]) % MOD;

    return 0;
}


Measured memory_bytes: 11520
#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_popcountll

#define INF 1e16
#define mod 1000000007

ll a,b;

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

  cin>>a>>b;
  rep(i,b+1){
    if(i*a-i+1>=b){
      cout<<i<<endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    char s[128];
    scanf("%s",s);
    printf("%c%d%c\n",s[0],strlen(s)-2,s[strlen(s)-1]);
    return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int X,A,B;
    cin >>X >> A>> B;

    X -= A;
    cout << X%B << endl;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(float,input().split()))

dp = [[0 for i in range(N+1)]for j in range(N)]
dp[0][0] = 1 - p[0]
dp[0][1] = p[0]

for i in range(1,N):
    for j in range(N):
        dp[i][j] += dp[i-1][j] * (1 - p[i])
        dp[i][j+1] += dp[i-1][j] * p[i]

print(sum(dp[-1][(N//2)+1:]))


Measured memory_bytes: 257672
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    int N;
    string s;
    cin >> N;
    cin >> s;
    
    int red=0, blue=0;
    for (int i=0; i<N; i++) {
        if(s[i]=='R'){
            red++;
        }
        else{
            blue++;
        }
    }
    
    if (red>blue) {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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


int main(){
	int N,T;
	int c[100];
	int t[100];
	cin >> N >> T;
	for(int i=0;i<N;i++){
		cin >> c[i] >> t[i];
	}

	vector<int> v;
	for(int i=0;i<N;i++){
		if(t[i]<=T) v.push_back(c[i]);
	}

	if(v.size()==0){
		cout << "TLE" << endl;
	}else{
		sort(v.begin(),v.end());
		cout << v[0] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 1e6 + 6, mod = (int) 0;
int par[N], cc = 0;
pair<int, pair<int, int>> qry[N];
int find(int v) { return v == par[v]? v: par[v] = find(par[v]); }
void unite(int u, int v) {
    u = find(u);
    v = find(v);
    if (u == v) return;
    par[u] = v;
    cc++;
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < N; ++i) par[i] = i;
    for (int i = 0; i < q; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        qry[i] = make_pair(c, make_pair(a, b));
    }
    sort(qry, qry + q);
    int w = qry[0].first, p = 0;
    long long res = 0;
    set<int> pos[2];
    for (int cur = w; cur <= w + 2 * n; ++cur) {
        int tmp = cc;
        int t = cur & 1;
        vector<int> nw;
        for (auto x : pos[t]) {
            int c0 = find(x), c1 = find((x + 1) % n);
            if (c0 != c1) {
                unite(c0, c1);
                nw.push_back((x + 1) % n);
            }
        }
        pos[t].clear();
        for (int x : nw)
            pos[t].insert(x);
        while (p < q && qry[p].first == cur) {
            int u = qry[p].second.first, v = qry[p].second.second;
            unite(u, v);
            pos[t ^ 1].insert(u);
            pos[t].insert(v);
            p++;
        }
        res += (cc - tmp) * 1ll * cur;
    }
    cout << res << endl;
}

Measured memory_bytes: 18560
#include <iostream>
#include <vector>
using namespace std;
const int year_3 = 20*10;
const int year = 20*5+19*5;
int cal(int y,int m,int d){
  int ans = 0;
  for(int i = 1;i < y;i++){
    if(i%3 == 0)ans += year_3;
    else ans += year;
  }
  for(int i = 1;i < m;i++){
    if(y % 3 == 0)ans += 20;
    else{
      if(i%2 == 1)ans += 20;
      else ans+= 19;
    }
  }
  return ans+d;
  
}

int main(){
  int mille = 0;
  for(int i = 1;i < 1000;i++){
    if(i%3 == 0)mille += year_3;
    else mille += year;
  }

  int n;
  cin >> n;
  for(int i =0 ;i < n;i++){
    int y,m,d;
    cin >> y >> m >> d;
    cout << mille - cal(y,m,d)+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
c1 = c2 = 0
for i in range(x):
    if i in a:
        c1+=1
for i in range(x,n):
    if i in a:
        c2 +=1
print(min(c1,c2))

Measured memory_bytes: 3060
#include <cstdio>
typedef long long int64;
static const int THRESHOLD = 5e5;
static const int64 MAXN = 1.1e11;

int64 n, s;

inline int64 f(int64 b, int64 n)
{
    int64 ans = 0;
    for (; n > 0; n /= b) ans += n % b;
    return ans;
}

int main()
{
    scanf("%lld%lld", &n, &s);

    int64 b;
    for (b = 2; b < THRESHOLD || f(b, n) < f(b - 1, n); ++b) if (f(b, n) == s) { printf("%lld\n", b); return 0; }

    while (true) {
        int64 begin = f(b, n);
        int64 diff = f(b + 1, n) - begin;
        if (diff == 0) {
            if (s == begin) { printf("%lld\n", b); return 0; }
            break;
        }
        int64 lo = b, hi = MAXN, mid;
        while (lo < hi - 1) {
            mid = (lo + hi) >> 1;
            if (f(mid, n) - f(mid - 1, n) == diff) lo = mid; else hi = mid;
        }
        //printf("%lld %lld\n", b, hi);
        if (s <= begin && (s - begin) % diff == 0 && (s - begin) / diff < hi - b) {
            printf("%lld\n", b + (s - begin) / diff); return 0;
        }
        b = hi;
    }

    puts("-1"); return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  string s; cin >> s;
  int ans = 0;
  if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') ans = 1;
  if(s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R') ans = 2;
  if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') ans = 3;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>

using namespace std;

int main(void)
 {
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c && c<=b)
   {
     cout<<"Yes"<<endl;
   }
   else
   {
     cout<<"No"<<endl;
   }
  return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    map<ll, ll> M;
    for (ll i = -300; i < 300; i++) {
        M[i] = i*i*i*i*i;
    }

    int X; cin >> X;
    for (auto& i : M) {
        for (auto& j : M) {
            if (i.second - j.second == X) {
                cout << i.first << " " << j.first;
                return 0;
            }
        }
    }
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b && a == c)
    {
        cout << "No";
    }
    else if (a == b || a == c || b == c)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
A, B, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [[int(x) for x in input().split()] for _ in range(M)]
ans = min(a) + min(b)
for i in range(M):
  n_ans = a[c[i][0]-1]+b[c[i][1]-1]-c[i][2]
  ans = min(n_ans, ans)
print(ans)

Measured memory_bytes: 36940
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ins insert
#define int long long int
#define pb push_back
#define mp make_pair
#define f(i,n) for(int i = 0 ; i < n ; i++ )
#define f1(i,n) for(int  i = 1 ; i <= n ; i++)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test() int t;cin>>t;while(t--)
int mpower(int x, int y, int p){int res = 1;x = x % p;while(y > 0){if(y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
int power(int x, int y){int res = 1;while (y > 0){if (y & 1) res = res*x;y = y>>1;x = x*x;}return res;}
bool isPrime(int n){if (n <= 1)  return false;if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false;int p=sqrt(n);for(int i=5;i<=p;i=i+6)if (n%i == 0 || n%(i+2) == 0)return false;return true;}
const int mod = 1e9 + 7;

void add_self(int &a , int b)
{
    a+=b;
    if(a>mod)
        a-=mod;
        
}



int32_t main()
{
	fast();

    int n , m ;
    cin >> n >> m ;
    
    char grid[n][m];
    
    f(i,n)  
    {
        f(j,m)
            cin >> grid[i][j];
    }
    
    vector< vector<int> > dp(n , vector<int> (m , 0 ));
    dp[0][0] = 1;
    
    f(i,n)
    {
        f(j,m)
        {
            for(int r : {i,i+1})
            {
                int c = j;
                if(r == i)
                {
                    c = j+1;
                }
                
                if(r<n && c < m && grid[r][c] == '.')
                    add_self(dp[r][c] , dp[i][j]);
            }
        }
    }
    
    cout<<dp[n-1][m-1];
    

	
	



	return 0;
}

Measured memory_bytes: 9088
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
using namespace std;
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v) for (auto i : v)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second
#define setp(x) setprecision(x)
#define mset(m, v) memset(m, v, sizeof(m))
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

//static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//#define int ll

int main() { 
        double x, y;
        char s[20], t[20], u[20];
        cin >> s >> t >> u;
        char a = 'A' + s[0] - 'a';
        char b = 'A' + t[0] - 'a';
        char c = 'A' + u[0] - 'a';
        D(a << b << c);
        return 0;
}



Measured memory_bytes: 888
#coding:utf-8

moji = list(input().rstrip())
moji2 =[]
for i in moji:
    if i.isalpha() == False:
        moji2.append(i)

    elif i.islower() == True:
        moji2.append(i.upper())
    else:
        moji2.append(i.lower())

print("".join(moji2))

Measured memory_bytes: 7340
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-7
#define equals(a,b) (fabs(a-b) < EPS)
 
struct Point{
    double x,y,z;
 
    double getDist(const Point &p){
	return sqrt(pow(x-p.x,2)+pow(y-p.y,2)+pow(z-p.z,2));
    }
};
 
int main(){
    int Tc,N;
    double QR,RP,PQ;
    cin >> Tc;
    while(Tc--){
	cin >> QR >> RP >> PQ >> N;
	Point p[N];
	for(int i = 0 ; i < N ; i++){
	    cin >> p[i].x >> p[i].y >> p[i].z;
	}
	double qr,rp,pq;
	for(int i = 0 ; i < N ; i++){
	    for(int j = 0 ; j < N ; j++){
		if(i == j) continue;
		for(int k = 0 ; k < N ; k++){
		    if(i == k || j == k) continue;
		    qr = p[j].getDist(p[k]);
		    rp = p[k].getDist(p[i]);
		    pq = p[i].getDist(p[j]);
		    if(equals(QR/qr,RP/rp) && equals(RP/rp,PQ/pq)){
			cout << i+1 << " " << j+1 << " " << k+1 << endl;
			goto end;
		    }
		}
	    }
	}
    end:;
    }
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<int> T(N,0);
  vector<int> A(N,0);
  vector<int> x(N,0);
  vector<int> y(N,0);
  vector<int> z(N,0);
  for(int i=0;i<N;i++){
    cin>>T[i];
  }
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    if(i==0 || T[i]>T[i-1]){
      x[i]=1;
    }else{
      x[i]=0;
    }
  }
  for(int i=N-1;i>=0;i--){
    if(i==N-1 || A[i]>A[i+1]){
      y[i]=1;
    }else{
      y[i]=0;
    }
  }
  for(int i=0;i<N;i++){
    if(x[i]==1 && y[i]==1){
      if(A[i]==T[i]){
        z[i]=1;
      }else{
        cout<<0<<endl;
        return 0;
      }
    }else if(x[i]==0 && y[i]==1){
      if(A[i]<=T[i]){
        z[i]=1;
      }else{
        cout<<0<<endl;
        return 0;
      }
    }else if(x[i]==1 && y[i]==0){
      if(T[i]<=A[i]){
        z[i]=1;
      }else{
        cout<<0<<endl;
        return 0;
      }
    }else{
      z[i]=min(T[i],A[i]);
    }
  }
  int res=1;
  for(int i=0;i<N;i++){
      cerr<<x[i];
  }
  cerr<<endl;
  for(int i=0;i<N;i++){
      cerr<<y[i];
  }
  cerr<<endl;
  for(int i=0;i<N;i++){
    res=(res*z[i]) % MOD;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    double a, b, x;
    cin >> a >> b >> x;

    double S = x / a;
    //printf("%.7lf\n", S);
    double ans;
    if (S >= (a * b / 2)) {
        double St = a * b - S;
        ans = atan2(2 * St, a * a);
        ans = (ans / acos(-1)) * 180.0;
    }
    else {
        ans = atan2(2 * S, b * b);
        ans = (ans / acos(-1)) * 180.0;
        ans = 90 - ans;
    }

    printf("%.7lf\n", ans);
    
    return 0;
}

Measured memory_bytes: 4128
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var taro = 0
    var hanako = 0
    (0 until n).forEach { _ ->
        val (t, h) = readLine()!!.toString().split(" ")
        when {
            t == h -> {
                taro++
                hanako++
            }
            t > h -> {
                taro += 3
            }
            else -> {
                hanako += 3
            }
        }
    }
    println("$taro $hanako")
}


Measured memory_bytes: 32604
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int l;
  cin >> l;
  int n = 1;
  while(1<<n<=l) ++n;

  vector<tuple<int,int,int>> ans;
  rep(i,n-1) {
    ans.emplace_back(i,i+1,0);
    ans.emplace_back(i,i+1,1<<i);
  }
  l -= 1<<(n-1);
  int val = 1<<(n-1);
  for(int p = n-2; p>=0; --p){
    if(l>=1<<p){
      ans.emplace_back(p,n-1,val);
      val += 1<<p;
      l -= 1<<p;
    }
  }
  cout << n << " " << ans.size() << endl;
  rep(i,ans.size()){
    int u,v,w;
    tie(u,v,w) = ans[i];
    printf("%d %d %d\n",u+1,v+1,w);
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long h[200000];

struct edge
{
	int x;int y;
}e[200000];

int f[200000];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	  {
	  	  cin>>h[i];
	  	  f[i]=1;
      }
	for(int j=1;j<=m;++j)
	{
		int x,y;
		cin>>x>>y;
		if(h[x]>=h[y])
		  f[y]=0;
		if(h[x]<=h[y])
		  f[x]=0;  
	}  
	long long ans=0;
	for(int i=1;i<=n;++i)
	  if (f[i]) ans++;
	cout<<ans<<endl;  
}

Measured memory_bytes: 4820
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
vector<int> e[200010],ans;
int n,q;

void dfs(int v,int p = -1){
    for(int u : e[v]){
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main() {
    cin >> n >> q;
    for (int i = 0; i < n-1; ++i) {
        int a,b;
        cin >> a >> b;
        a--,b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    ans.resize(n);
    for (int i = 0; i < q; ++i) {
        int p,x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    for (int i = 0; i < n; ++i)  cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 23424
<?php

fscanf(STDIN,"%s",$s);


$arrayS = str_split($s);
$aToz = range('a','z');

$total = [];

for ($i = 0; $i < 26; $i++) {
    if (!in_array($aToz[$i], $arrayS)) {
        $total[] = $aToz[$i];
    }
}


if (count($total) == 0){
    echo 'None';
}else{
    echo $total[0];
}


Measured memory_bytes: 10872
#include <iostream>
using namespace std;
int main () {
  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  a[4] = 0;
  while (a[0] > 0) {
    a[2] -= a[1];
    if (a[2] <= 0) 
      a[4] = 1; 
    if (a[4] == 1)
      break;
      a[0] -= a[3]; 
      }
  cout << (a[4] == 1 ? "Yes" : "No");
  }
    


Measured memory_bytes: 3568
n,m,x = [int(i) for i in input().split()]

a = [int(i) for i in input().split()]

totalUp = 0
i = x


while i!=n:
    if i in a:
        totalUp+=1
    i+=1

totalDown = 0

i = x
while i!=0:
    if i in a:
        totalDown+=1
    i-=1

print(min(totalUp,totalDown))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    int n,w,x,y;
    cin>>n>>w;
    vector<vector<ll>> dp(n+1,vector<ll>(w+1));
    REP(i,1,n) {
        cin>>x>>y;
        REP(j,0,w) {
            dp[i][j] = dp[i-1][j];
            if(j>0) dp[i][j] = max(dp[i][j],dp[i][j-1]);
            if(j>=x) dp[i][j] = max(dp[i][j],y+dp[i-1][j-x]);
        }
    }
    cout<<dp[n][w];
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 80256
import math

#n, a, b= map(int, input().split())
#n, x  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))
n = int(input())

tot = 0

n_str = list(str(n))
integ  = [int(s) for s in n_str]
length = len(integ)
for i in range(length):
  tot = tot + integ[i]

mod = n % tot
if (mod == 0):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long n;
void solve()
{
    int tag=0;
    while(n--)
    {
        long t,x,y;
        cin>>t>>x>>y;
        if (t>=x+y)
        {
            if (t%2==(x+y)%2) ;
            else tag=1;
        }
        else tag=1;
    }
    if (tag) cout<<"No";
    else cout<<"Yes";
    cout<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  char s[4];
  int i, k;
  int count_2 = 0;

  scanf("%s", s);

  for(i = 0; i < 4; i++){
    for(k = i; k < 4; k++){
      if(s[i] == s[k]){
        count_2 += 1;
      }
    }
  }

  if(count_2 == 6){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }


  return 0;
}


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

int main(){
        int n, m;
        scanf("%d %d", &n, &m);

        int links[n][n], paths[m][2];
        for(int i=0; i<n*n; i++) links[i/n][i%n]=0;
        for(int i=0; i<m; i++){
                int a, b;
                scanf("%d %d", &a, &b);
                paths[i][0] = a-1;
                paths[i][1] =  b-1;
                links[a-1][b-1] = links[b-1][a-1] = 1;
        }

        int ans = 0;
        for(int i=0; i<m; i++){
                int a=paths[i][0], b=paths[i][1];
                links[a][b] = links[b][a] = 0;

                int cnt = 0, used[n] = {0};
                std::queue<int> que;
                que.push(0);
                while(!que.empty()){
                        int from = que.front(); que.pop();
                        if(used[from]) continue;
                        used[from] = 1;
                        cnt++;
                        for(int j=0; j<n; j++){
                                if(links[from][j] && !used[j]){
                                        que.push(j);
                                }
                        }
                }
                if(cnt!=n) ans++;
                links[a][b] = links[b][a] = 1;
        }

        printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  ll cnt=0;
  ll t=n;
  while(t){
    v.pb(t%2);
    cnt+=t%2;
    t/=2;
  }
  reverse(all(v));

  // cout<<v.size()<<endl;
  vector<ll> ans;

  ll k=v.size()+cnt-2;
  for(ll i=0;i<cnt-1;i++)ans.pb(v.size()+i);
  for(ll i=1;i<v.size();i++)ans.pb(i);

  for(int i=1;i<v.size();i++){
    ans.pb(i);
    if(v[i])ans.pb(k--);
  }
  
  ans.pb(100);
  ans.pb(100);
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    if(i)cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}



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

class Program {

	public void Proc() {
		string[] inpt = Console.ReadLine().Split(' ');
		string ans = inpt[0].Substring(0, 1) + inpt[1].Substring(0, 1) + inpt[2].Substring(0, 1);
		Console.WriteLine(ans);
	}

	static void Main(string[] args) {
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 2772
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String s = in.next();
            int K = in.nextInt();

            TreeSet<String> set = new TreeSet<>();
            for (int i = 0; i < s.length(); i++) {
                for (int end = i + 1; end <= i + 5 && end <= s.length(); end++) {
                    set.add(s.substring(i, end));
                }
            }
//            Utils.debug(set);
            int k = 0;
            for (String string : set) {
                if (++k == K) {
                    System.out.println(string);
                    return;
                }
            }

        }
    }
}


Measured memory_bytes: 24916
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
ll N;
ll M;
string s;
vector<ll > input1;  
vector<vector <ll > > input2;

int main(){
    
    //cin >> N;
    int N, X;
    cin >> N >> X;

    vector<int>D(N+1, 0);
    vector<int>L(N+1, 0);
    int sum = 1;
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }

    for(int i = 1; i <= N; i++){
        int d = D[i-1] + L[i-1];
        //cout << d << endl;
        D[i] = d;
        if(d <= X){
            sum++;
        }
    }

    cout << sum << endl;

} 

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m;
	String s;

	void run(){
		m=sc.nextInt();
		for(int i=0; i<m; i++){
			s=sc.next();
			solve();
		}
	}

	void solve(){
		int n=s.length();
		// StringBuffer sb=new StringBuffer(s);
		TreeSet<String> set=new TreeSet<String>();
		for(int i=1; i<n; i++){
			StringBuffer sb1=new StringBuffer(s.substring(0, i));
			StringBuffer sb2=new StringBuffer(s.substring(i, n));
			String s1=sb1.toString()+sb2.toString();
			String s2=sb2.toString()+sb1.toString();
			sb2.reverse();
			String s3=sb1.toString()+sb2.toString();
			String s4=sb2.toString()+sb1.toString();
			sb1.reverse();
			String s5=sb1.toString()+sb2.toString();
			String s6=sb2.toString()+sb1.toString();
			sb2.reverse();
			String s7=sb1.toString()+sb2.toString();
			String s8=sb2.toString()+sb1.toString();
			set.add(s1);
			set.add(s2);
			set.add(s3);
			set.add(s4);
			set.add(s5);
			set.add(s6);
			set.add(s7);
			set.add(s8);
		}
		println(set.size()+"");
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
open System 
open System.Text

type Explicit =          
    static member inline ($) (_:int32, _:Explicit) = int
    static member inline ($) (_:int64, _:Explicit) = int64

let inline convert (value:'a): 'b = 
    (Unchecked.defaultof<'b> $ Unchecked.defaultof<Explicit>) value

let inline fromInt (x: int): 'a = convert x

module NumericLiteralG =
    let inline FromZero(): 'a = LanguagePrimitives.GenericZero
    let inline FromOne(): 'a = LanguagePrimitives.GenericOne
    let inline FromInt32 (n: int): 'a = fromInt n

let R() = Console.ReadLine()

let f (p: int array) (k: int): int =
    Array.sort p 
    |> Array.take k 
    |> Array.sum

let N, K = let t = R().Split() |> Array.map (string >> int) in t.[0], t.[1]
let p = R().Split() |> Array.map (string >> int)

f p K 
|> printfn "%i"

Measured memory_bytes: 30456
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define end getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n, a[300005], ans, memo;
signed main() {
	cin >> n;
	for (int i = 0; i < n * 3; i++)cin >> a[i];
	sort(a, a + n * 3);
	reverse(a, a + n * 3);
	for (int i = 1; memo < n; i += 2) {
		ans += a[i];
		memo++;
	}
	cout << ans << endl;
	end;
}

Measured memory_bytes: 2560
#include <iostream>
#include <map>
#include <vector>
using namespace std;
long long nChoosek( long long n, long long k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    long long result = n;
    for( long long i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}
int main(){
    long long n;cin>>n;
    vector<long long> balls(n);for (long long i=0;i<n;i++){cin>>balls[i];};
    map<long long, long long> counter;
    for (auto b : balls){
        if (counter.find(b) == counter.end()){
            counter[b] = 1;
        } else {
            counter[b]++;
        }
    }

    map<long long, long long> memo;
    long long base_number = 0;
    for (auto freq : counter){
        memo[freq.first] = nChoosek(freq.second, 2);
        base_number += memo[freq.first];
    }

    for (auto ball : balls){
        if (memo[ball] == 0){
            cout << base_number << endl;
        } else {
            cout << base_number - memo[ball] + nChoosek(counter[ball]-1, 2) << endl;
        }

    }


}

Measured memory_bytes: 20604
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define N 200005
#define F first
#define S second
using namespace std;

int n, s, cnt;
bool v[N];
struct st {
	int t1, t2, num;
} a[N];

bool comp(st p, st q) {
	if (p.t1 != q.t1) return p.t1 < q.t1;
	return p.t2 > q.t2;
}
vector<int> b;
int main()
{
	int i, j;
	cin >> i >> n;
	for (i = 0;i < n; i++) {
		scanf ("%d %d", &a[i * 2].t1, &a[i * 2 + 1].t1);
		a[i * 2].t2 = 0;
		a[i * 2 + 1].t2 = 1;
		a[i * 2].num = a[i * 2 + 1].num = i;
	}
	sort(a, a + n * 2, comp);
	for (i = 0; i < n * 2; i++) {
		if (a[i].t2 == 0) {
			b.push_back(a[i].num);
		} else {
			if (!v[a[i].num]) {
				cnt++;
				for (j = 0; j < b.size(); j++) v[b[j]] = 1;
				b.clear();
			}
		}
	}
	cout << cnt;
    return 0;
}


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

int main(void){

	char S[11];
  	scanf("%s",S);
  	int len=strlen(S),i,j=0,k;
  	char P[11];
  	for(i=0;i<len;i++){
    	P[i]=S[i];
    }
  
  	for(i=0;i<len;i++){
    	if(S[i]=='0'||S[i]=='1'){
          P[j]=S[i];
          j++;
        }
      	else if(S[i]=='B'){
          if(j==0);
          else{
            j--;
            P[j]='\0';
            }
        }
    }
  	P[j]='\0';
  	
   	printf("%s",P);
  	return 0;
}


Measured memory_bytes: 1704
s = input()
k = int(input())

a = sorted(set(s))[:5]
for num in range(2,6):
  if len(s) >= num:
    b = sorted(set([s[i:i+num] for i in range(len(s)-num+1)]))[:5]
    a.extend(b)
  else:
    break

print(sorted(a)[k-1])

Measured memory_bytes: 3492
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = sc.next()

  val mod = 1000000007
  def times(a: Long, b: Long): Long = (a * b) % mod

  def toIntList(s: List[Char]): List[Int] = {
    s match {
      case c1 :: c2 :: rest if c1 == c2 => 2 :: toIntList(rest)
      case _ :: rest => 1 :: toIntList(rest)
      case Nil => Nil
    }
  }

  val t = toIntList(s.toList)
  var ans = 3L * t.head

  if (t.length >= 2) {
    ans = t.sliding(2).map{ case List(a1, a2) => (a1, a2) match {
      case (1, 1) => 2L
      case (1, 2) => 2L
      case (2, 1) => 1L
      case (2, 2) => 3L
    }}.foldLeft(ans)(times)
  }

  println(ans)
}


Measured memory_bytes: 58132
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,flag=0;
    cin>>a>>b;
    if(a&&a<=9)
    {
        if(b&&b<=9){
            cout<<a*b<<endl;
        }
    else{
        cout<<-1<<endl;

    }

    }
    else{
        cout<<-1<<endl;

    }


    /*for(i=1; i<=9; i++)
    {
       for(int j=1;j<=9;j++){
        if(i*j==n){
            flag=1;break;
        }
       }


        /*if(n%i<=9&&(n/i)<=9)
        {
            flag=1;
            break;
        }*/
   // }






    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
ll n,ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(ll i=1;i<n;i++)
	{
		ans+=(n-1)/i;
	}
	cout<<ans;
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if ( a % 2 == 0 || b % 2 == 0 ) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

K=one_int()
S=one_str()

if K>=len(S):
    print(S)
else:
    print(S[:K]+"...")

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

typedef long long Long;

const int N = 2e5 + 2;
const Long INF = 1e18 + 7;

int a[N];
Long L[N];
Long R[N];
Long sum1L[N];
Long sum2L[N];
Long sum1R[N];
Long sum2R[N];

Long diff(Long sum, Long a) {
	Long b = sum - a;
	return max(sum - a, sum - b);
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i ++) {
		L[i] = L[i - 1] + a[i];
	}
	for (int i = n; i >= 1; i --) {
		R[i] = R[i + 1] + a[i];
	}
	int itL = 1;
	for (int i = 2; i <= n - 2; i ++) {
		while (itL < i - 1 && (diff(L[i], L[itL]) >= diff(L[i], L[itL + 1]))) {
			itL ++;
		}
		sum1L[i] = L[itL];
		sum2L[i] = L[i] - L[itL];
	}
	int itR = n;
	for (int i = n - 1; i >= 3; i --) {
		while (itR > i + 1 && (diff(R[i], R[itR]) >= diff(R[i], R[itR - 1]))) {
			itR --;
		}
		sum1R[i] = R[itR];
		sum2R[i] = R[i] - R[itR];
	}
	Long ans = INF;
	for (int i = 2; i <= n - 2; i ++) {
		Long diff = max(abs(sum1L[i] - sum2L[i]), abs(sum1R[i + 1] - sum2R[i + 1]));
		diff = max(diff, abs(min(sum1L[i], sum2L[i]) - max(sum1R[i + 1], sum2R[i + 1])));
		diff = max(diff, abs(max(sum1L[i], sum2L[i]) - min(sum1R[i + 1], sum2R[i + 1])));
		ans = min(ans, diff);
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 10368
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np


d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()

ORDER = 28


def np_search(b_list_, a_list_, pow2, N_):
    c1 = np.searchsorted(a_list_, pow2 - b_list_)
    c2 = np.searchsorted(a_list_, 2*pow2 - b_list_)
    c3 = np.searchsorted(a_list_, 3*pow2 - b_list_)
    return N_**2 - c3.sum() + c2.sum() - c1.sum()



N = d_in()
a_list = ds_in()
b_list = ds_in()


np_a = np.array(a_list)
np_b = np.array(b_list)
a_order_list = np.zeros((ORDER, N), dtype=int)
b_order_list = np.zeros((ORDER, N), dtype=int)
for i in range(1, ORDER+1):
    a_order_list[i-1, :] = np_a % 2**i
    b_order_list[i-1, :] = np_b % 2**i

a_order_list.sort(axis=1)

ans = ''
for i in range(ORDER):
    count = np_search(b_list_=b_order_list[i], a_list_=a_order_list[i],
            pow2=2**i, N_=N)
    if count % 2 == 1:
        ans += '1'
    else:
        ans += '0'

count = np_search(b_list_=b_order_list[-1], a_list_=a_order_list[-1],
        pow2=2**ORDER, N_=N)

if count % 2 == 1:
    ans += '1'
else:
    ans += '0'

print(int(ans[::-1], 2))

Measured memory_bytes: 127176