akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<String>();

    if n.len() == 1 {
        println!("{}", n);
        return;
    }

    let mut dp = vec![vec![vec![vec![0; 10]; 10]; 2]; n.len() + 1];
    dp[0][0][0][0] = 1; // pos, less, start, end

    for (i, c) in n.chars().enumerate() {
        for j in 0..2 {
            for k in 0..10 {
                for m in 0..10 {
                    let lim = if j == 1 {
                        9
                    } else {
                        c.to_digit(10).unwrap() as usize
                    };
                    for l in 0..lim + 1 {
                        let idx1 = if j == 1 || l < lim { 1 } else { 0 };
                        let idx2 = if k == 0 { l } else { k };
                        let idx3 = l;
                        dp[i + 1][idx1][idx2][idx3] += dp[i][j][k][m];
                    }
                }
            }
        }
    }

    let mut ans = 0;
    for start in 1..10 {
        for end in 1..10 {
            let mut start_to_end = 0;
            let mut end_to_start = 0;
            start_to_end += dp[n.len()][1][start][end] + dp[n.len()][0][start][end];
            end_to_start += dp[n.len()][1][end][start] + dp[n.len()][0][end][start];
            ans += start_to_end * end_to_start;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1LL << 60;

int main() {
  int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  int64_t now=1;
  for(int i=0;i<N;i++){
    if(A[i]==0){now=0;break;}
    else if(now<=1000000000000000000/A[i]){
      now*=A[i];
    }
    else{cout<<-1<<endl;return 0;}
  }
  cout<<now<<endl;
  return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
    ll bingocard[3][3];
    bool bing[3][3]={false};
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            bingocard[i][j]=0;
        }
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)
            cin>>bingocard[i][j];
    }
    ll n=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int a=0;
        cin>>a;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++)
                if(bingocard[j][k]==a)
                    bing[j][k]=1;
        }
    }
    bool x=false;
    for(int i=0;i<3;i++){
        if((bing[i][0] && bing[i][1] && bing[i][2])==1)
            x=true;
    }
    for(int i=0;i<3;i++){
        if(bing[0][i] && bing[1][i] && bing[2][i]==1)
            x=true;

    }
    if(bing[0][0] && bing[1][1] && bing[2][2]==1)
        x=true;
    if(bing[0][2] && bing[1][1] && bing[2][0]==1)
            x=true;
    if(x)
        cout<<"Yes";
    else
        cout<<"No";



    }

    return 0;
}


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

int main(){
  long long a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(a==b) cout << "YES" << endl;
  else if(v<=w)cout << "NO" << endl;//鬼遅い
  else{
    long long k=max(a-b,b-a);
    if(k>t*(v-w)) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>

using namespace std;

set<int> prime;
vector<int> alikes;

void calc_prime(int mm) {
    int cur = 2;
    while(cur <= mm) {
        for(auto itr = prime.begin();itr != prime.end();itr++) {
            if(cur % *itr == 0)
                goto not_prime;
        }
        prime.insert(cur);
    not_prime:
        cur++;
    }
}

void calc_alike(void) {
    for(auto itr = prime.begin();itr != prime.end();itr++) {
        if(prime.find((*itr + 1) / 2) != prime.end())
            alikes.push_back(*itr);
    }
}

int main(void) {
    int q,l,r;
    calc_prime(100000);
    calc_alike();
    sort(alikes.begin(),alikes.end());
    cin >> q;
    for(int i = 0;i < q;i++) {
        cin >> l >> r;
        auto itr1 = lower_bound(alikes.begin(), alikes.end(), l);
        auto itr2 = lower_bound(alikes.begin(), alikes.end(), r+1);
        cout << itr2 - itr1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
n=int(input())
l=list(map(int,input().split()))
import collections
c=collections.Counter(l)
count=0
for i in c.values():
    count+=i*(i-1)//2
for j in range(n):
    k=c[l[j]]
    print(count+(k-1)*(k-2)//2-k*(k-1)//2)
    

Measured memory_bytes: 87756
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

k = int(input())

ans = 0
for a in range(1,k+1):
    for b in range(a,k+1):
        for c in range(b,k+1):
            #print(a,b,c)
            #print(len(set([a,b,c])))
            abc_set = list(set([a,b,c]))
            l = len(abc_set)
            if l== 1:
                ans += a
            elif l == 2:
                ans += 3 * gcd(abc_set[0],abc_set[1])
            elif l == 3:
                ans += 6 * gcd(gcd(a,b),c)
print(ans)



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int X, Y, Z; cin >> X >> Y >> Z;
	cout << (X - Z) / (Y + Z);
}


Measured memory_bytes: 3612
a = ['dream','dreamer','erase','eraser']

a = [x[::-1] for x in a]

s = input()

s = s[::-1]
n = len(s)
i = 0
while i < n:
    if s[i] == 'm':
        if s[i:i+5] == 'maerd':
            i += 5
        else:
            print('NO')
            exit()
    elif s[i] == 'e':
        if s[i:i+5] == 'esare':
            i += 5
        else:
            print('NO')
            exit()
    elif s[i] == 'r':
        if s[i+2] == 'm':
            if s[i:i+7] == 'remaerd':
                i += 7
            else:
                print('NO')
                exit()
        elif s[i+2] == 's':
            if s[i:i+6] == "resare":
                i += 6
            else:
                print('NO')
                exit()
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int ans = 1e9;
int h, w, n;
vector<int> E[maxn];
int main()
{
	scanf("%d%d%d", &h, &w, &n);
	for(int i = 1; i <= n; ++i)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		E[y].push_back(x);
	}
	int cur = 0, last = h;
	for(int i = 1; i <= w; ++i)
	{
		sort(E[i].begin(), E[i].end());
		++cur;
		for(auto v : E[i])
		{
			if(v < cur) continue;
			else if(v == cur) ++cur;
			else 
			{
				last = min(last, v - 1);
				break;
			}
		}
		if(cur > last) break;
		ans = last;
	}
	printf("%d\n", ans);
	return 0;
}

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



int main() {
    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;



    cout << A[K-1] << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _2582
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }
                string[] a = Console.ReadLine().Split();
               // bool Lup = false;
              //  bool Rup = false;
                int ans = 0;
              //  int last = 0;//0????????????????????????1???????????????????????????????????¢????????????
                for(int i = 1; i < a.Length; i++)
                {
                    if (a[i - 1][1] == a[i ][1]) { ans++; }
                }Console.WriteLine(ans);
            }
        }
    }
}

