akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string[] figures = new string[7];
            figures[0] = "1100000011";
            figures[1] = "1000000010000000100000001";
            figures[2] = "1111";
            figures[3] = "01000000110000001";
            figures[4] = "11000000011";
            figures[5] = "100000001100000001";
            figures[6] = "0110000011";

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {

                string map = "";
                map += input;

                for (int i = 0; i < 8; i++) map += Console.ReadLine();

                for (int i = 0; i < figures.Length; i++)
                {
                    if (map.Contains(figures[i]))
                    {
                        sb.Append((char)('A' + i));
                        sb.Append("\n");
                        break;
                    }
                }
            }
            Console.Write(sb);
        }
    }
}

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

int main() {
	int X,A,B;
  	cin >> X >> A >> B;
  
  	if(A >= B) {
    	cout << "delicious" << endl;
    }else if (A + X >= B) {
    	cout << "safe" << endl;
    } else if(A + X < B){
    	cout << "dangerous" << endl;
    }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A, B, K;
    cin >> A >> B >> K;
    i64 a, b;
    if (A >= K) {
        a = A - K;
        b = B;
    } else {
        a = 0;
        b = max(B - (K - A), (i64)0);
    }

    cout << a << " " << b << endl;

    return 0;
}

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

vector<vector<string>> a = {
	{"aab", "c.b", "cdd"},
	{"aabc", "ddbc", "efgg", "efhh"},
	{"abbcc", "a.dde", "fg..e", "fg..h", "iijjh"},
	{"aab.dd", "c.be..", "cdde..", ".eeaab", "f..c.b", "f..cdd"},
	{"a..bc..", "a..bc..", "ddee.ff", ".gg.hii", "j..kh...", "j..kl..", ".mm.lnn"},
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	if(n == 2) cout << -1 << "\n";
	else if(n == 3){
		for(auto i:a[0]) cout << i << "\n";
	}else{
		vector<string> ans(n, string(n, '.'));
		Int t = (n-4)/4;
		for(Int i=0; i<t; ++i)
			for(Int j=0; j<4; ++j)
				for(Int k=0; k<4; ++k)
					ans[4*i+j][4*i+k] = a[1][j][k];
		for(Int j=0; j<n-4*t; ++j)
			for(Int k=0; k<n-4*t; ++k)
				ans[4*t+j][4*t+k] = a[n-4*t-3][j][k];
		for(auto i:ans) cout << i << "\n";
	}
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,yellow,blue,red,x,fuel,cap,d,y,b,r,price,sum=0,t,i,j,ans=0,dif,array[100000+10],f,p,minn,a,c,flag;
    char pixel [110][110];
    vector<long long int>v,vec;
    bool prime[1000007];
    string str,ptr;
    char ch;
    cin>>n;
    x=100;
    while(1)
    {
      x=x+(x*1)/100;
      sum++;
      if(x>=n)
      {
          break;
      }
    }
  cout<<sum<<endl;


    return 0;


}


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

