akhauriyash/Code-Regression huggingface dataset:
// Snippets
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

macro_rules! stdin {
    () => ({
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    })
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => (
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input.to_string()), $output);
            )*
        }
    )
}

// End Snippets

fn main() {
    println!("{}", solve(stdin!()));
}

fn solve(src: String) -> String {
    input!{
        source = src,
        s: chars,
    }
    let mut bwb = 0;
    let mut wbw = 0;
    for i in 0..s.len() {
        if i % 2 == 0 {
            match s[i] {
                '0' => wbw += 1,
                '1' => bwb += 1,
                _ => (),
            }
        } else if i % 2 == 1 {
            match s[i] {
                '0' => bwb += 1,
                '1' => wbw += 1,
                _ => (),
            }
        }
    }
    let ans = std::cmp::min(bwb, wbw);
    ans.to_string()
}

test! {
    "000" => "1",
    "10010010" => "3",
    "0" => "0",
}


Measured memory_bytes: 4476
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
ll N,A,B;
vector<ll>h(100005);
bool isOK(ll mid){
	ll ret=0;
	for(int i=0;i<N;i++){
		if(h[i]-mid*B>0){
			ret+=(h[i]-mid*B+(A-B)-1)/(A-B);
		}
	}
	return ret<=mid;
}


int main(){
	init();
	ll N;cin>>N;
	string s;cin>>s;
	ll left=0;
	ll right=0;
	string ans;
	for(int i=0;i<N;i++){
		if(s[i]=='(')left++;
		if(s[i]==')')right++;
		if(right>left){
			right=left;
			ans.push_back('(');
		}
	}
	ans+=s;
	right=0;
	left=0;
	for(int i=0;i<ans.size();i++){
		if(ans[i]=='(')left++;
		if(ans[i]==')')right++;
	}
	//cout<<left-right<<endl;
	for(int i=0;i<left-right;i++)ans.push_back(')');
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
import copy
N=int(input())
a=[0]*(N+1)
cnta=copy.copy(a)
for i in range(1,N+1):
    a[i]=int(input())

button=1

for i in range(100000):
    cnta[button]=cnta[button]+1
    if cnta[2]==1:
        print(sum(cnta)-1)
        break
    elif cnta[button]>=2:
        print("-1")
        break
    button=a[button]
    


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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] p = new int[n];
            for(int i = 0; i < n;i++)
            {
                p[i] = int.Parse(Console.ReadLine());
            }
            Console.WriteLine(p.Sum() - p.Max() / 2);
        }
    }
}


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

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

  ll N; cin >> N;
  vector<ll> R(N); for (ll i = 0; i < N; i++) cin >> R[i];

  vector<ll> MIN(N + 1, 1e10);
  vector<ll> MAX(N + 1, -1);
  for (ll i = 1; i < N + 1; i++) { // 1 to N
    MIN[i] = min(MIN[i - 1], R[i - 1]);
  }
  for (ll i = N - 1; i >= 0; i--) { // 0 to N - 1
    MAX[i] = max(MAX[i + 1], R[i]);
  }
  ll ans = -1e9;
  for (ll i = 0; i < N; i++) {
    ans = max(ans, MAX[i] - MIN[i]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 7600
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    h, a = MAP()
    count = 0
    while h > 0:
        h = h - a
        count += 1
    print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 5728
object Main extends App{

  override def main(args : Array[String]) : Unit = {
     val str = io.StdIn.readLine.split(' ')
     
     val init = new Dice(str(0),str(1),str(2),str(3),str(4),str(5))
     val ops = io.StdIn.readLine
     
     val dice = ops.foldLeft(init)((z,n)=>
       n match {
         case 'N' => z.toNorth
         case 'S' => z.toSouth
         case 'W' => z.toWest
         case 'E' => z.toEast
       }
     )
     
     println(dice.top)
  }
  
  case class Dice(top: String, south: String, east: String, west: String, north: String, buttom: String) {

    def toNorth: Dice = {
      new Dice(south, buttom, east, west, top, north)
    }
    def toSouth: Dice = {
      new Dice(north, top, east, west, buttom, south)
    }
    def toEast: Dice = {
      new Dice(west, south, top, buttom, north, east)
    }
    def toWest: Dice = {
      new Dice(east, south, buttom, top, north, west)
    }

  }

}

Measured memory_bytes: 43892
# sys.stdin.readline()
import sys
input = sys.stdin.readline
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
    ans = n - (a[0][1]+b[0][1])
else:
    ans = min(n - (a[1][1]+b[0][1]), n - (a[0][1]+b[1][1]))
print(ans)

Measured memory_bytes: 20636
import java.util.Random;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int[] d = new int[6];

		Dice dice=new Dice();//クラスDiceを定義

		for (int i = 0; i < 6; i++) {
			d[i] = scanner.nextInt();
			dice.num[i]=d[i];//Diceクラスの変数numに代入
		}

		int q = scanner.nextInt();

		for(int i=0;i<q;i++){
			int head =scanner.nextInt();
			int flont=scanner.nextInt();
		
			dice.Roll(head,flont);
			
			System.out.println(dice.num[2]);
			
		}
		

		scanner.close();
	}
}


