akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int N,m,n,st[210][210],same[210][210];

int main(){
	while(cin>>N && N){
		rep(i,210)rep(j,210)st[i][j]=i==j?0:INF;
		map<string,int> M;
		n=0;
		rep(i,N){
			string s,t,u;
			cin>>s;
			int mode=0;
			rep(j,s.sz){
				if(s[j]=='-')mode=1;
				else mode?u+=s[j]:t+=s[j];
			}
			if(M.find(t)==M.end())M[t]=n++;
			if(M.find(u)==M.end())M[u]=n++;
			st[M[t]][M[u]]=1;
		}
		rep(i,n)rep(j,n){
			int ok=0;
			rep(k,n){
				if(st[i][k]==1&&st[j][k]==1
				|| st[k][i]==1&&st[k][j]==1)ok=1;
				if(st[i][k]==1&&st[k][j]==1
				|| st[j][k]==1&&st[k][i]==1){
					ok=0;break;
				}
			}
			if(ok)st[i][j]=0;
		}
		rep(k,n)rep(i,n)rep(j,n){
			st[i][j]=min(st[i][j],st[i][k]+st[k][j]);
		}
		cout<<n<<endl;
		cin>>m;
		rep(i,m){
			string s,t,u;
			cin>>s;
			int mode=0;
			rep(j,s.sz){
				if(s[j]=='-')mode=1;
				else mode?u+=s[j]:t+=s[j];
			}
			if(M.find(t)==M.end() || M.find(u)==M.end()){
				cout<<"NO"<<endl;continue;
			}
			int T=M[t],U=M[u];
			cout<<(st[T][U]<INF && st[T][U]%2 ? "YES":"NO")<<endl;
		}
	}
}

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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, x;
  cin >> n >> x;
  long long ans = n;
  function<void(long long, long long)> solve = [&](long long a, long long b) {
    if (b == 0) {
      return;
    }
    long long c = a / b;
    ans += 2 * c * b - (a % b == 0) * b;
    solve(b, a % b);
  };
  solve(n - x, x);
  cout << ans << '\n';
  return 0;
}


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

using namespace std;


void hawawa()
{
	int a, b;
	cin >> a >> b;
	b -= a + 1;
	for (int i = 1; i <= b; i++) {
		a -= i;
	}
	cout << -a << "\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	hawawa();
	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 < (int)N; i++)
const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  vector<vector<int>> pos(N, vector<int>(2)); rep(i,N) cin >> pos[i][0] >> pos[i][1];
  sort(pos.begin(), pos.end(), [](const vector<int>& x, vector<int>& y) {return x[1] < y[1];});
  sort(pos.begin(), pos.end(), [](const vector<int>& x, vector<int>& y) {return x[0] < y[0];});

  int l[N+1][2]={}, r[N+1][2]={};
  rep(i,N+1) {
    if (i==0) {
      l[i][0] = -1*INF;
      l[i][1] = INF;
    }
    else {
      l[i][0] = max(l[i-1][0], pos[i-1][0]);
      l[i][1] = min(l[i-1][1], pos[i-1][1]);
    }
  }
  for (int i=N; i>=0; i--) {
    if (i==N) {
      r[i][0] = -1*INF;
      r[i][1] = INF;
    }
    else {
      r[i][0] = max(r[i+1][0], pos[i][0]);
      r[i][1] = min(r[i+1][1], pos[i][1]);
    }
  }

  int result = 0;
  rep(i,N) {
    int lp, rp;
    if (i==0) {
      lp = r[i+1][0];
      rp = r[i+1][1];
    }
    else if (i==N-1) {
      lp = l[i][0];
      rp = l[i][1];
    }
    else {
      lp = max(l[i][0], r[i+1][0]);
      rp = min(l[i][1], r[i+1][1]);
    }
    int len = pos[i][1]-pos[i][0]+1;
    result = max(result, max(0,rp-lp+1)+len);
    // cout << lp << " " << rp << " " << len << endl;

    if (i!=0) {
      int ld = max(0, l[i][1]-l[i][0]+1);
      int rd = max(0, r[i][1]-r[i][0]+1);
      result = max(result, ld+rd);
      // cout << ld << " " << rd << endl;
    }
  }

  // rep(i,N+1) cout << l[i][0] << "~" << l[i][1] << ", " << r[i][0] << "~" << r[i][1] << endl;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 7296
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int x,y,z;cin>>x>>y>>z;
    swap(x,y);swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































Measured memory_bytes: 896
import scipy.sparse.csgraph as c,numpy
_,*s=open(0)
s=numpy.int32([list(t[:-1])for t in s])
m=c.floyd_warshall(s)
i=m[0]%2<1
j=i^True
print(s[i][:,i].any()|s[j][:,j].any()and-1or int(m.max()+1))