int main(){
    int B=0;
    string A;
    cin >> A;
    if(A[1]=='7'){
        B=1;
    }else if(A[2]=='7'){
        B=1;
    }else if(A[0]=='7'){
        B=1;
    }
    if(B==1){
        cout << "Yes" << endl;
    }else{
        cout << "No"<<endl;
    }
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[int]"):
    counter = 0
    for i in range(N-1):
        if i+1 == p[i]:
            p[i], p[i+1] = p[i+1], p[i]
            counter += 1
    if p[N-1] == N:
        counter += 1
    print(counter)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
from fractions import gcd
def lcm(x,y):
  return x * y // gcd(x,y)
def list_lcm(list):
  c=1
  for i in list:
    c=lcm(c,i)
  return c
n=int(input())
t=[int(input()) for i in range(n)]
print(list_lcm(t))

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

int main(void){
  int n, k, cnt = 0;
  scanf("%d",&n);
  scanf("%d",&k);
  while(n){
  	if(n != 0){
  	n = n/k;
    }
    cnt = cnt + 1;
  }
  printf("%d",cnt);
  
  return 0;
}

Measured memory_bytes: 1648
#include "bits/stdc++.h"
    #define LF '\n'
    #define ALL(x) x.begin(), x.end()
    #define iostreamBooster() do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
    using namespace std;
    typedef int64_t i64;
    typedef pair<int,int> pii;
    template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
    template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
    constexpr int INF = 0x3f3f3f3f;
    constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;
     
     
    signed main()
    {
    int N;
    cin >> N;
    for (int i = N; i < 1000; ++i) {
    char s[100];
    sprintf(s, "%d", i);
     
    if (s[0] == s[1] && s[0] == s[2]) {
    cout << i << endl;
    return 0;
    }
    }
     
    return 0;
    }
     

Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	ll ans;

	if (H == 1 || W == 1) {
		ans = 1;
	} else if ((H * W) % 2 == 1) {
		ans = (H * W) / 2 + 1;
	} else {
		ans = (H * W) / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
ans = 0 
t = 0
for e,(i , j) in enumerate(zip(A,A[1:])):
    if i + t > j : 
        ans += t + i-j
        t= t + i-j
    else:t = 0
    # print(t,ans)
print(ans)

Measured memory_bytes: 32148
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    readln;
    auto as = readln.split.to!(long[]);
    auto x = as[0];
    foreach (a; as[1..$]) x = gcd(a, x);
    writeln(x);
}

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

int main(){
  
  while(1){
    int n=0;
    cin >> n;
    if(n==0)break;
    int time[1000000] = {};
    for(int i=0;i<1000000;i++){
      time[i] =0;

    }
    
    for(int i=0;i<n;i++){
      
      int h,m,s;
      char c;
      c =0;
      cin >> h >> c >> m >> c >> s;

      int a = h * 3600 + m * 60 + s;

      time[a]++;

      cin >> h >> c >> m >> c >> s;

      a = h * 3600 + m * 60 + s;

      time[a]--;
    }

    int cnt,mx;
    mx =0;
    cnt= 0;
    for(int i=0;i<1000000;i++){
      cnt += time[i];
      mx = max(mx,cnt);
    }
    cout << mx << endl;

  }




}



Measured memory_bytes: 6996
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007
int main(){
  int n,a,b;cin>>n>>a>>b;
  int mn,mx;
  if(a+b <= n)mn = 0,mx = min(a,b);
  else mx = min(a,b),mn = (a+b-n);
  cout << mx << " " << mn << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> D, long long M, std::vector<long long> T)
{
    map<int, int> problem;
    map<int, int> needs;
    for (int i = 0; i < N; i++)
    {
        problem[D[i]]++;
    }
    for (int i = 0; i < M; i++)
    {
        needs[T[i]]++;
    }

    for (auto &&i : needs)
    {
        if(problem[i.first] < i.second){
            cout << NO << endl;
            return;
        }   
    }
    cout << YES << endl;
    
}

int main()
{
    long long N;
    scanf("%lld", &N);

    std::vector<long long> D(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &D[i]);
    }
    long long M;
    scanf("%lld", &M);
    std::vector<long long> T(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &T[i]);
    }
    solve(N, std::move(D), M, std::move(T));
    return 0;
}


Measured memory_bytes: 22144
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}




void solve(long long A, long long B, long long T){
    long long ans = 0;
    for(int i = A;i <= T;i += A){
        ans += B;
    }
    cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long T;
    scanf("%lld",&T);
    solve(A, B, T);
    return 0;
}


Measured memory_bytes: 256
r, d, x = map(int, input().split())
x1 = r*x - d
x2 = r*x1 - d
x3 = r*x2 - d
x4 = r*x3 - d
x5 = r*x4 - d
x6 = r*x5 - d
x7 = r*x6 - d
x8 = r*x7 - d
x9 = r*x8 - d
x10 = r*x9 - d
print(x1)
print(x2)
print(x3)
print(x4)
print(x5)
print(x6)
print(x7)
print(x8)
print(x9)
print(x10)

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

int main()
{
	long long N;
	cin >> N;
	vector<long long> cap(5);
	for (int i = 0; i < 5; ++i) {
		cin >> cap[i];
	}

	long long minValue = *min_element(cap.begin(), cap.end());

	cout << (N + minValue - 1) / minValue + 4 << endl;
}

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

