akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, m;
ll cnt[2][2000000];
ll h[2000];
ll w[2000];

int main() {
	while (cin >> n >> m&&n + m) {
		rep(i, 2)rep(j, 2000000)cnt[i][j] = 0;
		h[0] = 0;
		w[0] = 0;
		rep(i, n)cin >> h[i + 1];
		rep(i, m)cin >> w[i + 1];
		rep(i, n + 1)h[i] += h[i - 1];
		rep(i, m + 1)w[i] += w[i - 1];
		rep(i, n + 1) {
			FOR(j, i + 1, n + 1) {
				cnt[0][h[j] - h[i]]++;
			}
		}
		rep(i, m + 1) {
			FOR(j, i + 1, m + 1) {
				cnt[1][w[j] - w[i]]++;
			}
		}
		ll ans = 0;
		rep(i, 2000000) {
			ans += (cnt[0][i] * cnt[1][i]);
		}
		cout << ans << endl;
	}
}


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

using namespace std;
int main()
{
    int n;

    cin >> n;

    int ans {};

    for (int i = 0, l, r; i < n; ++i)
    {
        cin >> l >> r;

        ans += r - l + 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  int dp[31];
  dp[0] = dp[1] = 1;
  // ０段、１段あがる方法は１通り。
  // 実際上がらないという方法はない、計算の都合上dp[0]にも値を入れる。
  dp[2] = 2;
  // ２段あがる方法は２通り。

  for( int i = 3 ; i < 31 ; i++ ){
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
    // 一度に３段上れるので i - 1 , i - 2 , i - 3 ,がそれぞれ何通りあるかわかればよい。
    //　i - 1 , i - 2 , i - 3 のそれぞれの段から i 段に上る方法はそれぞれ１通りしかない。
  }
  
  int n;
  while( cin >> n , n){    
    //cout << "何通りか→" << dp[n] << endl;
    cout << dp[n]/10/365 + 1 << endl;
    // １日に１０通り試すので１０で割る。
    // 何年かかるか計算するため３６５で割り、１を加える。
  }
  return 0;
}

Measured memory_bytes: 1156
data = Array.new()
i = 0
ans = Array.new()
while true
	data[i] = gets
	break if data[i] == nil
	data[i] = data[i].split(" ")
	ans[i] = data[i][0].to_i.gcdlcm(data[i][1].to_i)
	i += 1
end
i.times do |i|
	puts "#{ans[i][0]} #{ans[i][1]}"
end

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

ll n,m;
int main()
{
    ll a,b;
    int c=0;
    sfl(b);
    a=100;
    while(a<b)
    {
        a+=((a)/100);
        c++;
    }
    pf("%d\n",c);
}


Measured memory_bytes: 3828
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int i, topping = 0;
  char S[4];
  unused = scanf("%s", S);

  for(i=0; i<3; i++){
    if(S[i]=='o') topping++;
  }
  printf("%d", 100*topping + 700);
  return 0;
}

Measured memory_bytes: 128
p = int(input().split()[1])
s = input()
if 10 % p == 0:
  r = sum(i for i, x in enumerate(s, 1) if int(x) % p == 0)
else:
  d = [1] + [0] * (p - 1)
  t, y = 0, 1
  for x in reversed(s):
    t = (t + int(x) * y) % p
    d[t] += 1
    y = y * 10 % p;
  r = sum(i * (i - 1) for i in d) // 2
print(r)

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> W(n);
    for (auto& w : W) cin >> w;

    vector<int> Ws = W;
    sort(Ws.begin(), Ws.end());

    int cost = 0;
    int left = 0;
    while (left < n - 1) {
        int min_i = min_element(W.begin() + left, W.end()) - W.begin();
        int cnt = 0;
        while (1) {
            int tgt_i = find(W.begin() + left, W.end(), Ws[min_i])
                        - W.begin();
            if (tgt_i == min_i) break;
            cost += W[min_i] + W[tgt_i];
            swap(W[min_i], W[tgt_i]);
            cnt++;
            min_i = tgt_i;
        }
        int compare = cnt * W[min_i] - 2 * (W[min_i] + Ws[0]) - cnt * Ws[0];
        if (compare > 0) cost -= compare;
        left++;
    }
    cout << cost << endl;

    return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x; cin>>x;
  int n=2;
  while(x>n){
    if(x%n==0){
        x++;
        n=2;
        continue;
      }
    else n++;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    n: usize,
    k: usize,
    r: usize,
    s: usize,
    p: usize,
    t: Chars
    }
    let mut ans = 0;
    let mut is_add = vec![true; n];
    for i in 0..n {
        if i >= k && t[i] == t[i - k] && is_add[i - k] {
            is_add[i] = false;
            continue
        }
        ans += char_to_p(t[i], r, s, p);
    }
    println!("{}", ans);
}

