akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<limits.h>
#include<math.h>

#define MAX 500
#define INF (1 << 21)

int cost[MAX][MAX]; // cost[u][v]は辺e=(u,v)のコスト(存在しない場合はINF)
int mincost[MAX]; // 集合Xからの辺の最小コスト
int used[MAX]; // 頂点iがXに含まれているか
int V; // 頂点数

int solve() {
	int i, v, u;
    int res = 0;
    for(i=1;i<=V;i++) {
        mincost[i] = INF;
        used[i] = 0;
    }

    mincost[0] = 0;
    used[1] = 1;
    for(u=1; u<=V;u++) {
        mincost[u] = cost[1][u];
    }

    while(1) {
        v = 0;
        // Xに属さない頂点のうちXからの辺のコストが最小になる頂点を探す
        for(u=1;u<=V;u++) {
            if (!used[u] && (v == 0 || mincost[u] < mincost[v])) v = u;
        }

        if (v == 0) break;
        used[v] = 1; // 頂点vをXに追加
        res += mincost[v]; // 辺のコストを加える

        for(u=1; u<=V;u++) {
            if(mincost[u] > cost[v][u]) {
                mincost[u] = cost[v][u];
            }
        }
    }
    return res;
}

int main(void) {
    int n, i, j, e;

    scanf("%d\n", &n);
    V = n;
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            scanf("%d", &e);
            cost[i][j] = (e == -1) ? INF : e;
        }
    }

    printf("%d\n", solve());

    return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>

void putast(int n) {
  while (n--) {
    putchar('*');
  }
}

int main(void) {
  int n, count[6], i;
  double h;

  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < 6; i++)
      count[i] = 0;
    while (n--) {
      scanf("%lf", &h);
      if (h < 165.0)
	count[0]++;
      else if (h < 170.0)
	count[1]++;
      else if (h < 175.0)
	count[2]++;
      else if (h < 180.0)
	count[3]++;
      else if (h < 185.0)
	count[4]++;
      else
	count[5]++;
    }
    for (i = 0; i < 6; i++) {
      printf("%d:", i + 1);
      putast(count[i]);
      putchar('\n');
    }
  }
  return 0;
}

Measured memory_bytes: 640
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long a = read.to!long;
	long b = read.to!long;
	
	if(a + b == 15) writeln("+");
	else if(a * b == 15) writeln("*");
	else writeln("x");
	}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M;
	while(cin>>N>>M) {
		VI A(N);
		vector<PII> BC(M);
		REP(i, N) cin>>A[i];
		REP(i, M) cin>>BC[i].SE>>BC[i].FI;
		sort(ALL(A));
		sort(ALLR(BC));
		ll ai = 0, go = 1;
		REP(mi, M) {
			REP(i, BC[mi].SE) {
				if(ai+i>=N) {go=0;break;}
				maxUpdate(A[ai+i], BC[mi].FI);
			}
			if(!go) break;
			ai += BC[mi].SE;
		}
		ll ans = accumulate(ALL(A), 0LL);
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int Saisyo(int x) {
	int saisyo;
	while (x >= 10)x /= 10;
	saisyo = x;
	return saisyo;
}

int Saigo(int x) {
	int saigo;
	saigo = x % 10;
	return saigo;
}

int main(void) {

	int n;
	int a[10][10] = {};
	int sum = 0;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) a[Saisyo(i)][Saigo(i)]++;

	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i > j)continue;
			int x;
			x = a[i][j] * a[j][i];
			if (i != j)x *= 2;
			sum += x;
		}
	}

	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<int,int> P;
 #include <boost/multiprecision/cpp_int.hpp>

using bint = boost::multiprecision::cpp_int;
 
 
 
 
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int s1 = 0;int s2 = 0; int s3 = 0;
    rep(i,n){
        if (p[i] <= a) s1++;
        else if (p[i] > b) s2++;
        else s3 ++;
    }
    cout << min(min(s3,s2),s1);
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  char s[5] = {};
  int ans = 0;

  scanf("%s", s);

  for(int i = 0; i < 4; i++){
    if(s[i] == '+') ans++;
    else if(s[i] == '-') ans--;
  }

  printf("%d", ans);
}


