akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <string>

using namespace std;

struct Process
{
	string name;
	int time;
};

void Calculate(queue<Process> p, int q)
{
	int time = 0;

	while(1){
		
		Process temp;
		temp = p.front();
		
		if(temp.time>q){
			temp.time -= q;
			p.push(temp);
			time += q;
			p.pop();
		}else{
			time += temp.time;
			cout << temp.name << " " << time << endl; 
			p.pop();
		}
		if(p.size() == 0)break; 
	}
	return;
}

int main()
{
	int n, q;
	cin >> n >> q;
	queue<Process> p;
	for(int i=0; i<n; i++){
		Process temp;
		cin >> temp.name >> temp.time;
		p.push(temp);
	}
	Calculate(p,q);
}

Measured memory_bytes: 5228
const main = (args) => {
    const input = args.trim().split("\n");
    const N = parseInt(input[0], 10) % 10;

    const p = [0,1,6,8];

    if( N == 3 ) {
        console.log("bon");

    } else if( p.includes(N) ) {
        console.log("pon");
    } else {
        console.log("hon")
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf-8'));

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

    int main() {
        
        int n;
        cin >> n;
        string s;
        cin >> s;
        
        int k = s.length();
        
        if(n>=k)
            cout << s;
        else{
            
            for(int i=0; i<n; i++){
                cout << s.at(i);
            }
            cout <<"...";
        }
            
        return 0;
        }

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);



int main(){
  int N,C;
  cin >> N >> C;

  vector<vector<pair<int, int>>> st(C+1);

  REP(i,N){
    int s,t,c;
    cin >> s >> t>> c;
    st[c].push_back(make_pair(s,t));
  }

  vector<int> sum(200001,0);

  FOR(i,1,C+1){
    sort(ALL(st[i]));
    REP(j,st[i].size()){
      if(j>0 && st[i][j-1].second == st[i][j].first){
        sum[st[i][j].first*2+1] += 1;
        sum[st[i][j].second*2+1] -= 1;        
      }else{
        sum[st[i][j].first*2-1] += 1;
        sum[st[i][j].second*2+1] -= 1;        
      }
    }

  }

  FOR(i,1,sum.size()){
    sum[i] += sum[i-1];
  }

  int ans=0;
  FOR(i,1,sum.size()){
    ans = max(ans,sum[i]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 2304
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c >= 22 ? "bust\n" : "win\n");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout<<"No" <<endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3


def main():
    ans = 0
    for i in range(int(input())):
        n = input()
        if n[0] != n[2]:
            ans = 0
        else:
            if ans == 2:
                ans += 1
                break
            else:
                ans += 1
    if ans == 3:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

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

#define ll long long

int main() {
  int N;
  cin >> N;
  
  vector<pair<double,double>> town(N);
  for (int i = 0; i < N; i++) {
    double x, y;
    cin >> x >> y;
    town[i] = {x, y};
  }
  
  int perm[N];
  for (int i = 0; i < N; i++) {
    perm[i] = i;
  }
  double count = 0;
  double sum = 0;
  // 平均距離の計算
  do {
    count++;
    double subsum = 0;
    for (int i = 0; i < N-1; i++) {
      pair<double,double> p = town[perm[i]], q = town[perm[i+1]];
      subsum += sqrt((p.first - q.first) * (p.first-q.first)
        + (p.second - q.second) * (p.second - q.second));
      
    }
    
    sum += subsum;
  } while(next_permutation(perm, perm+N));
  
  
  cout << fixed << setprecision(10) << sum / count << endl;
}

Measured memory_bytes: 3816
import numpy as np
S = list(input())
S_np = np.array(list(map(int, S)))

standard1 = np.array([i%2 for i in range(len(S))])
standard2 = np.array([(i+1)%2 for i in range(len(S))])

diff_standard1 = sum((S_np - standard1) != 0)
diff_standard2 = sum((S_np - standard2) != 0)

print(min(diff_standard1, diff_standard2))

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

void Do(char s[64]){
  int i, count;
  char S[64];
  count = 0;
  for(i = 0;i < strlen(s);i++){
    if(s[i] == 'B') count--;
    else S[count++] = s[i];
    if(count < 0) count = 0;
  }
  for(i = 0;i < count;i++) printf("%c", S[i]);
  printf("\n");
}

int main(void){
  char s[64];
  scanf("%s", s);
  Do(s);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  string s;
  cin >> s;
  cout << s[0] + to_string(s.size() - 2) + s[s.size() - 1] << endl;

  return 0;
}


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

using namespace std;

int main() {

    int n, m;
    int max_num = 0;
    int next[300001];

    fill(next, next + 300001, 0);

    cin >> n >> m;

    for(int i = 0; i < n; ++i) {
        int c;
        cin >> c;
        next[c + 1] = c;
        max_num = max(max_num, c);
    }

    for(int i = 1; i <= max_num; ++i) {
        if(!next[i]) {
            next[i] = next[i - 1];
        }
    }

    for(int i = 0; i < m; ++i) {

        int q;
        int ans, cur;

        cin >> q;

        ans = max_num % q;
        cur = max_num - (max_num % q);

        while(cur) {

            ans = max(ans, next[cur] % q);
            if(cur - q < 0) break;
            cur -= q;

        }

        cout << ans << endl;

    }

}

Measured memory_bytes: 4276
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s = s_input()
    t = s_input()

    min_count = INF

    for i in range(len(s)-len(t)+1):
        tmp = s[i:i+len(t)]
        count = 0
        for j in range(len(t)):
            if tmp[j] == t[j]:
                count += 1
        
        min_count = min(min_count, len(t)-count)

    print(min_count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 72856
#include<iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main() {
  long long  n;
  long long a;
  cin >> n >> a;
  
  long long  m= a;
  for(int i=0;i<4;i++){
      cin >> a;
      m=min (m,a);
     
  }  
  
  cout << (n-1)/m + 5   << endl;
}

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

int main(){
  
  int n, m;
  
  cin >> n;
  m = n;
  
  cout << n << ":";
  for(int i = 2;i * i <= m;i++){
    while(!(n % i)){
      cout << " " << i;
      n /= i;
    }
  }
  if(n != 1) cout << " " << n;
  cout << endl;
  
  return 0;
}


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

int main() {
  int N, sum = 0;
  cin >> N;
  vector<int> B(N - 1);
  for(int i = 0; i < (N - 1); i++) {
    cin >> B.at(i);
    if(i == 0)
      sum += B.at(i);
    else 
      sum += min(B.at(i), B.at(i - 1));
  }
  cout << sum + B.at(N - 2) << endl;
  return 0;
}

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

int an[100008];
bool a;

int main(){
    char c;
    long long int N, i, j, cnt = 0, cti = 0, ret;
    scanf("%lld ", &N);
    for(i = 0; i < N; ++i){
        c = getchar();
        if(!i) a = ((c == 48) != bool(i & 1));
        if(a != ((c == 48) != bool(i & 1))){
            an[cti] += cnt;
            an[cti + 1] += cnt;
            an[cti + 2] += cnt;
            cti++;
            cnt = 1;
        }else{
            cnt++;
        }
        a = ((c == 48) != bool(i & 1));
        c = getchar();
    }
    an[cti] += cnt;
    an[cti + 1] += cnt;
    an[cti + 2] += cnt;
    cti++;
    cnt = 1;
    cout << *max_element(an, an + cti + 1) << endl;
    return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
char a[1005][1005];
ll dp[1005][1005];
int n,m;
ll func(int i,int j){
    if(i==n-1 and j==m-1)
        return 1;
    if(i>=n || j>=m)
        return 0;

    if(dp[i][j]!=-1)
        return dp[i][j];

    ll x=0,y=0;
    if(a[i+1][j]=='.')
        x=func(i+1,j);
    if(a[i][j+1]=='.')
        y=func(i,j+1);

    return dp[i][j]=(x+y)%hell;
}
int main(){
    cin>>n>>m;

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    }

    memset(dp,-1,sizeof dp);
    cout<<func(0,0);
}

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

int main() {
  long n,m,ans=1;
  cin >> n >> m;
  map<long,long> pf;
  for(long i=2;true;i++) {
    while(m%i==0) pf[i]++,m/=i;
    if(m<i*i) {
      if(m!=1) pf[m]++;
      break;
    }
  }
  for(auto itr=pf.begin();itr!=pf.end();itr++) {
    long a=1,b=1;
    for(long i=1;i<=(*itr).second;i++) {
      a=a*((*itr).second+n-1-i+1)%1000000007;
      b=b*i%1000000007;
    }
    long c=1;
    for(long j=1;j<=1000000005;j=j*2) {
      if(1000000005/j%2==1) c=c*b%1000000007;
      b=b*b%1000000007;
    }
    ans=a*c%1000000007*ans%1000000007;
  }
  cout << ans << endl;
}

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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


int N, M;
vector<vector<int>> g;
int dp[123456];

int solve(int v){
	if (dp[v] > 0) return dp[v];

	int r = 0;
	for (auto i = g[v].begin(); i != g[v].end(); i++){
		r = max(r, solve(*i) + 1);
	}
	return dp[v]=r;
}

signed main(){


	cin >> N >> M;
	g.assign(N, vector<int>());
	
	for (int i = 0; i < M; i++){
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
	}

	int ans = -INF;
	for (int i = 0; i < N; i++)
		ans = max(ans, solve(i));

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8576
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n,k;
int h[M];
int dp[M];
int rec(int i)
{
	if(i==n-1) return 0;
    if(dp[i]!=-1) return dp[i];
	int ans=mod;
	for(int j=1;j<=k;j++)
	{
		if(i+j<n)
		ans=min(ans,rec(i+j)+abs(h[i+j]-h[i]));
	}
	return dp[i]=ans;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    mst(dp,-1);
    cin>>n>>k;
    for(int i=0;i<n;i++)
		cin>>h[i];
	cout<<rec(0);
    return 0;
}

Measured memory_bytes: 4224
import math

n = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))

a_num = 0
b_num = 0
a_li = []
b_li = []

for i in range(n):
  a_li.append(i+1)
  b_li.append(i+1)
  
for i in range(n):
  a_val = a[i]
  a_val2 = 0
  for j in range(len(a_li)):
    if a_li[j] == a_val:
      a_val2 = j
      a_li.remove(a_val)
      break
  a_num += math.factorial(n-i-1) * a_val2     

  b_val = b[i]
  b_val2 = 0
  for j in range(len(b_li)):
    if b_li[j] == b_val:
      b_val2 = j
      b_li.remove(b_val)
      break
  b_num += math.factorial(n-i-1) * b_val2    

print(abs(a_num-b_num))

Measured memory_bytes: 3064
#include <stdio.h>
int  main(void) {
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(a >= b){
        printf("delicious\n" );
    }else if(b-a <= x && b >= a){
        printf("safe\n");
    }else{
        printf("dangerous\n");
    }
    return 0;
}


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

int n;
int a[30];
int m[210];

bool solve(int index, int remain){
    if(index > n){
        return false;
    }
    if(remain < 0){
        return false;
    }
    if(remain == 0){
        return true;
    }
    return (solve(index + 1, remain)  ||  solve(index + 1, remain - a[index]));
}

int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> m[i];
    }
    for(int i=0; i<q; i++){
        if(solve(0, m[i])){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

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

    cin>>n;
    if(n%1000==0)
    	cout<<0;
    else
    	cout<<1000-n%1000<<'\n';
    
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    string S;
    cin >> S;
    bool ans = false;
    if(S[0] == S[1] && S[2]==S[3] && S[1] != S[2])ans = true;
    else if(S[0] == S[2] && S[1]==S[3] && S[1] != S[2])ans = true;
    else if(S[0] == S[3] && S[2]==S[1] && S[2] != S[3])ans = true;
if(ans)cout << "Yes" << endl;
else cout << "No" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	const int mod = 1e9 + 7;
	string s;
	int d; cin >> s >> d;
	vector<vi> dp(d, vi(2));
	dp[0][0] = 1;
	rep(i, s.size()){
		vector<vi> next(d, vi(2));
		rep(j, d) rep(k, 2) rep(l, 10){
			if(!k && s[i] - '0' < l) continue;
			(next[(j + l) % d][k || s[i] - '0' > l] += dp[j][k]) %= mod;
		}
		dp = next;
	}
	
	cout << ((ll)dp[0][0] + dp[0][1] + mod - 1) % mod;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> A(N), S(N+1), B(N+1);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        S[i+1] = S[i] + A[i];
    }
    map<ll,ll> mp;
    rep(i,N+1){
        mp[S[i]%M]++;
    }
    ll ans = 0;
    for(auto& e:mp){
        ans += e.second*(e.second-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9400
h,w = map(int,input().split())
a = [[] for i in range(0,h)]
for i in range(0,h):
    A = list(input())
    a[i].extend(A)

hlist = []
for i in range(0,h):
    for j in range(1,w):
        if a[i][j-1] !=  a[i][j]:
            break
        if j == w-1 and a[i][j] == ".":
            hlist.append(i)
wlist = []
for j in range(0,w):
    for i in range(1,h):
        if a[i-1][j] !=  a[i][j]:
            break
        if i == h-1 and a[i][j] == ".":
            wlist.append(j)

b = 0
for i in hlist:
    a.pop(i-b)
    b += 1
    h -= 1
b = 0
for j in wlist:
    for i in range(0,h):
        a[i].pop(j-b)
    b += 1
    w -= 1

for i in range(0,h):
    for j in range(0,w):
        if j < w-1:
            print(a[i][j],end="")
        else:
            print(a[i][j])


Measured memory_bytes: 4724
/**
 * author: BueVonHun 🐼🎋
 * More Info: https://github.com/Bue-von-hon
**/

#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>

typedef long long ll;
using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define mp make_pair
#define pii pair<int,int>
#define piii pair<int,pii>
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

template <class T> T _min(T a,T b){return (a<b ? a : b);}
template <class T> T _max(T a,T b){return (a>b ? a : b);}
template<class T> void read(T& x) {cin >> x;}

int test_case;
int main(void) {
    fast_cin();

    string s;
    read(s);
    ll size = s.size();
    ll i = 0, sum = 0;
    while (true) {
        if (i==size) break;
        sum += s[i]-'0';
        i++;
        if (sum%9==0) sum=0;
    }
    if (sum%9==0) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3768
import sys
from operator import itemgetter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n = int(readline())
xl = [list(map(int, readline().decode('utf-8').split())) for _ in range(n)]
LR = [(x - l, x + l) for x, l in xl]
LR.sort(key=itemgetter(1))

acc = -10**18

cnt = 0

for l, r in LR:
    if acc > l:
        continue
    cnt += 1
    acc = r

print(cnt)

Measured memory_bytes: 42792
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    long K = sc.nextLong();

    int i = 0;
    while(i < K && i < S.length()){
      if(S.charAt(i) != '1'){
        System.out.println(S.charAt(i));
        System.exit(0);
      }else{
        i++;
      }
    }
    System.out.println(1);
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vl a(4),b(4);
	cin>>a>>b;
	puta(max(sum(a),sum(b)));
	return 0;
}


Measured memory_bytes: 3240
import Control.Monad
import Data.Int
import Data.List
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

modulo :: Int64
modulo = 10^9 + 7

addMod a b = (a + b) `rem` modulo
subMod a b = (a - b) `mod` modulo
mulMod a b = (a * b) `mod` modulo

-- >>> makeIndex $ V.fromList [1,2,1,2,2]
-- [2,3,-1,4,-1]
-- >>> makeIndex $ V.fromList [4,2,5,4,2,4]
-- [3,4,-1,5,-1,-1]
-- >>> makeIndex $ V.fromList [1,3,1,2,3,3,2]
-- [2,4,-1,6,5,-1,-1]
makeIndex :: V.Vector Int -> V.Vector Int
makeIndex v = V.create $ do
  let n = V.length v
  w <- VM.new n
  idx <- VM.replicate (2*10^5+1) (-1)
  forM_ [n-1,n-2..0] $ \i -> do
    let c = v V.! i
    j <- VM.read idx c
    VM.write w i j
    VM.write idx c i
  return w

build :: V.Vector Int -> V.Vector Int -> V.Vector Int64
build v idx = V.create $ do
  let n = V.length v
  result <- VM.new n
  VM.write result (n-1) 1
  forM_ [n-2,n-3..0] $ \i -> do
    let c = v V.! i
        d = v V.! (i + 1)
    k <- VM.read result (i + 1)
    if c == d
      then VM.write result i k -- same color
      else do let j = idx V.! i
              if j /= -1
                then do u <- VM.read result j
                        VM.write result i (addMod k u)
                else VM.write result i k
  return result

main = do
  n <- readLn -- 1 <= n <= 2*10^5
  cs <- V.fromListN n <$> (sequence $ replicate n readLn) -- 1 <= ci <= 2*10^5
  let idx = makeIndex cs
      result = build cs idx
  print (V.head result)


Measured memory_bytes: 63356
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.second < y.second;
	}
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}
ll combination(ll n, ll r)
{
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1)%MOD + combination(n - 1, r)%MOD);
}
ll pow_mod(ll a, ll b){
    ll sum =1;
    while(b>0){
        if(b&1){
            sum *= a%MOD;
        }
        a = a* a%MOD;
        b >>= 1;
    }
    return sum;
}
int a[100010];

