akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int x;
    cin >> x;
    vector<int> v;
    for (int i = 1; i * i <= x;i++){
        if(x%i==0){
            v.push_back(i);
            if(i*i!=x){
                v.push_back(x / i);
            }
        }
    }
    sort(ALL(v));
   // show(v);
    for (int i = 0; i < v.size(); i++)
    {
        int a, b;
        for (int j = -1000; j <=1000; j++)
        {
            a = j;
            b = a - v[i];
            if(a*a*a*a*a- b*b*b*b*b == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

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

fn main() {
    let v = read_vec::<i64>();
    let (s, c) = (v[0], v[1]);
    if c > 2 * s {
        println!("{}", s + (c - 2 * s) / 4);
    } else {
        println!("{}", min(s, c / 2));
    }
}

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

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


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A[3];
	rep(i, 0, 3)cin >> A[i];

	sort(A, A + 2);

	cout << (A[0] <= A[2] && A[2] <= A[1] ? "Yes" : "No") << endl;

	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> a;
    int minDist = 0;

    for(int i=0; i<N; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end());

    for(int i=0; i<N-1; i++)
    {
        minDist += (a[i+1]-a[i]);
    }
    cout << minDist << endl;
    return 0;
}

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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

int n, a[N], s;

int main()
{

    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", a + i);
        s ^= a[i];
    }
    for(int i = 0; i < n; i++)
        printf("%d ", s ^ a[i]);
    return 0;
}


Measured memory_bytes: 4536
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

vector<ll> v;

ll f(ll n, ll x, ll m){
  ll ret = n-1;
  x %= m;
  vector<ll> v1;
  rep(i,0,v.sz){
    v1.pb(v[i]%m);
  }
  ll sum = 0;
  ll z = 0;
  rep(i,0,v1.sz){
    sum += v1[i];
    if(v1[i]==0)z++;
  }
  ll ans = 0;
  ll a = (n-1)/v1.sz;
  ll b = (n-1)%v1.sz;
  ll c = x+sum*a;
  ans += c/m;
  ans += z*a;
  c%=m;
  rep(i,0,b){
    if(v1[i]==0)ans++;
    c += v1[i];
    if(c>=m){
      ans++;
    }
    c%=m;
  }
  return ret-ans;
}

int main(){
  ll k,q;
  cin>>k>>q;
  rep(i,0,k){
    ll a;
    cin>>a;
    v.pb(a);
  }
  rep(i,0,q){
    ll n,x,m;
    cin>>n>>x>>m;
    ll ans = f(n,x,m);
    cout << ans << endl;
  }
  return 0;
}

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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,pair<int,int>>>
#define pb push_back
#define mod 1000000007

using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    double curr = a[0];
    for (int i = 1; i <n; i++) {
        curr = (curr + a[i]) / 2.0;
    }
    cout << fixed << setprecision(5) << curr;
    return 0;
}

ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

int main(){
	string s;cin >> s;
	int cnt=0;
	bool a=true;
	for(int i=2;i<s.size()-1;++i){
		if(s.at(i)=='C') cnt++;
	}
	for(int i=1;i<s.size();++i){
		int x=s.at(i)-'a';
		if(s.at(i)!='C' && x<0) a=false;
	}
	if(s.at(0)=='A' && cnt==1 && a) cout << "AC" << endl;
	else cout << "WA" << endl;
}

Measured memory_bytes: 256
length = int(input())
List = list(map(int,input().split()))

count = 0
state = 1

while state:
    state = 0
    for i in range(length-1):
        if List[i] > List[i+1]:
            stuck = List[i]
            List[i] = List[i+1]
            List[i+1] = stuck
            state = 1
            count += 1

for i in range(length):
    if i == length - 1:
        print(List[length-1])
    else: print(List[i],end=' ')
print(count)


Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <stack>

typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    stack<char> st;
    for(int i=0; i<s.length(); i++) {
        if(st.empty() || s[i]==st.top()) st.push(s[i]);
        else st.pop();
    }
    cout << s.length() - st.size() << endl;
    return 0;
}