Measured memory_bytes: 14652
/**
 * 問題文
 * シカのAtCoDeerくんは二つの正整数 a,b を見つけました。 
 * a と b をこの順につなげて読んだものが平方数かどうか判定してください。
 * 
 * 制約
 * 1 ≤ a,b ≤ 100
 * a,bは整数
 */

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a : String = read();
    let b : String = read();
    let c = format!("{}{}", a, b);
    let num : u32 = c.parse().unwrap_or(0); 

    for i in 1u32..318
    {
        //println!("**({} < {}({}))", num, i.pow(2), i);
        if num == i.pow(2) {
            //println!("Yes({})", num);
            println!("Yes");
            break;
        } else if num < i.pow(2) {
            //println!("No({} < {})", num, i.pow(2));
            println!("No");
            break;
        }
    }
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B, K;

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

    std::cin >> A >> B >> K;

    std::vector<int> v;

    for(int i=1;i<=std::min(A, B);++i){
        if(A % i == 0 && B % i == 0){
            v.emplace_back(i);
        }
    }

    std::reverse(v.begin(), v.end());

    std::cout << v[K - 1] << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, m, Q;
  int l, r, table[501][501];
  scanf("%d %d %d", &n, &m, &Q);
  for(int i = 0; i < m; i++){
    scanf("%d %d", &l, &r);
    table[l][r]++;
  }

  int dp[501][501];
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      dp[i][j] = dp[i][j - 1] + table[i][j];
    }
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      dp[i][j] += dp[i - 1][j];
    }
  }

  int p, q;
  for(int i = 0; i < Q; i++){
    scanf("%d%d", &p, &q);
    printf("%d\n", dp[q][q] - dp[p - 1][q]);
  }

  return 0;
}
    
    


Measured memory_bytes: 2816
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		int n = s.nextInt();
		int a = s.nextInt();
		int b = s.nextInt();
		System.out.println((n * a < b) ? n * a : b);

	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;

//配列要素数
static const int MAX = 200000;

//値
static const ll MX = 1e18;

using namespace std;

//#include "./lib/generic/sort.h"

std::tuple<int, int> swap(int num1, int num2){
     return std::forward_as_tuple(num1, num2);
}

void traceArray(int A[], int N){
    for(int i=0; i<N; i++){
        cout << A[i];
        if(i!=N-1){
            cout  << " ";
        }
    }
    cout << endl;
}

int push(int A[], int pointer, int tmp){
    A[pointer] = tmp;
    return pointer++;
}