int main() {
    ll N, M; cin >> N >> M;
    if(N==1||M==1){
        if(N==1&&M==1) cout << 1 << endl;
        else cout << N*M-2 << endl;
    }
    else cout << N*M-(2*(N+M)-4) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 int main(){
 
  int A[100];
  int i,j,n,temp,m=0,min;
 
  scanf("%d",&n);
  for(i = 0; i < n; i++)scanf("%d",&A[i]);
 
  for(i = 0; i < n ; i++){
   min = i;
      
   for(j = i; j < n; j++){
	if(A[j] < A[min]){
            min=j;
}
      }
 
      if(min!=i){
          temp = A[i];
          A[i] = A[min];
          A[min] = temp;
          m = m + 1;
        }
    }
 
  for(i = 0 ; i < n-1 ; i++){
   printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",m);
   
  return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC161
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = nm[0], m = nm[1];
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int sum = a.Sum() ;
            int ans = 0;
            for(int i = 0; i < n; i++)
            {
                if (a[i] * (4 * m) >= sum)
                    ans++;
            }
            if (ans >= m)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int x;
   cin>>x;
    int a[x];
    for(int i=0;i<x;i++)
        cin>>a[i];
    sort(a,a+x);
    cout<<a[x-1]-a[0];
   return 0;
   }


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n,k;
  scanf("%d%d",&n,&k);
  string s;
  cin>>s;
  char l = 'z';
  rep(i,n) mins(l,s[i]);
  string ans = s;
  string t = s;
  reverse(rng(t));
  t = s+t;
  int n2 = n*2;
  vi w(n2);
  int now = 0;
  drep(i,n2) {
    if (t[i] == l) ++now;
    else now = 0;
    w[i] = now;
  }
  rep(i,n+1) {
    if (w[i] == 0) continue;
    int x = w[i];
    rep(j,k-1) {
      x *= 2;
      if (x >= n) {
        x = n;
        break;
      }
    }
    string now = string(x,l)+t.substr(i+w[i],n-x);
    mins(ans,now);
  }
  cout<<ans<<endl;
  return 0;
}






















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

#include <cmath>
#include <iomanip>

void _126() {
    int n, k;
    cin >> n >> k;

    double probability = 0.0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; ; ++j) {
            if (i * pow(2, j) >= k) {
                probability += (pow(0.5, j)) / n;
                break;
            }
        }
    }
    cout << fixed << setprecision(12);
    cout << probability << endl;
}

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



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1ll << 62)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){
  
  int n;
  cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }else{
    int a,b;cin >> a >> b;
    cout << a + b << endl;
  }
  
  


  

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a=0;
  int i;
  int sum=0;
  char s[11];
  
  scanf("%s",s);
  
  for(i=0;i<10;i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')
      a++;
    else
       a=0;
    if(sum<a)
      sum=a;
  }
 
  printf("%d\n",sum);
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class union_find{
	int n;
	vector<int> p;
public:
	union_find(int n):n(n),p(n,-1){}
	int find(int u){ return p[u]<0?u:p[u]=find(p[u]); }
	void unite(int u,int v){
		u=find(u); v=find(v);
		if(u!=v){
			if(p[v]<p[u]) swap(u,v);
			p[u]+=p[v]; p[v]=u; n--;
		}
	}
	bool is_same(int u,int v){ return find(u)==find(v); }
	int size()const{ return n; }
	int size(int u){ return -p[find(u)]; }
};