class Dice {
	Random rand = new Random();
	int num [];
	Dice(){
		num= new int[6];
	}
	
	int box=0;

	public void Roll(int head,int flont) {
	
		while(true){
			
			if((head == num[0])&&(flont == num[1])){
				break;
				}
			
		 int random = rand.nextInt(4); 
			switch(random){//配列の各数字をサイコロの展開図に見立て動きを再現

			case 0:

				box=num[0];
				num[0]=num[4];
				num[4]=num[5];
				num[5]=num[1];
				num[1]=box;


				break;

			case 1 :

				box=num[0];
				num[0]=num[1];
				num[1]=num[5];
				num[5]=num[4];
				num[4]=box;


				break;

			case 2 :

				box=num[0];
				num[0]=num[2];
				num[2]=num[5];
				num[5]=num[3];
				num[3]=box;


				break;

			case 3:


				box=num[0];
				num[0]=num[3];
				num[3]=num[5];
				num[5]=num[2];
				num[2]=box;


				break;

			}
			

		}
	}}




Measured memory_bytes: 26092
def c_zigzag():
    from collections import Counter
    N = int(input())
    V = [int(i) for i in input().split()]

    # 数列の(偶数|奇数)番目の要素のうち、出現頻度が高いもの上位2つを求める
    count_seq_even = Counter(V[::2]).most_common(2)
    count_seq_odd = Counter(V[1::2]).most_common(2)

    # 偶数番目を抜き出した数列と奇数番目を抜き出した数列のそれぞれについて
    # 最も出現頻度の高い要素を調べ、各々それに書き換えればいい。
    # ただし、それらが一致する場合は両方ともその要素に書き換えられないので、
    # 2番目に出現回数の多い要素も(あれば)調べておく。(3番以下を見る必要はない)

    # 両方の数列についてそれぞれ1種の要素しかなく、かつそれらが一致する
    # (全要素が等しい値)場合は、奇数番目か偶数番目かどちらかの要素を
    # すべて書き換えなければならない
    if (len(count_seq_even) == 1 and len(count_seq_odd) == 1
            and count_seq_even[0] == count_seq_odd[0]):
        return N // 2

    ans = float('inf')
    for e, ve in count_seq_even:
        for o, vo in count_seq_odd:
            if e == o:
                continue  # 一致している場合は書き換えられない
            ans = min(ans, N - (ve + vo))
    return ans

print(c_zigzag())

Measured memory_bytes: 15588
#include <stdio.h>
#include<string.h>

