akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] cnt = new int[9];
            int n = in.nextInt();
            int min = 0;
            for (int i = 0; i < n; i++) {
                int tmp = in.nextInt();
                int col = getColor(tmp);
                ++cnt[col];
                if (cnt[col] <= 1 && col < 8) ++min;
            }

            if (min == 0) {
                out.println(1 + " " + cnt[8]);
                return;
            }
            out.println(min + " " + (min + cnt[8]));

        }
        public int getColor(int a) {
            int ret = a / 400;
            return Math.min(8, ret);
        }
    }
}



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

const int N = 2000005;
const int MOD = 1000000007;

int fact[N];
int ifact[N];

int k;
char s[N];

int power(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1) {
    if (y & 1) ret = 1LL * ret * x % MOD;
    x = 1LL * x * x % MOD;
  }

  return ret;
}

int C(int n, int k) {
  return 1LL * fact[n] * ifact[k] % MOD * ifact[n-k] % MOD;
}

int solve() {
  fact[0] = 1;
  for (int i = 1; i < N; ++i) fact[i] = 1LL * fact[i-1] * i % MOD;
  ifact[N-1] = power(fact[N-1], MOD-2);
  for (int i = N-2; i >= 0; --i) ifact[i] = 1LL * ifact[i+1] * (i+1) % MOD;

  scanf("%d", &k);
  scanf("%s", s);

  int n = strlen(s);

  int ans = 0;
  for (int i = 0; i <= k; ++i) {
    ans = (1LL * C(k-i + n-1, n-1) * power(25, k-i) % MOD * power(26, i) + ans) % MOD;
  }

  printf("%d\n", ans);
  return 0;
}

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


Measured memory_bytes: 20420
#include <stdio.h> 
 
  int main(){ 
     int i, n; 
     int arr[100]; 
     scanf("%d", &n); 
     for(i=0;i<n;i++){ 
         scanf(" %d", &arr[i]); 
     } 
     for(i=0;i<n;i++){ 
         if(i)printf(" "); 
         printf("%d", arr[n-i-1]); 
     } 
     printf("\n"); 
     return 0; 
 } 



Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    while(1){
        if(n >= pow(k,ans)){
            ans++;
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while(true){
			int H=sc.nextInt();
			int W=sc.nextInt();
			if(H==0&&W==0){
				break;
			}else{
				for(int i=0;i<W;i++){
					System.out.print("#");
				}
				System.out.println();
				for(int i=1;i<H-1;i++){
					System.out.print("#");
					for(int j=1;j<W-1;j++){
						System.out.print(".");
					}
					System.out.println("#");
				}
				for(int i=0;i<W;i++){
					System.out.print("#");
				}
				System.out.println();
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 34452
#include <iostream>
#include <vector>
#include <cstdlib>

#define MAX_HEIGHT 10000
#define MAX_ROCKS 100000


using namespace std;

int main()
{
    int nR, rV, dJ;
    int distances[MAX_ROCKS];
    int rocks[MAX_ROCKS]; 
    cin >> nR;
    for(int i = nR-1; i >= 0; i--)
    {   
        cin >> rV; 
        rocks[i] = rV;
        distances[i] = MAX_HEIGHT; 
    }
    distances[nR-1] = 0;
    distances[nR-2] = abs(rocks[nR-1] - rocks[nR-2]);
    for(int i = nR - 3; i >= 0; i--)
        distances[i] = min(abs(rocks[i+1]-rocks[i]) + distances[i+1], abs(rocks[i+2]-rocks[i]) + distances[i+2]);
    cout << distances[0];
}

Measured memory_bytes: 1024
n = int(input())
hs = input()
h = [int(j) for j in hs.split(" ")]
count = 0
flg = 0
for i in range(n):
    for j in range(0, i):
        if h[i] < h[j]:
            flg = 1
            break
    if flg == 0:
        count = count + 1
    flg = 0

print(count)


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
    int a, b, c, tmp, i;
    scanf("%d %d %d", &a, &b, &c);
    if(a>=1 && a<= 10000 && b>=1 && b<= 10000 && c>= 1 && c<= 10000){
        for(i=0; i<5; i++){
            if(a>b){
                tmp = a;
                a = b;
                b = tmp;
            }
            if(b>c){
                tmp = b;
                b = c;
                c = tmp;
            }
        }
        printf("%d %d %d\n", a, b, c);
    }
    return 0;
}

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

int main() {
  long long A, B, K;
  cin >> A >> B >> K;

  A -= K;
  if(A < 0){
    B += A;
    A = 0;
    if(B < 0){
      B = 0;
    }
  }

  cout << A << " " << B << endl;
}

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

class Main
{

	static Scanner sc;

	public static void main( String[] args ) throws IOException
	{
		sc = new Scanner( new BufferedReader( new InputStreamReader( System.in ) ) );
        while(true)
        {
            int a = sc.nextInt(), b = sc.nextInt();
            if(a == 0 && b == 0) return;
            if(a < b) System.out.printf("%d %d\n", a, b);
            else System.out.printf("%d %d\n", b, a);
        }
	}
}




Measured memory_bytes: 41816
n=int(input())
S = [input() for i in range(n)]

al_nu = lambda c: ord(c) - ord('A')
S2 = [[] for i in range(n)]
for i in range(n):
    for j in range(10):
        S2[i].append(al_nu(S[i][j]))
for i in range(n):
    S2[i] = sorted(S2[i])

S2.sort()
#print(S2)

ans = 0
co = 0
for i in range(n-1):
    if S2[i] == S2[i+1]:
        co += 1
        #print("a")
    else:
        ans += co*(co+1)/2
        co = 0
ans += co*(co+1)/2
print(int(ans))

Measured memory_bytes: 31832
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(i)a[i]+=a[i-1];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	for(int i=n-2;i>=0;i--){
		b[i]+=b[i+1];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(a[i]+b[i],ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = 0;
		// 文字列の入力
		int[] d = new int[a];
		for(int i = 0; i < a; i++){
			d[i] = sc.nextInt();
		} 
		for(int i = 0; i < a; i++){
			for(int j = i + 1; j < a; j++){
				b += d[i] * d[j];
			}
		}
		System.out.println(b);
		
		
	}
}

Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      sum += vec.at(i) * vec.at(j);
    }
  }
  
  for (int i = 0; i < N; i++){
    sum -= vec.at(i) * vec.at(i);
  }
  
  cout << sum / 2 << endl;
}

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