fn char_to_p(c: char, r: usize, s: usize, p: usize) -> usize {
    match c {
        'r' => p,
        's' => r,
         _ => s
    }
}

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

using namespace std;
typedef long long ll;
const int maxn=2e3+10;
const ll mod=1e9+7;
ll dp[maxn];//n  la_num;
int vis[maxn];
int main(){
	ll n;
	cin>>n;
	memset(dp,0,sizeof(dp));
	memset(vis,1,sizeof(vis));
	for(int i=3;i<=n;i++){
		dp[i]=1;
	}
	for(int i=3;i<=n;i++){
		for(int j=3;j+i<=n;j++){
			dp[i+j]=(dp[i+j]+dp[i])%mod;
		}
	}
	cout<<dp[n]<<endl;
	return 0 ;
}


Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	vin(a);
	for (int i = 0; i < n; ++i)
	{
		x -= a[i];
	}
	int ans = n;
	ans  += x / (*min_element(all(a)));
	cout << ans;

}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin>>n;
   int d[n];
   int kai=1;
   for(int i=0;i<n;i++){
       cin>>d[i];
   }
   sort(d,d+n);
   for(int i=1;i<n;i++){
       if(d[i]!=d[i-1]){
           kai++;
       }
   }
   cout<<kai<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    res = a - 1
    if a <= b:
        res += 1
    print(res)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


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

using namespace std;

using int64 = long long;

int64 Sum(const vector<int64>& xs) {
  int64 value = 0;
  for (int64 x : xs) value += x;
  return value;
}

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

  int n;
  cin >> n;
  vector<int64> xs(n + 1);
  for (int i = 0; i < n + 1; i++) cin >> xs[i];
  vector<int64> hs(n);
  for (int i = 0; i < n; i++) cin >> hs[i];
  int64 start = Sum(xs);

  for (int i = 0; i < n; i++) {
    int64 d1 = min(hs[i], xs[i]);
    hs[i] -= d1;
    xs[i] -= d1;
    int64 d2 = min(hs[i], xs[i + 1]);
    hs[i] -= d2;
    xs[i + 1] -= d2;
  }
  int64 end = Sum(xs);

  cout << start - end << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL l,n,a[200010],t[200010];
LL ans=0;
void solve()
{
	t[n]=l-1-a[n]+1;t[n-1]=a[n-1];
	LL tot=t[n]+t[n-1];
	ans=max(ans,a[n]);ans=max(ans,tot*2-t[n]);
	for(LL i=n-2;i>=1;i--)
	{
		LL len=n-i+1,p;
		t[i]=a[i];tot+=a[i];
		if(len&1) p=n-len/2;
		else
		{
			p=n-len/2+1;
			tot-=t[p];t[p]=l-1-a[p]+1;
			tot+=t[p];
		}
		ans=max(ans,tot*2-t[p]);
	}
}
int main()
{
	scanf("%lld %lld",&l,&n);
	for(LL i=1;i<=n;i++) scanf("%lld",&a[i]);
	solve();
	reverse(a+1,a+n+1);
	for(LL i=1;i<=n;i++) a[i]=l-a[i];
	solve();
	printf("%lld",ans);
}


Measured memory_bytes: 3328
count = 0
while True:
    try:
        text = list(input())
        
        a = len(text)
        b = a//2
        _te = []
        te_ = []
        
        for i in range(0,b):
            _te.append(text[i])
            te_.append(text[a-1-i])
        
        if _te==te_:
            count += 1
    
    except:
        break
print(count)


