akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	cnt := map[int]int{}
	min, max := 100000, 0
	for i := 0; i < n; i++ {
		a := nextInt()
		cnt[a]++
		if a > max {
			max = a
		}
		if a < min {
			min = a
		}
	}

	ans := 0
	for i := min; i <= max; i++ {
		if sum := cnt[i-1] + cnt[i] + cnt[i+1]; sum > ans {
			ans = sum
		}
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 705, INF = 0x3f3f3f3f;

int N, M, conn, par[MAXN], dp[MAXN][MAXN], col[MAXN], cnt[MAXN][3];
vector<int> edge[MAXN];
bool mat[MAXN][MAXN];

bool dfs(int now, int c) {
	col[now] = c;
	cnt[conn][c]++;
	for (auto i: edge[now]) {
		if (i == par[now]) continue;
		if (col[i] != -1) {
			if (col[i] == c) return 0;
		} else {
			bool bisa = dfs(i, c^1);
			if (!bisa) return 0;
		}
	}
	return 1;
}

int f(int pos, int rem) {
	if (pos > conn) return rem == 0;
	int &ret = dp[pos][rem];
	if (ret != -1) return ret;
	ret = 0;
	if (rem >= cnt[pos][0]) ret |= f(pos+1, rem-cnt[pos][0]);
	if (rem >= cnt[pos][1]) ret |= f(pos+1, rem-cnt[pos][1]);
	return ret;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		mat[x][y] = mat[y][x] = 1;
	}
	
	for (int i = 1; i <= N; i++) {
		for (int j = i+1; j <= N; j++) {
			if (mat[i][j] == 0) {
				edge[i].push_back(j);
				edge[j].push_back(i);
			}
		}
	}
	
	memset(col, -1, sizeof(col));
	for (int i = 1; i <= N; i++) {
		if (col[i] == -1) {
			conn++;
			if (!dfs(i, 0)) {
				cout << "-1\n";
				return 0;
			}
		}
	}
	
	int ans = INF;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i <= N; i++) {
		if (f(1, i)) ans = min(ans, i*(i-1)/2 + (N-i)*(N-i-1)/2);
	}
	cout << ans << "\n";
	
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	const int S = 1 << 19;
	vector<int> seg(2*S);
	int N; cin >> N;
	string str; cin >> str;
	for (int i = 0; i < N; i++) {
		seg[S+i] = 1<<(str[i] - 'a');
	}
	for (int i = S-1; i; i--) seg[i] = seg[2*i] | seg[2*i+1];

	int Q; cin >> Q;
	while (Q--) {
		int t; cin >> t;
		if (t == 1) {
			int i; char c; cin >> i >> c; i--;
			seg[S+i] = 1<<(c-'a');
			for (int a = (S+i)/2; a; a /= 2) {
				seg[a] = seg[2*a] | seg[2*a+1];
			}
		} else if (t == 2) {
			int l, r; cin >> l >> r; l--;
			int ans = 0;
			for (int a = S+l, b = S+r; a < b; a /= 2, b /= 2) {
				if (a & 1) ans |= seg[a++];
				if (b & 1) ans |= seg[--b];
			}
			cout << __builtin_popcount(ans) << '\n';
		} else assert(false);
	}

	return 0;
}