int main(){
    /*int  N;
    cin >> N;
    int  A[N];
    REP(i, N) cin >> A[i];*/
    //sort::Sort test;
    //test.sortByIntention(A, N);
    //test.sortByBubble(A, N);
    //test.sortBySelection(A, N);
    //traceArray(A, N);

     /*int N=200, pointer=0;
     int A[N];
     char tmp;
     while(1){
         cin >> tmp;
         //pointer == push(A, pointer, tmp);
         if(cin.eof()){
            cout << "bbb" << endl;
             break;
         }
     }*/

     ll N;
     cin >> N;
     ll tmp, ans=1;
     bool ng=false;

     REP(i, N){
         cin >> tmp;
         if(tmp==0){
             cout << "0" << endl;
             return 0;
         }

         if(tmp<=MX/ans){
             ans*=tmp;
         }else{
             ng=true;
         }
     }

    if(ng) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string.h>

int main(void){
    char S[10], T[10], U[10];
    int A, B;
    std::cin >> S >> T;
    std::cin >> A >> B;
    std::cin >> U;
    if(strcmp(S, U) == 0){
        std::cout << A -1 << " " << B << std::endl;
    }else{
        std::cout << A << " " << B-1 << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define reps(i,s,n) for (int i = s; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define per1(i,n) for (int i = n; i >= 1; --i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
// if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W)
static const long double pi = acos(-1.0);
typedef complex<ld> cd;

template<class Abel> struct WeightedUnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    WeightedUnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

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

    int N, M;
    cin >> N >> M;
    WeightedUnionFind<int> uf(N);
    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if (uf.issame(l, r)) {
            int diff = uf.diff(l, r);
            if (diff != d) {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            uf.merge(l, r, d);
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << "\n";
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while(sc.hasNextLine()){
            sb.append(sc.nextLine().toLowerCase());
        }

        char now;
        char a = 'a';
        int[] data = new int[26];
        String line = sb.toString();

        for(int i = 0; i < line.length(); i++){
            now = line.charAt(i);
            for(int j = 0; j < 26; j++){
                if(now == (char)(a+j)){
                    data[j]++;
                    break;
                }
            }
        }

        for(int i = 0; i < 26; i++){
            System.out.println((char)(a+i) + " : " + data[i]);
        }
    }
}

Measured memory_bytes: 26248
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	// fmt.Println(text)
	text = strings.TrimRight(text, "\n")
	if strings.Compare(text, "AAA") == 0 || strings.Compare(text, "BBB") == 0 {
		fmt.Printf("No\n")
	} else {
		fmt.Printf("Yes\n")
	}
	os.Exit(0)
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n, a, b, c, x[105], y[105], z[105], count = 0, vc = 0;
	cin >> n >> a;
	set<int>ans;
	for (int i = 0; i < a; ++i) {
		cin >> x[i];
	}
	cin >> b;
	for (int i = 0; i < b; ++i) {
		cin >> y[i];
	}
	cin >> c;
	for (int i = 0; i < c; ++i) {
		cin >> z[i];
	}
	for (int i = 0; i < c; ++i) {
		for (int j = 0; j < b; ++j) {
			if (z[i] == y[j]) {
				ans.insert(z[i]);
				vc++;
				break;
				// vc == v.size()
			}
		}
	}
	for (int i = 0; i < c; ++i) {
		bool aa = true;
		for (int j = 0; j < a; ++j) {
			if (z[i] == x[j]) {
				aa = false;
				break;
			}
		}
		if (aa) {
			ans.insert(z[i]);
		}
	}
	cout << ans.size() << endl;
}


Measured memory_bytes: 3104
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        int num = Integer.parseInt(scan.nextLine());

        for(int i = 0; i < num; i++) {
            String[] line = scan.nextLine().split(" ");
            String order = line[0];
            int first = Integer.parseInt(line[1]);
            int end = Integer.parseInt(line[2]) + 1;

            if (order.equals("replace")) {
                if (first == 0) {
                    str = line[3].concat(str.substring(end));
                } else if (end == str.length()) {
                    str = str.substring(0, first).concat(line[3]);
                } else {
                    str = str.substring(0, first).concat(line[3]).concat(str.substring(end));
                }

            } else if (order.equals("reverse")) {
                if (first == 0) {
                    str = new StringBuffer(str.substring(0, end)).reverse().toString().concat(str.substring(end));
                } else if(end == str.length()) {
                    str = str.substring(0, first).concat(new StringBuffer(str.substring(first)).reverse().toString());
                } else {
                    str = str.substring(0, first).concat(new StringBuffer(str.substring(first, end)).reverse().toString()).concat(str.substring(end));
                }
            } else if (order.equals("print")) {
                String ans = str.substring(first, end);
                System.out.println(ans);
            }
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    int ab = 80000, a[n], b[n];
    for (int i = 0; i < n; i++) {
        int j = 20000 * (i + 1) + 1;
        a[i] = j;
        b[n - 1 - i] = j;
    }
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        b[p - 1] += i;
    }
    for (int i = 0; i < n - 1; i++) {
        cout << a[i] << ' ';
    }
    cout << a[n - 1] << endl;
    for (int i = 0; i < n - 1; i++) {
        cout << b[i] << ' ';
    }
    cout << b[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 768
# -*- coding: utf-8 -*-
n = int(input())
a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]
"""
ans = 0
tmp = 0
for i in range(n):
    tmp = sum(a1[0:i+1]) + sum(a2[i:n])
    #print(sum(a1[0:i+1]))
    #print(sum(a2[i:n]))
    if ans < tmp:
        ans = tmp
print(ans)
"""
ans = 0
for i in range(n):
    tmp = 0
    for j in range(i + 1):
        tmp += a1[j]
    for j in range(i, n):
        tmp += a2[j]
    #print(tmp)
    if ans < tmp:
        ans = tmp
print(ans)


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

int main(){
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a == b){
        printf("%d", c);
    }else if(a == c){
        printf("%d", b);
    }else{
        // b == c
        printf("%d", a);
    }

    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
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

const int CM = 130000;
char cn[CM + 10], * ci = cn + 10, * owa = cn + CM;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	char c = ci[8];
	ci[8] = 0;
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci[8] = c;
	ci += (64 - dig >> 3) + 1;

	if (ci - owa > 0) {
		memcpy(cn, owa, 10);
		ci -= CM;
		fread(cn + 10, 1, CM, stdin);
	}
	return tmp;
}

char* di = cn;
const int MAX = 200000;
class shuturyoku_unko {
public:
	char C[MAX * 6 - 100000];
	int K[MAX + 10];
	constexpr shuturyoku_unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
} f;
inline void putint(ll X) {
	int ue = X / 100000;
	if (ue) {
		for (int i = f.K[ue]; i < f.K[ue + 1]; i++)* di++ = f.C[i];
		int sita = X - ue * 100000ll;
		rep(i, 5 - f.K[sita + 1] + f.K[sita])* di++ = '0';
		for (int i = f.K[sita]; i < f.K[sita + 1]; i++)* di++ = f.C[i];
	}
	else for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
	*di++ = '\n';
}

int B[200001];

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


	fread(ci, 1, CM, stdin);

	int N = getint();
	ll kotae = 1;
	int A[200000];
	rep(i, N) kotae += B[(A[i] = getint())]++;
	int *a = A;
	
	int amari = N % 10800;
	int shou = N / 10800;
	rep(j, shou) {
		rep(k, 10800) putint(kotae - B[*a++]);
		fwrite(cn, 1, di - cn, stdout);
		di = cn;
	}
	rep(k, amari) putint(kotae - B[*a++]);
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 int a,b;
 cin >> a >> b;
 if(a+b<=23)cout << a+b << endl;
 else cout << a+b-24 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	int current = 1;

	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;

		if (current == tmp)
		{
			current++;
		}
	}

	if (current == 1)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << N - current + 1 << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

class LowElements
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());
        var number = Console.ReadLine().Split(' ');

        int[] intArray = number.Select(int.Parse).ToArray();

        int count = 1;
        int min = intArray[0];

        for(var i = 1; i < input; i++)
        {
            if(intArray[i - 1] >= intArray[i] && min >= intArray[i])
            {
                count++;
                min = intArray[i];
            }
        }

        Console.WriteLine(count);


    }
}