Measured memory_bytes: 512
/* Code by : Suraj (@suraj1611) */

#include<bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define maxsize 1100005
#define lb cout<<endl;
#define endl "\n"
#define F first
#define S second
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll x, ll  y) 
{ 
	ll m=md;
   	ll ans=1;
    while (y > 0) 
    {
        if (y & 1)
            ans = (ans * x) % m;
        x = (x * x) % m;
        y >>= 1;
    }
    return ans;
} 

int main()
{
	IOS
	


	ll n,x;
	cin>>n>>x;
	ll a[n],csa[n+2];
	rep(i,n)
	cin>>a[i];
	csa[0]=0;
	rep1(i,n)
	{
		csa[i]=a[i-1]+csa[i-1];
		//cout<<csa[i]<<endl;
	}

	ll c=0;
	rep(i,n+1)
	{
		if(csa[i]<=x)
			c++;
		else
			break;
	}

	cout<<c<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> c(w);
    for(int i = 0; i < w; i++) {
        c[i].resize(h);
    }
    for(int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for(int j = 0; j < w; j++) {
            c[j][i] = s[j];
        }
    }
    auto cst = make_v<int>(w, h);
    int ans = 0;
    for(int i = 0; i < w - 1; i++) {
        auto f = make_v<int>(h + 1, h + 1);
        for(int j = 0; j < h; j++) {
            for(int k = 0; k < h - j; k++) {
                if(c[i][k + j] == c[i + 1][k]) {
                    f[0][j]++;
                }
            }
            for(int k = 1; k <= h - j; k++) {
                f[k][j + k] = f[k - 1][j + k - 1];
                if(h - k - j >= 0 && c[i][h - k] == c[i + 1][h - k - j]) {
                    f[k][j + k]--;
                }
            }
        }
        for(int j = 1; j < h; j++) {
            for(int k = 0; k < h - j; k++) {
                if(c[i][k] == c[i + 1][k + j]) {
                    f[j][0]++;
                }
            }
            for(int k = 1; k <= h - j; k++) {
                f[j + k][k] = f[j + k - 1][k - 1];
                if(h - k - j >= 0 && c[i][h - k - j] == c[i + 1][h - k]) {
                    f[j + k][k]--;
                }
            }
        }
        auto d = make_v<int>(h + 1, h + 1);
        fill_v(d, INF);
        d[0][0] = 0;
        for(int j = 0; j <= h; j++) {
            for(int k = 0; k <= h; k++) {
                if(j > 0) {
                    chmin(d[j][k], d[j - 1][k] + f[j - 1][k]);
                }
                if(k > 0) {
                    chmin(d[j][k], d[j][k - 1] + f[j][k - 1]);
                }
            }
        }
        int mi = INF;
        for(int j = 0; j <= h; j++) {
            chmin(mi, d[h][j]);
        }
        ans += mi;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1544
//writer：Sakura

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

int a,b;
int h[1005];
//int as=0,bs=0;
int ans=0;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d %d",&a,&b);
	for(int i=1;i<=999;i++){
		h[i]=h[i-1]+i;
	}
	//for(int i=1;i<=999;i++)cout<<h[i]<<endl;
	ans=abs(b-a);
	//printf("%d\n",h[ans]);
	ans=abs(h[ans]-b);
	printf("%d\n",ans);
	//printf("%d %d\n",as,bs);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
int main() {
  string T;
  cin >> T;
  rep(i,T.size()){
    if(T.at(i) =='?'){
      T.at(i) = 'D';
    }
  }
  cout << T << endl;
  return 0;
}

Measured memory_bytes: 3724
parseline(str=readline()) = parse.(Int, split(str))
function StringFormation()
    S = readline()
    Q = parseline()
    queries = split.(readlines())
    inverse = false
    ans = [S]
    for q in queries
        l = length(q)
        l≡0 && continue
        if l≡1
            inverse = !inverse
        else
            head = q[2]=="1" ? true : false
            head = inverse ? !head : head
            head ? pushfirst!(ans, q[3]) : push!(ans, q[3])
        end
    end
    ret = prod(ans)
    println(inverse ? ret[end:-1:1] : ret)
end
StringFormation()

Measured memory_bytes: 328896
import static java.lang.String.*;

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan =new Scanner(System.in);
			int num;
			for(int i = 1;(num = scan.nextInt())!= 0;i++)
				System.out.println("Case "+valueOf(i)+": "+valueOf(num));
		}finally{
			if(scan !=null)scan.close();
		}

	}
}