Measured memory_bytes: 5268
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    cin >> a;
    ll ans = 0;
    for(int i = 1; i < n; i++) {
        ll eat = max(0, a[i] + a[i - 1] - x);
        a[i] = max(0ll, a[i] - eat);
        ans += eat;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int n;
   cin>>n;
   int arr[n];
   rep(i,n)cin>>arr[i];
   sort(arr,arr+n);
   int ans=0;
   int index=n/2;
   ans=arr[index]-arr[index-1];
   cout<<ans<<endl;

   return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n=s.size();
  while(s.size()!=0){
    if(s.substr(max(0,n-5))=="dream"){
      n-=5;
      s.erase(n);
    }
    else if(s.substr(max(0,n-5))=="erase"){
      n-=5;
      s.erase(n);
    }
    else if(s.substr(max(0,n-7))=="dreamer"){
      n-=7;
      s.erase(n);
    }
    else if(s.substr(max(0,n-6))=="eraser"){
      n-=6;
      s.erase(n);
    }
    else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	int mi=1<<30;
	int fi=N;
	
	FOR(i,N) cin>>A[i];
	
	FOR(i,N) {
		if(i+K<=N) {
			x=A[i];
			y=A[i+K-1];
			
			if(y<=0) mi=min(mi,-x);
			else if(x>=0) mi=min(mi,y);
			else mi=min({mi,2*y-x,y-2*x});
		}
	}
	
	cout<<mi<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

int main()
{
	int A,B;
	cin >> A >> B;

	int s = A - 2 * B;

	if (s <= 0)
	{
		cout << 0;
	}
	else
	{
		cout << s;
	}
	
}


Measured memory_bytes: 3616
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> hoge(n);
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        int fuga;
        cin>>fuga;
        hoge.push_back(fuga);
        
        int j=0;
        while(hoge.at(j)!=fuga) j++;
        
        if(j!=hoge.size()-1) ans++;
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3256
class UnionFindNode(object):
    """
    Union-Find構造
    ノードのグループ併合や、所属グループ判定を高速に処理する
    """

    def __init__(self, group_id, parent=None, value=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        template = "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})"
        return template.format(self.group_id_, self.parent_, self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        parent = self.root()
        return parent.group_id_

    def size(self):
        parent = self.root()
        return parent.size_

    def unite(self, unite_node):
        parent = self.root()
        unite_parent = unite_node.root()

        if parent.group_id_ != unite_parent.group_id_:
            if parent.size() > unite_parent.size():
                unite_parent.parent_ = parent
                parent.size_ = parent.size_ + unite_parent.size_
            else:
                parent.parent_ = unite_parent
                unite_parent.size_ = parent.size_ + unite_parent.size_
    def is_group(self,other):#selfとotherが同じグループに属するか
        return self.root()==other.root()

N,M=map(int,input().split())
p=[int(i)-1 for i in input().split()]
U=[UnionFindNode(i) for i in range(N)]
for i in range(M):
    x,y=map(int,input().split())
    U[x-1].unite(U[y-1])
ans=0
for i in range(N):
    if U[i].is_group(U[p[i]]):
        ans+=1
print(ans)


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

int main(){
string S,temp2;
  cin >> S;
  ll tot=0,a=0;

  
  //rep(i,S.size()){
     // 3ビットのビット列をすべて列挙する
  for (int tmp = 0; tmp < (1 << (int)S.size()-1); tmp++) {
    bitset<9> b(tmp);
    
//   cout << b << endl;

    rep(i,(int)S.size()-1){
 
      if(b.test(i)){
        for(int j=a;j<i+1;j++){
          temp2.push_back(S.at(j));
        }
        ll m=(long long)stoll(temp2);
      //  cout << m << endl;
        tot+=m;
       // cout << temp << endl;
        a=i+1;
       temp2="";
      }
      
    }
   // cout << a << endl;

    for(int j=a;j<(int)S.size();j++){
      temp2.push_back(S.at(j));
     // cout << temp2.at(j) << endl;
    }
   // cout << temp2 << endl;
    ll k=(long long)stoll(temp2);
   // cout << k << endl;
    tot+=k;
    a=0;
    temp2="";
               }
  
  cout << tot << endl;
}



Measured memory_bytes: 256
n=input()
a=[int(i) for i in input().split()]
def chk(a,t):
    ans=0
    x=0
    for i in a:
        x+=i
        if t==True and x<1:
            ans+=1-x
            x=1
        elif t==False and x>-1:
            ans+=x+1
            x=-1
        t=not t
    return ans
print(min(chk(a,True),chk(a,False)))

Measured memory_bytes: 63216
import java.util.*;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
        while(true){
    		String s=in.next();
    		if(s.equals("-")) break;
            int k=in.nextInt();
    		StringBuilder sb = new StringBuilder(s);
            for(int i=0;i<k;i++){
                int h=in.nextInt();
                sb.append(sb.substring(0,h));
                sb.delete(0, h);
            }
            System.out.println(sb);
        }
	}
}

Measured memory_bytes: 26440
s = input()
n = len(s)

ans = 0

for bit in range(1 << (n - 1)):
    # 各場合で式 f を生成する
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            # フラグが立っているならば "+" を式の末尾に追加する
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)

Measured memory_bytes: 9128
def main():
    S = input()
    is_keyence = False
    string = "keyence"

    for i in range(len(string)):
        if S.startswith(string[:i]) and S.endswith(string[i:]):
            is_keyence = True
    
    if is_keyence:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <atomic>
#include <thread>
#include <mutex>
#include <string>
#include <string.h>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <limits.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define P std::pair<int,int> 
#define INF LLONG_MAX/3
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int q;
deque<int> d;
signed main() {
	cin >> q;
	rep(i, q) {
		int a;
		cin >> a;
		if (!a) {
			int b, c;
			cin >> b >> c;
			if (!b)d.push_front(c);
			else d.push_back(c);
		}
		else if (a == 1) {
			int p;
			cin >> p;
			cout << d[p] << endl;
		}
		else {
			int b;
			cin >> b;
			if (!b)d.pop_front();
			else d.pop_back();
		}
	}
	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 6164
#include <iostream>
using namespace std;
int n;
string s;
void f(int x){
    if(x == n){
        cout << s << endl;
        return;
    }
    int v = -1;
    for(int i=0;i<x;i++) v = max(v, s[i]-'a');
    for(int i=0;i<=v+1;i++){
        s[x] = 'a' + i;
        f(x+1);
    }
}
int main(void){
    cin >> n;
    s = string(n, 'a');
    f(0);
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<math.h>
int perm(int n,int arr[])
{
    int arr1[n];
    int sum=0,count,i,j;
    int arr2[9]={1,1,2,6,24,120,720,5040,40320};
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(arr[j]<arr[i])
            count++;
        }
        arr1[i]=count;
	count=0;
    }
    for(i=0;i<n;i++)
    {
        sum=sum+(arr1[i]*arr2[n-i-1]);
    }
    return sum+1;
}
int main()
{
    int n,res1,res2;
    scanf("%d",&n);
    int arr[n];
    int arr1[n];
    int i,j;
    for(i=0;i<=n-1;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=0;i<=n-1;i++)
    {
        scanf("%d",&arr1[i]);
    }
    res1=perm(n,arr);
    res2=perm(n,arr1);
    printf("\n%d",abs(res1-res2));
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();
 
	public static void main(String[] args) {
 
		int[] pos = new int[100+1];
		for(int i=1; i<=9; i++) {
			pos[in.nextInt()] = i;
		}

		int N = in.nextInt();
		Set<Integer> card = new HashSet<>();
		for(int i=0; i<N; i++) {
			card.add(pos[in.nextInt()]);
		}

		boolean isBingo =
				card.containsAll(Arrays.asList(1,4,7)) ? true
				: card.containsAll(Arrays.asList(2,5,8)) ? true
				: card.containsAll(Arrays.asList(3,6,9)) ? true
				: card.containsAll(Arrays.asList(1,2,3)) ? true
				: card.containsAll(Arrays.asList(4,5,6)) ? true
				: card.containsAll(Arrays.asList(7,8,9)) ? true
				: card.containsAll(Arrays.asList(1,5,9)) ? true
				: card.containsAll(Arrays.asList(3,5,7)) ? true
				: false;
		System.out.println(isBingo ? "Yes" : "No");

	}
 
 
	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}

}