int main(){
	int n,m; scanf("%d%d",&n,&m);
	union_find U(n);
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		U.unite(u,v);
	}

	int ans=1;
	rep(u,n) ans=max(ans,U.size(u));
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, K; scanf("%d%d", &n, &K);
	std::vector<i64> h(n);
	for(int i = 0; i < n; i++) scanf("%lld", &h[i]);

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

	auto cost = [&](int i, int j) -> i64 {
		return std::max<i64>(h[j] - h[i], 0);
	};

	auto dp = make_v<i64>(n + 1, n, K + 1);
	for(auto & A: dp) for(auto & B: A) for(auto & C: B) C = 1LL << 60;
	for(int i = 0; i < n; i++) dp[1][i][!!i] = h[i];
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < n; j++) {
			for(int k = 0; k <= K; k++) {
				i64 from = dp[i][j][k];
				if(from == 1LL << 60) continue;
				
				// 変更なし
				dp[i + 1][i][k] = std::min(dp[i + 1][i][k], from + cost(j, i));

				// 変更あり
				if(k + 1 <= K) dp[i + 1][j][k + 1] = std::min(dp[i + 1][j][k + 1], from + cost(j, j));
			}
		}

		/*
		for(int j = 0; j < n; j++) {
			for(int k = 0; k <= K; k++) {
				if(dp[i + 1][j][k] == 1LL << 60) cout << -1 << " ";
				else cout << dp[i + 1][j][k] << " ";
			}
			cout << endl;
		}
		cout << endl;
		*/
	}
	
	i64 ans = 1LL << 60;
	for(int i = 0; i < n; i++) for(int j = 0; j <= K; j++) ans = std::min(ans, dp[n][i][j]);
	printf("%lld\n", ans);
	return 0;
}



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

