akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL x,y;
	cin>>x>>y;
	if(x%y==0){
		cout<<-1;
	}else{
		FOR(i,1,y){
			if((1LL*i*x)%y!=0){
				cout<<1LL*i*x<<endl;
				break;
			}
		}
	}
    return 0;
}


Measured memory_bytes: 256
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
S = ISS()
if len(set(S)) == 3:
    print("Three")
else:
    print("Four")

Measured memory_bytes: 3064
// AtCoder ABC070 B - Two Switches
// 2020.1.25 bal4u

#include <stdio.h>

int main()
{
	int A, B, C, D;
	scanf("%d%d%d%d", &A, &B, &C, &D);
	if (A < C) A = C;
	if (B > D) B = D;
	if (A < B) printf("%d\n", B-A);
	else puts("0");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

ll N, L[100000], R[100000];

int main() {
    ll max_l = -100000, min_r = 100000;
    cin >> N;
    REP(i, N) {
        cin >> L[i] >> R[i];
        min_r = min(min_r, R[i]);
        max_l = max(max_l, L[i]);
    }

    sort(L, L + N, greater<ll>());
    sort(R, R + N);

    int ok_count = 0;
    REP(i, N) if (L[i] > R[i]) ok_count++;

    ll l_ans = 0, r_ans = 0;
    ll l_now = 0, r_now = 0;
    REP(i, ok_count) {
        l_ans += abs(L[i] - l_now);
        l_ans += abs(R[i] - L[i]);
        l_now = R[i];
        r_ans += abs(R[i] - r_now);
        r_ans += abs(L[i] - R[i]);
        r_now = L[i];
    }

    if (L[ok_count] > l_now) {
        l_ans += abs(L[ok_count] - l_now);
        l_ans += abs(L[ok_count]);
    }
    else {
        l_ans += abs(l_now);
    }
    if (R[ok_count] < r_now) {
        r_ans += abs(R[ok_count] - r_now);
        r_ans += abs(R[ok_count]);
    }
    else {
        r_ans += abs(r_now);
    }

    cout << max(l_ans, r_ans) << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ');
            var a = Convert.ToInt32(x[0]);
            var b = Convert.ToInt32(x[1]);
            var c = Convert.ToInt32(x[2]);

            var count = 0;
            for (int i = a; i <= b; i++)
            {
                if (c % i == 0)
                {
                    count++;
                }
            }

            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9228
N = int(input())
s = [input() for _ in range(N)]
 
dic = {}
ans = 0
 
for ss in s:
    #temp = [ch for ch in ss]
    #temp.sort()
    
   # sss = "".join(temp)
    sss="".join(sorted(ss))
  
    if sss in dic:
        ans += dic[sss]
        dic[sss] += 1
    else:
        dic[sss] = 1
 
print(ans)

Measured memory_bytes: 24976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)
using ll = long long;
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INF = 1LL << 60;

int main() {
    ll N;
    cin >> N;
    ll dp[100010][3];
    ll abc[100010][3];
    rep(i, N) {
        rep(j, 3) { cin >> abc[i][j]; }
    }
    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + abc[i][k]);
            }
        }
    }
    ll ans = 0;
    rep(i, 3) { chmax(ans, dp[N][i]); }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
class MyStack
  def initialize(max)
    @top = 0
    @max = max
    @s = Array.new(max)
  end

  def is_empty?
    @top == 0
  end

  def is_full?
    @top >= (@max -1)
  end

  def push(x)
    if is_full?
      raise "overflow"
    end
    @top += 1
    @s[@top] = x
  end

  def pop
    if is_empty?
      raise "underflow"
    end
    @top -=1
    @s[@top+1]
  end

  def dump
    puts @s
  end

  def print
    results = []
    while (!is_empty?) do
      results << pop[1]
    end
    pools = results.empty? ? '' : ' ' + results.reverse.join(' ')
    puts results.length.to_s + pools
  end
end

inputs = gets.split('')

