akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;
constexpr ll MOD = 1e9+7;

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main(void) {
    ll N;
    cin >> N;
    ll all = 1;
    for (int i = 0; i < N; i++) {
        all = (all * 10) % MOD;
    }
    ll x9 = 1;
    for (int i = 0; i < N; i++) {
        x9 = (x9 * 9) % MOD;
    }
    ll x8 = 1;
    for (int i = 0; i < N; i++) {
        x8 = (x8 * 8) % MOD;
    }
    ll ans = mod(all - mod((((x9*2)%MOD) - x8), MOD), MOD);
    cout << ans << endl;
    return 0;
}



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

using namespace std;

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

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


int atcoder(){
    //入力
    int n;
    cin >> n;
    map<int,int> mpa,mpb;
    REP(i,n/2){
        int tmp;
        cin >> tmp;
        mpa[tmp]++;
        cin >> tmp;
        mpb[tmp]++;
    }
    
    
    int maxa=0;
    int maxb=0;
    int maxanum,maxbnum;
    for(auto p : mpa){
        if(p.second>maxa){
            maxa = p.second;
            maxanum = p.first;
        }
    }
    for(auto p : mpb){
        if(p.second>maxb){
            maxb = p.second;
            maxbnum = p.first;
        }
    }
    
    if(maxanum!=maxbnum){
        cout << n-maxa-maxb <<ENT;
        return 0;
    }
    else{
        int maxasec=0;
        int maxbsec=0;
        for(auto p : mpa){
            if(p.second>maxasec && p.first!=maxanum){
                maxasec = p.second;
            }
        }
        for(auto p : mpb){
            if(p.second>maxbsec && p.first!=maxbnum){
                maxbsec = p.second;
            }
        }
        if((maxa-maxasec)>(maxb-maxbsec)){
            cout << n-maxa-maxbsec << ENT;
            return 0;
        }else{
            cout << n-maxasec-maxb << ENT;
            return 0;
        }
    }
    
    
    //処理
    
    //出力
    return 0;
}

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


Measured memory_bytes: 4992
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = [0]+list(mapint())
As.sort()
from itertools import accumulate
cAs = list(accumulate(As))
cAs.sort(reverse=True)
As.sort(reverse=True)

ans = 1
for i in range(1, N):
    if cAs[i]*2<As[i-1]:
        break
    ans += 1

print(ans)

Measured memory_bytes: 92544
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX 500005
#define ll long long
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
ll ans;
int n,h,w,tot,f[MAX];
bool cir[MAX];
struct edge{int u,v,w;}E[MAX];
bool operator<(edge a,edge b){return a.w>b.w;}
int getf(int x){return x==f[x]?x:f[x]=getf(f[x]);}
int main()
{
	scanf("%d%d%d",&n,&h,&w);
    for(int i=1;i<=h+w;++i)f[i]=i;
    fp(i,1,n){
    	R int x,y,c;
    	scanf("%d%d%d",&x,&y,&c);
    	
            E[++tot]=(edge){x,y+h,c};
	}
//    for(int i=1;i<=n;++i)
//        for(int j=1;j<=m;++j)
//            E[++tot]=(edge){i,j+n,read()};
    sort(&E[1],&E[tot+1]);
    for(int i=1;i<=tot;++i)
    {
        int u=getf(E[i].u),v=getf(E[i].v);
        if(u==v){if(!cir[u])cir[u]=true,ans+=E[i].w;}
        else if(!cir[u]||!cir[v])
            f[u]=v,ans+=E[i].w,cir[v]|=cir[u];
    }
    printf("%lld\n",ans);return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (A == 1) A = 14;
	if (B == 1) B = 14;

	if (A > B) cout << "Alice" << endl;
	if (A < B) cout << "Bob" << endl;
	if (A == B) cout << "Draw" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int k,x;
    cin >> k >> x;
    
   int hani_1 = -1*(k-1);
   int hani_2 = k-1;
   for(int i=hani_1; i<=hani_2; i++){
       cout << x+i << " ";
   }
   cout << endl;
}
    

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

