akhauriyash/Code-Regression huggingface dataset:
package main

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

var n, u, v int
var ps [][]int // 隣接頂点の保持
var prt []int  // 深さ優先探索における親頂点の保持
var md int

func main() {
	fmt.Scan(&n, &u, &v)
	// 頂点番号をリストのインデックスと対応させる為、それぞれ1減算する
	// こうすることで、後の繰り返し処理が色々と楽に記述できる
	u--
	v--

	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ps = make([][]int, n)
	for i := 0; i < n-1; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		// 頂点番号をリストのインデックスと対応させる為、それぞれ1減算する
		// こうすることで、後の繰り返し処理が色々と楽に記述できる
		a--
		b--
		// 頂点aとbは双方向に移動可能なので
		ps[a] = append(ps[a], b) // 頂点aの隣接頂点リストに頂点bを追加する
		ps[b] = append(ps[b], a) // 頂点bの隣接頂点リストに頂点aを追加する
	}

	// 頂点uとvが同じ場所で始まる場合、青木君の移動回数は0で終わる
	if u == v {
		fmt.Println(0)
		return
	}

	// make parent
	// 頂点vを根とする深さ優先探索を行う
	prt = make([]int, n)
	prt[v] = -1
	dfs(v, -1)

	// check min path
	// 頂点uを始点として頂点vを終点とする最短コストの経路を求める
	var mp int
	sp := u
	for sp != v { // uとvが同じ頂点になるまで繰り返す
		sp = prt[sp] // 現在の始点と隣接する頂点を次の始点にする
		mp++         // 頂点間の移動コストを加算する（1固定）
	}

	// bottom path
	// uとvが同じ葉に存在し移動中にかち合うケースを最低移動回数とする
	bp := int((mp - 1) / 2)
	// uとvを結ぶ最短経路における中間頂点を求める
	sp = u
	for i := 0; i < bp; i++ {
		sp = prt[sp] // 現在の始点の親を新たな始点にする
	}

	// calc depth
	// 中間頂点を起点とする最深頂点の深度を求める（
	cd(sp, 0)

	// mp: 頂点uを始点として頂点vを終点とする最短経路のコスト
	// bp: 頂点uとvそれぞれが最短で合流するよう動いたときのuの最短コスト
	// -----> vから出発した青木君は高橋君の動き方を把握してるので最短手で追い詰めようとする。
	// md: 頂点uとvを結ぶ最短経路上の中間頂点を起点としたときの最深頂点の深度（追加コスト）
	// -----> uから出発した高橋君は逃げ場所として一番遠いところを目指す。
	// mp - bp + md - 1: 頂点uから出発した高橋君を、頂点vから出発した青木君が捕まえるのに必要な移動回数
	fmt.Println(mp - bp + md - 1)
}

// cd は親頂点の木prtを活用して、始点spから見た最深頂点を探索し、その最大深度をmdに設定する
func cd(sp, depth int) {
	if depth > md { // 現在の最大深度より深い深度が確認できた場合
		md = depth // 最大深度を更新する
	}
	for _, cp := range ps[sp] { // 始点spの各隣接頂点spに対して
		if cp == prt[sp] { // 隣接点が始点の親である場合はパスする
			continue
		}
		cd(cp, depth+1) // 深度を一つ上げ、隣接頂点を始点とする深度調査を行う
	}
}

// dfs は深さ優先探索（再帰あり）で親頂点の木prtを形成する
func dfs(p, fp int) {
	prt[p] = fp // 頂点pの親頂点fpを登録する

	for _, cp := range ps[p] { // 頂点pの隣接点cpに対して
		if cp == fp { // 頂点pと親頂点fpが同じ場合はパスする
			continue
		}
		dfs(cp, p) // 同じように深さ優先探索を繰り返す
	}
}


Measured memory_bytes: 22400
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>



using namespace std;

int main() {
    int n;
    cin >> n;

    for (int i = 1; i <= n ;i++) {

        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        }
        else {
            do {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }while(x);
                
            
        }
    }
    cout << endl;

    }
        


Measured memory_bytes: 3104
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int A, B, C;

	cin >> A >> B >> C;

	if (A == B) cout << C << endl;
	else if (A == C) cout << B << endl;
	else cout << A << endl;

}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int n,m;
	int kos[550],ned[550],man[11000];
	int data[10050];
	cin>>m>>n;
	for(int i=0;i<m;i++)cin>>man[i];
	for(int i=0;i<n;i++)cin>>kos[i]>>ned[i];
	sort(man,man+m);reverse(man,man+m);
	for(int i=0;i<=m;i++)data[i]=110110110;
	data[0]=0;
	for(int j=0;j<n;j++)
	{
		for(int i=m;i>=0;--i)
		{
			data[i]=min(data[max(i-kos[j],0)]+ned[j],data[i]);
		}
	}
	//for(int i=0;i<=m;i++)cout<<data[i]<<endl;
	int jo=0;
	for(int i=0;i<m;i++)
	{
		jo+=man[i];
		data[i+1]-=jo;
	}
	
	int ans=0;
	for(int i=0;i<=m;i++)ans=min(data[i],ans);
	
	cout<<abs(ans)<<endl;
}