s1 = MyStack.new(20000)
s2 = MyStack.new(10000)
total = 0
is_contiguous = false
inputs.each_with_index do |x, i|
  case x
  when "\\"
    s1.push(i)
    is_contiguous = false
  when "/"
    if s1.is_empty?
      next
    end

    position = s1.pop()
    area = i - position
    total += area
    total_prev_area = 0
    stack_position = position + 1
    while (!s2.is_empty?)
      prev_position, prev_area = s2.pop()
      if prev_position < position
        s2.push([prev_position, prev_area])
        break
      end
      total_prev_area += prev_area
      stack_position = prev_position
    end

    s2.push([stack_position -1, total_prev_area + area])
  when "_"
    next
  end
end

puts total
# s2.dump
s2.print


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

using namespace std;

#define ll long long

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif // ONLINE_JUDGE
	ll times=1;
	// cin>>times;
	while(times--)
	{
		int n;
		cin>>n;
		string str;
		cin>>str;
		int res=0;
		for(int i=0;i<=n-3;i++)
		{
			if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C')
				res++;
		}
		cout<<res<<"\n";
	}
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin >> N;
    set<ll> elem;
    map<ll,ll> num;
    rep(i,N){
        cin>>A;
        ++num[A];
        elem.insert(A);
    }
    ll ans = 0;//残る要素数
    for(ll e : elem){
        ans += (num[e] >= e) ? e : 0;
    }
    cout<<N - ans<<endl;
}

Measured memory_bytes: 10752
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    k=int(input())
    score=0
    B=0

    from heapq import heappush,heappop
    q=[] # 小さいほうの最大をとる→マイナスにして入れる
    Q=[] # 大きいほうの最小をとる

    for _ in range(k):
        s=input()
        if(s[0]=='1'):
            s,a,b=map(int,s.split())
            heappush(q,-a)
            heappush(Q,a)
            B+=b
            # 大小関係が逆転しているかを判断する
            t=-q[0]; T=Q[0]
            if(t>T):
                score+=t-T
                heappop(q); heappop(Q)
                heappush(q,-T); heappush(Q,t)
        else:
            print(-q[0],score+B)
resolve()

Measured memory_bytes: 19004
S = input()
i = 0
j = len(S) - 1
ans = 0
while i < j:
    if S[i] == S[j]:
        i += 1
        j -= 1
    elif S[i] == "x":
        i += 1
        ans += 1
    elif S[j] == "x":
        j -= 1
        ans += 1
    else:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 3316
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)
b = gets.chop.split.map(&:to_i)
ans = 0
n.times do |i|
  x = [a[i], b[i]].min
  b[i] -= x
  y = [a[i+1], b[i]].min
  a[i+1] -= y
  ans += x + y
end
puts ans


Measured memory_bytes: 21788
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <set>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_H = 500;
const int MAX_W = 500;
int H, W;
int a[MAX_W][MAX_H];

string solve() {
    string answer = "";
    bool wip = false;
    int pre_x = 0;
    int pre_y = 0;
    int count = 0;
    REP(y,0,H) {
        if (y % 2 == 0) {
            REP(x,0,W) {
                if (x == 0 && y == 0) {
                    if (a[x][y] % 2 == 1) wip = !wip;
                    continue;
                }
                if (wip) {
                    count++;
                    answer += to_string(pre_y + 1) + " " + to_string(pre_x + 1) + " " + to_string(y + 1) + " " + to_string(x + 1) + "\n";
                }
                if (a[x][y] % 2 == 1) {
                    wip = !wip;
                }
                pre_x = x;
                pre_y = y;
            }
        } else {
            RREP(x,0,W) {
                if (wip) {
                    count++;
                    answer += to_string(pre_y + 1) + " " + to_string(pre_x + 1) + " " + to_string(y + 1) + " " + to_string(x + 1) + "\n";
                }
                if (a[x][y] % 2 == 1) {
                    wip = !wip;
                }
                pre_x = x;
                pre_y = y;
            }
        }
    }
    answer = to_string(count) + "\n" + answer;
    return answer;
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> H >> W;
    REP(y,0,H) REP(x,0,W) cin >> a[x][y];
    cout << solve();
    return 0;
}



Measured memory_bytes: 5124
import java.util.Scanner;

public class Main {

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

        String s = sc.next();
        int a = 0;
        int b = 0;
        for (int i = 0 ; i < s.length() ; i++) {
            if (s.substring(i, i + 1).equals("0")) {
                a++;
            } else {
                b++;
            }
        }
        if (a == 0 || b == 0) {
            System.out.println(0);
        } else {
            System.out.println(Math.min(2 *a , 2 * b));
        }

    }

}