int main(){
	int x, y;
	cin >> x >> y;

	for(int kame = 0; kame <= x; kame++){
		int tsuru = x-kame;
		if(kame*4 + tsuru*2 == y){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

const int MAX_NM = 30;
int N, M, A, C, R = 0;
int B[MAX_NM];

inline void Main() {
  // code
  int N, M, R, H[30];
  cin >> N;
  rep(i, N) cin >> H[i];

  M = H[0];
  R = 1;
  repi(i, 1, N) {
    if(M <= H[i]) R++;
    M = max(M, H[i]);
  }

  cout << R << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  if(s.length()==3)rep(i,3)cout<<s[2-i];
  else cout<<s;
  cout<<endl;

  return 0;

}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	ss := strings.Split(s,"")
	chars := "ACGT"

	ansCnt := 0
	tmpCnt := 0
	for _,v := range ss {
		if strings.Index(chars,v) >= 0 {
			tmpCnt++
			if ansCnt < tmpCnt {
				ansCnt = tmpCnt
			}
		} else {
			tmpCnt = 0
		}
	}
	fmt.Println(ansCnt)
}

Measured memory_bytes: 640
/* Code by : Suraj (@suraj1611) */

#include<bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define pf printf
#define sc scanf
#define maxsize 1100005
#define lb cout<<endl;
#define F first
#define S second
#define print(i) cout<<i<<endl
#define print1(i,j) cout<<i<<" "<<j<<endl
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll x, ll  y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y%2 == 0) 
        return power(x, y/2)*power(x, y/2); 
    else
        return x*power(x, y/2)*power(x, y/2); 
} 



int main()
{
	IOS
	
	

	ll n,m;
	cin>>n>>m;
	queue < pair < ll, pair <ll,ll> > > q;
	ll dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
	string a[1000];

	rep(i,n)
	cin>>a[i];

	rep(i,n)
	{
		rep(j,m)
		{
			if(a[i][j]=='#')
			{
				q.push({0,mp(i,j)});
			}
		}
	}
	ll ans=0;
	while(!q.empty())
	{
		auto p=q.front();
		q.pop();
		rep(i,4)
		{
			ll x,y;
			x=p.S.F+dx[i];y=p.S.S+dy[i];
			if(x<0||y<0||x>=n||y>=m||a[x][y]=='#')
				continue;
			else
			{
				q.push({p.F+1,mp(x,y)});
				ans=max(ans,p.F+1);
				a[x][y]='#';
			}
		}
	}

	cout<<ans<<endl;







	

    return 0;
}

Measured memory_bytes: 25524
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int[] s = new int[5];

		// 整数の入力
		s[0] = sc.nextInt();
		s[1] = sc.nextInt();
		s[2] = sc.nextInt();
		s[3] = sc.nextInt();
		s[4] = sc.nextInt();
		int k = sc.nextInt();
		boolean flg = true;

		for(int n=0;n<4&&flg;n++){
			for(int m=n+1;m<5&&flg;m++){
				if(s[m]-s[n]>k)flg=false;
			}
		}

		// 出力
		System.out.println(flg?"Yay!":":(");
	}
}

Measured memory_bytes: 23124
N = int(input())
import itertools

def divisor_pl(num):
    l = []
    i = 2
    while num > 1:
        if num%i == 0:
            l.append(i)
            num = int(num/i)
        else:
            i += 1
    if num != 1:
        l.append(num)
    return l

l = []
for i in range(2,N+1):
    l.append(divisor_pl(i))
l = sum(l,[])
l.sort()

fac_dict = {}
fac_list = []
for key, value in itertools.groupby(l):
    fac_dict[str(key)] = len(list(value))
    fac_list.append(key)

count = 0
#(4,4,2)型のカウント
for l in itertools.combinations(fac_list,3):
    for i in range(3):
        if fac_dict[str(l[i%3])] >= 4 and fac_dict[str(l[(i+1)%3])] >= 4 and fac_dict[str(l[(i+2)%3])] >= 2:
            count+=1

