akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int cnt[N];
  fill(cnt, cnt + N, 0);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    cnt[--A]++;
  }
  sort(cnt, cnt + N);
  int r = N - 1;
  int S = N;
  for (int i = 0, K = 1; i < N; i++, K++) {
    while (r >= 0 && S < K * cnt[r]) S -= cnt[r--], K--;
    cout << S / K << '\n';
  }
  return 0;
}


Measured memory_bytes: 4832
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var k = cin.nextInt();
            var s = "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";
            var ss = s.Split(',');

            Console.WriteLine(ss[k-1]);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
//53
#include<iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  for(;;){
    char c;
    cin>>c;
    if(c=='=')break;
    int m;
    cin>>m;
    if(c=='+'){
      n+=m;
    }else if(c=='-'){
      n-=m;
    }else if(c=='*'){
      n*=m;
    }else{
      n/=m;
    }
  }
  cout<<n<<endl;
  return 0;
}

Measured memory_bytes: 1160
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int h=n/3600;
	int m=(n%3600)/60;
	int s=((n%3600)%60);
	System.out.println(h+":"+m+":"+s);
    }
}

Measured memory_bytes: 17288
n,k=map(int,input().split())
h_list=[]
for i in range(n):
    h_list.append(int(input()))
h_list.sort()
i=0
Min=10**9
while i+k-1<=n-1:
    d=h_list[i+k-1]-h_list[i]
    if d<Min:
        Min=d
    i=i+1
print(Min)


Measured memory_bytes: 50392
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K,C;
	string S;
	scan(N>>K>>C>>S);
	int maxwork=0;
	rep(i,N){
		if(S[i]=='o'){
			maxwork++;
			i+=C;
		}
	}
	int cnt[200001]={};
	rep(i,N){
		if(S[i]=='o'){
			cnt[i]++;
			i+=C;
		}
	}
	brep(i,N){
		if(S[i]=='o'){
			cnt[i]++;
			i-=C;
		}
	}
	if(maxwork==K){
		rep(i,N){
			if(cnt[i]==2) prin(i+1);
		}
	}
	else{

	}
	return 0;
}


Measured memory_bytes: 4516
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int N;

int dfs(string s) {
    int res = 0;
    if (stoll(s) > N) return res;
    if (count(s.begin(), s.end(), '7') >= 1
        and count(s.begin(), s.end(), '5') >= 1
        and count(s.begin(), s.end(), '3') >= 1)
        res = 1;

    res += dfs(s+'7');
    res += dfs(s+'5');
    res += dfs(s+'3');

    return res;
}

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

    cin >> N;
    cout << dfs("0") << endl;
}

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

