akhauriyash/Code-Regression huggingface dataset:
q, h, s, d = gets.split().map(&:to_i)
n = gets.to_i
q1 = q * 4
h1 = h * 2

min2 = q1 * 2
if min2 > (h1*2)
  min2 = h1 * 2
end
if min2 > (s*2)
  min2 = s * 2
end
if min2 > d
  min2 = d
end
min1 = q1
if min1 > h1
  min1 = h1
end
if min1 > s
  min1 = s
end


m = 0
if n >= 2
  m = min2 * (n / 2)
end
if n % 2 == 1
  m += min1
end
puts m


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(ull (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

ull root(vector<ull> &p, ull i){
    // DEBUG{cout << "i : " << i << "p[i-1] : " << p[i-1] << endl;}
    if(p[i]==i)return i;
    p[i]=root(p,p[i]);
    return p[i];
}

int main(void) {
    ull n,m,e1,e2;
    cin >> n >> m;
    vector<pair<ull, ull> > e;
    vector<ull> cnt(n,1);
    vector<ull> res(m,0);
    vector<ull> parents;
    rep(i,m){
        // pair<ull, ull> tmp;
        // tmp = pair<ull, ull>();
        cin >> e1 >> e2;
        // DEBUG{printf("(%llu %llu)",e1,e2);}
        // scanf("%d %d\n", &e[i].first, &e[i].second);
        // cin >> e[i].first >> e[i].second;
        e.push_back(make_pair(e1,e2));
    }
    DEBUG{
        rep(i,m){
            printf("(%llu %llu)\n",e.at(i).first, e[i].second);
        }
    }
    rep(i,n){
        parents.push_back(i);
    }
    // DEBUG {printf("test\n");}
    ull mm = (n*(n-1))/2;
    DEBUG {cout << "mm=" << mm << endl;}
    rep(i,m){
        pair<ull, ull> tmp; 
        // ull tmp_first = e[m-i-2].first, tmp_second=e[m-i-2].second;
        // DEBUG {printf("tmp : (%llu, %llu)\n",tmp.first,tmp.second);}
        // DEBUG {printf("e : (%d, %d)\n",e[i].first,e[i].second);}

        if(i==0){
            DEBUG{cout << "i=0" << endl;}
            // colors[tmp.first]=cnt;
            // colors[tmp.second]=cnt;
            res[i]=mm;
            continue;
        }
        tmp = e[m-i];
        ull pf=root(parents,tmp.first-1),ps=root(parents,tmp.second-1);
        if(pf!=ps){
            // DEBUG{printf("union : %llu %llu",tmp.first, tmp.second);}
            

            ull a = cnt[pf]*cnt[ps];
            parents[pf]=ps;
            cnt[ps]+=cnt[pf];
            res[i]=res[i-1]-a;
            // change_parent(parents, children, tmp.first, tmp.second);
        }else{
            res[i]=res[i-1];
        }
        // cnt++;
    }
    DEBUG{cout << "roop out" << endl;}
    rep(i,m){
        cout << res[m-i-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N, Q, a, b, c, s = 0;
    cin >> N;
    ll M = 1e5+1;
    vector<ll> ns(M);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        ns[a]++;
        s += a;
    }
    cin >> Q;
    vector<ll> ans(Q);
    for ( int i = 0; i < Q; i++ ) {
        cin >> b >> c;
        s += (c-b)*ns[b];
        ns[c] += ns[b];
        ns[b] = 0;
        ans[i] = s;
    }
    for ( int i = 0; i < Q; i++ ) {
        cout << ans[i] << "\n";
    }
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
 
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if((c - b) == (b - a)) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
#define INF 1000000007



int main()
{
	ll n,i,j,k;
	cin>>n>>k;
	ll arr[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	ll dp[n+1];
	for(i=1;i<=n;i++)
	{
		dp[i]=INF;
	}
	dp[1] = 0;

	for(i=2;i<=n;i++)
	{
		/*if(i==2)
		{
			dp[i] = min(dp[i],dp[1] + abs(arr[i]-arr[1]));
		}
		else{*/
		ll s =1;
		ll l = max(i-k,s);
		for(j=i-1;j>=l;j--)
		{
			dp[i] = min(dp[i],dp[j] + abs(arr[i] - arr[j]));
		}
	//}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

const ll INF=LLONG_MAX/2;
 
ll f(ll b, ll n){
  if(b<2) return INF;
  ll res=0;
  while(n>=b){
    res+=n%b;
    n/=b;
  }
  res+=n;
  return res;
}
 
int main(){
  ll n,s;
  cin>>n>>s;
  if(n<s){
    cout<<-1<<endl;
    return 0;
  }
  if(n==s){
    cout<<n+1<<endl;
    return 0;
  }
  ll ans=INF;
  for(ll i=2;i*i<=n;i++){
    ll tmp=f(i,n);
    if(tmp==s){
      ans=min(ans,i);
    }
  }
  for(ll i=1;i*i<n;i++){
    ll b=(n-s)/i+1;
    ll tmp=f(b,n);
    if(tmp==s){
      ans=min(ans,b);
    }
  }
  if(ans==INF) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
ll inf=1000000007;

int main()
{
    ll n, k, i, j, l, m;
    cin>>n>>k;
    ll sum=0, tem;
    int a[n];
    //for(i=0;i<n;i++) a[i]=i;
    for(i=k;i<=n;i++)
    {
        j=i-1;
        l=j*(j+1)/2;
        j=j+1;
        m=(n*(n+1)/2);
        tem=((n-j)*(n-j+1)/2);
        m=m-tem;
        //cout<<l<<" "<<m<<endl;
        //if(sum<0) break;
        sum=sum+m-l+1;
    }
    cout<<(sum+1)%inf<<endl;
    return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long ans;
	int N,K;
	int v[200005];
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%d",&v[i]);
	}
	sort(v,v+N);
  	reverse(v,v+N);
	for(int i=K;i<N;i++) ans+=v[i];
  	cout<<ans<<endl;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	ans := 0
	switch {
	case n == 1 && m == 1:
		ans = 1
	case n == 1:
		ans = m - 2
	case m == 1:
		ans = n - 2
	default:
		ans = (n - 2) * (m - 2)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

class Main {
	public static void main(String[] argv){
		Scanner in = new Scanner(System.in);
		System.out.println( IntStream.rangeClosed(1, 3).mapToObj(i->in.nextInt()).sorted().map(i->""+i).collect(Collectors.joining(" ")));
	}
}

Measured memory_bytes: 32536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int n, m, a = 0, b = 0, c = 0;
		
		while(!(string = reader.readLine()).equals("0")){
			n = Integer.valueOf(string);
			m = Integer.valueOf(reader.readLine());
			
			int map[][] = new int[n][n];
			boolean visit[] = new boolean[n];
			for(int i = 0;i < n; i++) Arrays.fill(map[i], 1 << 29);
			for(int i = 0; i < m; i++){
				string = reader.readLine();
				a = Integer.valueOf(string.split(",")[0]);
				b = Integer.valueOf(string.split(",")[1]);
				c = (Integer.valueOf(string.split(",")[2]) - 100) / 100;
				map[a][b] = map[b][a] = c;
			}
			c = 0;
			visit[0] = true;
			for(int x = 0; x < n - 1; x++){
				m = 1 << 29;
				for(int i = 0; i < n; i++){
					if(map[0][i] < m && !visit[i]){
						m = map[0][i];
						b = i;
					}
				}
				visit[b] = true;
				c += map[0][b];
				for(int i = 0; i < n; i++){
					map[0][i] = Math.min(map[0][i], map[b][i]);
				};
			}
			System.out.println(c);
		}
		reader.close();
	}
}

Measured memory_bytes: 35320
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    
    for(int i=1; i<=n; i++){
        if(i * 108 / 100 == n){
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n),b(n);
    rep(i,0,n) cin>>a[i];
    int cnt = 0;
    repp(i,n-1,0){
        int num = 0;
        for (int j=(i+1)*2;j<n+1;j+=i+1){
            if (b[j-1]==1) num++;
        }
        if (num%2==1){
            if (a[i]==0) b[i] = 1,cnt++;
        }else{
            if (a[i]==1) b[i] = 1,cnt++;;
        }
    }
    cout<<cnt<<endl;
    rep(i,0,n){
        if (b[i]==1) cout<<i+1<<endl;
    }
}

Measured memory_bytes: 4796
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, D, x, y;
  cin >> N >> D;
  int cnt = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> x >> y;
    if (sqrt(pow(x, 2) + pow(y, 2)) <= D)
    {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, H, X, Y;
	cin >> W >> H >> X >> Y;
	int res = 0;

	if (X * 2 == W && 2 * Y == H) {
		res = 1;
	}

	cout << fixed << setprecision(15) << (W*H / 2.0) << " " << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		if (s.equals("hi")
				|| s.equals("hihi")
				|| s.equals("hihihi")
				|| s.equals("hihihihi")
				|| s.equals("hihihihihi")
				) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}
import scala.util.Random
import java.util.Date

object Main extends App {
  val startTime = new Date().getTime // to milli seconds

  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val D = in.next().toInt
  val c = new Array[Long](26+1)
  val s = Array.ofDim[Long](D+1, 26+1)

  for (i <- 1 to 26) {
    c(i) = in.next().toInt
  }
  for (d <- 1 to D) {
    for (i <- 1 to 26) {
      s(d)(i) = in.next().toInt
    }
  }


  /** functions **/
  def calcScore(t: Array[Int]): Long = {
    val last = new Array[Int](26+1)
    var res = 0L

    for (d <- 1 to D) {
      val ty = t(d)

      res += s(d)(ty)
      last(ty) = d

      for (i <- 1 to 26) {
        res -= c(i) * (d - last(i))
      }
    }

    res
  }


  /** solve **/
  val t = new Array[Int](D+1)
  val last = new Array[Int](26+1)
  for (d <- 1 to D) {
    val (_, ty) =
      s(d).zipWithIndex
        .drop(1)
        .map{ case (s, ty) => (s + c(ty) * (d - last(ty)), ty) }
        .max

    t(d) = ty
    last(ty) = d
  }

  val endTime = 1400
  var currentScore = calcScore(t)
  var bestAns = t.clone
  var bestScore =  currentScore

  val annStartTime = new Date().getTime
  var currentTime = annStartTime

  val T = endTime - annStartTime // 焼きなましにかける時間
  val R = 10000

  while ((new Date().getTime - startTime) < endTime) {
    for (_ <- 1 to 1000) {
      val time = currentTime - annStartTime // 焼きなまし法開始からの時間

      // 遷移を実施
      val d = Random.nextInt(D) + 1
      val ty = Random.nextInt(26) + 1

      val tmp = t(d)
      t(d) = ty

      val nextScore = calcScore(t) // 遷移後のスコアを計算

      // スコアが悪くなったときでも、次の状態に移動する遷移する場合はtrue。
      val ForceNext = T * Random.nextInt(R) < (T-time) * R // １次関数
      
      if (nextScore > currentScore || ForceNext) {
        // 遷移を適用
        currentScore = nextScore
      }
      else {
        // 遷移を破棄
        t(d) = tmp
      }

      // ベストスコアを保存
      if (currentScore > bestScore) {
        bestScore = currentScore
        bestAns = t.clone // 現在の盤面を渡す
      }
    }
  }

  val last2 = new Array[Int](26+1)
  for (d <- 1 to D) {
    if (d == D) {
      val (_, ty) =
        s(d).zipWithIndex
          .drop(1)
          .map{ case (s, ty) => (s + c(ty) * (d - last2(ty)), ty) }
          .max

      t(d) = ty
    }
    else {
      last2(t(d)) = d
    }
  }


  for (d <- 1 to D) {
    pw.println(t(d))
  }
  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 57280
import numpy as np
from numba import njit

n = int(input())


@njit
def f(n):
    cnt = np.zeros(n + 1, np.int16)
    for i in range(1, n + 1):
        cnt[i::i] += 1

    return (cnt * np.arange(n + 1)).sum()


ans = f(n)
print(ans)


Measured memory_bytes: 302320
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tgmath.h>
#include <unordered_map>
#include <vector>

using namespace std;

typedef uint16_t ui16;
typedef uint32_t ui32;
typedef uint64_t ui64;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef long double ld;
typedef pair<int, int> pr;

//template<typename T> inline T abs(T a) { return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a) { return a * a; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) {for (int i = 0; i < v.size(); ++i) cout << v[i] << " "; cout << endl; return cout; }
void print() { cout << endl; }
template<typename T, typename... Ts> void print(T x, Ts... xs) { cout << x << " "; print(xs...); };
template<typename T> void read(vector<T>& v) { for (int i = 0; i < v.size(); ++i) cin >> v[i]; };

int main() {
    int N;
    cin >> N;
    vector<double> p(N + 1, 0.0);
    for (int i = 0; i < N; ++i) {
        cin >> p[i + 1];
    }

    vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0.0));
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (j == 0) {
                dp[i][j] = 1.0;
            } else if (i == 0) {
                dp[i][j] = 0.0;
            } else {
                dp[i][j] = (1.0 - p[i])*dp[i - 1][j] + p[i]*dp[i - 1][j - 1];
            }
        }
    }

    cout << fixed << setprecision(10) << dp[N][N / 2 + 1] << endl;

    return 0;
}


Measured memory_bytes: 70784
NC = input()
N,C = NC.split()
N = int(N)
C = int(C)

mod2 = []
mod0 = []
mod1 = []
colormap = []


for n in range(C):
    row = input()
    col = row.split()
    for m in range(len(col)):
        col[m] = int(col[m])
    colormap.append(col)

for i in range(N):
    row = input()
    col = row.split()
    for j in range(len(col)):
        if (i+j)%3 == 0:
            mod2.append(int(col[j])-1)
        elif (i+j)%3 == 1:
            mod0.append(int(col[j])-1)
        else:
            mod1.append(int(col[j])-1)

colorscore = []
for c in range(C):
    s2 = 0
    s0 = 0
    s1 = 0
    for i in mod2:
        s2 += colormap[i][c]
    for i in mod0:
        s0 += colormap[i][c]
    for i in mod1:
        s1 += colormap[i][c]
    colorscore.append([s2,s0,s1])

score = []
l =  len(colorscore)
for i in range(l):
    tempj = []
    for j in range(l):
        tempk = []
        for k in range(l):
            if  k == j or k == i:
                tempk.append(float("inf"))
            else:tempk.append(colorscore[j][1] + colorscore[k][2])
        tempk = min(tempk)
        if j == i:
            tempj.append(float("inf"))
        else:tempj.append(colorscore[i][0] + tempk)
    tempj = min(tempj)
    score.append(tempj)

print(min(score))

Measured memory_bytes: 5256
#include <iostream>
using namespace std;
 
int main(){
    int n,k;
    cin >> n >> k;
    int A[10] = {0};
    for(int i=0;i<k;i++){
        int a; cin >> a; A[a] = 1;
    }
    
    for(int i=n;i<10*n;i++){
        int sub = i;
        while(A[sub%10] == 0 && sub != 0) sub /= 10;
        if(sub==0){
            cout << i ;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{   int n,m;
    scanf("%d%d",&n,&m);
    char a[n][n+1],b[m][m+1];
    int k[n][n+1],l[m][m+1];
    for(int i=0;i<n;i++){
        scanf("%s",&a[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%s",&b[i]);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i][j]=='#'){
                k[i][j]=1;
            }else{
                k[i][j]=0;
            }
            //printf("%d",k[i][j]);
        }
        //printf("\n");
    }
    
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            if(b[i][j]=='#'){
                l[i][j]=1;
            }else{
                l[i][j]=0;
            }
             //printf("%d",l[i][j]);
        }
        //printf("\n");
    }
    
    for(int i=0;i<n-m+1;i++){
        for(int j=0;j<n-m+1;j++){
            int check=0;
            for(int x=0;x<m;x++){
                for(int y=0;y<m;y++){
                    if(k[i+x][j+y]==l[x][y]){
                        check++;
                        //printf("check increment at k[%d][%d]",i+x,j+y);
                    }
                }
            }
            if(check==m*m){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    result = n/2;
    if(n%2)
        result++;
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
 
using namespace std;
 
int main(){
int x=0,y=0,z;
int K,S,ans=0;
cin >> K >> S;
for(x=0;x<=K;x++){
for(y=0;y<=K;y++){
if((S-x-y>=0) &&(S-x-y<=K))ans++;
}
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
cnt = 0
max = int(10e5+1)
l = [0] * (max+1)
for n in A:
    if l[n] != 0:
        l[n] = 2
        continue
    for j in range(n, max+1, n):
        l[j] += 1
for n in A:
    if l[n] == 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 32336
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int K = GetInt();
		long cnt = 0;
		for(int a = 1; a <= K; a++)
		{
			for(int b = 1; b <= K; b++)
			{
				for(int c = 1; c <= K; c++)
					cnt += (long)gcd(a, gcd(b, c));
			}
		}
		WriteLine(cnt);
	}

	private int gcd(int x, int y) => (y == 0) ? x : gcd(y, x % y);
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 27476
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define REP(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 1;
  for (int i = m / n; i >= 2; i--) {
    if (m / i < n)
      break;
    else if (m % i == 0) {
      ans *= i;
      m /= i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    count = 0


    for i in a:
        if i % 2 ==0:
            if i % 3 == 0 or i % 5 ==0:
                count = count
            else:
                count = count +1
    if count > 0:
        print("DENIED")
    else:
        print("APPROVED")




Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner in = new Scanner(System.in);

		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}

}



Measured memory_bytes: 26268
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    dp = [0] * N
    for i in range(1, N):
        if i == 1:
            dp[i] = abs(H[i] - H[i-1])
        else:
            dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 52208
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 5000 + 10;

int N;
long long H[MAXN], P[MAXN];
long long DP[MAXN];

void Work()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i ++)
		scanf("%lld%lld", &H[i], &P[i]);

	for (int i = 1; i <= N; i ++)
		for (int j = 1; j <= N; j ++)
			if (P[i] + H[i] < P[j] + H[j] || (P[i] + H[i] == P[j] + H[j] && H[i] < H[j]))
			{
				swap(H[i], H[j]);
				swap(P[i], P[j]);
			}
	
	memset(DP, 10, sizeof(DP));
	long long INF = DP[0];
	DP[0] = 0;
	for (int i = 1; i <= N; i ++)
	{
		for (int j = i - 1; j >= 0; j --)
		{
			if (DP[j] <= H[i])
				DP[j + 1] = min(DP[j + 1], DP[j] + P[i]);
		}
	}
	for (int j = N; j >= 0; j --)
	{
		if (DP[j] != INF)
		{
			printf("%d\n", j);
			break;
		}
	}
}

int main()
{
	Work();
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	int n, m, a;
	while(cin >> n >> m >> a, n|m|a) {
		vector<pair<int, pair<int, int> > > ppi;
		REP(i, m) {
			int in[3];
			REP(j, 3) cin >> in[j];
			ppi.push_back(make_pair(in[0], make_pair(in[1], in[2])));
			sort(ppi.begin(), ppi.end());
			reverse(ppi.begin(), ppi.end());
		}
		int ans = a;
		int now = INF;
		REP(i, ppi.size()) {
			if(ppi[i].first == now) continue;
			if(ppi[i].second.first == ans) {
				ans = ppi[i].second.second;
				now = ppi[i].first;
			}
			else if(ppi[i].second.second == ans) {
				ans = ppi[i].second.first;
				now = ppi[i].first;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
S=input()
flag=0

for i in range(len(S)):
    if i%2==0 and (S[i]== "R"or S[i]== "U" or S[i]== "D") :
        #print("first")
        #print(S[i])
        pass
    elif i%2!=0 and (S[i]== "L"or S[i]== "U"or S[i]== "D") :
        #print("second")
        #print(S[i])
        pass
    else:
        flag=1
        #print(i)

if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100;
vector <int> g[N];
ll a[N],b[N];
ll vis[N];
ll par[N];
vector <int> mol[N];
set <pii> s[N];
ll val[N];
queue <pii> q;
void mrg(ll u,ll v){
    if (mol[u].size()<mol[v].size()) swap(u,v);
    if (mol[u].size()==1){
        for (auto y : g[u]) q.push({y,u});
    }
    for (auto y : mol[v]){
        for (auto t : g[y]){
            q.push({y,t});
        }
        mol[u].pb(y);
        par[y]=u;
        val[u]+=b[y];
    }
    while (s[u].size() && s[u].begin()->F<=val[u]){
        q.push({u,s[u].begin()->S});
        s[u].erase(s[u].begin());
    }
    return ;
}
int32_t main(){
    sync;
    ll n,m;
    cin >> n >> m;
    for (int i=1;i<=n;i++){
        cin >> a[i] >> b[i];
    }
    for (int i=1;i<=m;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    if (n==1){
        cout << max(a[1],b[1]) << endl;
        return 0;
    }
    ll l=-1,r=(ll)1e9+10;
    while(r-l>1){
        ll mid=(r+l)/2;
        for (int i=1;i<=n;i++){
            s[i].clear();
            par[i]=i;
            mol[i].clear();
            mol[i].pb(i);
            val[i]=b[i]+mid;
            if (b[i]+mid<a[i]) val[i]=-1;
        }
        for (int i=1;i<=n;i++) for (auto u : g[i]) q.push({i,u});
        while(q.size()){
            ll v=q.front().F,u=q.front().S;
            q.pop();
            if (par[u]==par[v]) continue;
            ll u1=par[u],v1=par[v];
            if (val[u1]==-1 && val[v1]==-1){
                continue;
            }
            if (val[u1]==-1){
                if (val[v1]>=a[u1]-b[u1]){
                    val[u1]=b[u1]+mid;
                    mrg(v1,u1);
                }
                else{
                    s[v1].insert({a[u1]-b[u1],u1});
                }
                continue;
            }
            if (val[v1]==-1){
                if (val[u1]>=a[v1]-b[v1]){
                    val[v1]=b[v1]+mid;
                    mrg(u1,v1);
                }
                else{
                    s[u1].insert({a[v1]-b[v1],v1});
                }
                continue;
            }
            mrg(u1,v1);
        }
        ll p1=0;
        
        for (int i=1;i<=n;i++){
            if (mol[i].size()==n) p1=1;
            if (par[i]==i && val[i]==-1){
                for (auto u : g[i]){
                    ll z=par[u];
                    if (val[z]>=a[i]-b[i]) cout << 1/0;
                }
            }
            else if (mol[par[i]].size()!=n){
                for (auto u : g[i]){
                    ll z=par[u];
                    if (val[z]!=-1 && z!=par[i]) cout << 1/0;
                }
            }
        }
        if (p1) r=mid;
        else l=mid;
    }
    for (int i=1;i<=n;i++) r+=b[i];
    cout << r << endl;

}


Measured memory_bytes: 63572
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;

int main() {
  int a, b;
  while (cin >> a >> b) {
    int d = b - a;
    int res = -1;
    for (int i = 1; i <= 999; i++) {
      for (int j = 1; j <= 999; j++) {
        int A = i * (i + 1) / 2;
        int B = j * (j + 1) / 2;
        if (A > a && B > b && B - A == d) {
          res = A - a;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

line = input()
sA, sB = line.split()
A = int(sA)
B = int(sB)
if A == 1:
    A = 14
if B == 1:
    B = 14
if A == B:
    print('Draw')
elif A > B:
    print('Alice')
else:
    print('Bob')
    
    


Measured memory_bytes: 2940
function main(input){
  input = input.trim();
  let list = input.split("");
  let answer = 0;
  for(let i=0; i<list.length; i++){
    if(list[i]==="R"){
      if(answer===0){answer++;
      }else if(list[i-1]==="R"){
        answer++;
      }                 
    }
  }
  console.log(answer);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29536
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  input()
  s = input().strip()
  prev = s[:len(s) // 2]
  post = s[len(s) // 2:]

  if prev == post:
    print('Yes')
  else:
    print('No')


if __name__ == '__main__':
  main()


Measured memory_bytes: 38384
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#define U ((1<<n)-1)
using namespace std;

const int N = 16;
int a[N+2][N+2];
int cost[(1<<N)+2];
int dp[(1<<N)+2][N+2];
int n,m;

void update(int &x,int y) {x = max(x,y);}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; i++)
	{
		int x,y,z; scanf("%d%d%d",&x,&y,&z); x--; y--;
		a[x][y] = a[y][x] = z;
	}
	for(int i=0; i<=U; i++)
	{
		cost[i] = 0;
		for(int j=0; j<n; j++)
		{
			if((i&(1<<j))==0) continue;
			for(int k=j+1; k<n; k++)
			{
				if((i&(1<<k))==0) continue;
				cost[i] += a[j][k];
			}
		}
	}
	memset(dp,-1,sizeof(dp));
	dp[1][0] = 0;
	for(int i=1; i<=U; i+=2)
	{
		for(int j=0; j<n; j++)
		{
			if(dp[i][j]==-1) continue;
			if((i&(1<<j))==0) continue;
			for(int k=0; k<n; k++)
			{
				if(a[j][k]==0) continue;
				if(i&(1<<k)) continue;
				update(dp[i|(1<<k)][k],dp[i][j]+a[j][k]);
			}
			int c = (U-i)|(1<<j);
			for(int k=c; k>=0; k=(k==0 ? -1 : (k-1)&c))
			{
				update(dp[i|k][j],dp[i][j]+cost[k]);
			}
		}
	}
	int ans = 0;
	for(int i=(U>>1)+2; i<=U; i+=2) ans = max(ans,dp[i][n-1]);
	printf("%d\n",cost[U]-ans);
	return 0;
}

Measured memory_bytes: 4864
#include <algorithm>
#include <iostream>
#include <stdio.h>

#define MAX_N 200'000

using namespace std;

int A[MAX_N];

int main() {
  int N;
  cin >> N;
  int x, y;
  cin >> x >> y;
  A[0] = x;
  A[1] = y;
  if (x < y) {
    swap(x, y);
  }
  for (int i = 2; i < N; ++i) {
    cin >> A[i];
    if (x <= A[i]) {
      y = x;
      x = A[i];
    } else if (y < A[i]) {
      y = A[i];
    }
  }
  if (x == y) {
    for (int i = 0; i < N; ++i) {
      printf("%d\n", x);
    }
  } else {
    for (int i = 0; i < N; ++i) {
      if (A[i] == x) {
        printf("%d\n", y);
      } else {
        printf("%d\n", x);
      }
    }
  }
}

Measured memory_bytes: 4004
def main():
    x, y = map(int, input().split())
    A = abs(abs(x) - abs(y))

    if x * y > 0:
        if x < y:
            B = 0
        else:
            B = 2
    elif x == 0:
        if x < y:
            B = 0
        else:
            B = 1
    elif y == 0:
        if x < y:
            B = 0
        else:
            B = 1
    else:
        B = 1

    print(A + B)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9132
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

# 負の数
nega = []
# 正の数
posi = []
# 0のカウンタ
zeros = 0

# Aの数をnega, posiに分配 & 0の数を数える
A.each do |ai|
  if ai < 0
    nega << ai
  elsif ai > 0
    posi << ai
  else
    zeros += 1
  end
end

# 正の数は昇順にソート
posi.sort!
# 負の数は降順にソート
nega.sort!.reverse!

# A_iの値の制約の最小値（最大値）同士の積よりわずかに小さい（大きい）値を設定する
ng = -(10 ** 18) - 1
ok = 10 ** 18 + 1

# 二分探索で「積がx以下になるペアの総数が、k以上であるようなxの最小値」を求める
while ok - ng > 1
  mid = (ok + ng) / 2
  cnt = 0

  if mid >= 0
    # 積が0になるペア数を加算
    # (0同士のペア + 0と0でない数のペア)
    cnt += zeros * (zeros - 1) / 2 + zeros * (N - zeros)
  end

  if mid > 0
    # 何もわからない
    cnt += nega.size * posi.size

    [posi, nega].each do |a|
      l = 0
      r = a.size - 1
      while l < r
        while l < r && a[l] * a[r] > mid
          r -= 1
        end
        cnt += r - l
        l += 1
      end
    end
  else
    r = nega.size - 1
    0.upto(posi.size - 1) do |l|
      while r >= 0 && posi[l] * nega[r] <= mid
        r -= 1
      end
      cnt += nega.size - r - 1
    end
  end

  if cnt >= K
    ok = mid
  else
    ng = mid
  end
end
puts ok

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

int main(){
  int N, D, X;
  cin >> N >> D >> X;
  int ans = X;
  int A[N];
  rep(i, N){
    cin >> A[i];
    ans += (A[i]+D-1)/A[i];
  }
  cout << ans << endl;
  
}

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

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

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> a(n), t(n);
  rep(i, n) cin >> a[i];

  for (int i = k; i < n; ++i) {
    cout << (a[i - k] < a[i] ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 6424
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    int K = sc.nextInt();
	    int[] as = new int[N];
	    boolean[] Rs = new boolean[K+1];

	    for(int i=0; i<N; ++i) {
            as[i] = sc.nextInt();
        }

	    // Rs[0] false 임으로 Taro가 이기는 경우 입니다.
        for(int i=1; i<=K; ++i) {
            boolean bRi = false;
            for(int j=0; j<N && (bRi == false); ++j) {
                boolean tRi = false;
                int r = i - as[j];
                if(r < 0) {
                    tRi = false;
                }
                else {
                    tRi = !Rs[r];
                }
                bRi = (bRi | tRi);
            }
            Rs[i] = bRi;
        }

        System.out.println(Rs[K]? "First": "Second");
    }
}


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

int main(){
    int Distance[5];
    for(int i=0;i<5;i++){
        cin >> Distance[i];
    }
    int K; cin >> K;
    bool flg;
    for(int i=1;i<5;i++){
        flg=true;
        for(int j=0;j<i;j++){
            if(Distance[i]-Distance[j]>K){
                flg=false;
                break;
            }
        }
    }
    if(flg==true){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, X, D, ans;
  cin >> N >> X;
  D = 0;
  ans = 1;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  for(int i=0;i<N;i++){
    D += L.at(i);
    if(D > X) break;
    else ans++;
  }
  cout << ans <<endl;
}


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

int InterRating(int x, int y){
    if(x<10){
        return y+100*(10-x);
    }else{
        return y;
    }
}

int main(){
    int N,R; cin >> N >> R;
    cout << InterRating(N,R) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
  string str; 
  size_t len;

  cin >> str;
  len = str.length();
  
  if(len == 2) {
    cout << str << endl;
   } else if ( len == 3 ) {
    reverse(str.begin(),str.end());
    cout << str << endl;
   }

  return 0;
}
  


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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

const int N = 1e5 + 10;

int main()
{
	#ifdef LOCAL_TEST
	freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#endif
	int n;
	cin>>n;
	string s;
	cin>>s;
	int c1 = 0,c2 = 0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')c1++;
		else c2++;
	}

	if(c1>c2)cout << "Yes\n";
	else cout << "No\n";
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    char c; cin >> c;
    int x = c - 'A';
    if (0<=x && x<=25) cout << 'A';
    else cout << 'a';
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

int main()
{
    ll A;
    string shousuu;
    cin >> A >> shousuu;
    ll n;
    n=(shousuu[0]-'0')*100+(shousuu[2]-'0')*10+shousuu[3]-'0';
    cout << A*n/100 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
    using namespace std;
    void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
   }

    int main()
    {   init();
        int s,w;
        cin>>s>>w;
        if(w>=s)cout<<"unsafe";
        else cout<<"safe";
    }


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

ll oddsolve(ll a) {return (a + 1) / 2 % 2;}
ll solve(ll a) {
    if (a % 2 == 1) return oddsolve(a);
    else return oddsolve(a + 1) ^ (a + 1);
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll a, b;
    cin >> a >> b;
    cout << (solve(b) ^ solve(a - 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2010;
bitset<N*N> f;
int n;
int main(){
	scanf("%d",&n);
	f[0]=1;
	for (int i=1,x;i<=n;++i){
		scanf("%d",&x);
		f|=f<<x;
	}
	int k=f.count()/2;
	int x=0;
	for (int i=1;i<=k;++i){
		++x;
		while (!f[x]) ++x;
	}
	printf("%d",x);
	return 0;
}


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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;

  int r = 0, w = 0, swap = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'W') {
      ++w;
    } else {
      ++r;
    }
  }
  int ans = min(r, w);

  for (int i = 0; i < r; ++i) {
    if (s[i] == 'W') {
      ++swap;
    }
  }
  ans = min(ans, swap);

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
const int INF=1e9+5;
int main()
{
    int n;
    cin>>n;
    vector<int> dp(3);
    for(int day=0;day<n;day++)
    {
        vector<int> new_dp(3,0 );
        vector<int> c(3);
        for(int i=0;i<3;i++)
        {
            cin>>c[i];
        }

        for(int i=0;i<3;++i)
        {
            for(int j=0;j<3;j++)
            {
                if(i!=j)
                {
                    new_dp[j]=max(new_dp[j],dp[i]+c[j]);
                }
            }
        }
        dp=new_dp;
    }
    cout<<max({dp[0],dp[1],dp[2]}) ;
	return 0;
}


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

const int mod = 1e9 + 7;

signed main () {
	int n, m;
	cin >> n >> m;
	vector < int > s(n), t(m);
	for (int &x: s)
		cin >> x;
	for (int &x: t)
		cin >> x;
	vector < vector < int > > dp(n + 1, vector < int > (m + 1, 0));
	for (int i = 0; i <= n; ++i)
		dp[i][0] = 1;
	for (int i = 0; i <= m; ++i)
		dp[0][i] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
			if (s[i - 1] != t[j - 1])
				dp[i][j] = (dp[i][j] + mod - dp[i - 1][j - 1]) % mod;
		}
	}
	cout << dp[n][m] << '\n';
}


Measured memory_bytes: 16000
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean[][] b = new boolean[h][w];
        int[][] d = new int[h][w];
        int MAX = 10000;
        int bw = 0;
        for(int i=0; i<h; i++) {
            String line = sc.next();
            for(int j=0; j<w; j++) {
                b[i][j] = line.charAt(j) == '.';
                if(b[i][j]) bw++;
                d[i][j] = 10000;
            }
        }

        d[0][0] = 1;
        LinkedList<P> q = new LinkedList<>();
        q.push(new P(0, 0));

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

        while(!q.isEmpty()){
            P p = q.poll();
            for(int i=0; i<4; i++) {
                int nx = p.x + dx[i];
                int ny = p.y + dy[i];
                if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if(d[nx][ny] < MAX || !b[nx][ny]) continue;
                d[nx][ny] = d[p.x][p.y] + 1;
                q.offer(new P(nx, ny));
            }
        }
        System.out.println( d[h-1][w-1] < MAX ? bw -  d[h-1][w-1] : -1);
    }

    static class P {
        public int x;
        public int y;
        public P(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}


Measured memory_bytes: 23508
w, h, n = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
s, t = [0, w], [0, h]
for i in range(n):
    x = p[i][0]
    y = p[i][1]
    a = p[i][2]
    if a == 1:
        if x <= s[0]:
            continue
        elif s[0] < x < s[1]:
            s[0] = x
        else:
            print(0)
            exit()
    elif a == 2:
        if x <= s[0]:
            print(0)
            exit()
        elif s[0] < x < s[1]:
            s[1] = x
        else:
            continue
    elif a == 3:
        if y <= t[0]:
            continue
        elif t[0] < y < t[1]:
            t[0] = y
        else:
            print(0)
            exit()
    else:
        if y <= t[0]:
            print(0)
            exit()
        elif t[0] < y < t[1]:
            t[1] = y
        else:
            continue

print((s[1]-s[0])*(t[1]-t[0]))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323

int main() 
{
    FAST;
    string s;
    ll n;
    cin>>s;
    n=s.length();
    ll pr[2019],ar[2019];
    ll ans=0;
    for(int i=0;i<2019;i++)
        pr[i]=0;
    pr[s[0]-'0']++;
    for(int p=1;p<n;p++)
    {
        for(int i=0;i<2019;i++)
            ar[i]=0;
        ar[s[p]-'0']++;
        for(int i=0;i<2019;i++)
            ar[((i*10)+(s[p]-'0'))%2019]+=pr[i];
        for(int i=0;i<2019;i++)
            pr[i]=ar[i];
        ans+=pr[0];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3748