Measured memory_bytes: 33628
#include <iostream>
#include <string>

int decimal(int a){
  int ans = 0;
  while(a > 0) {
    ans += a % 10;
    a = a / 10;
  }
  return ans;
}

int main () {
  int x;
  std::string ans = "No";
  std::cin >> x;
  int fx = decimal(x);
  if(x % fx == 0) ans = "Yes";
  std::cout << ans << std::endl;
}

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

int main(){
    long long ans=0, N;
    cin >> N;
    ll tmp = N;
    vector<int> num(1e6+100, 0);
    if(N==1){
	cout << 0 << endl;
	return 0;
    }

    for(ll i=2; i*i<=N; i++){
	if(tmp%i==0){
	    while(tmp%i==0){
		num[i]++;
		tmp/=i;
	    } 
	}
    }

    if(tmp > 1){
	ans ++;
    }

    for(int i=0; i<(int)num.size(); i++){
	int j = 1;
	while(num[i]>0){
	    if(num[i]>=j){
		ans++;
	    }
	    num[i]-=j;
	    j++;
	} 
    }
    cout << ans << endl;
}






Measured memory_bytes: 7216
/*
 * CountingCharacters.cpp
 *
 *  Created on: 2014/07/27
 *      Author: WanWan1985
 */
#include <iostream>
#include <stdio.h>
#include <cctype>	// for isupper() or islower()
#include <vector>

#define SIZE	(26)

using namespace std;

int main(void) {

	char ch;
	int iCounter[SIZE] = { 0 };

	while (cin >> ch) {

		if (isupper(ch)) {
			ch = tolower(ch);
		}

		int iIndex = ch - 'a';
		iCounter[iIndex]++;
	}

	int i = 'a';
	for (unsigned int j = 0; j < SIZE; j++) {
		printf("%c : %d\n", i + j, iCounter[j]);
	}

	return 0;
}

Measured memory_bytes: 1124
s = input()
t = input()
check = False
for i in range(len(s)):
    s = s[len(s)-1] + s[:len(s)-1]
    for j in range(len(t)):
        t = t[len(t)-1] + t[:len(t)-1]
        if s < t:
            check = True
            break
    if check:
       break
if check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	string S;
	cin >> S;
	int ans = -100;
	for(int i = 0; i < S.size() - 2; i ++){
		int tmp = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0');
		if(abs(ans - 753) > abs(tmp - 753))ans = tmp;
	}
	//cout << ans << endl;
	cout << abs(ans - 753) << endl;

	return 0;
}

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


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

using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

using num = modnum<924844033>;