int n, k;
vector<pair<int, int>> a;

int kb[30];

long long solve_flat(vector<pair<int, int>> a, int k) {
	long long sol = 0;
	for (auto& p : a) {
		if ((p.first | k) == k) {
			sol += p.second;
		}
	}
	return sol;
}

long long solve(vector<pair<int, int>> a, int k) {
	if (k == 0) {
		long long sol = 0;
		for (auto p : a) {
			if (p.first == 0) {
				sol += p.second;
			}
		}
		return sol;
	}

	if (!(k & (k+1))) {
		return solve_flat(a, k);
	}

	int i = 30;
	while (!(k & (1<<i))) {
		i--;
	}

	// najvisi bit
	long long s1 = solve_flat(a, (1<<i) - 1);

	for (auto& p : a) {
		if (p.first & (1<<i)) {
			p.first ^= (1<<i);
		}
	}

	long long s2 = solve(a, k - (1<<i));

	return max(s1, s2);
}

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

	cin >> n >> k;
	for (int i=1; i<=n; i++) {
		int x, y;
		cin >> x >> y;
		a.push_back({x, y});
	}

	cout << solve(a, k);
}

Measured memory_bytes: 17508
#include <fstream>
#include <map>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, a, x, ct;
bool arr [1000001] = {0};
map<int,int> freqs;
// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    F0R(i,N) {
        cin >> a;
        freqs[a]++;
    }
    int ans = 0;
    while (!freqs.empty()) {
        x = freqs.begin()->F;
        ct = freqs.begin()->S;
        freqs.erase(freqs.begin());
        if (!arr[x] && ct == 1) ans++;
        for (int i = x; i <= 1000000; i += x) arr[i] = 1;
    }
    cout << ans << '\n';
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var s = cin.Read;
            Console.WriteLine(s.Count(x => x == '1'));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}