Measured memory_bytes: 9368
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

bool check(int n) {
	for (int i = 2; i * i <= n; ++i) {
		if (n % i == 0) return false;
	}
	return true;
}

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

	while (true) {
		if (check(x)) {
			cout << x << endl;
			return 0;
		}
		else x+=1;
	}
}

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

int Q, L, R;
int prime[100001];
int like2017[100001];
int dsum[100001];
int main(){
	int i, j;
	for(i=2; i*i<=100000; i++){
		if (!prime[i]){
			for(j=i+i; j<=100000; j+=i)
				prime[j] = 1;
		}
	}
	prime[1] = 1;
	for(i=1; i<=100000; i+=2) {
		if ( prime[(i+1)/2] == 0 ) 
			like2017[i] = 1;
	}
	
	for(i=1; i<=100000; i++)
		dsum[i] = dsum[i-1] + (prime[i]==0 && like2017[i]==1?1:0);
	
    scanf("%d", &Q);
    for(i=0; i<Q; i++){
    	scanf("%d %d", &L, &R);
    	printf("%d\n", dsum[R] - dsum[L-1]);
    }
    
    return 0;
}

Measured memory_bytes: 1792
N,Q = map(int,input().split())
s = input()
info = [input().split() for _ in range(Q)]

def left_out():
    left = -1; right = N
    while right - left > 1:
        mid = (left+right) // 2
        if judge(mid) == -1:
            left = mid
        else:
            right = mid
    return left

def right_out():
    left = -1; right = N
    while right - left > 1:
        mid = (left+right) // 2
        if judge(mid) == 1:
            right = mid
        else:
            left = mid
    return right

def judge(i):
    now = i
    for t, d in info:
        if s[now] == t:
            if d == "L":
                now -= 1
            elif d == "R":
                now += 1
        if now < 0:
            return -1
        elif N <= now:
            return 1
    return 0
    
left = left_out()
right = right_out()
ans = right - left - 1
print(ans)

Measured memory_bytes: 41392
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

vector<uint64_t> divisor(uint64_t N)
{
    vector<uint64_t> ret;
    for (uint64_t i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}


bool ruijyo(uint64_t v)
{
    bool ret = false;
    
    map<uint64_t, uint64_t> m;
    uint64_t a = 2;
    while(v >= a * a) {
        if (v % a == 0) {
            v /= a;
            m[a] = 1;
        }else {
            a++;
        }
    }
    
    if (v != 1) {
        m[v] = 1;
    }
    
    if(m.size() == 1) {
        ret = true;
    }
    return ret;
}

int main(int argc, const char * argv[]) {
    uint64_t N;
    cin >> N;
    uint64_t ans = 0;
    
    map<uint64_t, bool> z;
    while (N > 1) {
        vector<uint64_t> d = divisor(N);
        
        bool success = false;
        
        for (uint64_t v : d) {
            if (v == 1) {
                continue;
            }
            // vが素数の累乗か判断する。
            if (ruijyo(v)) {
                if (z.count(v) == 0) {
                    z[v] = true;
                    N /= v;
                    ans++;
                    success = true;
                    break;
                }
            }
        }
        
        if (!success) {
            break;
        }
        
    }
    std::cout << ans;
    
    return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int n;
  cin >> n;
  cout << n + n * n + n * n * n << endl;
  return 0;
}


Measured memory_bytes: 3648
// AOJ 1080: Everything Starts With Your Vote
// 2018.2.4 bal4u

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

#define HASHSIZ		200017
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;			// Hash table

void insert(char *s, int w, int id)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;
	int inc = *s + (*(s + 1) << 1);

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return;
		tp += inc; if (tp >= hashend) tp -= HASHSIZ;
	}
	tp->s = s, tp->id = id;
}