#(14,4)型のカウント
for l in itertools.combinations(fac_list,2):
    for i in range(2):
        if fac_dict[str(l[i%2])] >= 14 and fac_dict[str(l[(i+1)%2])] >= 4:
            count+=1

#(24,2)型のカウント
for l in itertools.combinations(fac_list,2):
    for i in range(2):
        if fac_dict[str(l[i%2])] >= 24 and fac_dict[str(l[(i+1)%2])] >= 2:
            count+=1

#(74)型のカウント
for l in fac_list:
    if fac_dict[str(l)] >= 74:
        count += 1

print(count)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
#include <functional>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s; cin >> s;
    int ans = 0;
    REP(i,s.size()){
        if(s[i]=='+') ++ans;
        else --ans;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("d",&a,&b)
#define sfff(a,b,c)     scanf("d%d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define PRINT_CASE printf("Case %d: ",z)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = 100005;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;
int n,k,a[102];

int win_dp[maxn];

int cal(int stone)
{
    //if(val==0) return 1;
    if(stone<a[1]) return 0;

    int &win=win_dp[stone];
    if(win!=-1){
        return win;
    }
    win=0;
    f1(i,n) if(a[i]<=stone)
    win|=!cal(stone-a[i]);

    return win;
}

int main() {

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin>>n>>k;

    f1(i,n) cin>>a[i],win_dp[a[i]]=1;


    memset(win_dp , -1 , sizeof(win_dp));


    int win=cal(k);
    if(win) cout<<"First"<<endl;
    else cout<<"Second"<<endl;

    return 0;
}

Measured memory_bytes: 5376
using System;

namespace _064c
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int count_max = 0;
            int count_min = 0;
            int count = 0;
            int valiable_num = 0;
            int[] a_n = new int[8];
            for(int i = 0; i< N;i++){
                if(a[i]>=3200){
                    valiable_num ++;
                }else{
                    a_n[a[i]/400] = 1; 
                }
            }
            for(int j= 0; j<8;j++){
                count += a_n[j];
                // Console.WriteLine(a_n[j]);
            }
            count_max = count + valiable_num;
            if(count == 0){
                count_min = 1;
            }else{
                count_min = count;
            }
            Console.WriteLine("{0} {1}",count_min,count_max);
        }
    }
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int h, w;
char c[1000][1000];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> h >> w;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      cin >> c[i][j];
  for (int i = 0; i < h; i++, cout << "\n")
    for (int j = 0; j < w; j++)
      cout << ((i & 1) == 0 && j != w - 1 || j == 0 || c[i][j] == '#' ? '#' : '.');
  cout << "\n";
  for (int i = 0; i < h; i++, cout << "\n")
    for (int j = 0; j < w; j++)
      cout << ((i & 1) == 1 && j != 0 || j == w - 1 || c[i][j] == '#' ? '#' : '.');
}


Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int H,W;
    cin >> H >> W;
    char s[H+2][W+2];
    for(int i=0;i<W+2;i++) s[0][i] = '.';
    for(int i=1;i<H+1;i++){
        s[i][0] = '.';
        for(int j=1;j<W+1;j++) cin >> s[i][j];
        s[i][W+1] = '.';
    }
    for(int i=0;i<W+2;i++) s[H+1][i] = '.';

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j] == '#' && s[i-1][j] == '.' && s[i+1][j] == '.' && s[i][j-1] == '.' && s[i][j+1] == '.' ){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define lng long long

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

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

  int a, b;
  cin >> a >> b;
  cout << 6 - a - b << endl;
  
  return 0;
}


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

const int N = 250;
const int mod = 1e9 + 7;

int n, m;
char a[N][N];
int res = 1;
int par[N];

int anc(int p) { return p == par[p] ? p : par[p] = anc(par[p]); }
void join(int p, int q) { par[anc(p)] = anc(q); }

bool is_palind(string &s) {
    for (int i = 0; i < s.size() / 2; ++i) {
        if (s[i] != s[s.size() - 1 - i]) return false;
    }
    return true;
}