Measured memory_bytes: 21844
#include<stdio.h>
    int main(){
        int a[5],s[14],p[14],i,j,c,g,h,d;
        while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
            g=0;
            h=0;
            d=0;
            c=0;
            for(i=0;i<14;i++){
                s[i]=i+1;
                p[i]=0;
            }
            s[13]=1;
            for(i=0;i<13;i++)
                for(j=0;j<5;j++)
                if(a[j]==s[i]){
                p[i]++;
                if(a[j]==1)
                    p[13]++;
            }
            for(i=0;i<10;i++)
                if(p[i]==1){
                     
                    for(j=i+1;j<i+5;j++){
                         
                        if(p[j]!=1)
                            break;
                        if(j==i+4){
                            printf("straight\n");
                            c++;
                        }
                    }
                     
            }
            if(c>0)
                continue;
            for(i=0;i<13;i++){
                if(p[i]==4)d++;
                if(p[i]==3)g++;
                if(p[i]==2)h++;
            }
            if(d>0)
                printf("four card\n");
            else if(g>0&&h>0)
                printf("full house\n");
            else if(g>0&&h==0)
                printf("three card\n");
            else if(g==0&&h==1)
                printf("one pair\n");
            else if(g==0&&h==2)
                printf("two pair\n");
            else printf("null\n");
        }
        return 0;
}

