akhauriyash/Code-Regression huggingface dataset:
// abc177_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int D, T, S;
    cin >> D >> T >> S;

    if (D <= S * T){
        print("Yes");
    } else {
        print("No");
    }


    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
typedef long long ll;

ll gcd(ll n, ll m){
    if(n % m == 0) return m;
    return gcd(m, n % m);
}

int main()
{
    int t;
    cin >> t;
    while(t--){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if(b > a || b > d){
            cout << "No" << endl;
            continue;
        }
        ll g = gcd(b, d);
        a = a + d * (c / d + 1);
        a = c + (a - c) % g;
        if(a == c) a += g;
        if(b > a) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3532
l, r = map(int, input().split())

if r - l >= 2018:
    print(0)
    exit()

ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        if i * j < 2019:
            print(i*j)
            exit()
        ans = min(ans, (i * j % 2019))
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (1LL<<62)
#define NINF ((-1)*(INF))
#define MOD (1000000007)

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	#ifdef LOCAL_PROJECT
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	vector<int> a(n+1), b(n+1), c(n+1);
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<int>> dp(n+1, vector<int>(3));
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	for(int i = 1; i <= n; i++)
	{
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}


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

int main(){
  int n; string s; stack<char>st;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (st.empty())st.push(s[i]);
		else if (st.top() == '(' && s[i] == ')')st.pop();
		else st.push(s[i]);
	}
	int le = 0, ri = 0;
	while (st.size()) {
		if (st.top() == '(')le++;
		else ri++;
		st.pop();
	}
	for (int i = 0; i < ri; i++)
    cout << "(";
 cout << s;
  for (int i = 0;i < le; i++)
    cout << ")";
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int mod(long long int a)
{
	if(a<0) a=-a;
	return a;
}
int main(void)
{
	long long int h[200000];
	long long int cost[200000];
	int n,k;
	cin >> n>>k;
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	cost[0]=0;
	for (int i = 1; i < k; ++i)
	{
		cost[i]=mod(h[i]-h[0]);
	}

	for (int i = k; i < n; ++i)
	{
		long long int min1=cost[i-1]+mod(h[i]-h[i-1]);
		for (int j = 2; j <=k; ++j)
		{
			long long int a=cost[i-j]+mod(h[i]-h[i-j]);
			if(a<min1)
			{
				min1=a;
			}
		}
		cost[i]=min1;
		
	}
	printf("%lld\n",cost[n-1]);
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    cout << ((N + X - 1) / X * T) << endl;
    return 0;
}


Measured memory_bytes: 3632
/*
  AOJ 2420
  Title:Anipero 2012
  @kankichi573
  14/4/6 WA 20/23
*/
#include <stdio.h>
#include <limits.h>

#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
#define max3(x,y,z) max(max(x,y),z)
int m,n,a[50],b[50],c[50];
int memo[51][9][51];     //step,lv1,zan more than 8 => 8
#define next(fold,zan) memo[step+1][fold][zan-fold]

void solve_all()
{
  int step,zan,lv1,fold,sw2,sw1;
  int max_,ret;
  
  for(step=n-1;step>=0;step--)
    for(zan=0;zan<=m;zan++)
      for(lv1=0;lv1<=8;lv1++)
	{
	  max_=INT_MIN;
	  for(fold=0;fold<=min(8,zan);fold++)
	    for(sw2=0;sw2<=fold;sw2++)
	      for(sw1=0;sw1<=min(lv1,8-sw2);sw1++)
		{
		  if(sw2==0 && sw1==0)
		    ret=c[step];
		  else
		    ret=sw2*a[step]+sw1*b[step];

		  ret+=next(fold,zan);
#ifdef DEBUG2		  
		  if(ret==67 && step==0) 
		    printf("%d %d %d %d %d\n",fold,zan,next(fold,zan),sw2,sw1);
#endif		  
		  max_=max(max_,ret);
		}
	  memo[step][lv1][zan]=max_;
	}
}
void solve()
{
  int i,j,k;

  for(i=0;i<n;i++)
    for(j=0;j<=8;j++)
      for(k=0;k<50;k++)
	memo[i][j][k]=INT_MIN;


  for(i=0;i<=8;i++)
    for(j=0;j<50;j++)
	memo[n][i][j]=0;

  solve_all();
}


main()
{
  int i,ret,l2;

#ifdef DEBUG
  scanf("%d %d %d",&n,&m,&l2);
#else
  scanf("%d %d",&n,&m);
#endif
  for(i=0;i<n;i++)
    {
      scanf("%d %d %d",&a[i],&b[i],&c[i]);
    }
  solve();
#ifdef DEBUG
  while((ret=memo[0][l2][m])==INT_MIN)
    m--;
#else
  ret=memo[0][0][m];
#endif
  printf("%d\n",ret);
  //printf(":%d\n",memo[1][3][0]);
  //printf(":%d\n",memo[1][7][7]);
  return(0);
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    ll n,m;cin>>n>>m;
    vll a(n); REP(i,n) cin>>a[i];
    ll sum = accumulate(ALL(a), 0LL);
    if (n>=sum){
        cout<<n-sum<<endl;
        return 0;
    }
    else cout <<-1<<endl;
    return 0;
}

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

int64_t Len[51], Pat[51];

int64_t rec(int64_t k, int64_t x){
    //バーガー全部なら前計算の結果を返す
    if(x == Len[k]) return Pat[k];

    int64_t ans = 0;

    //下のバン
    x--;

    //下のk-1バーガー
    if(x > 0){
        int64_t l = min(x, Len[k-1]);
        ans += rec(k-1, l);
        x -= l;
    }

    //真ん中のパティ
    if(x > 0){
        ans++;
        x--;
    }

    //上のk-1バーガー
    if(x > 0){
        int64_t l = min(x, Len[k-1]);
        ans += rec(k-1, l);
        x -= l;
    }

    return ans;
}

int main(){
    int64_t N, X;
    cin >> N >> X;

    Len[0] = Pat[0] = 1;
    for(int i=1; i <= N; i++){
        Len[i] = Len[i-1] * 2 + 3;
        Pat[i] = Pat[i-1] * 2 + 1;
    }

    cout << rec(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
int main(){
  int N;
  cin >> N;
  vector<int> A(N), cnt(N/2+N%2, 2);
  REP(i, N){
    cin >> A[i];
  }
  
  REP(i, N){
    if((A[i] % 2 != N % 2) && A[i] <= N-1 && A[i] >= (N-1)%2){
      cnt[A[i]/2]--;
    }
    else{
      cout << 0 << endl;
      return 0;
    }
  }
 
  REP(i, N/2+N%2){
    if(N % 2 == 1 && i == 0 && cnt[i] ==1){
     
    }
    else if(cnt[i] != 0){
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  REP(i, N / 2){
    ans *= 2;
    ans %= (ll)(1e9+7);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = (int)s.size();

    int maxl = 0, len = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T'){
            len = 0;
            continue;
        }
        maxl = max(maxl, ++len);
    }

    cout << maxl << endl;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main(){
int N;
cin >> N;
vector<string> s(N);
REP(i, N) {
  cin >> s[i];
  sort(all(s.at(i)));
}

sort(all(s));

ll cnt = 0;
ll tmp = 1;
REP(i, N - 1){
  if(s.at(i) == s.at(i + 1)){
    cnt += tmp;
    tmp++;
  }else tmp = 1;

}

print(cnt);
}

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

int main(void)
{
    int n;
    scanf("%d", &n);
    int a[n];
    for (size_t i = 0; i < n; i++)
    {
        scanf("%d", &(a[i]));
    }
    sort(a, a + n);
    int ans_n = a[n - 1];
    int ans_r;
    double t = a[n-1]-a[0];
    for (size_t i = 0; i < n; i++)
    {
        if (t > abs((double)a[i] - (double)ans_n / 2))
        {
            t = abs((double)a[i] - (double)ans_n / 2);
            ans_r = a[i];
        }
    }
    printf("%d %d", ans_n, ans_r);
    return 0;
}

Measured memory_bytes: 640
N = int(input())
L = []
for _ in range(N):
  L.append([list(map(int, input().split())) for _ in range(int(input()))])
for ls in L:
  for l in ls:
    l[0] -= 1
M = 0
for i in range(1<<N):
  A, Normal = [], True
  for j in range(N):
    if (i>>j)&1:
      A.append(j)
  for a in A:
    for l in L[a]:
      if l[0] in A and l[1]==0:
        Normal = False
      if l[1]==1 and l[0] not in A:
        Normal = False
  if Normal:
    M = max(M, len(A))
print(M)

Measured memory_bytes: 9220
import sys
sys.setrecursionlimit(int(1e6))

a, b, x = list(map(int, input().split()))

import math

# 水筒の残りの体積
m = a*a*b - x
# 残りの体積の高さ
n = m / (a*a)

# 水筒の底面が現れる場合とそうでない場合
if n < (b / 2):    
    tan_k = n / (a/2)
else:
    # x = a * (1/2*b*d)
    d = 2 * x / (a * b)
    tan_k = b / d

k_rad = math.atan(tan_k)
ans = k_rad * 180 / math.pi

print(ans)


Measured memory_bytes: 3060
parseInt(x) = parse(Int, x)

function main()
  n = parseInt(readline())
  a = Array{Int}(n)
  for i in 1:n
    a[i] = parseInt(readline())
  end
  mmm = maximum(a)
  sss = sum(a)
  print(sss-+div(mmm,2))
end

main()

Measured memory_bytes: 165596
N,Y = map(int,input().split())

for i in range(0,N+1):
    for j in range(0,N-i+1):
        if 9*i+4*j + N== Y/1000:
            print(str(i)+" "+str(j)+" "+str(N-i-j))
            exit()
        
print("-1 -1 -1")
    

Measured memory_bytes: 2940
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int X = int.Parse(input[1]);
        string[] inputL = Console.ReadLine().Split(' ');
        int[] L = Array.ConvertAll(inputL, int.Parse);
        int ans = 1;
        int c = 0;
        for(int i = 0; i < N; i++)
        {
            c += L[i];
            if(c <= X)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

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

int main() {
  
	long int H, W;
	cin >> H >> W;

	if(H == 1 || W == 1) cout << "1" << endl;
	else if(H % 2 == 0 || W % 2 == 0) cout << (H * W) /2 << endl;
	else cout << (H * W) / 2 + 1 <<endl;

}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

ll a, b, c;

bool read() {
    if (!(cin >> a >> b >> c))
        return false;

    return true;
}

void solve() {
    if (a & b & c & 1) {
        if (a >= b && a >= c)
            cout << b * c << endl;
        else if (b >= a && b >= c)
            cout << a * c << endl;
        else
            cout << a * b << endl;
    } else {
        cout << 0 << endl;
    }
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    srand(time(nullptr));
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



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

using namespace std;

int main() {
 
  int n, m;
  cin >> n >> m;
 
  priority_queue<int> q;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;	
    q.push(p);
  }
  
  while (m > 0) {
    int p = q.top(); q.pop();
    p = p / 2;
    m--;
    q.push(p);
  }
  
  long long sum = 0;
  while (!q.empty()) {
    sum += q.top(); q.pop();
  }
  
  cout << sum;
}

Measured memory_bytes: 892
loop do
a,b,c = gets.split(" ").map(&:to_i)
break if a == 0 && b == 0 && c == 0
n = gets.to_i
# 初期状態はすべての部品が「わからない」(2)
buhins = Array.new(a+b+c) {2} # 部品iの状態がbuhins[i-1]
tests = Array.new(n) {gets.split(" ").map(&:to_i)}

# 正常な部品を検出する
tests.each do |test|
  if test[3] == 1
    0.upto(2) do |i|
      buhins[ test[i]-1 ] = 1
    end
  end
end

# 異常な部品を検出する
tests.each do |test|
  if test[3] == 0
    # 3個中2個の部品が正常なら残り一つが故障
    cnt = 0
    0.upto(2) {|i| cnt += 1 if buhins[ test[i]-1 ] == 1}
    if cnt == 2
      0.upto(2) {|i| if buhins[ test[i]-1 ] == 2 then buhins[test[i]-1]=0;break end}
    end
  end
end

puts buhins
end

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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

const int mod = 1000000007;

int dp[(1 << 21)];
bool calced[1 << 21];
bool a[21][21];
int n;

int calc(int m) {
    if (m == 0)
        return 1;

    if (calced[m])
        return dp[m];

    int num = -1;
    forn(i, n) num += (m & (1 << i)) != 0;

    forn(i, n)
        if (a[num][i] && (m & (1 << i)))
            dp[m] = (dp[m] + calc(m ^ (1 << i))) % mod;
    calced[m] = true;
    return dp[m];
}

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);

    cin >> n;
    forn(i, n) forn(j, n)cin >> a[i][j];

    cout << calc((1 << n) - 1);

    return 0;
}

Measured memory_bytes: 10496
from itertools import product

s = input()
assert all(c in '123456789' for c in s)

def make_string(mask):
    return s[0] + ''.join(('+' if m else '') + c for m, c in zip(mask, s[1:]))

masks = product((0,1), repeat=len(s)-1)
print(sum(eval(make_string(mask)) for mask in masks))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void) {
	char c[4];
	cin >> c;
	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		if (c[i] == 'o') {
			cnt++;
		}
	}
	cout << 700 + cnt * 100 << endl;
	//system("pause");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		
		double S = r * r * Math.PI;
		double L = 2 * r * Math.PI;
		
		System.out.printf("%f %f",S,L);
	}
}

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

using namespace std;

void swap ( vector<int> &v, int i, int j )
{
	int tmp = v[i];
	v[i] = v[j];
	v[j] = tmp;
}

int BubbleSort ( vector<int> &v )
{

	int i,j,count=0;
	for ( i = 0 ; i < v.size()-1 ; i++ )
	{
		for ( j = v.size()-1 ; i < j ; j-- )
		{
			if ( v[j-1] > v[j] )
			{
				swap ( v, j-1, j );
				count++;
			}
		}
	}

	return count;
}

void show ( vector<int> &v )
{
	int i;
	for ( i = 0 ; i < v.size()-1 ; i++ )
	{
		cout << v[i] << " ";
	}
	cout << v[i] << endl;
}

int main ()
{
	vector<int> v;
	int N,n,count;

	cin >> N;

	while ( N-- )
	{
		cin >> n;
		v.push_back ( n );
	}

	count =  BubbleSort ( v );
	
	show ( v );

	cout << count << endl;

return 0;
}


Measured memory_bytes: 3152
#include<stdio.h>
//operation a == doubled
//operation b == increase by b
int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    int result = 1;
    for(int i = 0; i < a; i++){
        if(result < b)//it works if result + b is smaller than doubled
        {
            result = result * 2;
        }
        else//it works if result * 2 is smaller than doubled
        {
            result = result + b;
        }
    }
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, Q, K, A;
    cin >> N >> K >> Q;

    vector<int> P(N,K);
    for(int i = 0; i < Q; i++){
        cin >> A;
        /*
        for(int j = 0; j < P.size(); j++){
            if(j != A - 1){
                P[j]--;
            }
        }
        */
       P[A-1]++;
    }
    for(int i = 0; i < N; i++){
        //if(P[i] > 0){
        if((P[i] - Q) > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if (0 < a) cout << "Positive" << endl;
    else { // a <= b < 0
        int n = b - a + 1;
        if (n % 2 == 1) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
}


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

namespace ARC080
{
    public class C
    {
        private void Run()
        {
            var N = int.Parse(Console.ReadLine().Trim());
            var A = Console.ReadLine().Trim().Split().Select(long.Parse).OrderBy(x => x).ToArray();

            var l = A.Count(x => x % 4 == 0);
            var m = A.Count(x => x % 4 == 2);
            var n = A.Count(x => x % 2 == 1);

            bool can = true;
            if (l + 1 < n) { can = false; }

            if (l + 1 == n && m > 0) { can = false; }

            Console.WriteLine(can ? "Yes" : "No");
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new C().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 26080
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    int a , b , c ; 
    cin >> a >> b >> c ; 
    int t = min(a-b,c) ; 
    cout << c - t << endl;
    return 0 ;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,W = map(int,input().split())
weight = []
val = []
for i in range(n):
    a,b = map(int,input().split())
    weight.append(a)
    val.append(b)
max_v = sum(val) + 10 # 全部使ったとしてもこれ以上の勝ちにはならない
# point : v < =10^3 でn <= 10^2なので、n**2 vでもOK
# wが使えないときには変数を入れ替える
INF = 10**12+7 #Wより大きな値
dp = [[INF]*(max_v+1) for i in range(n+1)]
#初期化は 価値が0になる最小の重さが0なので、dp[i][0] = 0
# 漸化式：dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i])
# i+1　は i番目までの品物を使うとする
# 先にどっちからループを回した方が良い？価値か、品数か
#　品数が全部埋まってから、価値を更新する方が楽そう
for i in range(n+1):
    dp[i][0] = 0
for i in range(n):
    for j in range(max_v+1):
        if j-val[i] >= 0:
            #print("yes")
            dp[i+1][j] = min(dp[i][j],dp[i][j-val[i]]+ weight[i])
        else: dp[i+1][j] = dp[i][j]
    if i == n-1:
        #print("Yes")
        #print(dp[i+1])
        #大きい方から見ていく
        for j in range(max_v,-1,-1):
            #print(j)
            if dp[i+1][j] <= W:
                print(j)
                break


Measured memory_bytes: 119788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long N, long long T, long long A, std::vector<long long> H){
  vector<double> v(N);
  REP(x, N) {
    v.at(x) = T - H.at(x) * 0.006;
  }

  double minDiff = 999999999;
  int minDiffIndex = 0;
  REP(x, N) {
    double diff = abs((double)A - v.at(x));
    if (minDiff > diff) {
      minDiff = diff;
      minDiffIndex = x;
    }
  }

  cout << minDiffIndex + 1 << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long T;
  scanf("%lld",&T);
  long long A;
  scanf("%lld",&A);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&H[i]);
  }
  solve(N, T, A, std::move(H));
}


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

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

  if (A % 500 <= B) {
    cout << "Yes" << endl;
  }

  else{
    cout<<"No"<<endl;
  }
  
  // ここにプログラムを追記
}

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


int main(void){
  cout<<fixed<<setprecision(10);
  long double pi=acos(-1);
  int a,b,x;
  cin>>a>>b>>x;
  long double k, retval;
  if(a*a*b/2<x){
    k=2.0*x/(a*a)-b;
    retval=atan((b-k)/a)*180.0/pi;
  }
  else{
    k=2.0*x/(a*b);
    retval=atan(b/k)*180.0/pi;
  }
  cout<<retval<<endl;
  return 0;
}


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


int main(void)
{
  string  S,T;
  cin >> S >> T;
  unsigned int L = S.size();

  for (unsigned int i = 0;i < L;i++)
  {
    string s;
    for(unsigned int k = 0;k<L;k++)
    {
      s = s + S[(i+k)%(L)];
    }
    if(s == T)
    {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
//#include "unordered_map"
//#include "unordered_set"
#include "iomanip"
#include "cmath"
//#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
const int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;

//const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> K;
	}
	for (int i = 0; i < N; i++)cin >> K;
	cin >> K;
	for (int i = 0; i < K; i++)cout << -1 << endl;
}

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

int main(void){
  double l;
  cin >> l;
  l /= 3;
  double ans = l*l*l;
  printf("%.10f",ans);
  return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

#define LLMAX (1e18)

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);

  rep(i,n) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  if (a[0] == 0) {
    cout << 0 << endl;
    return 0;
  }

  __int128 result = 1;
  rep(i, n) {
    result *= a[i];
    if (result > 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }
  }
  ll res = (ll)result;
  cout << res << endl;
}


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

#define mp make_pair
#define pb push_back 
#define pf push_front 
#define pbp pop_back
#define pfp pop_front 
#define sz(x) x.size()
#define all(x) x.begin(),x.end() 
#define ios_base ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define open(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define F first
#define S second

using namespace std;

typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;

const int mod = 1e9+7;
const int N = 1e5+123;
const int inf = 1e9+123;
const long long INF = 1e18;
const double eps = 1e-5;
ll n, x, ans;

void rec(ll a, ll b){
 if(b % a == 0){
  ans += b/a * (2*a) - a;
  return ;
 }else{
  ans += b/a * (2*a);
  rec(b % a, a);
 }
}

int main (){
 cin >> n >> x;
 rec(x, n-x);
 cout << ans + n;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int n;
int dp[100001];
int res=INF;
int rec(int k){//
  if(dp[k]>=0){
    return dp[k];
  }
  if(k==0){
    return 0;
  }
  int res=n;
  for(int i=1;i<=k;i*=6)res=min(res,rec(k-i)+1);

  for(int j=1;j<=k;j*=9)res=min(res,rec(k-j)+1);
  dp[k]=res;
  return res;
}

int main(){
  cin>>n;
  memset(dp,-1,sizeof(dp));
  for(int i=1;i<=n;i*=6)dp[i]=1;

  for(int j=1;j<=n;j*=9)dp[j]=1;
  dp[0]=0;
  cout<<rec(n)<<endl;
}


Measured memory_bytes: 3712
#include<iostream>

int a[100];

int main()
{
	int n;
	while( std::cin >> n, n )
	{
		for( int i = 0; i != n; ++i )
			std::cin >> a[i];

		int ans = 0;
		for( int i = 0; i != n; ++i )
			for( int j = 0; j != n - i - 1; ++j )
				if( a[j] > a[j+1] )
					std::swap( a[j], a[j+1] ), ++ans;

		std::cout << ans << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#ifdef ONLINE_JUDGE
#define trace(...)
#endif

using LL = long long;

const int N = 2e5;
LL a[N], f[N];

LL check(LL lim, int n) {
	LL res = 0;
	for (int i = 0; i < n; i++) {
		LL xa = lim / f[i];
		res += max(0ll, a[i] - xa);
	}
	return res;
}

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

	int n; LL k; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> f[i];
	}
	sort(a, a + n);
	sort(f, f + n);
	reverse(f, f + n);

	LL lo = 0, hi = 1e16;
	while (lo < hi) {
		LL mid = (lo + hi) / 2;
		if (check(mid, n) <= k) {
			hi = mid;
		} else {
			lo = mid + 1;
		}
	}
	cout << lo << endl;
	
	return 0;
}


Measured memory_bytes: 3328
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    ll n,m,k;
    cin >> n >> m >> k;

    bool ans = false;
    ll cnt = 0;

    for(ll i = 1; i <= n; ++i)
    for(ll j = 0; j <= m; ++j)
    {
        cnt = m * i + j * (n - i) - j * i;
        if(cnt == k)
            ans = true;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

long long Combi::nPk_modp(long long n, long long k, long long p)
{
  ll ans = 1;
  for(long long i = k; i <= n; i++)
  {
    ans = (ans * i) % p;
  }

  return ans;
};


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

namespace program
{
    class Program
    {
        static void Main()
        {
          string a = "abcdefghijklmnopqrstuvwxyz";
          var alp = new Dictionary<char, bool>();
          for(int i=0;i<a.Length;i++) alp.Add(a[i],　false);
          
          var s = Input.ScanStr();
          for(int i=0; i<s.Length; i++)
            alp[s[i]] |= true;
          
          for(int i=0;i<a.Length;i++) {
            if(!alp[a[i]]) { Out(a[i]); return; }
          }
          
          Out("None");
        }
        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    static class Input {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
    }

    static class MyMath {
        public static int DistanceL1(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = Math.Abs(a[i]-b[i]);
            return c.Sum();
        }

        public static double DistanceL2(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = (a[i]-b[i])*(a[i]-b[i]);
            return Math.Sqrt(c.Sum());
        }
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13152
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int a, b, c, x, y;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	a = min(a,c*2);
	b = min(b,c*2);
	int ans = a*x + b*y;
	ans -= max(0, a+b-c*2) * min(x,y);
	writeln(ans);
}

Measured memory_bytes: 380
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    // Your code here!
    int K;
    char S[101] = {}, s[101] = {};
    scanf("%d",&K);
    scanf("%s",S);
    
    int L = strlen(S);
    
    if(L > K)
    {
        strncpy(s,S,K);
        printf("%s...\n",s);
    }
    else
    {
        printf("%s\n",S);
    }
}


Measured memory_bytes: 3764
#include <stdio.h>

int main()
{
  //監視範囲が重ならないような配置は 0*(2d+1)+d+1,(2d+1)+d+1,2(2d+1)+d+1...に
  //一人ずつ配置される状態。だから、上記で配置すると考えて前の項+d内に木があれば＋1
  int n,d;
  scanf("%d%d",&n,&d);
  int i,cnt;
  i = 0;
  cnt = 0;
  while (i*(2*d+1)+d+1 <= n)
  {
    cnt += 1;
    i++;
  }
  //printf("%d\n",i*(2*d+1));
  //printf("%d",i*(2*d+1)+d+1);
  if (n > i*(2*d+1) && n < i*(2*d+1)+d+1)
  {
    printf("%d",cnt+1);
  }
  else
  	printf("%d",cnt);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n;
    cin >> n;
    char c[n];
    rep0(i,n-1) cin >> c[i];
    ll left = 0;
    ll right = n-1;
    ll swap_cnt = 0;
    while(left < right){
        char leftc = c[left];
        char rightc = c[right];
        if(leftc == 'W' && rightc == 'R'){
            swap_cnt++;
            left++;
            right--;
        }else if(leftc == 'R' && rightc == 'R'){
            left++;
        }else if(leftc == 'R' && rightc == 'W'){
            left++;
            right--;
        }else if(leftc == 'W' && rightc == 'W'){
            right--;
        }
    }

    cout << swap_cnt << endl;
    return 0;
}

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

int main(){
    int d;
    cin>>d;
    switch(d){
        case 22:
            cout<<"Christmas Eve Eve Eve"<<endl;
            break;
        case 23:
            cout<<"Christmas Eve Eve"<<endl;
            break;
        case 24:
            cout<<"Christmas Eve"<<endl;
            break;
        case 25:
            cout<<"Christmas"<<endl;
            break;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=0;
    for(int i=0;i<a+1;i++){
        for(int j=0;j<b+1;j++){
            for(int l=0;l<c+1;l++){
                if(i*500+j*100+l*50==k){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll h,w,k;cin>>h>>w>>k;
  vector<string >c(h);
  rep(i,h){
    cin>>c[i];
  }
  ll bla=0;
  rep(i,h){
    rep(j,w){
      if(c[i][j]=='#')bla++;
    }
  }
  ll cnt=bla-k;
  ll ans=0;
  rep(bit1,1LL<<h){
    rep(bit2,1LL<<w){
      ll now=0;
      //cout<<bit1<<" "<<bit2<<endl;
      rep(i,h){
        rep(j,w){
          if(bit(bit1,i)||bit(bit2,j)){
            if(c[i][j]=='#')now++;
          }
        }
      }
      
      if(now==cnt)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t a, b, k;
    cin >> a >> b >> k;
    if(k <= a){
        cout << a - k << " " << b << endl;
    }else if(k <= a+b){
        cout << 0 << " " << b - (k-a) << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define ni(n) scanf("%d", &n)
#define nl(n) scanf("%lld", &n)
#define nai(a,n) for (int i = 0; i < (n); i++) ni((a)[i])
#define nal(a,n) for (int i = 0; i < (n); i++) nl((a)[i])
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
using namespace std;

int main()
{
    int q;
    ni(q);
    for (int i = 0; i < q; i++)
    {
        ll a, b;
        nl(a), nl(b);
        ll ans = 0;
        if (a > b)
            swap(a, b);
        if (a == b)
            ans = 2 * a - 2;
        else if (a + 1 == b)
            ans = 2 * a - 2;
        else
        {
            ll c = floor(sqrt(a * b));
            if (c * c == a * b)
                c--;
            if (c * (c + 1) >= a * b)
                ans = 2 * c - 2;
            else if (c * (c + 1) < a * b)
                ans = 2 * c - 1;
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}

import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad

-- Union-Find
type Parent = VUM.IOVector Int
type Size = VUM.IOVector Int

makeUF :: Int -> IO (Parent, Size)
makeUF n = do
    par <- VU.unsafeThaw $ VU.generate n id
    siz <- VUM.replicate n 1
    return (par, siz)

root :: Int -> Parent -> IO Int
root x par = do
    r <- VUM.read par x
    if x == r
        then return x
        else do
            newr <- root r par
            VUM.write par x newr
            return newr

same :: Int -> Int -> Parent -> IO Bool
same x y par = do
    rx <- root x par
    ry <- root y par
    return $ rx == ry

unite :: Int -> Int -> Parent -> Size -> IO ()
unite x y par siz = do
    x' <- root x par
    y' <- root y par
    sx <- VUM.read siz x'
    sy <- VUM.read siz y'
    unless (x' == y') $ 
        if sx < sy
            then do
                VUM.modify siz (+sx) y'
                VUM.write par x' y'
            else do
                VUM.modify siz (+sy) x'
                VUM.write par y' x'

size :: Int -> Parent -> Size -> IO Int
size x par siz = root x par >>= VUM.read siz
    
main = do
    [n,m,k] <- map read . words <$> getLine :: IO [Int]
    (par, siz) <- makeUF (n+1)
    (cnt :: VUM.IOVector Int) <- VUM.replicate (n+1) 0
    forM_ [1..m] $ \_ -> do
        [a,b] <- map read . words <$> getLine :: IO [Int]
        unite a b par siz
        VUM.modify cnt (+1) a
        VUM.modify cnt (+1) b
    forM_ [1..k] $ \_ -> do
        [c,d] <- map read . words <$> getLine :: IO [Int]
        branch <- same c d par
        when branch $ do
            VUM.modify cnt (+1) c
            VUM.modify cnt (+1) d
        
    forM_ [1..n] $ \i -> do
        s <- size i par siz
        c <- VUM.read cnt i
        putStr $ show (s - c - 1)
        putStr " "
    putStrLn ""

Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

    int n,m;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    cin >> m;
    vector<string> t(m);
    rep(i,m) cin >> t[i];
    
    int ans = 0; int val = 0;
    rep(i,n){
        val = 0;
        val += count(all(s),s[i]);
        val -= count(all(t),s[i]);
        ans = max(ans,val);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n - 1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];
    int count = 0;
    rep(i,n) {
        count += b[a[i] - 1];
        if (i > 0 && a[i] == a[i - 1] + 1) {
                count += c[a[i - 1] - 1];
        } 
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256