Measured memory_bytes: 33132
#encoding:utf-8 No.0521 2014.11.11
while (price = gets.chomp.to_i) != 0
  change = 1000 - price
  count = 0
  until change == 0
    if change >= 500
      change -= 500
      count += 1
    elsif change >= 100
      change -= 100
      count += 1
    elsif change >= 50
      change -= 50
      count += 1
    elsif change >= 10
      change -= 10
      count += 1
    elsif change >= 5
      change -= 5
      count += 1
    else
      count += change
      change = 0
    end
  end
  puts count
end

Measured memory_bytes: 6092
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define REP_REV(i, n) for (ll i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n, d, a;
  cin >> n >> d >> a;
  d = 2 * d;
  vector<Pair> b;
  REP(i, n) {
    ll x, h;
    cin >> x >> h;
    b.emplace_back(x, h);
  }
  sort(all(b));
  ll ans = 0;
  ll sum_v = 0;
  queue<Pair> q;
  REP(i, n) {
    while(q.size() && q.front().first < b[i].first) {
      sum_v -= q.front().second;
      q.pop();
    }
    if(sum_v * a < b[i].second) {
      ll tmp = (b[i].second - sum_v * a + a - 1) / a;
      ans += tmp;
      sum_v += tmp;
      q.emplace(b[i].first + d, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long power(long long x,int y)

{

    if (!y)

    return 1;

    long long ret=power(x,y/2);

    ret=(ret*ret)%mod;

    if (y%2)

    ret=(ret*x)%mod;

    return ret;

}
int main(){
  long long a[100005],b[100005];
  long long i,n,res1,res2,k,res;
  a[0]=1;b[0]=1;
  for(i=1;i<100005;i++) {a[i]=(a[i-1]*i)%mod;b[i]=power(a[i],mod-2);}
  cin>>n>>k;
  for(i=1;i<=k;i++){
   if(n-k+1-i<0)res=0;
   else{
   res1=(a[n-k+1]*b[n-k+1-i])%mod;
   res1=(res1*b[i])%mod;
   res2=(a[k-1]*b[i-1])%mod;
   res2=(res2*b[k-i])%mod;
   res=(res1*res2)%mod;}
   cout<<res<<'\n'; 
}
  return 0;
}

Measured memory_bytes: 1920
'use strict';
function main(input) {
  const a = input.trim().split('\n')[0].split(' ').map(x => Number(x));
  const b = input.trim().split('\n')[1].split(' ').map(x => Number(x)).sort(function (a, b) {
    return b - a;
  });
  let sum = b.reduce((a,c) => a + c);

  if (b[(a[1] - 1)] < sum / 4 / a[1]) {
    console.log('No');
  } else {
    console.log('Yes');
  }
  
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

class Program {
  static void Main() {
    int x = int.Parse(Console.ReadLine());
    List<int> lst = new List<int> {1};
    for (int b = 2; b * b <= x; b++) {
      for (int p = 2; ; p++) {
        int t = (int)Math.Pow(b, p);
        if (t <= x) lst.Add(t);
        else break;
      }
    }
    Console.WriteLine(lst.OrderByDescending(e => e).First());
  }
}

Measured memory_bytes: 13396
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

import math # version 3.4
from collections import defaultdict
from functools import reduce

from itertools import product
k = n_in()
#k = 200

memo = {}

def gcd(a,b):
    if a == 1 or b == 1:
        return 1
    if a == b:
        return a
    if b < a:
        a,b = b,a
    if (a,b) in memo:
        return memo[(a,b)]
    else:
        memo[(a,b)] = math.gcd(a,b)
        return memo[(a,b)]
    
res = 0
for a,b,c in product(range(1,k+1), repeat=3):
    q = gcd(a,b)
    res += gcd(q,c)

print(res)


Measured memory_bytes: 74580
#include <cstdio>

int main(void) {
    int n;
    scanf("%d", &n);
    int order[n];

    for (int i=0; i<n; i++) {
        int existedNumber;
        scanf("%d", &existedNumber);
        order[existedNumber-1] = i+1;
    }

    for (int i=0; i<n; i++) {
        printf("%d ", order[i]);
    }

    return 0;
}

Measured memory_bytes: 1152
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

long gcd(long a, long b) {
	long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long lcm(long a, long b) {
	return a * b / gcd(a, b);
}

int main() {
	long long a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 0) {
		if (a - b > pow(10, 18)) {
			cout << "Unfair" << endl;
		}
		else {
			cout << a - b << endl;
		}
	}
	else {
		if (b - a > pow(10, 18)) {
			cout << "Unfair" << endl;
		}
		else {
			cout << b - a << endl;
		}
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,m; cin >> n >> m;
    vvl G(n);
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }
    vl ans(n+1);
    vl d(n,INF);
    vl pre(n,-1);
    rep(i,n){
        vl now;
        bool flag = false;
        rep(i,n) pre[i] = -1;
        rep(i,n) d[i] = INF;
        d[i] = 0;
        queue<ll> q;
        q.push(i);
        while(!q.empty()){
            ll u = q.front(); q.pop();
            for(auto v : G[u]){
                if(d[v] != INF && v != i) continue;
                d[v] = d[u] + 1;
                pre[v] = u;
                if(v == i){
                    flag = true;
                    break;
                }
                q.push(v);
            }
            if(flag) break;
        }
        if(d[i] > 0){
            ll u = i;
            now.push_back(i+1);
            while(pre[u] != i){
                now.push_back(pre[u]+1);
                u = pre[u];
            }
            if(now.size() < ans.size()) ans = now;
        }
    }
    if(ans.size()==n+1) puts("-1");
    else{
        cout << ans.size() << endl;
        for(auto i : ans){
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int A[100005],B[100005];
int ans;

signed main(){
    cin>>N;
    for(int i=0;i<N+1;++i)cin>>A[i];
    for(int i=0;i<N;++i)cin>>B[i];
    for(int i=0;i<N;++i){
        int a,b,na;
        a=max(A[i]-B[i],0ll);
        b=max(B[i]-A[i],0ll);
        na=max(A[i+1]-b,0ll);
        ans+=(A[i]-a)+(A[i+1]-na);
        A[i+1]=na;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <climits>
#include <set>

class Graph
{
 private:
  std::vector<std::vector<long> > weight_;
 public:
  Graph(const unsigned long node_num){};


  void insert_weight(const std::vector<long> weight){
    weight_.push_back(weight);
  };


  void display()
  {
    for(unsigned long i = 0, imax = weight_.size(); i < imax; ++i)
    {
      for(unsigned long j = 0, jmax = weight_[i].size(); j < jmax; ++j)
      {
        std::cout << " " << weight_[i][j];
      }
      std::cout << std::endl;
    }
  };


  unsigned long MinimumSpanningTree()
  {
    if(weight_.size() <= 1) return 0;

    struct Edge
    {
      long value_;
      long start_node_;
      long end_node_;
      Edge(long value = LONG_MAX, long sn = -1, long en = -1) : value_(value), start_node_(sn), end_node_(en){};
      void change(long value, long sn, long en)
      {
        value_ = value; start_node_ = sn, end_node_ = en;
      };
      void display()
      {
        std::cout << value_ << " : " << start_node_ << " : " << end_node_ << std::endl;
      };
    };

    unsigned long minimum_spanning_value = 0;

    std::set<long> connect_node; connect_node.insert(0);
    std::set<long> noconnect_node;

    for(unsigned long node_i = 1, imax = weight_.size(); node_i < imax; ++node_i)
      noconnect_node.insert(node_i);

    while(!noconnect_node.empty())
    {
      Edge min_edge;
      for(std::set<long>::iterator it = connect_node.begin(); it != connect_node.end(); ++it)
      {
        for(std::set<long>::iterator noit = noconnect_node.begin(); noit != noconnect_node.end(); ++noit)
        {
          if(weight_[*it][*noit] == -1) continue;
          if(weight_[*it][*noit] < min_edge.value_)
          {
            min_edge.value_ = weight_[*it][*noit];
            min_edge.change(weight_[*it][*noit], *it, *noit);
          }
        }
      }
      connect_node.insert(min_edge.end_node_);
      noconnect_node.erase(min_edge.end_node_);
      minimum_spanning_value += min_edge.value_;
    }

    return minimum_spanning_value;
  };//   unsigned long MinimumSpanningTree()
 protected:
};//    class Graph

int main()
{

  unsigned long node_num = 0;
  std::cin >> node_num; std::cin.ignore();

  Graph graph(node_num);

  for(unsigned long node_i = 0; node_i < node_num; ++node_i)
  {
    std::vector<long> weight(node_num, -1);
    for(unsigned long weight_i = 0, weight_num = node_num; weight_i < weight_num; ++weight_i)
    {
      std::cin >> weight[weight_i]; std::cin.ignore();
    }
    graph.insert_weight(weight);
  }

  std::cout << graph.MinimumSpanningTree() << std::endl;

  return 0;
};//    main()

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

int main(void) {
  int N; cin >> N;
  
  if(N == 1){
    cout << "Hello World";
  }

  if(N == 2){
    int A, B; cin >> A >> B;

    cout << A + B;
  }
  return 0;
}

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

typedef long long ll;

typedef pair<ll, pair<int, int> > p;

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

    int r, g, b;
    cin >> r >> g >> b;

    int x = 100 * r + 10 * g + b;

    if(x % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;

int main(){
	int N, tmp;
	int dp[10][10];
	memset(dp, 0, sizeof dp);
	cin>>N;
	
	for(int i=1;i<=N;i++){
		int l = i%10;
		int tmp = i;
		while(tmp/10 != 0)
			tmp /= 10;
		int f = tmp;
		dp[f][l]++;
	}
	ll ans = 0;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			ans += dp[i][j]*dp[j][i];
		}
	}
	cout<<ans<<"\n";
	return 0;
}

/*
c[i][j] = No. of integers less than N such that 1st digit is i and last digit is j.
*/

Measured memory_bytes: 256
import sys

inf = sys.maxsize
N = int(input())
B = list(map(int, input().split()))

A = [0]*N
A[0] = B[0]
for i in range(N-1):
    if A[i] > B[i]:
        A[i] = B[i]
    A[i+1] = B[i]
print(sum(A))

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, k);
    int2(x, y);
    int ans = 0;
    Rep(i, n+1) {
        if (i <= k) {
            ans += x;
        } else {
            ans += y;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int main()
{
	int c[3];
	while (scanf("%d %d %d\n", c, c+1, c+2) != EOF)
	{
		bool left[11];
		fill(left, left+11, true);
		for (int i = 0; i < 3; ++i)
			left[c[i]] = false;

		int safe = 20 - (c[0]+c[1]);
		int t = 0;
		for (int i = 1; i <= safe; ++i)
		{
			if (left[i])
				++t;
		}
		if ((double)t/7 >= 0.5)
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}

Measured memory_bytes: 0
main = solve . head . map read . words <$> getLine >>= putStrLn

cs = ['a'..'z']

at 0 (c:_) = c
at n (_:l) = at (n-1) l

solve n = reverse $ solve' (n-1)

solve' :: Integer -> String
solve' n
    | n < 26   = [at n' cs]
    | otherwise = at n' cs : solve' n''
    where
        n'  = n `mod` 26
        n'' = n `div` 26 - 1

Measured memory_bytes: 3944
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int l, r; cin >> l >> r;
	if (r - l >= 2019) {
		cout << 0 << endl; return 0;
	}
	int ans = INF;
	for (int i = l; ; i++) {
		if (i - 3 >= r)break;
		for (int j = i + 1; j <= r; j++) {
			chmin(ans, ((i%2019)*(j%2019)) % 2019);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    double A[5];
    double a[5];

    int timeMemo[5];
    int minTimeRemainder = 10;
    int imemo;

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

        a[i] = ceil(A[i]/10) * 10;

        timeMemo[i] = (int) A[i] % 10;
        if (timeMemo[i] == 0)
        {
            timeMemo[i] = 10;
        }
        if (timeMemo[i] < minTimeRemainder)
        {
            minTimeRemainder = timeMemo[i];
            imemo = i;
        }
    }

    int ordertime;

    for (int i = 0; i < 5; i++)
    {
        ordertime += a[i];
    }

    ordertime = ordertime - a[imemo] + A[imemo];

    cout << ordertime << endl;

    return 0;
}

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

using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	vector<vector<int> > dp(n+1,vector<int>(m+1));
	
	
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
			else               dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	string ans;
	int i = n,j = m;
	while(true){
		if(i==0 || j==0) break;
		if(dp[i][j]==dp[i-1][j]){
			i--;
		}else if(dp[i][j] == dp[i][j-1]) j--;
		else{
			i--;
			j--;
			ans+=s[i];
		}
	}
	reverse(ans.begin(),ans.end());
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 35584
#include<stdio.h>

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


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

using namespace std;

#define ll long long 
#define endl "\n"

int main()
{
	int t, a[25],b[25], sum = 0;
	
	cin >> t;
	
	for(int i = 1; i <= t; i++)
	{
		cin >> a[i];
	}
	for(int i = 1; i <= t; i++)
	{
		cin >> b[i];
	}
	
	for(int i = 1; i <= t; i++)
	{
		int ans = a[i] - b[i];
		if(ans > 0) sum += ans;
	}
	
	cout << sum << endl;
	
	
	return 0;
}


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

public class Main {

	public static void main(String args[]) {
		FastScanner cin = new FastScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(FastScanner cin, PrintWriter cout) {
		assert solve(4, new int[] { 1, 4 }) == 7;
		assert solve(4, new int[] { 0, 4 }) == 8;

		assert solve(4, new int[] { 0, 3 }) == 7;
		assert solve(4, new int[] { 0, 5 }) == 8;
		assert solve(1, new int[] { 0 }) == 1;
		assert solve(1000000000, new int[] { 0, 1000, 1000000, 1000000000 }) == 2000000000;
		assert solve(10, new int[] { 0, 3, 5, 7, 100, 110, 200, 300, 311 }) == 67;
		int n = cin.nextInt();
		int t = cin.nextInt();
		int[] u = new int[n];
		for (int i = 0; i < n; i++)
			u[i] = cin.nextInt();
		int ans = solve(t, u);
		cout.println(ans);
	}

	private static int solve(int t, int[] u) {
		int ans = 0;
		int endExcl = 0;
		for (int start : u) {
			if (start < endExcl)
				ans = ans - endExcl + start;
			ans += t;
			endExcl = start + t;
		}
		return ans;
	}

	/**
	 * How to read input in Java — tutorial <br />
	 * By Flatfoot<br />
	 * http://codeforces.com/blog/entry/7018
	 */
	static class FastScanner {
		private BufferedReader br;
		private StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

		int nextInt() {
			return Integer.parseInt(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
			return str;
		}

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

}


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

using namespace std;

typedef long long int lli;

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

    int a, b;

    cin >> a >> b;

    if (abs(a-b)%2) cout << "IMPOSSIBLE" << endl;
    else cout << abs(a-b)/2 + min(a, b) << endl;

    return 0;
}


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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define endl '\n'

using namespace std;

int dp[1000][1000];
int a[1000][1000];
const int inf = 1e5;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int i, j, n, m;
    cin >> n >> m;
    for (i = 0; i < n; i++){
        string s; cin >> s;
        for (j = 0; j < m; j++){
            a[i][j] = int(s[j] == '#');
            dp[i][j] = inf;
        }
    }
    dp[0][0] = a[0][0];
    for (i = 0; i < n; i++){
        for (j = 0; j < m; j++){
            if (i > 0){
                dp[i][j] = dp[i - 1][j];
                if (!a[i - 1][j] && a[i][j]){
                    dp[i][j]++;
                }
            }
            if (j > 0){
                int cur  = dp[i][j - 1];
                if (!a[i][j - 1] && a[i][j]){
                    cur++;
                }
                dp[i][j] = min(dp[i][j], cur);
            }
        }
    }
    cout <<dp[n - 1][m - 1] << endl;

    return 0;
}


Measured memory_bytes: 4736
#include <iostream>

using namespace std;

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

int main(int argc, char **argv)
{
	int a, d, n, c, j;
	
	while(1){
		cin >> a >> d >> n;
		if(a == 0){
			break;
		}
		c = 0;
		j = 0;
		while(c != n){
			if(prime(a+j*d)){
				c++;
			}
			j++;
		}
		j--;
		cout << a+j*d << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ll x,k,d;
    cin >>x >> k >> d;
    x = abs(x);
    ll ans;
    if((x / d) > k){
        ans = x - k * d;
    }
    else{
        ll kaisuu = x / d;
        k -= kaisuu;
        x -= kaisuu * d;
        if(k % 2 == 0){
            ans = x;
        }
        else{
            ans = d-x;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,len=0,ans=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<s.size();i++)if(s[i]=='R')len++;
	for(int i=0;i<len;i++)if(s[i]=='W')ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3408
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
        mut b: [usize; n],
    }
    b.reverse();
    let mut pos1 = n;
    let mut pos2 = n;
    let mut found = false;
    for i in 0..n {
        if a[i] == b[i] {
            if !found {
                pos1 = i;
                found = true;
            } 
            pos2 = i;
        }
    }
    if !found {
        println!("Yes");
        for b in b {
            print!("{} ", b)
        }
        return;
    }
    let pivot = a[pos1];
    let mut p = pos1;
    let lower = min(pos1, a.lower_bound(&pivot));
    let upper = max(pos2+1, a.upper_bound(&pivot));
    for i in 0..lower {
        if p > pos2 {
            break;
        }
        if b[i] == a[pos1] {
            continue;
        }
        b.swap(i, p);
        p += 1;
    }
    for i in upper..n {
        if p > pos2 {
            break;
        }
        if b[i] == a[pos1] {
            continue;
        }
        b.swap(i, p);
        p += 1;
    }
    for i in 0..n {
        if a[i] == b[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
    for b in b {
        print!("{} ", b);
    }

}


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

int n,k,q,b,ans=0;
int cnt=0;


int main(){
 cin>>n>>k>>q;
 vector<int>a(q);
 for(int i=0;i<q;i++)cin>>a[i];

 if(k>q){
    while(cnt<n){
        cout<<"Yes"<<endl;
        ++cnt;
    }
 }
 else{
    int p[n];
    for(int i=0;i<n;i++)p[i]=k-q;
    for(int i=0;i<q;i++){
        p[a[i]-1]++;
    } 
   for(int i=0;i<n;i++){
    if(p[i]>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
   }
 }
 return 0;
}

    


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

int main() {
    long long X, Y, Z;
    cin >> X >> Y >> Z;
    if (X % (Y + Z) >= Z) {
        cout << X / (Y + Z) << endl;
    } else {
        cout << X / (Y + Z) - 1 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int N,SS[400010],NN=2147483647;
int hyouka(int a,int b){return a<b?a:b;}
void ssset(int n,int *d){
	int i,t;
	for(N=1;N<n;N*=2);
	for(i=0;i<n;i++)SS[i+N]=d[i];
	for(   ;i<N;i++)SS[i+N]=NN;
	for(i=N-1;i;i--){
		t=hyouka(SS[i*2],SS[i*2+1]);
		SS[i    ]+=t;
		SS[i*2  ]-=t;
		SS[i*2+1]-=t;
	}
}
//[l,r)?????????x??????????????????i??????????????????[a,b)
//ssud(l,r,x,1,0,N);
int ssud(int l,int r,int x,int i,int a,int b){
	int t;
	if(b<=l||r<=a)return SS[i];
	if(l<=a&&b<=r)return SS[i]+=x;
	t=hyouka(ssud(l,r,x,i*2,a,(a+b)/2),ssud(l,r,x,i*2+1,(a+b)/2,b));
	SS[i*2  ]-=t;
	SS[i*2+1]-=t;
	return SS[i]+=t;
}
//[l,r)????????????????????????i??????????????????[a,b)
//ssout(l,r,1,0,N);
int ssout(int l,int r,int i,int a,int b){
	if(r<=a||b<=l)return NN;
	if(l<=a&&b<=r)return SS[i];
	return hyouka(ssout(l,r,i*2,a,(a+b)/2),ssout(l,r,i*2+1,(a+b)/2,b))+SS[i];
}
int main(){
	int n,m,d[100010],i,a,b,c,q;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)d[i]=NN;
	ssset(n,d);
	while(m--){
		//for(i=1;i<N*2;i++)printf("%d %d\n",i,SS[i]);printf("\n");fflush(stdout);
		scanf("%d",&q);
		if(q){
			scanf("%d %d",&a,&b);
			printf("%d\n",ssout(a,b+1,1,0,N));
		}
		else{
			scanf("%d %d",&a,&b);
			c=ssout(a,a+1,1,0,N);
			ssud(a,a+1,b-c,1,0,N);
		}
	}
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}


int main(){
	int n,m;
	cin >> n >> m;
	if(n==m){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin>>N;
  int j;
  j=0;
  for(int i=0; i<N.size()-2;++i){
    if(N.at(i)==N.at(i+1) && N.at(i+1)==N.at(i+2)){
    cout<<"Yes"<<endl;
      break;
    }
   else{
   ++j;
   }
  }
 if(j==N.size()-2){
 cout<<"No"<<endl;
 }
}

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

int main(void){
  int N,K; 
  cin >>N>>K;
  
  int x;
  int ans = 0;
  rep(i,0,N){
    cin >> x;
    ans += 2*min(x,abs(x-K));
  }
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
X = 0
for i in range(N-1):
  if A[i+1] -A[i] == 1:
    X += C[A[i]-1]
print(sum(B)+X)    

Measured memory_bytes: 3064
st = input()
q = int(input())

for i in range(q):
    com = input().split()
    a = int(com[1])
    b = int(com[2])
    if com[0] == 'print':
        print(st[a:b + 1])
    elif com[0] == 'reverse':
        st = st[:a] + st[a:b + 1][::-1] + st[b + 1:]
    else:
        p = com[3]
        st = st[:a] + p + st[b + 1:]

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    queue<char> q;
    int numoflast = 0;
    for(int i = 0; i < n; i++){
        char a = s[i];
        if(a == '('){
            q.push(a);
        }else{
            if(q.empty()){
                numoflast++;
            }else{
                q.pop();
            }
        }    
    }

    for(int i = 0; i < numoflast; i++) s = '(' + s;
    for(int i = 0; i < q.size(); i++) s+= ')';

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256