Measured memory_bytes: 5560
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        sc.close();

        if(Y % 2 == 1){
            System.out.println("No");
        }else{
            if(Math.round((double)Y/4) <= X && Y/2 >= X){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 35752
from heapq import heappop, heappush

max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def solve(cities,trains,S):
    N = len(cities)
    adj = [[] for _ in range(N)]

    for u,v,a,b in trains:
        u,v = u-1,v-1
        adj[u].append((v,a,b))
        adj[v].append((u,a,b))

    M = 2500
    S = min2(S,M-1)

    encode = lambda v,c: v*M+c
    decode = lambda i: (i//M,i%M)

    dist = [10**18]*(N*M)
    dist[S] = 0

    q = [(0, S)]

    while q:
        d,i = heappop(q)
        if dist[i] < d:
            continue

        v,c = decode(i)
        C,D = cities[v]

        nc = min2(c+C,M-1)
        ni = encode(v,nc)
        nd = d+D
        if dist[ni] > nd:
            dist[ni] = nd
            heappush(q, (nd, ni))

        for u,a,b in adj[v]:
            if c < a:
                continue
            ni = encode(u,c-a)
            nd = d+b
            if dist[ni] > nd:
                dist[ni] = nd
                heappush(q, (nd, ni))

    return [min(dist[v*M:v*M+M]) for v in range(N)][1:]



if __name__ == '__main__':
    N,M,S = map(int,readline().split())

    m = map(int,read().split())

    trains = list(t for _,t in zip(range(M), zip(m,m,m,m)))
    cities = list(zip(m,m))

    print(*solve(cities,trains,S), sep='\n')


Measured memory_bytes: 86280
#[test]
fn check_solve() {
    println!("input:\n3\n1 2\n2 3\noutput:\n{}\n", solve("3\n1 2\n2 3\n"));
    println!(
        "input:\n8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\noutput:\n{}\n",
        solve("8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8\n")
    );
    println!(
        "input:\n6\n1 2\n1 3\n1 4\n1 5\n1 6\noutput:\n{}\n",
        solve("6\n1 2\n1 3\n1 4\n1 5\n1 6\n")
    );
}

use std::collections::HashMap;
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let ab: Vec<_> = (0..n - 1)
        .map(|_| (sc.read::<usize>() - 1, sc.read::<usize>() - 1))
        .collect();
    let mut nbr = vec![Vec::new(); n + 1];
    for &(a, b) in &ab {
        nbr[a].push(b);
        nbr[b].push(a);
    }
    let mut clr = HashMap::new();
    let mut vsd = vec![false; n];
    vsd[0] = true;
    dfs(0, 0, &mut clr, &mut vsd, &nbr);

    let mut ret = String::new();
    use std::fmt::Write;
    let mut k = 0;
    for &(a, b) in &ab {
        k = std::cmp::max(k, clr[&(a,b)]);
        writeln!(&mut ret, "{}", clr[&(a,b)]).unwrap();
    }
    format!("{}\n{}", k, ret)
}

fn dfs(v: usize, a: usize, clr: &mut HashMap<(usize,usize), usize>, vsd: &mut [bool], nbr: &[Vec<usize>]) {
    vsd[v] = true;
    let mut i = 1;
    for &c in &nbr[v] {
        if vsd[c] {
            continue;
        }
        if clr.contains_key(&(a,v)) && i == clr[&(a,v)] {
            i += 1
        }
        clr.insert((v,c),i);
        clr.insert((c,v),i);
        i += 1;
        dfs(c, v, clr, vsd, nbr);
    }
}
fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 28968
#include <iostream>

using namespace std;

int n,s;

int cou (int i,int cn, int cs){
	if(cs > s|| cn > n)
		return 0;
	if((cn == n||cn==n-1) && cs == s)
		return 1;
	int ans=0;
	i++;
	for(;i<10;i++)
		ans+=cou(i,cn+1,cs+i);
	return ans;
}


int main(void){
	while( cin >> n >> s, n|s){
		cout << cou(0,0,0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
const int MX = (1e5);
Long A[MX + 2];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  Long res = 0;
  fore(i, 0, n) {
    int num;
    cin >> num;
    A[num]++;
    res += num;
  }
  int q;
  cin >> q;
  while (q--) {
    Long a, b;
    cin >> a >> b;
    Long before = A[a] * a;
    Long now = A[a] * b;
    res += (now - before);
    A[b] += A[a];
    A[a] = 0;
    cout << res << '\n';
  }

  return 0;
}

Measured memory_bytes: 4380
class Dice:
    def __init__(self, d1, d2, d3, d4, d5, d6):
        self.d1 = d1
        self.d2 = d2
        self.d3 = d3
        self.d4 = d4
        self.d5 = d5
        self.d6 = d6
    def S(self):
        tmp = self.d1
        self.d1 = self.d5
        self.d5 = self.d6
        self.d6 = self.d2
        self.d2 = tmp
    def N(self):
        tmp = self.d1
        self.d1 = self.d2
        self.d2 = self.d6
        self.d6 = self.d5
        self.d5 = tmp
    def E(self):
        tmp = self.d1
        self.d1 = self.d4
        self.d4 = self.d6
        self.d6 = self.d3
        self.d3 = tmp
    def W(self):
        tmp = self.d1
        self.d1 = self.d3
        self.d3 = self.d6
        self.d6 = self.d4
        self.d4 = tmp
    def output(self):
        print(self.d1)

d1, d2, d3, d4, d5, d6 = map(int, input().split())
dice = Dice(d1, d2, d3, d4, d5, d6)
M = input()
for i in range(len(M)):
    if M[i] == 'S':
        dice.S()
    elif M[i] == 'N':
        dice.N()
    elif M[i] == 'E':
        dice.E()
    elif M[i] == 'W':
        dice.W()
dice.output()


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
struct NODE
{
    int st,ed;
} node[100000+100];
bool cmp(NODE x,NODE y)
{
    return x.ed<y.ed;  //按结束时间早的升序排
}
int main()
{
    int n,num,k,t,s,e;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>s>>e;
        node[i].st=s-e;
        node[i].ed=s+e;
    }
    sort(node,node+n,cmp);
    num=1;
    t=node[0].ed;
    for(int i=1; i<n; ++i)
    if(t<=node[i].st)
        {
            num++;
            t=node[i].ed;
        }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

vs64 f(2010), finv(2010);

s64 pow_mod(s64 x, s64 n, s64 mod)
{
    s64 ret = 1;
    while (n)
    {
        if (n & 1) ret = ret * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}

void init(int n)
{
    f[0] = 1;
    rep (i, n)
    {
        f[i + 1] = f[i] * (i + 1) % MOD;
    }
    finv[n] = pow_mod(f[n], MOD - 2, MOD);
    for (int i = n - 1; i >= 0; --i)
    {
        finv[i] = finv[i + 1] * (i + 1) % MOD;
    }
}

s64 comb(int n, int k)
{
    if (n < k || n < 0 || k < 0) return 0;
    return f[n] * finv[n - k] % MOD * finv[k] % MOD;
}


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

    int s;
    cin >> s;

    init(s);

    s64 ans = 0;
    for (int l = 1; l <= s / 3; ++l)
    {
        ans += comb(s - 2 * l - 1, s - 3 * l);
        ans %= MOD;
    }

    cout << ans << "\n";
    return 0;
}



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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int X,A;
    cin >> X >> A;

    if( X < A ) cout << 0 << endl;
    else cout << 10 << endl;

}


Measured memory_bytes: 256
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N, K = [int(a) for a in input().split()]
    A = [int(a) for a in input().split()]
    # X = int(input())
    # A = [int(a) for a in input().split()]
    # T1, T2, T3 = [int(a) for a in input().split()]

    for i in range(K+1, N + 1):
        ii = i - 1
        old = A[ii - K]
        new = A[ii]
        if old < new:
            print('Yes')
        else:
            print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 97180
#include <iostream>
using namespace std;

int main(){
    int v[6]={1, 5, 10, 50, 100, 500};
    int sum=0;
    for(int i=0; i<6; i++){
        int c;
        cin >> c;
        sum += c*v[i];
    }
    if(sum>=1000){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll a, b, c;

int swap(ll& x, ll& y){
	ll tmp = x;
	x = y;
	y = tmp;
	return 0;
}

int main() {
	cin >> a >> b >> c;
	if(a > b){swap(a, b);}
	if(a > c){swap(a, c);}
	if(b > c){swap(b, c);}
	
	//cout << a << b << c;
	ll ans = -1;
	if(a%2 == b%2 && a%2 == c%2){ans = (c-a)/2+(c-b)/2;}
	if(a%2 == b%2 && a%2 != c%2){ans = (c-(a+1))/2+(c-(b+1))/2+1;}
	if(a%2 != b%2 && a%2 == c%2){ans = (c-a)/2+(c+1-b)/2+1;}
	if(a%2 != b%2 && a%2 != c%2){ans = (c+1-a)/2+(c-b)/2+1;}
	
	cout <<ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#endif

    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> red(a);for(auto &i:red)cin>>i;
    vector<int> gre(b);for(auto &i:gre)cin>>i;
    vector<int> col(c);for(auto &i:col)cin>>i;
    sort(red.rbegin(),red.rend());
    sort(gre.rbegin(),gre.rend());
    for(int i=0;i<x;i++)col.push_back(red[i]);
    for(int i=0;i<y;i++)col.push_back(gre[i]);
    sort(col.rbegin(),col.rend());

    int ans=accumulate(col.begin(),col.begin()+x+y,0LL);
    cout<<ans;



}


Measured memory_bytes: 7784
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    string s; cin >> s;
    int n = s.size();
    int ans = 1;
    string a = "";
    a += s[0];
    string b = "";
    repp(i,n,1){
        b += s[i];
        if (i < n-1 && a != b && b != s.substr(i+1,n-i-1)){
            ans ++;
            //cout << a << " " << b << endl;
            a = b;
            b = "";
        }
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 772
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var n = h[0];
		var rs = new int[n - 1 + h[1]].Select(_ => read()).ToArray();

		var map = rs.ToLookup(r => r[0], r => r[1]);
		var map_r = rs.ToLookup(r => r[1], r => r[0]);
		var ins = Enumerable.Range(0, n + 1).Select(i => map_r[i].Count()).ToArray();

		var q = new Queue<int>(Enumerable.Range(1, n).Where(i => ins[i] == 0));
		var u = new int[n + 1];
		while (q.Any())
		{
			var p = q.Dequeue();
			foreach (var np in map[p])
				if (--ins[np] == 0)
				{
					u[np] = u[p] + 1;
					q.Enqueue(np);
				}
		}
		Console.WriteLine(string.Join("\n", Enumerable.Range(1, n).Select(i => map_r[i].SingleOrDefault(x => u[i] - u[x] == 1))));
	}
}


Measured memory_bytes: 50696
A, B, H, M = gets.chomp.split.map(&:to_i)

ar = 2 * Math::PI / 12 * H + (2 * Math::PI / 12 / 60) * M;
br = 2 * Math::PI / 60 * M;

ax = A * Math.cos(ar)
ay = A * Math.sin(ar)

bx = B * Math.cos(br)
by = B * Math.sin(br)

puts Math.sqrt((ax - bx) ** 2 + (ay - by) ** 2)


Measured memory_bytes: 14820
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]

H.sort(reverse=True)

max_num = H[0]
min_num = H[K-1]
diff = max_num - min_num
l_h = len(H)
for i in range(l_h-K+1):
    max_num = H[i]
    min_num = H[i+K-1]
    _diff = max_num - min_num
    if _diff < diff:
        diff = _diff
print(diff)


Measured memory_bytes: 7384
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if N == 1:
  if max_ans % 10 == 0:
    print(0)
    exit(0)
  else:
    print(max_ans)
    exit(0)
if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <random>
#include <functional>

using namespace std;

#define F first
#define S second
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << ": "; for (auto& xxxx: a) cerr << xxxx << " "; cerr << endl;
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define pw(n) (1ll << (n))

#define equal equalll
#define less lesss
typedef long double dbl;
typedef long long ll;
const int N = 888;
const ll INF = 1.01e9;
typedef vector<int> vi;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};

char s[N][N];

int main(){
#ifdef HOME 
    assert(freopen("in", "r", stdin));
#endif
    int n, m, k;
    scanf("%d%d%d",  &n, &m, &k);
    for (int i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }

    int sx = -1;
    int sy = -1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            if (s[i][j] == 'S') {
                sx = i;
                sy = j;
            }
        }
    queue<pair<int,int>> q;
    q.push({sx, sy});
    vector<vector<int>> dist(n, vector<int>(m, INF));
    dist[sx][sy] = 0;
    while (!q.empty()) {
        int x = q.front().F;
        int y = q.front().S;
        q.pop();
        for (int i = 0; i < 4; i++) {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if (0 <= xx && xx < n && 0 <= yy && yy < m && s[xx][yy] == '.' && dist[xx][yy] > dist[x][y] + 1) {
                dist[xx][yy] = dist[x][y] + 1;
                q.push({xx, yy});
            }
        }
    }
    int best = INF;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (dist[i][j] <= k) {
                best = min(best, i);
                best = min(best, j);
                best = min(best, n - i - 1);
                best = min(best, m - j - 1);
            }
    
    if (sx == 0 || sy == 0 || sx == n - 1 || sy == m - 1) {
        puts("0");
    }
    else {
        printf("%d\n", 1 + (best + k - 1) / k);
    }

    
    
#ifdef HOME 
    epr("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
#endif
    return 0;
}



Measured memory_bytes: 3584
N = input()
A = map(int, raw_input().split())
C = [0]*N
for a in A:
    C[a] += 1
ok = True
if N%2==0 and C[0]!=0 or N%2!=0 and C[0]!=1:
    ok = False
for i in range(N%2+1, N, 2):
    if C[i]!=2:
        ok = False
print 2**(N/2)%(10**9+7) if ok else 0


Measured memory_bytes: 11328
import math
def sieve(n):
    p = [1] * (n + 1)
    p[0] = p[1] = 0
    
    for i in range(math.ceil((n + 1) ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p

from itertools import compress, count
def prime_factor(n):
    p = sieve(int(n ** 0.5))
    factor = []
    for pi in compress(count(0), p):
        while n % pi == 0:
            n //= pi
            factor.append(pi)

    if n != 1:
        factor.append(n)
    return factor

from sys import stdin
from functools import reduce
from operator import mul
from collections import Counter
readline = stdin.readline

print(reduce(mul, (pow(p, k) - pow(p, k - 1) for p, k in Counter(prime_factor(int(readline()))).items())))

Measured memory_bytes: 7084
#include <stdio.h>

int main(void){

        long int a,b,c,d,n;
        int judge = 0;
        char s[200000];
    
        scanf("%ld%ld%ld%ld%ld",&n,&a,&b,&c,&d);
        scanf("%s",s);

        //if(s[a-1] == '.' && s[b-1] == '.' && s[c-1] == '.' && s[d-1] == '.'){//abcdについて   
                if(c>d){//どこかでaがbを跨がなければならない//bとdの間に...がないとできない
                        for(int i=b-1;i<d;i++){
                                if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
                                        judge = 2;
                                }   
                        }   
                }else{
                        judge = 2;
                }   
        //} 


if(d>c){
        for(int i=a;i<d;i++){
                if(s[i] == '#' && s[i+1] == '#'){
                        judge = 1;
                }   
        }   
}else{
        for(int i=a;i<c;i++){
                if(s[i] == '#' && s[i+1] == '#'){
                        judge = 1;
                }   
        }   
}
    
        if(judge == 2){ 
                printf("Yes\n");
        }else{
                printf("No\n");
        }   
return 0;
}


Measured memory_bytes: 384
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

template<typename T>
vector<T> getVector(int N) {
    vector<T> v(N);
    REP(i, N) cin >> v[i];
    return v;
}

int main(void)
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int turn = 0;
    while(A > 0 && C > 0) {
        if (turn%2 == 0) {
            C -= B;
        }
        else {
            A -= D;
        }
        turn++;
    }
    if (A > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
from sys import setrecursionlimit
setrecursionlimit(10 ** 5 + 10)

N, M, *XY = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for x, y in zip(*[iter(XY)] * 2):
    E[x].append(y)

memo = {}
def dp(p):
    if p not in memo:
        memo[p] = max((1 + dp(c) for c in E[p]), default=0)
    return memo[p]

print(max(dp(p) for p in range(1, N + 1)))

Measured memory_bytes: 126648
<?php
$length = trim(fgets(STDIN));
$chars = trim(fgets(STDIN));
$count = substr_count($chars, 'E');
$answer = $count;
for ($i=0; $i < $length; $i++) {
    if ($chars[$i] === 'E') {
        $count--;
    } elseif ($chars[$i] === 'W') {
        $count++;
    }
    $answer = min($count, $answer);
}
echo $answer."\n";


Measured memory_bytes: 4212
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	map<int, int> Map;
	vector<P> Vec;
	set<int> Set;
	P p;
	while(~scanf("%d,%d", &p.second, &p.first))
	{
		if(p.first == 0 && p.second == 0)
		{
			break;
		}
		Vec.push_back(p);
	}
	sort(Vec.begin(), Vec.end());
	int n = Vec.size();
	for(int i = 0; i < n; ++i)
	{
		Set.insert(Vec[i].first);
	}
	int rank = Set.size();
	set<int>::iterator Ite = Set.begin();
	for(int i = 0; i < n; ++i)
	{
		if(*Ite != Vec[i].first)
		{
			++Ite;
			--rank;
		}
		Map[Vec[i].second] = rank;
	}
	int num;
	while(cin >> num)
	{
		cout << Map[num] << endl;
	}
}

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

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
#define CO(x) cout<<(x)<<endl;
#define COSP(x) cout<<(x)<<" ";
#define DICIMAL(x) fixed<<setprecision(x)
using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int N; cin>>N;
  vector<ll> A(N); REP(i,N) cin>>A[i];

  ll ans = A[0];
  REP(i,N) ans = gcd(ans, A[i]);

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


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace bla
{
    class Program
    {
        static void Main()
        {
            int r = int.Parse(Console.ReadLine());
            if (r < 1200)
                Console.WriteLine("ABC");
            else if (r < 2800)
                Console.WriteLine("ARC");
            else
                Console.WriteLine("AGC");
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    int n = str.length();
    for(int i=0;i<n;i=i+2){
      System.out.print(str.charAt(i));
    }
  }
}

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

// ??????????????????f??¨????????¨f(N)<N ????????§?????????????????????????????¨????????????

public class Main{
    public static void main(String args[]) throws Exception{
    	BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
    	int Q= Integer.parseInt( br.readLine() );
    	for(int i=0;i<Q;i++){
    		String strN= br.readLine();
    		int cnt=0;
    		while( strN.length() > 1 ){
    			int max= 0;
        		for(int j=1; j<strN.length(); j++){
        			int n1= Integer.parseInt(strN.substring(0,j));
        			int n2= Integer.parseInt(strN.substring(j));
        			if( max< n1*n2 ){ max= n1*n2; }
        		}
        		strN= String.valueOf(max);
        		cnt++;
    		}
    		System.out.println(cnt);
    	}
    }
}

Measured memory_bytes: 20760
#include <iostream>
#define intloop(i,n) for (int i = 0; i < n; i++)
#define charloop(j,n) for(char i =j;i<=n;i++)
using namespace std;

void solve(long n) {
	string ans = "";
	while (n) {
		if (n % 26 == 0) {
			ans = 'z' + ans;
			--n;
		} else {
			char c = (n % 26 - 1) + 'a';
			ans = c + ans;
		}
		n /= 26;
	}
	cout << ans;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long n;
	cin >> n;
	solve(n);
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	vector<long long>dp(n,1145141919),num(n);
	for(int i=0;i<n;i++){
	    cin>>num[i];
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
	    if(i+1<n)dp[i+1]=min(dp[i+1],dp[i]+abs(num[i]-num[i+1]));
		 if(i+2<n)dp[i+2]=min(dp[i+2],dp[i]+abs(num[i]-num[i+2]));
	    
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
N = int(input())
alf = [chr(i) for i in range(97, 97+26)]
List = []
for i in range(100):
  if N > 0:
    N -= 1
    a = N % 26
    N = N // 26
    List.append(alf[a])
  else:
    break
    

print("".join(List[::-1]))


Measured memory_bytes: 9112
fn input1<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

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

fn main() {
    let n: usize = input1().unwrap();
    let ds: Vec<usize> = input_arr();
    println!("{}", (0..n).map(|i| (i+1..n).map(|j| ds[i] * ds[j]).sum::<usize>()).sum::<usize>());
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int N; string S;
  cin >> N;
  cin >> S;
  
  int r = 0, w = 0;
  for(char c : S) {
    if (c == 'W') {
      w++;
    } else if (c == 'R') {
      r++;
    }
  }

  int ans = 0;
  REP(i,r) {
    if (S[i] == 'W') {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
    int h, w, n; scanf("%d%d%d", &h, &w, &n);
    int t = max(h, w);
    int ans = n / t; if (n % t) ans++;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

string a[200005];
string b[200005];
int cnt;
int f[200005];
int n;


void inp()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
}


void proc()
{
    int l = 0;
    sort(a+1,a+n+1);
    for (int i = 1; i <= n; i++)
    {
        if (a[i] != a[i-1])
        {
            f[i] = 1;
        }
        else
        {
            f[i] = f[i-1] + 1;
        }
        l = max(l,f[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        if (f[i] == l)
        {
            b[cnt++] = a[i];
        }
    }
    sort(b,b+cnt);
    for (int i = 0; i < cnt; i++) cout << b[i] << "\n";
}


int main()
{
    inp();
    proc();
    return 0;
}


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

int main() {
	int a,b,ans;
	ans = 0;
	cin >> a>>b;

	if (a > b) {
		ans = ans + a;
		a = a - 1;
	}
	else {
		ans = ans + b;
		b = b - 1;
	}

	if (a > b) {
		ans = ans + a;
		a = a - 1;
	}
	else {
		ans = ans + b;
		b = b - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    vector<int> x(5);
    rep(i,5){
        int a;
        cin >> a;
        x[i] = a;
    }
    rep(i,5){
        if(x[i] ==0){
        cout << i+1 << endl;
        }
    }

}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
using namespace std;

void dfs(vector<vector<int> > &g, vector<bool> &used, int v = 0){
  used[v] = true;
  for (int i = 0; i < g[v].size(); i++) {
    if(used[g[v][i]] == true)continue;
    dfs(g, used, g[v][i]);
  }
}

int main(){
  int n, m, k;
  std::cin >> n >> m;
  vector<vector<int> > l(n + m);
  for (int i = 0; i < n; i++) {
    std::cin >> k;
    for (int j = 0; j < k; j++) {
      int tmp;
      std::cin >> tmp;
      l[i].emplace_back(tmp - 1 + n);
      l[tmp - 1 + n].emplace_back(i);
    }
  }
  vector<bool> used(n + m, false);
  dfs(l, used);
  bool flag = true;
  for (int i = 0; i < n; i++) {
    flag &= used[i];
  }
  std::cout << ((flag == true)?"YES":"NO") << std::endl;
  return 0;
}


Measured memory_bytes: 8440
#include<stdio.h>

int main(){
	int n;
	int ns[10];
	int length;
	length = 0;
	while(scanf("%d",&n)!=EOF){
		if(n == 0){
			length -= 1;
			printf("%d\n",ns[length]);
		}else{
			ns[length] = n;
			length += 1;
		}
	}
	return 0;
}

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

using namespace std;
    int si[6];

    int main(){
        while(1){
        int sum = 1;
        si[0]=1;
        si[1]=2;
        si[2]=3;
        si[3]=5;
        si[4]=4;
        si[5]=6;
        int H;
    int coun=0;
    cin >> coun ;
    if(coun == 0)break;
    string num;
    for(int a=0;a<coun;a++){
        cin >> num;
        if(num == "North"){
        H=si[0];
        si[0]=si[1];
        si[1]=si[5];
        si[5]=si[3];
        si[3]=H;
     //   cout << si[0];
        }else
        if(num == "East"){
        H=si[0];
        si[0]=si[4];
        si[4]=si[5];
        si[5]=si[2];
        si[2]=H;
      //          cout << si[0];
        }else
        if(num == "West"){
        H=si[0];
        si[0]=si[2];
        si[2]=si[5];
        si[5]=si[4];
        si[4]=H;
        //        cout << si[0];
        }else if(num == "South"){
        H=si[0];
        si[0]=si[3];
        si[3]=si[5];
        si[5]=si[1];
        si[1]=H;
          //      cout << si[0];
        }else if(num == "Right"){
        H=si[1];
        si[1]=si[2];
        si[2]=si[3];
        si[3]=si[4];
        si[4]=H;
            //    cout << si[0];
        }else if(num == "Left"){
        H=si[1];
        si[1]=si[4];
        si[4]=si[3];
        si[3]=si[2];
        si[2]=H;
              //  cout << si[0];
        }
        sum = sum + si[0];

    }
    cout << sum << endl;
        }
return 0;
}

Measured memory_bytes: 1216
n = int(input())
p = list(map(int,input().split()))
ans = 0

for i in range(1,n - 1):
    if p[i - 1] <= p[i] <= p[i + 1] or p[i + 1] <= p[i] <= p[i - 1]:
        ans += 1
print(ans)


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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    for (int i = 0; i < k; i++) {
        if (b <= a) b *= 2;
        else if (c <= b) c *= 2;
    }

    if (b > a && c > b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;

int main()
{
  int N, M, C;
  while (cin >> N >> M >> C && N != 0) {
    C *= 10;
    map<string,int> m;
    string start, goal;
    cin >> start >> goal;
    m.insert(make_pair(start, 0));
    m.insert(make_pair(goal, 1));
    vector<vector<pair<int,int> > > gg(2);
    for (int i = 0; i < N; i++) {
      string src, dst;
      int d;
      cin >> src >> dst >> d;
      int u, v;
      if (!m.count(src)) {
        u = m.size();
        m.insert(make_pair(src, u));
        gg.push_back(vector<pair<int,int> >());
      } else {
        u = m[src];
      }
      if (!m.count(dst)) {
        v = m.size();
        m.insert(make_pair(dst, v));
        gg.push_back(vector<pair<int,int> >());
      } else {
        v = m[dst];
      }
      gg[u].push_back(make_pair(v, d));
      gg[v].push_back(make_pair(u, d));
    }

    vector<int> gss, gss_map(gg.size(), -1);
    gss.push_back(0); // start
    gss.push_back(1); // goal
    gss_map[0] = 0;
    gss_map[1] = 1;
    for (int i = 0; i < M; i++) {
      string s;
      cin >> s;
      const int v = m[s];
      if (v != 0 && v != 1) {
        gss_map[v] = gss.size();
        gss.push_back(v);
      }
    }
    const int MM = gss.size();

    static const int INF = 10000000;
    vector<vector<int> > dist(MM, vector<int>(MM, INF));
    for (int i = 0; i < MM; i++) {
      priority_queue<pair<int,int> > q;
      vector<int> dp(gg.size(), INF);
      dp[gss[i]] = 0;
      q.push(make_pair(0, gss[i]));
      while (!q.empty()) {
        const int n = q.top().second;
        const int c = -q.top().first;
        q.pop();
        if (c > dp[n]) {
          continue;
        }
        for (vector<pair<int,int> >::const_iterator it = gg[n].begin(); it != gg[n].end(); ++it) {
          int k = it->first;
          const int cc = c + it->second;
          if (cc <= C && cc < dp[k]) {
            dp[k] = cc;
            if (gss_map[k] != -1) {
              dist[i][gss_map[k]] = min(dist[i][gss_map[k]], cc);
            } else {
              q.push(make_pair(-cc, k));
            }
          }
        }
      }
    }

    priority_queue<pair<int,int> > q;
    vector<int> dp(MM, INF);
    dp[0] = 0;
    q.push(make_pair(0, 0));
    while (!q.empty()) {
      const int n = q.top().second;
      const int c = -q.top().first;
      q.pop();
      if (n == 1) {
        cout << c << endl;
        goto NEXT;
      }
      for (int v = 0; v < MM; v++) {
        const int cc = c + dist[n][v];
        if (dist[n][v] != INF && cc < dp[v]) {
          dp[v] = cc;
          q.push(make_pair(-cc, v));
        }
      }
    }
    cout << "-1" << endl;
NEXT:
    ;
  }
  return 0;
}

Measured memory_bytes: 0