int main(){
  char day_of_week[7][4] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  char s[4];
  int r = 0;
  scanf("%s",s);
  for(int i = 0; i < 7;i++){
    if(strcmp(day_of_week[i],s)==0){
      r = 7 - i;
      printf("%d",r);
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n=0,cnt=0,p=1,sum=0;
    char s[8];
    cin >> s ;
    while(s[cnt]!=0){
        cnt++;
    }
    for(int i=cnt-1;i>=0;i--){
        n+=(s[i]-'0')*p;
        p*=10;
        sum+=(s[i]-'0');
    }
    if(n%sum==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int k; cin >> k;
    int a, b; cin >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      sum += b - a + 1;
    }
    cout << sum << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
a,b = map(int,input().split())

tax1 = int(a/0.08)
tax2 = int(b/0.1)
en = 0
l = sorted([tax1,tax2])
for i in range(l[0]-1,l[1]+2):
    if int(i*0.08) == a and int(i*0.1) == b:
        print(i)
        en = 1
        break
if en == 0:
    print(-1)

Measured memory_bytes: 3064
#include<iostream>
#define L 1000000000000000000
using namespace std;

int main()
{
  int n,count=0;
  cin >> n;
  long long m[1000000],total=1;
  for(int i=0; i<n; i++){
    cin >> m[i];  
    //cout << m[i] << endl;
    if(m[i]==0)
      count++;
    
  }   
  if(count>0){
   cout << 0 << endl;
    return 0;
  }
  
    for(int i=0; i<n; i++){
      if(m[i] <= L/total){
        total *= m[i];
      }
      else { 
        cout << -1 << endl;
        return 0;
      }
    }

    cout << total  << endl; 

  } 
   



Measured memory_bytes: 3912
#include<stdio.h>
main(){
  int n,a,b,c,d,x=0;

  while(scanf("%d",&n) != EOF){
    x=0;
    for(a=0 ; a<=9 ; a++){
      for(b=0 ; b<=9 ; b++){
	for(c=0 ; c<=9 ; c++){
	  for(d=0 ; d<=9 ; d++){
	    if(a + b + c + d == n){
	      x=x+1;  /*組み合わせの数を計算*/
	    }
	  }
	}
      }
    }
    printf("%d\n",x);
  }

  return 0;
}

Measured memory_bytes: 596
import sys 
import math
try:
	sys.stdin = open('input.txt', 'r') 
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(1):
	a,b,c,d = map(int,input().split())
	if math.ceil(c/b) - math.ceil(a/d)<= 0:
		print ("Yes")
	else:
		print("No")
	

Measured memory_bytes: 9180
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int res[510][510];
void dfs(int l,int r,int deep)
{
//	cout<<l<<" "<<r<<endl;
	if(l+1==r)
	{
		res[l][r]=deep;res[r][l]=deep;return;
	}
	if(l==r) return;
	for(int i=l;i<=(l+r)/2;i++)
	{
		for(int j=(l+r)/2+1;j<=r;j++)
		{
			res[i][j]=deep;
			res[j][i]=deep;
		}
	}
	dfs(l,(l+r)/2,deep+1);
	dfs((l+r)/2+1,r,deep+1);
}
int main()
{
	int n;
	scanf("%d",&n);
	dfs(1,n,1);
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			printf("%d ",res[i][j]);
		}
		printf("\n");
	}
 } 

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int> v(n),b(n),c(n);
    for(int i=0;i<n;i++)    cin >> b[i];
    for(int i=0;i<n;i++)    cin >> c[i];
    for(int i=0;i<n;i++){
        v[i] = i+1;
    }
    int B=-1,C=-1;
    int count=0;
    bool flag1,flag2;
    do{
        count++;
        flag1=0,flag2=0;
        for(int i=0;i<n;i++){
            if(b[i]!=v[i]) flag1=1;
            if(c[i]!=v[i]) flag2=1;
        }
        if(flag1==0)   B = count;
        if(flag2==0)   C = count;
    }while( next_permutation(v.begin(), v.end()) ); 
    cout << abs(B-C) << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	str := "CODEFESTIVAL2016"
	var input string
	fmt.Scan(&input)
	a := 0
	for i := 0; i < len(str); i++ {
		if str[i] != input[i] {
			a++
		}
	}
	fmt.Println(a)
}

Measured memory_bytes: 512
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
ll mod=1000000007;

ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}

int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int k,x;
    cin>>k>>x;
    int ans=k*500;
    if(ans<x)cout<<"No";
    else cout<<"Yes";

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, x = Is()
A = LI()
ans = 0
for i in range(n-1):
    y = A[i]+A[i+1] - x
    if y > 0:
        ans += y
        if A[i+1] >= y:
            A[i+1] -= y
        else:
            A[i+1] = 0
            A[i] -= y - A[i+1]

