akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

type pair struct {
	l int
	r int
}

func main() {
	sc.Split(bufio.ScanWords)
	q := readInt()

	pairs := make([]pair, q)
	rmax := 0
	for i := 0; i < q; i++ {
		l, r := readInt(), readInt()
		pairs[i] = pair{l, r}
		rmax = max(rmax, r)
	}

	s := make([]int, rmax+1)
	for i := 1; i <= rmax; i++ {
		s[i] = s[i-1]
		if i%2 == 0 {
			continue
		}
		if i%2 != 0 && isPrime(i) && isPrime((i+1)/2) {
			s[i] += 1
		}
	}

	for _, p := range pairs {
		fmt.Println(s[p.r] - s[p.l-1])
	}
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int c[3][3];
  for (int j = 0; j < 3; j++) {
    for (int i = 0; i < 3; i++) {
      cin >> c[i][j];
    }
  }
  int a[3], b[3];
  a[0] = 0;
  b[0] = c[0][0];
  b[1] = c[0][1];
  b[2] = c[0][2];
  a[1] = c[1][0] - c[0][0];
  a[2] = c[2][0] - c[0][0];
  for (int j = 0; j < 3; j++) {
    for (int i = 0; i < 3; i++) {
      if (c[i][j] != a[i] + b[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

int gcd(int x,int y){
	if(x%y==0)return y;
	return gcd(y,x%y);
}

int lcm(int x,int y){
	return x/gcd(x,y)*y;
}

signed main(){
	int a,b,c,d;cin>>a>>b>>c>>d;
	a--;
	int B=b/c+b/d-b/lcm(c,d),
		A=a/c+a/d-a/lcm(c,d);
	cout<<b-a-(B-A)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

constexpr long long inf = (1ll << 60);

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N), B(N);
  for (int i: range(0, N)) {
    std::cin >> A[i] >> B[i];
  }
  long long ans = inf;
  chmin(ans, std::accumulate(A.begin(), A.end(), 0ll));
  chmin(ans, std::accumulate(B.begin(), B.end(), 0ll));
  std::vector<std::pair<int, int>> vec;
  vec.reserve(2 * N);
  for (int i: range(0, N)) {
    vec.emplace_back(A[i], i);
    vec.emplace_back(B[i], N + i);
  }
  std::sort(vec.begin(), vec.end());
  std::vector<int> order(2 * N);
  for (int i: range(0, 2 * N)) {
    order[vec[i].second] = i;
  }
  long long sum = 0;
  for (int i: range(0, N)) {
    sum += vec[i].first;
  }
  for (int i: range(0, N)) {
    if (order[i] >= N && order[N + i] >= N) {
      chmin(ans, sum);
    }
    else if (order[i] >= N) {
      int idx = N;
      if (order[i] == N) ++idx;
      chmin(ans, sum - B[i] + vec[idx].first);
    }
    else if (order[N + i] >= N) {
      int idx = N;
      if (order[N + i] == N) ++idx;
      chmin(ans, sum - A[i] + vec[idx].first);
    }
    else {
      chmin(ans, sum - A[i] - B[i] + vec[N].first + vec[N + 1].first);
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
    long long K,A,B,sum;
    cin>>K>>A>>B;
    if(B-A<3){
        cout<<K+1<<endl;
        return 0;
    }
    if(K<A+1){
        cout<<K+1<<endl;
        return 0;
    }
    sum=A;
    K=K-(A-1);
    sum+=(B-A)*(K/2);
    K=K%2;
    sum+=K;
    cout<<sum<<endl;
}


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

ll ans[3000];

int main(){
	int N, X, Y; cin >> N >> X >> Y;
	int d[N][N];
	X--; Y--;
	rep(i, N)rep(j, N){
		d[i][j] = min(abs(i-j), min(abs(X-i)+1+abs(Y-j), abs(Y-i)+1+abs(X-j)));
	}
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			ans[d[i][j]]++;
		}
	}
	for(int i=1; i<N; i++) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>

int main(void){
 int W,H,x,y,r;
 scanf("%d",&W);
 scanf("%d",&H);
 scanf("%d",&x);
 scanf("%d",&y);
 scanf("%d",&r);

 if(x - r < 0 || x + r > W || y - r < 0 || y + r > H){
  printf("No\n");
 }
 else{
  printf("Yes\n");
 }
 return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n;
	ll a[200020];
	ll s[200020];
	s[0]=0;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>a[i];
		s[i+1]=s[i]+a[i];
	}
	ll ans=1e18;
	for(int i=1; i<=n; i++){
		ans=min(ans, abs(s[i]-(s[n]-s[i])));
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3328
from itertools import accumulate

n,k = map(int, input().split())
a = list(map(int, input().split()))
e_a = [(i+1)/2 for i in a] #それぞれの期待値
s_a = list(accumulate(e_a)) #期待値の累積和

res = 0
exp = 0
for i in range(k-1, n):
    if i == k-1:
        exp = s_a[i]
    else:
        exp = s_a[i] - s_a[i-k]
        
    res = max(res, exp) #最大期待値を更新

print(res)

Measured memory_bytes: 25148
n = input()
A = list(map(int, input().split()))
for index in range(len(A)):
    if index != len(A) - 1:
        print(A[index], end=" ")
    else:
        print(A[index])

for i in range(1, len(A)):
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key
    for index in range(len(A)):
        if index == len(A) - 1:
            print(A[index])
        else:
            print(A[index], end=" ")



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

#define xx first
#define yy second

const int N = 1e5 + 1;
const int oo = 2e9 + 1;

int h[N], dp[N];

void solve() {
    int n; cin >> n;
    fill(dp, dp + n, oo);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    dp[0] = 0;
    for (int i = 1; i < n; i++)
        for (int j = 1; i - j >= 0 && j < 3; j++)
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    cout << dp[n - 1] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 4352
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

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

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

int d[101] = {0};

int main()
{
	int N = 0, ans = 0;
	int i = 0, j = 0;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
    	scanf("%d", &d[i]);
    }

    qsort(d, N, sizeof(int), sort_dec);

    for (i = 0; i < N; i++) {
        for (j = i+1; j < N; j++) {
        	ans += (d[i] * d[j]);
        }
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

void dfs(Vvec<int>& graph, vector<int>& bw, int tmp, int from)
{
    bw[tmp] = (from == -1) ? 0 : 1 - bw[from];
    for(auto& to: graph[tmp]){
        if(to != from) dfs(graph, bw, to, tmp);
    }
}

int main()
{
    int N;
    cin >> N;
    Vvec<int> graph(N);
    for(int i=0; i<N-1; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    vector<int> bw(N);
    dfs(graph, bw, 0, -1);

    int b = 0, w = 0;
    for(auto& x: bw){
        if(x == 0) b++;
        else w++;
    }

    vector<ll> pb(b), pw(w);
    if(b <= N/3){
        for(int i=0; i<b; i++) pb[i] = 3*i+3;
        int j = 1;
        for(int i=0; i<w; i++){
            if(j%3==0 && j<=3*b) j++;
            pw[i] = j; j++;
        }
    }
    else if(w <= N/3){
        for(int i=0; i<w; i++) pw[i] = 3*i+3;
        int j = 1;
        for(int i=0; i<b; i++){
            if(j%3==0 && j<=3*w) j++;
            pb[i] = j; j++;
        }
    }
    else if(b < w){
        for(int i=0; 3*i+2<=N; i++) pb[i] = 3*i+2;
        for(int i=0; 3*i+1<=N; i++) pw[i] = 3*i+1;
        int j = 3;
        for(int i=b-1; i>=0; i--, j+=3){
            if(pb[i] != 0) break;
            pb[i] = j;
        }
        for(int i=w-1; i>=0; i--, j+=3){
            if(pw[i] != 0) break;
            pw[i] = j;
        }
    }
    else{
        for(int i=0; 3*i+2<=N; i++) pw[i] = 3*i+2;
        for(int i=0; 3*i+1<=N; i++) pb[i] = 3*i+1;
        int j = 3;
        for(int i=b-1; i>=0; i--, j+=3){
            if(pb[i] != 0) break;
            pb[i] = j;
        }
        for(int i=w-1; i>=0; i--, j+=3){
            if(pw[i] != 0) break;
            pw[i] = j;
        }
    }

    int i = 0, j = 0;
    for(int k=0; k<N; k++){
        if(bw[k] == 0){
            cout << pb[i] << " "; i++;
        }
        else{
            cout << pw[j] << " "; j++;
        }
    }
    cout << endl;
}

Measured memory_bytes: 20864
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int p=0;
  int q=0;
  for(int i = 0; i < S.size(); i++){ //0,1,0,1...
    if(i%2 == 0){
      if(S.at(i) == '1'){
        p++;
      }
    }
    if(i%2 == 1){
      if(S.at(i) == '0'){
        p++;
      }
    }
  }
  for(int i = 0; i < S.size(); i++){ //1,0,1,0...
    if(i%2 == 0){
      if(S.at(i) == '0'){
        q++;
      }
    }
    if(i%2 == 1){
      if(S.at(i) == '1'){
        q++;
      }
    }
  }
  cout << min(q,p) << endl;
}



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

using namespace std; // {{{

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, int sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, int sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
} // }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int H, W;
    cin >> H >> W;

    vector<string> mat(H);
    for (int i = 0; i < H; ++i) {
        cin >> mat[i];
    }

    auto left = make_v(0, H + 5, W + 5);
    auto right = make_v(0, H + 5, W + 5);
    for (int y = 0; y < H; ++y) {
        left[y][0] = (mat[y][0] == '#');
        for (int x = 1; x < W; ++x) {
            left[y][x] = left[y][x - 1];
            if (mat[y][x] == '#') left[y][x] = x + 1;
        }
        for (int x = W - 1; x >= 0; --x) {
            right[y][x] = right[y][x + 1];
            if (mat[y][x] == '#') right[y][x] = W - x;
        }
    }

    auto above = make_v(0, H + 5, W + 5);
    auto below = make_v(0, H + 5, W + 5);
    for (int x = 0; x < W; ++x) {
        above[0][x] = (mat[0][x] == '#');
        for (int y = 1; y < H; ++y) {
            above[y][x] = above[y - 1][x];
            if (mat[y][x] == '#') above[y][x] = y + 1;
        }
        for (int y = H - 1; y >= 0; --y) {
            below[y][x] = below[y + 1][x];
            if (mat[y][x] == '#') below[y][x] = H - y;
        }
    }

    int maxv = 0;
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            if (mat[y][x] == '.') {
                chmax(maxv, (W - left[y][x] - right[y][x]) + (H - above[y][x] - below[y][x]) - 1);
            }
        }
    }

    cout << maxv << "\n";

    return 0;
}


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

int main(){
  ll h,w;
  cin>>h>>w;
  if(h==1||w==1){
    cout<<'1'<<endl;
  }
  else{
    cout<<(h*w+1)/2<<endl;
  }
}


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

using namespace std ;

#define N 500010
#define inf 0x3f3f3f3f

struct node {
	int to , nxt , belong ;
}e[ N << 2 ];

int n , m ; 
int head[ N << 2 ] , cnt ;


int d[ N * 2 ]  ;

void ins( int u , int v , int c ) {
	e[ ++ cnt ].to = v ;
	e[  cnt ].nxt = head[ u ] ;
	e[ cnt ].belong = c ;
	head[ u ] = cnt ;
}

std::set< int > st[ N ] ;
priority_queue< pair<int,int> > q;

void spfa() {
	for( int i = 1 ; i <= n ; i ++ ) d[ i ] = inf ;
	d[ 1 ] = 0 ;
	q.push( { 0 , 1 } ) ;
	while(!q.empty()){
		int u = q.top().second , ans = -q.top().first;
		q.pop() ;
		if( d[ u ] < ans ) continue ;
		for( int i = head[ u ] ; i ; i =e[ i ].nxt ) {
			int v = e[ i ].to ;
			int num = ans + !st[ u ].count( e[ i ].belong ) ;
			if( d[ v ] > num ) {
				d[ v ] = num ;
				q.push( { -num , v } ) ;
				st[ v ].clear() ;
				st[ v ].insert( e[ i ].belong ) ;
			}else if( d[ v ] == num ) {
				st[ v ].insert( e[ i ].belong ) ;
			}
		}
	}
	if( d[ n ] == inf ) puts( "-1" ) ;
	else printf( "%d\n" , d[ n ] ) ;
}

int main() {
	scanf( "%d%d" , &n ,&m ) ;
	for( int i = 1 ; i <= m ; i ++ ) {
		int x , y , c ;
		scanf( "%d%d%d" , &x , &y , &c ) ;
		ins( x , y , c ) ;
		ins( y , x , c ) ;
	}
	spfa() ;
}


Measured memory_bytes: 42744
#include<stdio.h>
 
struct Card{
  char suit;
  int value;
};
 
 
int main(){
  struct Card C1[101], C2[101],key[101];
  int n, i,j,mini,count=0;;
  char ch;
 
  scanf("%d%c", &n, &ch);
  for ( i = 1; i <= n; i++ ){
    scanf("%c%d%c", &C1[i].suit, &C1[i].value, &ch);
  }
 
for ( i = 1; i <= n; i++ ){
  C2[i]=C1[i];
  }
for(i=1;i<=n;i++){
    for(j=n;j>=i+1;j--){
      if(C1[j].value<C1[j-1].value){
    key[j]=C1[j];
    C1[j]=C1[j-1];
    C1[j-1]=key[j];
    }}}
   for(i=1;i<=n;i++){
if(i==n){
printf("%c%d\n",C1[i].suit,C1[i].value);
    break;
}
 printf("%c%d ",C1[i].suit,C1[i].value);
}
    printf("Stable\n");
     
     
    for(i=1;i<=n;i++){
    mini=i;
    for(j=i;j<=n;j++){
        if(C2[j].value<C2[mini].value){
        mini=j;
        }}        
    if(C2[mini].value<C2[i].value){
    key[i]=C2[i];
    C2[i]=C2[mini];
    C2[mini]=key[i];
    }}
     
      for(i=1;i<=n;i++){
if(i==n){
printf("%c%d\n",C2[i].suit,C2[i].value);
    break;
}
 printf("%c%d ",C2[i].suit,C2[i].value);
}
for(i=1;i<=n;i++){
    if(C1[i].value==C2[i].value && C1[i].suit==C2[i].suit){
        count++;
        }
else break;
}
    if(count==n) printf("Stable\n");
    else printf("Not stable\n");
     
     
  return 0;}

Measured memory_bytes: 612
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int id = -1;
    rep(i,n){
        cin >> a[i];
        if(a[i] == 1) id = i;
    }
    int ans = 0;
    for(int i = 0; i < n; i+=k-1){
        if(i >= id){
            id = i;
            break;
        }
        ans++;
    }
    for(int i = id; i < n-1; i+=k-1){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/


signed main(){
  string s;
  cin>>s;
  if(s[1]=='R') s[1]='B';
  else s[1]='R';

  cout<<s<<endl;
  return 0;
}

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

#define sz(x) ((int)x.size())
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll; 


int main(){
  string s; cin>>s; 
  int a=stoi(s.substr(0,2)); 
  int b=stoi(s.substr(2,2)); 
  if( a>=1 && b>=1 && a<=12 && b<=12){
    cout<<"AMBIGUOUS"<<endl; 
  }
  else if( a>=1 && a<=12 && (b>12 || b==0)){
    cout<<"MMYY"<<endl; 
  }
  else if( b>=1 && b<=12 && (a>12 || a==0)){
    cout<<"YYMM"<<endl; 
  }
  else {
    cout<<"NA"<<endl;
  }
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    int cnt = 0;
    cin >> h >> w;
    char b[h][w];
    int d[h][w];
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};

    rep (i, h) {
        rep (j, w) {
            cin >> b[i][j];
            if (b[i][j] == '#') {
                d[i][j] = -1;
                cnt++;
            } else {
                d[i][j] = Inf;
            }
        }
    }

    queue<pair<int, int> > q;
    d[0][0] = 1;
    q.push(make_pair(0, 0));
    while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();
        int x, y;
        x = p.first, y = p.second;
        rep (i, 4) {
            int nx, ny;
            nx = x + dx[i], ny = y + dy[i];
            if (nx >= h || nx < 0 || ny >= w || ny < 0) continue;
            if (d[nx][ny] != -1 && d[nx][ny] > d[x][y] + 1) {
                d[nx][ny] = d[x][y] + 1;
                q.push(make_pair(nx, ny));
            }
        }
    }
    if (d[h - 1][w - 1] == Inf) cout << "-1" << endl;
    else cout << h * w - cnt - d[h - 1][w - 1] << endl;

    return 0;
}



Measured memory_bytes: 256
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val (t,a) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }
    val ondo = h.indices.map { t - h[it] * 0.006.toDouble() }
    val ans = ondo.indices.map { Pair(it, Math.abs(a-ondo[it])) }.minBy { it.second }!!.first + 1
    println(ans)
}


Measured memory_bytes: 38184
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, q;
int max[maxn << 2];
inline void upt(int pos,int v,int cur = 1,int l = 0,int r = n) {
	if(l == r) return void(max[cur] = v);
	int mid = l + r >> 1;
	pos <= mid ? upt(pos, v, cur << 1, l, mid) : upt(pos, v, cur << 1 | 1, mid + 1, r);
	max[cur] = std::max(max[cur << 1], max[cur << 1 | 1]);
}
inline int qry(int ql,int qr,int cur = 1,int l = 0,int r = n) {
	if(ql <= l && r <= qr) return max[cur];
	int mid = l + r >> 1, ans = -1e9;
	if(ql <= mid) ans = std::max(ans, qry(ql, qr, cur << 1, l, mid));
	if(mid < qr) ans = std::max(ans, qry(ql, qr, cur << 1 | 1, mid + 1, r));
	return ans;
}
std::vector<int> v[maxn];
int b[maxn];
int dp[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n) {
		cin >> b[i];
		b[i] += b[i - 1];
	}
	cin >> q;
	rep(i, 1, q) {
		int l, r;
		cin >> l >> r;
		v[l].push_back(r);
	}
	rep(i, 1, n) dp[i] = -1e9, upt(i, -1e9);
	rep(i, 1, n) {
		for(int x : v[i]) {
			int v = std::max(dp[i - 1], qry(i - 1, x));
			if(v > dp[x]) {
				dp[x] = v;
				upt(x, v);
			}
		}
		dp[i] = std::max(dp[i], dp[i - 1] + (b[i] == b[i - 1] ? 1 : -1));
	}
	cout << n - b[n] - dp[n] << '\n';
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define print(x) cout << (x) << endl
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second

inline int in(){int x;std::cin>>x;return x;}
struct FAST {FAST(){cin.tie(0);ios::sync_with_stdio(false);}} Fast;
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
/* }}} */ 

signed main(void)
{
  int d;

  while (cin >> d){
    int res = 0;
    FOR(i, 1, 600 / d) res += d * i * d * i * d;

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 2952
using System;
using System.Linq;

class PG{
    static void Main(string[] args){
        int[] nums=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int a,b,c,n;
        n=0;
        a=nums[0];
        b=nums[1];
        c=nums[2];
        for(int i=a;i<=b;i++){
            if(c%i==0){
                n++;
            }
        }
        Console.WriteLine(n);
    }
}


Measured memory_bytes: 18436
s, t = gets.chomp.split(" ")
a, b = gets.chomp.split(" ").map(&:to_i)
u = gets.chomp
if u == s
    print a-1
    print " "
    print b
    print "\n"
elsif u == t
    print a
    print " "
    print b-1
    print "\n"
end

Measured memory_bytes: 14276
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] NMXY = br.readLine().split(" ");
        int N = Integer.parseInt(NMXY[0]);
        int M = Integer.parseInt(NMXY[1]);
        int X = Integer.parseInt(NMXY[2]);
        int Y = Integer.parseInt(NMXY[3]);
        String[] xiString = br.readLine().split(" ");
        String[] yiString = br.readLine().split(" ");
        
        int[] xi = new int[N+1];
        int[] yi = new int[M+1];
        for(int i = 0; i < N; i++){
            xi[i] = Integer.parseInt(xiString[i]);
        }
        xi[N] = X;
        Arrays.sort(xi);
        
        for(int i = 0; i < M; i++){
            yi[i] = Integer.parseInt(yiString[i]);
        }
        yi[M] = Y;
        Arrays.sort(yi);
        if(xi[0] <= yi[M] && xi[N] >= yi[0]){
            System.out.println("War");
        } else if(yi[0] <= xi[N] && yi[N] >= xi[0]){
            System.out.println("War");
        } else {
            System.out.println("No War");
        }
    }
}