void cut_row() {
    string s = "";
    int mid = n / 2;
    for (int i = 0; i < m; ++i) {
        s += a[mid][i];
    }
    if (!is_palind(s)) {
        res *= 2;
    }
    --n;
    for (int i = mid; i < n; ++i) {
        for (int j = 0; j < m; ++j) a[i][j] = a[i + 1][j];
    }
}

void cut_col() {
    string s = "";
    int mid = m / 2;
    for (int i = 0; i < n; ++i) {
        s += a[i][mid];
    }
    if (!is_palind(s)) {
        res *= 2;
    }
    --m;
    for (int i = mid; i < m; ++i) {
        for (int j = 0; j < n; ++j) a[j][i] = a[j][i + 1];
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }

    if (n & 1) {
        cut_row();
    }
    if (m & 1) {
        cut_col();
    }

    // solve
	for (int i = 0; i < n / 2 + m / 2; ++i) par[i] = i;

    for (int i = 0; i < n / 2; ++i) {
        for (int j = 0; j < m / 2; ++j) {
            vector<char> cur;
            cur.push_back(a[i][j]);
            cur.push_back(a[n - i - 1][j]);
            cur.push_back(a[i][m - j - 1]);
            cur.push_back(a[n - i - 1][m - j - 1]);

            sort(cur.begin(), cur.end());
            int cnt = 0;
            do {
                ++cnt;
            } while(next_permutation(cur.begin(), cur.end()));

			if (cnt == 24) {
				res = 12LL * res % mod;
				join(i, j + n / 2);
			} else {
				res = 1LL * res * cnt % mod;
			}
        }
    }

	int ncomp = 0;
	for (int i = 0; i < n / 2 + m / 2; ++i) {
		if (i == par[i]) {
			++ncomp;
		}
	}

	for (int i = 0; i < n / 2 + m / 2 - ncomp; ++i) {
		res = 2LL * res % mod;
	}

    cout << res << endl;
}

Measured memory_bytes: 256
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: u64 = sc.read();
    if n % 2 != 0 {
        println!("{}", 0);
        return;
    }
    let mut div: u64 = 10;
    let mut result = 0;
    while div <= n {
        result += n / div;
        div *= 5;
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

int n, m, sum;

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

    for(int i = 1; i <= m; i++){
        int x; cin >> x;

        sum += x;
    }

    cout << max(-1, n - sum) << "\n";

    return 0;
}

Measured memory_bytes: 3648
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long 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 FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b){
    if(a % b == 0){
        return(b);
    }
    else{
        return(gcd(b, a % b));
    }
}

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;
string s;
vector<ll> a;