"""code-fes-2017-qual-c-c"""


import sys

OP_NUM = 0

def solve(s):
    """Solve."""
    global OP_NUM

    if len(s) == 0:
        return ""
    if len(s) == 1:
        return ""

    if s[0] == 'x':
        if s[-1] == 'x':
            return s[1:-1]
        OP_NUM += 1
        return s[1:]

    if s[0] == s[-1]:
        return s[1:-1]
    if 'x' == s[-1]:
        OP_NUM += 1
        return s[:-1]

    return None


def main():
    """Main function."""
    s = input()

    while s:
        s = solve(s)
        if s is None:
            print(-1)
            sys.exit(0)

    print(OP_NUM)

if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<n;++i)
#define Sort(a) sort(a.begin(),a.end())
const int INF = 1e9+7;

int main(){
  ll N,M,m=0;
  cin >> N >> M;
  vector<pair<ll,ll>> v(N);
  rep(i,N)
    cin >> v.at(i).first >> v.at(i).second;
  Sort(v);
  rep(i,N){
    if(M<=v.at(i).second){
      m += v.at(i).first * M;
      break;
    }
    else{
      M -= v.at(i).second;
      m += v.at(i).first*v.at(i).second;
    }
  }
  cout << m;
}


Measured memory_bytes: 1792
use std::vec::Vec;

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()
}