Measured memory_bytes: 33132
n = int(input())
k = int((n*2)**.5)
while k*(k+1)//2 < n:
  k += 1
l = list(range(1,k+1))
if k*(k+1)//2-n:
  l.remove(k*(k+1)//2-n)
for i in l:
  print(i)

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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef long long int lli; 
 
int main(){
    
    lli n,i;
	map<string,lli> mp;
	cin>>n;
	string x;
	for(i=0;i<n;i++){
		cin>>x;
		mp[x]++;
	}
	cout<<mp.size();
    return 0;
}

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

#define debug(x) cerr << #x << " = " << x << endl

const int N_MAX = 100003;
long long a[N_MAX], t[N_MAX], ans[N_MAX];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n, Q;
  cin >> n >> Q;
  if (Q == 0) {
    for (int i = 1; i <= n; ++i)
      cout << 1 << '\n';
    return 0;
  }
  int m = 0;
  for (int i = 1; i <= Q; ++i) {
    long long x;
    cin >> x;
    while (m > 0 && a[m] >= x)
      --m;
    a[++m] = x;
  }
  
  t[m] = 1;
  for (int i = m; i > 0; --i) {
    long long k = a[i];
    for (int j = i - 1; j > 0; j = upper_bound(a, a + j + 1, k) - a - 1) {
      t[j] += t[i] * (k / a[j]);
      k %= a[j];
    }
    if (k >= n) {
      ans[n] += t[i] * (k / n);
      k %= n;
    }
    ans[k] += t[i];
  }
  for (int i = n; i > 1; --i)
    ans[i - 1] += ans[i];
  for (int i = 1; i <= n; ++i)
    cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 4096
// JOI 2016 Q3 Refreshment Area - C++

#include <iostream>
using namespace std;

int main()
{

	int N, M, D, pos, ans = 0, cnt = 0;
	char MAP[101][101];

	// ??±?\??????????????????°??¨?????????????????????????????°??\???
	cin >> N >> M >> D;

	// ???????????\???
	for(int i = 0; i < N; i++) cin >> MAP[i];

	// ??¢?´¢????§?
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			// ??????????¨??????????????????\??????????????????????????????????????´??????
			// ??¢?´¢???????????????????????????
			if(D <= M) {
				// ??¢?´¢????§????????????\??????
				pos = j;
				// ??±(???)???????????¢?´¢?????????????????????????????????????§?????????????
				// ????????????(#)??????????????????????????????????????????????????´?????????
				// break
				for(cnt = 0; cnt < D; cnt++) {
					if(MAP[i][pos] == '#' || pos >= M) break;
					pos++;
				}
				// ??????????????????????§?????????§????????°????????????
				if(cnt == D) ans++;
			}
			// ?????£????????????????????????
			if(D <= N) {
				pos = i;
				for(cnt = 0; cnt < D; cnt++) {
					if(MAP[pos][j] == '#' || pos >= N) break;
					pos++;
				}
				if(cnt == D) ans++;
			}
		}
	}

	// ???????????????????????°?????????
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
double dp[301][301][301];
double Sushi(int x,int y,int z,int n){
  	if(x<0 || y<0 || z<0){
    	return 0;
    }
	if(x==0 && y==0 && z==0){
    	return 0;
    }
  	if (dp[x][y][z]!=-1){
    	return dp[x][y][z];
    }
  	double val=n+x*Sushi(x-1,y,z,n)+y*Sushi(x+1,y-1,z,n)+z*Sushi(x,y+1,z-1,n);
  	return dp[x][y][z]=val/(x+y+z);
}
int main(){
	int n;
  	cin>>n;
  	for(int i=0;i<=300;i++){
        for(int j=0;j<=300;j++){
            for(int k=0;k<=300;k++){
                dp[i][j][k]=-1;
            }
        }
  	}
  	int a[n];
  	for(int i=0;i<n;i++){
    	cin>>a[i];
    }
  	int one=0,two=0,three=0;
  	for(int i=0;i<n;i++){
    	if(a[i]==1){
        	one++;
        }
      	else if(a[i]==2){
        	two++;
        }
      	else if(a[i]==3){
        	three++;
        }
    }
    cout<<fixed;
  	cout<<setprecision(10)<<Sushi(one,two,three,n)<<endl;


}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll n,k; cin >> n >> k;
    vector<ll> x(n);rep(i,n)cin >> x[i];
    ll mn = LINF;
    for (ll i = 0; i+k-1 <= n-1; i++)
    {
        ll r,l;
        l = x[i];r = x[i+k-1];
        if(0<=r && 0<=l)
        {
            mn = min(abs(r), mn);
        }else if (l<0 && 0<=r)
        {
            mn = min(2*abs(l)+abs(r),mn);
            mn = min(2*abs(r)+abs(l),mn);
        }else
        {
            mn = min(abs(l),mn);
        } 
        // cout << mn << endl;
    }
    cout << mn << endl;
    

}