int main(){
    //cin >> ;
    //cout << ans << endl;
    queue<ll> que;

    scanf("%lld", &K);

    FOR(i, 1, 9){
        que.push(i); 
    }
    cnt = 1;
    while(1){
        ans = que.front();
        if(K == cnt){
            break;
        }
        cnt++;
        ll tmp = ans % 10;
        if(tmp != 0){
            que.push((ans * 10) + (tmp - 1));
        }
        que.push(ans * 10 + tmp);
        if(tmp != 9){
            que.push((ans * 10) + (tmp + 1));
        }
        que.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    int n;
    scanf("%d", &n);

    vector<int> x(n);
    rep(i, n) scanf("%d", &x[i]);

    vector<int> y(x);
    sort(y.begin(), y.end());

    int lo = y[n / 2 - 1];
    int hi = y[n / 2];

    rep(i, n) {
        int ans = (x[i] <= lo) ? hi : lo;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4852
//#define LOCAL
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<random>
using namespace std;
using lld = long long int;
using llu = unsigned long long int;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using pll = pair<lld, lld>;
int n, m;
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	while (t--) {
		scanf("%d %d %d", &k, &n, &m);
		bool valid = false;
		for (i = n; i <= m; i++) {
			if (i % k == 0) {
				valid = true;
			}
		}
		printf("%s\n", valid ? "OK" : "NG");
	}
}

Measured memory_bytes: 1644
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        if(n==100) n++;
        long ans = n * (long)Math.pow(100,d);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  int ans = (N + 1) / 2;

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


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  ll b = 0, ans = 0;
  rep(i, s.size()) {
    if(s[i] == 'B')
      b++;
    else
      ans += b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
	int n;
	int i;
	int *data;
	double mean = 0.0;
	double sum = 0.0;
	double var = 0.0;
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		else{
			mean = 0.0;
			sum = 0.0;
			var = 0.0;
			data = (int *)malloc(sizeof(int) * n);
			for(i=0; i<n; i++){
				scanf("%d", &data[i]);
				sum += (double)data[i];
			}
			mean = sum / (double)n;
			
			for(i=0; i<n; i++){
				var += (mean - (double)data[i])*(mean - (double)data[i]);
			}		
			var = var / n;	

			printf("%lf\n", sqrt(var));
			free(data);
		}
	}
	return 0;

}


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

using namespace std;
using ll = long long;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    int i, j, n, k, h;
    cin >> n >> k;

    vector<ll> p(n), c(n);

    for(i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
    }

    for(i = 0; i < n; i++)
        cin >> c[i];
    
    ll bestAns = LONG_LONG_MIN;
    for(i = 0; i < n; i++){
        vector<ll> cost(n + 2, 0);
        int ini = i;
        for(j = 1, h = p[ini]; ; h = p[h], j++){
            cost[j] = cost[j - 1] + c[h];
            if (h == ini)
                break;
        }
        int loops = k / j;
        ll ans = LONG_LONG_MIN;
        if (loops)
            ans = max(*max_element(&cost[1], &cost[j + 1]), cost[j] * loops);
        if (cost[j] >= 0 && loops == 1){
            ans = max(ans, *max_element(&cost[0], &cost[(k % j) + 1]) + cost[j] * loops);
        }
        else if (cost[j] >= 0 && loops > 1){
            ans = max(max(ans, *max_element(&cost[0], &cost[(k % j) + 1]) + cost[j] * loops), *max_element(&cost[0], &cost[j + 1]) + cost[j] * (loops - 1));
        }
        else{
            ans = max(ans, *max_element(&cost[1], &cost[min(j, k) + 1]));
        }
        bestAns = max(bestAns, ans);
    }
    cout << bestAns << endl;
}

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

int main(){
    while(1){
        int n, y;
        cin >> n;
        
        if(n == 0)  break;
        
        cin >> y;
        
        int ans = -1;
        double maxmoney = -1;
        
        int b, r, t;
        for(int i = 0; i < n; i++){
            cin >> b >> r >> t;
            double tmpmoney = 1.0;
            
            if(t == 1){
                tmpmoney *= (1.0 + y*r/100.0);
            }else if(t == 2){
                tmpmoney *= pow(1.0 + r/100.0, y);
            }
            
            if(tmpmoney > maxmoney){
                ans = b;
                maxmoney = tmpmoney;
            }
        }
        
        cout << ans << endl;
    }
    return 0;
}



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

int main(){
    long long n;
    string s;
    cin>>n>>s;
    long long sum=1;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]) sum++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 512
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let a: u32 = sc.read();
    let b: u32 = sc.read();
    let c: u32 = sc.read();
    let d: u32 = sc.read();
    println!("{}", cmp::min(a, b) + cmp::min(c, d));
}

Measured memory_bytes: 2124
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read(int n, int m)
{
	vector<vector<T>> v;
	REP(i,n) { v.push_back(read<T>(m)); }
	return v;
}

template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

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

/// template end ///

void solve()
{
	READ(int, datasets);
	REP(dataset, datasets)
	{
		READ(int, y, m, d);
		int days = 0;
		while (true)
		{
			if (y == 1000 && m == 1 && d == 1) { break; }

			d++;

			if (y % 3 == 0 && d == 21 // 閏年
				|| y % 3 != 0 && m % 2 == 1 && d == 21 // 大の月
				|| y % 3 != 0 && m % 2 == 0 && d == 20 // 小の月
				) { d = 1; m++; }

			if (m == 11) { y++; m = 1; }

			days++;
		}

		write(days);
	}
}

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