fn main() {
    let (h, w) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1])
    };
    let mut c: Vec<Vec<usize>> = Vec::new();
    for i in 0..10 {
      let t = read_vec();
      c.push(t);
    }
    let mut graph = Vec::new();
    for i in 0..10 {
      for j in 0..10 {
        graph.push((i, j, c[i][j]));
      }
    }

    let mut a: Vec<Vec<i64>> = Vec::new();
    for i in 0..h {
      let t = read_vec();
      a.push(t);
    }

    let dist = warshal_floyd(10, &graph, true);
    let mut ans: u64 = 0;
    for vec in &a {
      for &val in vec {
        if val == -1 {
          continue;
        } else {
          ans += dist[val as usize][1] as u64;
        }
      }
    }
    println!("{}", ans);
}


fn warshal_floyd(n: usize, v: &Vec<(usize, usize, usize)>, direct: bool) -> Vec<Vec<usize>> {
  let mut dist = vec![vec![std::usize::MAX/2; n]; n];
  // init
  for &(x, y, c) in v {
    dist[x][y] = c;
    if !direct {
      dist[y][x] = c;
    }
  }

  for k in 0..n {
    for i in 0..n {
      for j in 0..n {
        if dist[i][j] > dist[i][k] + dist[k][j] {
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }
  dist
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		ll dp[n][3];
		for (auto &i : dp) cin >> i[0] >> i[1] >> i[2];
		for (int i = 1; i < n; i++) {
			dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
			dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
			dp[i][2] += max(dp[i - 1][1], dp[i - 1][0]);
		}
		cout << *max_element(dp[n - 1], dp[n - 1] + 3) << "\n";
	}
	return 0;
}

Measured memory_bytes: 5908
import sys
from collections import deque, defaultdict, Counter
# from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from math import ceil, sqrt
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()
S = [input() for _ in range(H)]

L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
D = [[0]*W for _ in range(H)]
U = [[0]*W for _ in range(H)]

for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			L[i][j] = 0
		elif j == 0:
			L[i][j] = 1
		else:
			L[i][j] = L[i][j-1] + 1

for i in range(H):
	for j in range(W-1, -1, -1):
		if S[i][j] == '#':
			R[i][j] = 0
		elif j == W-1:
			R[i][j] = 1
		else:
			R[i][j] = R[i][j+1] + 1

for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			U[i][j] = 0
		elif i == 0:
			U[i][j] = 1
		else:
			U[i][j] = U[i-1][j] + 1

for i in range(H-1, -1, -1):
	for j in range(W):
		if S[i][j] == '#':
			D[i][j] = 0
		elif i == H-1:
			D[i][j] = 1
		else:
			D[i][j] = D[i+1][j] + 1

ans = 0
for i in range(H):
	for j in range(W):
		ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)

print(ans)


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector <vector <int> > t(m);
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int x;
            cin >> x;
            x--;
            t[i].push_back(x);
        }
    }
    vector <int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int msk = 0; msk < (1 << n); msk++) {
        set <int> kek;
        for (int i = 0; i < n; i++) {
            if ((msk >> i) & 1) {
                kek.insert(i);
            }
        }
        bool good = true;
        for (int i = 0; i < m; i++) {
            int cnt = 0;
            for (int x : t[i]) {
                if (kek.count(x)) {
                    cnt++;
                }
            }
            good &= ((cnt % 2) == p[i]);
        }
        ans += good;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappop, heappush

N, M = map(int, input().split())
A = list(map(int, input().split()))
A_minus = [-x for x in A]
heapify(A_minus)

for i in range(M):
    n = -heappop(A_minus) // 2
    heappush(A_minus, -n)

print(-sum(A_minus))


Measured memory_bytes: 14180
#include <iostream>
#include <stack>

using namespace std;

int cnt;

void insertion_sort(int* A, int n, int g) {
  for (int i = g; i < n; i++) {
    int key = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > key) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = key;
  }
}

void shell_sort (int* A, int n) {
  cnt = 0;

  int m = 0;
  int val = 1;
  stack<int> st;
  while(val <= n) {
    m++;
    st.push(val);

    val = 3 * val + 1;
  }

  // line 1
  cout << m << endl;

  for (int i = 0; i < m; i++) {
    int g = st.top();
    st.pop();

    // line 2
    if (i == 0) {
      cout << g;
    } else {
      cout << " " << g;
    }

    insertion_sort(A, n, g);
  }
  cout << endl << cnt << endl;
  
  for (int i = 0; i < n; i++) {
    cout << A[i] << endl;
  }
}