Measured memory_bytes: 1260
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
S = list(input())
ans = 0
x = 0
for s in S:
    if s=='I':
        x+=1
        ans = max(x, ans)
    else:
        x-=1
        ans = max(x, ans)
print(ans)

Measured memory_bytes: 61988
#include<iostream>
#include<vector>
#include<algorithm>
#include<cfloat>
#include<cmath>
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}

int main(){
    int p, n;
    while(cin >> p >> n, p+n){
        double l = 0, r = DBL_MAX, sq = sqrt(p);
        int lc, lm, rc, rm;
        for(int m = 1; m <= n; m++){
            int ll = (int)(sq*m), rr = ceil(sq*m);
            if(ll < 1)  ll = 1;
            if(rr < 1)  rr = 1;
            if(ll > n)  ll = n;
            if(rr > n)  rr = n;
            if((double)ll/m < sq && (double)ll/m > l){
                l = (double)ll/m, lc = ll, lm = m;
            }
            if((double)rr/m > sq && (double)rr/m < r){
                r = (double)rr/m, rc = rr, rm = m;
            }
        }
        int g = gcd(lc, lm);    lc /= g, lm /= g;
        g = gcd(rc, rm);        rc /= g, rm /= g;
        printf("%d/%d %d/%d\n", rc, rm, lc, lm);
    }
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int K, T; cin >> K >> T;

  vector <int> A(T);
  for (int i = 0; i < T; i++) cin >> A[i];
  sort(A.begin(), A.end(), greater<int>());

  
  if (A[0] <= K / 2){
    cout << 0 << endl;
  }else{
    int rest = A[0] - K / 2;  
    if (K % 2 == 0){
      cout << 2 * rest - 1 << endl;
    }else{
      cout << 2 * rest - 2 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))

b_list_even = []
b_list_odd = []
for i, a in enumerate(a_list , start=1):
    if i % 2 == 0:
        b_list_even.append(a)
    else:
        b_list_odd.append(a)


if n % 2 != 0:
    b_list_odd.reverse()
    b_list = b_list_odd + b_list_even
else:
    b_list_even.reverse()
    b_list = b_list_even + b_list_odd

print(" ".join(map(str, b_list)))


Measured memory_bytes: 31300
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,s=0;
cin>>n;
int a[n+1];
a[0]=0;
for(int i=1;i<=n;i++){
cin>>a[i];
if(a[i]>a[i-1])
s+=a[i]-a[i-1];} 
cout<<s;}

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

int main (){
  int N, Q;
  vector<int> ctr(N + 1, 0);
  string T;
  cin >> N >> Q >> T;
  
  for (int i = 0; i < N - 1; i++) {
    ctr[i + 2] = ctr[i + 1];
    if (T[i] == 'A' && T[i + 1] == 'C') ctr[i + 2]++;
  }
  
  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    cout << ctr[r] - ctr[l] << endl;
  }
  
  return 0;
}

  

Measured memory_bytes: 25728
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                while(true){
                        int r = sc.nextInt();
                        int c = sc.nextInt();
                        if (r == 0 && c == 0) {
                                break;
                        }
                        if (r % 2 == 0 || c % 2 == 0) {
                                System.out.println("yes");
                        } else {
                                System.out.println("no");
                        }
                }
        }
}

Measured memory_bytes: 28660
// 2014/08/01 Tazoe

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

int main()
{
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	double d = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

	cout.precision(8);
	cout << fixed << d << endl;

	return 0;
}

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

int main()
{
  int M, N, x;
  int sum = 0;
  int count = 0;
  vector<double> vote;
  vector<double> rate;
  cin >> N >> M;

  for (int i = 0; i < N; i++)
  {
    cin >> x;
    vote.push_back(x);
  }

  for (int i = 0; i < N; i++)
  {
    sum += vote[i];
  }

  for (int i = 0; i < N; i++)
  {
    double y = double(vote[i] / sum);
    rate.push_back(y);
  }

  for (int i = 0; i < N; i++)
  {
    if (rate[i] >= (double)((double)1 / (4 * M)))
    {
      count++;
    }
  }

  if (count >= M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  // for (int i = 0; i < N; i++)
  // {
  //   cout << rate[i] << "," << (double)((double)1 / (4 * M)) << endl;
  // }
}

Measured memory_bytes: 256
using System;

namespace ABC065A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int X = Int32.Parse(bufs[0]);
            int A = Int32.Parse(bufs[1]);
            int B = Int32.Parse(bufs[2]);

            if (A >= B)
            {
                Console.WriteLine("delicious");
            }
            else if ((X + A) >= B)
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("dangerous");
            }

        }
    }
}


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

using namespace std;

#define DIM 1009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ld long double
#define pairll pair<long long,long long>
#define se second
#define fi first
#define pb push_back

long long i,j,k,l,n,m,a,b,c,a1,b1,c1,res;