Measured memory_bytes: 3988
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int a;
    int b;
    int sum=0;
    cin>>a>>b;
    int c[a];
    for(int i=0;i<a;i++){
        cin>>c[i];
        sum=sum+c[i];
    }
    int min = c[0];
    for(int j=1;j<a;j++){
        if(min>c[j]){
            min=c[j];
        }
    }
    if(sum>=b){
        cout<<a<<endl;
    }
    else{
        int d=b-sum;
        int e=d/min;
        cout<<e+a<<endl;
    }
    return 0;
}


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

int main() {
  int a, b, c, i, cnt=0;
  cin >> a >> b >> c;
  for(i = a; i <= b; i++){
    if(c % i == 0){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3104
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
l=[[] for i in range(a)]
for j in range(b):
  x,y=mi()
  l[x-1].append(y-1)
  l[y-1].append(x-1)
lst=[-1]*a
q=deque([0])
while q:
  s=q.popleft()
  for j in l[s]:
    if lst[j]==-1:
      lst[j]=s
      q.append(j)
print("Yes")
for k in range(a-1):
  print(lst[k+1]+1)

Measured memory_bytes: 95096
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    s.erase(unique(s.begin(),s.end()),s.end());
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
#define LL long long
#define N 500
#define lowb(x) x&-x

int c[N][N];
map<pair<int,int>,int>mp;
void add(int x,int y)
{
    for(int i=x;i<=N;i+=lowb(i))
    {
        for(int j=y;j<=N;j+=lowb(j))
        {
            c[i][j]+=1;
        }
    }
}

int sum(int x,int y)
{
    int ans=0;
    for(int i=x;i;i-=lowb(i))
    {
        for(int j=y;j;j-=lowb(j))
        {
            ans+=c[i][j];
        }
    }
    return ans;
}
int main()
{
    int n,m,q;
    int l,r;
    cin>>n>>m>>q;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&l,&r);
        add(l,r);
    }
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d",&l,&r);
        printf("%d\n",sum(r,r)-sum(r,l-1)-sum(l-1,r)+sum(l-1,l-1));
    }
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();

		Long sum = (long) 0;
		for (int i = 1; i <= N; i++) {
			if (i % 3 == 0)
				continue;
			else if (i % 5 == 0)
				continue;
			else if (i % 15 == 0)
				continue;
			else
				sum += i;
		}

		System.out.println(sum);
		sc.close();

	}
}

Measured memory_bytes: 48292
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		StringBuilder sb = new StringBuilder();
		for(int i = 0 ; i < a ; i++) sb.append(".");
		sb.append("-");
		for(int i = 0 ; i < b ; i++) sb.append(".");
		if(s.substring(0, a).matches(sb.toString().substring(0, a)) && s.substring(a, a + 1).equals(sb.toString().substring(a, a + 1)) && s.substring(a + 1).matches(sb.toString().substring(a + 1)) && !s.substring(0, a).contains("-") && !s.substring(a + 1).contains("-")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23508
num = int(input())
base_str = input()
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
            'U', 'V', 'W', 'X', 'Y', 'Z']
def replacer(letter, num):
    letter_index = alphabets.index(letter)
    return(alphabets[(letter_index+num)%26])
answer = []
for i in range(len(base_str)):
    answer.append(replacer(base_str[i], num))
answer = ''.join(answer)
print(answer)