int main() {
  int n;
  int* A;

  cin >> n;
  A = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }

  shell_sort(A, n);

  return 0;
}

Measured memory_bytes: 5108
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int A;
	cin >> A;


	co((A - 1) / 2);



	Would you please return 0;
}

Measured memory_bytes: 764
let s = cin.str
let t = cin.str

if s.allSatisfy({ $0.isLowercase }), 
    t.allSatisfy({ $0.isLowercase }),
    s.count <= 10,
    t.prefix(s.count) == s,
    t.count == s.count + 1 {
        print("Yes")
} else {
    print("No")
}

// MARK: #### 以下、ライブラリ ####

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var int: Int { Int(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    // 12 23 34
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    // AtCoder
    static var str: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { str.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { str.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in int } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence }
infix operator ^^ : PowerPrecedence
func ^^ (radix: Int, power: Int) -> Int {
    return Int(pow(Double(radix), Double(power)))
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}


Measured memory_bytes: 13156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, l;
    cin >> n >> l;

    int s = (l + l + n - 1) * n / 2;
    int t = 1 << 30;
    for (int i = 0; i < n; i++) {
        int a = l + i;
        if (abs(a) < abs(t)) {
            t = a;
        }
    }
    cout << s - t << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define prin(a) cout<<a<<"\n"
#define kaigyo cout<<"\n"
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define SORT(V) sort(ALL(V))
#define REV(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REV(V)

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<string> vst;
typedef vector<char> vc;
typedef vector<long double> vd;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
typedef vector<vector<int>> vint2;
ll mod=1e9+7;

const double pi=acos(-1.0);
const ll inf=1LL<<60;
ll gcd(ll p,ll q){if(q==0)return p;return gcd(q,p%q);}  
ll lcm(ll p,ll q){return (p*q)/gcd(p,q);}
ll kaizyo(ll k){ll sum=1;rep1(i,k){sum*=i;sum%=mod;}return sum;}
ll ncr(ll n,ll r){return kaizyo(n)/(kaizyo(r)*kaizyo(n-r));}


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

  int n; cin >> n;
  string s; cin >> s;
  int ans=0;
  for(int i=0,j=n-1;i<j;) {
    while(i<j&&s[i]=='R') ++i;
    while(i<j&&s[j]=='W') --j;
    if(i < j) {
      swap(s[i], s[j]);
      ++i;
      --j;
      ans++;
    }
  }
  prin(ans);
  return 0;


}



Measured memory_bytes: 3740
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		String s=scanner.next();
		String ans=s;
		int cnt = 0;
		for(int i=0;i<n;i++) {
			char c=s.charAt(i);
			if(c=='(')cnt++;
			else cnt--;
			if(cnt<0) {
				ans="("+ans;
				cnt++;
			}
		}
		if(cnt>=0) {
			for(int i=0;i<cnt;i++) {
				ans=ans+")";
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21332
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<cmath>
#include<iomanip>
#include<iostream>
using namespace std;

int main() {
	long double n,ans=0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		long double a[100];
		string s[100];
		cin >> a[i] >> s[i];
		if (s[i] == "BTC")
			ans += (a[i] * 380000);
		else
			ans += a[i];
	}
	cout <<setprecision(19)<< ans << endl;
}





Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
using namespace std;
struct Node
{
  int key;
  Node *p, *l, *r;
};
Node *root, *NIL;

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

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

void insertkey(int k)
{
  Node *x, *y, *z;
  y = NIL;
  x = root;
  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = z->r = NIL; // Don't forget this......
  while(x != NIL)
  {
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  z->p = y;
  if(y == NIL) root = z;
  else
  {
    if(z->key < y->key) y->l = z;
    else y->r = z;
  }
}

void print()
{
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
}

int main()
{
  int n, k;
  scanf("%d", &n);
  string s;
  for(int i=0; i<n; i++)
  {
    cin >> s;
    if(s == "insert")
    {
      scanf("%d", &k);
      insertkey(k);
    }
    else print();
  }
  return 0;
}



Measured memory_bytes: 26780
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>

#define pb push_back
#define pf push_front

using namespace std;	
typedef long long int lli;

lli n,k,l,m,t,a,b,r,c,temp1,temp2,x,y,temp,q,d,mod=1e9+7,w;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n;
    string s;
    cin>>s;
    lli cnt=0;
    
	lli pref[n+2]={0};
	
	if(s[0]=='R')
	pref[0]=1;
	
	
	for(int i=1;i<n;i++)
	{
		
		if(s[i]=='R')
		{
			pref[i]++;
		}
		
		pref[i]+=pref[i-1];
		
	}
	lli cnt2;
	
	if(pref[n-1]>=1)
	{
		cnt2=pref[n-1]-pref[pref[n-1]-1];
	}
	
	for(int i =0;i<n-1;i++)
    {
    	if(s[i]=='W' &&s[i+1]=='R')
    	{
    		cnt++;
    		s[i+1]='W';
    	}
    }
	
	cnt=min(cnt,cnt2);
	cout<<cnt<<endl;
	
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll a, b, c, d;
	cin>>n>>a>>b>>c>>d;
	bool ok=false;
	ll e=b-a;
	REP(i, n){
		if(c*(n-1-i)-d*i<=e && e<=-c*i+d*(n-1-i)){
			ok=true;
			break;
		}
	}
	cout<<(ok ? "YES" : "NO")<<'\n';
	return 0;
}


Measured memory_bytes: 256
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut s: String = s.trim().chars().collect();
    while s.len() > 3 {
        let n = s.len();
        let mut replace = vec![false; n];
        let t: Vec<char>= s.chars().collect();
        for i in 2..n {
            if t[i - 2] == 'A' && t[i - 1] == 'B' && t[i] == 'C' {
                replace[i - 2] = true;
                replace[i - 1] = true;
                replace[i] = true;
            }
        }
        let mut cond = [false; 3];
        for i in 0..n {
            if !replace[i] {
                let k = t[i] as usize - 'A' as usize;
                cond[k] = true;
            }
        }
        let mut update = false;
        let to = ["A", "B", "C"];
        for i in 0..3 {
            if !cond[i] {
                if update {
                    println!("No");
                    return;
                }
                update = true;
                s = s.replace("ABC", to[i]);
            }
        }
        if !update {
            println!("No");
            return;
        }
    }
    if s != "ABC" {
        println!("No");
    } else {
        println!("Yes");
    }
}

fn main() {
    run();
}



Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

int tab[105][105];
int dp[105][105];

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	int h, w;
	std::cin >> h >> w;
	FOR(i, h){
		FOR(j, w){
			char a;
			std::cin >> a;
			if(a == '#') tab[i+1][j+1] =1;
		}
	}
	FOR(i, h+1) FOR(j, w+1) dp[i][j] = 1000000000;
	dp[0][1] = 0;
	dp[1][0] = 0;
	REP(i, 1, h+1){
		REP(j, 1, w+1){
			if(tab[i][j]){
				if(tab[i-1][j]) dp[i][j] = std::min(dp[i-1][j], dp[i][j]);
				else dp[i][j]= std::min(dp[i][j],dp[i-1][j]+1);
				if(tab[i][j-1]) dp[i][j] = std::min(dp[i][j-1], dp[i][j]);
				else dp[i][j] = std::min(dp[i][j], dp[i][j-1]+1);
			}else{
				dp[i][j] = std::min(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	std::cout << dp[h][w];

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
using ll = long long;

void bunkai(vector<ll> &a,ll x){
  ll temp=x;
  for(ll i=2;i*i<=x;i++){
    if(temp%i==0){
      a.push_back(i);
      while(temp%i==0){
	temp/=i;
      }
    }
  }
  a.push_back(temp);
  return;
}

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

int main(){
  ll p,q;
  cin>>p>>q;
  ll a=gcd(q,p);
  p/=a;
  q/=a;
  //cout<<"p="<<p<<"q="<<q<<endl;
  vector<ll> soinsu;
  bunkai(soinsu,q);
  ll ans=1;
  for(ll i=0;i<soinsu.size();i++){
    ans*=soinsu[i];
    //cout<<"ans="<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}



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

using namespace std;

int main() {
    //freopen("inp.inp", "r", stdin);
    int  a, b, c;
    cin >> a >> b >> c;
    if (a == b and b == c and (a & 1)) {
        cout << 0;
        return 0;
    }
    if (a == b and b == c and !(a & 1)) {
        cout << -1;
        return 0;
    }
    int ans = 0;
    int temp1 = a, temp2 = b, temp3 = c;
    while (!(a & 1) and !(b & 1) and !(c & 1)) {
        ++ans;
        a = (temp2 + temp3) >> 1;
        b = (temp1 + temp3) >> 1;
        c = (temp1 + temp2) >> 1;
        temp1 = a, temp2 = b, temp3 = c;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

string s,t;
int Q,N,M,l1,r1,l2,r2,cnt_a[2][100010];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> s >> t;
    cin >> Q;

    int i;
    N=s.length(),M=t.length();
    for (i=1; i<=N; i++){
        cnt_a[0][i]=cnt_a[0][i-1];
        if (s[i-1]=='A') cnt_a[0][i]++;
    }

    for (i=1; i<=M; i++){
        cnt_a[1][i]=cnt_a[1][i-1];
        if (t[i-1]=='A') cnt_a[1][i]++;
    }

    int dif1,dif2;
    while (Q--){
        cin >> l1 >> r1 >> l2 >> r2;
        dif1=(r1-l1+1-2*(cnt_a[0][r1]-cnt_a[0][l1-1]));
        dif2=(r2-l2+1-2*(cnt_a[1][r2]-cnt_a[1][l2-1]));
        if ((dif2-dif1)%3==0) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


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


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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()


using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;


void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}


const double EPS = 1e-8;
const long long mod = 1e9 + 7;

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

const int N = 1e6 + 5;
const long long inf = 1e18;


long long a,b,c,d;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> c >> d;
    long long lcm = (1ll * c * d)/__gcd(c,d);
    long long C = b / c - (a - 1)/c;
    long long D = b / d - (a - 1)/d;
    long long LCM = b / lcm - (a - 1)/lcm;
    //error(C,D,LCM,lcm);
    cout << b - a + 1 - C - D + LCM << '\n';

    return 0;
}


Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def color(r):
    if 1 <= r < 400:
        return 'gray'
    elif r < 800:
        return 'brown'
    elif r < 1200:
        return 'green'
    elif r < 1600:
        return 'lightblue'
    elif r < 2000:
        return 'blue'
    elif r < 2400:
        return 'yellow'
    elif r < 2800:
        return 'orange'
    elif r < 3200:
        return 'red'

def main():
    n = II()
    aa = MII()
    aa_u = [a for a in aa if a < 3200]
    aa_o = [a for a in aa if a >= 3200]
    u_type_num = len(set(map(color, aa_u)))
    o_type_num = len(aa_o)
    if u_type_num == 0:
        print('1 {}'.format(o_type_num))
    else:
        print('{} {}'.format(u_type_num, u_type_num+o_type_num))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMaximumVolume solver = new CMaximumVolume();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMaximumVolume {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            double x = sc.nextDouble();
            pw.println(Math.pow(x, 3) / 27.0);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

        public double nextDouble() {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

    }
}



Measured memory_bytes: 21460
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_cum = [0 for _ in range(n+1)]
b_cum = [0 for _ in range(m+1)]

for i in range(n):
    a_cum[i+1] = a_cum[i] + a[i]
for i in range(m):
    b_cum[i+1] = b_cum[i] + b[i]

ans = 0
for i in range(n+1):
    if a_cum[i] > k:
        break
    x = bisect.bisect_right(b_cum, k - a_cum[i])
    ans = max(ans, i + x - 1)

print(ans)

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

using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'

const int maxn = 1e5 + 10;
int a[maxn], b[maxn], c[maxn];
int dp[maxn];
int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> a[i];
	for(int i=1; i<=n; i++){
		b[i] = 1, c[i] = 1;
		if(i == 1 || a[i - 1] >= a[i - 2]) b[i] = b[i - 1] + 1;
		if(i == 1 || a[i - 1] <= a[i - 2]) c[i] = c[i - 1] + 1;
	}
	//for(int i=1; i<=n; i++)
//	cout << i << " " << b[i] << " " << c[i] << endl;
	for(int i=1; i<=n; i++){
		dp[i] = min(dp[i - b[i]] + 1, dp[i - c[i]] + 1);
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 1792
open System

[<EntryPoint>]
let main _ =
    let n = Console.ReadLine() |> int |> fun v -> v % 10
    match n with
    | 0 | 1 | 6 | 8 -> "pon"
    | 3 -> "bon"
    | _ -> "hon"
    |> printfn "%s"
    0 


Measured memory_bytes: 29684
#include<stdio.h>

#define POS(i,j) ((i)*n+(j))

int connected(int *g,int n){
  int q[50];
  int used[50];
  int i;
  for(i=0;i<n;i++) used[i]=0;
  int front=0,last=0;
  q[last++]=0;
  used[0]=1;
  while(front<last){
    int v=q[front++];
    for(i=0;i<n;i++){
      if(g[POS(v,i)] && !used[i]){
	q[last++]=i;
	used[i]=1;
      }
    }
  }
  return last==n;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int g[2500];
  int i,j;
  for(i=0;i<n*n;i++) g[i]=0;
  for(i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;b--;
    g[POS(a,b)]=1;
    g[POS(b,a)]=1;
  }
  int cnt=0;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(g[POS(i,j)]){
	g[POS(i,j)]=g[POS(j,i)]=0;
	cnt+=connected(g,n);
	g[POS(i,j)]=g[POS(j,i)]=1;
      }
    }
  }
  printf("%d\n",m-cnt);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
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
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

if N < 1000:
    print("ABC")
else:
    print("ABD")


Measured memory_bytes: 5144
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2616
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      char[] c = s.toCharArray();
      int a = 0;
      for(int i=0; i<n-2; i++){
        if(c[i]=='A' && c[i+1]=='B' && c[i+2]=='C'){
          a++;
        }
      }
       System.out.println(a);
    }
}

Measured memory_bytes: 21844
using System;
					
public class Program
{
	public static void Main()
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split(' ');
		int[] array = new int[N+1];
		int tmp=0;
		
		for(int i=0; i < N-1; i++){
			tmp = array[int.Parse(str[i])];
			tmp++;
			array[int.Parse(str[i])] =tmp;
		}
        
		for(int i=1; i <= N; i++){
			Console.WriteLine(array[i]);
		}
		
	}
}

Measured memory_bytes: 38420
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;
 
typedef long long ll;

#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
 
string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
constexpr int mod = 1e9 + 7;
ll POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

ll power(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans * a) % mod;
		}
		a = (a * a) % mod;
		b /= 2;
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (a == 0) {
		return b;
	}
	return gcd(b % a,a);
}
ll lcm(ll a, ll b) {
	return (a * b) / gcd(a,b);
}
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			return 0;
		}
	}
	return 1;
}