int lookup(char *s, int w)
{
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;
	int inc = *s + (*(s + 1) << 1);

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		tp += inc; if (tp >= hashend) tp -= HASHSIZ;
	}
	return -1;
}

typedef struct { char *nm; int x; char fav; } T;
T tbl[100002], *fav;
char name[100002][22];
int N, M, K, L;

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(T *a, T *b)
{
	if (a->fav - b->fav) return a->fav - b->fav;
	if (b->x - a->x) return b->x - a->x;
	return strcmp(a->nm, b->nm);
}

int check(int m)
{
	int i, f, x, base, sum;
	char *nm;

	base = K-m;
	if (base < 0) return 0;
	if (base >= N) return 1;
	sum = 0, nm = tbl[base].nm, base = tbl[base].x;
	for (i = 0; i < m; i++) {
		x = base - fav[i].x;
		if (x < 0) continue;
		f = (strcmp(fav[i].nm, nm) <= 0);
		if (!x && f) continue;
		sum += x; if (!f) sum++;
		if (sum > L) return 0;
	}
	return sum <= L;
}

int main()
{
	int i, lo, hi, mi;
	char buf[12], *p;

	while (N = in()) {
		M = in(), K = in(), L = in();
		memset(hash, 0, sizeof(hash));

		for (i = 0; i < N; i++) {
			fgets(name[i], 22, stdin);
			tbl[i].nm = p = name[i];
			while (*p > ' ') p++; *p = 0;
			insert(name[i], p-name[i], i);
			tbl[i].x = atoi(p+1), tbl[i].fav = 0;
		}
		for (i = 0; i < M; i++) {
			fgets(p=buf, 12, stdin);
			while (*p > ' ') p++; *p = 0;
			tbl[lookup(buf, p-buf)].fav = 1;
		}
		qsort(tbl, N, sizeof(T), cmp);
		fav = tbl + N - M, N -= M;

		lo = 0;
		hi = M; if (hi > K) hi = K; hi++;
		while (hi-lo > 1) {
			mi = (lo + hi) >> 1;
			if (check(mi)) lo = mi; else hi = mi;
		}
		printf("%d\n", lo);
	}
	return 0;
}


Measured memory_bytes: 10332
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
ll k,a[1000000];
	
int main(){
	cin>>k;
	for (int i=1;i<=k;i++) cin>>a[i];
	
	if (a[k]!=2) cout<<-1;
	else{
		ll l=2,r=3,x,flag=1;
		for (int i=k-1;i>=1;i--){
			if (a[i]>r) {
				flag=0;
				break;
			}
			if (l>r) {
				flag=0;
				break;
			}
			if ((r-l+1)<a[i]){
				int can=0;
				if (l%a[i]==0) can=1;
				if (r%a[i]==0) can=1;
				int k1=l/a[i],k2=r/a[i];
				if (k1==k2&&can==0) {
					flag=0;
					break;
				}
			}
			
			if (l%a[i]==0) l=max(l,a[i]);
			else l=max(l,a[i]*(l/a[i]+1));
			
			r=a[i]*(r/a[i]+1)-1;
		//	cout<<l<<endl;
		}
		ll res=l;
		for (int i=1;i<=k;i++){
			res=res-res%a[i];
		}
		if (res!=2) flag=0;
		
		res=r;
		for (int i=1;i<=k;i++){
			res=res-res%a[i];
		}
		if (res!=2) flag=0;	
		
		if (flag){
			cout<<l<<" ";
			cout<<r;
		}else{
			cout<<-1;
		}
	}
	
}

Measured memory_bytes: 1024
command = str(input())
N = len(command)
text = ""
for i in range(N):
    if command[i] == "1":
        text += "1"
    elif command[i] == "0":
        text += "0"
    else:
        if text  == "":
            text = text
        else:
            text = text[:-1]

print(text)