Measured memory_bytes: 22996
K=int(input())
A,B = map(int, input().split())
a=[]
i=1
while True:
    if K*i<=1000:
        a.append(K*i)
        i=i+1
    else:
        break
s=0
for i in a:
    

    if A<=i<=B:
        s=1
        
        break
if s==0:
    print("NG")
if s==1:
    print("OK")
     

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

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    int i = 0;
    int cnt = 0;
    while (1) {
        if (cnt >= n) {
            cout << -1 << endl;
            return 0;
        }
        else if (i == 1) {
            cout << cnt << endl;
            return 0;
        }
        else {
            i = a.at(i) - 1;
            cnt++;
        }
    }
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n,m, cnt = 0;
	cin >>n >> m;
  	if(n>=m) {
    	cnt += n;
      	n--;
    } else {
      	cnt += m;
      	m--;
    }
  	if(n>=m) {
    	cnt += n;
      	n--;
    } else {
      	cnt += m;
      	m--;
    }
  
  
	cout << cnt << endl;
}


Measured memory_bytes: 256
ips = []
ips.append(input())
while True:
    try:
        ips.append(input())
    except (EOFError):
        break
num = int(ips[0])
hina = ips[1].split(" ")
v = []
for i in range(num):
    if hina[i] not in v:
        v.append(hina[i])