ll power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans * a) % mo;
		}
		a = (a * a) % mo;
		b /= 2;
	}
	return ans;
}     

int main() {
	int n;
	cin >> n;
	//int cnt = 0;
	vector<int> v(n + 1);
	//for (int e = 1; e <= n; ++e) {
	//int cnt = 0;
	for (ll i = 1; i <= sqrt(n) + 1; ++i) {
		for (ll j = 1; j <= sqrt(n) + 1; ++j) {
			for (ll k = 1; k <= sqrt(n) + 1; ++k) {
				ll x = i * i + j * j + k * k + i * j + j * k + k * i;
				if (x <= n) {
					v[x]++;
				}
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << v[i] << endl;
	}
}








Measured memory_bytes: 3680
#include<stdio.h>
int main(void)
{
	int h, w,i,j,k;
	char str[101][101];

	while (1) {
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0)break;
		j = 0;
		k = 0;
		for (i = 0; i < h; i++) {
				scanf("%s",str[i]);
		}
		while (1) {
			if (str[j][k] == '>') {
				str[j][k] = '0';
				k++;
			}
			else if (str[j][k] == 'v') {
				str[j][k] = '0';
				j++;
			}
			else if (str[j][k] == '^') {
				str[j][k] = '0';
				j--;
			}
			else if (str[j][k] == '<') {
				str[j][k] = '0';
				k--;
			}
			else if (str[j][k] == '.') {
				printf("%d %d\n",k,j);
				break;
			}
			else if (str[j][k] == '0') {
				printf("LOOP\n");
				break;
			}
		}
	}
	return 0;
}

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

typedef long long int int64;

int64 gcd(int64 a,int64 b);

int main()
{
    int64 a,b;
    scanf("%lld %lld",&a,&b);
    printf("%lld",(a/gcd(a,b))*b);
}

int64 gcd(int64 a,int64 b)
{
    if(a==b||b<=0)return a;
    else if(a<b)return ((a<=0)?(b):(gcd(a,b%a)));
    else return gcd(b,a%b);
}

Measured memory_bytes: 128
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
#define ar array
const ll maxN=1e5+5 , N=1e2+5;
ar<ll,2> a[N];
ll dp[N][maxN];
ll n , w;
void solve(){
	cin>> n >> w ;
	for(ll i=0;i<n ;i++)cin>>a[i][0]>>a[i][1];

	for(ll i=0;i<=n ; i++){
		for(ll j=0 ; j<=w ; j++){
			if(i==0 || j==0)dp[i][j]=0;
			else if(j>=a[i-1][0]){
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1][0]]+a[i-1][1]);
			}
			else dp[i][j]=dp[i-1][j];

		}
	}
	cout<<dp[n][w]<<endl;;
}
int main(){
	//mahakal(),fast;
	ll t=1;
	// cin>> t ;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 82496
#include<bits/stdc++.h>
using namespace std;
int main(){
	char b;
  cin >> b;
  if( b=='A'){
  	cout << 'T';
  }else if(b=='C'){
  	cout <<'G';
  }else if(b=='T'){
  	cout <<'A';
  }else if(b=='G'){
  	cout <<'C';
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int A,B;
    cin >> A >> B;
    int ans;
    ans = max(0,A-B*2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,a,b;
    scanf("%d %d %d", &n,&a,&b);
    int sum=0,ssum=0;
    for(int i=1;i<n+1;i++){
        ssum = (i%10) + ((i/10)%10) + ((i/100)%10) + ((i/1000)%10) + ((i/10000)%10);
        if((a<=ssum)&&(ssum<=b)){
            sum+=i;
        }
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,a[123],i,sum=0,mn=INF,ans;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
		sum += a[i];
		a[i] *= n;
	}
	for(i=0; i<n; ++i){
		if(abs(a[i]-sum)<mn){
			mn = abs(a[i]-sum);
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			1000003

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

int find(vector<int> &T, int x) {
	//if (x < 0) return x;
	if (T[x] < 0) return x;
	return T[x] = find(T, T[x]);
}

void unite(vector<int> &T, int x, int y) {
	x = find(T, x);
	y = find(T, y);
	if (x == y) return;
	T[y] = x;
	//T[x]--;
}

int main(){
	int N,M;cin>>N>>M;
	vector<int> arr(N);
	vector<int> T(N+4,-1);

	REP(i,N)cin>>arr[i];
	//REPS(i,1,N+1)T[i]=i;
	REP(i,M){
		int a,b;
		cin>> a >> b;
		unite(T,a,b);
	}

	int cnt =0;
	REP(i,N){
		if((i+1)==arr[i])
			++cnt;
		else if(find(T,i+1)==find(T,arr[i]))
			++cnt;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
import sys

N = int(input())
H = list(map(int,input().split()))

def frog1(n,h):
  s = [0]*n
  s[0] = 0
  s[1] = abs(h[1]-h[0])
  for i in range(2,n):
    s[i]=min(s[i-2]+abs(h[i]-h[i-2]),s[i-1]+abs(h[i]-h[i-1]))
  return s[n-1]

print(frog1(N,H))

Measured memory_bytes: 13928