akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cstdio>

using namespace std;

#define rep(i, n) for(long int i = 0; i < n; i++)
#define P pair<long int, long int>

int main(){
    int n, m;
    cin >> n >> m;
    if (n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
n = int(input())
a = [[0 for j in range(10)] for i in range(10)]
for i in range(1, n + 1):
    s = str(i)
    a[int(s[0])][int(s[-1])] += 1
sol = 0
for i in range(1, 10):
    sol += (a[i][i] * a[i][i])
for i in range(2, 10):
    for j in range(1, i):
        sol += (a[i][j] * a[j][i] * 2)
print(sol)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int q;
    cin >> q;
    set<int> s;
    while (q--) {
        int c, x;
        cin >> c >> x;
        if (c == 0) {
            s.emplace(x);
            cout << sz(s) << endl;
        } else {
            cout << s.count(x) << endl;
        }
    } 
}



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

using namespace std;
typedef long long ll;

int main(void) {
	int num, i;
	ll a = 0;
	cin >> num;
	vector<ll> d(num), ans(num);
	for (i = 0; i < num; i++) {
		cin >> d[i];
		a += d[i];
	}
	a -= 2 * d[num - 1];
	for (i = 1; i < num - 3; i += 2)
		a -= d[i] << 1;
	ans[num - 2] = a;
	ans[num - 1] = 2 * d[num - 2] - ans[num - 2];
	for (i = num - 3; i >= 0; i--)
		ans[i] = (d[i] << 1) - ans[i + 1];
	for (i = 0; i < num; i++)
		cout << ans[i] << " ";
	printf("\n");
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, lala[300005], rara[300008];
string str;

int main() {
	cin >> n >> str;
	lala[0] = 0;
	for(ll i = 1; i <= n; i++){
		lala[i] = (str[i-1] == 'W')? lala[i-1]+1 : lala[i-1];
	}
	rara[n] = 0;
	for(ll i = n-1; i >= 0; i--){
		rara[i] = (str[i] == 'E')? rara[i+1]+1 : rara[i+1];
	}
	
	ll ans = 300005; 
	for(ll i = 1; i <= n; i++){
		ans = min(lala[i-1]+rara[i], ans);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5380
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

using namespace std;

typedef int State[3];

const int maxn = 5000 + 50;
int A, B, C;

struct Node
{
	int nu[3];
	int step;
};

bool check(State state) {
	for (int i = 1; i < 3; i++) {
		if (state[i] != state[i - 1])
			return false;
	}
	return true;
}

string convert(int nu[])
{
	string s = "";
	for (int i = 0; i < 3; i++) {
		s += to_string(nu[i]);
	}
	return s;
}

int bfs() {
	Node node;
	node.nu[0] = A; node.nu[1] = B; node.nu[2] = C;
	sort(node.nu, node.nu + 3);
	node.step = 0;
	queue<Node> que;
	set<string> ses;
	que.push(node);
	ses.insert(convert(node.nu));

	int res = -1;
	while (!que.empty()) {
		Node no = que.front();
		que.pop();
		if (check(no.nu)) {
			res = no.step;
			break;
		}


		for (int i = 0; i < 3; i++) {
			Node t = no;
			for (int j = 0; j < 3; j++) {
				if (i == j)
					continue;
				t.nu[j]++;
			}
			sort(t.nu, t.nu + 3);
			string sta = convert(t.nu);
			if (ses.count(sta))
				continue;
			t.step++;
			que.push(t);
			ses.insert(sta);
		}

		for (int i = 0; i < 3; i++) {
			Node t = no;
			t.nu[i] += 2;
			sort(t.nu, t.nu + 3);
			string sta = convert(t.nu);
			if (ses.count(sta))
				continue;
			t.step++;
			que.push(t);
			ses.insert(sta);
		}
	}//while
	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> A >> B >> C;
	int res = bfs();
	cout << res << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), x(n + 11, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= MOD;
    x[i + 1] = (x[i] + a[i]) % MOD;
  }
  ll ans = 0;
  for (int i = 0; i < n - 1; i++) {
    ll p = x[n] - x[i + 1];
    ans += (p < 0 ? p + MOD : p) * a[i];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll N;
  cin >> N;

  if(N%2==1){
    cout << 0 << endl;
    return 0;
  }

  N /= 2;

  ll ret = 0;
  ll p = 5;
  for(ll k=1; k<=25; k++){
    ret += N/p;
    p *= 5;
  }

  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

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

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

  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  vector<int> left(n+1,0),right(n+1,0);
  for(int i = 0; i < n; i++){
    left[i+1] = gcd(left[i], a[i]);
  }
  for(int i = n-1; i >= 0; i--){
    right[i] = gcd(right[i+1], a[i]);
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    int now = gcd(left[i], right[i+1]);
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int r;cin>>r;
	if(r<1200)cout<<"ABC"<<endl;
	else if(r<2800)puts("ARC");
	else puts("AGC");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long n,k;
  cin >> n >> k;
  vector<long> a(n);
  vector<long> f(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n) cin >> f.at(i);
  sort(f.begin(),f.end());
  sort(a.begin(),a.end(),greater<long>());
  vector<long> x(n);
  long maxi = 0;
  rep(i,n){
    x.at(i) = a.at(i)*f.at(i);
    maxi = max(maxi,x.at(i));
  }
  long mini = 0;
  long count = 0;
  //int i = 0;
  while(maxi - mini > 1){
    long mid = (maxi + mini) / 2;
    //cout << mini << " " << mid << " " << maxi << endl;
    count = 0;
    rep(i,n){
      if(x.at(i) <= mid) continue;
      count += (x.at(i) - mid + f.at(i) - 1) / f.at(i);
    }
    if(count > k) mini = mid;
    else maxi = mid;
    //i++;
    //if(i > 50) break;
  }
  count = 0;
  rep(i,n){
    if(x.at(i) <= mini) continue;
    count += ((x.at(i) - mini + f.at(i) - 1) / f.at(i));
  }
  if(count <= k) cout << mini << endl;
  else cout << maxi << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long sa;
int main()
{
    ios_base::sync_with_stdio(false);
    sa s=0,i,j=0,k,n;
    cin>>n;
    sa ara[n];
    for(i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            continue;
        else
        {
            ara[j]=i;
            s=s+ara[j];
            j++;
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 7704
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)

using namespace std;
int dx[]={1,-1,0,0,1,-1,1,-1},dy[]={0,0,1,-1,1,-1,-1,1};
int w,h;
vector<vector<int> >c(50, vector<int>(50));
vector<vector<bool> >done(50, vector<bool>(50,false));

int dfs(int x, int y){
	int i;
	if(c[x][y] == 0)return 0;
	
	myfor(i,8){
		if(x+dx[i]>=0&&x+dx[i]<w && y+dy[i]>= 0 && y+dy[i] < h )if(!done[x+dx[i]][y+dy[i]]&& c[x+dx[i]][y+dy[i]] == 1){
			done[x+dx[i]][y+dy[i]] = true;
			dfs(x+dx[i],y+dy[i]);
		}
	}
	done[x][y] = true;
	return 1;
}
int mainloop(int win, int hin){
	int i,j,count=0;
	w = win,h=hin;
	
	myfor(i,w)myfor(j,h)cin >> c[i][j];
	myfor(i,w)myfor(j,h){
		if(!done[i][j])count+= dfs(i,j);
	}
	return count;
}

int main(){
	int win=1,hin=1,i;
	vector<int> ans;
	while(win != 0 && hin != 0){
		cin >> win >> hin;
		int cnt=0;
		if(win != 0 && hin != 0){
			done.assign(50,vector<bool>(50,false));
			ans.push_back(mainloop(hin,win));
		}
	}
	myfor(i,ans.size())cout << ans[i] << endl;
	return 0;
}


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

using namespace std;

int dp[100005];
int arr[1000];

int main(){
    int N, K;
    cin >> N >> K;
    for(int i= 1; i<=N; i++){
        cin >> arr[i];
    }
    for(int i = 1; i<=K; i++){
        for(int j = 1; j<=N; j++){
            if(arr[j] <= i){
                dp[i] |= !dp[i-arr[j]];
            }
        }
    }
    if(dp[K]){
        cout << "First" << endl;
    }
    else{
        cout << "Second" << endl;
    }
}


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

const int N = 200005;

int n;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (a > b) {
        swap(a, b);
    }
    cout << (a + 1LL * t * v >= b + 1LL * w * t ? "YES\n" : "NO\n");
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;


int main()
{
      int a,b,c;
      cin >> a;
      cin >> b;
      cin >> c;
      if(a == b)
            cout << c;
      else if(a == c)
            cout << b;
      else
      {
            cout << a;
      }
    return 0;
}


Measured memory_bytes: 256
main(){int c[9];scanf("%d%d%d%d%d%d%d%d%d",&c[0],&c[1],&c[2],&c[3],&c[4],&c[5],&c[6],&c[7],&c[8]);if(c[0]-c[1]==c[3]-c[4]&&c[3]-c[4]==c[6]-c[7]&&c[1]-c[2]==c[4]-c[5]&&c[4]-c[5]==c[7]-c[8]&&c[0]-c[3]==c[1]-c[4]&&c[1]-c[4]==c[2]-c[5]&&c[3]-c[6]==c[4]-c[7]&&c[4]-c[7]==c[5]-c[8])puts("Yes");else puts("No");}

Measured memory_bytes: 128
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let a: Vec<u64> = read_vec();
    // dp[i][j]はa_i ~ a_jを合成するときの最小コスト 答えはdp[0][n-1]
    // dp[i][j] = min(dp[i][l] + dp[l+1][j] + cost(i, l, j)) (i < l < j)
    // cost(i, l, j) = SUM(a_k) (for k = i ~ l) + SUM(a_k) (for k = l+1 ~ j)

    // コストを計算するための累積和
    let mut sum: Vec<u64> = vec![0; n+1];
    // dp_table
    let mut dp: Vec<Vec<u64>> = vec![vec![std::u64::MAX/2; n]; n];


    // 累積和を作成
    for i in 0..n {
      sum[i+1] = sum[i] + a[i];
    }

    // i == jの時、要素は１つなので合成できずコストは０、つまり、dp_tableの体格成分は０
    for i in 0..n {
      dp[i][i] = 0;
    }

    // dp_tableを更新
    // 区間の幅に関してループを回す
    for len in 1..n {
      for i in 0..n-len {
        // dp[i][i + len] = min(dp[i][i + len], )
        for j in i..i+len {
          dp[i][i + len]
            = min(dp[i][i + len],
                  dp[i][j] + dp[j+1][i + len]
                  + sum[i + len + 1] - sum[j+1]
                  + sum[j+1] - sum[i]);
        }
      }
    }
    println!("{}", dp[0][n-1]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
void read (int &x) {
    char ch = getchar(); x = 0;
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 5e5 + 10;
int n, tmp, ans, a[N], p[100];
signed main() {
    read (n), read (a[1]), read (a[2]); p[0] = 1;
    for (int i = 3; i <= n; ++i) read (a[i]), tmp ^= a[i];
    for (int i = 1; i <= 50; ++i) p[i] = p[i - 1] * 2;
    int sum = a[1] + a[2] - tmp;
    if (sum < 0 || (sum & 1)) return puts ("-1"), 0;
    sum >>= 1, ans = a[1] - sum;
    if (sum > a[1] || (sum & tmp)) return puts ("-1"), 0;
    for (int i = 45; i >= 0; --i) {
        if (tmp >= p[i]) {
            tmp -= p[i];
            if (ans >= p[i]) ans -= p[i];
        }
    } if (a[1] <= ans) return puts ("-1"), 0;
    return printf ("%lld\n", ans), 0;
}


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

int main() {
    int A, B;

    cin >> A >> B;
    if(A==1 || B==1) {
        if(A==B) {
            cout << "Draw\n";
        }
        else if(A==1) {
            cout << "Alice\n";
        }
        else {
            cout << "Bob\n";
        }
    }
    else {
        if(A>B) {
            cout << "Alice\n";
        }
        else if(A<B) {
            cout << "Bob\n";
        }
        else {
            cout << "Draw\n";
        }
    }
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();
    int n, s=1, t, mx;
    cin>> n;

    cin>> mx;

    for(int i=1; i<n; i++)
    {
        cin>> t;
        if( t>= mx)
        {
            s++;
            mx= t;
        }
    }


    cout << s;
    nl;


    return 0;
}




Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl

using namespace std;

const int MAX_N = 200005;

vector<int> info[2 * MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = (int)s.size();
    vector<int> vec;
    int cur = 0;
    ll ans = 0;
    vector<int> ad;
    info[cur + MAX_N].push_back(0);
    rep(i,n){
        // show("OK");
        if(s[i] == '('){
            vec.pb(0);
            ++cur;
            // show("BUE");
            info[cur + MAX_N].push_back(-1);
            ad.push_back(0);
            cout << (ans += ad.back()) << "\n";
        }else if(s[i] == ')'){
            vec.pb(1);
            --cur;
            if(!info[cur + MAX_N].empty()){
                if(info[cur + MAX_N].back() < 0){
                    ad.pb(1);
                }else{
                    ad.pb(info[cur + MAX_N].back() + 1);
                }
            }else{
                ad.push_back(0);
            }
            info[cur + MAX_N].push_back(ad.back());
            cout << (ans += ad.back()) << "\n";
        }else{
            cout << (ans -= ad.back()) << "\n";
            info[cur + MAX_N].pop_back();
            if(vec.back() == 0){
                --cur;
            }else{
                ++cur;
            }
            vec.pop_back();
            ad.pop_back();
        }
        // show("END");
        // show(cur);
    }
}



Measured memory_bytes: 20328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int r,d,x;cin>>r>>d>>x;
    rep(i,10){
        x = r*x -d;
        co(x);
    }
}


Measured memory_bytes: 256
from sys import stdin

def solve_howmany_trucks(P):
    '''
    トラックの数がk、最大積載量がPのとき荷物を載せきれるかを判定する
    '''
    truck = 1
    temp_weight = 0
    for a,b in enumerate(w):
        if b > P:
            return False
        if temp_weight + b > P:
            # print(f"P = {P} truck No {truck} temp_weight {temp_weight+b}")
            truck += 1
            if truck > k:
                return False
            temp_weight = b
        else:
            temp_weight += b

    return True



n,k = input().split()
n = int(n)
k = int(k)

w = [int(input()) for a in range(n)]

min_P = 10000*100000
left = 0
right = min_P
while left != right:
    middle = int((left+right)/2)
    if solve_howmany_trucks(middle):
        right = middle
    else:
        left = middle+1
print(left)



Measured memory_bytes: 9576
#include <stdio.h>
#include <stdlib.h>

int main(void){

	int *a, *b, *c;
	int n, i;

	scanf("%d", &n);
	a = (int *)malloc(n * sizeof(int));
	b = (int *)malloc(n * sizeof(int));
	c = (int *)malloc(n * sizeof(int));

	for(i = 0; i < n; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]);
	for(i = 0; i < n; i++){
		if((a[i] * a[i] + b[i] * b[i] == c[i] * c[i]) ||
		   (c[i] * c[i] + a[i] * a[i] == b[i] * b[i]) ||
		   (b[i] * b[i] + c[i] * c[i] == a[i] * a[i])) 
		   printf("YES\n");
		else printf("NO\n");
	}

	free(a);
	free(b);
	free(c);

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>

const double pi = 3.141592653589793;

int main()
{
	double hourlong,minutelong,hour,minute;
	scanf("%lf %lf %lf %lf",&hourlong,&minutelong,&hour,&minute);
	double hourangle,minuteangle;
	hourangle = hour*30 + minute/2;
	minuteangle = minute * 6;
	double delta;
	delta = abs(hourangle - minuteangle);
	if(delta > 180)
	{
		delta = 360 - delta;
	}
	//printf("%.10lf",delta);
	double result;
	result = sqrt(hourlong*hourlong + minutelong* minutelong - 2 * hourlong * minutelong * cos(pi*2*(delta/360)));
	printf("%.11f",result);
	return 0;
}


Measured memory_bytes: 3612
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto x = readln.chomp.to!int;
  auto res = (x / 500) * 1000;
  res += ((x % 500) / 5) * 5;
  res.writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7; // 998244353
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	string s; cin >> s;
	bool flg1 = false;
	bool flg2 = false;
	REP(i, s.size()) {
		if (s[i] == 'C' && !flg1) flg1 = true;
		if (s[i] == 'F' && flg1) flg2 = true;
	}
	Yn(flg2);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  long long N,K,X,Y;
  cin>>N>>K>>X>>Y;
  if (N<=K){
    cout<<X*N<<endl;
    return 0;
  }
  cout<<(N-K)*Y+X*K<<endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;


int main() {

	int h,w;
	cin >> h >> w;
	vs s(h);
	rep(i, h)cin >> s[i];

	int ans = 0;

	rep(sy, h)rep(sx, w){
		if (s[sy][sx] == '#') continue;

		vvi dist(h, vi(w, INF));

		queue<pair<int, int>> q;
		q.push(make_pair(sy, sx));
		
		dist[sy][sx] = 0;

		while (!q.empty()) {
			int y = q.front().first;
			int x = q.front().second;
			q.pop();

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

			rep(i, 4) {
				int ey = y + dy[i], ex = x + dx[i];
				if (ey < 0 || h <= ey || ex < 0 || w <= ex)continue;
				if (s[ey][ex] == '.' && dist[ey][ex] == INF) {
					dist[ey][ex] = dist[y][x] + 1;
					q.push(make_pair(ey, ex));
				}
			}
		}

		rep(i, h)rep(j, w) {
			if (dist[i][j] != INF)ans = max(ans, dist[i][j]);
		}

	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    string s;
    cin >> s;

    ll q;
    cin >> q;

    vector<set<ll>> pos(26, set<ll>({INF}));

    rep(i, s.size()){
        pos[s[i]-'a'].insert(i);
    }

    vector<int> ans;

    rep(i, q){
        int type;
        cin >> type;
        if(type == 1){
            ll i;
            char c;
            cin >> i >> c;
            i--;

            pos[s[i]-'a'].erase(i);
            pos[c-'a'].insert(i);

            s[i] = c;
        }
        else {
            ll l, r;
            cin >> l >> r;
            l--;
            
            int cnt = 0;

            rep(i, 26){
                if(pos[i].empty())continue;
                ll l_lower = *pos[i].lower_bound(l);
                ll r_lower = *pos[i].lower_bound(r);
                
                if(r_lower > l_lower)cnt++;
            }

            ans.push_back(cnt);
        }
    }

    rep(i, ans.size())cout << ans[i] << endl;
}

Measured memory_bytes: 24452
n = gets.to_i
robots = []
n.times do
  xl = gets.split(" ").map(&:to_i)
  robots.push(xl)
end

ranges = robots
         .map {|r| [r[0] - r[1], r[0] + r[1]] }
         .sort {|a, b| a[1] <=> b[1] }

pos = -1.0 / 0
count = 0
ranges.each do |r1|
  if r1[0] >= pos
    count += 1
    pos = r1[1]
  end
end

puts count

Measured memory_bytes: 13688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int a,b,c;
  cin>>a>>b;
  c=b;
  if(a==1){
    cout<<b;
    return 0;
  }
b--;
  a--;
  while(a>0){
  c*=b;
    a--;
  }
  cout<<c;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vector<int> vw(f + 1, false);
  for (int i = 0; i < 31; ++i) {
    for (int j = 0; j < 31; ++j) {
      int w = 100 * i * a + 100 * j * b;
      if (w < vw.size()) {
        vw[w] = true;
      }
    }
  }

  vector<bool> vs(f + 1, false);
  for (int i = 0; i < 3001; ++i) {
    for (int j = 0; j < 3001; ++j) {
      int s = i * c + j * d;
      if (s < vs.size()) {
        vs[s] = true;
      }
    }
  }

  double ans = -1, ans_w = 0, ans_s = 0;
  for (int w = 100; w < vw.size(); w += 100) {
    for (int s = 0; s < vs.size(); s++) {
      if (!vw[w] || !vs[s]) {
        continue;
      }

      if (w + s > f || w / 100 * e < s) {
        continue;
      }

      double conc = (s * 100.0) / (w + s);
      if (conc > ans) {
        ans = conc;
        ans_w = w;
        ans_s = s;
      }
    }
  }

  cout << ans_s + ans_w << ' ' << ans_s << '\n';
}

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

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  if(s.size()==1) {
    cout << s << endl;
    return 0;
  }
  vector<string> vec;
  rep(i,s.size())for(int j = 1; j<=5 && i+j<=s.size(); j++) {
    string t;
    t = s.substr(i,j);
    vec.push_back(t);
  }
  sort(vec.begin(),vec.end());
  int cnt = 1;
  rep(i,vec.size()-1) {
    if(vec.at(i) != vec.at(i+1)) cnt++;
    if(cnt == k) {
      cout << vec.at(i+1) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1660
#include <cstdio>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

template <class RandomIt, class T>
size_t num_windows(RandomIt first, RandomIt last, T ub) {
    size_t num=0;
    T sum=0;
    for (RandomIt begin=first, end=first; end<last; ++end) {
        sum += *end;
        while (sum > ub) {
            sum -= *begin;
            ++begin;
        }
        ++num += end-begin;
    }
    return num;
}

int main() {
    size_t N, Q;
    scanf("%zu %zu", &N, &Q);

    vector<long long> a(N);
    for (size_t i=0; i<N; ++i)
        scanf("%lld", &a[i]);

    for (size_t i=0; i<Q; ++i) {
        long long x;
        scanf("%lld", &x);
        printf("%zd\n", num_windows(a.begin(), a.end(), x));
    }

    return 0;
}

Measured memory_bytes: 3236
N = int(input())
a = list(map(int, input().split()))

# s[i] = sum(a[:i])
s = [0]*(N+1)
for i in range(N):
    s[i+1] = s[i]+a[i]

# [i:j) のスライムを合体させるのに必要な最小のコスト
dp = [[10**(18)]*(N+1) for _ in range(N+1)]
for i in range(N):
    dp[i][i+1] = 0
for l in range(2, N+1):
    for i in range(N-l+1):
        j = i+l
        for k in range(i, j):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j] + s[j]-s[i])

print(dp[0][N])

Measured memory_bytes: 43756
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n;
    cin >> n;
    double x1, y1, x2, y2, x3, y3, x4, y4;
    for(int i = 0; i < n; i++){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        double a,b;
        a = 10000.0;
        b = 10000.0;
        if(x1 != x2){
            a = (y2 - y1) / (x2 - x1);
        }
        if(x3 != x4){
            b = (y4 - y3) / (x4 - x3);
        }
        if(fabs(b - a) < 0.0000000001){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()

int main(){
	string S;cin>>S;
	bool flag=false;
	rep(i,0,3){
		if(S.at(i)==S.at(i+1)){
			flag=true;
		}
	}if(flag){
		cout<<"Bad"<<endl;
	}else{
		cout<<"Good"<<endl;
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
	string s;
	cin >> s;
	int n;
	int i = 0;
	if (s == "RRR") {
		cout << 3 << endl;
	}
	if (s == "SRR"||s=="RRS") {
		cout << 2<< endl;
	}
	if (s == "SRS" || s == "RSS" || s == "SSR"||s=="RSR") {
		cout << 1 << endl;
	}
	if (s == "SSS"){
		cout<<0<<endl;
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(void)
{
  int N;
  string S;

  cin >> N >> S;

  ll r, g, b;
  r = g = b = 0;

  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') r++;
    if (S[i] == 'G') g++;
    if (S[i] == 'B') b++;
  }

  ll n1 = r * g * b;
  ll n2 = 0;
  for (ll i = 0; i < N; i++) {
    for (ll j = i + 1; j < N; j++) {
      ll k = 2 * j - i;
      if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i] && k < N) {
        n2++;
      }
    }
  }

  ll ans = n1 - n2;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

int main(){
  int n=0,i=0,j=0;
  char s[3];
  cin >> s[0] >> s[1] >> s[2];
  sort(s,s+3);
  if(s[0]=='a' && s[1]=='b' && s[2]=='c')cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;

	map<string, int> cnt;
	string S;

	rep(i, N) {
		cin >> S;
		cnt[S]++;
	}

	cout << "AC x " << cnt["AC"] << endl;
	cout << "WA x " << cnt["WA"] << endl;
	cout << "TLE x " << cnt["TLE"] << endl;
	cout << "RE x " << cnt["RE"] << endl;



	return 0;
}


Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    ll ans=0,p=-1,n=s.size()+1;
    vector<ll> a(n,0);
    rep(i,n-1){
        if(s[i]=='<'){
            a[i]=p+1; p++;
        }
        else{
            a[i]=p+1; p=-1;
        }
    }
    if(s[n-2]=='<') a[n-1]=p+1;
    p=-1;
    rep(i,n-1){
        if(s[n-2-i]=='>'){
            a[n-1-i]=max(a[n-1-i],p+1); p++;
        }
        else{
            a[n-1-i]=max(a[n-1-i],p+1); p=-1;
        }
    }
    if(s[0]=='>') a[0]=p+1;
    rep(i,n) ans+=a[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 4740
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
string S;
int main(){
	cin>>S;
	int R=0;
	string A,B;
	for(int i=0; i<S.size(); i++){
		R+=1;
		B=S[i];
	}
	A=S[0];



	cout<<A<<R-2<<B<<endl;
	return 0;
}



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

//region Template

typedef long long ll;
typedef long double ld;
const ll inf = 1ll << 50;

using namespace std;
#define finish(x) return cout << x, 0;
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

const string USCAO_TAG = "nocows";
void usaco() { setIn(USCAO_TAG + ".in"); setOut(USCAO_TAG + ".out"); }


template<typename... Args>
void print(Args... args) {
  #ifdef LOCAL
  ((std::cout << args << " "), ...);
  cout << endl;
  #endif
}
//endregion

/* Notes:
 * This is probably wrong.
 */

ll d[2501];

vector<pair<int, int>> adj;
int cost[5001];
vector<vector<int>> edj;

bool v[2501];

ll mn = 1e15;
void dfs(int node){
  if(v[node]) return;

  v[node] = 1;

  //mn = min(mn, d[node]);
  for(auto x : edj[node]){
    dfs(x);
  }
}

int main() {
  //setIn("input.txt");
  //setOut("output.txt");

  int n, m, p;
  cin >> n >> m >> p;

  edj.assign(n + 1, vector<int>());

  for(int i = 0; i < m; i++){
    int a, b, c;
    cin >> a >> b >> c;

    adj.push_back({a, b});
    edj[b].push_back(a);

    cost[i] = -(c - p);
  }

  for(int i = 1; i <= n; i++){
    d[i] = inf;
  }
  d[1] = 0;

  bool f;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(d[adj[j].first] < inf){
        d[adj[j].second] = min(d[adj[j].second], d[adj[j].first] + cost[j]);
      }
    }
  }

  dfs(n);
  mn = d[n];

  f = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      if(d[adj[j].first] < inf){
        if(d[adj[j].first] + cost[j] < d[adj[j].second] && v[adj[j].first]){
          f = 1;
        }
        d[adj[j].second] = min(d[adj[j].second], d[adj[j].first] + cost[j]);
      }
    }
  }

  if(f){
    finish(-1);
  }
  else{
    if(mn > 0){
      finish(0);
    }
    finish(-mn);
  }
}


Measured memory_bytes: 512
import datetime

while 1:
    data = list(map(int, input().split()))
    if data[0] < 0:
        break

    first = datetime.date(data[0], data[1], data[2])
    second = datetime.date(data[3], data[4], data[5])
    diff = (second - first).days
    print(diff)



Measured memory_bytes: 6036
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int32_t main() {
    fastio
    ll a, b, n;
    cin>>a>>b>>n;
    ll x = min(n, b-1);

    cout<<(a*(x)/b)<<endl;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> a;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    double sum = 0;
    for(auto i : a) sum += 1.0/i;
    cout << 1/sum << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
x = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: -x[1])
y = sorted([list(map(int, input().split())) for _ in range(N)])

cnt = 0
for c, d in y:
  for a, b in x:
    if a < c and b < d:
      x.remove([a, b])
      cnt += 1
      break

print(cnt)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

string s,t;
vector<vector<ll>> dp;

int input(){
  cin >> s;
  cin >> t;
}

int main()
{
  input();
  REP(i,3001){
    auto v = vector<ll>();
    REP(j,3001) v.push_back(0);
    dp.push_back(v);
  }
  
  ll ns=s.size();
  ll nt=t.size();
  
  FOR(i,1,ns+1){
    FOR(j,1,nt+1){
      if (  s[i-1] == t[j-1] ){
        dp[i][j] = dp[i-1][j-1] + 1;
      }else{
        dp[i][j] = max( dp[i][j-1] , dp[i-1][j] );
      }
    }
  }
 cout << endl;
 //REP(i,ns+1){REP(j,nt+1){cout << dp[i][j] << ",";}cout << endl;}
  
ll x=ns,y=nt;
ll ndp = dp[x][y];
string f;
while( x > 0 & y > 0 ){
  //cout << x << "," << y << endl;
  if ( ndp-1 == dp[x-1][y-1] and s[x-1]==t[y-1] ){
    x-=1; y-=1; ndp-=1;
    f = s[x] + f;
  }else if(ndp == dp[x-1][y]){
    x-=1;
  }else{
    y-=1;
  }
}
  //cout << s << endl;
  //cout << t << endl;
  cout << f << endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 1, n, k, counter = 0, w, h;
string s;
char c;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
map<ll, string> mp;
/*--------------------template--------------------*/

int main() {
	int x, y, z, count = 0;
	cin >> n >> k;
	for (x = 0; x <= n; x++) {
		for (y = 0; y <= n; y++) {
			z = k - x - y;
			if (0 <= z && z <= n) {
				count++;
			}
		}
	}
	cout << count << endl;
}

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

void fnInput(string& rsColor)
{
  cin >> rsColor;
}

int fnChangeCnt(string sBgnColor, string sColor)
{
  int nChangeCnt = 0;

  for (int i = 0; i < sColor.size(); i++)
  {
    int n = i % 2;
    if (sColor[i] != sBgnColor[n]) nChangeCnt++;
  }
  return nChangeCnt;
}

int fnMinChangeCnt(string sColor)
{
  int nMinChangeCnt = INT_MAX;
  nMinChangeCnt = min(nMinChangeCnt, fnChangeCnt("01", sColor));
  nMinChangeCnt = min(nMinChangeCnt, fnChangeCnt("10", sColor));

  return nMinChangeCnt;
}
 
int main()
{
  string sColor;
  fnInput(sColor);
  cout << fnMinChangeCnt(sColor) << endl;

  return 0;
}

Measured memory_bytes: 3836
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
A, B = map(int, input().split())
if em: sys.stdin = open('/dev/tty')
print(max(A+B, A-B, A*B))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	if (s.at(k - 1) == 'A') s.at(k - 1) = 'a';
	else if (s.at(k - 1) == 'B') s.at(k - 1) = 'b';
	else s.at(k - 1) = 'c';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	int A[100010];
	int B[100010];

	for (int i = 1; i <= N; i++) {
		B[i] = K - Q;
	}
	for (int i = 1; i <= Q; i++) {
		cin >> A[i];
		B[A[i]]++;
	}

	for (int i = 1; i <= N; i++) {
		if (B[i] > 0)cout << "Yes";
		else cout << "No";
		cout << endl;
	}
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
    int x, y;
    int i;
 
    for (;;) {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0) break;
        if (x > y){
            i = x;
            x = y;
            y = i;
        }
        
        printf("%d %d\n", x, y);
    }
    return 0;
}


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

using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define ll long long
#define fi first
#define se second
const int N = 1e6+5;
const int p = 1e9+7;

int a[N];
int cnt[N];
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    int ans=1e5;
    for(int i=1;i<=n;i+=2)cnt[a[i]]++;
    vector<pair<int,int> >v,v1;
    for(int i=1;i<=1e5;i++){
        if(cnt[i]){
            v.pb({cnt[i],i});
        }
    }
    memset(cnt,0,sizeof(cnt));
    for(int i=2;i<=n;i+=2)cnt[a[i]]++;
    for(int i=1;i<=1e5;i++){
        if(cnt[i]){
            v1.pb({cnt[i],i});
        }
    }
    sort(v.begin(),v.end());
    sort(v1.begin(),v1.end());
    int len1=sz(v),len2=sz(v1);

    if(v[len1-1].se!=v1[len2-1].se)ans=n-v[len1-1].fi-v1[len2-1].fi;
    else{
        if(len1==1){
            ans=min(ans,n-v1[len2-1].fi);
        }else{
            ans=min(ans,n-v1[len2-1].fi-v[len1-2].fi);
        }
        if(len2==1){
            ans=min(ans,n-v[len1-1].fi);
        }else{
            ans=min(ans,n-v[len1-1].fi-v1[len2-2].fi);
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int f(int x, int m = -1){
    int k = lower_bound(r.begin(), r.end(), a.at(x)) - r.begin();
    int ma = r.at(k);
    r.at(k) = a.at(x);
    int ak = lower_bound(r.begin(), r.end(), 1000000001) - r.begin();
    ans.at(x) = ak-1;
    rep(i, g.at(x).size()){
        if(g.at(x).at(i) == m) continue;
        f(g.at(x).at(i), x);
    }
    r.at(k) = ma;
    return 0;
}

int main(){
    int in0, in1;
    cin >> n;
    g = vector<vector<int>>(n, vector<int>(0));
    a = vector<int>(n);
    ans = vector<int>(n);
    r = vector<int>(n+2);
    rep(i, n) cin >> a.at(i);
    rep(i, n+2) r.at(i) = 1000000001;
    r.at(0) = -1;
    rep(i, n-1){
        cin >> in0 >> in1;
        in0--; in1--;
        g.at(in0).push_back(in1);
        g.at(in1).push_back(in0);
    }
    f(0);
    rep(i, n) cout << ans.at(i) << endl;
    return 0;
}

Measured memory_bytes: 30780
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <algorithm>
using namespace std;

char bt[10][10];
char ne[10][10];
bool dn[10][10];
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int W,H;


void chg(int x,int y,char a,char b){
	if( x < 0 || x >= W || y < 0 || y >= H || bt[y][x] != b || dn[y][x]) return;
	dn[y][x] = true;
	ne[y][x] = a;
	for(int i = 0 ; i < 4 ; i++){
		chg(x+dx[i],y+dy[i],a,b);
	}
}

int ans = 0;
int dfs(int r){
	if( r >= ans ){
		//cout << r << endl;
		return 0;
	}
	int f = true;

	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			if(bt[i][j] != bt[0][0]){
				f = false;
				goto en;
			}
		}
	}
	en:;
	
	if( f ){
		ans = r;
		return 0;
	}
	char tmp[10][10];
	bool prev[10][10];
	memcpy(prev,dn,sizeof(dn));
	memcpy(tmp,bt,sizeof(tmp));
	for(int i = 0 ; i < 3 ; i++){
		memcpy(ne,bt,sizeof(ne));
		memset(dn,0,sizeof(dn));
		int f = false;
		if( "RGB"[i] != bt[0][0] ){
			chg(0,0,"RGB"[i],bt[0][0]);
			for(int i = 0 ; i < H ; i++){
				for(int j = 0 ; j < W ; j++)
				if(prev[i][j] != dn[i][j]) f = true;
			}
			memcpy(bt,ne,sizeof(ne));
			if(f)dfs(r+1);
			memcpy(bt,tmp,sizeof(tmp));	
		}
	}
}
int main(){
	int n;
	while(cin >> W >> H && W){	
		memset(dn,0,sizeof(dn));
		
		for(int i = 0 ; i < H ; i++)
			for(int j = 0 ; j < W ; j++)
				cin >> bt[i][j];
		ans = 1e7;
		dfs(0);
		cout << ans << endl;
	}
	
}

Measured memory_bytes: 876
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,p;
    cin>>s>>p;
    s+=s;
    auto pos=s.find(p);
    if(pos==string::npos){
	cout<<"No"<<'\n';
    }
    else{
	cout<<"Yes"<<'\n';
    }
    return(0);
}



Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define PI 3.1415926535897932L
#define QRT_PI 15.707963267948966L
typedef long long ll;
typedef pair<ll, ll> P;

const int MAX_N = 2e5;
const int INF = 1e9;

vector<P> arr;
ll dp[MAX_N];

int main(void)
{
    cin.sync_with_stdio(false); cin.tie(NULL);
    ll x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
    ll vx, vy;

    if (y1 > y2)
    {
        swap(x1, x2);
        swap(y1, y2);
    }

    bool rev = x1 > x2;
    int N;  cin >> N;

    if (rev)
        swap(x1, x2);
    for (int i = 0; i < N; i ++)
    {
        cin >> vx >> vy;

        if (x1 <= vx && vx <= x2 && y1 <= vy && vy <= y2)
            arr.emplace_back(vx, vy);
    }
    /*
    if (rev)
        swap(x1, x2);
    */

    fill(dp, dp + arr.size(), INF);
    sort(arr.begin(), arr.end(), [rev](auto& a, auto& b)
            {
                if (rev)
                    return a.first > b.first;
                else
                    return a.first < b.first;
            });

    for (int i = 0; i < arr.size(); i ++)
        *lower_bound(dp, dp + arr.size(), arr[i].second) = arr[i].second;

    ll cnt = lower_bound(dp, dp + arr.size(), INF) - dp;
    double res = 100*(abs(x1-x2)+abs(y1-y2)) + cnt*(QRT_PI - 20);

    if (cnt-1 == min(x2-x1, y2-y1))
        res += QRT_PI;


    printf("%.15lf\n", res);

}


Measured memory_bytes: 6512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;

int N;
int A, B;
vi v;
int comb[55][55];

void init()
{
	comb[0][0] = 1;
	for (int i = 1; i <= 50; ++i) {
		comb[i][0] = 1;
		for (int j = 1; j <= 50; ++j) {
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
}

signed main()
{
	cin >> N >> A >> B;
	v.resize(N);

	init();

	map<int, int> counter;
	
	rep(i, N) {
		cin >> v[i];
		counter[v[i]]++;
	}
	sort(all(v));

	int S = -1;
	int div = -1;

	for (int i = A; i <= B; ++i) {
		int sum = 0;
		for (int j = 0; j < i; ++j) {
			sum += v[N - 1 - j];
		}
		if (S * i < sum) {
			S = sum;
			div = i;
		}
	}

	int ans = 0;
	map<int, int> uses;

	for (int i = A; i <= B; ++i) {
		uses.clear();

		int s = 0;
		for (int j = 0; j < i; ++j) {
			s += v[N - 1 - j];
			uses[v[N - 1 - j]]++;
		}

		if (S * i == s * div) {
			int add = 1;
			for (pii a : uses) {
				add *= comb[counter[a.fst]][uses[a.fst]];
			}

			ans += add;
		}
	}

	printf("%.10Lf\n", (ld)S / div);
	printf("%lld\n", ans);
}



Measured memory_bytes: 384
def main():
    a, b = map(int, input().split())
    if a == 1:
        a = 14
    if b == 1:
        b = 14

    if a > b:
        print('Alice')
    elif a < b:
        print('Bob')
    else:
        print('Draw')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940