int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> lengths;
	for(int m = 0; m < 2*k; m++){
		int cnt = 0;
		for(int a = m; a < n; a += 2*k){
			if(a-k >= 0 && a-k < n) cnt += 1;
			if(a+k >= 0 && a+k < n) cnt += 1;
		}
		if(cnt) lengths.push_back(cnt);
	}
	vector<num> fact = {1};
	for(int i = 1; i <= 5000; i++) fact.push_back(i * fact[i-1]);
	vector<num> ifact;
	for(num x : fact) ifact.push_back(1 / x);
	vector<num> dp = {1};
	for(int x : lengths){
		vector<num> cdp(x+1, 0);
		for(int i = 0; i <= x; i++){
			if(x + 1 - i >= i) cdp[i] = fact[x+1-i] * ifact[i] * ifact[x+1-i-i];
		}
		vector<num> newdp(dp.size() + cdp.size() - 1, 0);
		for(int i = 0; i < dp.size(); i++){
			for(int j = 0; j < cdp.size(); j++){
				newdp[i+j] += dp[i] * cdp[j];
			}
		}
		dp = newdp;
	}

	num ans = 0;
	for(int i = 0; i < (int)dp.size(); i++){
		if(i <= n){
			ans += dp[i] * fact[n-i] * (i & 1 ? -1 : 1);
		}
	}
	cout << (int) ans << '\n';
}

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

int main() {
string az="abcdefghijklmnopqrstuvwxyz";
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    int i=0,j=0;
    for(int j=0;j<s.length();j++) {
        if(az[i]==s[j]) {
		i++;
		}
        if(i==26) {
		cout << "None" << endl;
		return 0;
		}
    }
    cout << az[i];
}


Measured memory_bytes: 3720
import sys
import math
import bisect

def main():
    s = input()
    if s == 'A':
        print('T')
    elif s == 'C':
        print('G')
    elif s == 'G':
        print('C')
    elif s == 'T':
        print('A')
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        int [] a = new int[3];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextInt();
        }
        out.print(a[2] + " " + a[0] + " " + a[1]);
        out.flush();
    }
}

class Interval {
    int start;
    int end;

    public int getStart() {
        return start;
    }

    public int getEnd() {
        return end;
    }

    public Interval(int start, int end) {
        this.start = start;
        this.end = end;
    }

    @Override
    public String toString() {
        return
                "start=" + start +
                ", end=" + end +
                '}';
    }
}


class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

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

    public Integer nextInt(){
        return Integer.valueOf(next());
    }
    public Long nextLong() {
        return  Long.valueOf(next());
    }
    public Double nextDouble() {
        return Double.valueOf(next());
    }
    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}


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

