akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

	int n;
	cin >> n;
	vllint a(n + 1);

	a[0] = 2;
	a[1] = 1;

	for (int i = 2; i <= n; i++) {
		a[i] = a[i - 2] + a[i - 1];
	}

	cout << a[n] << rt;

	please AC;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<char> a(h*w);

    rep(i, h*w){
        cin >> a.at(i);
    }
    
    rep(i, h*w){
        if( i == 0 ){
            rep(j, w+2){
                cout << "#" ;
            }
            cout << endl << "#";
        }

        cout << a.at(i);
        
        if( (i+1) % w == 0 )cout << "#" << endl << "#";

        if( i == h*w-1 ){
            rep(j, w+1){
                cout << "#";
            }
            cout << endl;
        }

    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std; 
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b){
        if (b<c){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS=1e-10;
const double PI=acos(-1.0);

vvi box(100, vi(2, 0));

void pick(int toru) {
	if(box[toru][1] != -1) {
		pick(box[toru][1]);
		box[toru][1] = -1;
	}

	if(box[toru][0] != -1) {
		box[box[toru][0]][1] = -1;
		box[toru][0] = -1;
	}
}

void put(int noru, int noseru) {
	if(box[noru][1] != -1) {
		put(box[noru][1], noseru);
	} else {
		box[noru][1] = noseru;
		box[noseru][0] = noru;
	}
}

bool search(int toru, int noseru) {
	if(box[toru][0] == -1) {
		return true;
	}
	else if(box[toru][0] == noseru) {
		return false;
	}
	else {
		return search(box[toru][0], noseru);
	}
}

int takasa(int num, int h) {
	if(box[num][1] == -1) {
		return h;
	} else {
		++h;
		return takasa(box[num][1], h);
	}
}



int main(){
	int m;

	while(cin >> m, m) {
		REP(k, m) {
			box[k][0] = -1;
			box[k][1] = -1;
		}

		int i, j;
		while(cin >> i >> j, i!=0||j!=0) {
			if(i == j) {
				continue;
			}

			if(i==0) {
				continue;
			}

			if(j==0) {
				if(box[i-1][0] != -1) {
					pick(i-1);
				}
				continue;
			}

			bool isShita = search(i-1, j-1);

			if(isShita) {
				pick(i-1);
				put(j-1, i-1);
			}
		}

		vi height;

		REP(i, m) {
			if(box[i][0] == -1) {
				height.push_back(takasa(i, 1));
			}
		}

		sort(ALL(height));

		REP(i, height.size()) {
			cout << height[i] << endl;
		}

		cout << "end" << endl;
	}

}

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

 int gcd(long x,long y){
   int r;
   if(x<y)swap(x,y);

   while(y>0){
     r=x%y;
     x=y;
     y=r;
   }
   return x;
 }


 int main(){
   int N;
   long long X,x1;
   cin>>N>>X;
   cin>>x1;
   long a=abs(X-x1);
   for(int i=0;i<N-1;i++){
     long x;
     cin>>x;
     long b=gcd(abs(X-x),a);
     if(a>=b)a=b;
   }
   cout<<a<<endl;

   return 0;

 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
    char str1[201], str2[101], str3[101];
    scanf("%s", str1);
    scanf("%s", str2);

    strcpy(str3, str1);
    strcat(str1, str3);

    if(strstr(str1, str2) == NULL) 
        printf("No\n");
    else
        printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <climits>
#include <cmath>

int main(){
  int n;
  std::cin >> n;
  long long d[100000];
  long long h[100000];
  //int* d = new int[n]; 
  //int* h = new int[n]; 
  for(int i=0;i<n;i++){
    std::cin >> h[i];
    d[i] = LLONG_MAX;//INT_MAX;
  }
  
  d[0] = 0;
  d[1] = std::abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    d[i] = std::min(d[i], std::abs(h[i]-h[i-1])+d[i-1]);
    d[i] = std::min(d[i], std::abs(h[i]-h[i-2])+d[i-2]);
    
  }
  
  std::cout << d[n-1];
  
  //delete h;
  //delete d;
  return 0;
}


Measured memory_bytes: 1792
###
# main
if(__name__ == '__main__'):
    # input
    n, k = map(int, input().split(" "))
    a = list(map(int, input().split(" ")))

    pos_li = []
    tele_dic = {}
    current = 0
    ans = 0
    for i in range(k):
        if current in tele_dic:
            # detect loop
            cycle = i - tele_dic[current]
            mod = (k - tele_dic[current]) % cycle
            ans = pos_li[tele_dic[current]+mod]
            break
        else:
            pos_li.append(current)
            tele_dic[current] = i
            current = a[current]-1
    else:
        ans = current

    # output
    print(ans+1)
# else:
    # do nothing


Measured memory_bytes: 33124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
   ll N, K;
    cin>>N>>K;
    vector<ll> A(N);
    vector<ll> B(41, 0);
    rep(i, N){
        cin>>A[i];
        ll C=A[i];
        rep(j, 41){
            if(C%2==0)B[j]++;
          	C/=2;
        }
    }
  	rep(i, 41){
      	if(B[i]>N/2){
			B[i]=1;
        }
      	else{
          	B[i]=0;
        }
    }
  	
  	ll tot=0;
  	for(ll i=40; i>=0; i--){
      	ll num=1ll<<i;
		if(B[i]&&tot+num>K){
          	B[i]=0;
        }
      	else{
          	tot+=B[i]*num;
        }
    }
  	ll Ans=0;
  	rep(i, N){
      	Ans+=tot^A[i];
    }
    cout<<Ans<<endl;
}
     

Measured memory_bytes: 1024
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    t=x=y=0
    for _ in range(n):
        nt,nx,ny=MI()
        d=abs(x-nx)+abs(y-ny)
        dt=nt-t
        if d&1!=dt&1 or d>dt:
            print("No")
            exit()
        t,x,y=nt,nx,ny
    print("Yes")

main()

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

namespace contest10
{
    class Program
    {
        static void Main(string[] args)
        {
            var read_line_origin = Console.ReadLine();

            if (string.IsNullOrEmpty(read_line_origin))
            {
                return;
            }

            //三角形の数
            int all_num = int.Parse(read_line_origin);

            
            //空白で分割する

            for (int i = 0; i < all_num; i++)
            {
                read_line_origin = Console.ReadLine();
                string[] words = read_line_origin.Split();

                //配列の要素、すべてに処理を行う
                var num_array = Array.ConvertAll(words, len => double.Parse(len));

                //三角形の座標
                double x1 = num_array[0];
                double y1 = num_array[1];
                double x2 = num_array[2];
                double y2 = num_array[3];
                double x3 = num_array[4];
                double y3 = num_array[5];

                //辺の長さ
                double r1 = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
                double r2 = Math.Sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
                double r3 = Math.Sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
                double radius = (r1 * r2 * r3) / Math.Sqrt((r1 + r2 + r3) * (-r1 + r2 + r3) * (r1 - r2 + r3) * (r1 + r2 - r3) );


                double x = (((x1 * x1 + y1 * y1) * (y2 - y3)) +
                            ((x2 * x2 + y2 * y2) * (y3 - y1)) +
                            ((x3 * x3 + y3 * y3) * (y1 - y2)))
                            /
                            ((x1 * (y2 - y3)) +
                             (x2 * (y3 - y1)) +
                             (x3 * (y1 - y2))
                            ) * 0.5;
                double y = (((x1 * x1 + y1 * y1) * (x2 - x3)) +
                            ((x2 * x2 + y2 * y2) * (x3 - x1)) +
                            ((x3 * x3 + y3 * y3) * (x1 - x2))) / 
                            ((y1 * (x2 - x3)) + 
                             (y2 * (x3 - x1)) + 
                             (y3 * (x1 - x2))
                            ) * 0.5;



                Console.WriteLine("{0:f3} {1:f3} {2:f3}", x, y, radius);
            }




        }
    }
}

Measured memory_bytes: 5688
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	if (b - a + 1 - 2 * k <= 0) {
		for (int i = a; i <= b; i++) {
			cout << i << endl;
		}
		return 0;
	}
	for (int i = a; i <= a + k - 1;i++) {
		cout << i << ' ';
	}
	for (int i = b-k+1; i <= b; i++) {
		cout << i << endl;
	}
	return 0;
}




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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int h, a;
    cin >> h >> a;
    int ans = 0;
    while(h > 0) {
        ans++;
        h -= a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define __ cout<<fixed;cout<<setprecision(10);
#define int long long
#define fori(a,b) for(int i = a ; i < b ; i++)
#define forj(a,b) for(int j = a ; j < b ; j++)

void solve() {
	int n;
	cin >> n;
	if (n >= 1800) {
		cout << "1\n";
		return;
	}
	if (n >= 1600) {
		cout << "2\n";
		return;
	}
	if (n >= 1400) {
		cout << "3\n";
		return;
	}
	if (n >= 1200) {
		cout << "4\n";
		return;
	}
	if (n >= 1000) {
		cout << "5\n";
		return;
	}
	if (n >= 800) {
		cout << "6\n";
		return;
	}
	if (n >= 600) {
		cout << "7\n";
		return;
	}
	cout << "8\n";
}

int32_t main() {
	_ __
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

#ifndef ONLINE_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

Measured memory_bytes: 3688
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
#pragma endregion

int main()
{
  init_main();

  int n;
  cin >> n;
  int Max = -1, num;
  for (int i = 1; i <= n; i++)
  {
    int t = i;
    int cnt = 0;
    while (t % 2 == 0)
    {
      t /= 2;
      cnt++;
    }
    if (Max < cnt)
    {
      Max = cnt;
      num = i;
    }
  }
  cout << num << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    rep(i, N) {
        cin >> s[i];
    }
    int M;
    cin >> M;
    vector<string> t(M);
    rep(i, M) {
        cin >> t[i];
    }
    set<string> s2(s.begin(), s.end());
    set<string> t2(t.begin(), t.end());
    int ans = 0;
    int tmp = 0;
    auto itr = s2.begin();
    rep(i, s2.size()) {
        rep(j, s.size()) {
            if (*itr == s[j]) tmp += 1;
        }
        rep(j, t.size()) {
            if (*itr == t[j]) tmp -= 1;
        }
        ans = max(ans, tmp);
        tmp = 0;
        itr++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R')
        {
            cnt++;
        }
        else
        {
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3648
import java.io.*;
import java.math.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        String s[]=bu.readLine().split(" ");
        long a=Long.parseLong(s[0]),b=Long.parseLong(s[1]),n=Long.parseLong(s[2]),ans=0;
        long x=Math.min(n,b-1);
        ans=(long)Math.floor((a*x)/b);
        System.out.print(ans);
    }
}


Measured memory_bytes: 32732
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int a = x.nextInt();
		int b = x.nextInt();
		int c = x.nextInt();
		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

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

int main(){
	int N, sum = 0;
	int a[1000000], b[1000000] = {};
	int i = 0;
	cin >> N;
	
	for (int i = 0; i < N-1; i++) {
		cin >> a[i];
		b[a[i]-1]++;
	}
	for (int i = 0; i < N; i++) {
		cout << b[i] << endl;
	}
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};


const int MAX_V = 1e5;
vector<int> G[MAX_V];

set<int> used_v;
set<PII> used_e;
int ord[MAX_V], lowlink[MAX_V];
int k = 0;

void calc_lowlink(int v)
{
    used_v.insert(v);
    ord[v] = lowlink[v] = k++;

    for (auto u : G[v]) {
        if (!used_v.count(u)) {
            used_e.insert(PII(v, u));
            calc_lowlink(u);
            lowlink[v] = min(lowlink[v], lowlink[u]);
        } else if (!used_e.count(PII(u, v))) {
            // backward edge
            lowlink[v] = min(lowlink[v], ord[u]);
        }
    }
}

vector<PII> calc_bridge(int N)
{
    vector<PII> res;
    for (int v=0; v<N; v++) {
        for (auto u : G[v]) {
            if (ord[v] < lowlink[u]) {
                res.emplace_back(min(v, u), max(v, u));
            }
        }
    }
    return res;
}


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

    rep(i, M) {
        int U, V;
        cin >> U >> V;
        // U--, V--;
        G[U].push_back(V);
        G[V].push_back(U);
    }

    calc_lowlink(0);
    vector<PII> bridges = calc_bridge(N);
    sort(bridges.begin(), bridges.end());

    for (auto p : bridges) {
        cout << p.first << " " << p.second << endl;
    }

    /*
    rep(i, N) {
        cout << ord[i] << " " <<  lowlink[i] << endl;
    }
    */
}

Measured memory_bytes: 7768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int cnt = 0;
    for(int i=1; i<=n; i+=2) {
        int tmp_cnt = 0;
      for(int j=1; j<=i; j++){
        if(i%j==0) {
          tmp_cnt += 1;
        }
      }
      if(tmp_cnt == 8) {
        cnt+=1;
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 23124
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N = int(input())
    edge = [[] for _ in range(N)]
    order = dict()
    for i in range(N-1):
        a, b = map(int, input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        order[(min(a-1, b-1), max(a-1, b-1))] = i
    K = 0
    for i in range(N): K = max(K, len(edge[i]))
    
    q = deque()
    col = [-1] * N
    col[0] = 0
    colE = [-1] * (N - 1)
    colPointer = 1
    for next in edge[0]: 
        q.append((0, next))
        col[next] = colPointer
        colE[order[(0, next)]] = colPointer
        colPointer += 1
    while q:
        parentNode, nowNode = q.popleft()
        colPointer = 1
        for nextNode in edge[nowNode]:
            if nextNode != parentNode:
                q.append((nowNode, nextNode))
                if colPointer == col[nowNode]: colPointer += 1
                col[nextNode] = colPointer
                colE[order[(min(nowNode, nextNode), max(nowNode, nextNode))]] = colPointer
                colPointer += 1

    print(K)
    for c in colE: print(c)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 46928
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, R;
    cin >> N >> R;
    if (N < 10)
    {
        cout << R + ((10 - N) * 100) << endl;
    }
    else
        cout << R << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 100000
#define INF (NUM_MAX+1)


int main(void) {
    int num, llimit;
    int arr[NUM_MAX];

    get_int2(&num, &llimit);
    fget_array(arr, num);

    int left;
    int right = 0;
    int sum = 0;
    int ans = INF;
    for(left = 0; left < num; left++) {
        for(; right < num; right++) {
            if(sum >= llimit) break;
            sum += arr[right];
        }
        // no need to search
        if(sum < llimit) break;
#ifdef DEBUG
        printf("%d %d -> %d\n", left, right, sum);
#endif
        ans = min(ans, right-left);
        sum -= arr[left];
    }
    printf("%d\n", ans == INF ? 0 : ans);
    return 0;
}


Measured memory_bytes: 2236
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

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

	string res;
	if (N == 0 || N == 1)
		cout << N << endl;
	else
	{
		while (true)
		{
			if (N < 0)
			{
				int tmp = abs(N);
				if (tmp%2 == 1)
				{
					res.push_back('1');
					N = tmp/2 + 1;
				}
				else
				{
					res.push_back('0');
					N = tmp/2;
				}
			}
			else
			{
				if (N%2 == 1)
				{
					res.push_back('1');
				}
				else
				{
					res.push_back('0');
				}
				N = -1*(N/2);
			}
			if (abs(N) == 1)
			{
				if (N == -1)
				{
					res.push_back('1');
					res.push_back('1');
				}
				else
					res.push_back('1');
				break;
			}
		}
		reverse(res.begin(), res.end());
		cout << res << endl;
	}

	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<pair<int, int>> v(n), iv(n);
  for (int i = 0; i < n; i++)
    cin >> v[i].first >> v[i].second;
  for (int i = 0; i < n; i++)
    iv[i].first = v[i].second, iv[i].second = v[i].first;
  sort(v.begin(), v.end());
  sort(iv.rbegin(), iv.rend());
  pair<int, int> f,s;
  if (n&1^1) {
    f.first = v[n/2-1].first + v[n/2].first;
    f.second = v[n/2-1].second + v[n/2].second;
    
    s.second = iv[n/2-1].first + iv[n/2].first;
    s.first = iv[n/2-1].second + iv[n/2].second;
  }
  else {
    f = v[n/2];
    s.first = iv[n/2].second;
    s.second = iv[n/2].first;
  }
  f.second = min(f.second, s.second);
  s.first = max(f.first, s.first);
  cout << f.second-f.first+1 + s.second-s.first+1 - max(f.second-s.first+1, 0);
  return 0;
}


Measured memory_bytes: 6384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] num = new int[n];
			for (int i = 0; i < n; i++) {
				num[i] = scanner.nextInt();
			}
			int m = scanner.nextInt();
			int count = 0;
			int l = 0;
			int r = n - 1;
			while (l <= r) {
				count++;
				int mid = (r + l) / 2;
				if (num[mid] > m) {
					r = mid - 1;
				} else if (num[mid] < m) {
					l = mid + 1;
				} else {
					break;
				}

			}
			System.out.println(count);
		}

	}
}

