akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
class Edge{
public:
    int to,cap,rev;
    Edge(int _to,int next,int cost){
        to=_to,cap=next,rev=cost;
    }
};//ikisaki youryou gyakuhen
class Dinic{//max flow
public:
    int n;
    vector<vector<Edge> >G;//[MAX];
    vi level,iter;//[MAX];
    Dinic(int size){
        n=size;
        G=vector<vector<Edge> >(n);
    }
    void add_edge(int from, int to, int cap){
        Edge q={to,cap,int(G[to].size())};
        G[from].push_back(q);
        q={from,0,int(G[from].size()-1)};
        G[to].push_back(q);
    }
    int getmaxflow(int s,int t) {//from s to t,ford_fulkerson
        int flow=0;
        while(1){
            bfs(s);
            if(level[t]<0)return flow;
            iter=vi(n);
            int f;
            while((f=dfs(s,t,INF))>0)flow+=f;
        }
    }
private:
    void bfs(int s){
        level=vi(n,-1);
        queue<int>q;
        level[s]=0;
        q.push(s);
        while(!q.empty()){
            int v=q.front();q.pop();
            for(int i=0;i<G[v].size();i++){
                Edge &e=G[v][i];
                if(e.cap>0&&level[e.to]<0){
                    level[e.to]=level[v]+1;
                    q.push(e.to);
                }
            }
        }
    }
    int dfs(int v,int t, int f) {
        if(v==t)return f;
        for(int &i=iter[v];i<G[v].size();i++){
            Edge &e=G[v][i];
            if(level[v]>=level[e.to]||e.cap<=0) continue;
            int d =dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
        return 0;
    }
};
signed main(){
    int n; cin>>n;
    vector<pii>red(n);
    vector<pii>blu(n);
    rep(i,n)cin>>red[i].first>>red[i].second;
    rep(i,n)cin>>blu[i].first>>blu[i].second;
    Dinic mf(2*n+100);
    int source = 2*n;
    int tt = 2*n+1;
    rep(i,n)mf.add_edge(source, i, 1);
    rep(i,n)mf.add_edge(i+n,tt, 1);
    rep(i,n)rep(j,n){
        if(red[i].first<blu[j].first&&red[i].second<blu[j].second){
            mf.add_edge(i, j+n, 1);
        }
    }
    cout<<mf.getmaxflow(source, tt)<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

map<pair<ll,ll>,ll> m;

int main(){
    ll h,w,n;
    cin >> h >> w >> n;
    
    rep(i,0,n){
        ll y,x;
        cin >> y >> x;

        rep(xx,0,3){
            rep(yy,0,3){
                ll nx = x-xx,ny = y-yy;
                if(0 < nx && nx < w-1 && 0 < ny && ny < h-1){
                   m[make_pair(ny,nx)]++;
                }
            }
        }
    }
    ll ans[10] = {},sum = 0;
    for(auto ite:m){
        ans[ite.sd]++;
        sum++;
       // cout << ite.ft.ft << " " << ite.ft.sd << " " << ite.sd <<endl;
    }
    
    P(((w-2)*(h-2))-sum);
    rep(i,1,10)P(ans[i]);
	
	return  0;
}

Measured memory_bytes: 56448
import java.io.BufferedInputStream;
import java.util.*;

public class Main {

    // 1处理全为负数的情况
    // 2处理相同的数
    // 3正数
    // 4正数负数混合
    // 暴力试探
    public static void main(String[] args) {

        Scanner s = new Scanner(new BufferedInputStream(System.in));
        int n = s.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = s.nextInt();
        }
        int sum = Integer.MAX_VALUE;

        for (int i = -100; i <= 100; i++) {
            int cur = 0;
            for (int j : nums) {
                int o = Math.abs(j - i);
                o = o * o;
                cur += o;
            }
            sum = Math.min(sum, cur);
        }
        System.out.println(sum);

    }
}


Measured memory_bytes: 23124
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	m := map[string]bool{}
	n := nextInt()

	w1 := next()
	e := w1[len(w1)-1]
	m[w1] = true

