akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int, int, int> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    while (true) {
        int W, H;
        cin >> W >> H;
        
        if (W==0 && H==0) {
            break;
        }
        
        int tx, ty;
        cin >> tx >> ty;
        tx -= 1;
        ty -= 1;
        
        int kx, ky;
        cin >> kx >> ky;
        kx -= 1;
        ky -= 1;
        
        int d[H][W];
        
        for (int i=0; i<H; i++) {
            for (int j=0; j<W; j++) {
                cin >> d[i][j];
            }
        }
        
        int visited[H][W][H][W];
        
        for (int i=0; i<H; i++) {
            for (int j=0; j<W; j++) {
                for (int k=0; k<H; k++) {
                    for (int l=0; l<W; l++) {
                        visited[i][j][k][l] = -1;
                    }
                }
            }
        }
        
        queue<T> q;
        q.push(make_tuple(ty, tx, ky, kx, 0));
        
        bool flag = false;
        
        while (q.size()) {
            T t = q.front(); q.pop();
            int i1 = get<0>(t);
            int j1 = get<1>(t);
            int i2 = get<2>(t);
            int j2 = get<3>(t);
            int cost = get<4>(t);
            
            if (cost==100) {
                continue;
            }
            
            if (i1==i2 && j1==j2) {
                cout << cost << endl;
                flag = true;
                break;
            }
            
            for (int i=0; i<4; i++) {
                int ni1 = i1+dx[i];
                int nj1 = j1+dy[i];
                int ni2 = i2-dx[i];
                int nj2 = j2-dy[i];
                
                if (!(0<=ni1 && ni1<H && 0<=nj1 && nj1<W)) {
                    ni1 = i1;
                    nj1 = j1;
                }
                else if (d[ni1][nj1]==1) {
                    ni1 = i1;
                    nj1 = j1;
                }
                
                if (!(0<=ni2 && ni2<H && 0<=nj2 && nj2<W)) {
                    ni2 = i2;
                    nj2 = j2;
                }
                else if (d[ni2][nj2]==1) {
                    ni2 = i2;
                    nj2 = j2;
                }
                
                if (visited[ni1][nj1][ni2][nj2]==-1) {
                    visited[ni1][nj1][ni2][nj2] = 1;
                    q.push(make_tuple(ni1, nj1, ni2, nj2, cost+1));
                }
            }
        }
        
        if (flag) {
            continue;
        }
        
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 27660
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  double n,ans=0,tmp;
  cin>>n;
  vector<double> x(n),y(n);
  rep(i,n) cin>>x[i]>>y[i];
  tmp=Factorial(n-1);
  for(ll i=0;i<n-1;i++){
    for(ll j=i+1;j<n;j++){
      double aa=sqrt((double)pow((x[i]-x[j]),2)+(double)pow((y[i]-y[j]),2));
      ans+=aa/n;
    }
  }
  
  
  cout<<setprecision(10)<<ans*2<<endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            if (1 < N)
            {
                if (N % 2 == 0)
                {

                    if ((S.Substring(0, N / 2) == S.Substring(N / 2, N / 2)) && N % 2 == 0)
                    {
                        Console.WriteLine("Yes");
                    }
                    else
                    {
                        Console.WriteLine("No");
                    }
                }
                else
                {
                    if (S.Substring(0, N / 2) == S.Substring(N / 2, N / 2 + 1))
                    {
                        Console.WriteLine("Yes");
                    }
                    else
                    {
                        Console.WriteLine("No");
                    }
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

Measured memory_bytes: 11092
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%d",&i)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define 	mapp 	    map<int,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>s
#define 	set_it 	    set<int>::iterator si
#define     map_it      map<int,int> :: iterator mi
#define 	yes 	    cout<<"Yes"<<endl
#define 	no 	        cout<<"No"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          INT_MAX
#define     lmx         LLONG_MAX
#define     mn          INT_MIN
#define     lmn         LLONG_MIN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  // freopen ("(input).txt" , "r",  stdin) ;
  // string st,stt ;
  // int low=0,high=0;
  // int l,r;
    int n,k,t,b,c,x,y,z,d=0,temp=0,cnt=mx,sum=0,f=0;
    cin>>n  ; vect v(n) ,a  ; sett ; set_it ; mapp m,mp; pairr p; map_it;
    loop(i,n) cin>>v[i]; sorta(v);
    if(v[0]==v[n-1])
        cout<<0<<endl;
    else
    {

        for(int i=v[0];i<=v[n-1];i++)
        {
            for(int j=0;j<n;j++)
            {
                temp=abs(i-v[j]);
                sum+=temp*temp;
            }
            cnt=min(sum,cnt);
            sum=0;
        }
        cout<<cnt<<endl;
    }




}

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

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
template <typename T, typename U>
T max(T x, U y)
{
    return x>y ? x : y;
}
template <typename T, typename U>
T min(T x, U y)
{
    return x<y ? x : y;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;cin >> s >> t;cout << t+s;
    }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int n;
	cin>>n;
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;
  cout << endl;
}



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

int main(void){
	string str;
	int m, h, str_size;
	while(1){
		cin >>str;
		if(str=="-"){
			break;
		}
		str_size=str.size();
		cin >>m;
		for(int i=0; i<m; i++){
			cin >>h;
			str=str.insert(0, str.substr(h));
			str.erase(str_size);
		}
		cout <<str <<endl;
	}
    return 0;
}

Measured memory_bytes: 1236
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> P;
typedef pair<P, int> Q;

int n;
vector<Q> s;

int access(const P& p){
	vector<Q>::iterator it = lower_bound(s.begin(), s.end(), Q(p, 0));
	return it != s.end() && it->first == p ? it->second : 0;
}

int main(){
	scanf("%d", &n);
	rep(i, n){
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w);
		s.push_back(Q(P(x, y), w));
	}
	sort(s.begin(), s.end());
	int ans = 0;
	rep(i, n){
		int u = s[i].first.first;
		int v = s[i].first.second;
		int a = access(P(u - 1, v));
		int b = access(P(u - 1, v + 1));
		int c = access(P(u, v));
		int d = access(P(u, v + 1));
		int e = access(P(u + 1, v));
		int f = access(P(u + 1, v + 1));
		ans = max(max(a + b + c + d, c + d + e + f), ans);
	}
	printf("%d / 1\n", ans);
	return 0;
}