Measured memory_bytes: 20340
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,ans=1e9,x=0,w=0;
    char C[200001];
    cin>>n;
    rep(i,n){
        cin>>C[i];
        if(C[i]=='W') x++;
    }
    rep(i,n+1){
        if(i>0&&C[n-i]=='W') w++;
        ans=min(ans,abs(i-x)+(i-w));
    }
    cout<<ans;
}

Measured memory_bytes: 3848
//AOJ
//2018/07/08
//F_Naru

#include<iostream>
using namespace std;

int main(){
  int hst[3];
  hst[0]=0;
  hst[1]=0;
  hst[2]=0;
  int h;

  for(int i=0; i<10; i++){
    cin >> h;
    if(hst[0]<h){
      hst[2]=hst[1];
      hst[1]=hst[0];
      hst[0]=h;
    }else if(hst[1]<h){
      hst[2]=hst[1];
      hst[1]=h;
    }else if(hst[2]<h){
      hst[2]=h;
    }
  }
  
  cout << hst[0] << endl;
  cout << hst[1] << endl;
  cout << hst[2] << endl;

  return 0;
}



Measured memory_bytes: 3052
#include <stdio.h>

int main()
{
	int n, x, score;
	int i, j, k, a, b, c;

	while (1)
	{
		score = 0;
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0)
			break;
		for (i = 0; i < n; i++)
		{
			for (j = 1; j < n - i; j++)
				{
				for (k = 1; k < n - j - i; k++)
				{
					c = n - i - j - k;
					b = n - i - j;
					a = n - i;
					if ((a + b + c) == x)
						score++;
				}
			}
		}
		printf("%d\n", score);
	}
		return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define N 200020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