Measured memory_bytes: 39280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        for(int i=0; i<k*2-1; i++) {
            int a = x - k + 1 + i;
            System.out.print(a + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 38408
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
int a,b;
cin>>a>>b;
if(a>2*b)
    cout<<a-2*b<<endl;
else
    cout<<"0"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())
 
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
constexpr ll INF = TEN(18);
 
int main() {
    int N, K;
    cin >> N >> K;
    V<int> P(N), C(N);
    rep(i, N) cin >> P[i], --P[i];
    rep(i, N) cin >> C[i];
 
    ll ans = -INF;
 
    rep(i, N) {
        int v = i;
        ll cycle_sum = 0;
        int cycle_cnt = 0;
 
        while (true) {
            cycle_cnt++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i) break;
        }
 
        ll path = 0;
        int cnt = 0;
 
        while (true) {
            cnt++;
            path += C[v];
 
            if (cnt > K) break;
 
            int num = (K - cnt) / cycle_cnt;
            ll score = path + max(0ll, cycle_sum) * num;
            chmax(ans, score);
 
            v = P[v];
            if (v == i) break;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<cstring>
using namespace std;
int n,x,r[1000100];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >>x>>n;
for(int i=1;i<=n;i++)cin >>r[i];
int q,now=1,p=-1,low=x,high=0,ad=0;cin >>q;
while(q--)
{
	int t,a;cin >>t>>a;
	while((now<=n)&&(t>=r[now]))
	{
		int dlt=p*(r[now]-r[now-1]);
		ad+=dlt;low=min(x,max(dlt+low,0));high=min(x,max(dlt+high,0));
		now++,p*=-1;
	}
	cout <<min(x,max(0,min(low,max(a+ad,high))+p*(t-r[now-1])))<<'\n';
}
return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;
int main()
{
    int a,b,c,d,N,M;
    cin>>a>>b>>c>>d;
    N=a+b;
    M=c+d;
    if(N>M)
        cout<<"Left";
    if(M>N)
        cout<<"Right";
    if(M==N)
        cout<<"Balanced";
	
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,x,t,total = 0;
    scanf("%d",&n);
    scanf("%d",&x);
    scanf("%d",&t);
    if(n%x == 0) printf("\n%d",((int)n/x)*t);
    else printf("\n%d",((int)n/x)*t + t);
    return 0;
}

Measured memory_bytes: 2152
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
       int N = scanner.nextInt();
        System.out.println((N - 1) / 2);
    }

}

Measured memory_bytes: 21716
use std::io::*;
use std::str;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let s = i.read_line();
    writeln!(o, "{}", solve(s)).unwrap();
}
fn solve(s: &str) -> String {
    let b = s.as_bytes();
    if b.len() < 26 {
        for i in 0..26 {
            let c = b'a' + (i as u8);
            if !b.contains(&c) {
                return format!("{}{}", s, c as char);
            }
        }
        unreachable!()
    }
    let mut b = b.to_owned();
    for i in 1..26 {
        let i = 26 - 1 - i;
        let bi = b[i];
        if let Some(m) = b[i + 1..].iter().cloned().filter(|&x| x > bi).min() {
            b[i] = m;
            return str::from_utf8(&b[..i + 1]).unwrap().to_string();
        }
    }
    "-1".to_string()
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }
    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  vector<Pii> A(N);
  repeat(i,N){
    cin>>A[i].first>>A[i].second;
    A[i].first+=A[i].second;
  }
  sort(A.begin(),A.end(),greater<Pii>());
  ll ans = 0;
  repeat(i,N){
    if(i&1)
    ans -= A[i].second;
    else
    ans += A[i].first-A[i].second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*ボーナスポイントを取る点数帯で場合分けし、それらの点数の合計がG
以上であれば終了
G以下であれば、ボーナスポイントを取らないスコア帯の問題から、点数が
高いものから解き、解いた数をカウント
ボーナスポイントを取らない問題とスコアのペア配列をビットごとに作る
*/


int main() {
  int D,G;
  cin >> D >> G;
  vector<pair<int,int>> S(D);//（問題数、ボーナス）のペア
  rep(i,D){
      cin >> S[i].first;
      cin >> S[i].second;
  }

  int ans = 1000000;
  
  for(int tmp = 0;tmp < (1<<D);tmp++){
      int score = 0;//解いた問題分の点数
      int c = 0;//解いた問題数
      bitset<10> s(tmp);
      vector<int> notB;//ボーナス取りしない問題のスコアの配列
      for(int i = 0;i<D;i++){//ビットが立っている箇所に対応する問題をボーナス解きする
         if(s.test(i)){
          c += S[i].first;//ボーナス解きする問題の数を足す
          score += S[i].second;
          score += 100*(i+1)*S[i].first;
         }
      }
      if(score >= G){//ボーナス解きする問題だけで目標を越えれば終了
          ans = min(ans,c);
      }
      else{//ボーナス解きしない問題について、スコアの大きいものから解いていく
        
         for(int i = D-1;i>=0;i--){
             if(s.test(i)) continue;
             for(int j = 0;j<S[i].first;j++){
             if(score >= G) break;
             score += 100*(i+1);
             c++;
         }
      }
    ans = min(ans,c);
   }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
#define R register

int a,b;
bool ans;

int main()
{
	scanf("%d %d",&a,&b);
	for (R int i=1;i<=3;++i) ans |= ((a*b*i)&1);
	ans ? puts("Yes") : puts("No");
	return 0;
}

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

int main()
{

      /*#ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif*/

     int n , m , x , y ; 
     cin >> n >> m >> x >> y  ;
     int maxin = -1000 ;
     int minim = 1000 ;
     for(int i = 0 ; i < n ; i++ )
     {
         int xx ;cin >> xx ;
         if(xx > maxin )maxin = xx ;
     }
     for(int i = 0 ; i < m ; i++ )
     {
         int xx ;cin >> xx ;
        
         if(xx < minim )minim = xx ;
     }
    for(int i = x + 1 ; i <= y ; i++ )
    {
         if( i > maxin && i <= minim )
         {
            cout<<"No War"<<endl;
            return 0 ;
         }
    }
    cout<<"War"<<endl;
 }

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

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

  if (C == "a" || C == "e" || C == "i" || C == "o" || C == "u" ) {
    cout << "vowel";
  }
  else  {
    cout << "consonant" << endl;
  }

}

Measured memory_bytes: 256
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll n;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>n;
	cout<<(n*800-(n/15)*200);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(n):
  x = input()
  if x == 'AC':
    AC+=1
  elif x == 'WA':
    WA+=1
  elif x == 'TLE':
    TLE+=1
  else:
    RE+=1
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))
    