if len(v) == 3:
    print("Three")
elif len(v) == 4:
    print("Four")

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  string s;

  cin >> n >> s;

  while (true) {
    int r = 0;
    int l = 0;
    bool flag = true;
    REP (i, s.size()) {
      if (s[i] == ')') r++;
      else l++;

      if (l - r < 0) {
        s = "(" + s;
        flag = false;
        break;
      }
    }
    if (!flag) continue;
    REP (i, l - r) {
      s += ")";
    }
    break;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main(){
    int H,W; cin>>H>>W;
    vector<vector<bool>> odd(H,vector<bool>(W,false));
    int a;
    int oddcnt=0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin>>a;
            if((a&1)==1) {
                odd[i][j] = true;
                oddcnt++;
            }
        }
    }
    vector<pair<int,int>> mass;
    string ans="";
    int N=0;
    bool f=false;
    for(int i=0;i<H;++i){
        if((i&1)==0) {
            for (int j = 0; j < W; ++j) {
                if(f) mass.push_back({i,j});
                if(odd[i][j]){
                    if(f){
                        for(int k=0;k<mass.size()-1;++k){
                            int y1=mass[k].first+1,x1=mass[k].second+1, y2=mass[k+1].first+1,x2=mass[k+1].second+1;
                            ostringstream oss;
                            oss<<y1<<" "<<x1<<" "<<y2<<" "<<x2<<"\n";
                            ans+=oss.str();
                            N++;
                        }
                        f=false;
                        mass.clear();
                    }else{
                        f=true;
                        mass.push_back({i,j});
                    }
                }
            }
        }else{
            for (int j = W-1; j >=0; --j) {
                if(f) mass.push_back({i,j});
                if(odd[i][j]){
                    if(f){
                        for(int k=0;k<mass.size()-1;++k){
                            int y1=mass[k].first+1,x1=mass[k].second+1, y2=mass[k+1].first+1,x2=mass[k+1].second+1;
                            ostringstream oss;
                            oss<<y1<<" "<<x1<<" "<<y2<<" "<<x2<<"\n";
                            ans+=oss.str();
                            N++;
                        }
                        f=false;
                        mass.clear();
                    }else{
                        f=true;
                        mass.push_back({i,j});
                    }
                }
            }
        }
    }

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