int main(){
    int x1, y1, x2, y2; 
    cin >> x1 >> y1 >> x2 >> y2;

    int a = x2 - x1;
    int b = y2 - y1;
    int x3 = x2 - b;
    int y3 = y2 + a;
    int x4 = x3 - a;
    int y4 = y3 - b;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

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

using namespace std;

int main()
{
	int N;
	int count = 0;
	int judge = 9;

	cin >> N;

	while (N > 0) {
		int k  = N % 10;
		if (judge == k) {
			cout << "Yes" << endl;
			count = 1;
			break;
		}
		N /= 10;
	}

	if (count == 0)
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<numeric>

std::string Replace( std::string String1, std::string String2, std::string String3 )
{
    std::string::size_type  Pos( String1.find( String2 ) );

    while( Pos != std::string::npos )
    {
        String1.replace( Pos, String2.length(), String3 );
        Pos = String1.find( String2, Pos + String3.length() );
    }

    return String1;
}

int main() {

   std::string S, T;
   std::cin >> S >> T;
    
   for (int i = 0; i < S.size(); i++) {
      if (S[i] != T[i]) {
         if (i > 0 && (S.substr(0, i).find(T[i]) <= i - 1 || S.substr(0, i).find(S[i]) <= i - 1)) {
            // std::cout << S.substr(0, i).find(T[i]) << std::endl;
            std::cout << "No" << std::endl;
            return 0;
         }
         std::string S2 = S;
         std::string tmp = "*@";
         S = Replace(S, S.substr(i, 1), tmp.substr(0, 1));
         S = Replace(S, T.substr(i, 1), tmp.substr(1, 1));
         S = Replace(S, tmp.substr(0, 1), T.substr(i, 1));
         S = Replace(S, tmp.substr(1, 1), S2.substr(i, 1));
         // std::cout << S << std::endl;
      }
   }
   
   std::cout << "Yes" << std::endl;
   return 0;
}


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

int main(){
  long long x,a,b;
  cin>>x;
  for(long long i=120;i>=0;i--){
    for(long long j=-70;j<=i;j++){
       if(pow(i,5)-pow(j,5)==x){
         a=i;
         b=j;
         break;
       }
    }
  }
  cout <<a<<" "<<b;
}


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

int main(){
	int x[3], y[3];
	f(i, 0, 3)scanf("%d", x + i);
	f(i, 0, 100){
		bool ok = false;
		f(j, 0, 3)if (x[j] & 1) { ok = true; break; }
		if (ok)printf("%d\n", i), exit(0);
		f(j, 0, 3)y[j] = x[j] >> 1;
		f(j, 0, 3)x[j] = 0;
		f(j, 0, 3)f(k, 0, 3)if (j != k)x[j] += y[k];
	}
	printf("-1\n");
}

Measured memory_bytes: 256
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sqrt

fun main(args: Array<String>) {
  val (A,B,H,M) = readLine()!!.split(" ").map { it.toInt() }
  val deg = ((6-0.5)*(H*60+M))%360
  val x = sqrt(A*A + B*B - 2*A*B*cos((deg*PI)/180))
  println(x)
}



Measured memory_bytes: 36672
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b>a||b>d){
        puts("No");
        return;
    }
    if(c>=b){
        puts("Yes");
        return;
    }
    int g=gcd(b,d);
    int h=b-g+(a%g);
    if(h<=c)puts("Yes");
    else puts("No");
}
signed main(){
    int tekitou;
    cin>>tekitou;
    while(tekitou--){
        solve();
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    int t = 1;
    for(int i=0; i<n; i++){
        if(a[i]%2 == 0){
            if((a[i]%3 != 0) && (a[i]%5 != 0)) {
                t = 0;
                break;
            }
        }
    }
    if(t == 1) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main(){
  string str; cin >> str;
  if(str.at(5)=='0' && str.at(6)=='1')  cout << "Heisei" << endl;
  else if(str.at(5)=='0' && str.at(6)=='2')  cout << "Heisei" << endl;
  else if(str.at(5)=='0' && str.at(6)=='3')  cout << "Heisei" << endl;
  else if(str.at(5)=='0' && str.at(6)=='4')  cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        var S = Console.ReadLine();
        if(S[0] == 'A' &&
        S.Substring(2,S.Length - 3)
            .Contains('C') &&
        S.Count(c => c == 'C') == 1){
            for(var i = 0;i < S.Length;i++){
                if(i == 0 || S[i] == 'C'){
                    continue;
                }else{
                    if(char.IsUpper(S[i])){
                        Console.WriteLine("WA");
                        return;
                    }
                }
            }
            Console.WriteLine("AC");
        }else{
            Console.WriteLine("WA");
        }
    }
}


Measured memory_bytes: 13268
N = int(input())
x_list = [int(x) for x in input().split(' ')]

p = 1
v_list = [0 for _ in range(N)]


def calc(p, x):
    return (x - p) ** 2

ans = 0
for _ in range(100):
    new_v_list = [calc(p, x) for x in x_list]
    s = sum(v_list)
    new_s = sum(new_v_list)
    
    if p==1:
        pass        
    elif s < new_s:
        ans = s
        break
        
    ans = new_s
    p+=1
    v_list = new_v_list

print(ans)

Measured memory_bytes: 3064
k = int(input())
data = [str(i) for i in range(1,10)]
ans = [i for i in range(1,10)]
for i in range(9):
    data2 = []
    for x in data:
        j = int(x[-1])
        if j-1>=0:
            y = x+str(j-1)
            data2.append(y)
            ans.append(int(y))
        y = x+str(j)
        data2.append(y)
        ans.append(int(y))
        if j+1<10:
            y = x + str(j+1)
            data2.append(y)
            ans.append(int(y))
    data = data2

print(ans[k-1])

Measured memory_bytes: 69080
nmk = input().split()
n = int(nmk[0])
m = int(nmk[1])
k = int(nmk[2])

message = "No"
for i in range(m):
    x = int(i)
    if m-2*x == 0:
        y=-1
    else:
        y = (-n*x+k)/(m-2*x)
#         print(y)
    if y >= 0 and y <= n and y%1 == 0:
        message="Yes"
        break

print(message)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define vl vector<ll>
#define pll pair<ll, ll>
#define F first
#define S second

template <typename T>
vector<T> BinarySearch(vector<T> &vec, T key) {
    if (vec.size() == 1) return vec;
    // key: 検索対象の値
    T left = 0, right = (T)vec.size()-1, mid, idx_res;
    while (left < right) {
        mid = (left + right)/2;
        if (right - left == 1) {
            vector<T> res = {vec[left], vec[right]};
            return res;
        } else if (key < vec[mid]) {
            // 半分より下
            right = mid;
        } else if (vec[mid] < key) {
            // 半分より上
            left = mid;
        }
    }
    return {-1, -1};
}

int main() {
    // input
    ll A, B, Q;
    cin >> A >> B >> Q;
    vl Jin(A), Tera(B), Query(Q);
    REP(i, A) cin >> Jin[i];
    REP(i, B) cin >> Tera[i];
    REP(i, Q) cin >> Query[i];
    
    // calculation
    vector<ll> res_A, res_B;
    ll query, jin, ter, res;
    REP(i, Q) {
        query = Query[i];
        res_A = BinarySearch(Jin, query);  // size: 1 or 2
        res_B = BinarySearch(Tera, query);  // size: 1 or 2
        res = LLONG_MAX;
        REP(j, res_A.size()) {
            REP(k, res_B.size()) {
                jin = res_A[j];
                ter = res_B[k];
                if (query < jin && query < ter) {
                    // query が小さい
                    res = min(res, max(jin, ter) - query);
                } else if (query > jin && query > ter){
                    // query が大きい
                    res = min(res, query - min(jin, ter));
                } else {
                    // 間にあるとき
                    res = min(res, min(abs(query - jin), abs(query - ter)) + abs(jin - ter));
                }
            }
        }
        cout << res << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

int main() {
  int a, b, c, d, f;
  double e;
  cin >> a >> b >> c >> d >> e >> f;
  e /= 100;
  int m = 1501;
  vi suga(m, 0);
  suga[0] = 1;
  rep (i, m) {
    if (suga[i] == 0) {
      continue;
    }
    if (i + c < m) {
      suga[i + c] = 1;
    }
    if (i + d < m) {
      suga[i + d] = 1;
    }
  }
  vi sugar;
  rep (i, m) {
    if (suga[i] == 1) {
      sugar.push_back(i);
    }
  }

  vi wate(f+1, 0);
  wate[0] = 1;
  rep (i, f+1) {
    if (wate[i] == 0) {
      continue;
    }
    if (i + 100*a < f+1) {
      wate[i + 100*a] = 1;
    }
    if (i + 100*b < f+1) {
      wate[i + 100*b] = 1;
    }
  }
  wate[0] = 0;
  vi water;
  rep (i, f+1) {
    if (wate[i] == 1) {
      water.push_back(i);
    }
  }

  double ma = -1;
  int ans1, ans2;
  for (int w : water) {
    int s = f - w;
    s = min(s, (int)(e * w));
    s = *(upper_bound(all(sugar), s) - 1);
    double no = (double)s / (s + w);
    if (ma < no) {
      ma = no;
      ans1 = s + w;
      ans2 = s;
    }
  }

  printf("%d %d\n", ans1, ans2);

  return 0;
}


Measured memory_bytes: 888
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

bool Search(string &s,vector<vector<int>>&dp, int l, int r) {
	if (dp[l][r] == 1)return true;
	if (dp[l][r] == -1)return false;
	if ((r - l + 1) % 3) {
		dp[l][r] = -1;
		return false;
	}
	if (r < l) {
		dp[l][r] = 1;
		return true;
	}
	if (r - l + 1 == 3) {
		if (s[l] == 'm'&&s[l + 1] == 'e'&&s[r] == 'w') {
			dp[l][r] = 1;
			return true;
		}
		dp[l][r] = -1;
		return false;
	}
	if (s[l] != 'm' || s[r] != 'w') {
		dp[l][r] = -1;
		return false;
	}
	bool ret = false;
	for (int i = l + 1; i < r; i++) {
		if (s[i] == 'e') {
			bool bag = true;
			bag &= Search(s,dp, l + 1, i - 1);
			bag &= Search(s,dp, i + 1, r - 1);
			ret |= bag;
		}
	}
	if (ret)dp[l][r] = 1;
	else dp[l][r] = -1;
	return ret;
}

long long int N, M, K, H, W, L, R, V, E;

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

	string s;
	cin >> s;
	vector<vector<int>>dp(s.size(), vector<int>(s.size()));
	if (Search(s, dp, 0, s.size() - 1))cout << "Cat\n";
	else cout << "Rabbit\n";
	return 0;
}



Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, b;
    cin >> a >> b;
    cout << (0 < a && a < 10 && 0 < b && b < 10 ? a * b : -1);

}





Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws IOException{
    	Scanner sc = new Scanner(System.in);

    	int x = sc.nextInt();
    	int y = sc.nextInt();

    	if(y>x) {
    		int tmp = x;
    		x = y;
    		y = tmp;
    	}

    	int a = 0;

    	if(x != y) {
	    	int z = x%y;

	    	a = z;

	    	while(true) {
	    		if(y%a==0 && z%a==0) {
	    			break;
	    		}
	    		a--;
	    	}
    	}else {
    		a = x;
    	}

    	System.out.println(a);

    	sc.close();
    }
}


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