Measured memory_bytes: 2560
s = input().split()

if(s[0]=='5' and s[1]=='5' and s[2]=='7'):
  print("YES")
elif(s[0]=='5' and s[1]=='7' and s[2]=='5'):
  print("YES")
elif(s[0]=='7' and s[1]=='5' and s[2]=='5'):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
# 良さげだけどバグが取れない！！！！


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()
S = read()[:-1]
sum_0 = [0]
# 0のブロックの累積和を作成する
#  1 1 0 1 0 0 1だったら
# 0 0 0 1 1 2 2 2みたいな
now = '1'
for s_next in S:
    if s_next == '0' and now == '1':
        sum_0.append(sum_0[-1] + 1)
    else:
        sum_0.append(sum_0[-1])
    now = s_next

sum_0_2 = [0]
#  1 1 0 1 0 0 1だったら
# 0 0 0 1 1 1 2 2みたいな
# もし0で終わっていたら後ろに追加する。
for s_now, s_next in zip(S[:-1], S[1:]):
    if s_next == '1' and s_now == '0':
        sum_0_2.append(sum_0_2[-1] + 1)
    else:
        sum_0_2.append(sum_0_2[-1])

if S[-1] == '0':
    sum_0_2.append(sum_0_2[-1] + 1)
else:
    sum_0_2.append(sum_0_2[-1])

# print(S)
# print(sum_0)
# print(sum_0_2)

# [left,right)で考える
left = 0
right = 1
ans = 1  # 解初期値

# right-leftが答え
# sum_0[right]-sum0[left]がKを超えたらleftを進める
# print(sum_0)
# しゃくとり法で溶けそうでは？
for left in range(N - 1):
    while right < N:
        nextright = right+1
        # ここにバグの原因がここにあった。半端な00..00の途中から半端な00..00の途中までの引き算は正しく行われない
        if sum_0[nextright] - sum_0_2[left] > K:
            break
        right += 1
    #print(right, right < N)
    ans = max(ans, right - left)  # 大きい方に更新
    #print(left, right, ans, sum_0[nextright] - sum_0_2[left])

print(ans)


Measured memory_bytes: 8212
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] point = new int[n];
		int sum = 0;
		int sa = 0;
		int num = 0;
		for (int i = 0; i < n; i++) {
			point[i] = m + i;
			sum += point[i];
		}
		int min = Integer.MAX_VALUE / 10;
		for (int i = 0; i < n; i++) {
			int eated = sum - point[i];
			sa = Math.abs(sum - eated);
			if (min > sa) {
				num = i;
				min = sa;
			}
			}
		out.println(sum - point[num]);

	}
}

Measured memory_bytes: 25172
module Im = Map.Make(struct type t = int let compare = compare end)