	ok := true
	for i := 1; i < n; i++ {
		w := next()
		if w[0] != e {
			ok = false
		} else if m[w] {
			ok = false
		}
		e = w[len(w)-1]
		m[w] = true
	}

	if ok {
		puts("Yes")
	} else {
		puts("No")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int[] d = cin.ArrayInt(n);
			long ans = 0;
			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					if (i == j) {
						continue;
					}

					ans += d[i] * d[j];
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
program main
implicit none
integer::d
read(*,*) d
if (d==22) then
write(*,*) 'Christmas Eve Eve Eve'
end if
if (d==23) then
write(*,*) 'Christmas Eve Eve'
end if
if (d==24) then
write(*,*) 'Christmas Eve'
end if
if (d==25) then
write(*,*) 'Christmas'
end if


end program main


Measured memory_bytes: 768
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int inf = 1e18 + 7;	
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n, ans = inf;	cin >> n;
	for(int i = 1; i*i <= n; i++){
		if(n%i)	continue;
		int x = n/i;
		ans = min(ans, i + x - 2);
	}
	if(ans == inf)
		ans = n-1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
list = [int(input()) for i in range(5)]
ans = 0
amari = []
for i in range(5):
  ans += (list[i] // 10) * 10
  amari.append(list[i] % 10)
amari = sorted(amari)
for i in range(5):
  if amari[i] != 0:
    ans += amari[i]
    ans += (5-(i+1)) * 10
    break
print(ans)

Measured memory_bytes: 3064
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
// #include <fstream>//ifstream/ofstream
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>

#define PRIME_SHORT 10007
#define PRIME 1000000007

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;

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

    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
n, m = list(map(int, input().split()))
graph = defaultdict(list)
for i in range(m):
  u, v = list(map(int, input().split()))
  graph[u].append(v+n)
  graph[u+n].append(v+2*n)
  graph[u+2*n].append(v)
s, t = list(map(int, input().split()))
dist = [-1 for i in range(3*n+10)]

def bfs():
  que = deque([s])
  dist[s] = 0
  while len(que) > 0:
    cur = que.popleft()
    for to in graph[cur]:
      if dist[to] == -1:
        dist[to] = dist[cur]+1
        que.append(to)

bfs()
print(dist[t]//3)

Measured memory_bytes: 117848
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repm(i,m,n) for (int i = (m); i < (n); i++)
#define rrep(i,n) for (int i = (n); i >= 0; i--)
using namespace std;
typedef long long ll;
 
int main() {
  vector<int> X(3);
  rep(i,X.size()) cin >> X.at(i);
  
  sort(X.begin(), X.end());
  reverse(X.begin(), X.end());
  
  cout << (10*X.at(0)+X.at(1)) + X.at(2) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 

using namespace std;

int main()
{
    //freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
    unsyncIO;
    long long n, m;
    cin >> n >> m;
    long long s = n, c = m;
    n = n * 2;
    m = m - n;
    m = m / 4;
    long long cnt = m + s;
    if(c < 2) cnt = 0;
    if(s >= c) cnt = c / 2;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
void Swap(long x[ ], int i, int j)
{
    long temp;
    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}
void QSort(long x[ ], int left, int right)
{
    int i, j;
    long pivot;
    i = left;                     
    j = right;                    
    pivot = x[(left + right) / 2]; 
    while (1) 
    {    while (x[i] < pivot)      
            i++;                   
        while (pivot < x[j])       
            j--;                  
        if (i >= j)               
            break;                
        Swap(x, i, j);             
        i++;                       
        j--;
    }
    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)           
        QSort(x, j + 1, right);    
}
int main(){
  int n,i,j,aaa;;
  long h,a[100000],b[100000],max=0,temp,cnta=0,cntb=0,cnt;
  scanf("%d %ld",&n,&h);
  for(i=0;i<n;i++){ 
    scanf("%ld %ld",&a[i],&b[i]);
    if(max<a[i]) max=a[i];
  }
  QSort(b, 0, n - 1);
  for(i=n-1;i>=0;i--){
    if(max<b[i]){
      h-=b[i];
      cntb++;
    }
    else break;
    if(h<=0) break;
  }
  if(h<=0)  cnta=0;
  else if(h%max!=0)  cnta=(h/max)+1;
  else cnta=h/max;
  cnt=cnta+cntb;
  printf("%ld\n",cnt);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double d;
int main() {
  d A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<tuple<d,d,d>> t;
  
  for(ll i = 0;i<=30;i++){
    for(ll j = 0;j<=30;j++){
      for(ll k = 0;k<=100;k++){
        for(ll l = 0;l<=100;l++){
          double m= 100*A*i+100*B*j;
          double s = C*k + D*l;
          if(m+s >0 && m+s <= F && 100*s/(m+s) <= 100*E/(100+E)){
            t.push_back(make_tuple(100*s/(m+s),m+s,s));
          }
        }
      }
    }
  }
  sort(t.begin(),t.end());
  
  cout << get<1>(t[t.size()-1]) <<" " <<  get<2>(t[t.size()-1])<<endl;
  
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli a,b,c,d;
    cin2(a,b);
    cin2(c,d);
    cout << max(a*b,c*d) << endl;
}


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

int main()
{
  int n, i;
  cin >> n;
  int h, cnt = 0, ans;
  vector<vector<int>> t(n, vector<int>(0));
  cin >> h; t[0].push_back(h);
  for (i = 1; i < n; i++) {
    cin >> h;
    if (t[cnt][t[cnt].size()-1] < h)
      t[++cnt].push_back(h);
    else
      t[cnt].push_back(h);
  }
  ans = t[0].size()-1;
  for (i = 1; i < n; i++)
    if ((int)(t[i].size()-1) > ans) ans = t[i].size()-1;
  cout << ans << endl;
}

Measured memory_bytes: 5760
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edges[a].append(b)
        edges[b].append(a)

    prev = [-1 for _ in range(N)]
    prev[0] = 0
    que = queue.Queue()
    que.put(0)
    while not que.empty():
        cn = que.get()
        for e in edges[cn]:
            if prev[e] == -1:
                prev[e] = cn
                que.put(e)

    print("Yes")
    for p in prev[1:]:
        print(p + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95800
#include <iostream>

using namespace std;
class UFT {
public:
    UFT(int n) : tree {new int[n]}, r {new int[n]}, s {n} {
        for(int i = 0; i < s; ++i){
            tree[i] = i;
        }
    };
    int parent(int v){
        if(tree[v] == v){
            return v;
        }
        return tree[v] = parent(tree[v]);
    };
    void unite(int x, int y){
        if(same(x, y)){
            return;
        }
        int px = parent(x);
        int py = parent(y);
        int rx = r[px];
        int ry = r[py];
        if(rx > ry){
            tree[py] = px;
        } else if(rx < ry){
            tree[px] = py;
        } else {
            tree[px] = py;
            ++r[py];
        }
    };
    bool same(int x, int y){
        return parent(x) == parent(y);
    }
    void print(){
        for(int i = 0; i < s; ++i){
            cout << tree[i] << ' ';
        }
        cout << endl;
    }
private:
    int* tree;
    int* r;
    int s;
};

int main(){
    ios_base::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    UFT uft = UFT(n);
    int com, x, y;
    for(int i = 0; i < q; ++i){
        cin >> com >> x >> y;
        if(com == 0){
            uft.unite(x, y);
        } else {
            cout << (uft.same(x, y) ? "1" : "0") << endl;
        }
    }
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
int sn(string a,string b)
{
   int count=0;
   for ( int i =0 ; i<a.length() ; i++)
   {
       if ( a[i] != b[i]){count++;}
   }
    return count;
}
int main()
{
string a,b;
cin>>a>>b;
cout<<sn(a,b);
}

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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    string S;
    cin >> S;
    S[3] = '8';
    cout << S;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        int sum = 0;
        if( A % 2 != B % 2 || B % 2 != C % 2 ) {
            if( A % 2 != B % 2 && B % 2 == C % 2 ) {
                B++;
                C++;
            } else if( A % 2 != B % 2 && A % 2 == C % 2 ) {
                A++;
                C++;
            } else if( A % 2 == B % 2 && B % 2 != C % 2 ) {
                A++;
                B++;
            }
            sum++;
        }
        
        int max = Math.max(A, Math.max(B, C));
        sum += (max - A) / 2;
        sum += (max - B) / 2;
        sum += (max - C) / 2;
        
        System.out.println( sum );
    }
}


Measured memory_bytes: 35660
def main():
  S = input()
  half = int(len(S) / 2) if len(S) % 2 == 0 else int((len(S) - 1) / 2)
  first = []
  latter = []
  count = 0

  for i in range(half):
    first.append(S[i])
    latter.append(S[-i-1])

  for i in range(half):
    count += 0 if first[i] == latter[i] else 1

  print(count)
  

if __name__ == '__main__':
  main()


Measured memory_bytes: 3060
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = Is()
print((a-1)*(b-1))


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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> vec(n,vector<int>(10));//f
    vector<vector<int>> vec2(n,vector<int>(11));//p
    rep(i,n)rep(j,10) cin >> vec[i][j];
    rep(i,n)rep(j,11) cin >> vec2[i][j];
    ll ans=-10000000000;
    rep(i,1<<10){
        if(i==0) continue;
        bitset<10> bit(i);
        ll score=0;
        rep(i,n){
            int cnt=0;
            rep(j,10) if(bit.test(j)&&vec[i][j]==1)cnt++;
            score+=vec2[i][cnt];
        }
        ans=max(ans,score);
    }
    cout <<  ans << endl;
}


Measured memory_bytes: 3640
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 998244353;

int N = 550000 - 1; // 必要な数よりも大きい2^nよりも大きい数を入れるとよい
long long int BIT[550000];

void init(){
	for(int i = 0; i < N; i++){
		BIT[i] = 0;
	}
}

void add(int a, long long int w){
	
	// a番目の要素にwを足す O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		BIT[x] += w;
	}
}

long long int sum(int a){
	
	// 1からaまでの要素の合計を返す O(log N)
	
	long long int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += BIT[x];
	}
	return ret;
}

long long int x[210000], y[210000];
long long int P1[210000], P2[210000], P3[210000], P4[210000];
long long int p2[210000];

int main(){
    p2[0] = 1;
    for(int i = 1; i < 210000; i++){
        p2[i] = p2[i - 1] * 2 % MOD;
    }
    int N;
    cin >> N;
    map<P, int> mx, my;
    vector<P> v;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
        mx[P(x[i], i)] = 0;
        my[P(y[i], i)] = 0;
        v.push_back(P(x[i], y[i]));
    }
    int cnt = 1;
    for(auto Pid : mx){
        v[Pid.first.second].first = cnt;
        cnt += 1;
    }
    cnt = 1;
    for(auto Pid : my){
        v[Pid.first.second].second = cnt;
        cnt += 1;
    }
    sort(v.begin(), v.end());
    init();
    
    for(int i = 0; i < N; i++){
        int num = sum(v[i].second);
        P4[i] = num;
        P1[i] = i - num;
        add(v[i].second, 1);
    }
    init();
    for(int i = N - 1; i >= 0; i--){
        int num = sum(v[i].second);
        P2[i] = num;
        P3[i] = (N - 1 - i) - num;
        add(v[i].second, 1);
    }
    long long int ans = p2[N - 1] * N % MOD;
    for(int i = 0; i < N; i++){
        long long int S1 = (p2[P1[i]] - 1) * (p2[P2[i]] - 1) % MOD * p2[P3[i] + P4[i]] % MOD;
        long long int S2 = (p2[P3[i]] - 1) * (p2[P4[i]] - 1) % MOD * p2[P1[i] + P2[i]] % MOD;
        long long int S3 = (p2[P1[i]] - 1) * (p2[P2[i]] - 1) % MOD * (p2[P3[i]] - 1) % MOD * (p2[P4[i]] - 1) % MOD;
        ans += S1 + S2 - S3 + MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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


typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

char s[52], t[52];
int lsb(ll x){
  int r = 0;
  while(true){
    if((x>>r)&1)return r;
    r++;
  }
}
int erhe(ll s, ll t){
  int r = 50;
  while(true){
    if(((s>>r)&1) != ((t>>r)&1))return r;
    r--;
  }
}
int erlw(ll s, ll t){
  int r = 0;
  while(true){
    if(((s>>r)&1) != ((t>>r)&1))return r;
    r++;
  }
}
int sub(ll a, ll b){
  int ans = 0;
  while(a!=b){
    int x = lsb(a);
    int e = erhe(a,b);
    int f = erlw(a,b);
    ans++;
    // printf("(%lld, %lld): x(%d),e(%d),f(%d)\n",a,b,x,e,f);
    if(x<e || x==f){
      a = a & ~(1ll<<x);    // reset x
      a = a | (1ll<<(x+1)); // set x+1
    }else{
      a = a ^ ((a^b) & (1ll<<x));
      a = a | (1ll<<(x-1)); // set x-1
    }
    if(ans>2521)return 2521;
  }
  return ans;
}
void solve(){
  REP(i,52)s[i]=t[i]='\0';
  scanf("%s%s",s,t);
  int n = strlen(s);
  ll a=0, b=0;
  REP(i,n){
    a<<=1; a+=s[i]-'0';
    b<<=1; b+=t[i]-'0';
  }
  printf("%d\n",sub(a,b));
}

int main(){
  // sub(18,16);
  // return 0;
  // // if(true){
  // //   while(true){
  // //     ll a = rand() % 64;
  // //     ll b = rand() % 64;
  // //     if(a==0 || b==0)continue;
  // //     if(sub(a,b) == 2521){
  // //       printf("%lld %lld\n",a,b);
  // //       return 0;
  // //     }
  // //   }
  // // }
  int q;
  scanf("%d",&q);
  while(q--)solve();
  return 0;
}

// s, x = lsb(s)
// a = (s>>(x+1))&1
// if(x>0)  s-(1<<(x-1)) is ok
// if(x>0)  s+(1<<(x-1)) is ok
// if(a==1) s-(1<<x) is ok
// if(a==0) s+(1<<x) is ok

// x is lsb position
// if x>0 then reset(x) & set(x-1) & x++
// if x>0 then            set(x-1)
// if s[x-1]==1 then reset(x)            & x--
// if s[x-1]==0 then reset(x) & set(x-1) & x--

//    x+1 x+0 x-1
//      ?   1   0
// a.   ?   0   1   x--
// b.   ?   1   1   x--
// c.   1   0   0   x++


Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int all = 0;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        all ^= a[i];
    }
    for (int i=0; i<n; i++) {
        if (i != 0)
            cout << " ";
        cout << (all ^ a[i]);
    }
    cout << endl;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	bool ok = true;
	if (s[a] != '-') ok = false;
	int count = 0;
	rep(i, s.size()) {
		if (s[i] == '-') count++;
	}
	if (count > 2) ok = false;
	if (ok) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin>>n;
    int d[101]={};
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        d[a]++;
    }
    int ans=0;
    for(int i=0;i<=100;i++){
        if(d[i]>0) ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
  int n, temp;
  std::vector<int> A;
  
  std::cin >> n;
  
  for (auto i=0; i<n; ++i) {
    std::cin >> temp;
    A.push_back(temp);
  }
  
  auto counter = 0;
  
  for (auto i=0; i<n-1; ++i) {
    int min_idx = i;
    for (auto j=i; j<n; ++j) {
      if (A.at(min_idx) > A.at(j)) {
        min_idx = j;
      }
    }
    if (i !=  min_idx) {
      std::swap(A.at(i), A.at(min_idx));
      ++counter;
    }
  }

  for (auto i=0; i<n-1; ++i)
    std::cout << A.at(i) << " ";
  
  std::cout << A.back() << std::endl << counter << std::endl;
}


Measured memory_bytes: 3124
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int K, T;
	int a[101];
	cin >> K >> T;
	REP(i, 0, T) cin >> a[i];

	sort(a, a + T);
	reverse(a, a + T);
	int cnt = a[0];
	if (T == 1) cout << cnt - 1 << endl;
	else {
		REP(i, 1, T) {
			cnt -= a[i];
		}

		if (cnt <= 0) cout << 0 << endl;
		else cout << cnt - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools

mod = int(1e9+7)

def main():
    n = list(map(int,input().split()))
    n.sort()
    if n[0] == 1 and n[1] == 4 and n[2] == 7 and n[3] == 9:
        print('YES')
    else:
        print('NO')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38384
S=input()

ans=[1]*len(S)
for i in range(1,len(S)):
  if S[i-1]==S[i]=='R':
    ans[i+1]+=ans[i-1]
    ans[i-1]=0
for i in range(len(S)-2,0,-1):
  if S[i+1]==S[i]=='L':
    ans[i-1]+=ans[i+1]
    ans[i+1]=0
print(*ans)


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

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

    int n;
    cin >> n;
    vector<int> d(n);
    REP(i, n) cin >> d[i];
    sort(d.begin(), d.end());

    int midL = d[d.size() / 2 - 1];
    int midR = d[d.size() / 2];

    int ans = midR - midL;
    cout << ans << '\n';
    return 0;
}


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

#define ll long long
#define fr first
#define se second

using namespace std;

const long long N = 2e6 + 7;

ll res, n, m, cnt, q = 1;
string s, str;
vector< string > v;
int main()
{
    /// freopen( "input.txt", "r", stdin );
    /// freopen( "output.txt", "w", stdout );
    cin >> n;
     cin >> m >> q;
     for ( int i=m; i<=q; i ++ ){
        if ( i % n == 0 ){
            cout << "OK";
            return 0;
        }
     }
     cout << "NG";
}


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

using namespace std;

#define int long long

const int N = 1e5 + 100;

vector<int> vec;
int a[N], b[N];
int n, ans;

bool cmp(int i, int j) {
	return a[i] + b[i] > a[j] + b[j];	
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		vec.push_back(i);
	}
	sort(vec.begin(), vec.end(), cmp);
	for (int i = 0; i < n; i += 2) {
		int ind = vec[i];
		ans += a[ind];
	}
	for (int i = 1; i < n; i += 2) {
		int ind = vec[i];
		ans -= b[ind];
	}
	return cout << ans, 0;
}


Measured memory_bytes: 2676
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor, gcd
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10
    sa,sb = input().split()
    a = int(sa)
    b = int(float(sb)*100+0.1)
    print(a*b//100)

    
main()


Measured memory_bytes: 65328
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    res=0
    a = list(map(int,input().split()))
    for j in range(m):
        res += a[j]*b[j]
    if res+c>0: cnt+=1
print(cnt)

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int main(void){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    int x,y,X,Y;
    
    if(N%A == 0 && N%C == 0){
        x = N/A;
        y = N/C;
        
        X = x*B;
        Y = y*D;
        
        if(X > Y){
            cout << Y << endl;
        }
        else{
            cout << X << endl;
        }
    }
    else if(N%A == 0 && N%C != 0){
        x = N/A;
        y = N/C + 1;
        
        X = x*B;
        Y = y*D;
        
        if(X > Y){
            cout << Y << endl;
        }
        else{
            cout << X << endl;
        }
    }
    else if(N%A != 0 && N%C == 0){
        x = N/A + 1;
        y = N/C;
        
        X = x*B;
        Y = y*D;
        
        if(X > Y){
            cout << Y << endl;
        }
        else{
            cout << X << endl;
        }
    }
    else if(N%A != 0 && N%C != 0){
        x = N/A + 1;
        y = N/C + 1;
        
        X = x*B;
        Y = y*D;
        
        if(X > Y){
            cout << Y << endl;
        }
        else{
            cout << X << endl;
        }
    }
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;
  cin >> a >> b;
  c = abs(b - a);
  if(a <= 0 && b >= 0){
    cout << "Zero"<<endl;
  }
  else if(b > 0){
    cout << "Positive" << endl;
  }
  else if(b < 0 && c % 2){
    cout << "Positive" << endl;
  }
  else
    cout << "Negative" << endl;
  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 ll = long long;
using namespace std;

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

    map<string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    cout << mp[S] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
#define  fi first
#define  se second 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1e9+9;


int main()
{
    string s;
    int ans=0;
    cin>>s;
    for(char c:s)ans+=(c=='1');
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, m;
    cin >> n >> m;
    map<long, long> l;
    for(int i = 0; i < n; i++){
        long a, b;
        cin >> a >> b;
        l[a] += b;
    }
    long ans = 0, mm = m;
    for(auto i = l.begin(); i != l.end(); i++){
        if(i->second >= mm){
            ans += mm * i->first;
            break;
        }else{
            mm -= i->second;
            ans += i->second * i->first;
        }
    }
    cout << ans << endl;
    return 0;
}

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

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var restaurants = Enumerable.Range(0, n)
			.Select(i => Console.ReadLine().Split())
			.Select((x, i) => new Restaurant { Id = i + 1, City = x[0], Point = int.Parse(x[1]) });

		var query =
			from r in restaurants
			orderby r.City, r.Point descending
			select r.Id;
		Console.WriteLine(string.Join("\n", query));
	}
}

class Restaurant
{
	public int Id { get; set; }
	public string City { get; set; }
	public int Point { get; set; }
}


Measured memory_bytes: 11744
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#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 zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

	
//////////////////////////////code//////////////////////////////

void solve()
{
  //  cout << "-------------------" << "\n";
     
  int n;
  cin>>n;
  
  string s;
  cin>>s;
  
  int cnt = 0;
  for(int i=0;i<n;i++) if(s[i] == 'R') cnt++;
  
  int cnt1 = 0;
  
  for(int i=0;i<cnt;i++) if(s[i]=='R') cnt1++;
  
  db(cnt - cnt1)
  //  cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
    //cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values


Measured memory_bytes: 3772
N = int(input())
A = list(map(int, input().split()))
abs_A = list(map(lambda x: abs(x), A))
abs_A = sorted(abs_A)
min_cnt = 0
ans = 0
#print(A)
for a in A:
    if a < 0:
        min_cnt += 1
    ans += abs(a)
#print(min_cnt)
if min_cnt % 2 == 1:
    ans -= 2 * abs_A[0]
print(ans)

Measured memory_bytes: 92340
// aaa.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

/** @file report1.cpp @brief 改善対象のソースコード
 *
 *
 *
 *
 * @author Kenta Fjiwara
 * @date 2014/11/21 new
 */

#include <iostream>
#include <algorithm>
using namespace std;

class TEST
{
public:
    int H;          //height
    int W;          //width
    int _ans[2];    //answer
    
    /** Constructor
     *
     * Class initialization
     */
    TEST() {}
    /** input
     *
     *
     * KeyBoard Input
     */
    void input()
    {
        while(cin >> H >> W && H && W)
        {
            exam();
        }
    }
    /** output
     *
     *
     * Answer output
     */
    void output()
    {
     cout << _ans[0] << ' ' << _ans[1]<< endl;
    }
    /** calecuration
     *
     *
     */
    void exam()
    {
        const pair<int, int> given(tkj(H, W), H);
        pair<int, int> best(tkj(150, 150), 150), ans;
        
        for(int h=1; h<=150; ++h)
        {
            for(int w=1; w<=150; ++w)
            {
                if(w<=h)continue;
                // 幅の方が長い長方形を扱う
                pair<int, int> x(tkj(h,w), h);
                
                //pair<int, int>による比較
                if(given < x && x < best)
                {
                    best=x;
                    
                    ans= make_pair(h, w);
                }
            }
        }
        
        _ans[0] = ans.first;
        _ans[1] = ans.second;
        
        output();
    }
    
    
    /** 長方形の対角線の二乗
     *
     * @param h 高さ
     * @param w 幅
     * @return　長方形の対角線の二乗
     *
     */
    int tkj(int h, int w)
    {
        return(h*h + w*w);
    }
    
};


int main()
{
    TEST base;
    base.input();
}

Measured memory_bytes: 1160
n = int(input())
t, x, y =0, 0, 0
for i in range(n):
    next_t, next_x, next_y = map(int, input().split())
    dif = abs(next_x - x) + abs(next_y - y)
    if dif > (next_t - t) or (dif - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y = next_t, next_x, next_y
print("Yes")

Measured memory_bytes: 46952
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

ll mod = 1e9 + 7,dp[110][10];
int h, w, k;

int main(){
    cin >> h >> w >> k;
    dp[0][0] = 1, k--;
    vector<int>flag;
    for (int j = 0; j < (1 << (w - 1)); j++){
        bool jud = 1;
        for (int k = 0; k < w - 2; k++){
            if (j & (1 << k) && j & (1 << (k + 1)))jud = 0;
        }
        if(jud == true)flag.push_back(j);
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < flag.size(); j++){
            int p[w];
            for (int k = 0; k < w; k++)p[k] = k;
            for (int k = 0; k < w - 1; k++)if (flag[j] & (1 << k))swap(p[k], p[k + 1]);
            for (int k = 0; k < w; k++)(dp[i + 1][p[k]] += dp[i][k]) %= mod;
        }
    }
    cout << dp[h][k] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {

    int a, b;
    cin >> a >> b;
    string s = to_string(a) + to_string(b);
    int x = stoi(s);
    int c = (int)sqrt(x);
    if(c * c == x){
        cout << "Yes" << endl;
    }else cout << "No" << endl;

    return 0;
}

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

int a[5];
  int b =0;
  for (int i = 0 ;i<5;i++){
  cin >> a[i] ;
    if(a[i] == 0) b=i+1;
  }
   cout << b<< endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	ll ans = k;
	for(int i=0; i<n-1; i++) ans *= k-1;
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>#include <string.h>
short dp[4001][4001]={},ans=0;
char str1[2][4005];
int main(i,j){while(scanf("%s",str1[0])!=EOF){scanf("%s",str1[1]);int a=strlen(str1[0]),b=strlen(str1[1]); for(i=0;i<a;i++){for(j=0;j<b;j++){if(str1[0][i]==str1[1][j]){
if(!i || !j){dp[i][j]=1;if(!ans){ans++;}}else{dp[i][j]=1+dp[i-1][j-1];ans=ans<dp[i][j]?dp[i][j]:ans;}}}}printf("%d\n",ans); ans=0;memset(dp,0,sizeof(dp));}return 0;}

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


int solve (int n,int g[],int h[])
{
    if(n==2)
    {
        h[n-1] =abs(g[n-1]-g[n-2]);
        
        h[n-2] =0;
        return  h[n-1];
        
    }
    
    
    if(h[n-2] ==-1)
    solve(n-1, g,h);
    
    h [n-1] = min(h[n-2]+abs(g[n-1]-g[n-2]), h[n-3]+abs(g[n-1]-g[n-3]));
    return h[n-1];
    
    
}


int main() {

    int n; cin>>n;
    int g[n],h[n];
    for(int i=0; i<n; i++)
    {
        cin>>g[i];
        h[i]=-1;
    }
   cout<< solve(n,g,h);
    
    
    
	return 0;
}


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

using namespace std;
typedef long long ll;

const ll MX = 1e18;

int main(){
    int K;
    string S;
    cin >> K;
    cin >> S;

    if (S.size() > K)
    {
        cout << S.substr(0, K) << "..." << endl;;
    }
    else
    {
        cout << S << endl;
    }    

    return 0;
}

Measured memory_bytes: 3584
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  while n % (p ** e) == 0:
    n //= (p ** e)
    score += 1
    e += 1
  else:
    while n % p == 0:
      n //= p
    p += 1
else:
  if n != 1:
    score += 1
print(score)

Measured memory_bytes: 9080
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int $$,$[100010];
    cin>>$$;
    for(int $$$=1;$$$<=$$;$$$++)
        cin>>$[$$$];
    int $2[100010],$3[100010];
    for(int $$$=1;$$$<$$;$$$++)
        $2[$$$]=abs($[$$$+1]-$[$$$]);
    for(int $$$=1;$$$<$$-1;$$$++)
        $3[$$$]=abs($[$$$+2]-$[$$$]);
    int $4[100010];
    $4[1]=0,$4[2]=$2[1];
    for(int $$$=3;$$$<=$$;$$$++)
        $4[$$$]=min($4[$$$-1]+$2[$$$-1],$4[$$$-2]+$3[$$$-2]);
    cout<<$4[$$]<<endl;
    return 0;
}


Measured memory_bytes: 1792