using namespace std;

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int> > A(n);
  REP(i, m){
    int a, b;
    cin >> a >> b;
    --a, --b;
    A[a].push_back(b);
  }
  vector<vector<int> > B;
  vector<vector<int> > T;
  REP(i, n){
    queue<pair<int, int> > q;
    q.push(make_pair(i, 0));
    vector<int> v(n, -1);
    vector<int> t(n);
    while(!q.empty()){
      auto x = q.front();
      q.pop();
      for(auto y: A[x.first]){
        if(v[y] >= 0) continue;
        t[y] = x.first;
        v[y] = x.second + 1;
        q.push(make_pair(y, x.second + 1));
      }
    }
    B.push_back(v);
    T.push_back(t);
  }
  int r = 10000000;
  int mi, mj;
  REP(i, n){
    if(B[i][i] > 0){
      if(B[i][i] < r){
        mi = i;
        r = B[i][i];
      }
    }
  }
  if(r > n){
    cout << -1 << endl;
    return 0;
  }
  cout << r << endl;
  vector<int> ans(r);
  auto t = T[mi];
  int y = mi;
  REP(i, r){
    ans[r - i - 1] = y;
    y = t[y];
  }
  REP(i, r){
    cout << ans[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int p[n];
  for (auto i = 0; i < n; i++)
    scanf("%d", &p[i]);
  int q[n];
  for (auto i = 0; i < n; i++)
    q[p[i] - 1] = i;
  int ret = 1, maxr = 0;
  for (auto i = 1; i < n; i++) {
    if (q[i] < q[i - 1]) {
      maxr = max(maxr, ret);
      ret = 1;
    } else {
      ret++;
    }
  }
  maxr = max(ret, maxr);
  printf("%d\n", n - maxr);
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
const int maxn=1005;
int n,k;
int a[100005],b[100005],c[100005];
long long book[100005];
void bfs()
{
    memset(book,0,sizeof(book));
    int p=0,q=0;
    while(p<n&&q<n){
        while(c[q]<=b[p]&&q<n) q++;
        if(q==n) break;
        book[p]=n-q;
        p++;
    }
    for(int i=1;i<n;i++)
        book[i]+=book[i-1];
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
   for(int i=0;i<n;i++) cin>>b[i];
   for(int i=0;i<n;i++) cin>>c[i];
   sort(a,a+n);
   sort(b,b+n);
   sort(c,c+n);
   bfs();
   long long sum=0;
  int p=0,q=0;
  while(p<n&&q<n){
    while(b[q]<=a[p]&&q<n) q++;
    if(q==n) break;
    if(q==0)
    sum+=book[n-1];
    else
        sum+=book[n-1]-book[q-1];
    p++;
  }
   cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 2176
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int m1,d1;
	int m2,d2;
	cin >> m1 >> d1;
	cin >> m2 >> d2;

	if(m1 == m2){
		cout << 0 << endl;
	}
	else{
		cout << 1 << endl;
	}

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m=1e9+7;
int main()
{
	ll n;
	cin>>n;
	vector<vector<ll>>arr(n,vector<ll>(n));
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>arr[i][j];
	vector<ll>dp(1<<n);dp[0]=1;
		for(int mask=0;mask<(1<<n)-1;mask++)
		{
			ll a=__builtin_popcount(mask);
			for(int j=0;j<n;j++)
			{
				if(arr[a][j] && !(mask & (1<<j)))
				{
					int m1=mask|(1<<j);
					dp[m1]=(dp[m1]+dp[mask])%m;
				}
			}
		}
	cout<<dp[(1<<n)-1];
}

Measured memory_bytes: 16640
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: isize,
        n: usize,
        a: [isize; n],
    }
    let a_sum: isize = a.iter().sum();
    println!("{}", if a_sum >= h { "Yes" } else { "No" });
}


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

#define PRIME 1000000007
using namespace std;

long int **adj,**prod,**cp;
int n;

long int **multiply(long int **a,long int **b)
{
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j)
		{
			cp[i][j] = 0;
			for(int k=0;k<n;++k)
			cp[i][j] = (cp[i][j] + a[i][k]*b[k][j])%PRIME;
		}
	}
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
		b[i][j] = cp[i][j];
	return b;
}