let f n m =
  let rec aux m' map =
    if m' <= 0 then map
    else
      let a, b = Scanf.scanf "%d %d\n" (fun a b -> a, b) in
      let va = try Im.find a map with _ -> 0 in
      let vb = try Im.find b map with _ -> 0 in
      aux (pred m') (Im.add a (succ va) map |> Im.add b (succ vb))
  in
  let rec pr n' map =
    if n' > n then ()
    else
      (Printf.printf "%d\n" (try Im.find n' map with _ -> 0) ;
       pr (succ n') map)
  in
  aux m Im.empty |> pr 1

let () = Scanf.scanf "%d %d\n" f

Measured memory_bytes: 512
// Aizu 2286: Farey Sequence
// 2017.9.23 bal4u@uu
// ?????????????????¢??° ??(n)???????????????????????¬?????°??? Fn ????????°:
//???????????(1)?????(2)???...+??(n)
// ?????????, Fn(n) = Fn(n-1) + ??(n)???????????????Fn(0) = 1

#include <stdio.h>

#define MAX	 1000000
int phi[MAX+1];			// ??????????????¢??°??????
char isprime[MAX+1];	// ?´???°????????¨
long long fn[MAX+1];	// ??¬?????????Farey Sequence

void euler_phi()
{
	int i, j;

	for (i = 0; i <= MAX; i++) {
		phi[i] = i;
//		isprime[i] = 0;
	}
	phi[2] = 1;
	for (j = 4; j <= MAX; j += 2) isprime[j] = 1, phi[j] -= phi[j] >> 1;
	for (i = 3; i <= MAX; i++) {
		if (isprime[i]) continue;
		phi[i] -= phi[i] / i;
	    for (j = i+i; j <= MAX; j+=i) isprime[j] = 1, phi[j] -= phi[j] / i;
	}
}

int main()
{
	int t, n;

	euler_phi();
	fn[0] = 1; for (n = 1; n <= MAX; n++) fn[n] = fn[n-1] + phi[n];

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%d", &n);
		printf("%lld\n", fn[n]);
	}
	return 0;
}

Measured memory_bytes: 14456
#include <bits/stdc++.h>
#define int long long

using namespace std;

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

    int n;
    cin >> n;
    if(n % 1000 == 0) { cout << 0; return 0;}
    cout << 1000 - (n % 1000) << "\n";

    return 0;

}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Data
{
public:
    int a, b, w;
    bool operator<(const Data& d) const{
        return a < d.a;
    }
};

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<Data> d(n);
        for(int i=0; i<n; ++i)
            cin >> d[i].a >> d[i].b >> d[i].w;
        sort(d.begin(), d.end());

        vector<vector<int> > dp(366, vector<int>(366, 0));
        for(int i=0; i<n; ++i){
            for(int j=365; j>=0; --j){
                for(int k=365; k>=0; --k){
                    if(j < d[i].a)
                        dp[d[i].b][k] = max(dp[d[i].b][k], dp[j][k] + d[i].w);
                    if(k < d[i].a)
                        dp[j][d[i].b] = max(dp[j][d[i].b], dp[j][k] + d[i].w);
                }
            }
        }

        int ret = 0;
        for(int i=0; i<366; ++i){
            for(int j=0; j<366; ++j){
                ret = max(ret, dp[i][j]);
            }
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 1452
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a <= 8 && b <= 8) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	string t, u;
	cin >> s >> t;

	n = s.size();

	f = 0;
	u = "No";

	rep(i, n){
		f = 1;
		rep(j, n){
			if(s[(i+j)%n] != t[j]){
				f = 0;
				break;
			}
		}

		if(f == 1){
			u = "Yes";
			break;
		}
	}

	cout << u << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
int N,M;
vector<int> G[maxn];
bool dfs(int u,int d)
{
	if(u == N)    return true;
	if(d == 2)    return false;
	for(int v:G[u])
	    if(dfs(v,d+1))
	        return true;
	return false;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;
    int u,v;
	while(M--)
    {
    	cin >> u >> v;
    	G[u].push_back(v);
    	G[v].push_back(u);
	}
	if(dfs(1,0))
	    cout << "POSSIBLE" << endl;
	else
	    cout << "IMPOSSIBLE" << endl; 
    return 0;
}


Measured memory_bytes: 12016
fun main(args: Array<String>) {

    val (l, r) = readLine()!!.split(" ").map(String::toLong)

    println(func133c(l, r))
}

fun func133c(l: Long, r: Long): Any? {

    if (2019 <= r - l) {
        return 0
    }

    val rmin = Math.min(r, l + 2019 * 2)

    var ans = Long.MAX_VALUE
    for (i in l..rmin) {
        for (j in (i + 1)..rmin) {
            val x = (i * j) % 2019
            ans = Math.min(ans, x)
        }
    }

    return ans
}


Measured memory_bytes: 38000
from itertools import product

N = int(input())
ans = 0
for k in range(3,len(str(N))+1):
    for ptn in product((3,5,7), repeat=k):
        if 3 in ptn and 5 in ptn and 7 in ptn:
            if int(''.join([str(i) for i in ptn])) <= N:
                ans += 1
            else:
                break
print(ans)

Measured memory_bytes: 3060
n=int(input())
march=[0]*5
for _ in range(n):
    str=input()
    if str[0]=='M':
        march[0]+=1
        continue
    if str[0]=='A':
        march[1]+=1
        continue
    if str[0]=='R':
        march[2]+=1
        continue
    if str[0]=='C':
        march[3]+=1
        continue
    if str[0]=='H':
        march[4]+=1
        continue

ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
                ans+=march[i]*march[j]*march[k]
print(ans)


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int x;
    forn(i, n) {
        cin >> x;
        if (x % 2 == 0 && (x % 3 && x % 5)) {
            cout << "DENIED\n";
            return 0;
        }
    }
    cout << "APPROVED\n";
    return 0;
}

Measured memory_bytes: 256
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)

