akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int n,k;
	int g,Max=0,p;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&p);
		if(i==0){
			g=p;
		} else {
			g=__gcd(g,p);
		}
		Max=max(Max,p);
	}
	if(k%g==0&&k<=Max){
		puts("POSSIBLE");
	} else {
		puts("IMPOSSIBLE");
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
cnt = [0]*(10**5+1)

s = sum(A)
for i in A:
  cnt[i] += 1

for _ in range(Q):
  B, C = map(int, input().split())
  s += (C-B)*cnt[B]
  print(s)
  cnt[C] += cnt[B]
  cnt[B] = 0

Measured memory_bytes: 20868
n, m = map(int, input().split())

li_w = list()

for _ in range(m):
    li_w.append(tuple(map(int, input().split())))

w_l = 0
w_r = 999999

for w in li_w:
    w_l = max(w_l, w[0])
    w_r = min(w_r, w[1])


if w_r >= w_l:
    print(w_r - w_l + 1)
else:
    print(0)


Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int ans=0;
int main(void){
	int n,k;
	cin>>n>>k;
	if(n<k||n%k!=0)ans=1;
	else ans=0;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]){	
		Scanner scan = new Scanner(System.in);
				
		int m, n, h;
		String str;
		
		while(true){
			str = scan.next();
			if(str.equals("-"))break;
			
			n = str.length(); //??????????????°???????????°???
			
			m = scan.nextInt(); //?????£??????????????°
			
			for(int i = 0; i < m; i++){
				h = scan.nextInt(); //????????? h ????????????

				String sub = str.substring(0, h); //
				String sub2 = str.substring(h);
				str = sub2;
				str += sub;
			}
			
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 26432
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] in = br.readLine().split(" ");
		int A = Integer.parseInt(in[0]);
		int B = Integer.parseInt(in[1]);
		int C = Integer.parseInt(in[2]);
		
		String ans = "NO";
		for(int i=1; i<=B; i++) {
			if(i*A%B == C)
				ans = "YES";
		}
				
		System.out.println(ans);	
	}
}


Measured memory_bytes: 32724
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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

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



	
int main() {
	ll a, b;
	cin >> a >> b;
	cout << a * b / gcd(a, b);
	
	system("PAUSE");
}

Measured memory_bytes: 504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC125 {
	class ABC125_A {
		static void Main(string[] args) {
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var A = input[0];
			var B = input[1];
			var T = input[2];

			var constNumber = 0;
			while(A * (constNumber+1) < T + 0.5) {
				constNumber++;
			}
			Console.WriteLine(B * constNumber);
		}
	}
}


Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    string str;
    cin >> str;
    
    ll ans = 0;
    bool flag = false;
    ll num = 0;

    for(int i = str.size()-2; i >= 0; i--){
        if(str[i] == 'B'){
            if(str[i+1] == 'C'){
                num++;
                flag = true;
            }else{
                num = 0;
                flag = false;
            }
        }else if(str[i] == 'C'){
            if(flag){
                flag = false;
            }else{
                num = 0;
            }
        }else{
            if(flag){
                ans += num;
            }else{
                num = 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < d.length; i++) {
            d[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < d.length; i++) {
            for (int j = i + 1; j < d.length; j++) {
                sum += d[i] * d[j];
            }
        }
        System.out.println(sum);
        sc.close();
    }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    vector<int> v(3);
    for(auto &vi : v) cin >> vi;
    sort(v.begin(), v.end());
    rep(i, 3){
        cout << v[i];
        if(i!=2) cout << " ";
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>

int main(){
    
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if(a < b){
	    printf("a < b\n"); 
    } else if (a > b) {
	    printf("a > b\n");
    } else {
    	printf("a == b\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        abcds: [(usize, usize, usize, usize); q],
    };
    // dbg!(M,N,Q);
    // dbg!(abcds);
    let mut max = 0;
    let mut nums = vec![1; n];
    while {
        let sum = calc(&nums, &abcds);
        if sum > max {
            max = sum;
        }
        next(&mut nums, &m)
    } {}
    println!("{}", max);
}

fn calc(nums: &Vec<usize>, abcds: &Vec<(usize, usize, usize, usize)>) -> usize {
    let mut sum = 0;
    for &(a, b, c, d) in abcds {
        if nums[b - 1] - nums[a - 1] == c {
            sum += d;
        }
    }
    sum
}

fn next(nums: &mut Vec<usize>, m: &usize) -> bool {
    // 右から9のindexを探す
    // ある → 一番左にあるmの左隣をインクリメントし右を全部それに
    // ない → 右端を+1
    let len = nums.len();
    let ii = nums.iter().position(|x| x == m);
    if let Some(i) = ii {
        if i == 0 {
            return false;
        } else {
            nums[i - 1] += 1;
            for j in i..len {
                nums[j] = nums[i - 1];
            }
        }
    } else {
        nums[len - 1] += 1;
    }
    true
}


Measured memory_bytes: 2172
using System;

class quiz
{
    public long solve(string S)
    {
        string sub = "";
        long ans = 0;
        int p = 0;

        for (int i = 0; i < Math.Pow(2,S.Length-1); i++)
        {
            p = 0;

            for (int j = 0; j < S.Length; j++)
            {
                if(((i >> j) & 1) == 1 || j == S.Length - 1)
                {
                    sub = S.Substring(p, j - p + 1);
                    p = j + 1;
                    ans += long.Parse(sub);
                }
            }
        }

        return ans;
    }

    public int[] ParseIntBySpace(string str)
    {
        int[] array = new int[str.Length];
        int lastloc = 0, spaceloc = -1;

        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == ' ')
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc - 1));
                spaceloc = i;
            }
            else if (i == str.Length - 1)
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc));
            }
        }

        Array.Resize(ref array, lastloc);

        return array;
    }
}