void power(long int k)
{
	while(k)
	{
		if(k & 1)
		prod = multiply(adj,prod);
		adj = multiply(adj,adj);
		k = k >> 1;
	}
}
int main()
{
	long int k,path=0;
	scanf("%d%ld",&n,&k);
	adj = new long int*[n];
	prod = new long int*[n];
	cp = new long int*[n];
	for(int i=0;i<n;++i)
	{
		adj[i] = new long int[n];
		prod[i] = new long int[n];
		cp[i] = new long int[n];
	}
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
		{
			scanf("%d",adj[i]+j);
			if(i == j)
			prod[i][j] = 1;
			else
			prod[i][j] = 0;
		}
	power(k);
	/*for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j)
		cout<<prod[i][j]<<" ";
		cout<<endl;
	}*/
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
		path = (path + prod[i][j])%PRIME;
	printf("%ld\n",path);
	return 0;
}


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

int main(){
  int n,a,b,c;
  cin>>n>>a>>b>>c;
  vector<int> l(n);
  rep(i,n) cin>>l[i];
  
  vector<int> rui={1,4,16,64,256,1024,4096,16384,65536};
  int ans=1000000000;
  rep(bit,rui[n]){
    int res=0;
    int q=bit;
    int ka=0,kb=0,kc=0;
    rep(j,n){
      int p=q%4;
      q/=4;
      if(p==0) continue;
      else if(p==1){
        if(ka!=0) res+=10;
        ka+=l[j];
      }
      else if(p==2){
        if(kb!=0) res+=10;
        kb+=l[j];
      }
      else if(p==3){
        if(kc!=0) res+=10;
        kc+=l[j];    
      }
    }
    if(ka==0||kb==0||kc==0) continue;
    res+=abs(ka-a);
    res+=abs(kb-b);
    res+=abs(kc-c);
    ans=min(ans,res);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static final int MOD=1000000007;


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.charAt(0)!=s.charAt(1)||s.charAt(1)!=s.charAt(2)) System.out.println("Yes");
        else System.out.println("No");

    }
}




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

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    int ans = K;
    rep(i, N - 1) ans *= K - 1;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <stack>
#include <queue>
#include <map>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int k = 0;
	int mini = 1000000002;
	long long int res = 0;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		k += a > b;
		if (a > b)
		{
			mini = min(mini, b);
		}
		res += b;
	}
	cout << (k == 0 ? 0 : res - mini);
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def input():
  return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
v = [[] for _ in range(n+1)]
c = [0]*(n+1)

for _ in range(n-1):
  a, b = map(int, input().split())
  v[a].append(b)
  v[b].append(a)

for _ in range(q):
  p, x = map(int, input().split())
  c[p] += x

def addcount(p, prev):
  for i in v[p]:
    if i != prev:
      c[i] += c[p]
      addcount(i, p)
  return None
addcount(1, 0)
  
print(*c[1:])

Measured memory_bytes: 230932
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int small = k;
  if(a[n-1] - a[0] < small){
	small = a[n-1]-a[0];
  }
  if(a[0] + k - a[1] < small){
    small = a[0] + k - a[1];
  }
  
  for(int i = 1; i < n-1; i++){
    if(a[i] + k - a[i+1] < small){
      small = a[i] + k - a[i+1];
    }
    if(k - a[i] + a[i-1] < small){
      small = k-a[i] + a[i-1];
    }
  }
  cout << small;
}

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

int main() {
 bool seged=true;
 string S="8770";
 cin >> S;
 for(int i=0;i<S.length()-1;i++){
   if(S[i]==S[i+1]){
     seged=false;
   }
 }
   if(seged==false){
     cout << "Bad";
   }else{
     cout << "Good";
 } 
	return 0;
}


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

const static ll MOD = (1e+9)+7;

ll modpow(ll a,ll n){
    if(n==0)return 1;
    if(n%2==1)return a*modpow(a,n-1)%MOD;
    ll t = modpow(a,n/2) % MOD;
    return t*t % MOD;
}

int main(){
    int k,a,b;cin>>k>>a>>b;
    if(b/k - a/k != 0 || b%k == 0 || a%k == 0){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main(void)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a==b&&b!=c)||(a==c&&b!=c)||(c==b&&a!=c))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    startt
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if( x/d >= k)
    {
        cout << abs(x)-k*d;
        return 0;
    }
    ll bigger = x%d;
    ll smaller = bigger-d;
    ll bigp = k-x/d;
    if(bigp%2 == 0)
    {
        cout << bigger << endl;
    }
    else
    {
        cout << abs(smaller) << endl;
    }
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_len=(n); i<i##_len; ++i)
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
using ll = long long;
using namespace std;