Measured memory_bytes: 9052
#include <iostream>

using namespace std;

int main()
{
        int d[12] = {31, 29, 31, 30,
                                   31, 30, 31, 31,
                                   30, 31, 30, 31};
        string ans[7] = {"Thursday", "Friday", "Saturday", "Sunday",
                                         "Monday", "Tuesday", "Wednesday"};
        int mon, day;

        while (true) {
                cin >> mon >> day;
                if (!mon) {
                        break;
                }
                int sum = 0;
                for (int i = 0; i < mon - 1; i++) {
                        sum += d[i];
                }
                sum += day - 1;
                cout << ans[sum % 7] << endl;
        }


        return 0;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    
    vector<bool> A(N,false);
    for(int i=0;i<K;++i){
        int d;
        cin>>d;
        for(int j=0;j<d;++j){
            int a;
            cin>>a;
            A[a-1]=true;
        }
    }
    
    int ans=count(A.cbegin(),A.cend(),false);
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£????????????
		Scanner sc = new Scanner(System.in);
		//??\????????????1????????????
		int num1 = sc.nextInt();
		//??\????????????2????????????
		int num2 = sc.nextInt();
		//??\????????????3????????????
		int num3 = sc.nextInt();

		//??????
		int[] arr = new int[]{num1,num2,num3};
		//???????????????
		Arrays.sort(arr);
		//??¨?????????
		for(int i = 0; i<arr.length;i++){
			if(i < 2){
				System.out.print(arr[i]+ " ");
			}else{
				System.out.print(arr[i]);
			}
		}
		//???
		System.out.println();
	}
}

Measured memory_bytes: 26316
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <cstring>
#include <ctime>
#include <cassert>


#define pb emplace_back
#define re return
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265359;


int main()
{
    //freopen("distance.in", "r", stdin);
    //freopen("distance.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    if (n == m)
        cout << "Yes";
    else
        cout << "No";
}
/// ACTUAL CODE STARTS HERE:
//  I'm red in soul
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.map!(to!int).array; }