Measured memory_bytes: 4100
/**
 *    author:  tourist
 *    created: 29.12.2018 15:01:33       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << b + min(a + b + 1, c) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int counter;
    cin >> counter;
    
    int maxelement = 0;
    int maxelement_index = 0;
    int second_maxelement = 0;
    int tmp = 0;
    
    for(int i=0; i<counter; i++){
        cin >> tmp;
        if(tmp > maxelement){
            maxelement = tmp;
            maxelement_index = i;
        }else if(tmp > second_maxelement){
            second_maxelement = tmp;
        }
    }
    
    for(int i=0; i<counter; i++){
        if(i!=maxelement_index){
            cout << maxelement << endl;
        }else{
            cout << second_maxelement << endl;
        }
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
using namespace std;

string in;
int k;
vector<int>v;
vector<int>ans;

int main()
{
	cin.sync_with_stdio(0);		cin.tie(0);		cout.tie(0);

	cin >> in >> k;
	int p = in.size();

	for(int x = 0 ; x < p ; x++){
		int hash = 0;
		int val = 0;
		for(int y = x ; y < min(p, x + 5) ; y++){
			hash = hash * 27 + (in[y] - 'a' + 1);
			val++;
			int now = hash;
			for(int x = 4; x >= val ; x--){
				now = now * 27;
			}
			v.pb(now);
		}
	}
	sort(v.begin(), v.end());

	int siz = v.size();
	int jawab = 0;

	for(int x = 0 ; x < siz; x++){
		if(x == 0){
			k--;
		}else if(v[x] == v[x - 1]){
			continue;
		}else{
			k--;
		}
		if(k == 0){
			jawab = v[x];
			break;
		}
	}

	while(jawab > 0){
		int va = jawab % 27;
		jawab = jawab / 27;
		if(va == 0){
			continue;
		}else{
			ans.pb(va);
		}
	}
	int pp = ans.size();
	for(int x = pp - 1; x >= 0 ; x--){
		printf("%c",ans[x] + 'a' - 1);
	}
	printf("\n");
}	

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
#define fr(a, b, c) for(int a = b; a >= c; a--)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 2e6 + 7;
const ll inf = 1e9 + 5;




ll n;
ll arr[N];

int main()
{
    MohamedMotaz;
    cin >> n;
    ll sum = 0;
    f(i,1,n + 1) if (i % 3 == 0 || i % 5 == 0) arr[i] = -1;
    f(i,1,n + 1) if (arr[i] != -1) sum += i;
    cout << sum;
}





Measured memory_bytes: 10952
package main

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

func main() {
	io := newIo()
	defer io.Flush()
	N := io.NextInt()
	if N > 81 {
		fmt.Println("No")
		return
	}
	for i := 1; i < 10; i++ {
		if i*9 < N {
			continue
		}
		if N%i == 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std; 
int main() {
    string deck;
    int n ;
    int h;
    string tmp;
    while(1){
        cin >> deck;
        if(deck == "-") break;
        cin >> n;
        for (int i = 0; i < n; i++){
            cin >> h;
            tmp = deck.substr(h);
            deck = tmp + deck.erase(h);
        }
        cout << deck << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()

using namespace std;

long a, b, c, d, i, j, k, n, R, G, B;


int main(){
//////////////////////////////////////////////////////


    // cout << "Hello, World!" << endl;

    cin >> R >> G >> B >> n;
    long ball = 0;
    //赤個数

    long ok = 0;
    
    for ( int rn = 0 ; rn <= n / R ; rn ++ )
    {
        ball = rn * R;
        long nokoriball = n - ball;
        for ( int gn = 0 ; gn <= nokoriball / G ; gn++ )
        {
            ball = rn * R + gn * G;
            
            // 割り切れない場合
            if ( (n - ball) % B != 0 )
            {
                //cout << rn << "+" << gn << "+" << 0 << "," <<rn*R + gn*G << " < " << n << endl;

                continue;
            }
            else
            {
                long bn;
                bn = (n - ball) / B;
                ok ++;
                //cout << rn << "+" << gn << "+" << bn << "," <<rn*R + bn*B + gn*G << " = " << n << endl;
            }
        }
    }

    // cout << "n:" << n << endl;

    // vector<long> input(n);
    // for (int i = 0 ; i < n ; i ++ )
    // {
    //     cin >> input[i];
        // cout << "input[" << i << "]=" << input[i] << endl;
    // }

    // sort(input.begin() , input.end());

    // uint64_t max = numeric_limits<uint64_t>::max();



    // long sum = 0;
    // for ( int i = 0 ; i < n ; i ++ )
    // {
    //     sum += i;
    // }






    cout <<   ok   << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    loop(i,0,n) cin>>a[i];
    ll dp[n+1] = {0};
    dp[0] = 1;
    loop(i,0,n){
        if(dp[a[i]-1] == 1){
            dp[a[i]] = 1;
        }
    }
    for(ll i=n; i>=1; i--){
        if(dp[i] == 1){
            print(n-i);
            ret;
        }
    }
    print(-1);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }

}


Measured memory_bytes: 3968
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] d = new double[N];
		double ip = 1;
		for(int i = 0 ;i < N; i++) {
			d[i] = sc.nextDouble();
			ip *= d[i];
		}
		sc.close();
		
		double sum = 0;
		for(int i = 0 ;i < N; i++) {
			sum += ip / d[i];
		}
		System.out.println(ip/sum);
	}
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

const int N = 2e5 + 5;
const ll INF = 1e18L + 5;

int t[4*N] = {0}, lazy[4*N] = {0};

void push(int node){
    for(auto child: {2*node, 2*node + 1}){
        t[child] += lazy[node];
        lazy[child] += lazy[node];
    }
    lazy[node] = 0;
}

void update(int node, int tl, int tr, int l, int r, int add){
    if(l > r) return;
    if(tl == l && tr == r){
        t[node] += add;
        lazy[node] += add;
    } else {
        push(node);
        int tm = (tl + tr)>>1;
        update(2*node, tl, tm, l, min(r, tm), add);
        update(2*node+1, tm+1, tr, max(l, tm+1), r, add);
        t[node] = min(t[2*node], t[2*node+1]);
    }
}

int query(int node, int tl, int tr, int l, int r){
    if(l > r) return INF;
    if(tl == l && tr == r) return t[node];
    push(node);
    int tm = (tl + tr)>>1;
    return min(query(2*node, tl, tm, l, min(r, tm)),
               query(2*node+1, tm+1, tr, max(l, tm+1), r));
}


void solve(){
    ll n, m, l, r, x;
    cin>>n>>m;

    ll tot = 0;
    vector<pll> en[n+1];
    for(int i=0; i<m; i++){
        cin>>l>>r>>x;
        tot += x;
        en[r].push_back({l, x});
    }

    ll best = tot;

    for(int i=1; i <= n+1; i++){
        /// best value till now for putting 1 here
        for(auto p: en[i - 1]){
            l = p.first;
            x = p.second;
            update(1, 0, N - 1, 0, l - 1, x);
        }

        best = query(1, 0, N - 1, 0, i - 1);
        update(1, 0, N - 1, i, i, best);
    }

    cout<<tot - best;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

int main( )
{
  string a, b;
  cin >> a >> b;
  
  if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#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>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    int buf;
    REP(i, 5){
        cin >> buf; 
        if(buf==0) cout << i+1 << endl;
    }
}

Measured memory_bytes: 3628