int n1[] = {1, -1, 0,  0};
int n2[] = {0,  0, 1, -1};

int main()
{
    int H, W;
    cin >> H >> W;
    string A[H];
    REP(i, H) cin >> A[i];

    bool field[H][W];
    queue<tuple<int,int,int>> que;
    REP(i, H) REP(j, W)
    {
        bool is_black = A[i][j] == '#';
        field[i][j] = is_black;
        if (is_black) que.push(make_tuple(i, j, 0));
    }

    int ret = 0;
    while (!que.empty())
    {
        tuple<int,int,int> elem = que.front();
        que.pop();

        int oh = get<0>(elem);
        int ow = get<1>(elem);
        int oa = get<2>(elem);
        if (field[oh][ow] && oa > 0) continue;
        field[oh][ow] = true;

        ret = max(ret, oa);

        REP(i, 4)
        {
            int h = oh+n1[i];
            int w = ow+n2[i];
            if (h < 0 || h >= H) continue;
            if (w < 0 || w >= W) continue;
            if (field[h][w]) continue;

            que.push(make_tuple(h, w, oa+1));
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 14352
N,Q = map(int,input().split())
S = input()

t = [0]*(N+1)
for i in range(N):
    t[i+1] = t[i] + (S[i:i+2] == "AC")
    
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 13068
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	int sm[N] = {};
	vector<bool> pr(N, 1);
	for(int i = 2; i < N; i++){
		if(pr[i]){
			for(int k = 2*i; k < N; k += i){
				if(!sm[k]) sm[k] = i;
				pr[k] = 0;
			}
			sm[i] = i;
		}
	}
	int ar[n];
	int eb = 0;
	for(int i = 0; i < n; i++){
		cin>>ar[i];
		eb = ebob(eb, ar[i]);
	}
	bool seen[N] = {};
	bool pairwise = true;
	for(int i = n-1; i >= 0; i--){
		while(ar[i] > 1){
			int bol = sm[ar[i]];
			if(seen[bol]) pairwise = false;
			seen[bol] = true;
			while(ar[i] % bol == 0) ar[i] /= bol;
		}
	}
	if(pairwise) cout<<"pairwise coprime\n";
	else if(eb == 1) cout<<"setwise coprime\n";
	else cout<<"not coprime\n";
}

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

int main() {
  int N;
  cin >> N;
  vector<char> S(N);
  for(int i = 0; i < N; i++){
    cin >> S.at(i);
  }
  string ans = "No";
  if(N % 2 == 0){
    int N2 = N / 2;
    int count = 0;
    for(int i = 0; i < N2; i++){
      if(S.at(i) != S.at(i + N2)){
        break;
      }
      else{
        count++;
      }
    }
    if(count == N2){
      ans = "Yes";
    }
  }
  cout << ans << endl;
      
}


Measured memory_bytes: 256
x1, y1, x2, y2 = list(map(int, input().split()))
l = max(abs(x1 - x2), abs(y1 - y2))
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)
print('{} {} {} {}'.format(x3, y3, x4, y4))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,mod=998244353,pw2,t,mu[200005],f[200005],g[200005],ans;
int np[200005],p[200005],pc;
string st;

int solve(int x)// 步长=x*pw2
{
	int ans=0,i,j;
	fz0k(i,x*pw2){
		inc(ans,ans)
		inc(ans,st[i]-'0')
	}
	int rev=0;
	for(j=x*pw2;j<n*pw2;j+=x*pw2){
		rev^=1;
		fz0k(i,x*pw2){
			int t=(st[i]^rev);
			if(st[i+j]>t){
				inc(ans,1)
				return ans;
			}
			if(st[i+j]<t){
				return ans;
			}
		}
	}
	inc(ans,1)
	return ans;
}

int main()
{
	mu[1]=1;
	fz(i,2,200000){
		if(!np[i]){
			p[++pc]=i;
			mu[i]=mod-1;
		}
		for(j=1;j<=pc;j++){
			if(i*p[j]>200000) break;
			np[i*p[j]]=1;
			mu[i*p[j]]=mod-mu[i];
			if(i%p[j]==0){
				mu[i*p[j]]=0;
				break;
			}
		}
	}
	
	cin>>n>>st;
	pw2=1;
	while(n%2==0){
		pw2*=2;
		n/=2;
	}
	
	fz1(i,n)if(n%i==0){
		f[i]=solve(i);
	}
	
	fz1(i,n)if(n%i==0){
		for(j=1;i*j<=n;j++){
			inc(g[i*j],1ll*f[i]*mu[j]%mod)
		}
	}
	
	fz1(i,n)if(n%i==0){
		inc(ans,2ll*pw2%mod*i%mod*g[i]%mod);
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
ll gcd(ll p,ll q){while(q){ll t=p%q;p=q;q=t;}return p;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//KMP法
//検索したい文字列をmakekmpに食わせてから
//kmpsearchを呼ぶ
//*
int*makekmp(char*t,int tlen){
	int*tt=calloc(tlen+1,sizeof(int));
	int len=0;
	tt[0]=-1;
	for(int pos=1;pos<tlen;pos++,len++){
		if(t[pos]==t[len]){
			//同じなのに失敗したら、失敗
			tt[pos]=tt[len];
		}
		else{
			//違うとき失敗したら、そこからチェック
			tt[pos]=len;
			//一致するところまで戻る
			while(len>=0&&t[pos]!=t[len])len=tt[len];
		}
	}
	tt[tlen]=len;
	return tt;
}
int kmpsearch(char*s,char*t,int*tt){
	int k=0;
	for(int j=0;s[j];){
		if(s[j]==t[k]){
			j++,k++;
			if(!t[k]){
				//最後まで行ったら、最後で失敗扱い
				return 1;
			}
		}else{
			//失敗
			k=tt[k];
			if(k==-1)j++,k++;//1文字目
		}
	}
	return 0;
}
//*/

char s[2000010];
char t[2000010];
int main(){
	scanf("%s%s",s,t);
	int sn=strlen(s);
	int tn=strlen(t);
	int sss=sn;
	while(sss<1.5e6)memcpy(s+sss,s,sn),sss+=sn;

	int length=(sss-(tn-1))/tn*tn;
	int ttt=tn;
	while(ttt+tn<=length)memcpy(t+ttt,t,tn),ttt+=tn;
	int*p=makekmp(t,ttt);
	if(kmpsearch(s,t,p)){
		puts("-1");
		return 0;
	}
	int l=0,r=ttt/tn;
	while(r-l>1){
		int m=(l+r)/2;
		t[tn*m]=0;
		if(kmpsearch(s,t,p))l=m;
		else r=m;
		t[tn*m]=t[0];
	}
	printf("%d",l);
}

Measured memory_bytes: 11904
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

vector <int> a, b, c;

int id(vector <int> a)
{
	iota(ALL(c), 1);
	int ret = 0;
	do
	{
		if (a == c)
			return ret;
		ret++;
	}
	while (next_permutation(ALL(c)));
	assert(false);
}

void solve()
{
	int n;
	scanf ("%d", &n);
	a.resize(n);
	b.resize(n);
	c.resize(n);
	FOR(i, 0, n)
		scanf ("%d", &a[i]);
	FOR(i, 0, n)
		scanf ("%d", &b[i]);
	int res = 0;
	
	res = id(a);
	res = res - id(b);
	if (res < 0)
		res *= -1;
	printf("%d\n", res);
}

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


Measured memory_bytes: 256
input()
S = [i for i in input()]
point = 0
del_list = list()
for i in range(point,len(S)-1):
  if S[i] == S[i+1]:
    del_list.append(i)
for i,j in enumerate(del_list,0):
  del S[j-i]
      
print(len(S))

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

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

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

    string s;
    cin >> s;
    int n = s.size();

    string ex_x = "";
    for(int i = 0; i < n; ++i){
        if(s[i] == 'x') continue;
        ex_x += s[i];
    }

    if(!isp(ex_x)){
        cout << -1 << endl;
        return 0;
    }

    int m = ex_x.size();
    vector<int> num_x(m+1, 0);
    int ptr = 0;
    for(int i = 0; i < m; ++i){
        int num = 0;
        while(s[ptr] != ex_x[i]){
            ++num;
            ++ptr;
        }
        num_x[i] = num;
        ++ptr;
    }
    
    ptr = n-1;
    int num = 0;
    while(s[ptr] != ex_x[m-1]){
        ++num;
        --ptr;
    }
    num_x[m] = num;
    
    int res = 0;
    for(int i = 0; i < (m+1)/2; ++i){
        res += abs(num_x[i] - num_x[m-i]);
    }

    cout << res << endl;

    return 0;

}

Measured memory_bytes: 3952
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) begin(V), end(V)
#define ALLR(V) rbegin(V), rend(V)
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif
    
ll N, I, J;

ll rec(ll rest, ll aim, V<char> &ans) {
    if (rest == 0) return J;
    ll all = (1ll << rest);
    ll size = (1ll << (N - rest + 1));
    bool op;
    ll idx;
    if (aim < all / 2) {
        idx = rec(rest - 1, (1ll << (rest - 1)) - 1 - aim, ans);
        op = (idx < size / 2);
    } else {
        idx = rec(rest - 1, aim ^ (1ll << (rest - 1)), ans);
        op = !(idx < size / 2);
    }
    bool left = idx < size / 2;
    ans.push_back(op ? 'L' : 'R');
    if (left) {
        if (op) return (size / 2 - 1) - idx;
        else return idx;
    } else {
        idx -= size / 2;
        if (op) return idx;
        else return (size / 2 - 1) - idx;
    }
}

bool solve() {
    cin >> N >> I >> J;
    if (!(N + I + J)) return false;
    I--; J--;
    V<char> ans;
    rec(N, I, ans);
    for (char c : ans) cout << c;
    cout << endl;
    return true;
}

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



Measured memory_bytes: 3056
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;
int a[N][N];
void floyd(int n)
{
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
			{
				if (a[i][j] > a[i][k] + a[k][j]) puts("-1"), exit(0);
			}
		}
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<tuple<int, int, int>> vp;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			cin >> a[i][j];
			vp.emplace_back(a[i][j], i, j);
		}
	}
	floyd(n);
	sort(vp.begin(), vp.end());
	LL ans = 0;
	for (auto &p : vp)
	{
		int x, y, w;
		tie(w, x, y) = p;
		ans += w;
		for (int i = 1; i <= n; i++)
		{
			if (i == x || i == y) continue;
			if (a[x][i] + a[i][y] == a[x][y])
			{
				ans -= w;
				break;
			}
		}
	}
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