int main(){
    int n, m, x;
    cin >> n >> m>> x;
    int a[m];
    rep(i, m) cin >> a[i];

    int left=0, right=0;
    for(int i=0; i<m; i++){ // 左側の探索
        if(a[i]>0 && a[i]<x)
            left++;
        if(a[i]>x && a[i]<n)
            right++;
    }
    
    if(left > right)
        cout << right << endl;
    else 
        cout << left << endl;
    return 0;
}

Measured memory_bytes: 3592
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  [r] <- readInt
  if r < 1200
    then putStrLn "ABC"
    else if r < 2800
           then putStrLn "ARC"
           else putStrLn "AGC"


Measured memory_bytes: 380
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<random>
using namespace std;
int inf = 1e9;

int main() {

  vector<double> x(4);
  vector<double> y(4);
  while( cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3] ){
    double ax = x[1]-x[0];
    double ay = y[1]-y[0];
    double bx = x[3]-x[2];
    double by = y[3]-y[2];
    if( fabs(ax*bx + ay*by) < 1e-10 ){
      cout << "YES" << endl;
    }else cout << "NO" << endl;

  }

  return 0;
}




// EOF

Measured memory_bytes: 3140
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String data1 = sc.nextLine();
        String data2 = sc.nextLine();
        
        int n = Integer.parseInt(data1);
        
        String[] array2 = data2.split(" ");
        
        int[] shain = new int[n];
        
        for(int i = 0; i < array2.length; i++)
        {
            int buf = Integer.parseInt(array2[i]);
            shain[buf - 1] ++;
        }
        
        for(int j = 0; j < n; j++)
        {
            System.out.println(shain[j]);
        }
        
    }
}


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

int main(){
	int n;
	cin >> n;
	bool trans=false;
	long long ans[201]={};
	int coo[n]={};
	for (int i=0;i<n;i++){
		cin >> coo[i];
		if (coo[i]<0){
			trans=true;
		}
	}
	if (trans){
		for (int i=0;i<n;i++){
			coo[i]+=100;
		}
	}
	
	if (n==2){
		int temp=(coo[1]+coo[0])/2;
		cout << pow(temp-coo[1],2)+pow(temp-coo[0],2);
	}else{
		for (int i=0;i<=200;i++){
			for(int j=0;j<n;j++){
					ans[i]+=pow(abs(coo[j]-i),2);
			}
		}
		sort(ans,ans+201);
		cout << ans[0];
	}
		return 0;

}




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

using namespace std;