Measured memory_bytes: 128
using System;

namespace ABC123_a
{
    class Program
    {
        static void Main(string[] args)
           
        {
            int [] array = new int[6];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }
           

                if ((array[4] -array[0] ) <= array[5])
                {
                    Console.WriteLine("Yay!");
                }
                else
                {
                    Console.WriteLine(":(");
                }
            
        }
    }
}


Measured memory_bytes: 13140
N=int(input())
d=dict()
for i in range(N):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
max_value=max(d.values())
list_dic=[]
for key,value in d.items():
    if value==max_value:
        list_dic.append(key)
list_dic.sort()
for i in list_dic:
    print(i)




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

int main(){
  int n;cin >> n;
  vector<tuple<int,int>> order(n);
  for(int i=0;i<n;i++){
    int temp;
    cin >> temp;
    order[i] = make_tuple(temp,i);
  }
  sort(order.begin(),order.end());
  for(int i=0;i<n;i++) cout << get<1>(order[i])+1 << " ";
  return 0;
}

Measured memory_bytes: 1536
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
B.append(0)
sumA=sum(A)
c=min(A[0],B[0])
A[0]-=c
B[0]-=c

for i in range(1,N+1):
  c=min(A[i],B[i-1])
  A[i]-=c
  B[i-1]-=c
  d=min(A[i],B[i])
  A[i]-=d
  B[i]-=d

print(sumA-sum(A))

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

if a <= b and b <= c:
    print (a, b, c)
elif a <= c and c <= b:
    print (a, c, b)
elif b <= a and a <= c:
    print (b, a, c)
elif b <= c and c <= a:
    print (b, c, a)
elif c <= a and a <= b:
    print (c, a, b)
elif c <= b and b <= a:
    print (c, b, a)
    


Measured memory_bytes: 5596
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<double,int> P;

static const double eps = 10e-9;

bool isA(string str){
	if(str.size() >= 1 && str[0] != '>') return false;
	if(str.size() >= 2 && str[1] != '\'') return false;

	int hist[] = {0,0};
	for(int i=2,j=0;i<str.size()-1;i++){
		if(str[i] == '='){
			hist[j]++;
		}
		else if(str[i] == '#') j++;
		else return false;
	}

	if(hist[0] != hist[1]) return false;
	if(hist[0] == 0 || hist[1] == 0) return false;
	if(str[str.size()-1] != '~') return false;

	return true;

}

bool isB(string str){
	if(str.size() >= 1 && str[0] != '>') return false;
	if(str.size() >= 2 && str[1] != '^') return false;

	if(str.size() <= 3) return false;

	string rear = str.substr(2,str.size()-2);

	bool isok=false;
	int i;
	for(i=0;i+1<rear.size();){
		if(rear.substr(i,2) == "Q="){
			isok=true;
			i+=2;
		}
		else break;
	}

	return (i+2 == rear.size() && isok && rear.substr(i,2) == "~~");
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			string str;
			cin >> str;

			if(isA(str)) cout << "A" << endl;
			else if(isB(str)) cout << "B" << endl;
			else cout << "NA" << endl;
		}
	}
	
}

Measured memory_bytes: 0
A,B,C,D = map(int,input().split(' '))
count1 = 0
while A > 0:#先攻高橋のモンスターが死ぬまでの回数
    A -= D
    count1 += 1
count2 = 0
while C > 0:#後攻青木のモンスターが死ぬまでの回数
    C -= B
    count２ += 1 
if count1>count2:
    #青木のモンスターが先死んだ→高橋の勝ち
    print('Yes')
elif count1<count2:
    print("No")