Measured memory_bytes: 2940
import numpy
N = int(input())
a = numpy.array(list(map(int, input().split())))
count = 0

for i in range(N):
    if a[i] % 2 == 0:
        x = a[i]
        while True:
            if x %2 != 0:
                break
            else:
                x = x/2
                count+=1
print(count)

Measured memory_bytes: 27940
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________


	int r;
	cin >> r;
	cout << fixed << setprecision(5) << 2 * (pi)*r << en;

	return 0;
}


Measured memory_bytes: 3800
S = input()

keyence = 'keyence'

if keyence in S:
    print('YES')
else:
    result = 'NO'
    for i in range(1, len(keyence)):
        delimiters = keyence[:i], keyence[i:]
        if S.startswith(delimiters[0]) and S.endswith(delimiters[1]):
            result = 'YES'
            break
    print(result)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"

int n, m, d;

bool read() {
	if  (scanf("%d%d%d", &n, &m, &d) < 3) {
		return 0;
	}
	return 1;
}

int get(int i, int j) {
	int x = i + j;
	int y = i - j;
	x += 1000 * d;
	y += 1000 * d;
	x /= d;
	y /= d;
	return (x % 2) * 2 + (y % 2);
}

void solve() {
	const string S = "RYGB";
	forn(i, n) {
		forn(j, m) {
			putchar(S[get(i, j)]);
		}
		puts("");
	}
	puts("");
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		solve();
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 512
from collections import Counter
N,K=map(int, raw_input().split())
a=map(int, raw_input().split())
a.sort()
a.reverse()

tmp=[]
tmp_sum=0
b=[]
for i in a:
	if tmp_sum+i>=K:
		b.append(i)	
	else:
		tmp.append(i)
		tmp_sum+=i

if len(b)==0:
	print N
else:
	min_num=b[-1]
	c=Counter(a)
	print N-(a.index(min_num)+c[min_num])


Measured memory_bytes: 3448
N = int(input())

a = list(map(int,input().split()))

count_even = 0
count_odd = 0
for i in range(0,len(a)):
    if a[i] % 2 == 0:
        count_even += 1
        if a[i] % 3 == 0 or a[i] % 5 == 0:
             count_odd += 1

if count_even == count_odd:
    print("APPROVED")
else:
    print("DENIED")

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> L(m);
	vector<int> R(m);
	for(int i=0;i<m;i++) cin >> L[i] >> R[i];
	int left = *max_element(L.begin(),L.end());
	int right = *min_element(R.begin(),R.end());
	int ans = right-left+1;
	if(ans < 0) ans = 0;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>
const int N = 8;

int main() {
  vector<string> v(N);
  REP(i, N) cin >>v[i];
  cout <<"90" <<endl;
  REP(i, N){
    for(int j = N - 1; j >= 0; --j) cout <<v[j][i];
    cout <<endl;
  }
  cout <<"180" <<endl;
  for(int i = N - 1; i >= 0; --i){
    for(int j = N - 1; j >= 0; --j) cout <<v[i][j];
    cout <<endl;
  }
  cout <<"270" <<endl;
  for(int i = N - 1; i >= 0; --i){
    REP(j, N) cout <<v[j][i];
    cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
int n, m, a[100009], b[100009]; bool r[409][409], f[409];
int main() {
	scanf("%d %d", &n, &m);
	for (int i = m - 1; i >= 0; i--) scanf("%d %d", &a[i], &b[i]), a[i]--, b[i]--;
	for (int i = 0; i < n; i++) {
		r[i][i] = true;
		for (int j = 0; j < m; j++) {
			if (r[i][a[j]] && r[i][b[j]]) f[i] = true;
			if (r[i][a[j]]) r[i][b[j]] = true;
			if (r[i][b[j]]) r[i][a[j]] = true;
		}
	}
	int ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			bool ok = true;
			for (int k = 0; k < n; k++) {
				if (r[i][k] && r[j][k]) ok = false;
			}
			if (ok && !f[i] && !f[j]) ret++;
		}
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 1152
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0], m = tmp[1], r = tmp[2];
    long[] s = rdRow;
    s[] -= 1;

    long[][] dist = new long[][](n, n);
    foreach (i; 0 .. n-1)
    {
        foreach (j; i+1 .. n)
        {
            if (i == j) continue;
            dist[i][j] = dist[j][i] = inf;
        }
    }

    foreach (i; 0 .. m)
    {
        tmp = rdRow;
        long a = tmp[0] - 1, b = tmp[1] - 1, c = tmp[2];
        dist[a][b] = dist[b][a] = c;
    }

    foreach (i; 0 .. n)
    {
        foreach (j; 0 .. n)
        {
            foreach (k; 0 .. n)
            {
                dist[j][k] = min(dist[j][k], dist[j][i]+dist[i][k]);
            }
        }
    }

    long result = inf;
    foreach (x; s.permutations)
    {
        long total;
        foreach (i; 0 .. r-1)
        {
            total += dist[x[i]][x[i+1]];
        }
        result = min(result, total);
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int p[n], q[n], t[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        t[i] = i + 1;
    }
    for (int i = 0; i < n; i++) cin >> q[i];
    int a = 0, b = 0, cnt = 0;
    do {
        cnt++;
        bool flag_p = true;
        for (int i = 0; i < n; i++) {
            if (p[i] != t[i]) {
                flag_p = false;
                break;
            }
        }
        bool flag_q = true;
        for (int i = 0; i < n; i++) {
            if (q[i] != t[i]) {
                flag_q = false;
                break;
            }
        }
        if (flag_p) a = cnt;
        if (flag_q) b = cnt;
        if (a && b) break;
    } while (next_permutation(t, t+n));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll              long long int
#define nl              '\n'
using namespace std;

int main(void){

    ll a,b;
        cin>>a;

    for(int i=1; i<=9; i++){
        for(int j=i; j<=9; j++){
            if(i*j==a){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
}


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






int main() {
  int N,Q;cin>>N>>Q;
  vector<int>V(N);
  
  string s;
  cin>>s;
  V[0]=0;
  for(int i=1;i<N;i++){
    if(s[i-1]=='A' && s[i]=='C'){
      V[i]=V[i-1]+1;
    }
    else{V[i]=V[i-1];}
  }
 // for(int i=0;i<N;i++)cout<<V[i]<<endl;
  for(int i=0;i<Q;i++){
    int a,b;cin>>a>>b;
    a--;b--;
    if(a==0)cout<<V[b]<<endl;
    else{
  		cout<<V[b]-V[a]<<endl;
    }
  }
}



Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		sc.close();
		char[] b = a.toCharArray();
		int c = b[0] + 1;
		char d = (char)c;
		System.out.println(d);
	}
}


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

const int MAXN = 300055;

ll B[MAXN];
int A[MAXN];

int N;

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

	cin >> N;
	for(int i = 1; i <= N*3; i++) cin >> A[i];

	{
		priority_queue<int, vector<int>, greater<int>> PQ;
		ll sum = 0;
		for(int i = 1; i <= N; i++) {
			PQ.emplace(A[i]);
			sum += A[i];
		}
		B[N] = sum;
		for(int i = N+1; i <= N*2; i++) {
			PQ.emplace(A[i]);
			sum += A[i];
			sum -= PQ.top();
			PQ.pop();
			B[i] = sum;
		}
	}

	{
		priority_queue<int> PQ;
		ll sum = 0;
		for(int i = N*3; N*2 < i; i--) {
			PQ.emplace(A[i]);
			sum += A[i];
		}
		B[N*2] -= sum;
		for(int i = N*2; N < i; i--) {
			PQ.emplace(A[i]);
			sum += A[i];
			sum -= PQ.top();
			PQ.pop();
			B[i-1] -= sum;
		}
	}

	cout << *max_element(B+N, B+N*2+1) << endl;
	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> P(N);
	for (int i = 0; i < N; i++)
		cin >> P[i];
	vector<int> Q(N);
	for (int i = 0; i < N; i++)
		cin >> Q[i];

	vector<int> v;
	for (int i = 1; i <= N; i++)
		v.push_back(i);

	int count = 0;
	int a, b;
	do {
		count++;
		if (v == P)
			a = count;
		if (v == Q)
			b = count;
	} while (next_permutation(v.begin(), v.end()));

	cout << abs(a - b) << endl;

	return 0;
}

Measured memory_bytes: 3624
K=int(input())
if K==4 :
  print(2)
elif K==6 :
  print(2)
elif K==8 :
  print(5)
elif K==9 :
  print(2)
elif K==10 :
  print(2)
elif K==12 :
  print(5)
elif K==14 :
  print(2)
elif K==16 :
  print(14)
elif K==18 :
  print(5)
elif K==20 :
  print(5)
elif K==21 :
  print(2)
elif K==22 :
  print(2)
elif K==24 :
  print(15)
elif K==25 :
  print(2)
elif K==26 :
  print(2)
elif K==27 :
  print(5)
elif K==28 :
  print(4)
elif K==30 :
  print(4)
elif K==32 :
  print(51)
else :
  print(1)

Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [q, h, s, d] <- fmap read . words <$> getLine :: IO [Int]
    n <- readLn :: IO Int
    let bp2 = minimum [q * 8, h * 4, s * 2, d]
    let ans = case () of
            _ | bp2 == q * 8 -> n * 4 * q
              | bp2 == h * 4 -> n * 2 * h
              | bp2 == s * 2 -> n * s
              | bp2 == d, even n -> (n `div` 2) * d
              | otherwise ->
                    (n `div` 2) * d + minimum [q * 4, h * 2, s]
    print ans

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    string s;
    cout << 0 << endl;;
    cin >> s;
    flush(cout);
    if (s == "Vacant"){
        cout << 0 << endl;
        return 0;
    }
    string sex = s;
    int left = 0, right = n;
    while(true){
        int mid = (right+left) / 2;
        cout << mid << endl;;
        cin >> s;
        flush(cout);
        if (s == "Vacant"){
            cout << mid << endl;
            return 0;
        }
        if (mid % 2 != 0){
            if (sex != s) left = mid;
            else right = mid;
        }else{
            if (sex == s) left = mid;
            else right = mid;
        }
    }
    return 0;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
map<ll,ll>mp;
vector<ll>v;
void pre()
{
  ll i,ans=1;
  v.push_back(ans);
  mp[1]=1;
  for(i=2; i<=40; i++)
  {
    ans=ans*2;
    mp[ans]=i;
    v.push_back(ans);
  }
}

int main()
{
  pre();
  ll n, ans, i,res;
  cin>>n;
  for(i=0; i<v.size(); i++)
  {
    if(n>=v[i])
    {
      ans=mp[v[i]];
    }
  }
  res=pow(2,ans)-1;
  cout<<res<<endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};

fn main() {
    let _n = read_i64() as usize;
    let ys = {
        let mut ys = vec![];
        let mut xs = read_vec_i64();
        ys.push(0);
        ys.append(&mut xs);
        ys.push(0);
        ys
    };
    let mut max_len = 0;
    for ts in ys.windows(2) {
        max_len += (ts[1]-ts[0]).abs();
    }
    for ts in ys.windows(3) {
        let res = max_len - (ts[1]-ts[0]).abs() - (ts[2]-ts[1]).abs() + (ts[2]-ts[0]).abs();
        println!("{}", res);
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 8444
# 2000枚を3つに分ける方法は
# 2000**3 = 10**9 (*6) -> 総当りは間に合わなそう.
import sys

N, Y = map(int, input().split())

sagaku = (10000 * N) - Y
if sagaku < 0:
    print(-1, -1, -1)
    sys.exit()

for y in range(0, N+1):
    for z in range(0, N-y+1):
        if sagaku == 5000*y + 9000*z:
            print(N-y-z, y, z)
            sys.exit()
print(-1, -1, -1)

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int>> dist(n, vector<int>(n, inf));
    rep(i, n) dist[i][i] = 0;
    rep(_, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = dist[b][a] = c;
    }
    rep(_, 3) rep(i, n) rep(j, n) rep(k, n) {
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
    }
    vector<vector<int>> dist2(n, vector<int>(n, inf));
    rep(i, n) rep(j, n) {
        if (dist[i][j] <= l) dist2[i][j] = 1;
    }
    rep(k, n) rep(i, n) rep(j, n) {
        chmin(dist2[i][j], dist2[i][k] + dist2[k][j]);
    }
    int q;
    cin >> q;
    rep(_, q) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        int ans = dist2[s][t] - 1;
        if (dist2[s][t] == inf) ans = -1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
def slove():
    import sys
    input = sys.stdin.readline
    a = []
    k, x = list(map(int, input().rstrip('\n').split()))
    for i in range(x, x - k, -1):
        if i not in a:
            a.append(i)
    for i in range(x, x + k):
        if i not in a:
            a.append(i)
    print(*sorted(a))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sidha(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int> 
#define pb push_back
#define st string
#define pairi pair<int,int>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
		ll n;cin>>n;
		ll arr[n];
		ll m=INT_MIN,x=-1;
		sidha(i,0,n){
			cin>>arr[i];
		}
		ll mx=arr[0];
		ll brr[n];
		brr[0]=arr[0];
		for(int i=0;i<n;i++){
			mx=max(mx,arr[i]);
			brr[i]=max(mx,arr[i]);
			//cout<<brr[i]<<" ";
		}
		//cout<<endl;
		ll sum=0;
		sidha(i,0,n){
			sum+=(brr[i]-arr[i]);
			//cout<<sum<<" ";
		}
		cout<<sum<<endl;
}


Measured memory_bytes: 6776
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {
  int n;
  int ans=0;
  cin>>n;
  vector<pair<int, int> > v(n);
  for(int i=0; i<n; i++) {
    int a, b;
    cin>>a>>b;
    v[i]={a, b};
  }
  sort(v.begin(), v.end());
  ans+=n+v[0].first-1;
  for(int i=0; i<n-1; i++) {
    ans+=v[i+1].first-v[i].first-1;
  }
  ans+=v[n-1].second;
  cout<<ans<<endl;
  return 0;
}


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

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 ll L,R;
  cin>>L>>R;
    if((R-L)>2019){     //(L-1) / 2019 != R / 2019) {
        cout << 0 << endl; return 0;
    }

   int ans = 2018;
     L = L % 2019; R = R % 2019;
    FOR(i, L, R+1) {
        FOR(j, i+1, R+1) {
            ans = min(ans, (i*j)%2019);
        }
    }
    cout << ans << endl;

   }



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;
using ll = long long;

int main() {
	int a, b,suma,sumb ,n,ans=1000000;
	cin >> n;
	for (int i = 1; i < n; i++){
		suma = 0;
		sumb = 0;
		a = i;
		b = n - i;
		int dig;
		while (a) {
			dig = a % 10;
			suma = suma + dig;
			a = a / 10;
		}
		while (b) {
			dig = b % 10;
			sumb = sumb + dig;
			b = b / 10;
		}

		ans = min(ans, suma +sumb);
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

int f[4];

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    string a, b;
    int n;
    cin >> n;
    cin >> a >> b;
    for (int i = 0; i < n * 2; i++) {
        if (i % 2)
            cout << b[i / 2];
        else
            cout << a[i / 2];
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    System.out.println(A == B && B == C ? "Yes" : "No");
  }
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int MAX_N = 300000;

int N;
std::string s;
int cntW[MAX_N+1], cntE[MAX_N+1];
int ans;

int main()
{
  std::cin >> N >> s;

  ans = N;

  rep( i, N )
  {
    cntW[i+1] = cntW[i]+(s[i] == 'W');
    cntE[i+1] = cntE[i]+(s[i] == 'E');
  }

  rep( i, N )
    ans = std::min( ans, cntW[i]+(cntE[N]-cntE[i+1]) );

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

  return 0;
}

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

int main(){
  long long n,a[5];
  a[0] = 2;
  a[1] = 1;
  a[2] = 1;
  cin >> n;
  int i = 2;
  for (; i <= n ; i++){
    a[2] = a[1] + a[0];
    a[0] = a[1];
    a[1] = a[2];

  }
  cout << a[2] << endl;
}


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

#[fastout]
fn main() {
  input! {
      s:String
  };
  // 0:5, 1:7, 2:5, 3:6
  let words: [&str; 4] = ["dream", "dreamer", "erase", "eraser"];
  let mut dp = [""; 100_001];
  dp[0] = "start";

  for i in 0..s.len() + 1 {
    for item in words.iter() {
      let len = item.len();
      if i >= len {
        if *item == &s[i - len..i] && dp[i - len] != "" {
          dp[i] = *item;
        }
      }
    }
  }

  if dp[s.len()] != "" {
    println!("YES");
  } else {
    println!("NO");
  }
}


Measured memory_bytes: 3948
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;



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

	vector<int>ac(N + 1), bc(N + 1);
	REP(i, N) {
		ac[a[i]]++;
		bc[b[i]]++;
	}
	REP(i, N) {
		ac[i + 1] += ac[i];
		bc[i + 1] += bc[i];
	}
	int rot = 0;
	REP(i, N) {
		CHMAX(rot, ac[i + 1] - bc[i]);
		if(ac[i + 1] - ac[i] + bc[i + 1] - bc[i] > N) {
			out("No");
			return 0;
		}
	}
	out("Yes");
	REP(i, N) {
		cout << b[(i - rot + N) % N] << " \n"[i + 1 == N];
	}
}

Measured memory_bytes: 9576
import sys

n = int(input())

A = list(map(int, input().split()))

m = max(A)

C = [0] * (10**6 + 1)

dp = [True] * m

for a in A:
  if C[a] > 0:
    C[a] += 1
    continue
  C[a] += 1
  i = 2
  while a * i <= m:
    dp[a*i - 1] = False
    i += 1
    
ans = 0

for a in A:
  if C[a] < 2 and dp[a - 1] == True:
    ans += 1

print(ans)

Measured memory_bytes: 34340
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
int gcd(int a,int b)
{
	if(a%b==0)
		return b;
	else
		return gcd(b,a%b);
}
int h[100007],dp[100007];
void solve()
{
    int n,sol=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n-1];
}
int main()
{
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return(0);
}


Measured memory_bytes: 1024
# frozen_string_literal: true

n = gets.to_i
x = gets.split.map(&:to_i)

m = x.reduce(:+) / n

s1 = x.map { |e| (e - m) ** 2 }.reduce(:+)
s2 = x.map { |e| (e - m - 1) ** 2 }.reduce(:+)

puts [s1, s2].min


Measured memory_bytes: 1788
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())

A = list(map(int, readline().split()))
B = list(map(int, readline().split()))


def convert(A):
    return [x ^ y for x, y in zip(A, A[1:])] + [A[-1] ^ A[0]]


C = convert(A)
D = convert(B)


def Z_algorithm(S):
    # 共通接頭辞の長さを返す
    N = len(S)
    arr = [0] * N
    arr[0] = N
    i, j = 1, 0
    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1
        arr[i] = j
        if not j:
            i += 1
            continue
        k = 1

        while i + k < N and k + arr[k] < j:
            k += 1
        i += k
        j -= k

    return arr


Z = Z_algorithm(D + [-1] + C + C)[N + 1:N + N + 1]

K = [i for i, x in enumerate(Z) if x == N]
X = [A[k] ^ B[0] for k in K]

print('\n'.join('{} {}'.format(k, x) for k, x in zip(K, X)))

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

const int N=20010;
int n,x[N],y[N];
pair<int,int>a[N];
stack<int>stk;
bitset<N>now,G[N],revG[N],odd,vis;

void dfs(int x){
	now[x]=0;
	for(;;){
		int y=(now&G[x])._Find_first();
		if(y<N)dfs(y);else break;
	}
	stk.push(x);
}
void dfs2(int x){
	now[x]=0;
	for(;;){
		int y=(now&revG[x])._Find_first();
		if(y<N)dfs2(y);else break;
	}
	vis[x]=1;
}

bool chk(int m){
	int L=2*n;
	for(int i=1;i<=n;++i)a[2*i-1]=make_pair(x[i],2*i-1),a[2*i-2]=make_pair(y[i],2*i-2);
	sort(a,a+L);
	vis.reset();now.reset();
	for(int i=0,j=0,k=-1;i<L;++i){
		for(;k<L-1&&a[k+1].first<a[i].first+m;++k,vis[a[k].second]=now[a[k].second^1]=1);
		for(;a[j].first+m<=a[i].first;vis[a[j].second]=now[a[j].second^1]=0,++j);
		G[a[i].second]=now;revG[a[i].second^1]=vis;
	}
	for(int i=0;i<L;++i)G[i][i^1]=revG[i][i^1]=G[i][i]=revG[i][i]=0,now[i]=1;
	while(!stk.empty())stk.pop();
	for(int i=0;i<L;++i)if(now[i])dfs(i);
	for(int i=0;i<L;++i)now[i]=1;
	for(;!stk.empty();){
		int x=stk.top();stk.pop();if(!now[x])continue;vis.reset();
		dfs2(x);if(((vis&(vis<<1))&odd).any())return 0;
	}
	return 1;
}


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)odd[2*i-1]=1;
	for(int i=1;i<=n;++i)cin>>x[i]>>y[i];
	int L=0,R=1000000000;
	while(L<R){
		int mid=(L+R+1)/2;
		if(chk(mid))L=mid;
		else R=mid-1;
	}
	cout<<L<<'\n';
	return 0;
}


Measured memory_bytes: 148608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

const int nmax = 2 * 100005;
int gr1[nmax];
int gr2[nmax];
bool visit[nmax];
typedef pair<int, int> P;
map<P, int> MAP;
vector<vector<int> > g1(nmax);
vector<vector<int> > g2(nmax);
int sg, ng; // set group , new group
int N, K, L;

void dfs1(int x){
  visit[x] = true;
  gr1[x] = sg;
  for (auto &nx : g1[x]) {
    if(visit[nx]) continue;
    dfs1(nx);
  }
  return;
}

void dfs2(int x){
  visit[x] = true;
  gr2[x] = sg;
  for (auto &nx : g2[x]) {
    if(visit[nx]) continue;
    dfs2(nx);
  }
  return;
}

int main(){
  cin >> N >> K >> L;
  // 道路で同じ組みかどうか
  FOR(i,0,N) visit[i] = false;
  FOR(i,0,K){
    int a, b;
    cin >> a >> b;
    a--;b--;
    g1[a].push_back(b);
    g1[b].push_back(a);
  }
  sg = 0;
  for (int i = 0; i < N; i++){
    if(!visit[i]) dfs1(i);
    sg++;
  }

  // 鉄道で同じかどうか
  FOR(i,0,N) visit[i] = false;
  FOR(i,0,L){
    int a, b;
    cin >> a >> b;
    a--;b--;
    g2[a].push_back(b);
    g2[b].push_back(a);
  }
  sg = 0;
  for (int i = 0; i < N; i++){
    if(!visit[i]) dfs2(i);
    sg++;
  }

  FOR (i,0,N) MAP[P(gr1[i], gr2[i])]++;
  FOR(i,0,N){
    printf("%d%c", MAP[P(gr1[i], gr2[i])], i == N - 1 ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 28160