typedef long long ll;
typedef pair<ll, ll> P;

class dis{
    public:
        int x, y;

    int getDis(){ return abs(x) + abs(y); }
};

const int MAX = 1010;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N;
vector<dis> D;

int main(){
    cin >> N;
    rep(i, N){
        int x, y;
        cin >> x >> y;
        dis d;
        d.x = x;
        d.y = y;
        D.push_back(d);
    }

    int maxi = 0;
    rep(i, N - 1){
        int a = D[i].getDis();
        int b = D[i + 1].getDis();
        if(a % 2 != b % 2){
            cout << -1 << endl;
            return 0;
        }
        maxi = max(maxi, a);
    }
    maxi = max(maxi, D[N - 1].getDis());
    
    vector<ll> m;
    ll sum = 0;
    if(maxi % 2 == 0){
        m.push_back(1);
        sum++;
    }
    for(ll i = 1; sum < maxi; i*=2){
        m.push_back(i);
        sum += i;
    }

    sort(m.begin(), m.end(), greater<ll>());
    cout << m.size() << endl;
    for(auto i : m) cout << i << " ";
    cout << endl;
    rep(i, N){
        dis d = D[i];
        string s;
        ll res = sum;
        rep(j, m.size()){
            res -= m[j];
            ll nx, ny;

            nx = d.x + m[j];
            ny = d.y;
            if(abs(nx) + abs(ny) <= res){
                s.push_back('L');
                d.x = nx;
                d.y = ny;
                continue;
            }

            nx = d.x - m[j];
            if(abs(nx) + abs(ny) <= res){
                s.push_back('R');
                d.x = nx;
                d.y = ny;
                continue;
            }

            nx = d.x;
            ny = d.y + m[j];
            if(abs(nx) + abs(ny) <= res){
                s.push_back('D');
                d.x = nx;
                d.y = ny;
                continue;
            }

            ny = d.y - m[j];
            if(abs(nx) + abs(ny) <= res){
                s.push_back('U');
                d.x = nx;
                d.y = ny;
                continue;
            }
        }
        cout << s << endl;
    }
}


