akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <sstream>

using namespace std;

class student{
public:
    student(int a, int b){
        id = a;
        score = b;
    }
    int id;
    int score;

    bool operator < (const student arg) const{
        if(score == arg.score){
            return id < arg.id;
        }else{
            return score > arg.score;
        }
    }
};

int main(void){
    int n;

    while(cin >> n && n){
        vector<student> v;
        int id,tmp;
        string str;
        cin.ignore();
        for(int i=0;i<n;i++){
            getline(cin,str);
            istringstream iss(str);
            vector<int> score;
            iss >> id;
            while(iss >> tmp){
                score.push_back(tmp);
            }
            
            int sum=0;
            int fcount=0;
            int mul[score.size()];
            memset(mul, 0, sizeof(mul));
            for(int j=0;j<score.size();j++){
            	if(fcount == 9){
            		sum += (mul[j] + 1) * score[j];
                }else if(score[j] == 10){ //strike
                    if(j+1 < score.size()) mul[j+1]++;
                    if(j+2 < score.size()) mul[j+2]++;
                    sum += 10;
                    sum += mul[j] * score[j];
                    fcount++;
                }else if(j+1 < score.size()){
                    if(j+1 < score.size() && score[j] + score[j+1] == 10){ //spare?
                        if(j+2 < score.size()) mul[j+2]++;
                    }
                    sum += score[j]+score[j+1];
                    sum += score[j]*mul[j] + score[j+1] * mul[j+1];
                    j++;
                    fcount++;
                }else{
                    sum += score[j] * (mul[j] + 1);
                }
            }
            v.push_back(student(id,sum));
        }
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++){
            cout << v[i].id << " " << v[i].score << endl;
        }
    }
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