Measured memory_bytes: 11348
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;



void Show(vector<bool>& Ps) {
	for (int i = 0; i < Ps.size(); i++) {
		if (Ps[i]) {
			cout << "T" << endl;
		} else {
			cout << "F" << endl;
		}
	}
}

void Show(vector<vector<int>>& Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			cout << Ns[i][j] << " ";
		}
		cout << endl;
	}
}


int main() {
	array<int, 5> MARCH;
	for (int i = 0; i < 5; i++) {
		MARCH[i] = 0;
	}
	int N;
	long long Count = 0;
	cin >> N;
	string S;
	for (int i = 0; i < N; i++) {
		cin >> S;
		if (S[0] == 'M')MARCH[0]++;
		if (S[0] == 'A')MARCH[1]++;
		if (S[0] == 'R')MARCH[2]++;
		if (S[0] == 'C')MARCH[3]++;
		if (S[0] == 'H')MARCH[4]++;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = i + 1; j < 5; j++) {
			long long C = 1;
			for (int k = 0; k < 5; k++) {
				if (k != i && k != j) {
					C *= MARCH[k];
				}
			}
			Count += C;
		}
	}
	cout << Count << endl;
}

Measured memory_bytes: 504
n=int(input())
b=list(map(int,input().split()))

a=[]
if n==2:
    a.append(b[0])
    a.append(b[0])