using namespace std;
#define pb push_back
#define LL long long
int main() {
    // freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    int T, x;
    //cin >> T;
   // while(T--) {
        int n;
        LL ans = 0;
        cin >> n;
        for(int i = 1; i <= n; ++i) {
            cin >> x;
            ans += x-1;
        }
        cout << ans << "\n";
    //}

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<string>
#include<cstdio>
#include<stack>
#include<cmath>
#include<bitset>
#include<memory>
#include<utility>
#include<map>
using namespace std;
#define FOR(i,m,n) for(i=m;i<n;i++)
#define CLR(a,b) memset(a,b,sizeof(a))
#define ROF(i,m,n) for(i=m;i>=n;i--)
#define BUG cout<<"debug"<<endl;
#define RT return
#define BK break
#define HEAP priority_queue
#define SP " "
#define rd(x) (rand()%(x))
#define lowf(a,b,c) lower_bound(a,b,c)
#define upf(a,b,c) upper_bound(a,b,c)
#define sh(a) cout<<a<<endl
typedef long long LL;
typedef vector<int> VI;
const int INF = 2147483647;
const int NEN = -INF - 1;
const LL LINF = 9223372036854775807;
int G[25][25];
int dir[4][2] = { {-1,0},{1,0},{0,-1},{0,1} };//上下左右
int w, h,I1,I2,J1,J2,ans;
bool inmap(int x, int y)
{
	return x >= 0 && y >= 0 && x < h&&y < w;
}
void dfs(int i,int j,int sum)
{
	if (sum > ans||sum>10)return;
	int t = 4,x, y,d;
	while (t--)
	{
		x = i + dir[t][0];
		y = j + dir[t][1];
		if (!inmap(x, y))continue;
		else if (G[x][y] == 1)continue;
		for (d = 1;; d++)
		{
			x = i + d*dir[t][0];
			y = j + d*dir[t][1];
			if (!inmap(x, y))break;
			if (G[x][y] == 3)
			{
				ans = min(ans, sum + 1); return;
			}
			if (G[x][y] == 1)
			{
				G[x][y] = 0;
				dfs(i + (d - 1)*dir[t][0], j + (d - 1)*dir[t][1], sum + 1);
				G[x][y] = 1;
				break;
			}
		}

	}
}
int main()
{
	while (cin >> w >> h)
	{
		ans = INF;
		if (w == 0 && h == 0)break;
		int i, j;
		FOR(i, 0, h)
		{
			FOR(j, 0, w)
			{
				scanf("%d",&G[i][j]);
				if (G[i][j] == 2)I1 = i, J1 = j;
				else if (G[i][j] == 3)I2 = i, J2 = j;
			}
		}
		dfs(I1, J1, 0);
		if(ans<=10)cout << ans << endl;
		else cout << -1 << endl;
	}
}


Measured memory_bytes: 3136
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <complex>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
#define un using namespace
un std;
#define pb push_back
#define pf pop_front

#define mp make_pair

#define c0 first
#define c1 second
#define sqr(x) ((x)*(x))
#define clr(x) memset(x, 0, sizeof(x))
#define clr1(x) memset(x, -1, sizeof(x))
#define clr80(x) memset(x, 0x80, sizeof(x))
#define clr7F(x) memset(x, 0x7F, sizeof(x))

#define LL long long
#ifdef __unix__
#define LLD "%lld"
#else
#define LLD "%I64d"
#endif
#define pii pair<int, int>
#define pip pair<int, pii>
#define vi vector<int>
#define vpi vector<pii>
#define pq priority_queue

template<typename T>
inline bool chkmin(T &a, T b){return a > b ? a = b, 1 : 0;}
template<typename T>
inline bool chkmax(T &a, T b){return a < b ? a = b, 1 : 0;}

#define P 1000000007

#define getint(x){\
	char __next__char__;bool __nega__int__=0;\
	while(!isdigit(__next__char__=getchar())&&__next__char__!='-');\
	__next__char__=='-'?(x=0,__nega__int__=1):(x=__next__char__-48);\
	while(isdigit(__next__char__=getchar()))x=x*10+__next__char__-48;\
	if(__nega__int__)x=-x;\
}
#define getint2(x1,x2){getint(x1);getint(x2);}
#define getint3(x1,x2,x3){getint(x1);getint(x2);getint(x3);}
#define getint4(x1,x2,x3,x4){getint(x1);getint(x2);getint(x3);getint(x4);}
#define getint5(x1,x2,x3,x4,x5){getint(x1);getint(x2);getint(x3);getint(x4);getint(x5);}
#define getint6(x1,x2,x3,x4,x5,x6){getint(x1);getint(x2);getint(x3);getint(x4);getint(x5);getint(x6);}

long long a[100002];
long long lm[100002];
long long rm[100002];