void calc(string s) {
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';

    int reduce(int lhs, int rhs, int op) {
        return op == 0 ? lhs + rhs : lhs - rhs;
    }
    char op(int op) {
        return op == 0 ? '+' : '-';
    }

    for (int i = 0; i < 2; i++) {
        int x = reduce(a, b, i);
        for (int j = 0; j < 2; j++) {
            int y = reduce(x, c, j);
            for (int k = 0; k < 2; k++) {
                int z = reduce(y, d, k);
                if (z == 7) {
                    // writeln(a, op(i), b, op(j), c, op(k), d, "=7");
                    writefln("%s%s%s%s%s%s%s=7", a, op(i), b, op(j), c, op(k), d);
                    return;
                }
            }
        }
    }
}

void main() {
    auto s = readln.chomp;
    calc(s);
}

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

long long n,len,p=1,s;
string alphabets,ans;


int main()
{
	for(char a='a';a<='z';a++) alphabets+=a;

	cin>>n;

	for(len=1;s<n;len++)
	{
		p*=26;
		if(s+p<n) s+=p;
		else break;
	}

	n-=s+1;
	for(int i=0;i<len;i++)
		ans+=alphabets[n%26],n/=26;

	reverse(ans.begin(),ans.end());
	cout<<ans;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N, K; cin >> N >> K;
	VL x(N), y(N);
	FOR(i, 0, N) {
		cin >> x[i] >> y[i];
	}
	auto in = [](LL a, LL b, LL c) {
		return a <= b && b <= c;
	};
	LL ans = LLONG_MAX;

	FOR(i, 0, N) {
		FOR(j, 0, N) {
			FOR(k, 0, N) {
				FOR(l, 0, N) {
					LL cnt = 0;
					LL xmax = -LINF, xmin = LINF;
					LL ymax = -LINF, ymin = LINF;
					FOR(id, 0, N) {
						if (in(x[i], x[id], x[j]) && in(y[k], y[id], y[l])) {
							cnt++;
							xmax = max(xmax, x[id]);
							xmin = min(xmin, x[id]);
							ymax = max(ymax, y[id]);
							ymin = min(ymin, y[id]);
						}
					}
					if (cnt >= K) {
						ans = min(ans, (xmax - xmin)*(ymax - ymin));
					}
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

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

  if(A-(N%500)>=0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl; 
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int mod = 1000000007;
    int N;
    cin >> N;
    long long ans = 1;
    REP(i,N) ans = ans*(i+1) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i ++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int b;
  for (int j = 0; j < N - 1; j ++) {
    if (a[j] == a[j + 1]) b ++;
  }
  cout << N - b << endl;
}


Measured memory_bytes: 256
d=int(input())
C=[int(i) for i in input().split()]
s=[[int(i) for i in input().split()] for q in range(d)]

sco=0
L=[0 for i in range(26)]
ans=[]

#calc
for i in range(d):
    mayou=0
    est=s[i][0]+C[0]*(i+1-L[0])
    for p in range(1,26):
        if s[i][p]+C[p]*(i+1-L[p]) > est:
            mayou=p
            est=s[i][p]+C[p]*(i+1-L[p])
    ans.append(mayou)
    L[mayou]=i+1
    print(mayou+1) #output


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

int y,m,d;
bool b(int a,int b,int c){
    return (y<a||(y==a&&m<b)||(y==a&&m==b&&d<c));
}
int main(){
    while(cin>>y>>m>>d){
        if(b(1868,9,8))
            cout<<"pre-meiji"<<endl;
        else if(b(1912,7,30))
            cout<<"meiji "<<(y-1867)<<" "<<m<<" "<<d<<endl;
        else if(b(1926,12,25))
            cout<<"taisho "<<(y-1911)<<" "<<m<<" "<<d<<endl;
        else if(b(1989,1,8))
            cout<<"showa "<<(y-1925)<<" "<<m<<" "<<d<<endl;
        else cout<<"heisei "<<(y-1988)<<" "<<m<<" "<<d<<endl;
    }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000


int main(){
	
	long long N,A,B;
	cin>>N>>A>>B;
	
	if((B-A)%2==0){
		cout<<(B-A)/2<<endl;
	}
	else{
		long long ans = 0;
		if(N-A<B-1){
			ans += N-B;
			A += N-B;
			B = N;
			A ++;
			ans ++;
			ans += (B-A)/2;
		}
		else{
			ans += A-1;
			B -= A-1;
			A = 1;
			B --;
			ans ++;
			ans += (B-A)/2;
		}
		cout<<ans<<endl;
		
	}

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };

lint H, W, dp[1000][1000], sy, sx, gy, gx;
char mp[1000][1000];

typedef pair<lint, plint> tlint;
int main() {
	cin >> H >> W;
	cin >> sy >> sx; sy--; sx--;
	cin >> gy >> gx; gy--; gx--;
	REP(i, H) {
		REP(j, W) {
			cin >> mp[i][j];
			dp[i][j] = INF;
		}
	}

	priority_queue<tlint> que;
	dp[sy][sx] = 0;
	que.push({ -dp[sy][sx], { sy, sx } });
	while (!que.empty()) {
		plint curr = que.top().second; que.pop();
		if (curr.first == gy && curr.second == gx) break;
		REP(k, 4) {
			lint ny = curr.first + dy[k], nx = curr.second + dx[k];
			if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			if (mp[ny][nx] == '#') continue;
			if (dp[ny][nx] > dp[curr.first][curr.second]) {
				dp[ny][nx] = dp[curr.first][curr.second];
				que.push({ -dp[ny][nx], { ny, nx } });
			}
		}
		REP(i, 5) {
			REP(j, 5) {
				lint ny = curr.first - 2 + i, nx = curr.second - 2 + j;
				if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
				if (mp[ny][nx] == '#') continue;
				if (dp[ny][nx] > dp[curr.first][curr.second] + 1) {
					dp[ny][nx] = dp[curr.first][curr.second] + 1;
					que.push({ -dp[ny][nx], { ny, nx } });
				}
			}
		}
	}

	if (dp[gy][gx] == INF) cout << -1 << endk;
	else cout << dp[gy][gx] << endk;
}


Measured memory_bytes: 12608
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################

int main() {
int a=D(),b=D();
int ans=a-b;

if(ans<0){
cout<<0;
}else
cout<<ans;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> P;

int num;
const int N = 1010;
map<string, int> G[N];
int par[N];
int file[N];

bool f;
string ind = "index.html";

vector<string> path;
int dfs(int id, int i, bool create){
	if (id < 0) return -1;
	if (i == path.size()){
		if (file[id]) return id;
		return G[id].count(ind) && file[G[id][ind]] ? G[id][ind] : -1;
	}
	if (file[id]) return -1;
	if (path[i] == ".") return dfs(id, i + 1, create);
	if (path[i] == "..") return dfs(par[id], i + 1, create);
	if (G[id].count(path[i])){
		return dfs(G[id][path[i]], i + 1, create);
	}
	else{
		if (create){
			G[id][path[i]] = num;
			file[num] = i == path.size() - 1; // dir or file
			par[num++] = id;
			return dfs(G[id][path[i]], i + 1, create);
		}
		else {
			return -1;
		}
	}
}

vector<string> parse(string s){
	rep(i, s.size()){
		if (s[i] == '/') s[i] = ' ';
	}
	stringstream ss(s);
	vector<string> res;
	while (ss >> s) res.push_back(s);
	return res;
}

int main(){
	ios::sync_with_stdio(false);

	int n, m;
	while (cin >> n >> m, n){
		num = 1;
		rep(i, N) G[i].clear();
		rep(i, N) par[i] = -1;

		rep(i, n){
			string s;
			cin >> s;
			path = parse(s);
			dfs(0, 0, true);
		}
		rep(i, m){
			string s, t;
			cin >> s >> t;

			if (s.back() == '/') s += ".";
			path = parse(s);
			int a = dfs(0, 0, false);

			if (t.back() == '/') t += ".";
			path = parse(t);
			int b = dfs(0, 0, false);

			if (a < 0 || b < 0) cout << "not found" << endl;
			else if (a != b) cout << "no" << endl;
			else cout << "yes" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);	
int main()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll r=0,w=0;
	floop(i,0,n)
	{
		if(s[i]=='W')
		w++;
		else
		r++;
	}
	ll ans=w;
	ll temp=0;
	floop(i,0,n)
	{
		if(s[i]=='R' && i>=r)
		temp++;
	}
	ans=min(ans,temp);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3724