int main(){
	string s,a;
	for (int i = 0; i < 3; i++){
        cin >> s;
        a += s[0];
	}
    for (int i = 0; i < 3; i++){
        a[i] -= 32;
    }
    for (int i = 0; i < 3; i++){
        cout << a[i];
	}

return 0;
}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void printvi(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printvil(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}
void printvvi(vector<vector<int>> v){
    rep(i,0,v.size()){
        rep(j,0,v[i].size())cout<<v[i][j];
        cout<<endl;
    }
}
void printvstr(vector<string> v){
    rep(i,0,v.size()){
        cout<<v[i]<<endl;
    }
}

signed main (){
    int n;
    cin>>n;
    if(n<1000)cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;

    
}
/*

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t,u;
int a,b;
int main()
{
	cin>>s>>t>>a>>b>>u;
	for(int i=0;i<u.size();i++)
	{
		if(s[i]!=u[i]){b--;break;}
		if(t[i]!=u[i]){a--;break;}
	}
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin>>N;
long long counter=0;
long long a[N]={};
long long x;
cin>>x;
for(long long i=0;i<N;i++){
cin>>a[i];}
sort(a,a+N);
for(long long i=0;i<N;i++){
if(x-a[i]>0){
counter++;
x-=a[i];
continue;}
else if (x-a[i]==0){
x-=a[i];
counter++;
break;
}
else
break;}
if(N==counter&&x>0){
  counter--;}
cout<<counter<<endl;}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int simulate(const string &s, const vector<pair<char, char>> &td, int pos) {
  for (auto c : td) {
    if (s[pos] != c.first) {
      continue;
    }
    if (c.second == 'L') pos--;
    else pos++;
    
    if (pos < 0) return -1;
    if (pos >= (int)s.size()) return 1;
  }
  return 0;
}

int solve(int N, const string &s, const vector<pair<char, char>> &td) {
  int low = -1, high = N;
  while(high - low > 1) {
    int mid = (low + high) / 2;
    if (simulate(s, td, mid) == -1) low = mid;
    else high = mid;
  }
  int left_fall = high;
  
  low = -1, high = N;
  while(high - low > 1) {
    int mid = (low + high) / 2;
    if (simulate(s, td, mid) == 1) high = mid;
    else low = mid;
  }
  int right_fall = N - 1 - low;
  
  return N - (left_fall + right_fall);
}

int main(){
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<pair<char, char>> td(Q);
  for (int i = 0; i < Q; i++) {
    cin >> td[i].first >> td[i].second;
  }
  cout << solve(N, s, td) << endl;
  return 0;
}


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

//最大公約数を求める関数 O(logb)
int64_t gcd(int64_t a, int64_t b){
    return b ? gcd(b, a % b) : a;
}

int main(){
    int n;
    cin >> n;
    int a[111000];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int ans = a[0];
    for(int i=1; i<n; i++){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
s = input()
e_count = [0]*(n+1)
w_count = [0]*(n+1)
for i in range(n):
    if s[i] == "E":
        e_count[i+1] = e_count[i] + 1
        w_count[i+1] = w_count[i]
    else:
        w_count[i+1] = w_count[i] + 1
        e_count[i+1] = e_count[i]
#print(w_count)
#print(e_count)
ans = n+1
for i in range(1, n+1):
    res = 0
    res += w_count[i-1]
    res += e_count[n] - e_count[i]
    ans = min(ans, res)
print(ans)

Measured memory_bytes: 47064
#include<bits/stdc++.h>
#define N 200001
using namespace std;
int n,zero,ans;
char str[N]; 
int main(void){
	int i;scanf("%d%s",&n,str+1);
	for(i=1;i<=n;++i)zero+=(str[i]=='R');
	for(i=1;i<=zero;++i)ans+=(str[i]=='W');
	printf("%d\n",ans);
	return 0;
}




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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  ll ans = 1e18;
  for(int i = 0;i<=max<ll>(x, y)*2;i++) {
    ll sum = 0;
    sum += c * i;

    ll xx = x - i/2;
    ll yy = y - i/2;
    if(xx > 0)
      sum += xx * a;
    if(yy > 0)
      sum += yy * b;
    ans = min<ll>(ans, sum);
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()] #N
ans = 'Yes'
down = True
if H[0] == 0:
    down = False
 
for i in range(N-1):
    if down:
        if H[i+1] - H[i] >= 0:
            down = True
        elif H[i+1] - H[i] == -1:
            down = False
        else:
            ans = 'No'
            break
    else:
        if H[i+1] - H[i] >= 1:
            down = True
        elif H[i+1] - H[i] == 0:
            down = False
        else:
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    string s; cin>>s;
    for(int i = 0; i < s.size(); i+=2){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 592
# include <iostream>
using namespace std;
int main()
{
	int n,p;
	p=0;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		if((i+1)%2!=0 && a[i]%2!=0)
		{
			p=p+1;
		}
	}
	cout<<p;
}

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


int main() {
    long a,b,r,x,temp;
    cin >> a >> b;
    x = a * b;
    if(a < b){
        temp = a;
        a = b;
        b = temp;
    }
    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    cout << x / b;



}


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

using namespace std;
constexpr int MOD = 1e9 + 7;

int N, K;
long dp[101][101010];

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

	// 具体例
	// n = 3
	// 3以下 -> 1 
	// 3/2以下 -> 2
	// 3/3以下 -> 3
	// 3/2 == 3/3 <- 同一の状態からの遷移と考えてよい。
	// N / i (i = 1 ~ N)の取りうる値の種類は
	// 10だったら
	// 10(1), 5(2), 3(3), 2(4,5), 1(6,7,8,9,10)
	// 例えば4,5からは2以下にしか遷移できないし6,7,8,9,10からは1にしか遷移できない。=> divをN/iのソート済み配列とすると、div[M-1-i]以下からはdiv[i](=>累積和使う)に遷移する。
	// N/iの取りうる値を列挙し、その値を取りうる数の個数を控えておき、遷移時に掛け合わせればよい。

	vector<int> div;
	for (int i = 0; i * i <= N; ++i) {
		div.push_back(i);
		if (i != 0) div.push_back(N / i);
	}
	sort(div.begin(), div.end());
	int M = div.size() - 1;


	dp[0][0] = 1;
	for (int i = 1; i <= K; ++i) {
		for (int j = 1; j < M; ++j) (dp[i - 1][j] += dp[i - 1][j - 1]) %= MOD;
		for (int j = 0; j < M; ++j) {
			dp[i][j] = dp[i - 1][M - 1 - j] * (div[j+1] - div[j]) % MOD;
		}
	}

	long ans = 0;
	for (int i = 0; i < M; ++i) ans = (ans + dp[K][i]) % MOD;
	cout << ans << endl;
	return 0;
}

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

// これは昔落ちものゲームを作ったことがあるので、事実上やったことがある。しかし忘れてしまった。即興で解くしかない。

int H;
int S[10][5];

int shokyo_1(int r) { // 消去部分に0を入れ、得点を返す
  for (int i=5; i>=3; i--) { // 消去個数
    for (int j=0; j<=5-i; j++) { // 判定開始地点
      int temp = S[r][j];
      bool ok = true;
      if (temp == 0) continue;
      for (int k=j; k<j+i; k++) {
	if (temp != S[r][k]) {
	  // cerr << "r = " << r << ", i = " << i << ", j = " << j << ", k = " << k << ", S[r][k] = " << S[r][k] << endl;
	  ok = false;
	  break;
	}
      }
      if (ok) {
	// cerr << "r = " << r << ", i = " << i << ", j = " << j << endl;
	for (int k=j; k<j+i; k++) {
	  S[r][k] = 0;
	}
	return temp * i;
      }
    }
  }
  return 0;
}

int shokyo() {
  int sum = 0;
  for (int i=0; i<H; i++) {
    sum += shokyo_1(i);
  }
  return sum;
}

void swap(int r_0, int c_0, int r_1, int c_1) {
  int temp1 = S[r_1][c_1];
  S[r_1][c_1] = S[r_0][c_0];
  S[r_0][c_0] = temp1;
  // cerr << "r_0 = " << r_0 << ", c_0 = " << c_0 << ", r_1 = " << r_1 << ", c_1 = " << c_1 << ", temp1 = " << temp1 << endl;
}

void tsumeru_1(int c) {
  for (int i=H-1; i>=1; i--) {
    // cerr << "i = " << i << endl;
    if (S[i][c] == 0) {
      for (int j=i-1; j>=0; j--) {
	// cerr << "j = " << j << endl;
	if (S[j][c] != 0) {
	  swap(i, c, j, c);
	  break;
	}
      }
    }
  }
}

void tsumeru() {
  for (int c=0; c<5; c++) {
    tsumeru_1(c);
  }
}

int main() {
  while (scanf("%d", &H) != EOF && H) {
    for (int i=0; i<H; i++) {
      for (int j=0; j<5; j++) {
	scanf("%d", &S[i][j]);
      }
    }
    int sum = 0;
    int temp;
    while (true) {
      temp = shokyo();
      if (temp == 0) break;
      /*cerr << "--now--" << endl;
      for (int i=0; i<H; i++) {
	for (int j=0; j<5; j++) {
	  cerr << S[i][j] << " ";
	}
	cerr << endl;
      }
      cerr << "--end--" << endl;*/
      sum += temp;
      tsumeru();
    }
    printf("%d\n", sum);
  }
}

Measured memory_bytes: 1172