void solve() {
	int n, l;
	getint2(n, l);
	lm[0] = 0;
	rm[n + 1] = 0;
	for (int i = 1; i <= n; i++) {
		scanf(LLD, a + i);
		lm[i] = max(lm[i - 1], lm[i - 1] + a[i]);
	}
	for (int i = n; i >= 1; i--) {
		rm[i] = max(rm[i + 1], rm[i + 1] + a[i]);
	}
	long long nowsum = 0;
	long long ans = 1ULL << 63;
	for (int i = 1; i <= n; i++) {
		nowsum += a[i];
		if (i > l) {
			nowsum -= a[i - l];
		}
		if (i >= l) {
			chkmax(ans, nowsum + lm[i - l] + rm[i + 1]);
			chkmax(ans, lm[i - l] + rm[i + 1]);
		}
	}
	printf(LLD"\n", ans);
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int H;

void maxHeapify(int *A,int i)
{
  int l,r,largest;
  int temp;
  l = 2*i;
  r = 2*i + 1;
  if(l <= H && A[l] > A[i])
    {
      largest = l;
    }
  else
    {
      largest = i;
    }
  if(r <= H && A[r] > A[largest])
    {
      largest =r;
    }
  if(largest != i)
    {
      temp = A[i];
      A[i] = A[largest];
      A[largest] = temp;
      maxHeapify(A,largest);
    }
 
}

int main()
{
  int A[1000000];
  int i;
  scanf("%d",&H);
  for(i = 1; i <= H;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i = H/2;i >= 1 ;i--) //buildMaxHeap
    {
      maxHeapify(A,i);
    }
  for(i = 1; i <= H;i++)
    {
      printf(" %d",A[i]);
    }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3660
package main
import "fmt"
func main() {
  var h, n int
  fmt.Scan(&h, &n)
  sum := 0
  for i := 0; i < n; i++ {
    var a int
    fmt.Scan(&a)
    sum += a
  }
  
  if sum < h {
    fmt.Println("No")
  } else {
    fmt.Println("Yes")
  }
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int N  ;
  cin >> N  ;
  int ans = 0 ;
  vector<int> A(N) ;
  rep(i,N) cin >> A.at(i) ;
  sort(A.begin(),A.end());
  A[N-1] = A[N-1]/2 ;
  rep(i,N) ans += A[i] ;
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
ans=0
p=2

while p<=10**6 and n!=1:
  dv=0
  wa=1
  num=1
  while n%p==0:
    n/=p
    n=int(n)
    dv+=1
  if dv>0:
    while dv>=wa:
      num+=1
      wa+=num
    num-=1
    ans+=num
  p+=1
  
if n!=1:
  print(str(ans+1))
  exit()
  
print(str(ans))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1; i<=n; i++)
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//
const int LIM=3501;

int main() {
    int N;
    cin >> N;
    repd(h,1,LIM){
        repd(n,h,LIM){
            if((4*h*n-n*N-N*h)<=0) continue;
            if((N*h*n)%(4*h*n-n*N-N*h)==0){
                cout << h << " " << n << " " << (N*h*n)/(4*h*n-n*N-N*h) << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main () {
    
    int H,W;
    
    while(1) {
        
        cin >> H >> W;
        
        if (H == 0) break;
        
        for (int i = 0 ; i < H ; i ++) {
            
            for (int j = 0 ; j < W ; j ++) {
                
                cout << '#';
                
            }
            
            cout << endl;
            
        }
        
        cout << endl;
        
    }
    
    return 0;
    
}


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

using namespace std;

typedef long long ll;


ll N, M, Q, A, B, C;

string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> A;
	cin >> s;
	s[A-1] += 32;
	cout << s << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int X = N;
 
    int sum = 0;
    while (N != 0) {
        sum += N % 10;
        N /= 10;
    }
 
    if (X % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int cr = 0;
    rep(i, n) cr += s[i] == 'R' ? 1 : 0;
    int cw = n - cr;
    int wtr = 0, rtw = 0;
    rep(i, n)
    {
        if (i < cr)
        {
            if (s[i] == 'W')
                wtr++;
        }
        if (i >= cr)
        {
            if (s[i] == 'R')
                rtw++;
        }
    }
    int ans = max(rtw, wtr);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef pair <int,int> pii;
int N, M, L, Q;
vector <pii> edge[305];
int dist[305][305];
int INF = 0x3f3f3f3f;

void FloydWarshall() {
    memset(dist, INF, sizeof(dist));
    for (int i = 1; i <= N; i++) dist[i][i] = 0;
    for (int i = 1; i <= N; i++)
        for (pii v: edge[i])
            dist[i][v.first] = v.second;
    for (int k = 1; k <= N; k++) { //choose intermediate vertex between i and j
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (dist[i][k] + dist[k][j] < dist[i][j] && dist[i][k] != INF && dist[k][j] != INF)
                    dist[i][j] = dist[i][k] + dist[k][j];
            }
        }
    }
}

int main() {
    scanf("%d %d %d", &N, &M, &L);
    for (int i=0; i<M; i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        edge[a].push_back({b,c});
        edge[b].push_back({a,c});
    }
    FloydWarshall();
    for (int i=1; i<=N; i++){
        edge[i].clear();
        for (int j=1; j<=N; j++){
            if (dist[i][j] <= L) edge[i].push_back({j, 1});
        }
    }
    FloydWarshall();
    scanf("%d", &Q);
    for (int i=0; i<Q; i++){
        int s, t;
        scanf("%d %d", &s, &t);
        if (s == t) printf("1\n");
        else {
            if (dist[s][t] != INF) printf("%d\n", dist[s][t]-1);
            else printf("-1\n");
        }
    }
    return 0;
}

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

using namespace std;

// 約数列挙
vector<int> divisor(int n) 
{
    vector<int> ret;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
        ret.push_back(i);
        if(i * i != n) ret.push_back(n / i);
        }
    }
    //sort(begin(ret), end(ret));　時間短縮で削除
    return (ret);
}

int main()
{
    // 入出力高速化
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    map<int ,int> a;
    
    int buf;
    for(int i=0;i<n;i++){
        cin >> buf;
        a[buf]++;
    }

    int ans=0;
    vector<int> vec;
    for(auto p1: a){
        // チェック中の数字が2つ以上あるなら、cntなし
        if(p1.second>=2) continue;
        
        // チェック中の約数が存在するかデータにあるかチェック
        bool check=true;
        vec = divisor(p1.first);
        for(int i=0;i<vec.size();i++){
            if(vec[i]==p1.first) continue;
            if(a[vec[i]]>0){
                check=false;
                break;
            }
        }
        
        // 割り切れる数なしのときcnt up
        if(check) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 32512
#include<stdio.h>

int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int ans=0;
		for(int i=a;i<=c;i++)for(int j=b;j<=d;j++)if(!(i%2==1&&j%2==0))ans++;
		printf("%d\n",ans);
	}
}


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

int main() {
	int n;
	cin >> n;
	int v[n];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	vector<int> cnt1, cnt2;
	for (int i = 0; i < n; i++) {
		if (i % 2) cnt2.push_back(v[i]);
		else cnt1.push_back(v[i]);
	}
	map<int, int> CNT1, CNT2;
	for (int i = 0; i < cnt1.size(); i++) {
		CNT1[cnt1[i]]++;
	}
	for (int i = 0; i < cnt2.size(); i++) {
		CNT2[cnt2[i]]++;
	}
	int ans = 0;
	int ma = -1;
	vector<int> ANS;
	for (auto e : CNT1) {
		if (ma < e.second) {
			ANS.resize(1);
			ANS[0] = e.first;
		} else if (ma == e.second && ANS.size() == 1) ANS.push_back(e.first);
		ma = max(ma, e.second);
	}
	ans += cnt1.size() - ma;
	ma = 0;
	for (auto e : CNT2) for (auto E : ANS) if (E != e.first) ma = max(ma, e.second);
	int ans1 = ans + cnt2.size() - ma;
	ans = 0;
	ma = -1;
	ANS.resize(0);
	for (auto e : CNT2) {
		if (ma < e.second) {
			ANS.resize(1);
			ANS[0] = e.first;
		} else if (ma == e.second && ANS.size() == 1) ANS.push_back(e.first);
		ma = max(ma, e.second);
	}
	ans += cnt2.size() - ma;
	ma = 0;
	for (auto e : CNT1) for (auto E : ANS) if (E != e.first) ma = max(ma, e.second);
	int ans2 = ans + cnt1.size() - ma;
	cout << min(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 5756
#include <bits/stdc++.h>
using namespace std;
int n,arr[100003];
int dp[100003];
int k;
int f(int x)
{
    if(x==0) return 0;
    if(x<0) return 1987654321;
    if(dp[x]!=-1) return dp[x];
    int ret=1987654321;
    for(int j=1;j<=k;j++) if(x>=j) ret=min(ret,f(x-j)+abs(arr[x]-arr[x-j]));
    return dp[x] = ret;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    scanf("%d %d",&n,&k); for(int i=0;i<n;i++) scanf("%d",&arr[i]);
    printf("%d",f(n-1));
}


Measured memory_bytes: 5760
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():

    n, m = LI()
    a = LI()
    lst = []

    for e in a:
        lst.append((e, 1))

    for _ in range(m):
        b, c = LI()
        lst.append((c, b))

    lst.sort(reverse=True)
    ans = 0
    cnt = 0

    for t in lst:
        time = min(t[1], n-cnt)
        ans += t[0]*time
        cnt += time
        if cnt == n:
            break
    
    print(ans)

        


main()


Measured memory_bytes: 95644
#include<stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a == b){
    printf("a == b\n");
  }
}

Measured memory_bytes: 1008
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;



int main(){
  double a,b,c,d,e,f;
  double x,y;
  while(cin >> a >> b >>  c >>  d >>  e >>  f){
    x=(a*f-c*d)/(a*e-b*d);
    y=(c*e-f*b)/(a*e-b*d);
    if(x==0) x=0 ;
    if(y==0) y=0;
    printf("%.3lf %.3lf\n",y,x);
  }
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{int n,k,sum=0;
 cin>>n>>k;
 int pr[n];
 for(int i=0;i<n;i++)
   cin>>pr[i];
 sort(pr,pr+n);
 for(int i=0;i<k;i++)
   sum+=pr[i];
 cout<<sum;
 return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N 1000001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{
    int w;
    cin>>n>>w;

    int wt[n],val[n];

    for(i=0;i<n;i++)
        cin>>wt[i]>>val[i];

    int dp[w+2],vis[w+2];

    for(i=0;i<=w;i++)
        dp[i]=0,vis[i]=0;

    vis[0]=1;

    for(i=0;i<n;i++)
    {
        for(j=w;j>=wt[i];j--)
        {
            if(vis[j-wt[i]])
            {
                dp[j]=max(dp[j],dp[j-wt[i]]+val[i]);
                vis[j]=w;
            }
        }
    }
    int ans=0;
    for(i=0;i<=w;i++)
        ans=max(ans,dp[i]);

    cout<<ans;
}

}


Measured memory_bytes: 5200