struct Segmenttree {
	static const int N = 1 << 18;
	vector<ll>seg;
	vector<ll>idx;
	void st(ll p, ll v) {
		p += N - 1;
		seg[p] = v;
		idx[p] = p - N + 1;
		while (p > 0) {
			p = (p - 1) / 2;
			seg[p] = min(seg[2 * p + 1], seg[2 * p + 2]);
			if (seg[2 * p + 1] > seg[2 * p + 2])idx[p] = idx[2 * p + 2];
			else if (seg[2 * p + 1] < seg[2 * p + 2])idx[p] = idx[2 * p + 1];
			else idx[p] = min(idx[2 * p + 1], idx[2 * p + 2]);
		}
	}
	pair<ll, ll> query(ll l, ll r, ll a, ll b, ll k) {
		if (r <= a || b <= l)return { inf,inf };
		if (l <= a && b <= r)return { seg[k],idx[k] };
		ll m = (a + b) / 2;
		auto p1 = query(l, r, a, m, 2 * k + 1);
		auto p2 = query(l, r, m, b, 2 * k + 2);
		if (p1.first < p2.first) return p1;
		else if (p1.first > p2.first)return p2;
		else return { p1.first,min(p1.second,p2.second) };
	}

	void init() {
		seg.resize(2 * N);
		idx.resize(2 * N);
		for (int i = 0; i < 2 * N; i++)seg[i] = inf;
	}
	//[l,r]
	ll get(int l, int r) {
		return query(l, r + 1, 0, N, 0).first;
	}
	ll getidx(int l, int r) {
		return query(l, r + 1, 0, N, 0).second;
	}
	pair<ll, ll>getp(int l, int r) {
		return query(l, r + 1, 0, N, 0);
	}
};

