akhauriyash/Code-Regression huggingface dataset:
import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict

# import numpy as np

sys.setrecursionlimit(10**5 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7
# MOD = 998244353


x = read_item()
n = 0
cur = 100
while cur < x:
    n += 1
    cur += cur // 100
print(n)

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

int cube[30];
int tmp;

bool check() {
  for (int k = 1; k < 9; k++) {
    if (cube[0] != cube[k]) return false;
  }
  for (int k = 22; k < 30; k++) {
    if (cube[21] != cube[k]) return false;
  }

  if (cube[9] != cube[10] || cube[9] != cube[11]) return false;
  if (cube[12] != cube[13] || cube[12] != cube[14]) return false;
  if (cube[15] != cube[16] || cube[15] != cube[17]) return false;
  if (cube[18] != cube[19] || cube[18] != cube[20]) return false;

  return true;
}

void draw() {
  for (int j = 0; j < 30; j++) cout << cube[j] << " ";
  cout << endl;
}

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int dfs(int num) {
  if (num > 8 || check()) return num;
  int ans = 9;

  swap(&cube[2], &cube[21]);
  swap(&cube[5], &cube[24]);
  swap(&cube[8], &cube[27]);
  swap(&cube[11], &cube[18]);
  swap(&cube[12], &cube[14]);
  ans = min(dfs(num+1), ans);
  swap(&cube[2], &cube[21]);
  swap(&cube[5], &cube[24]);
  swap(&cube[8], &cube[27]);
  swap(&cube[11], &cube[18]);
  swap(&cube[12], &cube[14]);

  swap(&cube[0], &cube[27]);
  swap(&cube[1], &cube[28]);
  swap(&cube[2], &cube[29]);
  swap(&cube[14], &cube[15]);
  swap(&cube[18], &cube[20]);
  ans = min(dfs(num+1), ans);
  swap(&cube[0], &cube[27]);
  swap(&cube[1], &cube[28]);
  swap(&cube[2], &cube[29]);
  swap(&cube[14], &cube[15]);
  swap(&cube[18], &cube[20]);

  swap(&cube[6], &cube[21]);
  swap(&cube[7], &cube[22]);
  swap(&cube[8], &cube[23]);
  swap(&cube[12], &cube[17]);
  swap(&cube[9], &cube[11]);
  ans = min(dfs(num+1), ans);
  swap(&cube[6], &cube[21]);
  swap(&cube[7], &cube[22]);
  swap(&cube[8], &cube[23]);
  swap(&cube[12], &cube[17]);
  swap(&cube[9], &cube[11]);

  swap(&cube[0], &cube[23]);
  swap(&cube[3], &cube[26]);
  swap(&cube[6], &cube[29]);
  swap(&cube[9], &cube[20]);
  swap(&cube[15], &cube[17]);
  ans = min(dfs(num+1), ans);
  swap(&cube[0], &cube[23]);
  swap(&cube[3], &cube[26]);
  swap(&cube[6], &cube[29]);
  swap(&cube[9], &cube[20]);
  swap(&cube[15], &cube[17]);

  return ans;
}

int main() {

  int num;
  cin >> num;

  for (int i = 0; i < num; i++) {
    for (int j = 0; j < 30; j++) cin >> cube[j];
    cout << dfs(0) << endl;
  }

	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
typedef long long ll;
using namespace std; 
int main() { 
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin>>x;
  if(x>=400&&x<=599){
    cout<<8<<endl;
 }else if(x>=600&&x<=799){
    cout<<7<<endl;
 }else if(x>=800&&x<=999){
    cout<<6<<endl;
 }else if(x>=1000&&x<=1199){
    cout<<5<<endl;
 }else if(x>=1200&&x<=1399){
    cout<<4<<endl;
 }else if(x>=1400&&x<=1599){
    cout<<3<<endl;
 }else if(x>=1600&&x<=1799){
    cout<<2<<endl;
 }else if(x>=1800&&x<=1999){
    cout<<1<<endl;
 }
  return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
from heapq import *

a = [*range(1, 10)]
heapify(a)
i = 0
k = int(input())
c = 0
while True:
    t = str(heappop(a))
    i += 1
    if i == k:
        break
    if t[-1] != "0":
        heappush(a, int(t + str(int(t[-1]) - 1)))
    heappush(a, int(t + t[-1]))
    if t[-1] != "9":
        heappush(a, int(t + str(int(t[-1]) + 1)))
print(t)


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

int main(){
    char a[100000];
    scanf("%s",a);
    int cnt=0;
    while(a[cnt]!='\0'){
        cnt++;
    }
    int b[100000]={0};
    for(int i=0;i<cnt;i++){
        if(a[i]=='R' && a[i+1]=='L'){
            b[i]++;b[i+1]++;
            int temp1=1,temp2=2;
            while(a[i-temp1]=='R' && (i-temp1)>=0){
                b[i+(temp1%2)]++;
                temp1++;
            }
            while(a[i+temp2]=='L' && (i+temp2)<cnt){
                b[i+(temp2%2)]++;
                temp2++;
            }
        }
    }
    for(int i=0;i<cnt;i++){
        printf("%d ",b[i]);
    }
}


Measured memory_bytes: 896
#include <iostream>
#include <stdio.h> // forget this in cpp and not err but cannot io?
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    //puts("a");
    
    while( scanf("%d %d",&a,&b)!= EOF  ){//while( scanf("%d %d",&a,&b)!= EOF || ( a!=0 && b!=0 ) ){ //while( scanf("%d %d",&a,&b)!= EOF || !( a==0 && b==0 ) ){
         //if( a==0 && b==0 ) break;
    for(int i=0; i<a; i++){//for(int i; i<a; i++){
         for(int j=0; j<b; j++){//for(int j; j<a; j++){
            printf("#");
                             }   
        if( i!=a-1 ) puts("");
                        }
        if( a==0 && b==0 ) break;
                        puts("");
                        puts("");
        //if( a==0 && b==0 ) break;  //if( a!=0 && b!=0  ) 
                        //puts("");
                        //puts("a");
    }            

    return 0;
}




Measured memory_bytes: 3148
#include<stdio.h>
int main()
{
  int n,a,b,ans;
  scanf("%d%d%d",&n,&a,&b);
  ans=n*a;
  if(ans>b)
  {
    printf("%d\n",b);
  }
  else
  {
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=998244353;
const long long INF = 1LL<<60;

int main() {
  int64_t N,K,T=0; cin>>N>>K;
  vector<int64_t> R(2*K);
  rep(i,2*K){
    cin>>R[i];
    if(i%2==1)R[i]++;
  }
  vector<int64_t> DP(N,0);
  DP[0]=1;
  for(int64_t i=0;i<N;i++){
    if(i>1)DP[i]+=DP[i-1];
    DP[i]%=MOD;
    auto k=DP[i];
    rep(j,2*K){
      auto r=R[j];
      if(i+r>=N) continue;
      if(j%2==0){
        DP[i+r]+=k;
        DP[i+r]%=MOD;
      }
      else if(j%2==1){
        DP[i+r]-=k;
      }
    }
  }
  cout<<(DP[N-1]+MOD)%MOD;
}



Measured memory_bytes: 4840
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  string s;
  cin >> s;
  sort(s.begin(), s.end());

  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

const int INF = 1e9;

int dp[10010];
int main(){
    int h,n;
    cin >> h >> n;

    vi dmg(n),mp(n);
    rep(i,n){
        cin >> dmg[i] >> mp[i];
    }

    rep(j,10010){
        dp[j] = INF;
    }
    dp[0] = 0;

    rep(i,n){
        rep(j,10010){
            dp[j] = min(dp[j],dp[max(0,j-dmg[i])] + mp[i]);
        }
    }
    // rep(i,h+1){
    //     cout << dp[i] << " ";
    // }cout << endl;
    cout << dp[h] << endl;
    return 0;
}

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

int main()
{
	bool dic[10000000] = { 0 };
	long n = 0;
	long long k = 0;
	string st1, st2;

	cin >> n;

	for (long i = 0; i < n; i++) {
		cin >> st1 >> st2;
		k = 0;

		for(unsigned int j = 0; j < st2.size(); j++)
			switch (st2[j]) {
			case 'A':
				k += (long long)pow(5, j);
				break;
			case 'C':
				k += (long long)pow(5, j) * 2;
				break;
			case 'G':
				k += (long long)pow(5, j) * 3;
				break;
			case 'T':
				k += (long long)pow(5, j) * 4;
				break;
			}

		if (st1 == "insert")
			dic[k] = 1;
		else if (st1 == "find"){
			if(dic[k] == 1)
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
	}
	return 0;
}

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

int main()
{
  int N;
  ll res=0;
  ll Lm2=2, Lm1=1;
  cin >> N;

  if(N==0) res = Lm2;
  else if(N==1) res = Lm1;
  else {
    for(int i=2;i<=N;i++){
      res = Lm1 + Lm2;
      Lm2 = Lm1;
      Lm1 = res;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define spl set<pll>
#define lb lower_bound
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll mod=1e9+7;
const ll maxs=1e6+6;
ll max2d=1e3+3;
ll INF = 9e18;

int main(){
    ll N; cin>>N;
    ll a[N+1]; 
    for(ll i=1; i<=N; i++) cin>>a[i];
    ll dp[N+1]; mem(dp, 0);
    ll pref[N+1]; mem(pref, 0);
    pref[1] = a[1]; pref[2] = a[2];
    dp[1] = 0; dp[2] = max(a[1],a[2]);
    for(ll i=3; i<=N; i++){
        pref[i] = a[i] + pref[i-2];
        if(i&1) dp[i] = max(a[i]+dp[i-2] , dp[i-1]); 
        else dp[i] = max(a[i]+dp[i-2] , pref[i-1]);
    }
    cout<<dp[N];
    return 0;
}

Measured memory_bytes: 8332
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
using namespace std;


int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	long long int ans = 0;
	int N;
	cin >> N;
	vector<string> S;
	for(int i=0; i<N; i++) {
		string s;
		cin >> s;

		sort(s.begin(), s.end());
		S.push_back(s);
	}
	sort(S.begin(), S.end());
	int cnt = 0;
	string prev = "";
	for(int i=0; i<N; i++) {
		if(prev == S[i]) {
			ans += cnt;
			cnt++;
		} else {
			prev = S[i];
			cnt = 1;
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 5748
#include<stdio.h>
static const int N = 100;

void bubbleSort(int *A,int n){
  int i,j,key,count=0;
  for(i=0;i<n;i++)
    {
      for(j=n-1;j>0;j--)
	{
	  if(A[j]<A[j-1])
	    {
	      key=A[j];
	      A[j]=A[j-1];
	      A[j-1]=key;
	      count++;
	    }
	}
    }
  for(i=0;i<n-1;i++)printf("%d ",A[i]);
  printf("%d",A[i]);
  printf("\n%d\n",count);
}
        
int main(){
  int i,n;
  int A[N];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  bubbleSort(A,n);
 
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

char s[100100];
char t[4][11] = {"dream", "dreamer", "erase", "eraser"};
int l[4] = {5, 7, 5, 6};
int ok[100100];

bool match(int pos, int k) {
	FOR(i,l[k]) if (s[pos+i] != t[k][i]) return 0;
	return 1;
}

void test() {
	scanf("%s", s);
	int n;
	for (n=0; s[n]; n++) ;
	ok[n] = 1;
	for (int i=n-1; i>=0; i--) {
		FOR(k,4) {
			if (match(i, k)) ok[i] |= ok[i+l[k]];
		}
	}
	printf("%s\n", ok[0] ? "YES" : "NO");
}

int main() {
	int ttn=1;
	//scanf("%d", &ttn);
	while (ttn--) test();
	return 0;
}


Measured memory_bytes: 768
n = int(input())
a = list(map(int, input().split()))

cnt = {}
for ai in a:
    if ai in cnt:
        cnt[ai] += 1
    else:
        cnt[ai] = 1

ans = 0
for k, v in cnt.items():
    if k < v:
        ans += v - k
    elif v < k:
        ans += v
print(ans)

Measured memory_bytes: 67240
#include<stdio.h>
int main()
{
	int a,b;
	char x[11],s[10],t[10];
	scanf("%s %s",s,t);
	scanf("%d %d",&a,&b);
	scanf("%s",x);
	if(x[0]==s[0]) printf("%d %d",a-1,b);
	else printf("%d %d",a,b-1);
	return 0;
}

Measured memory_bytes: 1736
n = int(input())
a = []
b = []
for i in range(n):
	x,y = map(int,input().split())
	a.append(x)
	b.append(y)
a.sort()
b.sort()
if(n&1):
	l = a[n//2]
	r = b[n//2]
else:
	l = a[n//2]+a[n//2-1]
	r = b[n//2]+b[n//2-1]
print(r-l+1)


Measured memory_bytes: 99020
#include<stdio.h>

int main()
{
	int i;
	char S[4][4];
	for(i=0; i<3; i++){
		scanf("%s",S[i]);
	}
	
	printf("%c%c%c\n",S[0][0],S[1][1],S[2][2]);
	
	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
typedef long long ll;
using namespace std;

int main() {
    int abck[4], total = 0;
    rep(i, 4) cin >> abck[i];
    total += abck[3] > abck[0] ? abck[0] : abck[3];
    abck[3] -= abck[0] + abck[1];
    total -= abck[3] > 0 ? abck[3] : 0;
    printInt(total);
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
#define F(I,N) for(int I=0;I<N;I++)

int main(){
	int n;
	int p,q;
	while(cin>>n){
		p=100000;
		q=100;
		F(i,n){
			p+=p*5/100;
			q+=q*5/100;
			if(p>q*1000) q++;
			p=q*1000;
		}
		cout<<p<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	bool flag = true;
	REP( i,(int)S.size() )
	{
		int count{};
		REP( j, (int)S.size() )
		{
			if( S[i] == S[j] )
			{
				count++;
			}
		}
		if( count % 2 != 0 )
		{
			flag = false;
			break;
		}
	}
	cout << ( flag ? "Yes" : "No" ) << endl;
	return 0;
}

Measured memory_bytes: 256
require 'set'
loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  points =
    k.times.map do
      c, a, b = gets.split
      a = a.to_i; b = b.to_i
      case c
      when 'xy'
        [a, b, 0]
      when 'yz'
        [0, a, b]
      when 'xz'
        [a, 0, b]
      end
    end

  cross_points = Set.new
  ans = n * n * n - k * n
  triple = Set.new
  points.combination(2).each do |a, b|
    c = a.zip(b)
    if c.all?{ |p, q| !(p == 0 && q == 0) } && c.any?{ |p, q| p == q }
      cp = c.map{ |p, q| [p, q].max }
      unless cross_points.include?(cp)
        cross_points << cp
        ans += 1
      else
        unless triple.include?(cp)
          triple << cp
          ans += 1
        end
      end
    end
  end
  puts ans
end

Measured memory_bytes: 8896
#include<cstdio>
char s[200001],t[200001];
int main(){
    scanf("%s%s",s,t);
    int m[256];
    bool si[256],ti[256];
    for(int i=0;i<256;i++){
        m[i]=-1;
        si[i]=false;
        ti[i]=false;
    }
    for(int i=0;s[i]!='\0';i++){
        if(m[s[i]]==-1)m[s[i]]=t[i];
        else if(m[s[i]]!=t[i]){
            printf("No");
            return 0;
        }
        si[s[i]]=true;
        ti[t[i]]=true;
    }
    int sn=0,tn=0;
    for(int i=0;i<256;i++){
        if(si[i])sn++;
        if(ti[i])tn++;
    }
    if(sn==tn)printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N = int(input())
ab = []

for i in range(N):
  ab.append(tuple(map(int, input().split())))

ab.sort(key=lambda x:x[1])
s = 0

for i in range(N):
  s += ab[i][0]
  if (s > ab[i][1]):
    print('No')
    exit()
else:
  print('Yes')

Measured memory_bytes: 76892
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long long,long long>
#define INF 1000000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	cout << max(a + b, max(a - b, a*b)) << endl;
	return 0;
}

Measured memory_bytes: 764
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
s = input()
cnt = 0
ans = 0
if s=="RRR":
    ans = 3
elif s=="SSS":
    ans=0
elif s=="RRS" or s=="SRR":
    ans =2
else:
    ans = 1
print(ans)


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  string s;

  cin >> s;

  cout << s.erase(s.size() - 8, 8) << "\n";
}


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

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

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (to_string(i).length() % 2 == 1) ans++;
    }

    cout << ans << endl;
}

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

using namespace std;

int main() {
    int n;

    cin >> n;

    float min = float(n) / 1.08;
    float max = float(n + 1) / 1.08;

    if (min - float(int(min)) == 0) {
        cout << int(min) << endl;
    } else {
        if (int(max) - int(min) < 1.0) {
            cout << ":(" << endl;
        } else {

            if (max - float(int(max)) == 0) {
                cout << ":(" << endl;
            } else {
                cout << int(max) << endl;
            }
        }
    }
}

Measured memory_bytes: 256
using System;


public class B
{	
	public static void Main()
	{	
		int N = Int32.Parse(Console.ReadLine());
		string s = Console.ReadLine();
		
		int r = 0;
		int b = 0;
		for(int i = 0; i < N; i++)
		{
			if(s[i] == 'R')
			{
				r++;
			}
			else
			{
				b++;
			}			
		}
		
		Console.WriteLine((r > b) ? "Yes" : "No");
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	
	for (int i = 0; i < h;i++)
	{
		cin >> s[i];
	}

	for (int i = 0;i < h;i++)
	{
		cout << s[i] << endl;
		cout << s[i] << endl;
	}

	return 0;
}

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

int main() {
  int n,m,c;
  cin >> n >> m >> c;
  int b[m];
  for (int i = 0; i < m; i++) cin >> b[i];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = 0; j < m; j ++) {
      int a;
      cin >> a;
      sum += a * b[j];
    }
    sum += c;
    if (sum > 0) ans++;
  }
  cout << ans << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] acopy = new int[n];
        for(int i = 0;i < n;i++){
            a[i] = sc.nextInt();
            acopy[i] = a[i];
        }
        Arrays.sort(a);

        for(int i =0;i < n;i++){
            if(a[n-1] == acopy[i]){
                System.out.println(a[n-2]);
            }else{
                System.out.println(a[n-1]);
            }
        }

    }
}

Measured memory_bytes: 91692
ide = 0
def func(a,b):
  return max(a,b)
class SegmentTree:
  def __init__(self,ls,commutative = True):
    if commutative == True:
      self.n = len(ls)
      self.tree = [ide for i in range(self.n)]+ls
    else:
      self.n = 2**((len(ls)-1).bit_length())
      self.tree = [ide for i in range(self.n)]+ls+[ide for i in range(self.n-len(ls))]
    for i in range(1,self.n)[::-1]:
      self.tree[i] = func(self.tree[i<<1|0],self.tree[i<<1|1])
  def getall(self):
    return self.tree[1]
  def get(self,l,r):
    lret = ide
    rret = ide
    l += self.n
    r += self.n
    while l < r:
      if l&1:
        lret = func(lret,self.tree[l])
        l += 1
      if r&1:
        rret = func(self.tree[r-1],rret)
      l >>= 1
      r >>= 1
    ret = func(lret,rret)
    return ret
  def update(self,i,x):
    i += self.n
    self.tree[i] = x
    while i > 1:
      i >>= 1
      self.tree[i] = func(self.tree[i<<1|0],self.tree[i<<1|1])

n = int(input())
h = list(map(int,input().split()))
b = list(map(int,input().split()))
dp = [0 for i in range(n+1)]
ST = SegmentTree(dp)
for i in range(1,n+1):
  hi = h[i-1]
  bi = b[i-1]
  x = ST.get(0,hi)
  ST.update(hi,x+bi)
print(ST.getall())

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

signed main() {
	string s1, s2, s3; cin >> s1 >> s2 >> s3;
	cout << s1[0]<< s2[1] << s3[2] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;


void solve()
{
	ll n,m;
	cin>>n>>m;
	vector<ll> a(n+1,0);
	for(ll i=0;i<m;i++)
	{
		ll c;
		cin>>c;
		a[c]=1;
	}
	// cout<<a[75]<<endl;;
	vector<ll> dp(n+2,0);
	dp[0]=1;
	if(a[1]==0)
		dp[1]=1;
	for(ll i=2;i<=n;i++)
	{
		if(a[i]==0)
		{
			/*if(i==45)
				cout<<"xx";*/
			dp[i]=dp[i-1]+dp[i-2];
			dp[i]%=MOD;
		}
		else
			dp[i]=0;
	}
	/*for(ll i=0;i<=n;i++)
		cout<<i<<"*"<<dp[i]<<endl;*/
	cout<<dp[n];
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 4752
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

string s[55];
string t[55];
int n, m;

bool check(int x, int y) {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (s[x + i][y + j] != t[i][j]) {
        return false;
      }
    }
  }
  return true;
}

int main() { 
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> t[i];
  }

  bool flag = false;

  for (int i = 0; i < n - m + 1; i++) {
    for (int j = 0; j < n - m + 1; j++) {
      if (check(i, j)) {
        flag = true;
      }
    }
  }

  if (flag) {
    D("Yes");
  } else {
    D("No");
  }
  return 0;
}



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

int main(){
    ll W;
    cin >> W;
    vector<ll>A(W), R(W, 0), L(W, 0);
    for(int i = 0; i < W; i++)cin >> A[i];
    for(ll i = 0, mx = 0; i < W; i++){
        mx--;
        if(A[i] == 0){
            mx = 202020;
            continue;
        }
        if(A[i] < 0){
            mx = min(mx, -A[i]);
            continue;
        }
        L[i] = min(A[i], mx);
    }
    for(ll i = W - 1, mx = 0; i >= 0; i--){
        mx--;
        if(A[i] == 0){
            mx = 202020;
            continue;
        }
        if(A[i] < 0){
            mx = min(mx, -A[i]);
            continue;
        }
        R[i] = max(min(A[i], mx), 0LL);
    }

    ll ans = 0;
    for(int i = 0; i < W; i++)ans += max(R[i], L[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

template<int M>
class ModInt {
   public:
    ll value;
    constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; }
    constexpr ModInt pow(ll n) const { if (!n) return 1; ModInt a = pow(n >> 1); a *= a; if (n & 1) a *= *this; return a; }
    constexpr ModInt inv() const { return this->pow(M - 2); }
    constexpr ModInt operator + (const ModInt &rhs) const { return ModInt(*this) += rhs; };
    constexpr ModInt operator - (const ModInt &rhs) const { return ModInt(*this) -= rhs; };
    constexpr ModInt operator * (const ModInt &rhs) const { return ModInt(*this) *= rhs; };
    constexpr ModInt operator / (const ModInt &rhs) const { return ModInt(*this) /= rhs; };
    constexpr ModInt &operator += (const ModInt &rhs) { value += rhs.value; if (value >= M) value -= M; return *this; };
    constexpr ModInt &operator -= (const ModInt &rhs) { value -= rhs.value; if (value <  0) value += M; return *this; };
    constexpr ModInt &operator *= (const ModInt &rhs) { value = value * rhs.value % M; return *this; };
    constexpr ModInt &operator /= (const ModInt &rhs) { return (*this) *= rhs.inv(); };
    constexpr bool operator == (const ModInt &rhs) { return value == rhs.value; }
    constexpr bool operator != (const ModInt &rhs) { return value != rhs.value; }
    friend ostream &operator << (ostream &os, const ModInt &rhs) { os << rhs.value; return os; }
};

using mint = ModInt<MOD>;

int main() {
    int H, W, K; cin >> H >> W >> K;

    vector<vector<mint>> dp(H + 1, vector<mint>(W, 0));
    dp[0][0] = 1;
    REP(i, 0, H) {
        REP(j, 0, W) {
            for (int bit = 0; bit < (1 << (W - 1)); bit++) {
                bool ok = true;
                REP(k, 0, W - 2) if ((bit & (1 << k)) && (bit & (1 << (k + 1)))) ok = false;
                if (!ok) continue;

                int nj = j;
                if (bit & (1 << j)) nj = j + 1;
                else if (j > 0 && (bit & (1 << (j - 1)))) nj = j - 1;

                dp[i + 1][nj] += dp[i][j];
            }
        }
    }
    cout << dp[H][K - 1] << endl;
    return 0;
}

Measured memory_bytes: 3620
def calc(i, j, B1, len_b):
    extra = 0
    d = j - i

    # i < j < k
    k1 = d + j
    if k1 < len_b:
        extra += B1[k1]

    # k < i < j
    k2 = i - d
    if 0 <= k2 and k2 < len_b:
        extra += B1[k2]

    # i < k < j
    s = i + j
    if s % 2 == 0:
        k3 = s // 2
        if k3 < len_b:
            extra += B1[k3]
    return extra

def main():
    N = int(input())
    S = input()
    R, G, B = [], [], []
    num_r, num_g, num_b = 0, 0, 0
    for i in range(N):
        s = S[i]
        if s == 'R':
            R.append(i)
            num_r += 1
        elif s == 'G':
            G.append(i)
            num_g += 1
        elif s == 'B':
            B.append(i)
            num_b += 1
    if len(R) == 0 or len(G) == 0 or len(B) == 0:
        print(0)
        return
    len_b = (B[-1] + 1)
    B1 = [0]*len_b
    for b in B:
        B1[b] = 1
    # print(R, G, B)
    ans = 0
    for i in R:
        for j in G:
            ans += num_b
            if i < j:
                ans -= calc(i, j, B1, len_b)
            else:
                ans -= calc(j, i, B1, len_b)
    print(ans)

if __name__ == '__main__':
    main()


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

#define int long long



typedef long long ll;
typedef long double ld;








signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    if(s == "ARC") cout<<"ABC";
    else cout<<"ARC";
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <cassert>
using namespace std;

const int N = 2e5 + 5;

#define lowbit(x) (x & (-x))

#define Pair pair<int,int>
    
int n , m , x , y , S[N];

void add(int x, int y) {
    for(int i = x;i < N;i += lowbit(i)) S[i] += y;
}

int sum(int x) {
    int res = 0;
    for(int i = x;i;i -= lowbit(i)) res += S[i];
    return res;
}

#define mp(x , y) make_pair(x , y)

char s[N];

vector<int>pos[33];
vector < Pair > res;

int main(void) {
   scanf("%s" , s + 1);
   n = strlen(s + 1);
   for(int i = 1;i <= n;++ i) pos[s[i] - 'a'].push_back(i);
   bool have = 0;
   int where = 0;
   for(int i = 0;i < 26;++ i) if(have && (pos[i].size() & 1)) {return puts("-1") * 0;} else if(pos[i].size() & 1) have = 1 , where = pos[i][pos[i].size() / 2];
   for(int i = 0;i < 26;++ i) {
       for(int j = 0;j < (int) pos[i].size() / 2;++ j) {
	   res.push_back(make_pair(pos[i][j], pos[i][pos[i].size() - 1 - j]));
       }
   }
   long long ans = 0;
   sort(res.begin(), res.end());
   for(int i = (int)res.size() - 1;i >= 0;-- i) {
       ans += (sum(n) - sum(res[i].second));
       add(res[i].first , 1);
       add(res[i].second , 1);
   }
   if(have) {
       for(int i = 0;i < (int)res.size();++ i) {
	   if(res[i].second < where || res[i].first > where) ++ ans;
       }
   }
   cout << ans << endl;
}


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

using ll = long long;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int base = n;
    int current_count = 0;
    vector<int> counts(n + 1, -1);
    counts[n] = 0;
    while (base > 0) {
        current_count++;
        int mn = -1;
        for (int i = 1; i <= m; i++) {
            if (base - i >= 0 && s[base - i] == '0') {
                counts[base - i] = current_count;
                mn = base - i;
            }
        }
        if (mn < 0) {
            cout << -1 << endl;
            return 0;
        }
        base = mn;
    }
    current_count--;
    int cur = 0;
    for (int i = 0; i <= n; i++) {
        if (counts[i] == current_count) {
            cout << i - cur << " ";
            cur = i;
            current_count--;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    rep(i, N)
    {
        cin >> A[i];
        sum += A[i];
    }
    ll center = 0;
    ll ans = LLONG_MAX;
    for (int i = 0; i < N - 1; i++) {
        center += A[i];
        ll right = sum - center;
        ll need = abs(right - center);
        ans = min(ans, need);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    bool fl=true;
    fo(i,n)
    {
        cin>>in;
        if(in%2==0&&in%3&&in%5)
            fl=false;
    }
    cout<<(fl?"APPROVED":"DENIED")<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define M 1000000007
#define INF 999999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define MAX 1000005
#define fs first
#define sc second 
#define N 3
using namespace std;
typedef unsigned long long int ll;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;
typedef vector <ll> vi;

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

ll lcm(ll a,ll b)
{
    ll g=gcd(a,b);
    return a/g*b;
}

int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios::sync_with_stdio(false);
 cin.tie(0);
 ll n;
 ll arr[105];
 cin>>n;
 for(ll i=0;i<n;i++)
    cin>>arr[i];
if(n==1)
{
    cout<<arr[0]<<endl;
    return 0;
}
 //cout<<1<<endl;
 ll ans=lcm(arr[0],arr[1]);
// cout<<ans<<endl;
 for(ll i=2;i<n;i++)
 {
   ans=lcm(ans,arr[i]);
   //cout<<ans<<endl;
 }
 cout<<ans<<endl;
return 0;

}

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

namespace atcoder174
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = list[0];
            var D = list[1];

            int ans = 0;

            for(var i = 0; i < N; i++)
            {
                var xy = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

                var distance = Math.Sqrt(Math.Pow(xy[0], 2) + Math.Pow(xy[1], 2));

                if (distance <= D) ans++;

            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 47080
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    point= 0
    for i in range(n):
        point += b[a[i]-1]
        if i != 0:
            if a[i-1]+1 == a[i]:
                point += c[a[i]-2]
    
    print(point)

    
if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);

using ll = long long;
using namespace std;
using ld = long double;
const int MAXN=1e6 + 5;



int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    int a,b;
    cin >> a >> b;
    int dem=0;
    int k=1;
    while (k<b)
    {
        k+=a-1;
        dem++;
    }
    cout << dem;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
using namespace std;

const int mod=1000000007;
const int N=100005;

int n,k,l,r,ans;
ll x,y;
int dp1[N],dp2[N],f[2][N],p1[N],p2[N];
ll a[N];

void add(bool b,int x,int y){
	for (;x<=n+5;x+=x&-x){
		f[b][x]+=y;
		(f[b][x]>=mod)?f[b][x]-=mod:0;
	}
}

int query(bool b,int x){
	int s=0;
	for (;x;x-=x&-x){
		s+=f[b][x];
		(s>=mod)?s-=mod:0;
	}
	return s;
}

int ask(bool b,int x,int y){
	int s;
	if (x>y) return 0;
	s=(query(b,y)-query(b,x-1)+mod)%mod;
	return s;
}

int main(){
	scanf("%d%lld%lld",&n,&x,&y);
	if (x>y) swap(x,y);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	l=r=n;
	for (int i=n;i>=1;i--){
		if (a[i+1]-a[i]<x) l=i;
		if (a[i+1]-a[i]<y) r=i;
		p1[i]=l;
		p2[i]=r;
	}
	for (int i=n;i>1;i--){
		if (p2[i]==n) dp1[i]=1;
		if (p1[i]==n) dp2[i]=1;
		
		l=lower_bound(a+1,a+1+n,a[i-1]+x)-a; l=max(l,i+1);
		r=p2[i]+1;
		dp1[i]+=ask(1,l,r);
		(dp1[i]>=mod)?dp1[i]-=mod:0;
		
		l=lower_bound(a+1,a+1+n,a[i-1]+y)-a; l=max(l,i+1);
		r=p1[i]+1;
		dp2[i]+=ask(0,l,r);
		(dp2[i]>=mod)?dp2[i]-=mod:0;
		
		add(0,i,dp1[i]);
		add(1,i,dp2[i]);
		if (p1[1]>=i-1) ans+=dp1[i];
		(ans>=mod)?ans-=mod:0;
		if (p2[1]>=i-1) ans+=dp2[i];
		(ans>=mod)?ans-=mod:0;
	}
	if (p1[1]==n) ans++;
	if (p2[1]==n) ans++;
	ans%=mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	string s, t;
	cin >> s >> t;
	vector<vector<int>> v(26);
	int n = s.size();
	s += s;
	rep(i,s.size()) {
		v[s[i] - 'a'].push_back(i);
	}
	int p = -1;
	ll x = 0;
	rep(i,t.size()) {
		int k = t[i] - 'a';
		if (!v[k].size()) {
			cout << -1 << endl;
			return 0;
		}
		p = v[k][upper_bound(v[k].begin(), v[k].end(), p) - v[k].begin()];
		if (p >= n) {
			x++;
			p %= n;
		}
	}
	cout << n * x + p + 1 << endl;
}

Measured memory_bytes: 4688
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int x,y,xy[2];
vector<int> A,a[2];

bool getDP_(int t){
	vector<int> dp;
	dp.push_back(0);
	rep(i,0,a[t].size()){
		vector<int> v;
		rep(j,0,dp.size()){
			v.push_back(dp[j]+a[t][i]);
			v.push_back(dp[j]-a[t][i]);
		}
		sort(v.begin(),v.end());
		v.erase(unique(v.begin(),v.end()),v.end());
		dp.clear();
		rep(j,0,v.size()) dp.push_back(v[j]);
	}
	if(*lower_bound(dp.begin(),dp.end(),xy[t]) == xy[t])return true;
	else return false;
}

void getDP(){
	if(getDP_(0) && getDP_(1))puts("Yes");
	else puts("No");
}

int main()
{
	string S;
	cin >> S >> x >> y;
	int f = 0;
	rep(i,0,S.size()){
		if(S[i] == 'T'){
			if(S[0] == 'F' && A.size() == 0){
				x -= f;
				A.push_back(0);
			}else{
				A.push_back(f);
			}
			f = 0;
		}else{
			f++;
		}
	}
	if(S[0] == 'F' && A.size() == 0)x -= f;
	else A.push_back(f);
	rep(i,0,A.size()){
		if(A[i]==0)continue;
		a[i%2].push_back(A[i]);
	}
	xy[0] = x;
	xy[1] = y;

	getDP();

	/*
	cout << "(" << x << "," << y << ")" << endl;
	rep(i,0,a[0].size())cout << a[0][i] << " ";
	cout << endl;
	rep(i,0,a[1].size())cout << a[1][i] << " ";
	cout << endl;
	*/

	return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, D[int(1e5 + 5)];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> D[i];
  sort(D, D + N);

  cout << D[N/2] - D[N/2 - 1] << endl;


  return 0;
}


Measured memory_bytes: 3932
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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 pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int main(){

    int n;cin >> n;

    vector<int> a(n);
    int mi = INT_MAX;
    int mx = INT_MIN;
    rep(i,n){
        cin >> a[i];
        if( i > 0 && a[i] - mi > mx){
            mx = a[i] - mi;
        }
        if(a[i] < mi){
            mi = a[i];
        }
    }

    cout << mx << endl;


}


Measured memory_bytes: 3520
#include <stdio.h>
#include <string.h>
#include <ctype.h>

void strLow(char *a);

int main(void){
  int count = 0;
  char w[10], t[15];

  scanf("%s", w);
  strLow(w);
  scanf(" %s", t);
  while(strcmp(t, "END_OF_TEXT") != 0){
    strLow(t);
    if(strcmp(t, w) == 0){
      count++;
    }
    scanf(" %s", t);
  }
  printf("%d\n", count);
  return 0;
}


void strLow(char *a){
  int i = 0;

  while(a[i] != '\0'){
    if(isalpha((int)a[i]) != 0){
      a[i] = (char)tolower((int)a[i]);
    }
    i++;
  }
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)

typedef long long ll;

using namespace std;
//using namespace boost::multiprec

int main(){

    int n;
    cin >> n;

    vector<int> a;

    rep(i,n){
        int tmp;
        cin >> tmp;
        a.pback(tmp);
    }

    deque<int> each_color_min;

    each_color_min.pback(a[0]);

    for(int i = 1; i < n; i++){

        if(a[i] <= each_color_min[0]){
            each_color_min.push_front(a[i]);
        }else{
            auto itr = lower_bound(ALL(each_color_min), a[i]);
            if(itr == each_color_min.begin()){
                assert(false);
            }else{
                itr--;
                int idx = itr - each_color_min.begin();

                each_color_min[idx] = a[i];
            }
        }
    }

    cout << each_color_min.size() << endl;

    
    return 0;
}

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

struct UnionFind {
    vector<ll> par;  // par[i]: parent of i
    vector<ll> siz;

    UnionFind(ll N) : par(N + 1), siz(N + 1, 1ll) {  // initialize by making every node a root node
        for (int i = 0; i <= N; i++) par[i] = i;
    }

    ll root(ll x) {  // find the root of a given node
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return;
    }

    bool issame(ll x, ll y) {  // return true if x and y belong to the same tree
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind railsTree(n), roadsTree(n);
    while (k--) {
        int p, q;
        cin >> p >> q;
        p--, q--;
        railsTree.unite(p, q);
    }
    while (l--) {
        int r, s;
        cin >> r >> s;
        r--, s--;
        roadsTree.unite(r, s);
    }
    map<pair<int, int>, int> counter;
    rep(i, n) {
        int ai = railsTree.root(i);
        int bi = roadsTree.root(i);
        counter[make_pair(ai, bi)]++;
    }
    rep(i, n) {
        int ai = railsTree.root(i);
        int bi = roadsTree.root(i);
        cout << counter[make_pair(ai, bi)] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 20504
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
    int x = 0, fh = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            fh = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar();
    }
    return x * fh;
}
const int N = 2010, MOD = 1e9 + 7;
int n, i;
LL f[N];
int main() {
	n = read();
	f[3] = f[4] = 1;
	for (i = 5; i <= n; i++) f[i] = ((f[i - 2] + f[i - 3]) % MOD + f[i - 4]) % MOD;
	cout << f[n] << '\n';
	return 0;
}

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

int main()
{
  int num = 0;
  int reserve = 0;
  cin >> num;
  vector<int> data(num);
  for(int i = 0; i < num; i++)
  {
    cin >> data.at(i);
  }
  for(int i = 0; i < num /2; i++)
  {
    reserve = data.at(i);
    data.at(i) = data.at(num - i - 1);
    data.at(num - i - 1) = reserve;
    //cout << i << "番:" << data.at(i) << "  " << num - i - 1 << "番:" << data.at(num - i - 1) << endl;
  }
  for(int i = 0; i < num; i++)
  {
    cout << data.at(i);
    if(i < num - 1)
    {
      cout << ' ';
    }
  }
  cout << endl;
}


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

#define ll long long
#define endl "\n"
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define f first
#define s second
#define vecll vector<ll>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<ll,ll>>
#define mapllll map<ll,ll>
#define mapstrll map<string,ll>
#define mapllvecll map<ll,vecll>
#define setll set<ll>
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL); cout.tie(NULL);

using namespace std;

ll const N=1e5+5;
ll const inf=1e18+5;
ll const MOD=1e9+7;

ll t,n,m,x,y,z,w,k;

int main()
{
    fio

    string s1,s2;
    cin>>x>>s1>>s2;

    for(ll i=0;i<x;i++)
    {
        cout<<s1[i]<<s2[i];
    }

    return 0;
}



Measured memory_bytes: 256