elif count1 == count2:
    print("Yes")

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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	string s;
	if(a==b&&c!=a&&c!=b)
		s = "Yes";
	else if(b==c&&a!=b&&a!=c)
		s = "Yes";
	else if(a==c&&b!=a&&b!=c)
		s = "Yes";
	else
		s = "No";
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Numerics;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        string inpt = Reader.ReadLine();

        StringBuilder ans = new StringBuilder();

        for (int i = 0; i < inpt.Length; i++)
        {
            if (inpt[i] == 'B')
            {
                if (ans.Length > 0)
                {
                    ans = new StringBuilder(ans.ToString().Substring(0, ans.Length - 1));
                }
            }
            else
            {
                ans.Append(inpt[i]);
            }
        }

         
        Console.WriteLine(ans.ToString());


    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

01B0

";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 2648
# D-Knapsack 1
N,W = map(int,input().split())
Weight = [0 for _ in range(N)]
Value = [0 for _ in range(N)]
for i in range(N):
    Weight[i],Value[i] = map(int,input().split())

MAX_N = 110
MAX_V = 100100

# dp[i+1][v]:= i番目までの品物の中からスコアがv以上になるように選んだときの、重さの総和の最小値
dp = [[10**15 for i in range(MAX_V)] for j in range(MAX_N)]
dp[0][0] = 0

for i in range(N):
    for sum_v in range(MAX_V):
        # i番目を選ぶ場合
        if sum_v - Value[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - Value[i]] + Weight[i])

        # i番目を選ばない場合
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

ans = 0
# 重さの総和<=Wである最大スコアを探す
for sum_v in range(MAX_V):
    if dp[N][sum_v] <= W:
        ans = sum_v
print(ans)

Measured memory_bytes: 181512
// TEMPLATES -----------------------------------------------------------------------------------------------------------

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

// types
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

// constants
const int INF = INT_MAX / 3;


// MAIN ----------------------------------------------------------------------------------------------------------------


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

    string str;
    cin >> str;

    // while (cin >> a) {}

    stack<char> s;

    for (auto c : str) {
        if (c == 'S') {
            s.push(c);
        } else {
            if (!s.empty() && s.top() == 'S') {
                s.pop();
            } else {
                s.push(c);
            }
        }
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef queue<ll> qi;
int main()
{
	map<string,int> mp;
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		mp[s] = 1;
	}
	cout<<mp.size()<<endl; 
	return 0;
}

Measured memory_bytes: 19208
L=int(input())
l=0
pp=0
tmp=L
while tmp>0:l+=1;pp+=tmp%2;tmp//=2
print(l,l*2-3+pp)
for i in range(1,l):
  print(i,i+1,0)
  a=1<<i-1
  print(i,i+1,a)
  if L&a:L-=a;print(i,l,L)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#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 all(x) (x).begin(), (x).end()
#define MOD1 1000000007
#define MOD2 998244353
#define F first
#define S second
#define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define print(a) for(auto x : a)    cout<<x<<" "; cout<<"\n";
using namespace std;

void OFFLINE(){
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
    #endif
}

int main(){

    IOS;
    // OFFLINE();
    //check for corner test cases

    string s, t;
    cin >> s >> t;

    int n = s.length();
    int cnt = 0;

    for(int i = 0; i < n; i++){
        if(s[i] != t[i])    cnt++;
    }

    cout<<cnt<<"\n";


    //check for corner test cases
    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	int cnt = 0;
	fd(i,min(a,b),1){
		if(a % i == 0 && b % i == 0)++cnt;
		if(cnt == k){cout << i << endl;break;}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define in insert
#define rep(i,a,b) for(int i = a ; i < b ; i++)
#define repr(i,a,b) for(int i = b ; i > a ; i--)

signed main(){
    fast;
    int n;
    cin >> n;
    int ans=0;
    rep(i,0,n){
        if((i+1)%3!=0 && (i+1)%5!=0){
            ans+=i+1;
        }
    }
    cout << ans;
}

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



int main(){
	
	int n, k;
	cin >> n >> k;
	int ans = 1;
	for(int i = 0; i < n; i++)
	{
		if(ans > k) ans+=k;
		else ans*= 2;
	}
	
	cout << ans << endl;

	return 0;
}

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

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if (B - A <= 0) cout << "delicious" << endl;
    else if (B - A <= X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    from heapq import heappush, heappop

    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())

    h = []
    for _ in range(N):
        a, b = map(int, input().split())
        heappush(h, (a, b))

    while h:
        a, b = heappop(h)
        K -= b
        if K <= 0:
            print(a)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 16688
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int k,x;
  in(k,x);
  for(int i=max(-1000000,x-(k-1));i<=min(1000000,x+k-1);i++)cout<<i<<(i!=min(1000000,x+k-1)?" ":"\n");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;
    public static void main(String[] args) {
        long N = nlong();
        long maxA = 0;
        
        for (long a = 1; a <= Math.sqrt(N); a++) {
            if (N % a == 0) {
                maxA = a; 
            }
        }
        long b = N/maxA;
        so.println(keta(b));
    }

    private static int keta(long n) {
        int count = 0;
        while (n > 0) {
            count++;
            n /= 10;
        }
        return count;
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }
    
    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }
    
    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }
    
    private static char[][] nchars2D(int h, int w) {
        return nchars2D(h, w, 0);
    }
    
    private static char[][] nchars2D(int h, int w, int pad) {
        char[][] a2 = new char[h+pad*2][w+pad*2];
        for(int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad+i], pad, w);
        return a2;
    }
}


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

