akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a);
  vector<ll> q(b);
  vector<ll> r(c);
  for(int i = 0; i < a; i++){
    cin >> p[i];
  }
  for(int i = 0; i < b; i++){
    cin >> q[i];
  }
  for(int i = 0; i < c; i++){
    cin >> r[i];
  }
  sort(p.begin(), p.end(), greater<long long>());
  sort(q.begin(), q.end(), greater<long long>());
  vector<ll> sel(x+y+c);
  for(int i = 0; i < x; i++){
    sel[i] = p[i];
  }
  for(int i = 0; i < y; i++){
    sel[i+x] = q[i];
  }
  for(int i = 0; i < c; i++){
    sel[i+x+y] = r[i];
  }

  sort(sel.begin(), sel.end(), greater<long long>());

  ll ans = 0;
  for(int i = 0; i < x+y; i++){
    ans += sel[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4736
void main()
{
    int[] tmp = readln.split.to!(int[]);
    int m1 = tmp[0], d1 = tmp[1];

    tmp = readln.split.to!(int[]);
    int m2 = tmp[0], d2 = tmp[1];

    writeln(m1 != m2 && d1 > d2 ? 1 : 0);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
import java.util.Scanner;


public class  Main {

	static Scanner sc = new Scanner(System.in);
	
	static double v;
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		if(!sc.hasNext()) return false;
		
		v = sc.nextDouble();
		
		return true;
	}
	
	static void solve(){
		
		int N=0;
		double t, y, height;
		
		t = v / 9.8;
		y = 4.9 * Math.pow(t, 2.0);
		
		do{
			N++;
			height = 5 * (double)N - 5;
		}while(height < y);
		
		System.out.println(N);
	}

}

Measured memory_bytes: 18676
import sys

l = []
for i in range(5):
    l.append(int(input()))
k = int(input())

for i in range(5):
    # print("------------------")
    # print("i: "+str(i))
    for j in range(i+1, 5):
        # print("j: "+str(j))
        if l[j] - l[i] > k:
            print(":(")
            sys.exit()
print("Yay!")

"""
0 1234
1 234
2 34
3 4
"""

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

int main() {
    string str, tempA, tempB, temp;
    int number, times, strSize;
    while (true) {
        cin >> str;
        if (str == "-") {
            break;
        }
        cin >> times;
        strSize = str.size();
        temp = str;
        for (int i = 0; i < times; i++) {
            cin >> number;
            tempA = temp.substr(number);
            tempB = temp.substr(0, number);
            temp = tempA + tempB;
        }
        cout << temp << endl;
    }
    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define int long long
#define FLASH                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int modulo(int a, int b, int mod)
{
    int an = 1;
    while (b != 0)
    {
        if ((b % 2) == 1)
        {
            an = (an * a) % mod;
        }
        a = (a * a) % mod;
        b /= 2;
    }
    return an;
}

const int BMAX = 200000;
const int MOD = 1000000007;
int inv[200005];

void inv_init()
{
    inv[1] = 1LL;
    for (int i = 2; i <= BMAX; i++)
    {
        inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
    }
    return;
}

int COMB(int n, int a)
{
    if (n < a)
        return 0LL;
    if (n < 0 || a < 0)
        return 0LL;

    int rtn = 1;
    for (int i = 0; i < a; i++)
    {
        rtn *= n - i;
        rtn %= MOD;
        rtn *= inv[i + 1];
        rtn %= MOD;
    }
    return rtn;
}

signed main()
{
    int n, a, b;
    cin >> n >> a >> b;
    inv_init();
    int ans = modulo(2, n, MOD) - 1;
    ans += MOD - COMB(n, b);
    ans += MOD - COMB(n, a);
    ans %= MOD;
    cout << ans;
    return 0;
}

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

const long long INF = 1LL << 60;

int main(){
    int N,K;
    cin >> N >> K;
    vector<long long> h(N + K,0);
    for(int i = 0;i < N;i++) cin >> h[i];
    vector<long long> dp(N + K,INF);
    dp[0] = 0;
    for(int i = 0;i < N;i++){
        for(int j = 1;j <= K;j++){
            dp[i+j] = min(dp[i+j],dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[N-1] << endl;
}

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

Measured memory_bytes: 256
A, *BCD = map(int, input())
for bit in range(1 << 3):
    tmp = A
    formula = [A]
    for op, n in enumerate(BCD):
        if bit >> op & 1:
            tmp += n
            formula.append('+')
        else:
            tmp -= n
            formula.append('-')
        formula.append(n)
    if tmp == 7:
        formula.append('=7')
        print(*map(str, formula), sep='')
        break


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


def main():
    N = int(input())
    if int(str(N)[-1]) in [2,4,5,7,9]:
        print('hon')
    elif int(str(N)[-1]) in [0,1,6,8]:
        print('pon')
    else:
        print('bon')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9080
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        h:usize,
        w:usize,
        k:usize,
        c:[chars;h],
    }

    let mut ans = 0;
    for mask_r in 0..(1 << h) {
        for mask_c in 0..(1 << w) {
            let mut black = 0;

            for hi in 0..h {
                for wi in 0..w {
                    if (mask_r >> hi & 1) == 0 && (mask_c >> wi & 1) == 0 && c[hi][wi] == '#' {
                        black += 1;
                    }
                }
            }
            if black == k {
                ans += 1;
            }
        }
    }
    ans.to_string()
}
test! {
    include_str!("c1_in.txt") => "5",
    include_str!("c2_in.txt") => "1",
    include_str!("c3_in.txt") => "0",
}


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

using namespace std;
using ll = long long;

const ll maxn = 1e12+10;

void solve(){
	ll h,qtd,tot=0;
	cin >> h;
	vector<ll> ans,pot;
	for(ll j=0,i=1;i<=maxn;i*=2,++j){
		ans.push_back(tot+i);
		pot.push_back(i);
		tot+=i;
		//cout << "ans[j] = " << ans[j] << " pot[j] = " << pot[j] << '\n';
	}
	auto it = lower_bound(pot.begin(),pot.end(),h);
	//cout << "it = " << *it << '\n';
	if(*it == h){
		cout << ans[it-pot.begin()] << '\n';
	}
	else{
		cout << ans[it-pot.begin()-1] << '\n';
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define JD



int main(int argv, char* argc[])
{
    FASTIO

    #ifndef JD
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif


    int n,k;
    cin>>n>>k;
    vii v(n);
    rep(i,n)
    cin>>v[i];
    sort(all(v));
    int sum=0;
    rep(i,k)
    sum+=v[i];
    cout<<sum;




    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, c, k;
    cin >> n >> c >> k;

    ll t[n];
    rep(i, 0, n){
        cin >> t[i];
    }

    sort(t, t + n);
    ll count = 1;
    ll time = t[0];
    ll num = 1;
    rep(i, 1, n){
        if(t[i] <= time + k && num < c){
            num++;
        }else{
            time = t[i];
            num = 1;
            count++;
        }
    }

    cout << count << endl;
    return 0;
}


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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n, m;
        cin >> n >> m;

        vector<long> a(n);
        for (auto &x : a) cin >> x;

        set<long> s;
        while (m--) {
            long u, v;
            cin >> u >> v;

            if (a[u-1] <= a[v-1]) s.insert(u);
            if (a[v-1] <= a[u-1]) s.insert(v);
        }
        long ans = n - s.size();
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 6588
#include<bits/stdc++.h>
#include<iomanip>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define pb push_back

#define endl "\n"

using namespace std;



int main()
{
    ll n;string a;
    cin>>a;
    cin>>n;
    ll count=0;
    ll c=1;ll f=0;
    
    for(ll i=0;i<a.length()-1;i++)
    {
        if(a[i]==a[i+1])
        {
            c++;
        }
        else
        {
            count+=c/2;
            c=1;
        }
    }ll d=1;
    for(ll i=0;i<a.length();i++)
    {
        if(a[i]==a[i+1])
        {
            d++;
        }
        else break;
    }
    ll dd=1;
  for(ll i=a.length()-1;i>0;i--)
  {
  if(a[i]==a[i-1])
  {
      dd++;
      
  }
    else break;
  }
    if(c==a.length()&&a.length()%2!=0)
    {
    cout<<(a.length()*n)/2;
    }
    else if(a[0]==a[a.length()-1])
    {
        count+=c/2;
        count=count*n+(n-1)*(((d+dd)/2)-(d/2)-(dd/2));
        cout<<count<<endl;
    }
    else
    {
        count+=c/2;
        cout<<(count*n);
    }
        return 0;
    
}



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

int main()
{
    char c;
    cin >> c;
    switch(c){
        case 'a':
            cout << "vowel" << endl;
            break;
        case 'i':
            cout << "vowel" << endl;
            break;
        case 'u':
            cout << "vowel" << endl;
            break;
        case 'e':
            cout << "vowel" << endl;
            break;
        case 'o':
            cout << "vowel" << endl;
            break;
        default:
            cout << "consonant" << endl;
            break;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int n, m,k,a,b;
    int maxcnt = 0;
    cin >> n >> m >> k;
    vector<ll>booka, bookb;
    vector<ll>bookasum(n+1,0), bookbsum(m+1,0);
    rep(i, n) {
        cin >> a;
        booka.push_back(a);
        bookasum[i + 1] = a + bookasum[i];
    }

    rep(i, m) {
        cin >> b;
        bookb.push_back(b);
        bookbsum[i + 1] = b + bookbsum[i];
    }
    for (int i = 0;i <= n && bookasum[i] <= k;i++) {
        auto itr = upper_bound(all(bookbsum), k - bookasum[i]);
        if (bookbsum.begin() != itr)itr--;
        maxcnt = max(maxcnt, int(i + itr - bookbsum.begin()));
    }

    cout << maxcnt << endl;
    return 0;

}


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

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

    string dow[7] = {"sat","sun","mon","tue","wed","thu","fri"};

    int s = abs(x-9);
    s = s%7;

    if(x>=9){
        cout << dow[s] << endl;
    }else{
        if(s==0){
            cout << dow[0] << endl;
        }else{
            cout << dow[7-s] << endl;
        }
    }
}


Measured memory_bytes: 3196
n = int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]

xyh.sort(key=lambda x: x[2], reverse=True)

before = 0
cnt = 0

for cx in range(101):
    for cy in range(101):
        for x,y,h in xyh:
            if cnt ==0:
                height = abs(cx-x)+abs(cy-y)+h
            
            if h != max(height-abs(cx-x)-abs(cy-y), 0):
                cnt = 0
                break

            cnt += 1
            if cnt == n:
                print(cx,cy,height)
                exit()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
    
    public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] s = br.readLine().split(" ",0);
	int A = Integer.parseInt(s[0]);
	int B = Integer.parseInt(s[1]);
	int C = Integer.parseInt(s[2]);
	int D = Integer.parseInt(s[3]);
	int mensekia,mensekic;
	mensekia = A * B;
	mensekic = C * D;
	if(mensekia == mensekic){
	    System.out.println(mensekia);
	}
	else if(mensekia > mensekic){
	    System.out.println(mensekia);
	}
	else{	    
	    System.out.println(mensekic);
	}
    }
}


Measured memory_bytes: 8272
n = int(input())
arms = [input().split(' ') for _ in range(n)]
for a in arms:
    for i in range(2):
        a[i] = int(a[i])
arms.sort(key=lambda x:x[0])
res = []
for x, l in arms:
    left, right = x - l, x + l
    if not res or res[-1]  <= left:
        res.append(right)
    elif res[-1] > right:
        res[-1] = right
print(len(res))

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n,k,ans=0,temp;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n>>k;
    rep(i,1,n)
    {
        cin>>temp;
        if(temp>=k)
            ans++;
    }
    cout<<ans;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

//方針
//前からずっとシミュレーションして、
int main()
{
  int n;
  cin>>n;
  vector<int> a,b;
  rep(i,n){
      int c;
      cin>>c;
      a.push_back(c);
  }
  rep(i,n){
      int c;
      cin>>c;
      b.push_back(c);
  }
  int result=0;
  rep(i,n){
      int ans=0;
      rep(j,n){
          if(j<=i) ans+=a[j];
          if(j>=i) ans+=b[j];
          //cout<<ans<<" ";
      }
      //cout<<result<<endl;
      result=max(result,ans);
  }
  cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int sum=0;
  cin >> N;
 for(int i=0; i<N; i++){
    int j,k;
   cin >> j >> k;
   sum+=k-j+1;
}
  	cout << sum <<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
 
vvl G;
vl visited;
vl finished;
vl hist;
 
ll pos = -1;  // サイクルに含まれる頂点pos(-1のときサイクルを含まない)
 
void dfs(ll v) {
    visited[v] = 1;
    hist.pb(v);
    for(auto u : G[v]) {
        if(finished[u]) {
            continue;
        }
        // サイクルを検出
        if(visited[u] && !finished[u]) {
            pos = u;
            return;
        }
        dfs(u);
        if(pos != -1) {
            return;
        }
    }
    hist.pop_back();
    finished[v] = 1;
}
 
int main() {
    ll n, k;
    cin >> n >> k;    
    
    G.resize(n);
    rep(i, n) {
        ll a;
        cin >> a;
        a--;  
        G[i].pb(a);
    }
    
    visited.assign(n, 0);
    finished.assign(n, 0); 
    dfs(0);
    
    // サイクルを復元 
    vl cycle;
    while(!hist.empty()) {
        ll t = hist.back();
        cycle.pb(t);
        hist.pop_back();
        if(t == pos) {
            break;
        }
    }
    reverse(all(cycle));

    ll now = 0;
    ll x = 0;  // 頂点0からサイクルに到達するまでの長さ
    while(now != pos) {
        now = G[now][0];
        x++;
    }
    ll y = cycle.size();  // サイクルの長さ
    
    now = 0;
    if(x < k) {  // k回移動後サイクルに到達するとき
        k -= x;
        k %= y;
        now = pos;
    }
    
    rep(i, k) {
        now = G[now][0];
    }

    out(now+1);
    re0;
}

Measured memory_bytes: 30508
#include<iostream>
using namespace std;
int main(){
   long int N,Y;
   cin>>N>>Y;
   int ans=0;
   long int a=0,b=0,c=0;
   for(long int i=0;i<=N;i++){
      for(long int j=0;j<=N-i;j++){
         if(10000*i+5000*j+1000*(N-i-j)==Y){
            ans=1;
            a=i,b=j,c=N-i-j;
         }
      }
   }
   if(ans==1)cout<<a<<' '<<b<<' '<<c<<endl;
   else cout<<-1<<' '<<-1<<' '<<-1<<endl;
}


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

using namespace std;
using namespace __gnu_cxx;

random_device rd;
mt19937 rnd(rd());
#define pt pair<int, int>
#define x first
#define y second
#define what_is(x) cerr << #x << " is " << x << endl;
#define ok cerr << "ok" << endl;
#define endl '\n'
#define int long long
#define ld long double

signed main()
{
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);

	int a, b, n;
	cin >> a >> b >> n;
	int x = min(n, b - 1);
	cout << floor(a * x / b) - floor(x / b) * a << endl;

	return 0;
}


Measured memory_bytes: 3796
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()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    M=10**6+5
    dp=[1]*M
    A.sort()
    L=[A[0]]
    L2=set([])
    for i in range(1,N):
        if A[i]!=L[-1]:
            L.append(A[i])
        else:
            L2.add(A[i])
            
    for i in range(len(L)):
        temp=L[i]
        if dp[temp]==1:
            temp+=L[i]
            while temp<M:
                dp[temp]=0
                temp+=L[i]
        
    ans=0    
    for i in L2:
        dp[i]=0
        
    for i in range(len(L)):
        if dp[L[i]]==1:
            ans+=1
            
            
    

         
            
    print(ans)
                
    
    


main()


Measured memory_bytes: 104164
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define B       (cout << "Sehen Sie mich!" << endl)
#define VB(val) (cout << val << endl)

int main()
{
        long x, y;
        int res = 1;
        cin >> x >> y;

        while (2 * x <= y) {
                x *= 2;
                res++;
        }

        VB(res);
}

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

int main() {
    int K,X;
    cin >> K >>X;
    for (int i = 0; i < 2*K-1;i ++){
        if (i == 0){
            cout << X-K+1+i;
        }
        else{
            cout <<" "<< X-K+1+i ;
        }
    }
    cout << endl;
}

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

using namespace std;

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b+1>c){
		printf("%d\n",b+c);
		return 0;
	}
	printf("%d\n",a+b+1+b);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int BsearchQ(int A[],int n,int key){
	int l = 0;
	int r = n;
	while(l<r){
		int mid=(l+r)/2;
		if(A[mid]==key){
			return 1;
		}else if(A[mid]<key){
			l=mid+1; 		
		}else {
			r=mid;
		}
		
	}
	return 0;
}

int main() {
	int n,A[100000+5],q,key,sum=0;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d",&key);
		sum+=BsearchQ(A,n,key);
	} 
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 2976
n, m = map(int, input().split())
k = 0

if n > m:
    k = n
    n = m
    m = k

if m > 2 and n > 2:
    print((m-2)*(n-2))

elif n == 1:
    if m == 1:
        print(1)
    else:
        print(m - 2)

elif n == 2:
    print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;




int main()
{
    string s="aeiou";
    char c;
    cin>>c;
    for (int i=0;i<s.length();i++)
    {
        if (c==s[i])
        {
            cout<<"vowel"<<endl;return 0;
        }
    }
    cout<<"consonant"<<endl;

}


Measured memory_bytes: 256
from collections import deque

N,u,v = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

u -= 1; v -= 1

def bfs(s):
    dist = [-1] * N
    prev = [-1] * N
    que = deque([s])
    dist[s] = 0
    while que:
        v = que.popleft()
        for w in edge[v]:
            if dist[w] < 0:
                dist[w] = dist[v] + 1
                prev[w] = v
                que.append(w)
    return dist, prev

takahashi, _ = bfs(u)
aoki, prev = bfs(v)

node = 0
dist = -1
for i,(t,a) in enumerate(zip(takahashi, aoki)):
    if t < a and a > dist:
        dist = a
        node = i

print(aoki[prev[node]])

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

using namespace std;
typedef long long LL;
LL n,a,b,c,d,x,xx,w,i,lb,hb;

int main()
{
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    w=d-c;
    xx=abs(a-b);
    if(n%2){
        i=0;
    }else{
        i=1;
    }
    while(i<n){
        lb=((i-n+1)*d+(n+i-1)*c)/2;
        hb=((i+n-1)*d+(i-n+1)*c)/2;
        if(xx>=lb&&xx<=hb){
                printf("YES");
                exit(0);
        }
        i+=2;
    }
    printf("NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}
void submain();

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

int N; cin >> N;


cout << (N + 1000 -1 )/1000 * 1000 - N << "\n";

return 0;
}

// 制限が緩い場合での愚直解を書く。
void submain(){

}

// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::string s;
	std::cin >> s;
	if (n >= 3200) std::cout << s << std::endl;
	else std::cout << "red" << std::endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();
            int iN = int.Parse(sS);
            sS = Console.ReadLine().Trim();
            int iA = int.Parse(sS);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            if (iN % 500 <= iA) { sOut = "Yes"; }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main()
{
    int X;  cin >> X;
    cout << (2000 - X - 1) / 200 + 1;
}

Measured memory_bytes: 3632
a, b = map(int, input().split())
if a > 0 and b > 0: ans = "Positive"
elif a < 0 and b < 0:
  if (abs(a-b) + 1) % 2 == 0:
    ans = "Positive"
  else:
    ans = "Negative"
else:
  ans = "Zero"
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#define INF 1000000000

using namespace std;

int dist[101][101];
int n, m, a[1001], b[1001], c[1001];

int main() {
  cin >> n >> m;
  for (int j = 0; j < n; j++) for (int i = 0; i < n; i++) {
    if (i == j) dist[j][i] = 0;
    else dist[j][i] = INF;
  }

  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
  }

  for (int k = 0; k < n; k++) for (int j = 0; j < n; j++) for (int i = 0; i < n; i++)
    dist[j][i] = min(dist[j][i], dist[j][k]+dist[k][i]);

  int ans = m;
  for (int i = 0; i < m; i++) {
    bool use = false;
    for (int j = 0; j < n; j++) {
      if (dist[j][a[i]]+c[i] == dist[j][b[i]]) use = true;
    }
    if (use) ans--;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
length = len(S)

def check_palin(s):
    num = len(s)
    for i in range(num // 2):
        if s[i] != s[num - i - 1]:
            return False
    return True

first = S[:(length - 1) // 2]
second = S[(length + 1) // 2:]
#print(first)
#print(second)

if check_palin(S) and check_palin(first) and check_palin(second):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9124
N, M = map(int, input().split())
f = [False] * (N+1)
ac = wa = 0
c = [0] * (N+1)

for i in range(M):
    p, s = input().split()
    p = int(p)
    if f[p]: continue
    
    if s == 'AC':
        f[p] = True
        ac += 1
        wa += c[p]
    else: c[p] += 1
    
print(ac, wa) 

Measured memory_bytes: 4596
using System;
public class Hello{
    public static void Main(){
        // Your code here!
         long a,b;
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            a = long.Parse(str[0]); //標準入力
        
        for(b=a;!prime(b);b++){}
        Console.Write(b);
    }
    public static bool prime(long p){
        for(long i=2;i<=(long)(p/2);i++){
            if(p%i==0)return false;
        }
        return true;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int dig( int n ) {
        int ret = 0;
        while( n ) {
                ret += n%10 , n /= 10;
        }
        return ret;
}
int main( int argc , char const *argv[] ) {
        int n;
        cin >> n;
        if( n%dig(n) == 0 ) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s1,s2,s3,a;
  cin >> s1 >> s2 >> s3;
  a = "ABC";
 
  // ここにプログラムを追記
  a.at(1) = s2.at(0);
  cout <<  a << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  pair<int,int> a[100000];
  int ll,lr,rl,rr;
  ll=lr=rl=rr=0;
  int ans=0;
  int prev=0;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    a[i]=make_pair(x,y);
    if(y==0){
      ll++;
      //ans+=(y-1);
    }
    else{
      rl++;
      //ans-=(y-1);
    }
  }
  sort(a,a+n);
  rep(i,n){
    if(a[i].scd==0){
      //ll++;
      ans+=(a[i].fst-1);
      ans-=i;
    }
    else{
      //rl++;
      ans-=(a[i].fst-1);
      ans+=i;
    }
  }
  //cout<<ans<<endl;
  int now=ans;
  repn(i,n-1){
    if(a[i].scd==0){
      now-=(m-n);
    }
    else{
      now+=(m-n);
    }
    ans=max(ans,now);
  }
  cout<<ans<<endl;


  return 0;
}



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

int main(){
  double N, K;
  double sum = 0;
  cin >> N >> K;
  for(int i = 1; i <= N; i++){
    int x = 0;//指数
    int y = i;
    bool a = true;
    while(a){
      if(y < K){
        y *= 2;
        x++;
      }
      else{
        a = false;
        sum += (1.0/N)*pow((1.0/2.0), x);
      }
    }
  }
  printf("%.12f",sum);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    ll n, m; cin >> n >> m;
    vector<ll> h(n);
    vector<ll> max_h(n);
    rep(i, n){
        cin >> h[i];
        max_h[i] = 0;
    }
    vector<ll> a(m);
    vector<ll> b(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }
    rep(i, m){
        max_h[a[i]] = max(max_h[a[i]], h[b[i]]);
        max_h[b[i]] = max(max_h[b[i]], h[a[i]]);
    }
    ll ans = 0;
    rep(i, n){
        if(h[i] > max_h[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define wtr(a) cout<<(a)<<" "
//#define wtr(a,b) cout<<(a)<<" "<<(b)<<" "
//#define wtr(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wtrl(a) cout<<(a)<<endl
//#define wtrl(a,b) cout<<(a)<<" "<<(b)<<endl
//#define wtrl(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  string s;
  cin >> s;
  
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 3612
def main():
    n = int(input())
    s = list(map(int, input().split()))
    s.sort()
    q = int(input())
    t = list(map(int, input().split()))
    ans = 0
    for i in range(q):
        l = 0
        h = n
        m = (l + n) // 2
        while l < h:
            if t[i] == s[m]:
                ans += 1
                break
            elif t[i] < s[m]:
                h = m
            else:
                l = m + 1
            m = (l + h) // 2
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 16712
#include <iostream>
#include <vector>                                                                      
                                                                                        
using namespace std;                                                                    
                                                                                        
int main(void) {                                                                        
  int r, c;                                                                             
  cin >> r >> c;                                                                        
  vector<vector<int> > v(r+1,vector<int>(c+1,0));                                       
  for (int i=0; i<r; i++) {                                                             
    for(int j=0; j<c; j++) {                                                            
      cin >> v[i][j];                                                                   
      v[i][c]+=v[i][j];                                                                 
    }                                                                                   
  }                                                                                     
                                                                                        
  for(int j=0;j<c+1;j++){                                                               
    for(int i=0;i<r;i++){                                                               
      v[r][j]+=v[i][j];                                                                 
    }                                                                                   
  }                                                                                     
                                                                                        
  for (int i=0; i<r+1; i++) {                                                           
    for (int j=0; j<c+1; j++) {                                                         
      if (j != 0) {                                                                     
        cout << " " << flush;                                                           
      }                                                                                 
      cout << v[i][j] << flush;                                                         
    }                                                                                   
    cout << endl;                                                                       
  }                                                                                     
}                                          

Measured memory_bytes: 3164
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    ll n;
    ll p[20005] = {};
    cin >> n;
    rep(i,0,n){
        ll a;
        cin >> a;
        p[a] = i+1;
    }
    rep(i,1,n+1)cout << 30000LL * i << " " ;
    cout << endl;
    rep(i,1,n+1)cout << 30000LL * (n-i) + p[i] << " " ;
    cout << endl;
	
	return  0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main () {
  string S[2];
  cin >> S[0] >> S[1];
  int S_[2][200001];
  int N = (int)S[1].size();
  for (int i = 0; i < 2; i ++) {
    string a = "";
    for (int j = 0; j < N; j ++) {
      int n = a.size();
      int p = 0;
      while (p < n && a[p] != S[i][j]) p ++;
      S_[i][j] = p;
      if (p == n) a += S[i][j];
    }
  }
  for (int i = 0; i < N; i ++) {
    if (S_[0][i] != S_[1][i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}



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

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

    long long a, b, x;
    cin >> a >> b >> x;

    cout << b / x - (a + x - 1) / x + 1<< endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <list>
#include <stack>

using namespace std;

int n,m;
string s;
vector<pair<int,int>> p;

int main(void) {
    //auto getN = [](){int t;cin >> t;return t;};
    cin >> n >> m >> s;
    for(int i = 0;i < m;i++) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        p.push_back(make_pair(a,b));
        p.push_back(make_pair(b,a));
    }
    sort(p.begin(),p.end());
    stack<int> sch;
    for(int i = 0;i < n;i++) {
        if(s[i] == 'C') continue;
        auto bg = lower_bound(p.begin(), p.end(), make_pair(i,0));
        auto en = lower_bound(p.begin(), p.end(), make_pair(i+1,0));
        bool ok[2] = {false,false};
        for(auto itr = bg;itr != en;itr++) {
            if(s[itr->second] == 'A') ok[0] = true;
            if(s[itr->second] == 'B') ok[1] = true;
        }
        if(!ok[0] || !ok[1]) {
            s[i] = 'C';
            for(auto itr = bg;itr != en;itr++) {
                sch.push(itr->second);
            }
        }
    }
    while(!sch.empty()) {
        int cur = sch.top();
        sch.pop();
        if(s[cur] == 'C') continue;
        auto bg = lower_bound(p.begin(), p.end(), make_pair(cur,0));
        auto en = lower_bound(p.begin(), p.end(), make_pair(cur+1,0));
        bool ok[2] = {false,false};
        for(auto itr = bg;itr != en;itr++) {
            if(s[itr->second] == 'A') ok[0] = true;
            if(s[itr->second] == 'B') ok[1] = true;
        }
        if(!ok[0] || !ok[1]) {
            s[cur] = 'C';
            for(auto itr = bg;itr != en;itr++) {
                sch.push(itr->second);
            }
        }
    }
    int cnt = 0;
    for(int i = 0;i < n;i++) {
        if(s[i] != 'C') cnt++;
    }
    if(cnt != 0) cout << "Yes";
    else cout << "No";
}


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

int main() {
   	int x, N;
	cin >> x >> N;
  
    if (N==0) {
      cout << x << endl;
      return 0;
    }
  
  	vector<int> p(101, 1);
  	rep(i, N) {
      int ibuff;
      cin >> ibuff;
      p.at(ibuff) = 0;
    }
  	
    int i1=0;
	for (int i=x; i>0; --i) {
      if (p.at(i)==1) {
        i1=i;
        break;
      }
    }
      
    int i2=101;
  	for (int i=x; i<=100; ++i) {
      if (p.at(i)==1) {
        i2=i;
        break;
      }
    }

    if (x-i1 <= i2-x) {
      cout << i1 << endl;
    } else {
      cout << i2 << endl;
    }
    return 0;
}

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

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] price = new int[n];
		for (int i = 0; i < n; i++) {
			price[i] = scan.nextInt();
		}

		Arrays.sort(price);
		int sum = 0;
		for (int i = 0; i < price.length; i++) {
			if (i == price.length - 1)
				sum += price[i] / 2;
			else
				sum += price[i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
use std::io;

fn main() {
    let s = read_line();
    print!("2018");
    println!("{}", &s[4..s.len()]);
}

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_values<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

int num_of_digits (long long int num) {
  int count = 0;
  while(num > 0) {
    count++;
    num /= 10;
  };
  return count;
}

int func (long long int a, long long int b) {
  if (a > b) {
    return num_of_digits(a);
  } else {
    return num_of_digits(b);
  }
}

int main(void) {
  long long int N;
  std::cin >> N;

  // N = A * B

  int min = INT_MAX;
  int maxa = std::sqrt(N) + 1;
  for (long long int a = 1; a < maxa; a++) {
    if (N % a) {
      continue;
    }
    long long int b = N / a;
    int f = func (a, b);
    if (f < min) {
      min = f;
    }
  }

  std::cout << min << std::endl;
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define vi vector< int > 
#define pii pair< int, int >
#define mii map< int , int > 
#define F(start,stop) for(int i=start; i<stop; i++)
#define FRev(start,stop) for(int i=start; i>=stop; i--)
#define debugVector(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << endl;
#define debugArray(arr, n) for(int i=0; i<n; i++) cout << arr[i] << " "; cout << endl;
#define MOD1 1000000007
#define MOD2 998244353


int main()
{

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

	IOS

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

	ll arr[n+1];
	for(int i=1; i<=n; i++) cin >> arr[i];

	vector< ll > pos;
	pos.push_back(1);

	bool visited[n+1];
	memset(visited, false, sizeof visited);

	visited[1] = true;

	int i = arr[1]; 
	int val = -1;

	while(true){
		if(visited[i] == true){
			val = i;
			break;
		}
		pos.push_back(i);
		visited[i] = true;
		i = arr[i];
	};

	// debugVector(pos);
	
	if(k <= pos.size() - 1){
		cout << pos[k] << endl;
		return 0;
	}
	
	int ind = -1;
	F(0, pos.size()){
		if(pos[i] == val){
			ind = i;
			break;
		}
	}

	// cout << ind << endl;

	k -= (pos.size() - 1);

	// cout << k << endl;

	k = k%(pos.size() - ind);
	// cout << k << endl;
	if(k == 0){
		cout << pos[pos.size() - 1];
	}else{
		k--;
		cout << pos[k + ind] << endl;
	}
}

Measured memory_bytes: 7100