else:
    for i in range(n-1):
        if i==0:
            a.append(b[0])
        else:
            a.append(min(b[i-1],b[i]))
            if i==n-2:
                a.append(b[n-2])

result=0
for j in a:
    result+=j
print(result)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
l = [0] * 13

for i in a:
  l[int(i/400)] += 1

color = 0
anycolor = 0
for i in range(8):
  if l[i] != 0:
    color += 1
for i in range(8, 13):
  anycolor += l[i]

ret1 = max(color, 1)
ret2 = color+anycolor

print(str(ret1) + " " + str(ret2))


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int N;
    int ans=0;
    char S[50];
    scanf("%d",&N);
    scanf("%s",S);
    for(int i = 0 ; i < N ; i++){
        int j=i;
        if(S[j] == 'A'){
            j++;
            if(S[j] == 'B'){
                j++;
                if(S[j] == 'C'){
                    ans++;
                }
            }
        }
    }
    printf("%d",ans);
    return 0;
    
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

    if(n &1)
    {
        cout << "0" << endl;
        return 0;
    }
    long long t=0, f=0;
    long long m = n;
    while(m != 0)
    {
        m /= 2;
        t += m;
    }
    long long l = n;
    l /= 10;
    f += l;
    while(l != 0)
    {
        l /= 5;
        f += l;
    }
    if(f >= t)
    cout << t << endl;
    else
    cout << f << endl;
}


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