Measured memory_bytes: 580
// Aizu Vol0 0060: Card Game
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, my, win;
	int c[11], c1, c2, c3;

	while (scanf("%d%d%d", &c1, &c2, &c3) == 3) {
		for (i = 1; i <= 10; i++) c[i] = 1;
		my = c1 + c2;
		c[c1] = c[c2] = c[c3] = 0;

		win = 0;
		for (i = 1; i <= 10; i++) {
			if (c[i] && (my + i <= 20)) win++;
		}
		puts(win >= 4 ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

string inv(string x) {
  reverse(begin(x), end(x));
  for (auto&& e : x) e ^= 32;
  return x;
}
string cp(string x, string y) {
  reverse(begin(y), end(y));
  while (!x.empty() and !y.empty() and (x.back() ^ y.back()) == 32) {
    x.pop_back();
    y.pop_back();
  }
  reverse(begin(y), end(y));
  return x + y;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k, --k;
  V<> p(n); for (auto&& e : p) cin >> e, --e;
  V<> q(n); for (auto&& e : q) cin >> e, --e;
  auto cp = [&](const V<>& p, const V<>& q) -> V<> {
    V<> res(n);
    for (int i = 0; i < n; ++i) {
      res[i] = p[q[i]];
    }
    return res;
  };
  auto inv = [&](const V<>& p) -> V<> {
    V<> res(n);
    for (int i = 0; i < n; ++i) {
      res[p[i]] = i;
    }
    return res;
  };
  auto pow = [&](V<> p, int k) -> V<> {
    V<> res(n);
    iota(begin(res), end(res), 0);
    while (k) {
      if (k & 1) res = cp(res, p);
      p = cp(p, p);
      k >>= 1;
    }
    return res;
  };
  auto f = [&](const V<>& p, const V<>& q) -> V<> {
    return cp(q, inv(p));
  };
  auto solve = [&]() -> V<> {
    if (!k) return p;
    VV<> a(7);
    a[0] = p, a[1] = q;
    for (int i = 2; i <= 6; ++i) {
      a[i] = f(a[i - 2], a[i - 1]);
    }
    int r = (k - 1) % 6 + 1;
    auto x = cp(a[3], p);
    x = pow(x, (k - r) / 6);
    auto res = a[r];
    res = cp(x, res);
    res = cp(res, inv(x));
    return res;
  };
  auto res = solve();
  for (int i = 0; i < n; ++i) {
    cout << res[i] + 1 << " \n"[i == n - 1];
  }
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;
///////

int main(){
  int N,K;
  cin >> N >> K;
  int ma = (N-1)*(N-2) / 2;//組数（頂点数）計算
  if(ma < K) cout << -1 << endl;
  else {
    vector<pair<int,int>> res;
    for(int i=1;i<=N-1;i++) res.push_back({i,N});//スターグラフを作る
    int rem = ma-K;//余分な辺減らしたい
    int ci = 1,cj=2;
    //n-1C2 - K 個の辺を追加してペアをつぶす
    for(int _=0;_<rem;++_){
      res.push_back({ci,cj});
      ++cj;
      if(cj == N) {
        ci++;
        cj = ci+1;
      }
    }
    cout << res.size() << endl;
    for(auto p:res) cout << p.first << " " << p.second << endl;
  }
}

Measured memory_bytes: 384
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

typedef struct _NODE{
    llong key;
    _NODE *right;
    _NODE *left;
}NODE;

NODE *root=NULL;

NODE *MakeNode(llong key){
    NODE *node = (NODE*)malloc(sizeof(NODE));
    node->key = key;
    node->right = NULL;
    node->left = NULL;
    return node;
}

void Insert(llong key){
    if(root==NULL){
        root = (NODE*)malloc(sizeof(NODE));
        root->left = NULL;
        root->right = NULL;
        root->key = key;
        return;
    }
    NODE *now = root;
    NODE *prev;
    NODE *new_node = MakeNode(key);
    while(now!=NULL){
        if(now->key >= key){
            prev = now;
            now  = now->left;
        }else{
            prev = now;
            now  = now->right;
        }
    }
    if(prev->key >= key){
        prev->left = new_node;
    }else{
        prev->right = new_node;
    }
}

void Find(llong key){
    if(root==NULL){
        cout << "no" << endl;
        return;
    }
    NODE *now=root;
    while(now!=NULL){
        if(now->key==key){
            cout << "yes" << endl;
            return;
        }
        if(now->key < key){
            now = now->right;
        }else{
            now = now->left;
        }
    }
    cout << "no" << endl;
    return;
}

void InorderTreeWalk(NODE *node){
    if(node==NULL){
        return;
    }
    InorderTreeWalk(node->left);
    cout << " " << node->key;
    InorderTreeWalk(node->right);
    return;
}

void PreorderTreeWalk(NODE *node){
    if(node==NULL){
        return;
    }
    cout << " " << node->key;
    PreorderTreeWalk(node->left);
    PreorderTreeWalk(node->right);
    return;
}

void PrintTree(NODE *node){
    InorderTreeWalk(node);
    cout << endl;
    PreorderTreeWalk(node);
    cout << endl;
}

int main(){
    llong n;
    cin >> n;
    char command[100];
    llong key;
    for(int i=0; i<n; i++){
        scanf("%s", command);
        if(command[0]=='i'){
            scanf("%lld", &key);
            Insert(key);
        }else if(command[0]=='f'){
            scanf("%lld", &key);
            Find(key);
        }else{
            PrintTree(root);
        }
    }
    return 0;
}


Measured memory_bytes: 15632
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln endl
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inp freopen("input.txt", "r", stdin)
#define outp freopen("output.txt", "w", stdout)
#define dbgm(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 2e5+5, MOD = 1e9+7, EPS = 1e-9;
int t,n,m,k,x,y;
int main(){
	fastio;
	cin>>n;
	ld p;
	cin>>p;
	ld prob[n+1][n+1];
	forn(i,n+1){
		forn(j,n+1) prob[i][j]=0;
	}
	prob[1][0] = 1-p;
	prob[1][1] = p;
	forsn(i,2,n+1){
		cin>>p;
		forn(j,n+1){
			prob[i][j] = prob[i-1][j]*(1-p);
			if(j>0) prob[i][j] += prob[i-1][j-1]*p;
		}
	}
	ld ans=0;
	forsn(j,n/2+1, n+1){
		ans+=prob[n][j];
	}
	cout<<setprecision(10)<<fixed;
	cout<<ans<<ln;
	return 0;
}

Measured memory_bytes: 140928
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
long long  INF=1'0000'0000'0000'0000'00;
using namespace std;

int main(){


int alpha[26]={};

string s;
cin >>s;
for(int i=0;i<s.size();i++){
    alpha[s[i]-'a']++;
}
bool ans=true;
for(int i=0;i<26;i++){
    if(alpha[i]%2==0)continue;
    else{
        ans=false;
    }
}

if(ans){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int i;
    scanf("%d", &i);

    printf("%d\n", a[i - 1]);
    return 0;
}

Measured memory_bytes: 128
n = input()
R = []
for i in range(n):
    R.append(input())

maxv = R[1] - R[0]
minv = R[0]
for j in range(1, n):
    maxv = max(maxv, R[j] - minv)
    minv = min(minv, R[j])

print "%d" % maxv

Measured memory_bytes: 18980
#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>
#define N 100
int top=1;
int s[N];
int pop();
void push(int x);
int isempty();
int isfull();

int main(void){

  int ans=0,i,x1,x2;
  char x[8];

  while((scanf("%s",&x))!=EOF){

      if(x[0]=='+'){
        x1=pop();
        x2=pop();
        push(x1+x2);
      }

      else if(x[0]=='-'){
        x2=pop();
        x1=pop();
        push(x1-x2);
      }

      else if(x[0]=='*'){
        x1=pop();
        x2=pop();
        push(x1*x2);
      }

      else if(x[0]=='/'){
        x1=pop();
        x2=pop();
        push(x1/x2);
      }
    else{
      //printf("ok%d\n",top );
      push(atoi(x));
    }
  }

  ans=pop();
  printf("%d\n",ans);
  return 0;

}

void push(int x){
    /*if(isfull()==1){
      printf("error(full)");
      exit(1);
    }*/
    top++;
    s[top]=x;
}

int  pop(){
  /*if(isempty()==1){
    printf("error(empty)\n");
    exit(1);
  }*/
  top--;
  return s[top+1];
}

int isfull(){
  if(top==N)return 1;
  else  return 0;
}

int isempty(){
  if(top==0)return 1;
  else return 0;
}



Measured memory_bytes: 2080
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

void initStrArray(char** p, int n, int len){
    for(int i=0; i<n; i++){
        *(p + i) = (char*)malloc(sizeof(char) * (len + 1));
    }
}

int main(){
    int n;
    scanf("%d", &n);
    char* w[n];
    initStrArray(w, n, 10);
    rep(i, 0, n){
        scanf("%s", w[i]);
    }
    int f = 1;
    rep(i, 1, n){
        if(*(w[i]) != *(w[i-1] + strlen(w[i-1]) - 1)){
            f = 0;
        }
    }
    rep(i, 0, n){
        rep(j, i+1, n){
            if(strcmp(w[i], w[j]) == 0){
                f = 0;
            }
        }
    }
    printf(f? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string>
#define ll long long int
using namespace std;
int main(){
    string s1,s2;
    cin>>s1>>s2;
    s1="*"+s1;
    s2="*"+s2;
    ll sl1=s1.length();
    ll sl2=s2.length();
    ll dp[sl1][sl2];
    ll i=0,j=0;
    for(ll i=0;i<sl1;i++){
        for(ll j=0;j<sl2;j++){
            if((i==0) || (j==0)) dp[i][j]=0;
            else if( s1[i]==s2[j]) dp[i][j]=1+dp[i-1][j-1];
            else                   dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    /*
    for(ll i=0;i<sl1;i++){
        for(ll j=0;j<sl2;j++){
                cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */
 
    string ans="";
    i=sl1-1,j=sl2-1;
    ll x=dp[i][j];
    while(x>0){
        if(s1[i]==s2[j]){
            string y="";
            y=y+s1[i];
            ans=y+ans;
            i-=1;
            j-=1;
            x=dp[i][j];
        }
        else{
            if(dp[i][j-1]>dp[i-1][j]){
                j--;
                x=dp[i][j];
            }
            //if(dp[i][j-1]<dp[i-1][j])
            else{
                i--;
                x=dp[i][j];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 70656
from itertools import product
from bisect import bisect_right
n = int(input())
ns = []
for i in range(9):
    for j in product(["7", "5", "3"], repeat=i + 1):
        ns.append(''.join(j))
ns = sorted([int(i) for i in ns if len(set(i)) == 3])
print(bisect_right(ns, n))

Measured memory_bytes: 46316
s = input()
i = len(s)
while i > 0:
    if s[i-7:i] == 'dreamer':
        # print(s[i-7:i])
        i = i - 7
    elif s[i-6:i] == 'eraser':
        # print(s[i-6:i])
        i = i - 6
    elif s[i-5:i] == 'dream' or s[i-5:i] == 'erase':
        # print(s[i-5:i])
        i = i - 5
    else:
        print("NO")
        exit()
print('YES')

Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
    int N;
    int x[100100];
    int tmp[100100];
    scanf("%d",&N);
    for(int i = 0; i < N; i++){
        scanf("%d",&x[i]);
        tmp[x[i]-1]=i+1;
    }
    for(int i = 0; i < N; i++){
        printf("%d""%c",tmp[i],' ');
    }
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int M, D;
    cin >> M >> D;
    int ans = 0;
    for (int i = 1; i <= M; i++) {
        for (int j = 10; j <= D; j++) {
            if (i == ((j % 10) * (j / 10))) {
                if (j % 10 >= 2 && j / 10 >= 2) ++ans;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
while True:
    formula = input().split()
    if '?' in formula:
        break
    a,b = int(formula[0]),int(formula[2])
    if formula[1] == '+':
        print(a+b)
    elif formula[1] == '-':
        print(a-b)
    elif formula[1] == '*':
        print(a*b)
    elif formula[1] == '/':
        print(a//b)

Measured memory_bytes: 7600
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  ll ans = 0;
  for (int i = 0; i < 1<<(s.size()-1); i++) {
    string tmp;
    tmp.push_back(s[0]);
    for (int j = 0; j < (int)s.size()-1; j++) {
      if ((i>>j) & 1) {
	ans += stoll(tmp);
	tmp = s[j+1];
      }
      else {
	tmp.push_back(s[j+1]);
      }
    }
    ans += stoll(tmp);
  }
  dump(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

constexpr int32_t MOD = 1000000007;

int main()
{
    int n;
    std::cin >> n;
    int64_t p = 1;
    for (int i = 0; i < n; ++i)
    {
        p *= (i + 1);
        p %= MOD;
    }

    std::cout << p << std::endl;

    return 0;
}


Measured memory_bytes: 3592
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#ifdef ConanYu
#include "local.hpp"
#else
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 305;
ll dis[N][N];
int res[N][N];

void Main() {
  int n, m; ll l; cin >> n >> m >> l;
  memset(dis, 0x3f, sizeof dis);
  for(int i = 0; i < m; i++) {
    int a, b, c; cin >> a >> b >> c;
    dis[a][b] = dis[b][a] = c;
  }
  for(int i = 1; i <= n; i++) {
    dis[i][i] = 0;
  }
  for(int k = 1; k <= n; k++) {
    for(int i = 1; i <= n; i++) {
      for(int j = 1; j <= n; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  queue<pair<int, int>> q;
  memset(res, 0x3f, sizeof res);
  for(int i = 1; i <= n; i++) {
    for(int j = i + 1; j <= n; j++) {
      if(dis[i][j] <= l) {
        q.push({i, j});
        q.push({j, i});
        res[i][j] = res[j][i] = 0;
      }
    }
  }
  while(!q.empty()) {
    const pair<int, int> cur = q.front();
    q.pop();
    const int from = cur.first, to = cur.second;
    for(int i = 1; i <= n; i++) {
      if(i != from && i != to) {
        if(dis[to][i] <= l && res[from][i] == 0x3f3f3f3f) {
          res[from][i] = res[from][to] + 1;
          q.push({from, i});
        }
      }
    }
  }
  int Q; cin >> Q;
  while(Q--) {
    int s, t; cin >> s >> t;
    cout << (res[s][t] == 0x3f3f3f3f ? -1 : res[s][t]) << "\n";
  }
}


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

int f(int c){return c>='a'&&c<='z';}

int main(){
    char *k[]={"the","this","that"};
    char *p,c[80]; int i;
    while(fgets(c,80,stdin)){
        for(;;){
            for(i=0;i<80;i++){
                if(f(c[i])){
                    c[i]=++c[i]%'a'%26+'a';
                }
            }
            for(i=0;i<3;i++){
                for(p=c;p=strstr(p,k[i]);p++){
                    if((p==c||!f(p[-1]))&&!f(p[i?4:3])){
                        goto label;
                    }
                }
            }
        }
        label: printf("%s",c);
    }
    return 0;
}

Measured memory_bytes: 524
from collections import deque
S=deque(input())
q=int(input())
rev=False
for i in range(q):
  c=list(input().split())
  if c[0]=='1':
    rev=not rev
  elif c[1]=='1' and rev==False:
    S.appendleft(c[2])
  elif c[1]=='2' and rev==True:
    S.appendleft(c[2])
  else:
    S.append(c[2])
if rev:
  S.reverse()
ans=''.join(S)
print(ans)

Measured memory_bytes: 74072
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

using namespace std;
using ll = long long;


int main()
{
	int N;
	cin >> N;
	vector<int> h(N);
	h.resize(N);
	for (int i = 0; i < N; i++)
		cin >> h[i];

	int ans = 0;
	while (*max_element(h.begin(), h.end()) > 0) {
		unsigned int i = 0;
		for (i = 0; i < h.size(); i++) {
			if (h[i] != 0)
				break;
		}

		ans++;
		for (unsigned int j = i; j < h.size(); j++) {
			if (h[j] == 0)
				break;
			h[j]--;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
use strict;
use warnings;
use feature 'say';
use Data::Dumper;

my $S = <>; chomp($S);
my $out = [];

for my $S_group ($S =~ /(R+L+)/g) {
    my $r_children = 0;
    my $l_children = 0;
    my $r_count = () = $S_group =~ /R/g;
    my $l_count = () = $S_group =~ /L/g;

    if ($r_count % 2 == 0) {
        $r_children += $r_count / 2;
        $l_children += $r_count / 2;
    } else {
        $r_children += $r_count - int($r_count / 2);
        $l_children += int($r_count / 2);
    }

    if ($l_count % 2 == 0) {
        $r_children += $l_count / 2;
        $l_children += $l_count / 2;
    } else {
        $r_children += int($l_count / 2);
        $l_children += $l_count - int($l_count / 2);
    }

    for (1..$r_count) {
        if ($_ == $r_count) {
            push(@$out, $r_children);
        } else {
            push(@$out, 0);
        }
    }

    for (1..$l_count) {
        if ($_ == 1) {
            push(@$out, $l_children);
        } else {
            push(@$out, 0);
        }
    }
}

say "@$out";

Measured memory_bytes: 20224
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    /**
     * @param args
     */
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
            int N = sc.nextInt();
            if(N==0)break;
            Set<Integer>[] set = new Set[N];
            for (int i = 0; i < set.length; i++) {
                set[i]=new HashSet<Integer>();
            }
            for (int i = 0; i < N; i++) {
                int M = sc.nextInt();
                for (int j = 0; j < M; j++) {
                    set[i].add(sc.nextInt()-1);
                }
                
            }
            boolean[] can = new boolean[N];
            Arrays.fill(can, true);
            int K =sc.nextInt();
            for (int i = 0; i < K; i++) {
                int a = sc.nextInt()-1;
                for (int j = 0; j < set.length; j++) {
                    if(!set[j].contains(a)){
                        can[j]=false;
                    }
                }
            }
            int ans=-1;
            int cnt=0;
            for (int i = 0; i < can.length; i++) {
                if(can[i]){
                    ans=i+1;
                    cnt++;
                }
            }
            if(cnt>=2){
                System.out.println(-1);
            } else 
                System.out.println(ans);
        }
    }

}

Measured memory_bytes: 68716
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	map<int, int> m;
	rep(i, 3)
	{
		int tmp;
		cin >> tmp;
		m[tmp]++;
	}
	if (m[5] == 2 && m[7] == 1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

ll n, k, a[210000], v[210000];
vector<int> seq, lop;
int main() {
	scanf("%lld %lld", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%lld", a + i);
	int cur = 1;
	while (!v[cur]) {
		v[cur] = true;
		seq.emplace_back(cur);
		cur = a[cur];
	}
	cur = a[seq.back()];
	while (v[cur]) {
		v[cur] = false;
		lop.emplace_back(cur);
		cur = a[cur];
	}

	if (k < seq.size())
		printf("%d\n", seq[k]);
	else
		printf("%d\n", lop[(k - (seq.size() - lop.size())) % lop.size()]);
}

Measured memory_bytes: 8200
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	string s;cin >> s;
	s[1] = (s[1] == 'R' ? 'B' : 'R');
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

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

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	string s;
	cin>>s;
	if(s[2]==s[3] and s[4]==s[5]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxN = 2e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
const ll INF = (1ll)<<60;
const int MOD = 1e9+7;
int fa[maxN];
int get(int x)
{
	if(x == fa[x])
		return fa[x];
	else
		fa[x] = get(fa[x]);
	return fa[x];
}
int add(int x,int y)
{
	int u = get(x);
	int v = get(y);
	if( u != v)
		fa[u] = v;
}
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		fa[i] = i;
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		add(x,y);
	}
	int cnt = 0;
	for(int i=1;i<=n;i++)
	{
		if(get(i) == i)
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] v = new int[n];
        int[] c = new int[n];
        int ans = 0;
        
        for(int i = 0; i < n; i++){
            v[i] = Integer.parseInt(sc.next());
        }
        for(int i = 0; i < n; i++){
            c[i] = Integer.parseInt(sc.next());
            if(v[i] > c[i]){
                ans += v[i] - c[i];
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
def carriable_baggage(baggage, baggage_num, truck_capacity, truck_num):
    """Return the number of baggae which trucks can carry."""
    laden_baggage = 0
    for i in range(truck_num):
        laden_weight = 0
        while laden_weight + baggage[laden_baggage] <= truck_capacity:
            laden_weight += baggage[laden_baggage]
            laden_baggage += 1
            if laden_baggage == baggage_num:
                return baggage_num
    return laden_baggage

def min_capacity(baggage, baggage_num, truck_num):
    """Return the minimum value of maximum load capacity of trucks."""
    left = max(baggage) - 1
    right = sum(baggage)
    while right - left > 1:
        mid = (left + right) // 2
        v = carriable_baggage(baggage, baggage_num, mid, truck_num)
        if v >= baggage_num:
            right = mid
        else:
            left = mid
    return right


import sys

n, k = map(int, sys.stdin.readline().split())

T = list(map(int, sys.stdin))

P = min_capacity(T, n, k)

print(P)

Measured memory_bytes: 11596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;


public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		double money = 100000;
		BufferedReader bufReader =
				new BufferedReader(new InputStreamReader(System.in));
		int weeks = Integer.parseInt(bufReader.readLine());
		for (int i = 0; i < weeks; i++) {
			money *= 1.05;
			money /= 1000.0D;
			BigDecimal bd = new BigDecimal(money);
			money = bd.setScale(0, BigDecimal.ROUND_UP).doubleValue();
			money *= 1000;
		}
		System.out.println((int) money);
	}

}

Measured memory_bytes: 17160
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL x;
    LL ans=0;
    cin >> x;
    ans += (x/500)*1000;
    x%=500;
    ans += (x/5)*5;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string n;
	cin >> n;
	if (n.at(0) == n.at(1) && n.at(1) == n.at(2) || n.at(1) == n.at(2) && n.at(2) == n.at(3)) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
/*
方針
先ず、f(L,R)について。
f(l,r)を満たす組み合わせは、f(k,r) (0<k<l)も満たすので重複が出る。
今回は動的計画法(DP)を使うが、f(1,r)はa_1からa_rまでの要素からsを作る組み合わせである一方、
f(2,r)はa_2からa_rまでの要素からsを作る組み合わせになる。
つまり、f(2,r)はf(1,r)を求めるDPの途中(a_2以降)で、ついでに計算することができる。
更にrについては、f(~,N)を計算する途中のrにおいて合計がsになっている組み合わせを出力すればいい。
つまり、DPに必要なループはf(1,N)の1つになる。



*/

#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rp(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
const int INF=1000000;
const int MOD=998244353;


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    int s;
    cin >> n >> s;
    vector<int> a(n);
    rp(i,n) cin >> a[i];

    vector<ll> knap(s+1);
    ll out=0;
    rp(i,n){
        ++knap.at(0);      //i回目からDPを行う時の初期値
        for(int j=s-a.at(i); j>=0; --j){
            knap.at(j+a.at(i))+=knap.at(j)%MOD;
        }
        out+=knap.at(s);
    }

    cout << out%MOD << '\n' ;
}   

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

typedef long long ll;
typedef pair <int, int> pii;

const int MAX_N = 1e5 + 5;
int n, ans1, ans2;
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	n = s.size();

	for (int i = 0; i < n; i++)
		ans1 += (s[i] != (i & 1? '1': '0'));


	for (int i = 0; i < n; i++)
		ans2 += (s[i] != (i & 1? '0': '1'));

	cout << min(ans1, ans2);
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
# from collections import Counter
s = list(str(input()))
t = list(str(input()))

dict_ = {}
for i in range(len(s)):
    if s[i] in dict_:
        dict_[s[i]].append(i)
    else:
        dict_[s[i]] = [i]
for key, value in dict_.items():
    a = set([])
    for i in value:
        a.add(t[i])
    # print(a)
    if len(set(a)) != 1:
        print("No")
        exit()

s, t = t, s
dict_ = {}
for i in range(len(s)):
    if s[i] in dict_:
        dict_[s[i]].append(i)
    else:
        dict_[s[i]] = [i]
for key, value in dict_.items():
    a = set([])
    for i in value:
        a.add(t[i])
    # print(a)
    if len(set(a)) != 1:
        print("No")
        exit()
print("Yes")


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

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n==m? "Yes" : "No") << endl;
}


Measured memory_bytes: 256