void solve()
{
	double weight;
	while(cin >> weight)
	{
		if(weight <= 48.0)
		{
			cout << "light fly" << endl;
		}
		else if(weight <= 51.0)
		{
			cout << "fly" << endl;
		}
		else if(weight <= 54.0)
		{
			cout << "bantam" << endl;
		}
		else if(weight <= 57.0)
		{
			cout << "feather" << endl;
		}
		else if(weight <= 60.0)
		{
			cout << "light" << endl;
		}
		else if(weight <= 64.0)
		{
			cout << "light welter" << endl;
		}
		else if(weight <= 69.0)
		{
			cout << "welter" << endl;
		}
		else if(weight <= 75.0)
		{
			cout << "light middle" << endl;
		}
		else if(weight <= 81.0)
		{
			cout << "middle" << endl;
		}
		else if(weight <= 91.0)
		{
			cout << "light heavy" << endl;
		}
		else
		{
			cout << "heavy" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H,W;
  cin >> H >> W;
  char c[10][10];
  rep(i,0,H){
    rep(j,0,W){
      cin >> c[i][j];
    }
  }
  ll cnt = 0;
  rep(i,0,H){
    rep(j,0,W){
      if(c[i][j] == '#') cnt++;
    }
  }
  if(cnt != H+W-1){
    print("Impossible");
    return 0;
  }
  queue<lpair> lp;
  lp.push(make_pair(0,0));
  ll dx[2] = {0,1};
  ll dy[2] = {1,0};
  while(!lp.empty()){
    lpair l1 = lp.front();
    if(l1.first == H-1 && l1.second == W-1){
      print("Possible");
      return 0;
    }
    lp.pop();
    rep(i,0,2){
      ll hh = l1.first + dx[i];
      ll ww = l1.second + dy[i];
      if(hh >= 0 && hh < H && ww >= 0 && ww < W){
        if(c[hh][ww] == '#') lp.push(make_pair(hh,ww));
      } 
    }
  }
  print("Impossible");
}

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

int main(){
	string s;
	cin >>s;
	int n=-1;
	string t="           ";
	for(int i =0; i< s.size(); i++) {
		if(s[i] == 'B') {
if(n>=0)
			t[n--] = ' ';
		} else {
			t[++n] = s[i];
		}
	}
	cout << t << endl;
	
}


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

using namespace std;

const int mod = 1e9 + 7;

struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mod : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % mod; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

mint dp[100][1400];

mint fact[200000];
mint ifact[200000];
mint inv[200000];

int main() {
  inv[1] = 1;
  for (int i = 2; i < 200000; i++) {
    inv[i] = inv[mod % i] * (mod - mod / i);
  }
  fact[0] = 1;
  ifact[0] = 1;
  for (int i = 1; i < 200000; i++) {
    fact[i] = i * fact[i - 1];
    ifact[i] = inv[i] * ifact[i - 1];
  }
  int n, m;
  cin >> n >> m;
  vector<int> divs;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      divs.push_back(i);
      if (m / i != i) divs.push_back(m / i);
    }
  }
  sort(divs.begin(), divs.end());
  const int N = divs.size();
  dp[0][N - 1] = 1;
  for (int i = 0; i < 99; i++) {
    for (int j = 1; j < N; j++) {
      for (int k = 1; k < N; k++) {
        if (divs[j] % divs[k] != 0) continue;
        int nn = divs[j] / divs[k];
        int l = lower_bound(divs.begin(), divs.end(), nn) - divs.begin();
        dp[i + 1][l] += dp[i][j];
      }
    }
  }
  mint ans;
  for (int i = 0; i <= min(99, n); i++) {
    ans += dp[i][0] * fact[n] * ifact[i] * ifact[n - i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int D, T, S;
    cin >> D >> T >> S;
    if(D <= T *  S){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import math
n,d = map(int, input().split())
X = [list(map(int, input().split())) for i in range(n)]

def f(A,B):
  D = 0
  for i in range(d):
    D += (A[i]-B[i])**2
  if math.sqrt(D) == math.floor(math.sqrt(D)):
    return(1)
  else:
    return(0)
ans = 0  
for i in range(n-1):
  for j in range(i+1,n):
    ans += f(X[i],X[j])
 
print(ans)

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define MOD 1000000007

void solve()
{
    int A[3][3];
    int N;
    vector<int> b(N);
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    cin >> N;
    rep(i, N) cin >> b[i];

    bool bingo[3][3];
    rep(i, 3) rep(j, 3) bingo[i][j] = false;

    rep(k, N) rep(i, 3) rep(j, 3)
    {
        if (A[i][j] == b[k])
            bingo[i][j] = true;
    }

    rep(i, 3)
    {
        bool is_ok = true;
        rep(j, 3)
        {
            if (bingo[i][j] == false)
                is_ok = false;
        }
        if (is_ok)
        {
            cout << "Yes" << endl;
            return;
        }
    }

    rep(j, 3)
    {
        bool is_ok = true;
        rep(i, 3)
        {
            if (bingo[i][j] == false)
                is_ok = false;
        }
        if (is_ok)
        {
            cout << "Yes" << endl;
            return;
        }
    }

    if (bingo[0][0] && bingo[1][1] && bingo[2][2])
    {
        cout << "Yes" << endl;
        return;
    }

    if (bingo[0][2] && bingo[1][1] && bingo[2][0])
    {
        cout << "Yes" << endl;
        return;
    }

    cout << "No" << endl;
}

int main()
{
    solve();
    return 0;
}

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

int main() {
  int a, b, n, h, w;
  cin >> a >> b;
  a--;
  b--;
  n = max(a, b) / 50 + 1;
  
  h = 4 * n;
  w = 100;
  cout << h << " " << w << endl;
  
  rep(j, n) {
    if (a > 50) {
      rep(i, 50) { cout << ".#"; }
      a -= 50;
    } else {
      rep(i, a) { cout << ".#"; }
      rep(i, 50-a) { cout << "##"; }
      a = 0;
    }
    cout << endl;
    rep(i, w) { cout << "#"; }
    cout << endl;
  }
  
  rep(j, n) {
    rep(i, w) { cout << "."; }
    cout << endl;
    if (b > 50) {
      rep(i, 50) { cout << "#."; }
      b -= 50;
    } else {
      rep(i, b) { cout << "#."; }
      rep(i, 50-b) { cout << ".."; }
      b = 0;
    }
    cout << endl;
  }
  
  
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.string, std.range;

auto readLine(T=int)() {
    return readln().strip.splitter(" ").map!(to!T);
}

void main() {
    int n;
    readf("%d\n", &n);
    auto ans = new size_t[n];
    foreach (i, idx; readLine.enumerate) {
        ans[idx - 1] = i;
    }
    foreach (i, idx; ans) {
        write(idx + 1);
        if (i + 1 != ans.length) write(" ");
    }
    writeln();
}


Measured memory_bytes: 4412
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    string s;
    cin >> s;

    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;


    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        double N = double.Parse(input[0]);
        double K = double.Parse(input[1]);
        double ans = 0;
        double num = 1;
        for(double i=N;i>0; i--)
        {
            if (i < K) {
                num *= 0.5;
                K = K / 2;
            }
            if(i>=K){
                ans += num;
            }
            if (ans == 0) { i = N + 1; }
        }
        ans = ans / N;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	int f=1,mx=0;
	FOR(i,0,n){
		int t;
		cin>>t;
		if(t>=mx){
			mx=t;
		}else{
			if(mx-2>=t){
				f=0;
			}
		}
	}
	if(f){
		cout<<"Yes";
	}else{
		cout<<"No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a <= c)
  {
    if (b <= d)
    {
      cout << max(0, b - c) << endl;
    }
    else
    {
      cout << max(0, d - c) << endl;
    }
  }
  else
  {
    if (b <= d)
    {
      cout << max(0, b - a) << endl;
    }
    else
    {
      cout << max(0,d - a) << endl;
    }
  }
}

Measured memory_bytes: 256
n = input()
a = map(int,raw_input().split())

min = a[0]
max = a[0]
sum = 0
for i in range(n):
    if(min > a[i]):
        min = a[i]
    if(max < a[i]):
    	max = a[i]
    sum += a[i]

print('{0} {1} {2}'.format(min,max,sum))

Measured memory_bytes: 7020
# coding: utf-8
# Your code here!

import math

def comb_cnt(n):
    if n >= 2 : 
        return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
    else : 
        return 0

n, m = map(int, input().split())

print(comb_cnt(n) + comb_cnt(m))

Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int *, int);
void inputVector(vector<int> *, int);
template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int a, b;
    cin >> a >> b;
    int diff = b - a;
    int sum = (1 + diff) * diff / 2;
    cout << sum - b << endl;
    return 0;
}

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int gcd(int a, int b) {
    if (b > a) {
        int temp = a;
        a = b;
        b = temp;
    }
    if (b == 0) {
        return a;
    }
    return (b, b % a);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

 
int main(){
  string n;
  cin >> n;
  int ans=0;
  rep(i,3){if(n[i]=='o')ans++;}
  cout << 700+100*ans << endl;
  return 0;
}


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

int main() {
  int ans = 0;
  string S;
  cin >> S;
  if (S.at(0) == 'R') {
    ans++;
  }
  if (S.at(1) == 'R') {
    ans++;
  }
  if (S.at(2) == 'R') {
    ans++;
  }
  if (ans == 2 && S.at(1) == 'S') {
    ans--;
  }
  cout << ans << endl;
}

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

int main() {
  double x;
  bool found = false;
  cin >> x;
  rep (i, 50000) {
    if (x == floor((i + 1) * 1.08)) {
      cout << i + 1 << endl;
      found = true;
      break;
    }
  }
  if (!found) cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 1e3+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int a, b, c;

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin >> a >> b >> c;
	if(a+b+c == 17) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; cin >> n;
    vector<P> R, B;
    
    rep(i, n){
        int a, b;
        cin >> a >> b;
        R.pb({a,b});
    }
    rep(i, n){
        int a, b;
        cin >> a >> b;
        B.pb({a,b});
    }

    sort(all(B), [&](P x, P y){
        return x.fi < y.fi;    
    });

    sort(all(R), [&](P x, P y){
        return x.se > y.se;    
    });

    /*
    cout << "[B]" << endl;
    for(auto [x, y] : B){
        cout << x << " " << y << endl;
    }

    cout << "[R]" << endl;
    for(auto [x, y] : R){
        cout << x << " " << y << endl;
    }
    //*/

    vector<bool> seen(n, false);   
    int cnt = 0;
    rep(i, n){
        int a = B[i].fi, b = B[i].se;
        int tmp = -1;
        rep(j, n){
            if(seen[j]) continue;
            int c = R[j].fi, d = R[j].se;
            if(c < a && d < b){
                if(tmp == -1) tmp = j;
                else if(R[tmp].se < d) tmp = j;
            }
        }
        if(tmp != -1){
            cnt++;
            seen[tmp] = true;
        }
    }
    
    cout << cnt << endl;
    return;
}

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

Measured memory_bytes: 3692
#include <stdio.h>
#include <stdlib.h>

int main(){
	char c;
	scanf("%c", &c);
	if(c == 'a' ||c == 'i' ||c == 'e' ||c == 'o' ||c == 'u'){
	printf("vowel");
	return 0;
	}
	printf("consonant");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < 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;
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 n; cin >> n;
  string s; cin >> s;
  vi e(n),w(n);
  rep(i,n-1){
    if(s[i] == 'W') w[i]++;
    w[i+1] = w[i];
  }
  for(int i = n-1; 0 < i; i--){
    if(s[i] == 'E') e[i]++;
    e[i-1] = e[i];
  }
  int ans = INF;
  rep(i,n) chmin(ans,w[i]+e[i]-1);
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 6116
N = int(input())
S = []
a = 101
for i in range(N):
    s = int(input())
    if s % 10 != 0:
        a = min(s,a)
    S.append(s)
S.sort()
ans = sum(S)
if ans % 10 == 0:
    if a != 101:
        ans = ans - a
    else:
        ans = 0
print(ans)

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 


int main(void)
{
    int n, k;
    cin >> n >> k;
    
    v_int s(n, 0);

    irep(i, k) {
        int d; cin >> d;
        irep(j, d) {
            int a; cin >> a;
            s[a-1]++;
        }
    }

    int ans = 0;
    irep(i, n) {
        if(!s[i]) { ans++; }
    }
    cout << ans << endl;
    return 0;
}
/** atcoder **/


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

int main() {
  int N; cin >> N;
  string s, t; cin >> s >> t;
  for (int i = 0; i < N; i++) {
    if (s.substr(i) == t.substr(0, N-i)) {
      cout << N + i << endl;
      return 0;
    }
  }
  cout << 2*N << endl;
}

Measured memory_bytes: 256
def way12(ball, box):
    """ball: False / box: False / constraints: 1 or more
    ans = P(ball - box, box)  Pは分割数 / 計算量 O(ball * box)
    """
    if ball < box: 
        return 0
 
    # P[i][j] := 整数iを順序を区別せずに「j以下の自然数」の和に分ける場合の数
    diff = ball - box
    P = [[0] * (diff + 1) for _ in range(diff + 1)]
    for j in range(diff + 1):
        P[0][j] = 1
    for i in range(diff):
        for j in range(diff):
            if i - j >= 0:
                P[i + 1][j + 1] = (P[i + 1][j] + P[i - j][j + 1]) % MOD
            else:
                P[i + 1][j + 1] = P[i + 1][j]

    return P[diff][min(diff, box)]


n, k = map(int, input().split())
MOD = 10 ** 9 + 7

print(way12(n, k))


Measured memory_bytes: 29328
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair

#define ll long long
#define sc(n) int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define pi acos(-1)
#define flag bool fl=true;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    string s="ABC";
    string t;
    cin>>t;
    if(s==t)
    {
        cout<<"ARC"<<endl;

    } else
    {
        cout<<s<<endl;
    }
}





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

using namespace std;

int main()
{
    int n,temp,sign=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&temp);
        if(temp!=i) sign++;
    }
    if(sign==0||sign==2) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a=0,b=0,c=0;
    for(int i=0;i<3;i++){
        if(s[i]=='a'){
            a++;
        }
        else if(s[i]=='b'){
            b++;
        }
        else if(s[i]=='c'){
            c++;
        }
    }
    if(a==1 && b==1 && c==1){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_N = 5e5;
ll fac[MAX_N+1], ifac[MAX_N+1];

//comb(n, k)でnCk
ll comb(int n, int k){
    ll c = fac[n];
    c *= ifac[n-k], c %= MOD;
    c *= ifac[k], c %= MOD;
    return c;
}

//perm(n, k)でnPk
ll perm(int n, int k){
    return(fac[n]*ifac[n-k])%MOD;
}

//mpow(x,n)で(x^n)をO(log(n))で計算
ll mpow(ll x, ll n){
    ll res = 1, now = x;
    while(n > 0){
        if(n%2 == 1) res *= now, res %= MOD;
        now *= now, now %= MOD;
        n /= 2;
    }
    return res;
}

int main(){
    int N, K;
    cin >> N >> K;
    //1〜MAX_Nまでのmod(MOD)における逆元
    ll inv[MAX_N+1];
    rep2(i, 1, MAX_N){
        inv[i] = mpow(i, MOD-2);
    }
    //i!とi!の逆元
    fac[0] = 1, ifac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = (fac[i-1]*i) % MOD;
        ifac[i] = (ifac[i-1]*inv[i]) % MOD;
    }
    //0人部屋がK個以下であれば可能
    ll ans = 0;
    //0人部屋がi個の場合の場合の数を探索
    rep2(i, 0, min(N, K)){
        //0人部屋の選び方の数
        ll num1 = comb(N, i);
        //他の部屋への残った人の割り振り方
        ll num2 = comb(N-1, i);
        ans += num1*num2%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11904
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  string s;cin >> s;
  string correct = "CODEFESTIVAL2016";
  int ans = 0;
  repeat(i,16){
    ans += s[i]!=correct[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/**

F(i,W) = max( include ith item , exclude ith item )

Here ,
include ith item = F(i-1,W-w[i]) + v[i]
exclude ith item = F(i-1,W)

Base case:

F(i,W<0)     = INT_MIN
F(i<=0,W==0) = 0

**/

/** Which of the favors of your Lord will you deny ? **/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class TIn>using indexed_set = tree<TIn, null_type, less<TIn>,rb_tree_tag, tree_order_statistics_node_update>;

/**

PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 1e2+7;
const int nmax2 = 1e5+7;
const LL LINF = 1e17;

template <class T>
string to_str(T x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

LL w[nmax];
LL v[nmax];

LL dp[nmax][nmax2];

LL solve(int pos,int W)
{
    if(W<0)
        return INT_MIN;

    if(pos<=0 || W==0)
        return 0;

    LL &ret = dp[pos][W];
    if(ret!=-1) return ret;

    LL inc = solve(pos-1,W-w[pos]) + v[pos];
    LL exc = solve(pos-1,W);

    return ret = max(inc,exc);
}

int main()
{
    optimizeIO();

    int n,W;
    cin>>n>>W;

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

    memset(dp,-1,sizeof dp);

    cout<<solve(n,W)<<endl;

    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}




Measured memory_bytes: 83840
#include <bits/stdc++.h>
#define int long long
using namespace std;

main(){
    int k;cin>>k;
    queue<string> q;
    for(char i='1';i<='9';i++){
        string t;t+=i;
        q.push(t);
    }
    while(!q.empty()){
        string u=q.front();q.pop();
        k--;
        if(k==0)
            return cout<<u,0;
        for(char i='0';i<='9';i++)
            if(abs(u[u.size()-1]-i)<=1)
                q.push(u+i);
    }

}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  if(s == u)a--;
  if(u == t)b--;
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char number[1001];
    int i, sum;
    while(1){
        scanf("%s", number);
        if(number[0]=='0')break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n", sum);
    }

    return 0;
}


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

#define ll long long

using namespace std;

const ll maxn = (ll)1e5+100;
const ll stan = (ll)1e18;
ll n, a[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + 1 + n);
    ll ans = 1;
    for (int i = 1; i <= n; ++i) {
        ll maxx = stan / ans;
        if (a[i] > maxx) {
            ans = -1;
            break;
        }
        ans = ans * a[i];
        if (!ans) break;
       // cerr << i << ' ' << ans << ' ' << a[i + 1] << endl;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 4436
y=int(input())

res=[]

for i in range(1,y+1):
	cnt=0
	y1=i
	y2=y-i

	for j in range(6,0,-1):
		t9=9**j
		if y1>=t9:
			cnt+=y1//t9
			y1=y1%t9
	y2+=y1

	for j in range(7,0,-1):
		t6=6**j
		if y2>=t6:
			cnt+=y2//t6
			y2=y2%t6

	cnt+=y2
	res.append(cnt)

print(min(res))

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

int main(){
  int n;
  cin>>n;
  unordered_map<string,int>mp;//順番は関係ないマップ
  rep(i,n){
    string s;
    cin>>s;//ここまで入力
    sort(s.begin(),s.end());//文字列の中をソート
    mp[s]++;//ソート後に同じ文字列になれば、マップの二番目の数を増やす
  }
  ll ans=0;
  for(auto& p:mp){
    int s=p.second;//同じ文字列が最終的に何個あるか
    ans+=(ll)s*(s-1)/2;//文字列毎に組み合わせ結果を足す
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 10660
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e12
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
string s;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

ll calc(ll a) {
	if (a == 1)return 1;
	return calc(a / 2) * 2 + 1;
}

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

	cin >> s;
	REP(i, s.length()) {
		cout << 'x';
	}
	cout << endl;
}

Measured memory_bytes: 256
W = list(input())
L = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for e in L:
    if W.count(e) % 2 == 1:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;


int main() {

	ll L, R, ans = 2018;

	cin >> L >> R;

	if (R - L >= 2019) {
		ans = 0;
	}
	else {
		repl(i, L, R) {
			repl(j, L+ 1, R + 1) {
				ans = min(i * j % 2019, ans);
			}
		}
	}

	cout << ans;

	return 0;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s; cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    }
    else {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int maxN = 1000 + 100;
long long p[maxN], c[maxN];
long long dp[maxN][maxN];

int main(){
	int d, g;cin>>d>>g;
	int tmp = 0;
	for(int i=1;i<=d;i++){
		cin>>p[i]>>c[i];
		tmp += p[i];
	}
	int res = -1;
	for(int a=0;a<=tmp;a++){
		memset(dp, 0, sizeof(dp));
		
		for(int i=1;i<=d;i++){
			for(int j=1;j<=a;j++){
				for(int k=0;j-k>=0&&k<=p[i];k++){
					if(k==p[i])dp[i][j] = max(dp[i-1][j], dp[i-1][j-k]+k*i*100+c[i]);
					else dp[i][j] = max(dp[i-1][j], dp[i-1][j-k]+k*i*100);
				}
			}
		}
		//cout<<dp[d][a]<<endl;
		if(dp[d][a]>=g){
			res = a;
			break;
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF (1<<30)
#define LINF (1ll<<60ll)
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload4(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload4(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
#define d(a) cerr<<#a<<":"<<a<<endl
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl


int main(){
    int d;
    cin>>d;
    cout<<"Christmas";
    REP(i,25-d){
        cout<<" Eve";
    }
    cout<<endl;
    return 0;
}

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

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

    if(S == "hi"){
        cout << "Yes" << endl;
    }else if(S == "hihi"){
        cout << "Yes" << endl;
    }else if(S == "hihihi"){
        cout << "Yes" << endl;
    }else if(S == "hihihihi"){
        cout << "Yes" << endl;
    }else if(S == "hihihihihi"){
        cout << "Yes" << endl;
    }else if(S == "hihihihihihi"){
        cout << "Yes" << endl;
    }else if(S == "hihihihihihihi"){
        cout << "Yes" << endl;
    }else if(S == "hihihihihihihihi"){
        cout << "Yes" << endl;
    }else if(S == "hihihihihihihihihi"){
        cout << "Yes" << endl;
    }else if(S == "hihihihihihihihihihi"){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

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

using namespace std;

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

int N;

int main()
{
    scanf("%d",&N);
    LL ans = 0;
    _for(i,0,N){
        int num;scanf("%d",&num);
        ans += num-1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[1005],b[1005],c[1005];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
        c[i]=b[i]-a[i];
    }
    int m=0;
    for(int i=0;i<n;i++)
        m+=c[i];
        m+=n;
        cout<<m;
    return 0;
}


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

int isPrime(int x) {
  if(x == 1) return 0;
  if(x == 2) return 1;
  if(x % 2 == 0) return 0;
  
  int max = sqrt(x);
  for(int i = 3; i <= max; i += 2) {
    if(x % i == 0) return 0;
  }
  return 1;
}

int main() {
  int N;
  while(cin >> N) {
    int count = 0;
    for(int i = 0; i < N; i++) {
      if(isPrime(i+1) && isPrime(N-i)) count++;
    }
    cout << count << endl;
  }
  return 0;
}

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

map<int64_t, int64_t> primeFact(int64_t n) {
    map<int64_t, int64_t> prime;
    for(int64_t i = 2; i * i <= n; i++) {
        int64_t cnt = 0;
        while(n % i == 0) cnt++, n /= i;
        if(cnt) prime[i] = cnt;
    }
    if(n > 1) prime[n]++;
    return prime;
}

int main() {
    int64_t n; cin >> n;
    auto prime = primeFact(n);
    int ans = 0;
    for(auto &[key, val] : prime) {
        int now = 1;
        int t = val;
        while(now <= val) {
            val -= now;
            now++;
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

#define N 15

int imax, jmax, solution, digit[256], low[256];
char word[N][16];
bool ok[10];

void found(void){
	for(int i=0; i<imax; i++){
		if(strlen(word[i])>1&&digit[word[i][strlen(word[i])-1]]==0)return;
	}
	++solution;
}

void solve(int sum){
	static int i=0, j=0, carry;
	int c, d;

	c = word[i][j];
	if(i < imax-1) {
		i++;
		if((d = digit[c]) < 0) {
			for(d = low[c]; d <= 9; d++)
				if(ok[d]) {
					digit[c] = d;  ok[d] = false;
					solve(sum + d);  ok[d] = true;
				}
			digit[c] = -1;
		} else solve(sum + d);
		i--;
	} else {
		j++;  i=0;  d = sum % 10;  carry = sum / 10;
		if(digit[c] == d) {
			if(j <= jmax) solve(carry);
			else if(carry == 0) found();
		} else if(digit[c] < 0 && ok[d] && d >= low[c]) {
			digit[c] = d;  ok[d] = false;
			if(j <= jmax) solve(carry);
			else if(carry == 0) found();
			digit[c] = -1;  ok[d] = true;
		}
		j--;  i = imax-1;
	}
}

int main(){
	int k, c;
	char buffer[128];

	jmax = 0;
	while(1){
		cin >> imax;
		if(!imax) break;
		fill(word[0], word[16], 0);
		fill(digit, digit+256, 0);
		fill(ok, ok+10, false);
		for(int i=0; i<imax; i++) {
			cin >> buffer;
			k = strlen((char*)buffer) - 1;
			if(k > jmax) jmax = k;
			for(int j=0; j<=k; j++) {
				c = word[i][j] = buffer[k - j];
				if(isalpha(c)) digit[c] = -1;
				else if(isdigit(c)) digit[c] = c - '0';
			}
		}
		for(int i=0; i<=9; i++) ok[i] = true;
		solution = 0;
		solve(0);
		cout << solution << endl;
	}
	return 0;
}


Measured memory_bytes: 2992
#include <iostream>
#include <string>
#include <cstdlib>
#include <cctype>
using namespace std;

int n;
const char *p;

string parse(){
	string s;
	while(1){
		if(isalpha(*p)){
			s += *p++;
		}
		else if(isdigit(*p)){
			char *endp;
			int k = strtol(p, &endp, 10);
			p = endp;

			string t(1, 0);
			if(*p == '('){
				++p;
				t = parse();
				++p;
			}
			else{
				t[0] = *p++;
			}

			for(int i = 0; i < k && s.size() <= n; ++i){
				s += t;
			}
		}
		else{
			break;
		}
		
		if(s.size() > n + 1){
			s.resize(n + 1);
		}
	}
	return s;
}

int main(){
	string s;
	while(cin >> s >> n, s != "0"){
		p = s.c_str();
		s = parse();
		cout << (n < s.size() ? s[n] : '0') << endl;
	}
}

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

#define llint long long int
#define P 998244353

using namespace std;

// a^n (mod p)
llint mod_pow(llint a, llint n, llint p){
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        llint d = mod_pow(a, n / 2, p);

        return (d * d) % p;
    } else {
        return (a * mod_pow(a, n - 1, p)) % p;
    }
}
llint mod_inv(llint a, llint p){
    return mod_pow(a, p - 2, p);
}
int main(){
    llint N, M, K;

    cin >> N >> M >> K;

    vector<llint> C(K + 1);

    C[0] = 1;

    llint temp_C = 1;

    for(llint i = 1; i <= K; i ++){
        temp_C *= N - i;
        temp_C %= P;
        temp_C *= mod_inv(i, P);
        temp_C %= P;
        C[i] = temp_C;
    }
    llint ans = 0;

    for(int i = 0; i <= K; i ++){
        llint temp = 1;

        temp *= C[i];
        temp %= P;
        temp *= M;
        temp %= P;
        temp *= mod_pow(M - 1, N - i - 1, P);
        temp %= P;
        ans += temp;
        ans %= P;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include <iostream>
using namespace std;
int main() {
    int W, a, b; cin >> W >> a >> b;
    int ans = 0;
    if(a<=b&&b<=a+W || a<=b+W&&b+W<=a+W) ans = 0;
    else if(a+W<b) ans = b-a-W;
    else if(b+W<a) ans = a-b-W;
    cout << ans << endl;
}

Measured memory_bytes: 256