Measured memory_bytes: 20144
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
int N; string S[101010];
map<char, ll> m;
string march = "MARCH";
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> S[i];
    rep(i, 0, N) m[S[i][0]]++;
 
    ll ans = 0;
    rep(a, 0, 5) rep(b, a + 1, 5) rep(c, b + 1, 5) ans += m[march[a]] * m[march[b]] * m[march[c]];
    cout << ans << endl;
}

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

int main() {
    string w;
    cin >> w;
    string ans = "Yes";
    sort(w.begin(),w.end());
    if(w.size()%2==0){
        for(int i=0;i<w.size();i+=2){
            if(w.at(i)!=w.at(i+1)){
                ans = "No";
            }
        }
    }
    else{
        ans="No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    int N,M = 0;
    int pattern = 0;

    //標準入力
    cin >> N >> M;

    //NN:偶数
    //NM:奇数
    //MM:偶数
    if(N == 0)
    {
        //all奇数
        //MC2通り
        cout << (M*(M-1)/2) << endl;
        return 0;
    }
    if(M == 0)
    {
        //all偶数
        //NC2通り
        cout << (N*(N-1)/2) << endl;
        return 0;
    }

    //M=1,N=1なら0
    if(N == 1 && M == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    //M>1,N>1
    //偶数偶数と奇数奇数の選び方を合計
    pattern += (M*(M-1)/2);
    pattern += (N*(N-1)/2);
    
    cout << pattern << endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;

int main(){
  ll n,m;
  cin >> n >> m;
  for(ll i=1; i<=pow(2,64);i++){
    if(n<pow(m,i)){
      cout << i;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int res[10010] = {};
	for (int i = 1; i <= 100; i++)
	{
		for (int j = 1; j <= 100; j++)
		{
			for (int k = 1; k <= 100; k++)
			{
				int l = i * i + j * j + k * k + i * j + j * k + k * i;
				if(l <= n) res[l]++;
			}
		}
	}


	for (int i = 1; i <= n; i++)
	{
		cout << res[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3604
N = int(input())
S = input()

check = ["0","1","2","3","4","5","6","7","8","9"]

sum = 0
for a in check:
    for b in check:
        for c in check:
            A = S.find(a)
            B = S.find(b)
            C = S.find(c)
            if A == -1 or B == -1 or C== -1:
                continue
            else:
                B2 = S.find(b,A+1)
                if B2 == -1:
                    continue
                else:
                    C3 = S.find(c,B2+1)
                    if C3 != -1:
                        sum +=1

print(sum)


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define MAX 100002

int p[MAX];
int diff_w[MAX];
int r[MAX];

int root(int x){
    if(p[x]==x)return x;
    int r = root(p[x]);
    diff_w[x] += diff_w[p[x]];
    return p[x] = r;
}

void diff(int x,int y){
  if(root(x)==root(y))cout<<diff_w[y] - diff_w[x]<<endl;
  else cout<<"?"<<endl;
}
bool same(int x,int y){
  return root(x)==root(y);
}
void Union(int x,int y){
  p[x]=y;
}

void merge(int x,int y,int w){
  int rx = root(x);
  int ry = root(y);
  w = w + diff_w[x] - diff_w[y];
  if(r[rx]<r[ry]) {
    swap(rx,ry);
    w = -w;
  }
  r[rx]+=r[ry];
  p[ry] = rx;
  diff_w[ry] = w;
}

int main(){
  int n,q,x,y,z,rx,ry,flag;
  cin>>n>>q;
  for(int i=0;i<n+1;i++){
    p[i] = i;
    r[i] = 1;
  }
  for(int i=0;i<q;i++){
    cin>>flag>>x>>y;
    if(flag==1){
      diff(x,y);
    }
    else{
      cin>>z;
      merge(x,y,z);
    }
  }
  return 0;
}


Measured memory_bytes: 4248
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
		int W = sc.nextInt();

    int sub1;
    int sub2;
    int ans;

    int A;
    int B;
    int C;
    int H_mod3 = H%3;
    int W_mod3 = W%3;

    if(H_mod3==0){
      sub1 = 0;
    }else if(H_mod3==1){
      A = H / 3 * W;
      B = (H - H / 3) * (W / 2);
      C = H * W - A - B;
      sub1 = C - A;
      if(W<sub1){
        sub1 = W;
      }
    }else{
      A = (H / 3 + 1) * W;
      B = (H - H / 3 - 1) * (W / 2);
      C = H * W - A - B;
      sub1 = A - B;
      if(W<sub1){
        sub1 = W;
      }
    }

    if(W_mod3==0){
      sub2 = 0;
    }else if(W_mod3==1){
      A = W / 3 * H;
      B = (W - W / 3) * (H / 2);
      C = H * W - A - B;
      sub2 = C - A;
      if(H<sub2){
        sub2 = H;
      }
    }else{
      A = (W / 3 + 1) * H;
      B = (W - W / 3 - 1) * (H / 2);
      C = H * W - A - B;
      sub2 = A - B;
      if(H<sub2){
        sub2 = H;
      }
    }

    if(sub1<sub2){
      ans = sub1;
    }else{
      ans = sub2;
    }

    System.out.print(ans);

	}

}


Measured memory_bytes: 23124
#include<stdio.h>
int main(void)
{
    int n,s[1000],i,p[1000],q[1000],r[1000],c[1000];
	int P,Q,R,C,j;
	
	while(1){
	    scanf("%d",&n);
		if(n==0){
		    break;
	    }
        for(i=0;i<n;i++){
			scanf("%d %d %d %d",&s[i],&p[i],&q[i],&r[i]);
			c[i]=p[i]*4+q[i]*9+4*r[i];
		}
//		for(i=0;i<n;i++)	printf(" s=%d\n",s[i]);
		scanf("%d %d %d %d",&P,&Q,&R,&C);
		j=0;
		for(i=0;i<n;i++){
			if(P>=p[i] && Q>=q[i] && R>=r[i] && C>=c[i]){
				printf("%d\n",s[i]);
				j++;
			}
		}
		if(j==0){
			printf("NA\n");
		}
//		printf("cccc\n");
	}
	return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

#define all(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)

using namespace std;
typedef long long ll;

int main() {
	int A, P;
	cin >> A >> P;
	int ans = P;
	ans += A * 3;
	ans /= 2;
	cout << ans;


	return 0;
}


Measured memory_bytes: 256
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 2e6+5;

int32_t main(){
   
   speed_cubing
   
   int n;
   cin>>n;

   if(n%1000){
     cout<<1000-n%1000; 
   }
   else 
     cout<<0;

   return 0;
}

Measured memory_bytes: 3636
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,ans=0;
pii a[200010];

int main()
{
	cin>>n;
	rep(i,n) cin>>a[i].fi;
	sort(a,a+n);
	for(int i=n-1;i>=0;i--)
	{
		if(a[i].se==1) continue;
		LL pw=1;
		while(pw<=a[i].fi) pw*=2;
		int pos=upper_bound(a,a+i,mpr(pw-a[i].fi,0LL))-a;
		//cout<<i<<' '<<a[i].fi<<' '<<pw<<' '<<pos<<endl;
		//cout<<i<<' '<<pos<<" "<<a[i].fi<<' '<<a[pos-1].fi<<endl;
		if(pos<=i&&a[i].fi+a[pos-1].fi==pw)
		{
			ans++;
			a[pos-1].se=1;
		}
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 3328
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i = 1;
		while(i == 1){
			int X = sc.nextInt();
			int Y = sc.nextInt();
			if(X > Y){
				int tmp;
				tmp = X;
				X = Y;
				Y = tmp;
			}
			if(X == 0 && Y == 0)
				break;
			else
				System.out.println(X +" "+ Y);
		}
		sc.close();
	}
}

Measured memory_bytes: 27216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  int sum = 0;
  if (N >= 1)
  {
    sum += N * (N - 1) / 2;
  }
  if (M >= 1)
  {
    sum+=M*(M - 1) / 2;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
int h,w,n;
vector<int> v[200010];
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	for (int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
	}
	for (int i=1;i<=h;i++)
	{
		sort(v[i].begin(),v[i].end());
	}
	int now=0;
	for (int i=1;i<=h;i++)
	{
		for (int j=0;j<v[i].size();j++)
		{
			int y=v[i][j];
			if (y<i-now)
			{
				cout<<i-1<<endl;
				return 0;
			}
			if (y==i-now)
			{
				now++;
			}
			break;
		}
	}
	cout<<h<<endl;
	return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {

  int h=0, w=0;

  while(1) {

    cin >> h >> w;

    if(h==0 && w==0) {

      break;
      
    }

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

      for(int j=0; j<w; j++) {

        if(i%2==0 && j%2==0) {

          cout << "#";
          
        } else if(i%2==0 && j%2!=0) {

          cout << ".";
          
        }

        if(i%2!=0 && j%2==0) {

          cout << ".";
          
        } else if(i%2!=0 && j%2!=0) {

          cout << "#";
          
        }

        
        if(j==w-1) {

          cout << endl;
          
        }
        
      }

      if(i==h-1) {

        cout << endl;
        
      }
      
    }

  }

}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	static int n;
	static int[] c;
	static double[][][] dp;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		c = new int[4];
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			c[a]++;
		}
		sc.close();

		dp = new double[n + 1][n + 1][n + 1];
		dp[1][0][0] = n;
		System.out.println(dfs(c[1], c[2], c[3]));
	}

	static double dfs(int i, int j, int k) {
		if (dp[i][j][k] > 0) {
			return dp[i][j][k];
		}
		int s = i + j + k;
		double ret = 0;
		if (i > 0) {
			double val = dfs(i - 1, j, k) + (double) n / s;
			val = val * i / s;
			ret += val;
		}
		if (j > 0) {
			double val = dfs(i + 1, j - 1, k) + (double) n / s;
			val = val * j / s;
			ret += val;
		}
		if (k > 0) {
			double val = dfs(i, j + 1, k - 1) + (double) n / s;
			val = val * k / s;
			ret += val;
		}
		return dp[i][j][k] = ret;
	}
}


Measured memory_bytes: 279936
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

struct UF {
	vector<int>par;//親
	vector<int>Rank;//木の深さ

            UF(int n){init(n);}

	//初期化
	void init(int n) {
		par.resize(n); Rank.resize(n);
		for (int i = 0; i < n; i++) {
			par[i]= i;
			Rank[i] = 0;
		}
	}

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;//すでに同じ集合に属している

		if (Rank[x] < Rank[y]) {//高さが小さい方を下に
			par[x] = y;
		}
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;//同じだとrankが変わらないままになるので増やす（それ以外は大きい方のrankが採用される）
		}
	}

	//xとyが同じ集合に属するかを判定
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main() {
	ll n,m;
    cin>>n>>m;
    vector<ll>x(m),y(m),z(m);
    rep(i,m){
        cin>>x[i]>>y[i]>>z[i];
        x[i]--;y[i]--;
        }
    struct UF tree(n+1);
    rep(i,m){
        tree.unite(x[i],y[i]);
    }
    set<int>s;
    for(int i=0;i<n;++i){
        s.insert(tree.find(i));
    }
    cout<<s.size()<<endl;
}

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

int main() {
	int n = 0, choco = 0;
	int d, x, k;
	cin >> n >> d >> x;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		cin >> k;
		a.push_back(k);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; a[i] * j < d; j++)
			choco++;
	}
	cout << x + choco << endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> ss(m, 0);
    for(auto& e : ss) {
        int k;
        cin >> k;

        for (int i=0; i<k; i++) {
            int s;
            cin >> s;
            e += (1 << (s-1));
        }
    }

    vector<int> surplus(m);
    for (auto& e : surplus) {
        cin >> e;
    }

    int ans = 0;
    for (int i=0; i<(1<<n); i++) {
        
	bool bc = true;
        for (int j=0; j<m; j++) {
            int ba = i & ss[j];

            int bs = 0;
            for (int k=0; k<n; k++) {
                if (ba & (1 << k)) bs ^= 1;
            }

            if (bs != surplus[j]) bc = false;
        }

	    if (bc) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>

using namespace std;

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 998244353
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for(int i = 0; i < n; i++) {
        cout << edge[i].size() << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    long sum = 0;
    int i, j, len = str.length();
    for(i = 0; i < 1<<(len - 1); i++) {
      String firstChar = String.valueOf(str.charAt(0));
      StringBuilder sb = new StringBuilder(firstChar);
      for(j = 0; j < len - 1; j++) {
        if((1 & i >> j) == 1) sb.append("+");
        sb.append(str.charAt(j + 1));
      }
      String[] subsets = sb.toString().split("\\+");
      for(String tempStr : subsets) {
        sum += Long.parseLong(tempStr);
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 23764
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;
int n, x;
int a[maxn];
void solve() {
    while(cin >> n) {
    cin >> x;
    for (int i = 0; i < n; i++) cin >> a[i];
    ll res = 0;
    for (int i = 1; i < n; i++) {
        if(a[i] + a[i - 1] > x) {
            int t = a[i] + a[i - 1] - x;
            res += t;
            //cout << i << " asd "<< res << endl;
            if(a[i] >= t) {
                a[i] -= t;
            } else {
                //x -= a[i];
                a[i] = 0;
            }
        }
    }
    cout << res << endl;
    }
}
int main() {
   // freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vector<double> v(n);
  rep(i,n){
    cin>>v[i];
  }

  double dp[n]={};
  rep(i,n){
    double length=v[i];
    rep(j,i){
      length=max(length,dp[j]+sqrt(4*v[i]*v[j]));
    }
    dp[i]=length;
  }

  double ans=0;
  rep(i,n){
    ans=max(ans,dp[i]+v[i]);
  }

  cout<<ans<<endl;


}


Measured memory_bytes: 3300
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    while(1){
       if (x==0 && y==0){
           break;
       }
       if (x > y){
           cout<<y<<" "<<x<<endl;
       } else{
           cout<<x<<" "<<y<<endl;
       }
       cin>>x>>y;
    }
    return 0;
}



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

using namespace std;

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

	string s;
	cin >> s;
	int len = s.length();
	char b1 = s[0], b2 = {};
	for(int i = 1; i < len; i++)
	{
		if(b1 == s[i])
		{
			cout << i << " " << i + 1 << endl;
			return 0;
		}
		else if(b2==s[i])
		{
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
		b2 = b1;
		b1 = s[i];
	}
	cout << -1 << " " << -1 << endl;

	return 0;
}


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

#define Ff(i,j,n)  for (i = j ; i < n; i++)
#define Fb(i,j,n)    for (i = (n - 1); i >= j; i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pll pair<long, long>
#define pi 3.14159265358979323846
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(), x.end()
#define trav(i,x) for(auto& i:x)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef vector < long long > vll;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;

// const ll mod = 998244353;
// const ll N = 1000000007;
// ll binpow(ll b, ll p) { ll ans = 1; while (p > 0) {if (p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;} return ans;}
// ll inv(ll x) {return binpow(x, mod - 2);}
// ll divide(ll x, ll y) {return ((x % mod) * (inv(y))) % mod;}


int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS
    int t=1;
    // cin >> t;
    while (t--) {
        int n, i;
        string s;
        cin >> s;
        i = 0;
        while (i < 3 && s[i] == 'R')
            i++;
        if (i == 0) {
            if (s[1] == 'R' && s[2] == 'R')i = 2;
            else if (s[1] == 'R')i = 1;
            else if (s[2] == 'R')i = 1;
        }

        cout << i << endl;
    }


    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#define EPS (1e-10)
#define equals(a,b) (fabs(a)-fabs(b)<EPS)


using namespace std;

class Point{
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    ///不能写成Point &p，否则报错
    Point operator + (Point p) { return Point(x+p.x,y+p.y); }
    Point operator - (Point p) { return Point(x-p.x,y-p.y); }
    Point operator * (double a) { return Point(x*a,y*a); }
    Point operator / (double a) { return Point(x/a,y/a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x+y*y; }

    bool operator < (const Point &p) const {
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

typedef Point Vector;
///Program 16.3 表示线段的结构体
struct Segment{
    Point p1,p2;
};

///Program 16.4 表示直线的结构体
typedef Segment Line;

///内积
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
///外积
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot((p-s.p1),base)/base.norm();
    return s.p1 + base*r;
}

Point reflect(Segment s,Point p){
    return p+(project(s,p)-p)*2.0;
}

int main(){
    Point p1,p2;
    Segment s;
    scanf("%lf%lf%lf%lf",&s.p1.x,&s.p1.y,&s.p2.x,&s.p2.y);
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        Point tmp;
        scanf("%lf%lf",&tmp.x,&tmp.y);
        Point ans=reflect(s,tmp);
        printf("%.10f %.10f\n",ans.x,ans.y);
    }
    return 0;
}


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

int main(){
  int n;	cin >> n;
  vector<long long>	a(n+1);
  vector<long long>	b(n);
  rep(i,n+1)	cin >> a[i];
  rep(i,n)	cin >> b[i];
  
  long long ans=0;
  rep(i,n){
    long long x=min(a[i],b[i]);
    b[i]-=x;
    ans+=x;
    x=min(a[i+1],b[i]);
    a[i+1]-=x;
    ans+=x;
  }
  cout << ans;
}

Measured memory_bytes: 4828
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string s[3]; cin >> s[0] >> s[1] >> s[2];
	int now = 0;
	while (true) {
		if (s[now].empty()) {
			cout << char('A' + now) << endl; break;
		}
		char t = s[now][0];
		s[now].erase(s[now].begin());
		now = t - 'a';
	}
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
using namespace std;
static const int N=100;
int main(){
  int n,p[N+1],m[N+1][N+1];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>p[i-1]>>p[i];
  }
  for(int i=1;i<=n;i++) m[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      m[i][j]=(1<<21);
      for(int k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout << m[1][n] <<endl;
  return 0;
}



Measured memory_bytes: 3124
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2020 itachi <itachi@itachi-Z510>
#
# Distributed under terms of the MIT license.

"""

"""
a,b=map(int,input().split())
m=str(a)*b
n=str(b)*a
if  m<n:
    print(m)
else:
    print(n)


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

int compare(const void *a,const void *b){
	return *(int*)b-*(int*)a;
}

int main(){
	
	int i,k,N,a[110],alice=0,bob=0;
	scanf("%d",&N);
	
	for(i=0;i<N;i++){
	scanf("%d",&a[i]);
	}
	
	qsort(a,N,sizeof(int),compare);
	
	if(N%2==0){
	for(k=0;k<N/2;k++){
		alice+=a[2*k];
		bob+=a[2*k+1];
	}
	}else {
		for(k=0;k<(N-1)/2;k++){
		alice+=a[2*k];
		bob+=a[2*k+1];
	}
	alice+=a[N-1];	
		
	}
	
	
	
	
	printf("\n%d\n\n",alice-bob);
	
	
	return 0;
}




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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n, m;

signed main()
{
    cin >> n >> m;

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
    int W,H;
    while(true){
        std::cin>>H>>W;
        if(W==0&&H==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                std::cout<<"#";
            }
            std::cout<<"\n";
        }
        std::cout<<"\n";
        
    }
   
}


Measured memory_bytes: 3100
H, W = map(int, input().split())

A = ["." * (W+2)] + [("." + input()) + "." for _ in range(H)] + ["." * (W+2)]

for i in range(1,H+1):
  for j in range(1,W+1):
    if A[i][j] == "#":
      L ="#"
    else:
      L =sum([1 for x in range(-1, 2) for y in range(-1, 2) if A[i+x][j+y] == "#"])
    print (L, end = "")
  print()


Measured memory_bytes: 3444
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
c=A[0]
d=0
for i in range(N):
  d+=max(0,c-B[i])
  c=max(0,A[i+1]+min(0,c-B[i]))
print(sum(A)-(d+c))

Measured memory_bytes: 19116
import itertools

a, b, c, d, e, f = map(int, input().split())

a *= 100
b *= 100
waters = set()
for i in range(0, f // a + 1):
    for j in range(0, (f - a * i) // b + 1):
        waters.add(a * i + b * j)

sugers = set()
g = f // 100 * e
for i in range(0, g // c + 1):
    for j in range(0, (g - c * i) // d + 1):
        sugers.add(c * i + d * j)

answers = set()
for water, suger in itertools.product(waters, sugers):
    if water > 0 and water + suger <= f and suger <= water // 100 * e:
        answers.add((suger + water, suger))

weight, suger = max(answers, key=lambda answer: answer[1] / answer[0])
print(weight, suger)


Measured memory_bytes: 40944
#include<stdio.h>

int main(){
 int idx;
 int n,i;
 int max=-1;
 int temp1,temp2;

 scanf("%d",&n);

 for(i=0;i<n;i++){
  scanf("%d %d",&temp1,&temp2);
  if(temp2 > max){
    idx=temp1; max=temp2;
  }
  else if(temp2 == max && temp1<idx){
    idx=temp1;
  }
 }

 printf("%d %d\n",idx,max);

return 0;
}


Measured memory_bytes: 2104