int main() {
    int n; cin >> n;
     
    auto askArray = [&] (vector<int> a) {
        cout << "? ";
        for(auto val : a)
            cout << val << " ";
        cout << endl;
        string answer;
        cin >> answer;
        return answer;
    };
    
    auto askSegment = [&] (int start) {
        vector<int> a;
         for (int i = start; i <= start + n - 1; i += 1)
             a.push_back(i);
        return askArray(a);
    };

    auto getBingo = [&] () {
        int left = 1, right = n + 1;
        string val_left = askSegment(left);
        string val_right = askSegment(right);

        while (right - left > 1) {
            int mid = (left + right) / 2;
            string res = askSegment(mid);

            if (res == val_left) {
                left = mid;
            } else {
                right = mid;
            }
        }

        return left;
    };

    int bingo = getBingo();
    
    vector<int> rem;
    vector<string> sol(2 * n + 1);
    map<string, vector<int>> m;

    for (int i = 1; i <= 2 * n; i += 1)
        if (i < bingo + 1 or i > bingo + n - 1) {
            vector<int> a;
            for (int j = bingo + 1; j <= bingo + n - 1; j += 1) 
                a.push_back(j);
            a.push_back(i);

            sol[i] = askArray(a);
            m[sol[i]].push_back(i);
        } else {
            rem.push_back(i);
        }
    
    vector<int> dummy;
    
    assert((int) m["Red"].size() >= n / 2);
    assert((int) m["Blue"].size() >= n / 2);

    for (int i = 0; i < n / 2; i += 1) {
        dummy.push_back(m["Red"][i]);
        dummy.push_back(m["Blue"][i]);
    }

    for (int i = bingo + 1; i <= bingo + n - 1; i += 1) {
        vector<int> a = dummy;
        a.push_back(i);
        
        sol[i] = askArray(a);
    }

    for (int i = 1; i <= 2 * n; i += 1) {
        if (sol[i] == "Red")
            sol[i] = "R";
        else
            sol[i] = "B";
    }

    cout << "! ";
    for (auto line : sol)
        cout << line;
    cout << endl;
}   