class Example
{
    static void Main()
    {
        quiz ex = new quiz();

        //while (true)
        //{
        Console.WriteLine(ex.solve(Console.ReadLine()));
        //}
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

const int mod = 1'000'000'007;
vector<long> fact;
vector<long> ifact;

int mpow(int x, int y) {
    if (y==0) return 1;
    long a = mpow(x,y>>1);
    (a*=a) %= mod;
    if(y&1) (a*=x) %= mod;
    //cout << "x " << x << "  y " << y << "  a " << a << endl;
    return a;
}

void init(int n) {
    fact[0] = 1;
    for(int i=1; i<=n; ++i) fact[i] = fact[i-1]*i %mod;
    ifact[n] = mpow(fact[n], mod-2) % mod;
    for(int i=n; i>0; --i) ifact[i-1] = ifact[i]*i % mod;
}

long nPr(int n, int r) {
    if ( r<0 || n<r ) return 0;
	return fact[n] * ifact[n-r] % mod;
}


void dfs(long& ans, const int k, vector< vector <int> >& g, const int now, const int p){
    // cout << "now1 : " << now << "\t ans : " << ans << endl;
    if ( p != 0 && g[now].size() <= 1 ) return;
    if (p == 0) (ans *= nPr(k-1, g[now].size())) %= mod;
    else (ans *= nPr(k-2, g[now].size() - 1)) %= mod;
    // cout << "now2 : " << now << "\t ans : " << ans << endl;
	
	for(auto child: g[now]){
        if (child == p) continue;
        dfs(ans, k, g, child, now);
	}
}


int main() {
	int n, k;
	cin >> n >> k;
    --n;
	vector< vector<int> > g(n+5);
    fact = vector<long>(k+2);
    ifact = vector<long>(k+2);
    init(k);
    // cout << "init fin" << endl;

	for(int i=0; i<n; ++i) {
		int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    // cout << "input fin" << endl;

    long ans = k;
    dfs(ans, k, g, 1, 0);
    // cout << "dfs fin" << endl;
    cout << ans << endl;
}

Measured memory_bytes: 10368
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

using namespace std;

int main(){

    int r, d, x;
    cin >> r >> d >> x;

    for(int i=0;i<10;i++){
        x = r*x-d;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
q = int(input())
cnt = defaultdict(int)
for x in a:
    cnt[x] += 1
ans = [0] * q
total = sum(a)
for i in range(q):
    b, c = map(int, input().split())

    cnt[c] += cnt[b]
    total = total - b * cnt[b] + (cnt[b]) * c
    cnt[b] = 0
    ans[i] = total

for i in range(q):
    print(ans[i])

Measured memory_bytes: 27092
#include<bits/stdc++.h>
using namespace std;
int A[20];
int main()
{
    int a,b;
    cin>>a>>b;
    int k=0;
    for(int i=2;i<=13;i++)
        A[i]=++k;
    A[1]=++k;
    if(A[a]>A[b])
    {
        cout<<"Alice";
    }
    else if(A[a]<A[b])
    {
        cout<<"Bob";
    }
    else
    {
        cout<<"Draw";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main () 
{
    char s[13],t[13],u[13];
    int a,b;

scanf("%s %s",&s,&t);
scanf("%d %d",&a,&b);
scanf("%s",&u);
  

if(strcmp(s,u)==0)
    a = a-1;
if(strcmp(t,u)==0) 
    b = b-1;

printf("%d %d",a,b);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include<string>

using namespace std;

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

    int cnt = 0;
    int a = 0;
    int max = h[0];

    for(int i = 0; i  < n; i++){
        for(int j = 0; j < i; j++){
            if(max > h[i]){
                cnt++;
            }else{
                max = h[i];
            }
        }
        if(cnt == 0){
            a++;
        }
        cnt=0;
    }

    cout << a << endl;

}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
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); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;

inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    int n;
    cin >> n;

    vector<int> a(n);

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

    auto Isok = [&](int key){
        int now = key;
        auto x = a;
        x[0] -= key / 2;
        rep(i,n){
            x[(i + 1) % n] -= now / 2;
            now = x[(i + 1) % n] * 2;
            x[(i + 1) % n] -= now / 2;

            /*
            rep(j,n){
                cout << x[j] << ' ';
            }
            cout << now << '\n';
            */

            if(x[(i + 1) % n] < 0){
                return false;
            }
        }
        if(now < 0) return false;
        return (true);
    };

    int low = -1, high = a[1] + 1;
    while(high - low > 1){
        int mid = (high + low) / 2;
        if(Isok(mid * 2)) low = mid;
        else high = mid;
    }

    vector<int> res(n);

    int now = low * 2;
    a[0] -= now / 2;
    res[0] = now;
    rep(i,n){
       a[(i + 1) % n] -= now / 2;
       now = a[(i + 1) % n] * 2; 
       if(i != n-1){
        res[i + 1] = now;
       }
       a[(i + 1) % n] -= now / 2;
    }

    cout << res.back();
    for(int i = 0; i < n-1; ++i){
        cout << ' ' << res[i];
    }
    cout << '\n';

    return (0);
}

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

using namespace std;

int main() {
  int n;
  cin>>n;
  int count=n;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    int root=(int)sqrt(temp);
    for(int k=2;k<=root;k++){
      if(temp%k==0) {count--;break;}
    }
  }
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl A(N);
  rep(i, N) cin >> A[i];

  ll ans = 100;
  rep(i, N){
    ll cnt = 0;
    ll a = A[i];

    while(a % 2 == 0){
      a /= 2;
      cnt++;
    }
    ans = min(ans, cnt);
  }

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


Measured memory_bytes: 256
function Main(input) {

  var input = input.split("\n");
  var n = input[0];
  var arys = input[1].split("");

  var r = 0;
  var b = 0;

  arys.forEach(function(e) {
    if(e == "R") {
      r++;
    } else {
      b++;
    }
  });
  if(r > b) {
    console.log("Yes");
  } else {
    console.log("No");
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<stdio.h>

int main(void){

  char S[10];
  int i,j,n;
  int ans=0;
  int cnt=0;

  scanf("%s",S);

  for(n=0;n<10;n++){
    for(i=0;i<=n;i++){
      cnt=0;
      for(j=i;j<10-n+i;j++){
	if((S[j]=='A')||(S[j]=='T')||(S[j]=='C')||(S[j]=='G'))cnt++;
      }
      if(cnt==10-n){
	ans=10-n;
	break;
      }
    }
    if(ans==10-n)break;
  }

  printf("%d\n",ans);

  return 0;
}



Measured memory_bytes: 128
/*
         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗
         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝
         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗
    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║
    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║
     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝
*/
//password:+BdCHpO8dQvpo5fnV3/u
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int cnt[maxn];
int main() {
    string s;
    cin>>s;
    for(int i=0;i+7<=s.size();i++)
    {
        if(s.substr(i,7)=="dreamer") 
        {
            for(int j=i;j<i+7;j++) cnt[j]=1;
        }
    }
    for(int i=0;i+5<=s.size();i++)
    {
        if(s.substr(i,5)=="dream") 
        {
            for(int j=i;j<i+5;j++) cnt[j]=1;
        }
    }
    for(int i=0;i+6<=s.size();i++)
    {
        if(s.substr(i,6)=="eraser") 
        {
            for(int j=i;j<i+6;j++) cnt[j]=1;
        }
    }
    for(int i=0;i+5<=s.size();i++)
    {
        if(s.substr(i,5)=="erase") 
        {
            for(int j=i;j<i+5;j++) cnt[j]=1;
        }
    }
    for(int i=0;i<s.size();i++)
    {
        if(cnt[i]==0) 
        {
            cout<<"NO\n";
            return 0;
        }
    }
    cout<<"YES\n";
    return 0;
}

Measured memory_bytes: 896
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def f(a, b, c, d):
    return math.sqrt((a - b) ** 2 + (c - d) ** 2)

def main():
    N = int(input())
    L = [list(map(int, input().split())) for i in range(N)]
    Dsum = 0
    Dlen = 0

    for i, l in enumerate(itertools.permutations(range(N))):
        for j in range(len(l)-1):
            Dsum += f(L[l[j]][0], L[l[j+1]][0], L[l[j]][1], L[l[j+1]][1])
        Dlen += 1

    print(Dsum / Dlen)


main()


Measured memory_bytes: 4916
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t,x,sum[5];
	for(int j=0;j<5;j++){
sum[j]=0;
	cin>>t;
	if(t==0)break;
	
for(int i=0;i<9;i++){
	cin>>x;
	sum[j]=sum[j]+x;
}

	cout<<t-sum[j]<<endl;
}
return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main(void) {


	LL a, b, x;
	cin >> a >> b >> x;

	if (a > x) {
		cout << "NO" << endl;
	} else if (a + b < x) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}

	return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

ll n, m;
ll a[100000];
ll s[100001];

pair<ll, ll> count(ll x) {
  ll cnt = 0;
  ll sum = 0;
  rep(i, n) {
    ll lb = lower_bound(a, a + n, x - a[i]) - a;
    cnt += n - lb;
    sum += s[lb] + (n - lb) * a[i];
  }
  return {cnt, sum};
}

int main() {
  cin >> n >> m;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  for (int i = n - 1; i >= 0; --i) s[i] = s[i + 1] + a[i];

  ll lo = 0, hi = a[n - 1] * 2 + 1;
  while (lo + 1 < hi) {
    ll mid = (lo + hi) / 2;
    if (count(mid).first >= m) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  auto p = count(lo);
  out(p.second - (p.first - m) * lo)
}


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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  char t;
  cin >> t;
  if(t == 'S')
    cout << "Cloudy" << endl;
  else if(t == 'C')
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;

}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

// https://www.youtube.com/watch?v=yLkJZXkB6D0
// ある点から等距離な点の集合は, その点を中心とする菱形
// 座標系を45度斜めにすると, 正方形(どう軸を取るかは自由)
// 新しい座標系をx',y'とする
// 片方(x'とする)は, y=x上なので, x'=x-yとする
// 他方はy=-x上なのでy'=y+xとする

// ある点iと他の点jの距離を考える
// 点iを中心とした場合, iを中心とした, jが辺に乗っている正方形が, iからjと等距離の点の集合
// x'の差とy'の差の絶対値のmaxが距離
void solve() {
    int n;
    cin >> n;
    
    vector<int> v, v2;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        int z = x + y, w = x - y;
        v.eb(z);
        v2.eb(w);
    }
    sort(all(v));
    sort(all(v2));
    cout << max(v[sz(v) - 1] - v[0], v2[sz(v2) - 1] - v2[0]) << endl;
}


Measured memory_bytes: 5136
n, a, b = map(int, input().split())
s = input()

total = a + b
foreign = b

for c in s:
    if total <= 0:
        print('No')
    else:
        # still remain places
        if c == 'c':
            print('No')
        elif c == 'a':
            print('Yes')
            total -= 1
        elif foreign <= 0:
            print('No')
        else:
            print('Yes')
            total -= 1
            foreign -= 1
            
        


Measured memory_bytes: 51416
n   = gets.to_i
ary = gets.chomp.chars

min = 1E6

cntB = 0
cntW = ary.count('.')

ary.size.times do |i|
  if ary[i] == '.'
    cntW -= 1
  end
  if ary[i] == '#' || i == n - 1
    min = [min, cntB + cntW].min
    cntB += 1
  end
end

puts min


Measured memory_bytes: 16764
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int INF32 = INT_MAX;

int main() {
    int n, p;
    cin >> n >> p;
    int a = 0;
    for (int i = 0, x; i < n; i++) 
        cin >> x, a += x & 1;
    vector<vector<ll>> c(n + 1, vector<ll>(n + 1, 0));
    c[0][0] = 1;
    for (int i = 1; i <= n; i++) { 
        c[i][0] = 1;
        for (int k = 1; k <= i; k++)
            c[i][k] = c[i - 1][k] + c[i - 1][k - 1];
    }
    ll x = 0, y = 0;
    for (int i = p; i <= a; i += 2) 
        x += c[a][i];
    for (int i = 0; i <= n - a; i++)
        y += c[n - a][i];
    cout << ll(x * y);
    return false;                                                       
}

Measured memory_bytes: 256
def main():
    n, m, x, y = map(int, input().split())
    dx = map(int, input().split())
    dy = map(int, input().split())

    max_x = max(list(dx))
    min_y = min(list(dy))
    if x >= y:
        print("WAR")
        exit()

    z = x + 1
    while z <= y:
        if z > max_x and z <= min_y:
            # print("No War", z)
            print("No War")
            exit()
        z += 1
    print("War")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
main(a,b,c,X,Y,A,f,i,j){for(;scanf("%d%d%d",&a,&b,&c),a|b|c;printf("%d %d\n",X,Y))
for(A=99999999,f=i=0;!f;i++)
	for(j=0;j<=i;j++)
		if(a*j+b*(i-j)==c||a*j==b*(i-j)+c||a*j+c==b*(i-j))
			if(f=1,A>a*j+b*(i-j))A=a*j+b*(i-j),X=j,Y=i-j;
exit(0);}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using std::abs;
using std::accumulate;
using std::cin;
using std::cout;
using std::endl;
using std::vector;

int
main()
{
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++)
  {
    cin >> W[i];
  }
  int sum = accumulate(W.begin(), W.end(), 0);
  int sum1 = 0;
  int best_diff = sum;
  for (int T = 0; T < N - 1; T++)
  {
    sum1 += W[T];
    int diff = abs(sum - sum1 - sum1);
    if (diff < best_diff)
    {
      best_diff = diff;
    }
  }
  cout << best_diff << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define clr(x,y) memset(x,y,sizeof x)
#define INF 0x3f3f3f3f
const int maxn = 1e5 + 10;
typedef long long ll;
typedef unsigned long long ull;
const ull D = 131;
const ll Mod = 1e9 + 7;
const int N = 2e6 + 10;

int main()
{
    int n;
    while( ~ scanf("%d",&n))
    {
        int bits[100];
        int len = 0;
        while(n)
        {
            bits[len ++] = n % 10;
            n /= 10;
        }
        if(bits[0] == bits[1] && bits[1] == bits[2])
            puts("Yes");
        else if(bits[1] == bits[2] && bits[2] == bits[3])puts("Yes");
        else puts("No");
    }
    return 0;
}


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

int main() {
  int N,flag=0;
  cin >> N;

  // ここにプログラムを追記
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(S=="Y")
      flag=1;
  }
  
  if(flag==1)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


Measured memory_bytes: 3564
n = gets.to_i
dic = {}
n.times do |n|
  #puts n
  input = gets.chomp.split
  if input[0] == "insert"
    dic[input[1]] = true
  else
    if dic.key?(input[1])
      puts "yes"
    else
      puts "no"
    end
  end
end


Measured memory_bytes: 40692
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e18;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   ll n,k,c=0;
   cin>>n>>k;
   while(n>0)
   {
       n=n/k;
       c++;
   }
   cout<<c<<endl;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ma = 10 ** 9
ans = 0
for i in range(n):
    if abs(t - h[i] * 0.006 - a) < ma:
        ma = abs(t - h[i] * 0.006 - a)
        ans = i + 1
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	
		Scanner scan = new Scanner(System.in);
		String input = scan.nextLine();
		int min = Math.abs(Integer.parseInt(input.substring(0,3))-753);
		for(int i = 0; i < input.length() - 2; i++) {
			String temp = input.substring(i, i+3);
			int x = Integer.parseInt(temp);
			int diff = Math.abs(x - 753);
			if(diff<min) {
				min = diff;
			}
		}
		System.out.println(min);
		scan.close();	
    }
	
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef vector <int> vi;
typedef set <int> se;
#define endl "\n"
#define for(i,a,b) for(int i = a;i<b;i++)
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


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

int ans = 0;
while(n>0){
    ans+=t;
    n -= x;
}
cout<<ans<<endl;

}
 
 
int main()
{

solve();
 
return 0;
}

Measured memory_bytes: 3616
# include <bits/stdc++.h>
using namespace std;
# define ll long long
const int N = 2e5 + 10, mod = 1e9 + 7, INF = 1e9 + 100;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector < int > a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());
    for(int i = 1; i < n; i++){
        if(a[i] == a[i - 1]){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	ll k;
	cin >> S >> k;
	ll res = 0;
	for (int i = 0; i < min(k,(ll)S.size()); ++i) {
		if (S[i] != '1') {
			cout << S[i] << endl;
			break;
		}
		if (i == k - 1 ) {
			cout << 1 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,k,r,s,p,count=0,i;
  char t[200002],a[200002];
  scanf("%d%d",&n,&k);
  scanf("%d%d%d ",&r,&s,&p);
  for(i=0;i<k;i++){
    scanf("%c",&t[i]);
    if(t[i]=='r'){
      count+=p;
      a[i]='p';
    }
    else if(t[i]=='s'){
      count+=r;
      a[i]='r';
    }
    else{
      count+=s;
      a[i]='s';
    }
  }
  i=k;
  while(i<n){
    scanf("%c",&t[i]);
    if(t[i]==t[i-k]){
      if(t[i]=='r'){
        if(a[i-k]=='p')
          a[i]='a';
        else{
          a[i]='p';
          count+=p;
        }
      }
      else if(t[i]=='s'){
        if(a[i-k]=='r')
          a[i]='a';
        else{
          a[i]='r';
          count+=r;
        }
      }
      else if(t[i]=='p'){
        if(a[i-k]=='s')
          a[i]='a';
        else{
          a[i]='s';
          count+=s;
        }
      }
    }
    else{
      if(t[i]=='r'){
        count+=p;
        a[i]='p';
      }
      else if(t[i]=='s'){
        count+=r;
        a[i]='r';
      }
      else{
        count+=s;
        a[i]='s';
      }
    }
    i++;
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector< vector<int> > ice(90, vector<int>(90));

int m, n;

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

inline bool valid(int i, int j) {
	return 0 <= i && i < n && 0 <= j && j < m && ice[i][j] == 1;
}

int dfs(int i, int j, int count) {
	if ( ! valid(i, j) ) return 0;
	ice[i][j] = 0;
	int ret = count;
	for (int k=0; k<4; ++k) {
		if ( valid(i + dy[k], j + dx[k]) ) {
			ret = max(ret, dfs(i + dy[k], j + dx[k], count + 1));
		}
	}
	ice[i][j] = 1;
	return ret;
}

int main() {
	while (cin >> m >> n && m && n) {
		for (int i=0; i<n; ++i) {
			for (int j=0; j<m; ++j) {
				cin >> ice[i][j];
			}
		}
		int ans = 0;
		for (int i=0; i<n; ++i) {
			for (int j=0; j<m; ++j) {
				if (ice[i][j] == 1) ans = max(ans, dfs(i, j, 1));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int H = Integer.parseInt(scanner.next());
    int W = Integer.parseInt(scanner.next());
    int N = Integer.parseInt(scanner.next());
    int a_i = 0;
    int b_i = 0;
    long[] norms = new long[N*9];

    int index = 0;
    for(int i=0; i<N; i++){
      a_i = Integer.parseInt(scanner.next());
      b_i = Integer.parseInt(scanner.next());
      for(int h=-1; h<=1; h++){
        for(int w=-1; w<=1; w++){
          if((2<=(a_i+h)&&(a_i+h)<=H-1)&&(2<=(b_i+w)&&(b_i+w)<=W-1)){
            norms[index] = (long)(a_i+h)+((long)(b_i+w)<<32);
            index ++;
          }
        }
      }
    }
    scanner.close();

    Arrays.sort(norms);

    int[] ans = new int[10];
    int ans_i = 1;
    for(int i=N*9-index+1; i<9*N; i++){
      if(norms[i-1] == norms[i]){
        ans_i ++;
      }else{
        ans[ans_i] ++;
        ans_i = 1;
      }
      if(i == 9*N-1){
        ans[ans_i] ++;
      }
    }

    long count = 0l;
    for(int i=0; i<10; i++){
      count += ans[i];
    }

    System.out.println(((long)W-2l)*((long)H-2l)-count);
    for(int i=1; i<10; i++){
      System.out.println(ans[i]);
    }
  }
}


Measured memory_bytes: 70056
#include <cstdio>  
using namespace std;  
int main() { 	
	int a,b,c,d,e; 	
	scanf("%d", &a); 	
	b=a/1000;
	c=(a%1000)/100;
	d=(a%100)/10;
	e=a%10;
	if((b==c && c==d) || (c==d && d==e)){
		printf("Yes");
	}
	else{
		printf("No");
	}

} 


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int a,b,i,j,k=0,l=0;
    char s[10];
    scanf("%s",s);
    for(i=0;i<4;i++)
    {
        if(s[i]=='+')
        {
            k++;
        }
        else if(s[i]=='-')
        {
            l++;
        }
    }
    j=k-l;
    printf("%d",j);
    return 0;
}


Measured memory_bytes: 128
N=int(input())
*A,=sorted(map(int,input().split()))

a=True
if N%2==0:
 for i in range(1,N,2):
  if A[i-1]!=i or A[i]!=i:
    a=False
    break
else:
 if A[0]!=0:a=False
 else:
    for i in range(2,N,2):
     if A[i-1]!=i or A[i]!=i:
        a=False
        break
print(2**(N//2)%(10**9+7) if a else 0)

Measured memory_bytes: 20464
a,b,c,x=map(int,open(0).read().split())
cnt=0
#O(n**3)=O(50**3)=O(125000)
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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


int main(void) {
	int n; cin >> n;
	ll s = 0, ss = 0;
	for(int i=0;i<n;i++) {
		ll a;
		cin >> a;
		s += a; s %= mod;
		ss += (a*a) % mod; ss %= mod;
	}
	ll ans = ((s * s) % mod - ss) % mod;
	if(ans < 0) ans += mod;
	ans *= power(2, mod - 2);
	ans %= mod;
	if(ans < 0) ans += mod;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3536
#include <stdio.h>
#include <string.h>

int main(void){

  char sa[101];
  char sb[101];
  char sc[101];
  scanf("%s", sa);
  scanf("%s", sb);
  scanf("%s", sc);
  int a_length = strlen(sa);
  int b_length = strlen(sb);
  int c_length = strlen(sc);
  int a = a_length;
  int b = b_length;
  int c = c_length;
  int player = 0;
  while (1) {
    if (player == 0) {
      if (a == 0) {
        printf("A\n");
        break;
      }
      player = sa[a_length-a] - 'a';
      a--;
    } else if (player == 1) {
      if (b == 0) {
        printf("B\n");
        break;
      }
      player = sb[b_length-b] - 'a';
      b--;
    } else {
      if (c == 0) {
        printf("C\n");
        break;
      }
      player = sc[c_length-c] - 'a';
      c--;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    ll dis = abs(a-b);
    if(v <= w) cout << "NO" << endl;
    else
    {
        if(t * (v-w) >= dis) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;


int main(){
  int N;cin>>N;
  vector<int>A(N);
  rep(i,N){cin >>A[i];}
  sort(A.begin(),A.end());
  int core=N/2;
  int count=0;
  for(int i=1;i<=100000;i++){
  	auto t=lower_bound(A.begin(),A.end(),i);
    int x=A.end()-t;
    if(x==core){count++;}
  }
  cout<<count;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <string>
#include <list>
#include <bitset>

using namespace std;

#define CVector CPoint
typedef long long LL;
typedef unsigned long long ULL;

const LL mod=1e9+7;
const double PI=acos(-1);
const double EPS=1e-6;
const int INF=0x3f3f3f3f;
inline int readint(){int sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}
inline LL readLL(){LL sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}

int n;
LL a[55];

int main(){//ios_base::sync_with_stdio(0);cin.tie(0);
    n=readint();
    for(int i=1;i<=n;i++) a[i]=readLL();
    LL ans=0;
    while(1){
        bool fg=true;
        for(int i=1;i<=n;i++){
            if(a[i]>n-1){
                fg=false;
                break;
            }
        }
        if(fg) break;
        LL ct=0;
        for(int i=1;i<=n;i++){
            LL s=a[i]/n;
            ct+=s;
            a[i]-=s*(n+1);
        }
        for(int i=1;i<=n;i++){
            a[i]+=ct;
        }
        ans+=ct;
    }
    printf("%lld\n",ans);
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 256
//Solution By SlavicG
#include <bits/stdc++.h>
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
#define mp                          make_pair
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	int n,x,t;
	cin >> n >> x >> t;
	cout << ((n+x-1)/x) * t << endl;
}

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

int main()
{
	string s;
	int f=1;
	cin>>s;
	for(int i=1;i<=s.size();i++)
	{
		if(i%2==1 && !(s[i-1]=='R' || s[i-1]=='U' || s[i-1]=='D'))
		f=0;
		if(i%2==0 && !(s[i-1]=='L' || s[i-1]=='U' || s[i-1]=='D'))
		f=0;
	}
	if(f==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

ll d[205][205];

void init(){
  for(int i=0;i<205;i++){
    for(int j=0;j<205;j++){
      if(i!=j)d[i][j]=LLONG_MAX/100;
      else d[i][j]=0;
    }
  }
}

void wf(){
  for(int k=0;k<205;k++){
    for(int i=0;i<205;i++){
      for(int j=0;j<205;j++){
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
}

int main(){
  init();
  int N,M,R;
  cin>>N>>M>>R;

  vector<int> r(R);
  for(int i=0;i<R;i++)cin>>r[i];

  int a,b,c;
  for(int i=0;i<M;i++){
    cin>>a>>b>>c;
    d[a][b]=d[b][a]=c;
  }

  wf();

  ll ans=LLONG_MAX;
  sort(all(r));
  do{
    ll cost=0;
    for(int i=0;i<R-1;i++){
      cost+=(d[r[i]][r[i+1]]);
    }
    ans=min(ans,cost);
  }while(next_permutation(all(r)));
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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 T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int merge_cnt(vector<int> &s){
  int n = s.size();
  if (n == 1) return 0;
  int n2 = n/2;

  vector<int> b(n2); rep(i, n2) b[i] = s[i];
  vector<int> c(n-n2); rep(i, n-n2) c[i] = s[i+n2];
  int res = 0;
  res += merge_cnt(b);
  res += merge_cnt(c);
  int bi = 0, ci = 0;
  for (int i=0; i<n; i++){
    if (bi == n2) s[i] = c[ci++];
    else if (ci == n-n2) s[i] = b[bi++];
    else if (b[bi] <= c[ci]) s[i] = b[bi++];
    else s[i] = c[ci++]; res++;
    res++;
  }
  return res;
}

int main() {
  int n; cin >>n;
  vector<int> S(n); rep(i, n) cin >>S[i];
  int res = merge_cnt(S);
  rep(i, n){
    cout <<S[i];
    if (i == n-1) cout <<endl;
    else cout <<" ";
  }
  cout <<res/2 <<endl;
}


Measured memory_bytes: 8772