char ch[N];
int main(int argc, char const *argv[]) {
  scanf("%s", ch + 1);
  int n = strlen(ch + 1);
  int T = 0, S = 0;
  for (int i = 1; i <= n; ++ i) {
    if (ch[i] == 'T') {
      if (S) -- S;
      else ++ T;
    }
    if (ch[i] == 'S') {
      ++ S;
    }
  }
  printf("%d\n", S + T);
  return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> primes = new ArrayList<Integer>();
		final int MAX_SIZE = 100000;
		boolean[] sieve = new boolean[MAX_SIZE];
		sieve[0] = sieve[1] = true;
		int[] divisors = new int[n + 2];
		for(int i = 0; i < n + 2; ++i){ divisors[i] = 1; }
		int fixed = 0;
		for(int i = 2; i < MAX_SIZE; ++i){
			if(sieve[i]){ continue; }
			primes.add(i);
			for(int j = i; j < MAX_SIZE; j += i){
				if(j < n + 2 && divisors[j] == 1){
					++fixed;
					divisors[j] = i;
				}
				sieve[j] = true;
			}
			if(fixed >= n){ break; }
		}
		BigInteger base = BigInteger.valueOf(1);
		for(int i = 0; i < primes.size(); ++i){
			int p = primes.get(i).intValue();
			base = base.multiply(BigInteger.valueOf(p));
		}
		base = base.add(BigInteger.valueOf(2));
		System.out.println(base.toString(10));
		for(int i = 2; i < divisors.length; ++i){
			System.out.println(divisors[i]);
		}
	}
}

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