Measured memory_bytes: 724
#include<stdio.h>

int main(void){

  int K;
  char S[100];
  int i = 0;
  
  scanf("%d", &K);
  scanf("%s", S);

  while(S[i]){
    if(i == K) break;
    printf("%c", S[i]);
    i++;
  }

  if(S[i] != '\0'){
    puts("...");
  }

  putchar('\n');

  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a%(b+c)-c)/b>=1){
		cout<<a/(b+c)+1<<endl;
	}
	else{
		cout<<(a-c)/(b+c)<<endl;
	}
}


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

using namespace std;

int main() {
	
	int n;
	cin >> n;
	vector<char> v(n);
	int sum = 0;
	int i = 0;

	for (; i < n; i++) {
		cin >> v[i];
		if (v[i] == 'Y') {
			sum++;
		}
	}
		if(sum > 0){
			cout << "Four" << endl;
		}
		else {
			cout << "Three" << endl;
	}
		return 0;
}


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

int main(){
  vector<string> s(3);
  for(int i = 0; i < 3; i++){
    cin >> s[i];
  }
  string ans;
  for(int i = 0; i < 3; i++){
    char c = s[i][0];
    ans += (char)(c-32);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()
s="".join(sorted(s))
p0(s[0]==s[1] and s[1]!=s[2] and s[2]==s[3])

Measured memory_bytes: 3316
#include <stdio.h>

int main(void){

  int num;

  scanf("%d",&num);

  int val[num];
  int loop = 0;
  int count=0;
  int max = 0;
  int limit = 101;
  
  while( loop != num ){
    scanf("%d",&val[loop++]);
  }

  int i;
  while( max != limit ){
    for( i = 0; i<num; i++){
      if( max < val[i] && val[i] < limit ){
	max = val[i];
      }
    }
    limit = max;
    if( max != 0 ){
      count++;
    }
    max = 0;
  };

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,ans=0,cnt=0,tmp;
int main(){
  cin >> n;
  string s[n];
  map<string,int> mp;
  bool f=true;
  for(int i=0;i<n;i++){
    cin >> s[i];
    mp[s[i]]++;
    if(mp[s[i]]>1){
      f=false;
    }
  }
  if(!f){
    cout << "No" << endl;
    return 0;
  }
  for(int i=1;i<n;i++){
    if(s[i-1][s[i-1].size()-1]!=s[i][0]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256