print(ans)


Measured memory_bytes: 88940
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

template<typename T> vector<T> maximumSubArray(const vector<T> &v) {
  int n = v.size();
  vector<T> dp(n);
  dp[n - 1] = v[n - 1];
  for (int i = n - 2; i >= 0; i--) dp[i] = max(v[i], v[i] + dp[i + 1]);
  auto begin = max_element(all(dp));
  int l, r;
  l = r = distance(dp.begin(), begin);
  int maxSum = *begin, acc = 0;
  while (acc != maxSum) acc += v[r++];
  return vector<T>(v.begin() + l, v.begin() + r);
}

main {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    vector<int> a(n);
    cin >> a;
    auto v = maximumSubArray(a);
    cout << accumulate(all(v), 0LL) << endl;
  }
}



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

int main() {
	int N;
	cin >> N;
	int t[N+1]={0},x[N+1]={0},y[N+1]={0};
	for(int i=1; i<N+1; i++) cin >> t[i] >> x[i] >> y[i];

	for(int i=0; i<N; i++) {
		int dis=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
		if(t[i+1]-t[i]-dis<0||(t[i+1]-t[i]-dis)%2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int n;
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	if(n==3){
		cout << "2 5 63\n";
		return 0;
	}
	if(n==4){
		cout << "2 5 20 63\n";
		return 0;
	}
	int num=0;
	for(int i=0; i<(n+3)/4-1 ;i++){
		cout << (i*6+2) << ' ' << (i*6+3) << ' ' << (i*6+4) << ' ' << (i*6+6) << ' ';
		num=3-num;
	}
	int num2=(n-1)%4+1;
	int lol=(n+3)/4-1;
	if(num2==1 && num==0) cout << lol*6+6 << endl;
	if(num2==1 && num==3) cout << lol*6+3 << endl;
	if(num2==2 && num==0) cout << lol*6+2 << ' ' << lol*6+4 << endl;
	if(num2==2 && num==3) cout << lol*6+3 << ' ' << lol*6+6 << endl;
	if(num2==3 && num==0) cout << lol*6+2 << ' ' << lol*6+4 << ' ' << lol*6+6 << endl;
	if(num2==3 && num==3) cout << lol*6+2 << ' ' << lol*6+3 << ' ' << lol*6+4 << endl;
	if(num2==4 && num==0) cout << lol*6+2 << ' ' << lol*6+4 << ' ' << lol*6+6 << ' ' << lol*6+12 << endl;
	if(num2==4 && num==3) cout << lol*6+2 << ' ' << lol*6+3 << ' ' << lol*6+4 << ' ' << lol*6+6 << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#define FOR(i,m,n) for(i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
int main(void)
{
  int n,dp[31],i;
  dp[0]=dp[1]=1;dp[2]=2;
  FOR(i,3,31)dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
  for(;;){
    scanf("%d",&n);if(!n)break;
    printf("%d\n",(dp[n]+3649)/3650);
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws Exception {
		FastScanner scanner = new FastScanner(System.in);
		int width = (int) scanner.nextInt();
		int personWidth = (int) scanner.nextInt();
		int gap = (int) scanner.nextInt();

		PrintWriter printWriter = new PrintWriter(System.out);
		printWriter.printf("%d\n", (width-gap)/(personWidth+gap));
		printWriter.close();
	}

	static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public long nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = (int) nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}


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

signed main() {
  string S;
  cin >> S;
  
  int n = (int)S.size();
  if( n <= 7 ){
    cout << "YES" << endl;
  }else{
    int win = 0;
    for( int i = 0; i < n; i++ ){
      if( S.at(i) == 'o' ) win++;
    }
    if( win + (15 - n) > 7 ){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  
}

Measured memory_bytes: 256
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def main():

    N=int(input())
    S=list(input())
    K=int(input())

    d = S[K-1]

    for i in range(N):
        if S[i] !=d:
            S[i] ="*"

    print(*S,sep="")



if __name__ == "__main__":
    main()


Measured memory_bytes: 8952
n = input()
n = n[::-1]
l = len(n)
ans = 0
flg = 0
x = []
for j in range(l):
  i = n[j]
  i = int(i)
  i += flg
  if i >= 6:
    ans += (10-i)
    flg = 1
  elif i == 5:
    if j == l-1:
      ans += i
      flg = 0
    elif int(n[j+1]) >= 5:
      ans += (10-i)
      flg = 1
    else:
      ans += i
      flg = 0
  else:
    ans += i
    flg = 0
if flg:
  ans += 1
print(ans)

Measured memory_bytes: 5492
import sys
input = sys.stdin.readline

n = int(input())
As = [int(round(float(input())*10**9)) for _ in  range(n)]

fives = [0] * n
twos = [0] * n
cnts = [[0] * 20 for i in range(20)]
for i, a in enumerate(As):
    tmp = a
    five = 0
    two = 0
    while tmp % 5 == 0:
        five += 1
        tmp //= 5
    while tmp % 2 == 0:
        two += 1
        tmp //= 2
    cnts[min(two,18)][min(five,18)] += 1

# fiveの和とtwoの和が共に18以上ならOK
# 条件を満たすcnts        
ans = 0
for i1 in range(19):
    for j1 in range(19):
        for i2 in range(19):
            for j2 in range(19):
                if i1+i2 >= 18 and j1+j2>=18:
                    ans += cnts[i1][j1]*cnts[i2][j2]

# 自分自身を除外
for i in range(19):
    for j in range(19):
        if i*2 >= 18 and j*2 >= 18:
            ans -= cnts[i][j]

# ダブルカウント
ans //= 2
print(ans)

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

int main(){
  int n,a;
  double d = 0.0;
  cin >> n;
  for(int i = 0;i<n;i++){
    cin >> a;
    d += (double)1/a;
  }
  cout << 1/d << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 100000



int main(){
	int w;
	bool ans[10];
	for(int i=0;i<11;i++){
		ans[i]=0;
	}
	while(cin>>w){
		
		for(int i=0;i<11;i++){
			ans[i]=0;
		}
		for(int i=10;i--;){
			if(w>=pow(2,i)){
				ans[i]=1;
				w=w-pow(2,i);
			}
		}
		
		int i=0;
		for(;i<11;i++){
			if(ans[i]){
				cout<<pow(2,i);
				break;
			}
		}i++;
		for(;i<11;i++){
			if(ans[i]){
				cout<<" "<<pow(2,i);
			}
		}cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1272
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var a = r[0].ToLong();
            var b = r[1].ToLong();
            //最大公約数を求める
            long now = Gcd(a, b);
            long i = 2;
            long ans = 1;
            //
            while (i <= Math.Sqrt(now))
            {
                if (now % i == 0)
                {
                    ans += 1;
                    while (now % i == 0)
                    {
                        now /= i;
                    }
                    continue;
                }
                else
                {
                    i++;
                }
            }
            //割り切れなかった素数の回数を足す
            if (now != 1) ans++;
            WriteRead(ans);
        }

        public static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToLong(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
long long a[100005],mod=1e9+7;
map<long long,long long> m;
int main(){
	long long n,ans=1;
	cin>>n;m[-1]=3;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		ans=ans*(m[a[i]-1]-m[a[i]])%mod;
		m[a[i]]++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 7296
package main

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

func main() {
	// H := nextInt()
	// W := nextInt()
	var H, W int
	fmt.Scan(&H, &W)
	A := make([][]byte, H)
	for i := 0; i < H; i++ {
		var line string
		fmt.Scan(&line)
		A[i] = []byte(line)
		// A[i] = nextBytes()
		// if len(A[i]) != W {
		// panic("W")
		// }
	}
	q := make([]Pair, 0)
	next := make([]Pair, 0)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if A[i][j] == '#' {
				next = append(next, Pair{i, j})
			}
		}
	}
	ans := 0
	for len(next) != 0 {
		q = make([]Pair, 0)
		for _, n := range next {
			q = append(q, n)
		}
		next = make([]Pair, 0)
		for len(q) != 0 {
			p := q[len(q)-1]
			q = q[:len(q)-1]
			for d := 0; d < 4; d++ {
				ny := p.a + dy[d]
				nx := p.b + dx[d]
				if ny < 0 || ny >= H || nx < 0 || nx >= W {
					continue
				}
				if A[ny][nx] == '.' {
					A[ny][nx] = '#'
					next = append(next, Pair{ny, nx})
				}
			}
		}
		ans++
		// log.Println(next)
		// for i := 0; i < H; i++ {
		// 	log.Println(string(A[i]))
		// }
	}
	fmt.Println(ans - 1)
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type pairs []Pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}
func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 74240
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll w,n,h,k;
 sc(w);sc(h);sc(n);
 ll a[n+10],l[n+10],m[n+10];
 bool xy[w+10][h+10];
 
 rep(i,0,w+1){
  rep(j,0,h+1){
   xy[i][j]=false;
  }
 }
 rep(i,0,n){
  sc(l[i]);sc(m[i]);sc(a[i]);

 if(a[i]==1){
   rep(j,0,l[i]+1){
    rep(k,0,1+h){
     xy[j][k]=true;
    }
   }
  }
  if(a[i]==2){
   rep(j,l[i]+1,1+w){
    rep(k,0,1+h){
     xy[j][k]=true;
    }
   }
  }
  if(a[i]==3){
   rep(j,0,m[i]+1){
    rep(k,0,1+w){
     xy[k][j]=true;
    }
   }
  }
  if(a[i]==4){
   rep(j,m[i]+1,h+1){
    rep(k,0,1+w){
     xy[k][j]=true;
    }
   }
  }
  
 }

 ll ans=0;
 rep(i,1,w+1){
  rep(j,1,h+1){
   if(xy[i][j]==false)
     ans++;
  }
 }
 pr(ans);
  return 0;}

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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % mod_;
      inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
      finv[i] = finv[i - 1] * inv[i] % mod_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
  init();

  double w, h, x, y;
  cin >> w >> h >> x >> y;

  double marea = w * h / 2;
  cout << marea << " " << (x == w / 2 && y == h / 2) << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
for D in range(1, 10000000):
  if N <= 26 ** D:
    break
  N -= 26 ** D
#print(N)
N -= 1

ans = []
for d in range(D):
  ans.append(chr(ord('a') + N % 26))
  N //= 26
print(''.join(ans[::-1]))
    
    

Measured memory_bytes: 9212
n, k = map(int, input().split())
ball = list(map(int, input().split()))

written = set(ball)
count = [0 for _ in range(max(written))]

if len(written) > k:
    for i in ball:
        count[i - 1] += 1
rewrite = [c for c in count if c > 0]
rewrite.sort()
print(sum(rewrite[: len(written) - k]))

Measured memory_bytes: 27012
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()
    b = na()

    a_cnt = 0
    b_cnt = 0

    for ai, bi in zip(a, b):
        tmp = bi - ai
        if tmp < 0:
            b_cnt += abs(tmp)
        elif tmp > 0:
            a_cnt += (tmp + 1) // 2
            b_cnt += tmp % 2
        # print(ai, bi, a_cnt, b_cnt)

    print("Yes" if a_cnt >= b_cnt else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 66156
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	int a[3];
	for(int i = 0;i < 3;i++){
		cin >> a[i];
	}
	sort(a, a + 3);
	if(a[0] == 5 && a[1] == 5 && a[2] == 7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    a = INT()
    s = INPUT()

    if a >= 3200: print(s)
    else: print('red')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38492
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int main() {
    int n, a[2];
    ll r = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i % 2];
        if (a[(i + 1) % 2] && a[i % 2]) {
            a[i % 2]--;
            r++;
        }
        r += a[i % 2] / 2;
        a[i % 2] = a[i % 2] % 2;
    }
    cout << r << endl;
}

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

using namespace std;

int main(void) {
    int N;
    vector<int> A;
    cin >> N;
    vector<int> ans(N, 0);
    // A.push_back(0);

    for (int i = 0; i < N-1; i++) {
        int temp;
        cin >> temp;
        ans[temp-1]++;
    }

    for (auto& i: ans) {
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}
template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
//Auther: Arin Roday
#define vec vector
#define i64 long long
#define endl '\n'
#define sz(x) (x).size()
#define times(n) for(int i = 0; i < (n); ++i)
#define bits(x) __builtin_popcount(x)
 
int test_case_number = 1;

void print_case(){
    #ifdef LOCAL
    cout << "Case #" << test_case_number++ << ": ";
    #endif
}

void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int w_count = 0, r_count = 0;
    for(char ch : s){
        if(ch == 'W') 
            w_count ++;
        else 
            r_count ++;
    }
    int ans = 0;
    for(int i = 0; i < r_count; ++i){
        if(s[i] == 'W')
            ans ++;
    }
    cout << ans << endl;
}
 
int main(){ 
    solve();
}

Measured memory_bytes: 3700
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	s := scanString(sc)
	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}
	Count := 0
	for i := 1; i < len(s); i++ {
		if s[i] == 'C' && i > 1 && i < len(s)-1 {
			Count++
			continue
		}
		if !small(s[i]) {
			fmt.Println("WA")
			return
		}
	}
	if Count != 1 {
		fmt.Println("WA")
		return
	}
	fmt.Println("AC")
}

func small(c byte) bool {
	return c >= 'a' && c <= 'z'
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1776
S=[int(i) for i in input()]
N=len(S)
e=[]
o=[]
for i in range(N):
    if i%2==0:
        e.append(S[i])
    else:
        o.append(S[i])

e0=e.count(0)
e1=e.count(1)
o0=o.count(0)
o1=o.count(1)
print(N-max(e0+o1,e1+o0))

Measured memory_bytes: 47068
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf LLONG_MAX

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll x,n;
        cin>>x>>n;

        set<ll> st;

        for(ll i=-105;i<=105;i++)
        st.insert(i);

        for(ll i=0;i<n;i++)
        {
            ll p;
            cin>>p;

            st.erase(p);
        }

        ll r,rdp,l,ldp;

        for(ll i=x+1;i<=105;i++)
        {
            if(st.find(i)!=st.end())
            {
                rdp=i-x;
                r=i;
                break;
            }
        }

        for(ll i=x;i>=-105;i--)
        {
            if(st.find(i)!=st.end())
            {
                ldp=x-i;
                l=i;
                break;
            }
        }

        if(rdp<ldp)
        {
            cout<<r;
        }
        else
        {
            cout<<l;
        }
        
    }
}

Measured memory_bytes: 3664
# coding: utf-8
# Your code here!
a,b,c=map(int,input().split())

diff=c-b

if diff <=1:
    print(a+1)
else:
    if a -b < 1:
        print(a+1)
    else:
        if (a-b)%2==0:
            print(b+1+((a-b)*(diff))//2)
        
        else:
            print(b+((a-b+1)*(diff))//2)

Measured memory_bytes: 3060
#![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::<usize>();
    let a = read_vec::<usize>();
    let b = read_vec::<usize>();
    let c = read_vec::<usize>();

    let mut ans = b.iter().sum::<usize>();
    for i in 0..n - 1 {
        if a[i] == a[i + 1] - 1 {
            ans += c[a[i] - 1];
        }
    }
    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: 2104
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    int n,m;cin>>n>>m;
    vector<int> num(n);
    num[0]=-1;
    rep(i,n) num[i]=-1;
    int result=1;
    for(int i=0;i<m;i++){
        int s,c;cin>>s>>c;
        if(num[s-1]==-1) num[s-1]=c;
        else if(num[s-1]==c) continue;
        else{
            result=0;
            break;
        }
    }
    if(n==1){
        if(num[0]==-1) num[0]=0;
    }
    else{
        rep(i,n){
            if(num[0]==-1) num[0]=1;
            if(num[0]==0) result=0;
            if(num[i]==-1) num[i]=0;
        }
    }

    if(result==0) cout<<-1<<endl;
    else{
        rep(i,n) cout<<num[i];
        cout<<endl;
    }
}

Measured memory_bytes: 256