Measured memory_bytes: 256
from collections import Counter

h,w,n=map(int,input().split())
cc=Counter()
for _ in range(n):
    b,a=map(int,input().split())
    for i in range(3):
        for j in range(3):
            x=a+i
            y=b-j #brute forcing valid bottom right corners
            if x>=1 and x<=w and y>=1 and y<=h:
                if x-2>=1 and x-2<=w and y+2>=1 and y+2<=h:
                    cc[(x,y)]+=1
#                    print(x,y,end=' xy\n')#a valid 3*3 grid bottom right
ans=[0]*10
for i in cc.keys():
    ans[cc[(i)]]+=1
ans[0]=(h-2)*(w-2)-sum(ans)
print(*ans,sep='\n')


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

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> s(m,vector<int>());
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int a;
            cin>>a;   
            a--;
            s[i].push_back(a);
        }
    }
    vector<int> p(m);
    for(int i=0;i<m;i++) cin>>p[i];

    int ans=0;
    for(int i=0;i<(1<<n);i++){
        bool flag=true;
        for(int j=0;j<m;j++){
            int cnt=0;
            for(int k : s[j]){
                if(i&(1<<k)) cnt++;
            }
            if(cnt%2!=p[j]) flag=false;
        }
        if(flag) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif


namespace Solver{
using namespace std;

struct Problem{
    LL x,y;
    void solve(){
        cin >> x >> y;
        if(x%y==0){
            cout << -1 <<"\n";
        }else{
            LL i = 1;
            while(1){
                if((x*i)%y!=0){
                    cout << x*i <<"\n";
                    break;
                }
            }
        }
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    Solver::Problem p;
    p.solve();
    return 0;
}



Measured memory_bytes: 256
import itertools

n = int(input())


def add(dict, str):
    if not str[0] in dict:
        dict[str[0]] = []
    dict[str[0]].append(str)


march = {}
for _ in range(n):
    s_i = input()
    if 'M' == s_i[0] or 'A' == s_i[0] or 'R' == s_i[0] or 'C' == s_i[0] or 'H' == s_i[0]:
        add(march, s_i)

key_combination = list(itertools.combinations(list(march), 3))
count = 0
for case in key_combination:
    indiv_count = 1
    for key in case:
        if not key in march:
            indiv_count = 0
            break
        indiv_count *= len(march[key])
    count += indiv_count
print(count)


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int H, W, h, w, a, b, c,d;
	cin >> H >> W >> h >> w;
	a = H * W;
	b = H * w;
	c = h * W;
	d = h * w;
	cout << a - b - c + d;
    return 0;
}


Measured memory_bytes: 256
from itertools import combinations

n = int(input())
s = [input() for _ in range(n)]
march = list('MARCH')
d = {x:0 for x in march}
for x in s:
    if x[0] in march:
        d[x[0]] += 1
l = [v for v in d.values() if v > 0]

ans = 0
if len(l) >= 3:
    for gp in combinations(l, 3):
        buf = 1
        for x in gp:
            buf *= x
        ans += buf
print(ans)

Measured memory_bytes: 9772
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    string s;
    cin >> s;

    ll total=0;
    REP(i,s.size()){
        total += s[i]-'0';
    }
    //cout << total << endl;
    if(total%9 == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3732
# coding: utf-8
import math

a, b, C = [int(x) for x in input().split()]

c = math.radians(C)

# 面積
S = a * b * math.sin(c) / 2
print(S)

# 余弦定理
l = (a ** 2 + b ** 2 - 2 * a * b * math.cos(c)) ** (1 / 2)
print(a + b + l)

# 高さ
print(S / a * 2)



Measured memory_bytes: 5732
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
	string n;
	cin >> n;
	bool flag=true;
	for(int i=0;i<3;i++)
		if(n[i]==n[i+1])flag=false;
	cout << (flag ? "Good" : "Bad") << endl;
	
	




}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const int N = 3001;
const int MAXN = N + 5;

int n,M,ans;
int c[MAXN][MAXN],s[MAXN][MAXN];

namespace ModOperation{
	int mul(int x,int y){
		return 1ll * x * y % M;
	}
	
	int add(int x,int y){
		x += y;
		if(x >= M)
			x -= M;
		return x;
	}
	
	int sub(int x,int y){
		x -= y;
		if(x < 0)
			x += M;
		return x;
	}
}

using namespace ModOperation;

int power(int x,int y,int MOD = M){
	int res = 1;
	while(y){
		if(y & 1)
			res = 1ll * res * x % MOD;
		x = 1ll * x * x % MOD;
		y >>= 1;
	}
	return res;
}

void Init(){
	c[0][0] = s[0][0] = 1;
	for(int i = 1;i <= N;i++){
		c[i][0] = 1;
		for(int j = 1;j <= i;j++){
			c[i][j] = add(c[i - 1][j],c[i - 1][j - 1]);
			s[i][j] = add(s[i - 1][j - 1],mul(j,s[i - 1][j]));
		}
	}
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&M);
	Init();
	for(int i = 0;i <= n;i++){
		int pow2 = power(2,n - i);
		int res1 = mul(c[n][i],power(2,power(2,n - i,M - 1)));
		int tmp = 1,res2 = 0;
		for(int j = 0;j <= i;j++){
			res2 = add(res2,mul(s[i + 1][j + 1],tmp));
			tmp = mul(tmp,pow2);
		}
		if(i & 1)
			ans = sub(ans,mul(res1,res2));
		else
			ans = add(ans,mul(res1,res2));
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 58984
from collections import deque
from itertools import permutations

N,M = map(int, input().split())
l = [list(map(int,input().split())) for _ in range(M)]

graph = [[False]*(N+1) for _ in range(N+1)]
for i in l:
    graph[i[0]][i[1]] = True
    graph[i[1]][i[0]] = True

cnt = 0

for i in permutations(range(1,N+1)):
    if i[0] != 1:
        continue
    isJoin = True
    for j in range(1,N):
        if not graph[i[j-1]][i[j]]:
            isJoin = False
            break
    if isJoin:
        cnt += 1
print(cnt)
            


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

long long n, a, b, c, d;
map<long long, long long> dp;

long long rek(long long x) {
  if (x == 0) return 0;
  if (dp.find(x) != dp.end()) return dp[x];
  dp[x] = LLONG_MAX;
  if (x < LLONG_MAX/d) dp[x] = x*d;
  return dp[x] = min({dp[x], d*(x-x/2*2)+a+rek(x/2), d*(x-x/3*3)+b+rek(x/3), d*(x-x/5*5)+c+rek(x/5),
		      d*((x+1)/2*2-x)+a+rek((x+1)/2), d*((x+2)/3*3-x)+b+rek((x+2)/3), d*((x+4)/5*5-x)+c+rek((x+4)/5)});
}

void solve() {
  dp.clear();
  scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
  printf("%lld\n", rek(n));
}

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


Measured memory_bytes: 4492
#include <bits/stdc++.h>
using namespace std; 
int main() {
  
  int h, w;
  cin >> h >> w;
  
  for(int i=0; i<w+2; i++){
    cout << '#';
  }
  cout << endl;
  
  for(int i=0; i<h; i++){
    string s;
    cin >> s;
    cout << '#' << s << '#' << endl;
  }
  
  for(int i=0; i<w+2; i++){
    cout << '#';
  }
  cout << endl;
  
}

Measured memory_bytes: 256
s = list(input())

dict = {}

for c in s:
    if(c in dict.keys()):
        dict[c] += 1
    else:
        dict[c] = 1

# print(dict)

result = 'Yes'

if(len(dict) != 2):
    result = 'No'

for v in dict.values():
    if(v != 2):
        result = 'No'

print(result)

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

bool isPal(string s)
{
	int i=0;
	int j=s.length()-1;

	while(i<j)
	{
		if(s[i]!=s[j])
			return false;
		i++;
		j--;
	}
	return true;
}

int main()
{
	string s;
	cin>>s;
	//cout<<s.substr(0,s.length()/2)<<endl;

	//cout<<s.substr(s.length()/2+1,s.length())<<endl;
	if(isPal(s)&&isPal(s.substr(0,s.length()/2))&&isPal(s.substr(s.length()/2+1,s.length())))
			cout<<"Yes";
		else
			cout<<"No";

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;
const int MAX_V=10001;
int n,m;
vector<int> G[MAX_V];
bool used[MAX_V];
int mark[MAX_V];
int res;

void dfs(int s,int cnt){
  if(cnt>=res)return;
  if(s==n){
    bool ok=true;
    // 全てがmarkされているか
    for(int i=0;i<n;i++){
      if(!mark[i]){
	ok=false;
	break;
      }
    }
    if(ok)res=min(res,cnt);
  }
  else{
    dfs(s+1,cnt);
    // markする
    mark[s]++;
    for(int j=0;j<G[s].size();j++){
      int to=G[s][j];
      mark[to]++;
    }
    dfs(s+1,cnt+1);
    mark[s]--;
    for(int j=0;j<G[s].size();j++){
      int to=G[s][j];
      mark[to]--;
    }
  }
}

int main(){
  while(cin>>n>>m&&(n|m)){
    for(int i=0;i<n;i++)G[i].clear();
    for(int i=0;i<m;i++){
      int a,b;
      cin>>a>>b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    res=1000000000;
    memset(used,0,sizeof(used));
    memset(mark,0,sizeof(mark));
    dfs(0,0);
    cout<<res<<endl;
  }

  return 0;
}

Measured memory_bytes: 1068
def d(caps):
    start = count = 0
    num = 1
    for i in range(len(caps)):
        if caps[i] != num:
            count += 1
        else:
            num += 1
    
    if num == 1:
        print(-1)
    else:
        print(count)

input()
s = [int(i) for i in input().rstrip().split(' ')]

d(s)


Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
/*
int A,B,C,D,E,F;
int sugarMax,TotalMax;
double density=0;
void recur(int tillnowSugar, int tillnowTotal){

    double    tillnowDensity = (tillnowSugar*100.0)/(double)tillnowTotal;

    if(tillnowSugar>F || tillnowTotal>F || tillnowDensity>(double)E) return;

    if(density<=tillnowDensity)
    {
    sugarMax=max(tillnowSugar,sugarMax);
    TotalMax=max(tillnowTotal,TotalMax);
    }
  cout<<TotalMax<<" "<<sugarMax<<" "<<tillnowDensity<<" "<<density<<endl;

  recur(tillnowSugar+C, tillnowTotal+100*A);
  recur(tillnowSugar+D, tillnowTotal+100*B);
  recur(tillnowSugar+C, tillnowTotal+100*B);
  recur(tillnowSugar+D, tillnowTotal+100*A);

return ;
}

int main(){

freopen("in.txt","r",stdin);
cin>>A>>B>>C>>D>>E>>F;

  recur(C,100*A+C);
  recur(D,100*B+D);
  recur(C,100*B+C);
  recur(D,100*A+D);

cout<<TotalMax<<" "<<sugarMax<<endl;
return 0;

}
*/
int ar[100001];
int main(){
//freopen("in.txt","r",stdin);
int N,temp;
cin>>N;
int cnt=0;
for(int i=0;i<N;i++){

    cin>>temp;
    if(temp>100000) cnt++;
    else ar[temp]++;
}
for(int i=1;i<100001;i++){
if(ar[i]>=i)
cnt+=(ar[i]-i);
else cnt+=ar[i];
}
cout<<cnt<<endl;
}

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

int main() {
    string str;
    getline(cin, str);

    for (int i=0; i<str.length(); i++) {
      char c = str[i];
      if (c>='A' && c<='Z') {
          char newC = c-'A'+'a';
          cout << newC;
      } else if (c>='a' && c<='z') {
          char newC = c-'a'+'A';
           cout << newC;
      } else {
          cout << c;
      }
    }
    cout << endl;
    return 0;
}


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

using namespace std;

int main() {
    int n;
  	cin >> n;
    
  	int ans = 0;
  	if (n < 10) {
      ans = (n % 10);
    } else if (n < 1000) {
      ans += max(n - 99, 0) + 9;
    } else if (n < 100000) {
      ans += max(n - 9999, 0) + 909;
    } else {
      ans = 90909;
    }
  	
  	cout << ans << endl;
  
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int n = sc1.nextInt();
		int[] v = new int[n];
		int[] c = new int[n];

		int ans = 0;

		for ( int i = 0 ; i < n ; i++ ) {
			v[i] = sc1.nextInt();
		}

		for ( int i = 0 ; i < n ; i++ ) {
			c[i] = sc1.nextInt();
			if ((v[i] - c[i]) > 0) {
				ans += v[i] - c[i];
			}
		}

		System.out.println(ans);

		sc1.close();

	}

}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long

#define INF 1e+9
#define MAX_V 100008


int main(){
    long long a, b, x;
    cin >> a >> b >> x;

    long long numA = a / x;
    long long numB = b / x;

    
    cout << numB - numA + (a % x == 0) << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue> 
using namespace std;

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if (n%k==0) printf("0\n");
        else printf("1\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7;
int n,q,l,r,ans1,ans2;
string s;
char t[N],d[N];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>q;cin>>s;for(int i=1;i<=q;i++)cin>>t[i]>>d[i];
	l=0;r=n-1;ans1=-1;
	while(l<=r){
		int mid=(l+r)>>1,no=mid;
		for(int i=1;i<=q;i++){
			if(no<0)break;if(no==n)break;
			if(t[i]==s[no]){
				if(d[i]=='L')no--;
				else no++;
			}
		}
		if(no<0){ans1=mid;l=mid+1;}
		else r=mid-1;
	}
	l=0;r=n-1;ans2=n;
	while(l<=r){
		int mid=(l+r)>>1,no=mid;
		for(int i=1;i<=q;i++){
			if(no<0)break;if(no==n)break;
			if(t[i]==s[no]){
				if(d[i]=='L')no--;
				else no++;
			}
		}
		if(no==n){ans2=mid;r=mid-1;}
		else l=mid+1;
	}
	if(ans2<ans1)cout<<0<<endl;
	else cout<<ans2-ans1-1<<endl;
	return 0;
}

Measured memory_bytes: 976
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	char a; cin >> a;

	cout << ((a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') ? "vowel" : "consonant") << endl;

	return 0;
}

Measured memory_bytes: 256
let main k a b =
  let rec loop i =
    if a <= i * k && i * k <= b then
      print_string "OK"
    else if b < i * k then
      print_string "NG"
    else
      loop (i + 1)
  in
  loop 1;;

Scanf.sscanf (read_line ()) "%d" (fun k ->
    Scanf.sscanf (read_line ()) "%d %d" (fun a b ->
	main k a b
));;

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
	int n;
	cin >> n;
	
	int min = 1e9;
	rep(a, 1, n){
		int sum = 0;
		string sa = to_string(a), sb = to_string(n - a);
		for (char c : sa) sum += (int)(c - '0');
		for (char c : sb) sum += (int)(c - '0');
		if (sum < min) min = sum;
	}
	cout << min << endl;
}


Measured memory_bytes: 256
INF = 10 ** 20
 
N = int(input())
coin_list = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)]
dp = [INF]*(N+1)
dp[0] = 0
 
for i in range(1,N+1):
	for coin in coin_list:
	    if i-coin >= 0: dp[i] = min(dp[i], dp[i-coin]+1)
 
print(dp[N])

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

int main()
{
        long double a,b,c;
        cin >> a>> b>>c;
        long double ans = a + b;
        ans += 2*sqrt(a) * sqrt(b);
        if(ans < c)
        {
                cout << "Yes" << endl;
        }
        else if(ans >= c){
                cout << "No" << endl;
        }
}


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

int main(){
	string s,t;
	cin >> s >> t;

	bool flag = true;
	rep(i, s.size()){
		if(s.at(i) != t.at(i)){
			flag = false;
			break;
		}
	}

	if(flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
#include <cstdlib>
#include <math.h>

typedef long long ll;
using namespace std;

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

	vector<int> weight(N+1);
	vector<int> value(N+1);

	for( int i = 1; i <= N; i++){
		cin >> weight.at(i) >> value.at(i) ;
	}

	vector<vector<ll>> dp(N+1, vector<ll>(W+1,0));

	for( int i = 1; i <= N; i++){
		for( int w = 1; w <= W; w++){
			if( weight.at(i) <= w){
				dp[i][w] = max(dp[i][w],dp[i-1][w-weight[i]]+value[i]);
				dp[i][w] = max(dp[i][w],dp[i-1][w]);
			}else {
				dp[i][w] = dp[i-1][w] ;
			}
		}
	}
	cout << dp[N][W] << endl;

	return 0;
}

Measured memory_bytes: 80256
n=int(input())
c=[]
for i in range (0,10):
  c.append([0]*10)    
for k in range (1,n+1):
  x=str(k)
  a=int(x[0])
  b=int(x[-1])
  c[a][b]+=1
s=0
for i in range(1,10):
  for j in range(1,10):
    s+=c[i][j]*c[j][i]
print(s)    

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

namespace AtCoder.Contest.A
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();
			int a = cin.nextInt();
			int b = cin.nextInt();

			if (a % 2 == 0 || b % 2 == 0) Console.WriteLine("Even");
			else Console.WriteLine("Odd");
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=998244353;
int power(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}

char a[100111],b[100111],c[100111],d[100111];
int n,m,fac[300111],invf[300111];
int getv(int u,int v,int w)
{
	if(u==0)return (v==0&&w==0);
	return 1ll*fac[u+v+w-1]*invf[u-1]%mod*invf[v+w]%mod;
}

int pre[100111];
int calc(char*a,char*b,int tc,int td,int n)
{
	pre[0]=1;
	
	int s1=0,s2=0;
	for(int i=1;i<n;i++)
	{
		pre[i]=pre[i-1];
		s1+=a[i]-'0';s2+=b[i]-'0';
		if(a[i]=='1'&&b[i]=='1')
		{
			pre[i]+=pre[i];
			if(pre[i]>=mod)pre[i]-=mod;
		}
		if(a[i]=='1'||b[i]=='1')
		{
			pre[i]+=getv(tc,s1,s2);
			if(pre[i]>=mod)pre[i]-=mod;
		}
	}
	s1=s2=0;
	int ret=0;
	for(int i=n;i>=1;i--)
	{
		int cur=0;
		if(a[i]=='1'||b[i]=='1')
			cur+=getv(td,s1,s2);
		if(a[i]=='1'&&b[i]=='1')
		{
			cur+=cur;
			if(cur>=mod)cur-=mod;
		}
		s1+=a[i]-'0';s2+=b[i]-'0';
		ret=(ret+1ll*cur*pre[i-1])%mod;
	}
	return ret;
}
int main()
{
	fac[0]=1;for(int i=1;i<300111;i++)fac[i]=1ll*fac[i-1]*i%mod;
	invf[300110]=power(fac[300110],mod-2);for(int i=300111-2;i>=0;i--)invf[i]=1ll*invf[i+1]*(i+1)%mod;
	
	get2(n,m);scanf("%s%s%s%s",a+1,b+1,c+1,d+1);
	int ta=0,tb=0,tc=0,td=0;
	for(int i=1;i<=n;i++)ta+=a[i]-'0',tb+=b[i]-'0';
	for(int i=1;i<=m;i++)tc+=c[i]-'0',td+=d[i]-'0';
	if(ta+tb+tc+td==0)
	{
		puts("1");
		return 0;
	}
	int ans=calc(a,b,tc,td,n)+calc(c,d,ta,tb,m);
	if(ans>=mod)ans-=mod;
	printendl(ans);
	return 0;
}

Measured memory_bytes: 3328