Segmenttree sege = Segmenttree();
Segmenttree sego = Segmenttree();

int N;
vector<int>p;
int pa[202020];
vector<int>E[202020];

min_priority_queue<int>q;
void dfs(int st,int en,int par){
	if (st >= en)return;
	pair<int,int> p1,p2;
	if (st % 2 == 0) {
		p1 = sege.getp(st,en);
		p2 = sego.getp(p1.second,en);
	}
	else {
		p1 = sego.getp(st, en);
		p2 = sege.getp(p1.second, en);
	}
	E[par].pb(p1.first);
	pa[p1.first] = p2.first;
	int idx1 = p1.second;
	int idx2 = p2.second;
	dfs(st,idx1-1,p1.first);
	dfs(idx1+1,idx2-1,p1.first);
	dfs(idx2+1,en,p1.first);
}

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

	sege.init();
	sego.init();

	cin >> N;
	p.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		if (i % 2 == 0)sege.st(i,p[i]);
		else sego.st(i,p[i]);
	}
	dfs(0,N-1,200020);

	vector<int>ans;
	q.push(E[200020][0]);
	while (q.size()) {
		int tp = q.top();
		q.pop();
		ans.pb(tp);
		ans.pb(pa[tp]);
		fore(x, E[tp])q.push(x);
	}
	fore(x, ans)cout << x << " ";
	cout << endl;

	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

