akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
char str [100005];
char dr[10]="dream";
char er[10]="erase";
int main()
{
    while (scanf("%s",&str)!=EOF)
    {
        int len = strlen (str);
        int i,ok=1;
        for (i=0;i<len;i++)
        {
            if (str[i]=='d')
            {
                int j;
                for (j=i;j<=i+4;j++)
                {
                    if (j>=len||dr[j-i]!=str[j])
                    {
                        ok=0;
                        break;
                    }
                }
                if (j==i+5)
                {
                    i=j-1;
                    if (str[j]=='e'&&str[j+1]=='r'&&str[j+2]!='a')
                    {
                        i=j+1;
                    }
                }
            }
            else if (str[i]=='e')
            {
                int j;
                for (j=i;j<=i+4;j++)
                {
                    if (j>=len || er[j-i]!=str[j])
                    {
                        ok=0;
                        break;
                    }
                }
                if (j==i+5)
                {
                    i=j-1;
                    if (str[j]=='r') i=j;
                    else i=j-1;
                }
            }
            else ok=0;
            if (ok==0) break;
        }
        if (ok==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	string st; int c=-1,f=-1;
	cin>>st;
	for(register int i=0;i<st.size();i++){
		if (st[i]=='C') c=max(c,i);
		if (st[i]=='F') f=max(f,i);
	}
	if (c<f && c!=-1 && f!=-1) cout<<"Yes";
		else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define max 120 
#define reset_N -1 
 
#define c_whi 1 
#define c_gry 2 
#define c_bla 3 
#define n_max 1000000
#define c_max 2000000
typedef struct node{ 
  int stuff[max]; 
  int c_c_s; 
  int n_su_ki; 
}N; 

 
void k_v_eq_11(int); 
int k_i_dq(void); 
void k_v_bs(N*);
void k_hep();
void ck();

int Q[max],sirushi_mae_sai=1,sirushi_usiro_tai=1,me_kiroku; 
N list1[max]; 


int n_m_11,h_ji_11,c_ti,d[max]; 
int main() 
{ 
  
  int i,j,ch[n_max],ch2[c_max]; 
  scanf("%d",&n_m_11);
  for(int g=0;g<n_max;g++){
  k_hep();
  ck();
  }
  for(i=1;i<=n_m_11;i++) 
    { 
      scanf("%d",&list1[i].n_su_ki);
      scanf("%d",&h_ji_11); 
      list1[i].stuff[h_ji_11+1] = reset_N; 
      
      if(h_ji_11 != 0) 
        { 
  for(j=1;j<=h_ji_11;j++) 
    { 
      scanf("%d",&list1[i].stuff[j]); 
    } 
 } 
      
    } 
  
  
  k_v_bs(list1); 
  
  for(i=1;i<=n_m_11;i++) 
    { 
      printf("%d %d",i,d[i]); 
      
      printf("\n"); 
    } 
  return 0; 
} 

void k_v_bs(N* list1) 
{ 
  int i,j; 
  for(i=1;i<=n_m_11;i++)
    { 
      list1[i].c_c_s = c_whi; 
      d[i] = reset_N; 
    } 
  
  list1[sirushi_mae_sai].c_c_s = c_gry; 
  d[sirushi_mae_sai] = 0; 
  
  k_v_eq_11(list1[sirushi_mae_sai].n_su_ki); 
  
  while(Q[sirushi_mae_sai]!=Q[sirushi_usiro_tai]) 
  { 
      me_kiroku = k_i_dq(); 
      
      for(i=1;i<=max;i++) 
        { 
  if(list1[list1[me_kiroku].stuff[i]].c_c_s == c_whi) 
    { 
      list1[list1[me_kiroku].stuff[i]].c_c_s = c_gry; 
      d[list1[me_kiroku].stuff[i]] = d[me_kiroku] + 1; 
      k_v_eq_11(list1[list1[me_kiroku].stuff[i]].n_su_ki); 
 
    } 
 } 
      list1[me_kiroku].c_c_s = c_bla; 
    } 
 
 
}  

void k_v_eq_11(int n_su_ki) 
{ 
  Q[sirushi_usiro_tai] = n_su_ki; 
  sirushi_usiro_tai+=1; 
} 

int k_i_dq(void) 
{ 
  sirushi_mae_sai+=1; 
  return Q[sirushi_mae_sai-1]; 
}
void ck(){
  char gg[n_max],js[n_max];
  for(int i=0;i<n_max;i++){
    k_hep();
  }
}
void k_hep(){
  int i=100;
  int size=1000*1000*100;
  char *chek;
  for(int j=0;j<n_max;j++){
    chek=(char *)malloc(sizeof(char)*size);
    chek[j]='y';
  }
  
}



Measured memory_bytes: 2076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll A[200010], dp[200010][2];

int main(void){
    int N;
    cin >> N;
    for(int i=0; i<N; ++i) cin >> A[i];
    dp[0][0]=A[0];
    dp[1][0]=A[1];
    if(N%2==0){
        for(int i=1; i*2<N; ++i){
            dp[i*2][0]=dp[i*2-2][0]+A[i*2];
            dp[i*2+1][0]=max(dp[i*2-2][0], dp[i*2-1][0])+A[i*2+1];
        }
        cout << max(dp[N-2][0], dp[N-1][0]) << endl;
    }
    else{
        dp[0][1]=A[0];
        dp[2][0]=A[2];
        dp[2][1]=dp[0][0]+A[2];
        for(int i=2; i*2<N; ++i){
            dp[i*2-1][0]=max(dp[i*2-4][1], dp[i*2-3][0])+A[i*2-1];
            dp[i*2][0]=max({dp[i*2-4][1], dp[i*2-3][0], dp[i*2-2][0]})+A[i*2];
            dp[i*2][1]=dp[i*2-2][1]+A[i*2];
        }
        cout << max({dp[N-3][1], dp[N-2][0], dp[N-1][0]}) << endl;
    }
    return 0;
}


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

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

    auto queue = std::queue<pair<int, int>>();
    auto degrees = vector<int>(N);
    auto adjacency_list = vector<multiset<int>>(N);

    for (auto i = 0; i < 2*(N-1); i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;

        degrees[a]++;
        degrees[b]++;
        adjacency_list[a].insert(b);
        adjacency_list[b].insert(a);

        if (adjacency_list[a].count(b) == 2)
        {
            queue.push({a, b});
            adjacency_list[a].erase(b);
            adjacency_list[b].erase(a);
        }
    }

    auto representatives = vector<int>(N);
    iota(begin(representatives), end(representatives), 0);

    const function<int(int)> find = [&](const int i)
    {
        if (representatives[i] != i)
            representatives[i] = find(representatives[i]);
        return representatives[i];
    };

    auto size = N;
    while (!queue.empty())
    {
        int a, b; tie(a, b) = queue.front(); queue.pop();
        a = find(a); b = find(b);

        if (degrees[a] > degrees[b]) swap(a, b);

        degrees[b] += degrees[a];
        representatives[a] = b;

        for (const auto v : adjacency_list[a])
        {
            adjacency_list[v].erase(a);

            if (adjacency_list[b].count(v))
            {
                adjacency_list[b].erase(v);
                adjacency_list[v].erase(b);
                queue.push({b, v});
            }
            else
            {
                adjacency_list[b].insert(v);
                adjacency_list[v].insert(b);
            }
        }

        size--;
    }

    cout << (size == 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 24704
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
	string s;
	getline(cin, s);

	int K;
	cin >> K;

	for (int i = 0; i < s.length(); ++i)
	{
		if (s[i] == 'a' && i < s.length() - 1)
			continue;
		if (122 - s[i] + 1 <= K) {
			K -= (122 - s[i] + 1);
			s[i] = 'a';
		}
	}

	if (K >= 0) {
		K %= 26;
		if (K <= 122 - s[s.length()-1])
			s[s.length() - 1] += K;
		else {
			s[s.length() - 1] = 'a';
			K -= (122 - s[s.length() - 1] + 1);
			s[s.length() - 1] += K;
		}
	}

	cout << s;

	return 0;
}


Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main () {
	input!{
		a : i32,
		b : i32,
		t : i32
	}
	println!("{}", t / a * b);
}


Measured memory_bytes: 4352
#include <iostream>
#define LEN 100000
using namespace std;

//任务结构体
typedef struct pp{
    char name[10];
    int t;
}P;
P Q[LEN];
int head,tail;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail+1)%LEN;
}
P dequeue(){
    P p = Q[head];
    head = (head+1)%LEN;
    return p;
}
int main()
{
    int n,q;
    cin>>n>>q;
    for(int i=1;i<n+1;i++){
        cin>>Q[i].name;
        cin>>Q[i].t;
    }

    head=1;
    tail=n+1;
    int time = 0;
    while(head!=tail){
        P p = dequeue();
       // cout<<p.name<<" "<<p.t<<endl;
        int c = min(q,p.t);
        time += c;
        p.t -= c;
        if(p.t>0){
            enqueue(p);
        }else{
            cout<<p.name<<" "<<time<<endl;
        }
    }
    return 0;
}



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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r<0 || x + r>W || y - r<0 || y + r>H){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

using namespace std;

int main(){

	int n;
	cin >> n;
	cout << (1000-(n%1000))%1000 << '\n';

	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector <string> A(10);
    A[0]="pon";
    A[1]="pon";
    A[2]="hon";
    A[3]="bon";
    A[4]="hon";
    A[5]="hon";
    A[6]="pon";
    A[7]="hon";
    A[8]="pon";
    A[9]="hon";
    cout << A[N%10] << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cmath>

int main () {
    long long n;
    std::cin >> n;
    long long min = n - 1;
    for (long long i = 1;i <= sqrt(n); ++i) {
        if (n % i == 0){
            long long j = n / i;
            if(min > i + j - 2) {
                min = i + j - 2;
            }
        }
    }
    std::cout << min << std::endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        for(int i = 0; i < K; i++){
            if(i % 2 == 0){
                B += A / 2;
                A /= 2;
            }else{
                A += B / 2;
                B /= 2;
            }            
        }
        System.out.println(A+" "+B);
    }
}


Measured memory_bytes: 38856
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main(){

    int n, k;
    string s;
    cin >> n >> k >> s;

    transform(s.begin() + k - 1, s.begin() + k, s.begin() + k - 1, ::tolower);

    // if(s[k - 1] == 'A' ){
    //     s[k - 1] = 'a';
    // }else if(s[k - 1] == 'B'){
    //     s[k-1] = 'b';
    // }else{
    //     s[k-1] = 'c';
    // }

    cout << s;

    return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

char ch;
string text;

int main() {
    while(getline(cin,text)){
    	for(int i=0;i<26;i++){
    		for(int j=0;j<text.size();j++){
    			if(text[j]>='a'&&text[j]<='y')text[j]+=1;
    			else if(text[j]=='z')text[j]='a';
    		}
    		int p=text.find("the"),q=text.find("this"),r=text.find("that");
    		if(p!=string::npos||q!=string::npos||r!=string::npos){
    			cout<<text<<endl;
    			break;
    		}
    	}
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;


int main() {
    int n;  // number of towns
    long long k;  // number of teleports
    cin >> n >> k;

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

    vector<int> town_visit_order(n + 1, 0);
    int town_idx = 1;
    int order = 1;
    town_visit_order[town_idx] = order;
    order++;

    int loop_size;
    int loop_beginning_order;
    bool flag = true;
    while (flag) {
        town_idx = a[town_idx];
        if (town_visit_order[town_idx] == 0) {
            town_visit_order[town_idx] = order;
            order++;
        }
        else {
            loop_size = order - town_visit_order[town_idx];
            loop_beginning_order = town_visit_order[town_idx];
            flag = false;
        }
    }

    int ans_town;
    if (k + 1 < loop_beginning_order) {
        for (int town = 1; town <= n; town++) {
            if (town_visit_order[town] == k + 1) {
                ans_town = town;
            }
        }
    }
    else {
        int r = ((k + 1) - loop_beginning_order) % loop_size;
        for (int town = 1; town <= n; town++) {
            if (town_visit_order[town] == loop_beginning_order + r) {
                ans_town = town;
            }
        }
    }

    cout << ans_town << endl;

    return 0;
}


Measured memory_bytes: 4852
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;

    double rad = c * M_PI / 180;

    cout << fixed;
    cout << setprecision(8);

    cout << a * b * sin(rad) / 2 << endl;
    cout << a + b + sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(rad)) << endl;
    cout << b * sin(rad) << endl;

    return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	         int A = sc.nextInt();
      		 int B = sc.nextInt();
      		 int C = B*2;
      if(A>C){
        System.out.println(A-C);
    }else if(A<=C){
        System.out.println(0);
      }
    }
}


Measured memory_bytes: 21844
def cul(num, idx):
    if idx == len(num):
        return eval(num)

    return cul(num[:idx]+"+"+num[idx:], idx+2) + cul(num, idx+1)


def main():
    s = input()
    print(cul(s, 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
local mmi, mma = math.min, math.max
local mod = 998244353
local mfl = math.floor
local function bmul(x, y)
  local x0, y0 = x % 31596, y % 31596
  local x1, y1 = mfl(x / 31596), mfl(y / 31596)
  return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local n, k = io.read("*n", "*n")
local ls, rs = {}, {}
for i = 1, k do
  ls[i], rs[i] = io.read("*n", "*n")
end
local t = {1}
local imos = {0}
for i = 2, n + 1 do
  t[i] = 0
  imos[i] = 0
end
for src = 1, n do
  if 1 < src then
    imos[src] = badd(imos[src], imos[src - 1])
    t[src] = imos[src]
  end
  if src < n then
    for j = 1, k do
      local dstmin = src + ls[j]
      local dstmax = mmi(n, src + rs[j])
      if dstmin <= dstmax then
        imos[dstmin] = badd(imos[dstmin], t[src])
        imos[dstmax + 1] = bsub(imos[dstmax + 1], t[src])
      end
    end
  end
end
print(t[n])


Measured memory_bytes: 6876
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd

n = ni()
A = list(ma())
tot = 0
for a in A:
    tot = tot^a
ans = []
for a in A:
    ans.append(tot^a)
print(*ans)


Measured memory_bytes: 118244
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1)
        ret[n] = 1;
    return ret;
}

ll pow_mod(ll n, ll k, ll mod) {
    if(k == 0) {
        return 1;
    } else if(k % 2 == 1) {
        return pow_mod(n, k - 1, mod) * n % mod;
    } else {
        ll t = pow_mod(n, k / 2, mod);
        return t * t % mod;
    }
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if(u < 0)
        u += m;
    return u;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    map<ll, int> cnt;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        auto mp = prime_factor(a[i]);
        for(auto p : mp) {
            chmax(cnt[p.first], p.second);
        }
        (ans += modinv(a[i], MOD)) %= MOD;
    }
    for(auto p : cnt) {
        (ans *= pow_mod(p.first, p.second, MOD)) %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int mountain[10];
	for (int i = 0; i < 10; i++)
	{
		cin>>mountain[i];
	}

	sort(mountain,mountain+10);
	cout<<mountain[9]<<endl;
	cout << mountain[8] << endl;
	cout << mountain[7] << endl;
	return false;
}


Measured memory_bytes: 3164
use proconio::input;

fn main() {
	input!(w: usize);
	input!(h: usize);
	input!(n: usize);
	input!(xya: [(usize, usize, usize); n]);

	let mut rect = (0, 0, w, h);	// (左下x, 左下y, 右上x, 右上y)
	for i in 0..n {
		match xya[i].2 {
			1 => {
				if rect.0 < xya[i].0 {
					rect.0 = xya[i].0;
				}
			},
			2 => {
				if rect.2 > xya[i].0 {
					rect.2 = xya[i].0;
				}
			},
			3 => {
				if rect.1 < xya[i].1 {
					rect.1 = xya[i].1;
				}
			},
			4 => {
				if rect.3 > xya[i].1 {
					rect.3 = xya[i].1;
				}
			},
			_ => (),
		}
	}
	//println!("{:?}", rect);
	if rect.2 > rect.0 && rect.3 > rect.1 {
		println!("{}", (rect.2 - rect.0) * (rect.3 - rect.1));
	}
	else {
		println!("0");
	}
}



Measured memory_bytes: 2172
import collections
N = int(input())
A = [int(i) for i in input().split()]
c = collections.Counter(A)
c = c.most_common()
c.sort()
cnt = 0
for i in range(N):
  try:
    num = c[cnt][0]
    tmp = c[cnt][1]
    if num == i+1:
      print(tmp)
      cnt += 1
    else:
      print(0)
  except:
    print(0)


Measured memory_bytes: 44380
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll N,M,V,P,A[100007],mi,sum,S[100007];
map<ll,ll> m;

int main(){
  cin >> N >> M >> V >> P;
  rep(i,N){
    cin  >> A[i];
    A[i]*=-1;
    m[A[i]]++;
    sum+=A[i]; 
  }
  sort(A,A+N);
  rep(i,N){
    S[i+1]=S[i]+(-A[i]);
  }
  mi=-A[P-1];
  ll k=0,sum=0,ans=0,pre=0;
  for(auto p : m){
    // 明らかに不可能
    ll X=-p.fr,Y=p.sc;
    if(X<mi-M){
      break;
    }
    // 底上げ
    if(k<P){
      ans+=Y;
    }
    else{
      ll Z;
      if(V-N+(k-P+1)>0){
        Z=((S[k]-S[P-1])+M*(V-N+(k-P+1))+(k-P))/(k-P+1);
      }
      else{
        Z=mi;
      }
      if(Z<=X+M){
        ans+=Y;
      }
      else{
        break;
      }
    }
    k+=Y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(Q);
	vector<int> S(N);
	for (int q = 0; q < N; q++) S[q] = K - Q;
	for (int i = 0; i < Q; i++) {
		cin >> A[i];
		S[A[i]-1]++;
	}
	for (int j = 0; j < N; j++) {
		if (S[j] <= 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}

Measured memory_bytes: 1408
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
    
aaa = 0    
ans = A[0]
count = 1

for i in range(N):
    if ans == 2:
        aaa = 1
        break
    else:
        ans = A[ans-1]
        count += 1
if aaa == 1:
    print(count)
else:
    print(-1)
    


Measured memory_bytes: 7084
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {
	int n;
	cin >> n;
	int mini = 10000;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		mini = min(get2Digit(a), mini);
	}
	cout << mini << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

int main(){
    string s; cin >> s;

    int len = s.size();

    if(len%2 == 0){
        for(int i=len-2; i>=2; i-=2){
            bool flg = true;
            for(int j=0; j<(i/2); j++) if(s[j] != s[i/2 + j]) flg = false;
            if(flg){
                cout << i << endl;
                return 0;
            }
        }
    }
    else{
        for(int i=len-1; i>=2; i-=2){
            bool flg = true;
            for(int j=0; j<(i/2); j++) if(s[j] != s[i/2 + j]) flg = false;
            if(flg){
                cout << i << endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int c = 0;
  int pos = 0;
  while (pos < S.size() - 1 && S.size() != 0) {
    if (S[pos] != S[pos + 1]) {
      S.erase(pos, 2);
      c++;
      pos = max(0, pos - 1);
    } else {
      pos++;
    }
  }
  cout << 2 * c << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int  long long 
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e18
    
const int N=2e5+5; 
const int M=1e9+7;
void solve()
{
	int n;
	cin>>n;
	set<string> s;
	f(i,1,n)
	{
		string tt;
		cin>>tt;
		s.insert(tt);
	}
	int ans=s.size();
	cout<<ans;
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}



Measured memory_bytes: 19288
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
from collections import defaultdict
OUT=defaultdict(set)
IN=defaultdict(int)
for i in range(N+M-1):
    a,b=map(int,input().split())
    OUT[a-1]|={b-1}
    IN[b-1]+=1
P=[0]*N
start={i for i in range(N) if IN[i]==0}
while len(start)>0:
    now=start.pop()
    for nex in OUT[now]:
        IN[nex]-=1
        if IN[nex]==0:
            start|={nex}
            P[nex]=now+1
[print(p) for p in P]

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n;
  cin >> n;
  cout << (n - 2) * 180 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;

int N;
int Y[1010];
void disp_d(int *ary){
	printf("\x1b[37m");
	for(int i = 0;i < 10; ++i){
		printf("%2d ",ary[i]);
	}
  printf("\x1b[39m\n");
}
void factorize(int v){
	for (int i = 2; i < sqrt(N) && v > 1; ++i)
	{
		while(v%i==0 && v/i>0){
			v/=i;
			Y[i]++;
		}
	}
	if(v > 1) Y[v]++;
}

int main(){
	//	freopen("in.txt","r",stdin);
	ll yakusuu = 1;
	cin >> N;
	for (int i = 2; i <= N; ++i)
	{
		factorize(i);
		// disp_d(Y);
	}
	for (int i = 2; i < 1000; ++i)
	{
		yakusuu *= (Y[i]+1);
		yakusuu %= mod;
	}
	cout << yakusuu << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
const int inf = 0x3f3f3f3f ;
const int maxn = 2005 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
int n ;
string s ;
map<string , bool> mp ;
int main()
{
	ios ;
	cin >> n ;
	int ans = 0 ;
	while(n --)
	{
		cin >> s ;
		if(mp.count(s))  continue ;
		else  ans ++ , mp[s] = 1 ; 
	}
	cout << ans << '\n' ;
	return 0 ;
}

Measured memory_bytes: 19244
#include <iostream>
#include <string>

using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  const char* result = "No";
  if ((N % 2 == 0) &&
      (S.compare(0, N / 2, S, N / 2, N / 2) == 0)) {
    result = "Yes";
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define j0 j5743892
#define j1 j542893
#define prev PREV
#define next NEXT
                         
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> T gcd(T a, T b) { re a ? gcd (b % a, a) : b; }
template<class T> T sqr(T a) { re a * a; }
template<class T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }

#define filename ""

int n;
int m;
string s;
int res[1 << 26];

int main () {
	cin >> s;
	n = sz (s);
	int cur = 0;
	for (int i = 0; i < (1 << 26); i++) res[i] = 1e9;
	res[0] = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cur ^= 1 << (s[i] - 'a');
		int tmp = res[cur];
		for (int j = 0; j < 26; j++) tmp = min (tmp, res[cur ^ (1 << j)]);
		tmp++;
		res[cur] = min (res[cur], tmp);
		ans = tmp;
	}
	printf ("%d\n", ans);
	return 0;
}


Measured memory_bytes: 262788
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n;
  cin >> n;
  if(n % 2 == 1) cout << 0 << endl;
  else{
    ll ans = 0;
    n /= 2;
    for(ll i = 5; i <= n; i *= 5){
      ans += n / i;
    }
    cout << ans << endl;
  }
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int num[11];

int main(void){
	int n,m;
	while(cin >> n >> m){
		if(n==0)
			break;
		rep(i,11) num[i]=0;
		rep(i,n){
			int d,p;
			cin >> d >> p;
			num[p]+=d;
		}
		int ans=0;
		for(int i=10;i>=1;--i){
			int del=min(num[i],m);
			num[i]-=del,m-=del;
			ans+=i*num[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        String w[] = new String[n];
        for (int i = 0; i < n; i++) {
            w[i] = in.next();
        }

        for (int i = 1; i < n; i++) {
            if (w[i - 1].charAt(w[i - 1].length() - 1) != w[i].charAt(0)) {
                System.out.println("No");
                return;
            }

            for (int j = 0; j < i; j++) {
                if (w[i].equals(w[j])) {
                    System.out.println("No");
                    return;
                }
            }
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#define LL long long int
using namespace std;

int expmod(int a, int b, int m)
{
    int res = 1;
    while(b)
    {
        if(b & 1) res *= a % m;
        b >>= 1;
        a *= a % m;
    }
    return res % m;
}


int main()
{
    int n, x, ele = 0, cont;
    vector<int> arr;

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> x;
        if(!(x & 1))
            arr.push_back(x);
    }

    for(auto k : arr)
    {
        cont = 0;
        for(int i = 2; ((k * expmod(3, ele, i)) % i) == 0; i <<= 1, cont++);
        ele += cont;
    }

    cout << ele << '\n';





}


Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        s: String,
    }

    let ans = s.chars().filter(|c| *c == '1').count();
    println!("{}", ans);
}


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

using ll = long long;

#define int ll

int32_t main()
{
	int n;
	scanf("%lld",&n);
	vector<int> dp(3);
	for(int day = 0;day<n;day++)
	{
		vector<int> new_dp(3,0);
		vector<int> c(3);
		for(int i=0;i<3;i++)
		{
			scanf("%lld",&c[i]);
		}
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(i!=j)
				{
					new_dp[j] = max(new_dp[j],dp[i] + c[j]);
				}
			}
		}
		dp = new_dp;
	}
	printf("%lld\n",max({dp[0],dp[1],dp[2]}));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


string s;
int ch[26];

int main(){
	cin>>s;
	if(s=="zyxwvutsrqponmlkjihgfedcba"){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<s.size();i++){
		ch[s[i]-'a']=1;
	}
	if(s.size()!=26){
		for(int i=0;i<26;i++){
			if(!ch[i]){
				char e='a'+i;
				cout<<s+e<<endl;
				return 0;
			}
		}
	}
	int r=INF;
	//cout<<("aaz"<"ab")<<endl;
	string ans="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
	for(int i=25;i>=1;i--){
		for(int j=25;j>=i;j--){
			string ttt=s.substr(0,i-1)+s[j];
			if(ttt>s&&ttt<ans){
				ans=ttt;
				//cout<<i<<" "<<j<<endl;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = 1; i <= 1000; i++)
    {
        if (A <= K * i && K * i <= B)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    string str;cin >> str;
    int massx[N+10],massy[N+10];
    massx[0]=0,massy[0]=0;
    REP(a,N){
        massx[a+1]=massx[a]+(str.at(a)=='W'?1:0);
    }
    REP(a,N){
        massy[a+1]=massy[a]+(str.at(a)=='E'?1:0);
    }
    int ans = INF;
    REP(a,N){
       // cout<<N<<" "<<massx[a]<<" "<<massy[N]<<" "<<massy[a+1]<<endl;
        ans = min(ans,massx[a]+(massy[N]-massy[a+1]));
       // COUT(ans);
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 2948
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=(1<<31)-1;

ll seg[21][100100];

int main()
{
    rep(i,21){
        rep(j,100100){
            seg[i][j]=INF;
        }
    }
    ll n;
    cin >> n;
    ll q;
    cin >> q;
    while(q--){
        ll com;
        cin >> com;
        if(com==0){
            ll i,x;
            cin >> i >> x;
            seg[20][i]=x;
            for(ll p=19;p>=1;p--){
                ll j=i;
                i/=2;
                seg[p][i]=min(seg[p+1][2*i],seg[p+1][2*i+1]);
            }
        }
        else{
            ll s,t;
            cin >> s >> t;
            t++;
            ll ans=INF;
            ll p=20;
            while(t-s){
                if(s%2!=0){
                    ans=min(seg[p][s],ans);
                    s++;
                    
                }
                s/=2;
                if(t%2!=0){
                    
                    t--;
                    ans=min(seg[p][t],ans);
                }
                t/=2;
                p--;
            }
            cout << ans << endl;
        }
        
    }
    return 0;
} 



Measured memory_bytes: 19516
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
strToInt s = (read :: String -> Int) s

main = do
    x <- readLn
    print $ solve x

solve x = 2 * ele + moda
          where ele = div x 11
                moda = if (mod x 11) == 0
                       then 0
                       else if (mod x 11) <= 6
                            then 1
                            else 2

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
	int taka_health,taka_strength;
	cin>>taka_health>>taka_strength;
	int aoki_health,aoki_strength;
	cin>>aoki_health>>aoki_strength;
	
	int taka_hit = taka_health/aoki_strength;
	if(taka_health%aoki_strength)taka_hit++;
	int aoki_hit = aoki_health/taka_strength;
	if(aoki_health%taka_strength) aoki_hit++;
	if(taka_hit>=aoki_hit) cout<<"Yes";
	else cout<<"No";
	
}

Measured memory_bytes: 3560
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main (){
  int q,x;
  set<int> a,b;
  vector<int> result;

  cin >> q;

  for (int i = 0; i < q; i++){
    cin >> x;
    a.insert(x);
  }

  cin >> q;

  for (int i = 0; i < q; i++){
    cin >> x;
    b.insert(x);
  }
  set_difference(begin(a),end(a),begin(b),end(b),inserter(result,end(result)));

  for_each(begin(result), end(result), [](int x) {
    cout << x << endl;
  });
  return 0;
}



Measured memory_bytes: 22708
#include<bits/stdc++.h>
using namespace std;
int n,m;

int dfsDP(vector<vector<int> >&g, vector<int>& len, int src){
    if(len[src]!=-1)
        return len[src];
    int l = 0;
    for(int i=0;i<g[src].size();i++){
        int childLen = dfsDP(g,len,g[src][i]);
        l = max(l, 1+childLen);
    }
    //cout<<src<<" "<<l<<endl;
    return len[src] = l;
}

int dfs(vector<vector<int> >&g){
    vector<int> len(n+1, -1);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(len[i]==-1){
            dfsDP(g,len,i);
        }
        ans = max(ans,len[i]);
    }
    return ans;
}

int main(){

    cin>>n>>m;
    vector<vector<int> > g(n+1);
    for(int i=0;i<m;i++){
        int from,to;
        cin>>from>>to;
        g[from].push_back(to);
    }
    cout<<dfs(g)<<endl;
    return 0;
}


Measured memory_bytes: 11776