int main() {
    string s[4];
    cin >> s[0] >> s[1] >> s[2];
    for(int i = 0; i < 3; ++i) reverse(s[i].begin(), s[i].end());

    int player = 0;
    while (true) {
        if(s[player].empty()) return !printf("%c\n", player + 'A');
        int nxt = s[player].back() - 'a';
        s[player].pop_back();
        player = nxt;
    }
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,j,a[100000],b[100000],n,h,ans=0,t;
	cin>>n>>h;
	for (i=0;i<n;i++){
		cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    t=a[n-1];
    i=0;
    while (t>b[i]){
    	i++;
    }
    for (j=n-1;j>=i;j--){
    	h-=b[j];
    	ans++;
    	if (h<=0){
    		break;
    	}
    }
    if (h>0){
    	ans+=(h%t==0)?h/t:(int)h/t+1;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 1920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            if (C >= A && C <= B)
                out.println("Yes");
            else
                out.println("No");
        }

    }
}



Measured memory_bytes: 21844
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sum = 0;
    vint a(n);
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    int dis = INF;
    int ans  = -1;
    REP(i,n){
        if(abs(a[i]*n-sum)<dis){
            ans = i;
            dis = abs(a[i]*n-sum);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if(n==1)
        cout << "Hello World" << endl;
    else if(n==2)
    {
        int a,b;
        cin >> a >> b;
        cout << a + b << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline

N, W = map(int, input().split())
dp = np.zeros((N, W+1), dtype='int64')

def solve(N, W):
    for i in range(0, N):
        wi, vi = map(int, input().split())
        dp[i][:wi] = dp[i-1][:wi]
        dp[i][wi:] = np.fmax(dp[i-1][wi:],
                            dp[i-1][:W+1-wi] + vi)
    return dp[N-1][W]

print(solve(N, W))

Measured memory_bytes: 92068
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()

{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((a*b)>(c*d))
    cout<<(a*b)<<endl;
  else
    cout<<(c*d)<<endl;


 return 0;
}








Measured memory_bytes: 3640
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
long long dfs(vector<long long> &arr,int l,int r,vector<vector<long long>> &dp)
{
    if(l>r) return 0;
    if(l==r) return arr[l];
    if(dp[l][r]!=-1)
        return dp[l][r];
    dp[l][r]=max(arr[l]-dfs(arr,l+1,r,dp),arr[r]-dfs(arr,l,r-1,dp));
    return dp[l][r];
}
int main()
{
    int n;
    cin>>n;
    vector<long long> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    vector<vector<long long>> dp(n,vector<long long>(n,-1));
    cout<< dfs(arr,0,n-1,dp);
    return 0;
}

Measured memory_bytes: 73960
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,M = map(int,input().split(" "))
if N>1:
    n = combinations_count(N, 2)
else:
    n=0
if M>1:
    m = combinations_count(M, 2)
else:
    m=0
print(n+m)

Measured memory_bytes: 3060
#include <stdio.h>
int n,x,i,j,p,q,s,a[101][101],b[101][101],ans=-99999;
int main(void){
	scanf("%d",&n);
	//for(i=0;i<=n;i++){a[0][i]=0;b[i][0]=0;}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			scanf("%d",&x);
			if(x>ans)ans=x;
			a[i][j]=x+a[i-1][j];
			b[i][j]=x+b[i][j-1];
		}
	}
	for(i=1;i<=n;i++){
		for(p=i;p<=n;p++){
			s=-1;

			for(j=1;j<=n;j++){
				x=a[p][j]-a[i-1][j];
				if(s*x<0){
					s*=-1;
					if(s>0){
						for(q=j;q<=n;q++){
							if(q>j)x+=a[p][q]-a[i-1][q];
							if(x>ans)ans=x;
						}
					}
				}
			}

		}
	}
	//for(i=0;i<=n;i++){for(j=0;j<=n;j++){printf("%3d",a[i][j]);}printf("\n");}printf("\n");
	//for(i=0;i<=n;i++){for(j=0;j<=n;j++){printf("%3d",b[i][j]);}printf("\n");}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<int> ans;
vector<P> to[100005];

void dfs(int i, int j=-1){
    for(P u : to[i]){
        if(u.first == j) continue;
        if(u.second % 2 == 0){
            ans[u.first] = ans[i];
        }else{
            ans[u.first] = -ans[i];
        }
        dfs(u.first, i);
    }
}


int main()
{
    // input
    int n;
    cin >> n;
    rep(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        to[u].emplace_back(make_pair(v,w));
        to[v].emplace_back(make_pair(u,w));
    }

    // solve
    ans.resize(n);
    ans[0] = 1;
    dfs(0);

    // ouput
    rep(i,n){
        if(ans[i]==-1) cout << '0' << endl;
        else if(ans[i]==1) cout << '1' << endl;
    }

    return 0;
}


Measured memory_bytes: 8320
#include<stdio.h>
    int main()
    {
   
    	char a[10];
    	scanf("%s",a);
    	if(a[0]==a[1]&&a[1]==a[2]){ 
          printf("No\n");}
      
    	else {
          printf("Yes\n");}
    	return 0;
    }

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
#define ld long long double
#define ll long long
#define mod 1000000007
#define scl(x) scanf("%lld",&x)
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}

ll power(ll a,ll b) {
    ll res=1LL;
    while(b>0){
        if(b&1) res = mul(res,a);
        b/=2;
        a = mul(a,a);
    }
    return res%mod;
}

int main(){
   ll n;
   cin >> n;
   ll arr[n];
   for(ll i=0;i<n;i++) cin >> arr[i];
    sort(arr,arr+n);
    ll sum = 0;
    for(ll i=0;i<n;i++) {
        for(ll j=i+1;j<n;j++) {
            ll a = arr[i] + arr[j];
            ll idx = lower_bound(arr+j+1,arr+n,a)-arr;
            ll jdx = lower_bound(arr+j+1,arr+n,arr[j])-arr;
            sum += (idx-jdx);
        }
    }
    cout << sum << endl;
}

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

int main()
{
	int k;
	string s;
	cin >> k >> s;
	if (s.length() <= k) {
		cout << s << endl;
	}
	else {
		for (int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
//
//  main.cpp
//  CompetitiveProgramming
//
//  Created by Yuma Kikuchi on 2018/03/02.
//  Copyright © 2018年 yumarimo. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#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 FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

int main() {
    int n;
    cin >> n;
    if (n < 3) cout << 0 << endl;
    else cout << n / 3 << endl;

    return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int32_t main() {
    fastio
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    float R;
    cin >> R;
    float circum = 2 * 3.141592 * R;

    cout << circum;
    return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <map>
#include <set>
#include <string>
#include<string.h>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <cctype>
using namespace std;
typedef long long ll;

int main(){
	long long x;
	long long f=100;
	int cnt=0;
	scanf("%lld",&x);
	while(f<x){
		f=f*1.01;
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 3816
import math

a = []
b = []
ans = 0
for i in range(5):
    a.append(int(input()))
ans = sum(a)
for i in range(5):
    tmp = a[i] % 10
    if tmp != 0:
        b.append(10 - tmp)
if len(b) == 0:
    print(ans)
else:
    print(ans + sum(b) - max(b))


Measured memory_bytes: 3060
from itertools import product

N, M = map(int, input().split())
k = []
S = []
for i in range(M):
    in_ = list(map(int, input().split()))
    k.append(in_[0])
    S.append(in_[1:])
p = list(map(int, input().split()))

out = 0
for c in product(*[[0, 1]]*N):
    tf = []
    for i in range(M):
        count = sum([c[s-1] == 1 for s in S[i]])
        tf.append(count % 2 == p[i])
    out += int(all(tf))

print(out)


Measured memory_bytes: 3064
#include <queue>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

#define INF (1 << 20)
#define MAXN (1 << 12)

int d[MAXN];
int v[MAXN];
int n, k;
vector<int> a[MAXN];
int cnt[MAXN];

void bfs(int source) {
	for (int i = 0; i < n; i++) {
		d[i] = INF;
		v[i] = 0;
	}
	queue<int> q;
	q.push(source);
	v[source] = 1;
	d[source] = 0;
	while (!q.empty()) {
		int cur = q.front();
		q.pop();
		for (int i = 0; i < a[cur].size(); i++) {
			int t = a[cur][i];
			if (!v[t]) {
				v[t] = 1;
				d[t] = d[cur] + 1;
				q.push(t);
			}
		}
	}
}

void addedge(int x, int y) {
	a[x].push_back(y);
	a[y].push_back(x);
}

int main() {
	int x, y;
	cin >> n >> x >> y;
	for (int i = 0; i < n - 1; i++) {
		addedge(i, i + 1);
	}
	addedge(x - 1, y - 1);

	for (int i = 0; i < n; i++) {
		bfs(i);
		for (int j = 0; j < n; j++) {
			cnt[d[j]]++;
		}
	}
	for (int i = 1; i < n; i++) {
		cout << cnt[i] / 2 << endl;
	}

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    double y = n;
    double a[n];
    double sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    for(int i=0;i<n;i++){
        sum += a[i];
    }

    sum = sum/y;

    int ans = 0;
    double x = abs(sum-a[0]);

    for(int i=1;i<n;i++){
        if(x>abs(sum-a[i])){
            ans = i;
            x = abs(sum-a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
# 21:15
import fractions as math

a,b,c,d = map(int,input().split())

def F(n,c,d):
    x = n
    x -= n//c
    x -= n//d
    lcm = c*d//math.gcd(c,d)
    x += n//lcm
    return x

print(F(b,c,d) - F(a-1,c,d))

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

int N, M, cap;

using Graph = vector< vector< pair<int, int> > >;

const int INF = 1 << 29;
int dist[6010][2010];

struct Elem {
    int pos, tot, cost;
    bool operator<(const Elem &e) const {
        return cost > e.cost;
    }
};


int solve(Graph &G, vector<int>& is_station, int S, int T) {
    fill(dist[0], dist[6010], INF);
    dist[S][0] = 0;

    priority_queue<Elem> que;
    que.push(Elem{S, 0, 0});

    while(que.size()) {
        Elem cur = que.top(); que.pop();

        int u = cur.pos, pre_tot = cur.tot, pre_cost = cur.cost;
        if(dist[u][pre_tot] < pre_cost) continue;

        for(auto e : G[u]) {
            int v = e.first, cost = e.second;

            int nxt_cost = pre_cost + cost;
            int nxt_tot  = pre_tot  + cost;
            if(nxt_tot > cap) continue;
            if(is_station[v]) nxt_tot = 0;

            if(dist[v][nxt_tot] > nxt_cost) {
                dist[v][nxt_tot] = nxt_cost;
                que.push(Elem{v, nxt_tot, nxt_cost});
            }
        }
    }

    int ret = *min_element(dist[T], dist[T] + cap + 1);
    return (ret == INF ? -1 : ret);
}

int main() {
    while(cin >> N >> M >> cap, N) {
        cap *= 10;
        string st, gl; cin >> st >> gl;

        vector<string> u(N), v(N);
        vector<int> d(N);

        map<string, int> to_int_id;
        for(int i=0; i<N; i++) {
            cin >> u[i] >> v[i] >> d[i];
            to_int_id[ u[i] ]++;
            to_int_id[ v[i] ]++;
        }

        int id = 0;
        for(auto &e : to_int_id) {
            e.second = id++;
        }

        Graph G(id);
        for(int i=0; i<N; i++) {
            int x = to_int_id[ u[i] ];
            int y = to_int_id[ v[i] ];
            G[x].push_back(make_pair(y, d[i]));
            G[y].push_back(make_pair(x, d[i]));
        }

        vector<int> is_station(id);
        for(int i=0; i<M; i++) {
            string s; cin >> s;
            int s_id = to_int_id[s];

            is_station[s_id] = true;
        }

        int start_v = to_int_id[st];
        int goal_v  = to_int_id[gl];
        cout << solve(G, is_station, start_v, goal_v) << endl;
    }
    return 0;
}


Measured memory_bytes: 75520
S = list(input())
check = 0

if 'E' in S :
    if 'W' in S:
        pass
    else:
        check = 1

if 'W' in S :
    if 'E' in S:
        pass
    else:
        check = 1

if 'N' in S :
    if 'S' in S:
        pass
    else:
        check = 1

if 'S' in S :
    if 'N' in S:
        pass
    else:
        check = 1

if check == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
const int mod = 1e9 + 7;
int x[N];

int main() {
    int n, a, b;
    long long tot = 0;
    scanf("%d%d%d", &n, &a, &b);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &x[i]);
    }
    for(int i = 2; i <= n; i++) {
        tot += min((long long)b, (long long)(x[i]-x[i-1])*a);
    }
    cout << tot << endl;
    return 0;
}


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

int main(){
    string S;
    cin >> S;
    int cnt = 0;
    for(int i = 0; i < S.size()-1; i++) {
        if(S[i] == 'A' && S[i+1] == 'C') {
            cnt++;
        }
    }
    if(cnt > 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
using namespace std;

const unsigned long long BASE = 1e9 + 7;
#define SAFE 1e8

int main()
{
    int n;
    string c;
    cin >> n >> c;
    int idx1 = 0, idx2 = n - 1;
    int count = 0;
    while (idx1 != idx2)
    {
        while (c[idx1] == 'R' && idx1 < idx2)
            idx1++;
        while (c[idx2] == 'W' && idx1 < idx2)
            idx2--;
        if (idx1 != idx2)
        {
            count++;
            c[idx1] = 'R';
            c[idx2] = 'W';
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3684
S = input()
baf = S[0]
anscount = 0
count = 0
count2 = 0
count3 = 0
count4 = 0
farstflag = 1
countflag = 0
countflag2 = 0
def plus(N):
    return N * (N - 1) // 2
while(count < len(S)):
    #print("count", count, "Scount", S[count], "farstflag", farstflag, "countflag", countflag, "cfalg2", countflag2, "count3", count3, "count4", count4, "ans", anscount)
    if farstflag == 1 and S[0] == "<":
        farstflag = 0
    if farstflag == 1 and S[0] == ">":
        farstflag = 0
        countflag = 1
    if countflag == 1:
        if baf != S[count]:
            #print(count2)
            anscount += plus(count2 + 1)
            countflag = 0
        count2 += 1
        if count == len(S) - 1:
            anscount += plus(count2 + 1)
    if farstflag == 0 and countflag == 0 and countflag2 == 0:
        if S[count] == "<":
            count3 += 1
        else:
            countflag2 = 1
            count4 += 1
            count+= 1
            continue
    if farstflag == 0 and countflag == 0 and countflag2 == 1:
        if S[count] == ">":
            count4 += 1
        else:
            anscount += plus(max(count3, count4) + 1)
            anscount += plus(min(count3, count4))
            countflag2 = 0
            count4 = 0
            count3 = 0
            count3 += 1

    baf = S[count]
    count += 1
anscount += plus(max(count3, count4) + 1)
anscount += plus(min(count3, count4))
#print("count", count, "farstflag", farstflag, "countflag", countflag, "cfalg2", countflag2, "count3", count3, "count4", count4, "ans", anscount)

print(anscount)



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

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

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

bool p[7777777];

int main(void){
	int n,m,i,t;
	cin >> m >> n;
	while(n&&m){
		fill(p,p+7777777,false);
		while(true){
			if(p[m]){
				++m;
				continue;
			}
			if(!n){
				cout << m << endl;
				break;
			}
			--n;
			t = m*2;
			while(t<7777777){
				p[t] = true;
				t += m;
			}
			++m;
		}
		cin >> m >> n;
	}
	return 0;
}



Measured memory_bytes: 10636
n = int(input())

list = [list(map(int, input().split())) for x in range(n)]

t = 0
x = 0
y = 0
flag = 0

for i in range(n):
    if i>0:
        t = list[i][0] - list[i-1][0]
        d = abs(list[i][1] - list[i-1][1] + list[i][2] - list[i-1][2])
    else:
        t = list[i][0]
        d = abs(list[i][1] + list[i][2])
    if (t-d) >= 0 and (d-t)%2 == 0:
        continue
    else:
        flag = 1
        print('No')
        break
if flag ==0:
    print('Yes')


Measured memory_bytes: 27144
#include <iostream>
#include <vector>

int main(){
    int N;
    std::cin >> N;
    std::vector<int> arr;
    //arr.resize(N);
    int tmp = 0;
    //for(int i=0; i<N; i++){
    //    std::cin >> arr[i];
    //}
    while(std::cin >> tmp){
      arr.push_back(tmp); 
    }
    
    for(auto i=arr.rbegin(); i!=arr.rend(); i++){
        if(i!=arr.rbegin()){
            std::cout << " ";
        }
        std::cout << *i;
    }
    std::cout << std::endl;
}


Measured memory_bytes: 3052
N = int(input())
v_list = list(map(int, input().split()))
v_list = sorted(v_list)
sum = 0

for v,i in zip(v_list, range(1, N+1)):
  if i < 3:
    sum += v
  else:
    sum += (2**(i - 2)) * v
print(sum/(2**(i-1)))

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
  char c;
  vector<int> vec(4);
  for(int i = 0; i < 4; i++) {
    cin >> c;
    vec.at(i) = ctoi(c);
  }
  
  
  
  for(int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> ticket(tmp);
    int sum = 0;
    sum += vec.at(0);
    
    for(int i = 0; i < 3; i++) {
      
      if(ticket.test(i)) {
        sum -= vec.at(i + 1);
      }
      else {
        sum += vec.at(i + 1);
      }
      
    }
    
    if(sum == 7) {
      cout << vec.at(0);
      for(int i = 0; i < 3; i++) {
        if(ticket.test(i)) {
          cout << "-";
        } else {
          cout << "+";
        }
        cout << vec.at(i + 1);
      }
      cout << "=7" << endl;
      break;
    }
  }
}


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

int main() {
	string s;
	cin >> s;

	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
n = max(len(s),len(t))
dp = [[0]*(n+1) for i in range(n+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1])

ans = ""
i = len(s)
j = len(t)
while (i > 0 and j > 0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1
print(ans)
        

Measured memory_bytes: 114012
#include <stdio.h>
int main(void)
{
	int H[1000],W[1000],i,j,k,l,H1=1,W1=1;
	for(i=0;(H1 != 0) || (W1 != 0);i++)
	{
		scanf("%d" "%d" ,&H1,&W1);
		H[i] = H1;
		W[i] = W1;
	}
	for(j=0;j<i-1;j++)
	{
		H1 = H[j];
		W1 = W[j];
		for(k=0;k < H1;k++)
		{
			for(l=0;l < W1;l++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 580