int main()
{


   IOS;

  string s;
  cin>>s;

 




 if(s[2] == s[3] && s[4] == s[5])
 {
     cout<<"Yes";
 }
 else
 {
  cout<<"No";
 }



  return 0;


}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    t=SI()
    a=len(s)
    b=len(t)
    ans=b
    for i in range(a-b+1):
        res=b
        for j in range(b):
            if s[i+j]==t[j]:
                res-=1
        ans=min(ans,res)
    print(ans)
            
        
if __name__=="__main__":
    main()


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

#define pb push_back
#define mk make_pair
#define fs first
#define sc second
#define all(a) s.begin(), s.size()
#define file(s, w) freopen(s".in", "r", stdin); freopen(w".out", "w", stdout);

typedef long long ll;
typedef long double ld;

using namespace std;

const int N = 1e5 + 500;
const int mod = 1e9 + 7;
const int eps = 1e9 - 11;
const int inf = 2e9;
long long n, m, x, y;
long long dp[N], a[N];
int main()
{
        cin >> n >> x >> y;
        for (int i = 1; i <= n; i ++)
                cin >> a[i];
        for (int i = 2; i <= n; i ++)
        {
                dp[i] = dp[i - 1] + min((a[i] - a[i - 1]) * x, y);
        }
        cout << dp[n] << endl;
}


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

const int MAX_V = 500;
const int INF = 100000;

// 辺を表す構造体（行き先，容量，逆辺）
struct edge { int to, cap, rev; };

vector<vector<edge>> G(MAX_V);
vector<bool> used(MAX_V);

// fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, int cap) {
    int n = G[to].size();
    int m = G[from].size();
    G[from].push_back((edge){to, cap, n});
    G[to].push_back((edge){from, 0, m});
}

// 増加パスをDFSで探す
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f,e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流を求める
int max_flow(int s, int t) {
    int flow = 0;
    while(flow <= 100) {
        for (int j = 0; j < used.size(); j++) used[j] = 0;
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
    return 0;
}


int main() {
    int N; cin >> N;
    vector<int> a(N), b(N), c(N), d(N);

    rep(i,N) cin >> a[i] >> b[i];
    rep(i,N) cin >> c[i] >> d[i];
    rep(i,N) {
        rep(j,N) {
            if (a[i] < c[j] && b[i] < d[j]) add_edge(i+1,j+201,1);
        }
    }
    rep(i,N) add_edge(0,i+1,1);
    rep(i,N) add_edge(i+201,401,1);

    cout << max_flow(0,401) << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#define name 10
#define N 100005
typedef struct{
 char s[name];
  int time;
}R;
R x[N+1];
int head,tail;
void Enqueue(R );
R Dequeue(void);
int main()
{
  int i,n,q,T=0;
  R y;
  scanf("%d%d",&n,&q);
  for(i = 0 ; i < n ; i++){
    scanf("%s%d",y.s,&y.time);
    Enqueue(y);
  }
  while(n!=0){
    y = Dequeue();
    if(y.time>q){
      y.time = y.time-q; 
      T += q;
      Enqueue(y);
    } 
    else{
      T = T+y.time;
      printf("%s %d\n",y.s,T);
      n--;
    }
  }
  return 0;
}

void Enqueue(R Y){
  if(N == tail) tail = 0; 
    x[tail] = Y;
    tail++;
}

R Dequeue(void){
  if(head == N) head = 0;
  return x[head++];
}

Measured memory_bytes: 2160