int main()
{
    fast;

    cin>>a>>b>>c>>n;
    if(n%2==0)res=a-b;
    else res=b-a;
    cout<<res<<endl;
    amen;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

const int di[2][9] = {{-2, -1, -1, 0, 0, 0, 1, 1, 2}, {-2, -1, -1, 0, 0, 0, 1, 1, 2}};
const int dj[2][9] = {{1, 1, 2, 1, 2, 3, 1, 2, 1}, {-1, -2, -1, -3, -2, -1, -2, -1, -1}};
const int cost[] = {['S'] = 0, ['T'] = 0, ['X'] = INF, ['1'] = 1, 2, 3, 4, 5, 6, 7, 8, 9};

typedef struct {
	int i, j, f, d;
} PairCoordDis;

PairCoordDis heap[32400];
int hsize;

void insert(int i, int j, int f, int d) {
	int ii;
	for (ii = hsize++; ii > 0 && d < heap[ii - 1 >> 1].d; ii = ii - 1 >> 1)
		heap[ii] = heap[ii - 1 >> 1];
	heap[ii] = (PairCoordDis){i, j, f, d};
}

int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

PairCoordDis delete(void) {
	int i;
	int nextIdx;
	const PairCoordDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

char field[60][30];
int d[60][30][2];

void dijkstra(int h, int w, int si, int sj, int sf) {
	int i, j;

	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			d[i][j][0] = d[i][j][1] = INF;

	d[si][sj][sf] = 0;
	insert(si, sj, sf, 0);
	while (hsize > 0) {
		const PairCoordDis fromPair = delete();

		if (fromPair.d > d[fromPair.i][fromPair.j][fromPair.f])
			continue;

		for (i = 0; i < 9; i++) {
			const int ni = fromPair.i + di[fromPair.f][i], nj = fromPair.j + dj[fromPair.f][i];
			if (ni >= 0 && ni < h && nj >= 0 && nj < w)
				if (fromPair.d + cost[field[ni][nj]] < d[ni][nj][fromPair.f ^ 1]) {
					d[ni][nj][fromPair.f ^ 1] = fromPair.d + cost[field[ni][nj]];
					insert(ni, nj, fromPair.f ^ 1, d[ni][nj][fromPair.f ^ 1]);
				}
		}
	}
}

int main(void) {
	int i, j, k;
	int w, h;

	while (scanf("%d %d", &w, &h), w) {
		int min;

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf(" %c", field[i] + j);

		min = INF;
		for (i = 0; i < w; i++)
			if (field[h - 1][i] == 'S')
				for (j = 0; j < 2; j++) {
					dijkstra(h, w, h - 1, i, j);
					for (k = 0; k < w; k++)
						if (field[0][k] == 'T') {
							min = min(min, d[0][k][0]);
							min = min(min, d[0][k][1]);
						}
				}

		printf("%d\n", min == INF ? -1 : min);
	}

	return 0;
}

Measured memory_bytes: 624
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  double r; cin >> r;
  double p = acos(-1);
  printf("%.6f %.6f\n",r*r*p,r*2*p);
  return 0;
}



Measured memory_bytes: 3180
n = int(input())
l = list(map(int,input().split()))
length = len(l)
count = 0
if length < 3:
    print(0)
    exit()

for i in range(length-2):
    for j in range(i+1,length-1):
        for k in range(j+1,length):
            if len(set([l[i],l[j],l[k]])) == 3:
                li = sorted([l[i],l[j],l[k]])
                if li[0] + li[1] > li[2]:
#                    print(i+1,j+1,k+1)
#                    print(li)
#                    print(l[i],l[j],l[k])
                    count+=1

print(count)

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

using namespace std;

int main()
{
  int n;
  cin>>n;
  long long a[1000010],b[1000010],c[1000010];
  for(int i=1;i<=n;++i)
    cin>>a[i]>>b[i]>>c[i];
  long long dp[1000010][4];
  dp[1][1]=a[1];
  dp[1][2]=b[1];
  dp[1][3]=c[1];
  for(int i=2;i<=n;++i)
  {
    dp[i][1]=max(dp[i-1][2]+a[i] , dp[i-1][3] +a[i]);
    dp[i][2]=max(dp[i-1][1]+b[i] , dp[i-1][3] +b[i]);
    dp[i][3]=max(dp[i-1][1]+c[i] , dp[i-1][2] +c[i]);             
  }
  if(dp[n][1]>=dp[n][2] && dp[n][1]>=dp[n][3])
    cout<<dp[n][1]<<endl;
  else if(dp[n][2]>=dp[n][1] && dp[n][2]>=dp[n][3])
    cout<<dp[n][2]<<endl;
  else
    cout<<dp[n][3]<<endl;
  return 0;
}

Measured memory_bytes: 15360
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> H;
  tools::read(H, N);

  std::vector<i64> dp(N);
  dp[0] = 0;
  for (auto it1 = H.begin(), it2 = ++H.begin(); it2 != H.end(); ++it1, ++it2) {
    if (*it1 >= *it2) {
      dp[std::distance(H.begin(), it2)] = dp[std::distance(H.begin(), it1)] + 1;
    } else {
      dp[std::distance(H.begin(), it2)] = 0;
    }
  }

  std::cout << *std::max_element(dp.begin(), dp.end()) << std::endl;
  return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n,k=MI()
probab=0
for i in range(1,n+1):
    s=i
    count=0
    while s<k:
        s*=2
        count+=1
    probab+=1/(2**(count))
print(probab/n)
    

Measured memory_bytes: 38896
MOD = 998244353
N, S = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
dpR = Array.new(N + 1, 0) # 保存用 : Aをi番目まで使って、総和がSになる組合せの数(両端の区切り違いの重複含む)
dpL = Array.new(S + 1, 0) # 更新用 : Aをi番目まで使って、総和がsになる組合せの数(左端の区切り違いの重複含む)

A.each.with_index(1) do |a,i|
  dpL[0] = i # 左端の区切り違いの重複は総和が0になる組合せの数で表現できる
  S.downto(0) do |j|
    dpL[j + a] = (dpL[j + a] + dpL[j]) % MOD if j + a <= S
  end
  dpR[i] = (dpR[i - 1] + dpL[S]) % MOD
end
puts dpR[N]


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n; cin >> n;
	ll ans = n*(n-1)/2;
	cout << ans << endl;
}	