int main(){
  long n,k;
  cin >> n >> k;
  if(n>=k)cout << min(n%k,k-n%k);
  else cout << min(k-n,n);
  return 0;
}

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

    cout << max(-1LL, N - sum) << endl;
    return 0;
}

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

int main(void) {
    int N, M;
    cin >> N >> M;

    int A[M+1] = { 0 };
    for (int m = 0; m < N; m++) {
        int k;
        cin >> k;
        for (int i = 0; i < k; i++) {
            int a;
            cin >> a;
          A[a]++;
        }
    }

    int res = 0;
    for (int i = 0; i < M+1; i++) {
      //cout << i << " " << A[i] << endl;
        if (A[i] == N) res++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, m;
int h[100009];
struct edge {
    int to;
    edge(int to) : to(to) {}
};
vector<edge> G[100009];

int main() {
    cin >> n >> m;
    reps(i, n) { scanf("%d", &h[i]); }
    rep(i, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = n;
    reps(i, n) {
        for (auto &e : G[i]) {
            if (h[i] <= h[e.to]) {
                ans--;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9168
using System;

namespace ITP1_9_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string w = Console.ReadLine().ToUpper();
            int cnt = 0;
            while (true)
            {
                string line = Console.ReadLine();
                if (line.Equals("END_OF_TEXT")) break;
                string[] strs = line.ToUpper().Split(' ');
                foreach (var s in strs) if (s.Equals(w)) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

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

int main() {
	int n, x;
	cin >> n;
	
	cin >> x;
	long min = x, max = x, sum = x;
	for (int i=2; i<=n; i=i+1) {
		cin >> x;
		sum = sum + x;
		if (x < min) min = x;
		if (x > max) max = x;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}


Measured memory_bytes: 3100
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numA = nextInt();
		int numB = nextInt();

		int cnt = 0;
		for (int i = 0; i < 2; i++) {
			if (numA > numB) {
				cnt += numA;
				numA--;
			} else {
				cnt += numB;
				numB--;
			}
		}

		out.println(cnt);
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21076
<?php
// C
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
for ($i = 0; $i < $n; $i++) $aa[] = $a[$i] - ($i + 1);
sort($aa);
$b = $aa[intdiv($n, 2)];
$ans = 0;
for ($i = 0; $i < $n; $i++) $ans += abs($a[$i] - ($i + 1) - $b);
echo $ans;

Measured memory_bytes: 31220
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;

ll chk(ll a[], int N, bool t)
{
  ll total = 0;
  ll ops = 0;
  for (int i = 0; i < N; i++) {
    total += a[i];
    if (t == true && (total < 1)) {
      ops += (1-total);
      total = 1;
    } else if (t == false && (total > -1)) {
      ops += (total+1);
      total = -1;
    }
    t = !t;
  }
  return ops;
}

int main ()
{
  ll N;
  cin >> N;
  ll a[1000001];

  for (ll i = 0; i < N; i++) {
    cin >> a[i];
  }

  printf("%ld\n", min(chk(a, N, true), chk(a, N, false)));

}




Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int d_num(int n){
  int cnt = 0;
  for(int i=1; i<=n; i++){
    if(n%i == 0) cnt++;
  }
  return cnt;
}
int main(){
  int N;
  cin >> N;
  int cnt = 0;
  for(int i=1; i<=N; i=i+2){
    if(d_num(i) == 8) cnt++;
  } 
  cout << cnt << endl;
  return 0;
}

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

int main(){
  char k;
  cin >> k;
  if(k == 'a' || k == 'i' || k == 'u' || k == 'e' || k == 'o')
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

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

  int n; cin >> n;
  array<int, 2> mx{};
  set<int> vis;
  while (n--) {
    int a; cin >> a;
    if (vis.count(a)) {
      vis.erase(a);
      for (int i = 0; i < 2; ++i) {
        if (a > mx[i]) {
          swap(a, mx[i]);
        }
      }
    } else {
      vis.emplace(a);
    }
  }

  cout << static_cast<LL>(mx[0]) * mx[1] << '\n';

  return 0;
}


Measured memory_bytes: 8212
#include <stdio.h>
int n, k;
int f(int x) {
	int a = 0;
	for(int i = 1; i <= x * 7; i++) {
		if(i % 7 != 1 && i % 7 != 0 && i * 9 % 11 == k) { a++; }
	}
	return a;
}
int main() {
	scanf("%d%d", &n, &k);
	n--;
	printf("%d\n", n / 11 * 5 + f(n % 11) - f(1));
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;
const int maxx = 1e3 + 10;

int main()
{
    int n,m;
    string ss[maxx];
    while(cin>>n>>m)
    {
        for(int i=0; i<n; i++)
            cin>>ss[i];
        sort(ss,ss+n);
        for(int i=0; i<n; i++)
            cout<<ss[i];
        puts("");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 5005
const ll INF = 1e9 + 7;

struct circle {

	double x;
	double y;
	double r;
};

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

const ll MOD = 1e9 + 7;

int main() {

	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;

	vector<char> c(q), t(q);
	for (int i = 0; i < q; i++)
	{
		cin >> c[i] >> t[i];
	}

	int ng = -1;
	int ok = n;

	while (ok - ng > 1)
	{
		int mid = (ok + ng) / 2;//ここまでは左に落ちる

		int idx = mid;

		bool flag = false;

		for (int i = 0; i < q; i++)
		{
			if (s[idx] == c[i])
			{
				if (t[i] == 'L')
				{
					idx--;
				}
				else
				{
					idx++;
				}
			}
			if (idx < 0)
			{
				flag = true;
				break;
			}
			if (idx >= n)
			{
				
				flag = false;
				break;
			}
		}

		if (flag)
		{
			ng = mid;
		}
		else
		{
			ok = mid;
		}
	}

	int ng2 = -1;
	int ok2 = n;

	while (ok2 - ng2 > 1)
	{
		int mid = (ok2 + ng2) / 2;//ここまでは左に落ちる

		int idx = mid;

		bool flag = false;

		
		for (int i = 0; i < q; i++)
		{
			if (s[idx] == c[i])
			{
				if (t[i] == 'L')
				{
					idx--;
				}
				else
				{
					idx++;
				}
			}
			if (idx < 0)
			{
				flag = false;
				break;
			}
			if (idx >= n)
			{
				flag = true;
				break;
			}
		}
		if (flag)
		{
			ok2 = mid;
		}
		else
		{
			ng2 = mid;
		}
	}

	cout << ok2 - ok << endl;


	return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
constexpr uint64_t L1 = 1ull;
constexpr ull bit(int n){ return 1ull << n;}

// for(auto && i : Range(l,r))
// -> i = [l..r)
class Range {
private: struct It{ int x; int operator*(){return x;}
 bool operator!=(It& lhs){ return x<lhs.x;} void operator++(){++x;} }; It l,r;
public: Range(int n):l({0}),r({n}){} Range(int i,int n):l({i}),r({n})
 {}It& begin(){return l;} It& end(){return r;} };

void solve(istream& cin) {
    ll N, L, T;
    while(cin >> N >> L >> T){
        vector<ll> V, W;
        for (int i = 0; i < N; ++i) {
            int tmp;
            cin >> tmp;
            V.push_back(tmp);
            cin >> tmp;
            W.push_back(tmp == 1 ? 1 : -1);
        }
        ll col_n = 0;
        for (int i = 1; i < N; ++i) {
            if(W[0] != W[i]){
                ll tcol = -W[0] * V[0] - W[i] * V[i];
                tcol = (tcol + L) % L;
                if (tcol < 2*T){
                    ll tm = 2*T - tcol-1;
                    tcol = 1 + tm / L;
                }
                else tcol = 0;
                col_n += tcol;
            }
        }
        ll num0 = (W[0] * col_n);
        num0 = (num0 + 1000000ll*N) % N;
        ll ls0 = (V[0] + W[0] * T + 10000000*L) % L;
        vector<ll> last;
        last.push_back(ls0);
        for (int i = 1; i < V.size(); ++i) {
            last.push_back((V[i] + W[i] * T + 10000000*L) % L);
//            cerr << "last[" << i << "] :" << last.back() << endl;
        }
        sort(last.begin(), last.end());
        vector<ll> ans(N);
        auto pos0l = lower_bound(last.begin(), last.end(), ls0);
        auto pos0u = upper_bound(last.begin(), last.end(), ls0);
        if(pos0u - pos0l == 2){
            if(W[0] == -1){
                num0--;
            }
        }
        for (int i = 0; i < N; ++i) {
            ans[(i+num0) % N] = *pos0l;
            pos0l++;
            if(pos0l == last.end()) pos0l = last.begin();
        }
        for (int i = 0; i < N; ++i) {
            cout << ans.at(i) << '\n';
        }
    }
}

int main(int argc, char *argv[]) {
    string FileName("AGC013C"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    if(sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size()-ExecutionName.size(), ExecutionName.size());
    cerr << sub << endl;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        solve(cin);
    }
    else {
        string inFile = "sample.txt";
        auto fs = fstream(inFile, fstream::in);
        solve(fs);
    }
}

Measured memory_bytes: 4460
s=list(input())
s_new=[]
ans=0
flag=False
for i in range(len(s)-1):
  if flag==True:
    flag=False
    continue
  if s[i]=="B" and s[i+1]=="C":
    s_new.append("P")
    flag=True
  else:
    s_new.append(s[i])
s_new="".join(s_new)
import re
s_new=re.split("[BC]",s_new)
s_new=[list(i) for i in s_new if i]
for i in range(len(s_new)):
  count=0
  for j in range(len(s_new[i])):
    if s_new[i][-j-1]=="P":
      count+=1
    else:
      ans+=count
print(ans)

Measured memory_bytes: 12724
n,k,*v=map(int,open(0).read().split())
m=0
r=range
for i in r(n+1):
 for j in r(min(k,n)-i+1):
  t=sorted(v[:i]+v[::-1][:j])
  while t and(k-i-j)*t[0]<0:t.pop(0);j+=1
  m=max(m,sum(t))
print(m)

Measured memory_bytes: 3060