akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main()
{
    int n,d,i;
    scanf("%d\n",&n);
    char s[n];
    gets(s);
    d=n/2;
    if(n%2!=0){
        printf("No\n");
    }
    else{
        for(i=0;i<d;i++){
            if(s[i]==s[i+d]){
                continue;
            }
            else{
                break;
            }
        }
        if(i==d){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
my ($H,$W,$K) =split(/ /,<>);
#print "$H,$W,$K \n";
chomp $K;
my @DB;

for(my $i=0;$i<$H;$i++){
    my $s = <>;chomp $s;
    my @dat = split(//,$s);
    push (@DB,\@dat);
}

my @SS;
my $ans =0;
my $str="";
&roop($str);
for(my $i=0;$i<=$#SS;$i++){
    #print "$SS[$i]\n";
    my @dat = split(//,$SS[$i]);
    my $count = 0;
  for(my $k=0;$k<=$#DB;$k++){
    if( @dat[$k]==1 ){next;}
    
    for(my $j=0;$j<=$#{$DB[$k]};$j++){
      if( @dat[$H+$j]==1 ){next;}
      if( $DB[$k][$j] eq "#" ){$count++;}
      #print "$DB[$i][$j]";
    }
  }
  #print "$count $K\n";
  if($count == $K){$ans++;}
}
print "$ans";

exit;

sub roop{
  my ($str) = @_; 
  if(length($str) >= ($H+$W)){
       push (@SS,$str);
       return 0;
  }
  my $str1 = "${str}0";
  &roop($str1);
  my $str2 = "${str}1";
  &roop($str2);
}


Measured memory_bytes: 5132
#include <stdio.h>
#include <utility>

using namespace std;

#define ARRAY_SIZE_MAX 100

int main()
{
	int arraySize = 0;

	scanf("%d", &arraySize);

	int A[ARRAY_SIZE_MAX] = { 0 };
	for (int i = 0; i < arraySize; i++) {
		scanf("%d", &A[i]);
	}

	bool isSort = true;
	int sortedIndex = 0;
	int swapCount = 0;
	while (isSort) {
		isSort = false;
		for (int i = arraySize - 1; i > sortedIndex; i--) {
			if (A[i - 1] > A[i]) {
				swap(A[i - 1], A[i]);
				isSort = true;
				swapCount++;
			}
		}

		sortedIndex++;
	}

	// 結果出力
	// ソート済み配列
	for (int i = 0; i < arraySize; i++) {
		if (i != arraySize - 1) {
			printf("%d ", A[i]);
		}
		else {
			printf("%d\n", A[i]);
		}
	}

	// 交換回数
	printf("%d\n", swapCount);


	return 0;
}


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

int main()
{
    int n, x;
    while (true)
    {
        int cnt = 0;
        cin >> n >> x;
        if (n == 0 && x == 0)
        {
            break;
        }

        for (int i = 1; i <= n - 2; i++)
        {
            for (int j = i + 1; j <= n - 1; j++)
            {
                for (int k = j + 1; k <= n; k++)
                {
                    if (i + j + k == x)
                    {
                        cnt++;
                    }
                }
            }
        }

        cout << cnt << endl;
    }
}



Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, M; cin >> N >> M;
  vector<int> que(N);
  rep(i, M){
    int a, b; cin >> a >> b;
    a--, b--;
    que[a]++, que[b]++;
  }
  bool flag = true;
  rep(i, N){
    if (que[i] % 2 != 0) flag = false;
  }
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll H,W,h,w; cin >> H >> W >> h >> w;
  cout << (H-h)*(W-w) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		int N = sc.nextInt();
        Long K = sc.nextLong();
        Long MOD = new Long("1000000007");
        ArrayList<Integer> tmpList = new ArrayList<Integer>();
        ArrayList<Integer> tmpList2 = new ArrayList<Integer>();
      	while(sc.hasNext()){
          tmpList.add(sc.nextInt());
        }
       for(int i = 0; i < 2; i++){
         for(int j = 0; j < tmpList.size(); j++){
           tmpList2.add(tmpList.get(j));
         }
       }
      Long A = getPatten(tmpList);
      Long B = (getPatten(tmpList2) - (2 * A));
      //System.out.println(A);
      //System.out.println(getPatten(tmpList2) + "↓");
      //System.out.println(B);
     	 System.out.println((((K * (K - 1) / 2) % MOD) * B + A * K) % MOD);
      
	}
  
  public static Long getPatten(ArrayList<Integer> list){
    long ret = 0;
    for(int i = 0; i < list.size(); i++){
      for(int j = i; j < list.size(); j++){
        if(list.get(i) > list.get(j)){
          ret++;
        }
      }
    }
    return ret;
  }
}


Measured memory_bytes: 26240
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {a: usize, b: usize, c: usize, k: usize};

    let mut b = b;
    let mut c = c;
    let mut count = 0;

    while a >= b {
        b *= 2;
        count += 1;
    }

    while b >= c {
        c *= 2;
        count += 1;
    }

    if k >= count {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  deque<ll> V;
  for (int i = 0; i < N; i++)
  {
    ll v;
    cin >> v;
    V.push_back(v);
  }
  ll ans = -INF;
  for (int A = 0; A <= min(N, K); A++)
  {
    for (int B = 0; B <= min(N, K) - A; B++)
    {
      cerr << "A: " << A << "   B: " << B << endl;
      deque<ll> Vcopy = V;
      vector<ll> tmp;
      for (int i = 1; i <= A; i++)
      {
        tmp.push_back(Vcopy.front());
        Vcopy.pop_front();
      }
      for (int i = 1; i <= B; i++)
      {
        tmp.push_back(Vcopy.back());
        Vcopy.pop_back();
      }
      sort(tmp.begin(), tmp.end());
      int tmpSize = tmp.size();
      for (int i = 0; i < min(tmpSize, K - (A + B)); i++)
      {
        if (tmp[i] < 0)
          tmp[i] = 0;
      }
      ans = max(ans, accumulate(tmp.begin(), tmp.end(), 0LL));
    }
  }
  cout << ans << endl;
  return 0;
}

// 捨てる行為は最後に行ってもよい．操作AをA回，操作BをB回行うとするとA + B <= min(N, K)である．このとき左からA個，右からB個の宝石を手に入れ捨てる操作はK - (A + B)回行うことが出来る．価値が負のものをK - (A + B)個まで捨てる．


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

int main(){
    ll N;
    cin >> N;
    ll ans = 1e18;
    for(ll i = 1; i*i <= N; i++){
        if(N%i == 0) ans = min(ans, (i-1)+(N/i - 1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	l := make([]int, n)
	for i := range l {
		fmt.Scan(&l[i])
	}
	point := 0
	count := 1
	for i := range l {
		point = point + l[i]
		if point > x {
			fmt.Println(count)
			return
		}
		count++
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include<stdio.h>

int main() {
	int a, b;

	scanf("%d %d", &a, &b);
	int x = a - b;

	if (x == 0)
		puts("a == b");
	else if (x < 0)
		puts("a < b");
	else
		puts("a > b");

	return 0;
}

Measured memory_bytes: 1796
n=int(input())
x=[]
u=[]
for i in range(n):
    X,U=input().split()
    x.append(float(X))
    u.append(U)
    X=""
    U=""
#print(x)
#print(u)
sum=0
for i in range(n):
    if u[i]=="JPY":
        sum+=x[i]
    elif u[i]=="BTC":
        sum+=x[i]*380000.0
print(sum)

Measured memory_bytes: 3064
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<int, pi> node;
#define oset tree<pi, null_type,greater<pi>, rb_tree_tag,tree_order_statistics_node_update>

#define N 2003
lli dp[N][N], mod = 1e9+7;
int a[N], b[N];


int main()
{
    int n, m;
    cin >> n >> m;
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int j=1; j<=m; j++) cin >> b[j];

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(a[i] == b[j]){
                dp[i][j] = (1+dp[i-1][j]+dp[i][j-1])%mod;
            }
            else{
                dp[i][j] = (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+mod+mod+mod)%mod;
            }
        }
    }
    lli ans = (dp[n][m]+1) % mod;

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 34960
#include<stdio.h>
	int main(){
		int A1,A2,A3,hasil;
		scanf ("%d", &A1);
		getchar();
		scanf ("%d", &A2);
		getchar();
		scanf ("%d", &A3);
		getchar();
		
		if (A1+A2+A3 >= 22){
			hasil = A1+A2+A3;
			printf ("bust\n");
		}else {
			hasil = A1+A2+A3;
		    printf ("win\n");   
	    }
	}

Measured memory_bytes: 1664
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N, -1);
        int[] pos = new int[N];

        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            pos[A[i]] = i;
        }

        int pre = -1;
        int cnt = 0;

        for (int i = 0; i < N; i++)
        {
            if(pre < pos[i])
            {
                cnt++;
            }
            else
            {
                cnt = 1;
            }
            pre = pos[i];
            ans = Math.Max(cnt, ans);
        }


        ans = N - ans;
        Console.WriteLine(ans);
    }
}






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: 17292
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

template <int M> class ModInt {
    int x;

  public:
    constexpr ModInt() : x(0) {}
    constexpr ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
    constexpr ModInt &operator+=(const ModInt p) {
        if((x += p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt p) {
        if((x += M - p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt p) {
        x = (int)(1LL * x * p.x % M);
        return *this;
    }
    constexpr ModInt &operator/=(const ModInt p) {
        *this *= p.inverse();
        return *this;
    }
    constexpr ModInt operator-() const { return ModInt(-x); }
    constexpr ModInt operator+(const ModInt p) const {
        return ModInt(*this) += p;
    }
    constexpr ModInt operator-(const ModInt p) const {
        return ModInt(*this) -= p;
    }
    constexpr ModInt operator*(const ModInt p) const {
        return ModInt(*this) *= p;
    }
    constexpr ModInt operator/(const ModInt p) const {
        return ModInt(*this) /= p;
    }
    constexpr bool operator==(const ModInt p) const { return x == p.x; }
    constexpr bool operator!=(const ModInt p) const { return x != p.x; }
    constexpr ModInt inverse() const {
        int a = x, b = M, u = 1, v = 0, t = 0;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    constexpr ModInt pow(int64_t k) const {
        ModInt ret(1), mul(x);
        while(k > 0) {
            if(k & 1) ret *= mul;
            mul *= mul;
            k >>= 1;
        }
        return ret;
    }
    constexpr friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    constexpr friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t = 0;
        is >> t;
        a = ModInt(t);
        return (is);
    }
};
using mint = ModInt<mod>;

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

    int n;
    cin >> n;

    cout << mint(10).pow(n) - mint(9).pow(n) * 2 + mint(8).pow(n) << endl;

    return 0;
}

Measured memory_bytes: 3648
loop do
	w, h = gets.split.map &:to_i
	break if w == 0
	input = (1..h).map {gets.chomp}

	al = (0..h+1).map { [] }
	ar = (0..h+1).map { [] } 
	ly = lx = ry = rx = nil

	(0..h+1).each do |y|
		(0..w+1).each do |x|
			if [0, h+1].include?(y) || [0, w+1].include?(x)
				al[y][x] = ar[y][x] = ?#
			else
				al[y][x] = input[y-1][x-1]
				ar[y][x] = input[y-1][x-w-1]
				ly, lx = y, x if al[y][x] == ?L
				ry, rx = y, x if ar[y][x] == ?R
			end
		end
	end

	start = [ly, lx, ry, rx]
	stack = [start]
	reached = (0..h).map{(0..w).map{(0..h).map{(0..w).map{nil}}}}

	ok = false
	dirs = [[-1,0],[1,0],[0,-1],[0,1]]
	until stack.empty?
		ly0, lx0, ry0, rx0 = stack.pop
		dirs.each do |dy, dx|
			ly1, lx1, ry1, rx1 = ly0+dy, lx0+dx, ry0+dy, rx0-dx
			ly1, lx1 = ly0, lx0 if al[ly1][lx1] == ?#
			ry1, rx1 = ry0, rx0 if ar[ry1][rx1] == ?#

			gl = (al[ly1][lx1] == ?%)
			gr = (ar[ry1][rx1] == ?%)
			if gl && gr
				ok = true
				break
			end

			next if gl || gr

			a = reached[ly1][lx1][ry1]
			next if a[rx1]
			a[rx1] = 1
			
			stack << [ly1, lx1, ry1, rx1]
		end
		break if ok
	end
	puts ok ? 'Yes' : 'No'
end

Measured memory_bytes: 303784
#include <bits/stdc++.h>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

using namespace std;

int i;

string palin(string s){
    string res="Yes";
    int count=0;
    int len=(int)(s.length());
    REP(i,len){
        if(s[i]!=s[len-1-i]){
            res="No";
            break;
        }
    }
    REP(i,(len-1)/2){
        if(s[i]!=s[(len-3)/2-i]){
            res="No";
            break;
        }
    }
    for(i=(len+1)/2;i<len;i++){
        if(s[i]!=s[len-1-count]){
            res="No";
            break;
        }
        count++;
    }
    return res;
}

int main(){
    string s,ans;
    cin >>s;
    int i;
    ans=palin(s);

    
    cout<< ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    vector <long> f(n+1,0);
    for(long i = 1; i <= n; i++){
        for(long j = 1; (i*j)<=n; j++){
            f[i*j]++;
        }
    }
    long long ans = 0;
    for(long i = 1; i <= n; i++){
        ans+=f[i]*i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81400
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   debug::instance

using namespace std;

template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }
const int MAXN = 107;
int cnt[MAXN], n, d;
void succ() {
	cout << "Possible\n";
	exit(0);
}
void fail() {
	cout << "Impossible\n";
	exit(0);
}
void solve() {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		int a = fetch<int>();
		++cnt[a];
	}
	if(cnt[0] > 0) fail();
	d = NIL;
	for(int i = 0; i < n; ++i) if(cnt[i] > 0) d = i;
	if(d == NIL) fail();
	for(int pos = 0; pos <= d; ++pos) {
		int value = max(pos, d - pos);
		if(cnt[value] == 0) fail();
		--cnt[value];
	}
	for(int x = 0; x < n; ++x) if(cnt[x] > 0) {
		int y = x - 1;
		if(y < d - y) fail();
	}
	succ();
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
s = [input() for i in range(3)]
cnt = [0] * 3
player = 0
while True:
    if cnt[player] == len(s[player]):
        print("ABC"[player])
        break
    else:
        cnt[player] += 1
        player = ord(s[player][cnt[player]-1])-ord("a")
        

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int read(){
	int r=0,f=1;
	char c = getchar();
	while(!isdigit(c)){
		if(c == '-') f = -1;
		c = getchar();
 	}
 	while(isdigit(c)){
 		r = (r<<1)+(r<<3)+c - '0';
 		c = getchar();
	 }
	 return r*f;
}
int main(){
	int x =read(),y = read();
	for(int i=0;i<=x;i++){
		if(i*2 + (x-i)*4 == y){
		cout<<"Yes";
		return 0;
		}
	}
	cout<<"No";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define db(x){if(cond)cerr<<__LINE__<<" "<<#x<<" " <<x<<endl;}
#define rep(i,b)for(auto i=(0);i<(b);++i)
#define fo(i,a,b)for(auto i=(a);i<=(b);++i)
#define ford(i,a,b)for(auto i=(a);i>=(b);--i)
#define all(x) (x).begin(),(x).end()
#define vv vector
#define pb push_back
template<typename X>void MA(X&a,X b){a=max(a,b);}template<typename X>void MI(X&a,X b){a=min(a,b);}
template<typename X>void clr(X&x,int a){memset(x,a,sizeof(a));};typedef long long ll;typedef long double ld;
typedef array<int,2>i2;typedef vv<int>vi;int cond=0,multi=0,gcj=0;

struct solver_t;solver_t *solver;
struct solver_t{


  void solve(){
    int N;cin>>N;
    vi A(N);rep(i,N)cin>>A[i];

    cout<<set<int>(all(A)).size()<<"\n";
  }
  void gen(){}
  void brute(){}
};

int main(int argc,char** argv){
  fo(i,1,argc-1)for(int j=0;argv[i][j];j++)if(argv[i][j]=='.')freopen(argv[i],"r",stdin);
  fo(i,1,argc-1)if(argv[i]==string("q"))cond=1<<30;
  fo(i,1,argc-1)if(argv[i]==string("gen")){(solver=new solver_t())->gen();exit(0);}
  fo(i,1,argc-1)if(argv[i]==string("brute")){(solver=new solver_t())->brute();exit(0);}
  ios::sync_with_stdio(false),cin.tie(0);
  cout.setf(ios::fixed),cout.precision(10);int t;if(multi||gcj)cin>>t;else t=1;
  fo(i,1,t){if(cond)cerr<<__LINE__<<" "<<i<<endl;if(gcj)cout<<"Case #"<<i<<": ";
    solver = new solver_t();
    solver->solve();
  }return 0;
}
template class std::vector<int>;
template class std::vector<ll>;


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
    int n,a,b,c,d,i;


while(scanf("%d",&n) != -1){
    i=0;

    for(a=0;a <= 9;a++){
        for(b=0;b <= 9;b++){
            for(c=0;c <= 9;c++){
                for(d=0;d <= 9;d++){
                    if(a+b+c+d == n)
                        i++;
                }   
            }
        }
    }
    printf("%d\n",i);
}
    return 0;
}

Measured memory_bytes: 596
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    string s;
    cin >> s;

    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}



int e[10][10] = {0};
int v[10] = {0};
int n, m;
int cnt = 0;

int dfs(int node){
    for (int i = 1; i <= n; i++){
        if (e[node][i] == 1 && v[i] == 0){
            v[i] = 1;
            dfs(i);
            v[i] = 0;
        }
    }
    int flag = 1;
    for (int i = 2; i <= n; i++){
        if (v[i] == 0){
            flag = 0;
        }
    }
    if (flag == 1){
        cnt++;
    }
    return 0;
}

int main(void){
    int a, b;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++){
        scanf("%d %d", &a, &b);
        e[a][b] = 1;
        e[b][a] = 1;
    }
    v[1] = 1;
    dfs(1);
    

    printf("%d\n", cnt);




    return 0;
}


Measured memory_bytes: 128
#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"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;


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

	string s;
	cin >> s;
	if (s.find('7') == s.npos) cout << "No\n";
	else cout << "Yes\n";
}


Measured memory_bytes: 3652
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	ans = INF
	for i in range(1, 10 ** 6 + 1):
		if N % i == 0:
			ans = min(ans, i + int(N // i) - 2)
	print(ans)

if __name__ == '__main__':
	main()

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

typedef long long ll;

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

    int n, m, x;
    cin >> n >> m >> x;
    int c[n];
    int points[n][m];
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
            cin >> points[i][j];
    }

    int minCoins = INT_MAX;
    //go through all subsets
    for (int b = 0; b < (1 << n); b++)
    {
        vector<int> subset;
        int k[m] = {0};
        int coins = 0;

        for (int i = 0; i < n; i++)
        {
            if (b & (1 << i))
            {
                subset.push_back(c[i]);
                coins += c[i];
                for (int j = 0; j < m; j++)
                {
                    k[j] += points[i][j];
                }
            }
        }
        if (coins < minCoins)
        {
            bool go = true;
            for (int i = 0; i < m; i++)
                if (k[i] < x)
                    go = false;;
            if (go)
                minCoins = coins;
        }
    }
    if (minCoins == INT_MAX)
        cout << -1 << "\n";
    else
        cout << minCoins << "\n";
    return 0;
}

Measured memory_bytes: 3620
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

X, Y = map(int, input().split())
n = X
ans = 0
while n <= Y:
    ans += 1
    n *= 2
print(ans)


Measured memory_bytes: 8008
N = int(input())
li = list(map(int,input().split()))

count = 0
flag = False

while flag==False:
  for i in range(N):
    if li[i]%2==0:
      li[i]=li[i]/2
    else:
      flag=True
        
  if flag==False:
    count+=1

print(count)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);
	int n,k;
	cin >> n >> k;
	int x = ceil((double)n/2);
	if (x >= k) cout << "YES" << endl;
	else cout << "NO" << endl;
    return 0;
}


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

#define PI 4*atan(1);

int main(){
  int test[5], ave = 0;
  for(int i = 0; i < 5; i++){
    cin >> test[i];
    if(test[i] < 40){
      test[i] = 40;
    }
  }
  for(int i = 0; i < 5; i++){
    ave += test[i];
  }
  ave /= 5;
  cout << ave << endl;
}

Measured memory_bytes: 1160
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
using namespace std;
typedef long long i64;

#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

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

    if(N % 2 == 1) put((2*N));
    else put(N);

}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
#define MAX 100000

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert (int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x != NIL){
        y = x;
        if (z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL){
        root = z;
    }else{
        if (z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}


void inorder(Node *u){
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, x;
    string com;
    scanf("%d", &n);
    rep(i,n){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
}


Measured memory_bytes: 26704
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        int count = 0;
        for(int i=0;i<n;i++){//each idx

            char ac = a.charAt(i);
            char bc = b.charAt(i);
            char cc = c.charAt(i);

            if(ac==bc && ac==cc){
                //no count
            }else if(ac==bc || bc==cc || ac==cc){
                count++;
            }else{
                count++;
                count++;
            }

        }

        System.out.println(count);
    }

}

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

int main() {
    // get original ID and modified ID
    string ori, mod;
    cin >> ori >> mod;
    
    if ((mod.substr(0, ori.length()).compare(ori) == 0) && (islower(mod[mod.length() - 1]))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;


const int MOD = 1000000007;

vector <ll>  get_divisor(ll n)
{
  vector <ll> res;
  for(ll i = 2; i * i <= n; ++i)
  {
    while(n % i == 0)
    {
      res.push_back(i);
      n /= i; 
    }
  }
  if(n != 1)
  {
    res.push_back(n);
  }

  return res;
}

int main() {
    ll N,P;
    cin >> N >> P;

    if(N == 1)
    {
        cout << P << endl;
        return 0;
    }

    //Pを2で何回われるか試す
    //より大きかったら1を返す
    ll cnt = 0;
    ll p = 1;
    while(p < P)
    {
      p *= 2;
      ++cnt;
    }
    if(cnt < N)
    {
      cout << 1 << endl;
      return 0;
    }
    //公約数を数え上げて、N個に振り分ける 
    vector <ll> waruList;
    

    waruList = get_divisor(P);

    //for(auto v: waruList)
    //{
    //    cout << v << endl;
    //}
    int res = 1;

    for(int i = 0; i+N-1 < waruList.size(); ++i)
    {
        if(waruList[i] == waruList[i+N-1])
        {
            res *= waruList[i];
            i += N - 1;
        }
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while 1:
    key = 2
    data = list(map(int, input().split()))
    if data[0] == 0 and data[1] == 0:
        break
    month = data[0]
    day = data[1]
    for i in range(month-1):
        key += days[i]
    key += day
    print(week[key % 7])

Measured memory_bytes: 7584
#include<stdio.h>

//dp seearch 
//res = max(res,Rj - minRi)
//scan one time
int main(){
   int min_i = 0;//first input
   int j = 0; // second input
   int ans = -1000000500;
   int n = 0;
   scanf("%d",&n); 
   scanf("%d",&min_i); 
   for(int k = 1; k<n; k++){
     scanf("%d",&j);
     if(j-min_i>ans) ans = j-min_i;
     if(min_i>j) min_i = j; 
   }
printf("%d\n",ans);
   return 0;
}



Measured memory_bytes: 2748
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, m; cin >> n >> m;

    if(n==1 && m==1) cout << 1 << endl;
    else if(n==1 && m>=3) cout << m-2 << endl;
    else if(m==1 && n>=3) cout << n-2 << endl;
    else if(n>=2 && m>=2) cout << (n-2)*(m-2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int n,A[50];

int solve(int i,int m){
    if(m==0) return 1;
    if(i>=n) return 0;
    int res=solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(void){
    int q,M,i;

    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&M);
        if(solve(0,M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2096
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]

def gcd(x, y):
    while x % y != 0:
        t = x % y
        x = y
        y = t
    return y

def lcm(x, y):
    g = gcd(x, y)
    return (x // g) * (y // g) * g

print(reduce(lcm, T))


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

using namespace std;

template< typename Monoid, typename F >
struct SegmentTree {
  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

const int INF = 1 << 30;

int N, K, P[500000];
int pos[500000];
vector< int > g[500000];

int main() {
  scanf("%d %d", &N, &K);
  for(int i = 0; i < N; i++) {
    scanf("%d", &P[i]);
    --P[i];
    pos[P[i]] = i;
  }

  {
    auto f = [](int a, int b) { return max(a, b); };
    SegmentTree< int, decltype(f) > seg(N, f, -INF);
    for(int i = 0; i < N; i++) {
      auto ret = seg.query(max(0, pos[i] - K + 1), pos[i]);
      if(ret != -INF) {
        g[pos[ret]].emplace_back(pos[i]);
      }

      ret = seg.query(pos[i], min(N, pos[i] + K));
      if(ret != -INF) {
        g[pos[ret]].emplace_back(pos[i]);
      }

      seg.update(pos[i], i);
    }
  }


  vector< int > deg(N);
  for(int i = 0; i < N; i++) for(int j : g[i]) ++deg[j];
  priority_queue< int, vector< int >, greater<> > que;
  for(int i = 0; i < N; i++) if(deg[i] == 0) que.emplace(i);
  vector< int > ord;
  while(que.size()) {
    auto p = que.top();
    que.pop();
    ord.emplace_back(p);
    for(auto to : g[p]) {
      if(--deg[to] == 0) que.emplace(to);
    }
  }

  vector< int > ans(N);
  for(int i = 0; i < N; i++) ans[ord[i]] = i + 1;
  for(int i = 0; i < N; i++) printf("%d\n", ans[i]);
}

Measured memory_bytes: 42236
import sys
n,k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = sys.maxsize * (-1)
r = sys.maxsize

while l+1 < r:
  x = (l+r)//2
  def isOk():
    tot = 0
    for i in range(n):
      if a[i] < 0:
        l = -1
        r = n
        while (l+1<r):
          c = (l+r)//2;
          if (a[c] * a[i] < x):
            r = c
          else:
            l = c
        tot += n-r
      else:
        l = -1
        r = n
        while (l+1<r):
          c = (l+r)//2
          if (a[c] * a[i] < x):
            l = c
          else:
            r = c
        tot += r
      if (a[i]*a[i] < x):
        tot -= 1
    tot /= 2
    return tot < k
  if (isOk()):
    l = x
  else:
    r = x;
print(l)

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

int main() {
    int n;
    cin>>n;
    int d[n];
    for(int i=0;i<n;++i) cin>>d[i];
    sort(d,d+n);
    int s=1;
    for(int i=1;i<n;++i){
        if(d[i]!=d[i-1]) ++s;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll mod = 1e9+7;


int main(){
    int n; cin >> n;
    string s,t; cin >> s >> t;
    vector<string> ans(2*n);
    for(int i=0; i<n; i++){
        ans[2*i] = s[i];
    }
    for(int i=0; i<n; i++){
        ans[2*i+1] = t[i];
    }
    for(int i=0;i<2*n;i++){
cout << ans[i];
}cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0,p=0,q=n-1;
	while(p<q){
		while(p!=n&&s[p]!='W')p++;
		while(q>=0&&s[q]!='R')q--;
		if(p==n||q==-1||p>q)break;
		cnt++;
		p++;
		q--;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3720
/*
    B - Iroha Loves Strings (ABC Edition)
    https://atcoder.jp/contests/abc042/tasks/abc042_b
*/

#include <iostream>

using namespace std;

#define ll long long
#define forn(i, s, n) for (int i = s; i < n; i++)
#define whilen(val, n) while(n-- && cin >> val)

int main() {
    int n, l;
    string s;
    string strs[100];
    cin >> n >> l;

    forn(i, 0, n) {
        cin >> s;
        strs[i] = s;
    }

    forn(i, 0, n) {
        int min = i;
        forn(j, i+1, n) {
            if (strs[min] > strs[j]) {
                min = j;
            }
        }
        string temp = strs[i];
        strs[i] = strs[min];
        strs[min] = temp;
    }

    forn(i, 0, n) cout << strs[i];
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N; cin >> N;
    vec a(N); rep(i, N) cin >> a[i];

    int res=0;
    int kijun=1;
    rep(i, N){
        if(a[i] == kijun){
            kijun++;
        }else{
            res++;
        }
    }

    if(res == N) res = -1;

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;


int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(A, B) << " " << max((A+B)-N, 0) << "\n";
    return 0;
}

Measured memory_bytes: 256
readstr() = split(readline())
readnum(T::Type{<:Number} = Int) = parse.(T, split(readline()))
let
  X, Y = readnum()
  for k in 0:100, t in 0:100
    (X == k + t) && (Y == 4k + 2t) && (println("Yes");exit())
  end
  println("No")
end


Measured memory_bytes: 170976
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
string s[110],t[110];
int main(){
  int n,m;
  cin>>n;
  rep(i,n)cin>>s[i];
  cin>>m;
  rep(i,m)cin>>t[i];  
  int ans=0;
  rep(i,n){
    int score=0;
    rep(j,n)if(s[j]==s[i])score++;
    rep(j,m)if(t[j]==s[i])score--;
    ans=max(ans,score);
  }
  cout<<ans<<endl;
  return 0;
}

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

    int main(){
        int a1, a2, a3;
        cin >> a1 >> a2 >> a3;
        int s = a1 + a2 +a3;
        if(s >= 22){
            cout << "bust" << endl;
        }else{
            cout << "win" << endl;
        }
    }

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

int main(){
  string s,t,s1,s2;
  cin>>s>>t;
  for(int i=0; i<(int)s.size(); i++){
    s1 = s.substr(1,s.size()-1);
    s2 = s.substr(0,1);
    //cout<<s1<<s2<<endl;
    s=s1+s2;
    if(t==s){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256