Measured memory_bytes: 256
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
cnt = 0
S.sort()
for i in range(q):
    l = 0
    r = n-1
    ans = T[i]
    while l <= r:
        c = int((l+r)/2) #center
        if S[c] == ans:
            cnt += 1
        if S[c] < ans:
            l = c+1
        elif S[c] > ans:
            r = c-1
        else:
            break
        
print(cnt)



Measured memory_bytes: 16704
// All Heil Fire Lord Zuko
// High Functioning Socialpath
// she loves it when i call her senorita

#include<bits/stdc++.h>
using namespace std ;

//#define int ll

#define all(x) x.begin() , x.end()

#define _sz(x) (int)x.size()
#define F first
#define S second
#define PB push_back

#define debug(x) cerr << #x << " = " << x << "\n"

typedef long long ll ;
typedef pair<int, int> pii ;
typedef long double ld ;

const int N = 100 + 19 ;
const int Mod = 1e9 + 7 ;
const int inf = 1 << 30 ;
const ll INF = 1ll << 62 ;

int main() {
        ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
        int n ;
        cin >> n ;
        string s ;
        cin >> s ;
        for (int i = 0 ; i < _sz(s) ; i ++) {
                int x = 0 ;
                while (x < n) {
                        if (s[i] == 'Z')
                                s[i] = 'A' ;
                        else
                                s[i] += 1 ;
                        x ++ ;
                }
        }
        cout << s ;
        return 0 ;
}



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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
int N;
int main(){
	fast;
	
	cin>>N;
	
	if (N % 10 == 3) cout<<"bon";
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout<<"pon";
	else cout<<"hon";
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main() {
    ios_base::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    int ans = min(C, A - B) ;
    cout << C - ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _  << ' ' <<
#define squ(x)  ((x) * (x))
#define VAR_NAME(var)  cout << #var << " : ";
#define debug(var)  VAR_NAME(var); view(var);
template <class T>
using V = vector<T>;
template <class T>
using VV = vector<vector<T>>;
template <class T>
using VVV = vector<vector<vector<T>>>;
//// view vector functions
template<typename T>
void view(T e){
  cout << e << endl;
}
template<typename T>
void view(vector<T>& v){
  for(const auto& e : v){
    cout << setw(5)<< e << " ";
  }
  cout << endl;
}

template<typename T>
void view(const vector<vector<T>>& vv){
  for(const auto& v : vv){
    for(const auto& e : v)
      cout << setw(5) << e << " ";
    cout << endl;
  }
}

int main(){
  int i, j;
  int R, D;
  cin >> R >> D;
  V<int> x(11);
  cin >> x[0];
  for(i=1; i<x.size(); ++i){
    x[i] = R*x[i-1] - D;
    cout << x[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if((a%3==0)||(b%3==0)||((a+b)%3==0))
	cout<<"Possible\n";
	else
	cout<<"Impossible\n";
	return 0;
}

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

using namespace std;
using ll = long long;

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

    int a, b;

    cin >> a >> b;

    int ans = 0;

    int cnt = 1;
    while (cnt < b) {
        cnt += a-1;
        ans++;
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
signed main(){

    ll X;
    cin>>X;
    ll C=100;
    for(int i=0;1;i++){
        C=C*1.01;
        if(C>=X){
            cout<<i+1<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
//CLOCKS_PER_SEC
#define se second
#define fi first
#define ll long long
#define Pii pair<int,int>
#define Pli pair<ll,int>
#define ull unsigned long long
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define fio ios::sync_with_stdio(false);cin.tie(0);
#define db double
#define mk make_pair
const double Pi=3.14159265;
const int N = 2e5+10;
const int M = 2e5+10;
const ull base=163;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const db eps=1e-8;
const db pi=acos(-1);
using namespace std;
int a[40];
int main(){
    string s;
    cin>>s;
    for(int i = 0; i < 4; ++i){
        a[s[i]-'A']+=1;
    }
    int tot = 0;
    for(int i = 0; i < 26; ++i){
        if(a[i] == 2)tot++;
    }
    if(tot == 2)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n;
    scanf("%d", &n);
    pii p[n];
    rep(i, n) scanf("%d", &p[i].fi), p[i].se = i;
    sort(p, p+n);
    int ans[n];
    rep(i, n) ans[p[i].se] = (i < n/2 ? p[n/2].fi : p[n/2-1].fi);
    rep(i, n) printf("%d\n", ans[i]);
}

Measured memory_bytes: 6136
N, M = map(int, input().split())
AB = sorted([list(map(int, input().split())) for _ in range(N)])
ans = 0
res = 0
ind = 0

while (res < M):
    if M - res >= AB[ind][1]:
        ans += AB[ind][0] * AB[ind][1]
        res += AB[ind][1]
    else:
        ans += AB[ind][0] * (M - res)
        res += (M - res)
    ind += 1

print(ans)


Measured memory_bytes: 28656
#include "bits/stdc++.h"

using namespace std;

int main() {
    string S;
    cin >> S;
    string tomorrow;
    if(S == "Sunny") tomorrow = "Cloudy";
    else if(S == "Cloudy") tomorrow = "Rainy";
    else if(S == "Rainy") tomorrow = "Sunny";

    cout << tomorrow << endl;
}

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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<int>P(N);
	for (int i = 0; i < N; i++) cin >> P.at(i);
	int E = 0, M = 0, D = 0;
	for (int i = 0; i < N; i++) {
		if (P.at(i) <= A) E++;
		else if (P.at(i) > A && P.at(i) <= B) M++;
		else D++;
	}
	cout << min({ E, M, D }) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    int cnt = 0;
    REP(i, 3) {
        if(S[i] == 'o') {
            cnt++;
        }
    }
    cout << 700 + 100 * cnt << endl;
    return 0;
}

Measured memory_bytes: 256
while n = gets do
  n = n.to_i
  c = 0
  10.times{|i|
    10.times{|j|
      10.times{|k|
        10.times{|l|
          c = c + 1 if i + j + k + l == n
        }
      }
    }
  }
  puts c
end

Measured memory_bytes: 6096
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); //yen
		int m = in.nextInt();
		int[] c = new int[m];
		for (int i = 0; i < m; i++) {
			c[i] = in.nextInt();
		}

		int[] t = new int[n + 1];
		for (int i = 0; i <= n; i++) {
			t[i] = 50000;
		}
		t[0] = 0;

		for (int i = 0; i < m; i++) {

			for (int j = c[i]; j <= n; j++) {

				t[j] = Math.min(t[j], t[j - c[i]] + 1);

			}
		}

		System.out.println(t[n]);
		in.close();
	}
}





Measured memory_bytes: 26868
#include <stdio.h>

int main(void){
     unsigned long int x;
     unsigned long int ans = 0;
     unsigned long int i;
     scanf("%lu",&x);
     for(i=1;i<=(x/2);i++){
         ans++;
     }
     if(x%2 == 0)
         ans--;
     printf("%lu\n",ans);
     return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[1024];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

string amax(const string& s1, const string& s2){
	if(s1.size()!=s2.size()) return s1.size()>s2.size()?s1:s2;
	for(int i = 0; i < s1.size(); i++){
		if(s1[i] != s2[i]) return s1[i] > s2[i] ? s1 :s2;
	}
	return s1;
}
bool isNum(char c){
	return c>='0' && c<='9';
}

int main(){
	while(1){
		int w = in.nextInt(), h = in.nextInt();
		if(h == 0 &&  w == 0) break;
		vector<string> s(h);
		vector<vector<string> > d(h + 1, vector<string>(w+1));
		rep(i, h) s[i] = in.next();
		int m = 0;
		for(int i = 0; i < h; i++) for(int j = 0; j < w; j++){
			if(isNum(s[i][j])) m = max(m, s[i][j]-'0');
		}
		if(m == 0) {
			printf("0\n");
			continue;
		}
		string ans ="";
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(!isNum(s[i][j])) continue;
				if(s[i][j] != '0') d[i][j] = s[i][j];
				if(i > 0){
					if(d[i-1][j] == "" && s[i][j]=='0');
					else d[i][j] = amax(d[i][j], d[i-1][j] + s[i][j]);
				}
				if(j > 0){
					if(d[i][j-1] == "" && s[i][j]=='0');
					else d[i][j] = amax(d[i][j], d[i][j-1] + s[i][j]);
				}
				ans = amax(ans, d[i][j]);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1364
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a; i < b; i++)

int main() {
	
	int x, n;
	cin >> x >> n;

	int mini = 1000, ans = mini;

	if (n == 0) {
		cout << x << endl;
		return 0;
	}

	vector<int>p(n);
	rep(i, 0, n) {
		cin >> p[i];
	}

	sort(p.begin(), p.end());

	int k = p[0], l = 0;
	rep(i, 0, p[n - 1]) {
		if (i != k) {
			int a = x - i;
			if (mini > abs(a)) {
				mini = abs(a);
				ans = i;
			}
		}
		else {
			l++;
			k = p[l];
		}
	}

	int yy = p[n - 1] + 1;
	int a = x - yy;
	if (mini > abs(a)) ans = yy;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>

int N, A, B, C;
int INF = 1000000000;
int* l;
    
int dfs (int cur, int a, int b, int c) {
    if (cur == N) {
        if (std::min({a, b, c}) <= 0) {
            return INF;
        }
        return std::abs(a - A) + std::abs(b - B) + std::abs(c - C) - 30;
    }

    int ret0 = dfs(cur + 1, a, b, c);
    int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
    int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    return std::min({ret0, ret1, ret2, ret3});
}

int main() {
    std::cin >> N >> A >> B >> C;

    int in[N];
    for (int i = 0; i < N; i++) {
        std::cin >> in[i];
    }
    l = in;
    std::cout << dfs(0, 0, 0, 0);
}

Measured memory_bytes: 256
const Main = input => {
    input = input.split("\n");
    tmp1 = input[0].split(" ");
    const N = parseInt(tmp1[0], 10);
    const A = parseInt(tmp1[1], 10);
    const B = parseInt(tmp1[2], 10);
    const result = N * A < B ? N * A : B;
    console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21956
#include<bits/stdc++.h>
using namespace std;
int dp[1010][1010];
int main(){
  int q;
  cin>>q;
  for(int cn=0;cn<q;cn++){
    string x,y;
    cin>>x>>y;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=x.size();i++){
      for(int j=1;j<=y.size();j++){
	if(x[i-1]==y[j-1])dp[i][j]=dp[i-1][j-1]+1;
	dp[i][j]=max(dp[i-1][j],dp[i][j]);
	dp[i][j]=max(dp[i][j-1],dp[i][j]);
      }
    }
    cout<<dp[x.size()][y.size()]<<endl;
  }
  return 0;
}



Measured memory_bytes: 7180
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main() {
  int *x = new int[101];
  int *y = new int[101];
  int i, n;
  long sum2 = 0, sum3 = 0;
  double D1 = 0, D2 = 0, D3 = 0, Dm = 0;
  cin >> n;
  for(i = 0; i < n; i++) {
	cin >> x[i];
  }
  for(i = 0; i < n; i++) {
	cin >> y[i];
  }
  
  for(i = 0; i < n; i++) {
	D1 += abs(x[i] - y[i]);
	
	sum2 += pow(abs(x[i] - y[i]), 2);
	sum3 += pow(abs(x[i] - y[i]), 3);
	
	if(i == 0) {
	  Dm = abs(x[i] - y[i]);
	}
	else {
	  if(abs(x[i] - y[i]) > Dm) {
		Dm = abs(x[i] - y[i]);
	  }
	}
  }
  D2 = sqrt(sum2);
  D3 = cbrt(sum3);
  printf("%lf\n%lf\n%lf\n%lf\n", D1, D2, D3, Dm);
  return 0;
}

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

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

	vector<string> b( H, string( W, '0' ) );
	for( int h = 0; h < B; h++ ) {
		for( int w = A; w < W; w++ ) {
			b[h][w] = '1';
		}
	}
	for( int h = B; h < H; h++ ) {
		for( int w = 0; w < A; w++ ) {
			b[h][w] = '1';
		}
	}

	for( int i = 0; i < H; i++ ) {
		cout << b[i] << endl;
	}
}


Measured memory_bytes: 2304
#include<stdio.h>

int main(void){
    int H,W;
    
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i==0 || i==H-1){
                    printf("#");
                }else if(j==0 || j==W-1){
                    printf("#");
                }else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int gcd(int x, int y){
    if(y==0) return x;
    else return gcd(y, x%y);
}

int main(){
    int a, b, c, d; cin>>a>>b>>c>>d;
    int x=abs(c-a), y=abs(d-b);
    //int x, y; cin>>x>>y;
    int l=max(x, y), s=min(x, y);
    int num=gcd(l, s);
    l/=num, s/=num;

    if(s==0){
        cout << 0 << endl;
    }
    else if(l%s==0){
        cout << (ll)l*num << endl;
    }
    else{
        cout << (ll)(l+s-1)*num << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
struct Edge{
	int to,nxt;
}edge[500100];
struct Point{
	int minn,maxn,ans,opt;
}point[500100];
int cnt,head[500100],n,m;
void Exit(){
	puts("No");
	exit(0);
}
void addedge(int x,int y){
	edge[++cnt].to=y;
	edge[cnt].nxt=head[x];
	head[x]=cnt;
}
void dfs1(int x,int fa){
	for(int i=head[x];i;i=edge[i].nxt){
		int upup=edge[i].to;
		if(upup==fa)continue;
		dfs1(upup,x);
		point[x].maxn=min(point[x].maxn,point[upup].maxn+1);
		point[x].minn=max(point[x].minn,point[upup].minn-1);
		if(point[upup].opt!=-1){
			if(point[x].opt==-1)point[x].opt=point[upup].opt^1;
			else if(point[x].opt==point[upup].opt)Exit();
		}
	}
}
void dfs2(int x,int fa){
	if(fa){
		point[x].maxn=min(point[x].maxn,point[fa].maxn+1);
		point[x].minn=max(point[x].minn,point[fa].minn-1);
		if(point[x].opt!=-1)point[x].opt=point[fa].opt^1;
	}
	if(point[x].minn>point[x].maxn)Exit();
	if(point[x].minn==point[x].maxn&&(point[x].minn&1)!=point[x].opt)Exit();
	for(int i=head[x];i;i=edge[i].nxt){
		int upup=edge[i].to;
		if(upup==fa)continue;
		dfs2(upup,x);
	}
}
void getans(int x,int fa){
	if(!fa){
		if(point[x].minn%2==point[x].opt)point[x].ans=point[x].minn;
		else point[x].ans=point[x].minn+1;
	}
	else{
		point[x].ans=point[fa].ans-1;
		if(point[x].ans<point[x].minn)point[x].ans+=2;
	}
	for(int i=head[x];i;i=edge[i].nxt){
		int upup=edge[i].to;
		if(upup==fa)continue;
		getans(upup,x);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	for(int i=1;i<=n;i++){
		point[i].opt=-1;
		point[i].minn=-0x3f3f3f3f;
		point[i].maxn=0x3f3f3f3f;
	}
	scanf("%d",&m);
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		point[x].minn=point[x].maxn=y;
		point[x].opt=y&1;
	}
	dfs1(1,0);
	dfs2(1,0);
	getans(1,0);
	puts("Yes");
	for(int i=1;i<=n;i++)
		printf("%d\n",point[i].ans);
}

Measured memory_bytes: 11428
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>

using namespace std;

int main() {
	int n, s[200] = {}, num[200] = {}, result = 0, lamp = 1, in, ax, h, w, m, a[100] = {}, b[100] = {}, c[100] = {}, d[100] = {}, r, tmp;
	string str ,str2;
	cin >>n>>m;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >>b[i];
	}
	for (int i = 0; i < m; i++) {
		cin>> c[i] >> d[i];
	}
	
	for (int i = 0; i < n; i++) {
		in = abs(a[i] - c[0])+abs( b[i] - d[0]);
      	h=0;
		for (int j = 1; j < m; j++) {
          if(in> abs(a[i] - c[j]) + abs(b[i] - d[j])){h=j;}
			in = min(in, abs(a[i] - c[j]) + abs(b[i] - d[j]));
          
		}
		cout << h+1 << endl;
	}

}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 501
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

char s[105];
int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0,n,K;
    //double start=clock();
    scanf("%d%s",&n,s);
    rep(i,0,n)if(s[i]=='R')m++;
    if(m>n-m)puts("Yes");
    else puts("No");
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i=0; i<=s.length()-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            ans += 1;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int lli;

#define em emplace_back
#define rep(i,j,n) for(lli i=j;i<n;i++)
#define repf(i,a,j,n) for(lli i=j,a=0;i<n;i++,a++)
#define repg(i,j,n) for(int i=j;i>n;--i)
using namespace std;
lli m = 998244353;

void solve(){

    lli n,k;
    cin>>n>>k;

    vector<lli> temp(n+1,0)  ; 

    vector<pair<lli,lli>> v;

    rep(i,0,k){
        lli a,b;
        cin>>a>>b;
        
        v.em(make_pair(a,b));
    }

    sort(v.begin(), v.end());
    lli ans = 0;
    
    temp[1] = 1;

    lli current = 0;
    rep(i,1,n){
        temp[i]%=m;
        current = (current + temp[i]);
        if(current<=0){
            continue;
        }

        rep(j,0,v.size()){
            lli f = i+v[j].first;
            lli l = i+v[j].second;
            if(f>n){
                break;
            }else{
                temp[f] = (temp[f]+(current));
            }
            if(l+1>n){
                continue;
            }else{
                temp[l+1]= (temp[l+1]-current);
            }
        }
        temp[i] = temp[i]%m;
    }

    cout<<temp[n]%m;
}
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
 
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, b, a) for(int i = (b); i >= (a); --i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define boost ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define M (ll)(1e9+7)
#define inf (ll)(2e9+9)
#define infl (ll)(2e18+9)
#define debug1(a) cout<<#a<<" = " <<a<<endl; 
#define debug2(a,b) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<endl; 
#define debug3(a,b,c) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<endl; 
#define debug4(a,b,c,d) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<" , "<<#d<<" = " <<d<<endl; 
  
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc; 
typedef vector<ll> vll; 
typedef vector< pair<int,int> > vpii;

/* -------------------------------------------------------------------------*/
/* -------------------------------------------------------------------------*/



void solve(){
  int n; cin>>n; 
  vector<vector<int>> vals(n); 
  vector<vector<int>> dp(n,vector<int>(3)); 
  int a,b,c; 
  rep(i,0,n-1){
    cin>>a>>b>>c; 
    vals[i].push_back(a); 
    vals[i].push_back(b); 
    vals[i].push_back(c); 
  }
  rep(i,0,2) dp[0][i]=vals[0][i]; 
  rep(i,1,n-1){
    rep(j,0,2){
      dp[i][j]=vals[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);    
    }
  }
  int ans=-inf; 
  rep(i,0,2) ans=max(ans,dp[n-1][i]); 
  cout<<ans; 
}

int main() {
  clock_t beg=clock(); 
  boost;
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
  clock_t end=clock(); 
  fprintf(stderr, "%lf\n", (double)(end-beg)/CLOCKS_PER_SEC);
}


Measured memory_bytes: 11264
import sys

dictionary = {
        0:0,
        1:31,
        2:60,
        3:91,
        4:121,
        5:152,
        6:182,
        7:213,
        8:244,
        9:274,
        10:305,
        11:335,
        12:366}

for line in sys.stdin.readlines():
    line = line.strip()
    month, day = map(int, line.split())
    if month == 0:
        break
    else:
        pastDay = dictionary[month - 1] + day - 1
        if pastDay % 7 == 0:
            print "Thursday"
        elif pastDay % 7 == 1:
            print "Friday"
        elif pastDay % 7 == 2:
            print "Saturday"
        elif pastDay % 7 == 3:
            print "Sunday"
        elif pastDay % 7 == 4:
            print "Monday"
        elif pastDay % 7 == 5:
            print "Tuesday"
        else:
            print "Wednesday"

Measured memory_bytes: 5396
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 0xffffffff;

signed main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	vector<vector<int>> dp(n, vector<int>(n, INF));
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < n; i++) {
		dp[i][i] = 0;
	}
	for (int k = 1; k < n; k++) {
		for (int i = 0; i + k < n; i++) {
			for (int j = i; j < i + k; j++) {
				dp[i][i + k] = min(dp[i][i + k], dp[i][j] + dp[j + 1][i + k] + a[i] * b[j] * a[j + 1] * b[i + k]);
			}
		}
	}
	cout << dp[0][n - 1] << endl;
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

int main() {
    int A(in()), B(in()), C(in());
    string ans = (A == B && B == C) ?
                    "Yes":
                    "No";
    cout << ans << endl;

    return 0;

}



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

struct UnionFind {
  vector<int> par;
    
  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n, -1); }
    
  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
    
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
    
  bool merge(int x, int y) {
    x=root(x);
    y=root(y);
    if (x==y) return false;
    if (par[x]>par[y]) swap(x, y);
    par[x]+=par[y];
    par[y]=x;
    return true;
  }
    
  int size(int x) {
    return -par[root(x)];
  }
};

int main() { 
  int n,m; cin>>n>>m;
  vector<int> x(m),y(m),z(m);
  rep(i, m) cin>>x[i]>>y[i]>>z[i];
  UnionFind uf(n);
  rep(i, m) uf.merge(x[i]-1, y[i]-1);
  set<int> s;
  rep(i, n) s.insert(uf.root(i));
  int res=s.size();
  cout<<res<<endl;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int n, t;
    cin >> n >> t;

    vector<int> v(t + 2);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;

        v[a] += 1, v[b] += -1;
    }
    int sum = 0, mx = 0;
    for (int i = 0; i <= t; i++) {
        sum += v[i];
        mx = max(mx, sum);
    }
    cout << mx << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

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

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3632
#include<cstdio>

int n, id;
char s[111];

int main() {
	scanf("%d%s%d", &n, s, &id);
	id--;
	for(int i=0;i<n;i++)
		if(s[i]!=s[id]) s[i] = '*';
	printf("%s\n", s);
	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		Console.WriteLine("{0} {1}",Math.Min(s[1],s[2]),Math.Max((s[1]+s[2])-s[0],0));
	}
}

class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
}

Measured memory_bytes: 11220
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  h,w=parse.(Int,split(readline()))
  a=[chomp(readline()) for i = 1:h]
  tate=Bool[false for i=1:h]
  yoko=Bool[false for i=1:w]
  for i=1:h
    for j=1:w
      if a[i][j]=='#'; tate[i]=true; yoko[j]=true; end
    end
  end
  for i=1:h
    flag=false
    for j=1:w
      if tate[i]==true && yoko[j]==true; print(a[i][j]);flag=true; end
    end
    if flag == true; println(); end
  end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 179364
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const ll mod = 998244353;


ll dp[3030][3030][3];
int a[3030];
int main(){
    int n, k;
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
            (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if(j + a[i] <= k){
                (dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    cout << dp[n][k][2] << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd( T m, T n ){
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;

    while( m != n ){
        if ( m > n ) m %= n;
        else         n %= m;

        if(m == 0) return n;
        if(n == 0) return m;
    }
    return m;
}

int main()
{
    ll N, X;
    cin >> N >> X;
    ll xi;
    cin >> xi;
    ll res = abs(xi-X);
    for(int i=1;i<N;i++){
        cin >> xi;
        res = gcd(res, abs(xi-X));
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256