akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

/*
高橋君と青木君がモンスターを闘わせます。

高橋君のモンスターは体力が
A
 で攻撃力が
B
 です。 青木君のモンスターは体力が
C
 で攻撃力が
D
 です。

高橋君→青木君→高橋君→青木君→... の順に攻撃を行います。
攻撃とは、相手のモンスターの体力の値を自分のモンスターの攻撃力のぶんだけ減らすことをいいます。
このことをどちらかのモンスターの体力が
0
 以下になるまで続けたとき、 先に自分のモンスターの体力が
0
 以下になった方の負け、そうでない方の勝ちです。

高橋君が勝つなら Yes、負けるなら No を出力してください。
*/

struct Data {
	int atk;
	int hp;

	void Damage(int d) {
		hp -= d;
	}
	bool IsDead() const {
		return hp <= 0;
	}
};
int main(void) {
	Data datas[2];
	cin >> datas[0].hp >> datas[0].atk>> datas[1].hp >> datas[1].atk;

	int turnPlayer = 0;
	do {
		int takeDamagePlayer = (turnPlayer + 1) % 2;
		datas[takeDamagePlayer].Damage(datas[turnPlayer].atk);
		turnPlayer = takeDamagePlayer;
	} while (!datas[turnPlayer].IsDead());

	auto output = (turnPlayer == 1) ? "Yes" : "No";
	cout << output;
}

Measured memory_bytes: 3592
//using geometric series formula (first term 1, r=2); lol wait I read the problem wrong
/*#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	long long int h;
	cin >> h;
	cout << pow(2, h - 1) - 1 << endl;
}*/


#include <iostream>
using namespace std;

int main()
{
	long long int h, mult = 1, ans = 0;
	cin >> h;

	while (h > 0)
	{
		ans += mult;
		h /= 2;
		mult *= 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<int>vec[200005];
int n;
int a[200005];
int main(){
	scanf("%d",&n);
	repn(i,200000){ for(int j=i;j<=200000;j+=i) vec[j].pb(i); }
	repn(i,n) scanf("%d",&a[i]);
	vector<int>vecc;
	for(int i=n;i>=1;i--){
		if(a[i] == 0) continue;
		vecc.pb(i);
		for(int j=0;j<vec[i].size();j++){
			a[vec[i][j]]^=1;
		}
	}
	cout << vecc.size() << endl;
	rep(i,vecc.size()) printf("%d\n",vecc[i]);
}

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

int main(){
  int N,T; cin>>N>>T; vector<int>cost(N); vector<int>time(N); int ans=9999;
  rep(i,N){cin>>cost.at(i)>>time.at(i);}
  rep(i,N){if(time.at(i)>T){continue;}
           else{ans=min(ans,cost.at(i));}
          
          
       }
  if(ans==9999){cout<<"TLE"<<endl;}
  else{cout<<ans<<endl;}
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] a = new int[n];
    for(int i=0;i<n;++i)a[i]=sc.nextInt()%m;
    for(int i=1;i<n;++i)a[i]=(a[i]+a[i-1])%m;
    Map<Integer, Integer> cnt = new HashMap<>();
    cnt.put(0,1);
    long ans = 0;
    for(int i=0;i<n;++i){
      ans += (long)cnt.getOrDefault(a[i], 0);
      cnt.put(a[i], cnt.getOrDefault(a[i], 0)+1);
    }
    System.out.println(ans);
  }
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

vector<int> sieve(int n) {
  vector<bool> b(n / 3 + 1, true);
  vector<int> res{2, 3};
  for (int p = 5, d = 4; p * p <= n; p += d = 6 - d) if (b[p / 3])
    for (int i = p * p, di = p % 3 * 2 * p; i <= n; i += di = 6 * p - di)
      b[i / 3] = false;
  for (int p = 5, d = 4; p <= n; p += d = 6 - d) if(b[p / 3]) res.push_back(p);
  while (not res.empty() and res.back() > n) res.pop_back();
  return res;
}

struct bipartite_matching {
  vector<vector<int>> g;
  vector<int> r, c, vis;
  int t = 0;
  bipartite_matching(int h = 0, int w = 0) : g(h), r(h, -1), c(w, -1), vis(h) {}
  void add(int i, int j) { g[i].push_back(j); }
  bool dfs(int i) {
    if (exchange(vis[i], t) == t) return false;
    for (int j : g[i]) if (c[j] == -1) return r[i] = j, c[j] = i, true;
    for (int j : g[i]) if (dfs(c[j])) return r[i] = j, c[j] = i, true;
    return false;
  }
  int run() {
    for (bool updated = true; ++t, exchange(updated, false); )
      for (int i = r.size(); i--; ) if (r[i] == -1) updated |= dfs(i);
    return r.size() - count(begin(r), end(r), -1);
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<int> se;
  while (n--) {
    int x;
    cin >> x;
    for (int i : {x - 1, x}) {
      if (se.count(i)) {
        se.erase(i);
      } else {
        se.insert(i);
      }
    }
  }
  vector<int> even, odd;
  for (int e : se) {
    (e & 1 ? odd : even).push_back(e);
  }
  auto primes = sieve(1e7);
  int h = even.size(), w = odd.size();
  bipartite_matching bm(h, w);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int d = abs(even[i] - odd[j]);
      if (binary_search(begin(primes), end(primes), d)) {
        bm.add(i, j);
      }
    }
  }
  int res = bm.run();
  h -= res, w -= res;
  if (h & 1) {
    --h, --w;
    res += 3;
  }
  res += h + w;
  cout << res << '\n';
}


Measured memory_bytes: 6896
l1= input().split(' ')
a= int(l1[0])
v= int(l1[1])
l2= input().split(' ')
b= int(l2[0])
w= int(l2[1])
t=int(input())

if w>=v:
	print('NO')
else:
	speed_diff= v-w
	distance_gained= speed_diff*t
	if distance_gained>= abs(a-b):
		print('YES')
	else:
		print('NO')

Measured memory_bytes: 9188
N = int(input())
A = [0] + list(map(int,input().split())) + [0]
cost = sum(abs(A[i+1]-A[i]) for i in range(N+1))
for i in range(1, N+1):
  print(cost-abs(A[i+1]-A[i])-abs(A[i]-A[i-1])+abs(A[i+1]-A[i-1]))
  

Measured memory_bytes: 14044
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

macro_rules! chmax {
    ($x:expr, $e:expr) => {
        if $x < $e {
            $x = $e;
        }
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        if $x > $e {
            $x = $e;
        }
    };
}

const INF: i64 = 1 << 60;

use std::iter::IntoIterator;

fn join_string<T, S>(elems: T) -> String
where
    T: IntoIterator<Item = S>,
    S: ToString,
{
    elems
        .into_iter()
        .map(|i| i.to_string())
        .collect::<Vec<String>>()
        .join(" ")
}

fn main() {
    input!{ 
        N: usize,
        a: [usize; N],
    }
    let mut boxes = vec![0; N+1];
    let mut ans = Vec::new();
    for i in (1..N+1).rev() {
        let mut j = i * 2;
        let mut cnt = 0;
        while j <= N {
            cnt += boxes[j];
            j += i;
        }
        boxes[i] = (cnt + a[i-1]) % 2;
        if boxes[i] == 1 {
            ans.push(i);
        }
    }
    let M: usize = boxes.iter().sum();
    println!("{}", M);
    let b = join_string(ans);
    println!("{}", b);
}


Measured memory_bytes: 14588
data = int(input())
modu = 10 ** 9 + 7
n = 1
for i in range(2, data + 1):
  n *= i
count = 1
ans = 1
for i in range(2, data + 1):
  if n % i != 0:
    continue
  count = 1
  while n % i == 0:
    n //= i
    count += 1
  ans *= count
print(ans % modu)

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 2e5+5;

vector <ll> t(L);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll N, T;
    cin >> N >> T;

    for(ll i=0; i<N; i++)
    {
        cin >> t[i];
    }
    
    ll rem = 0;

    for(ll i=1; i<N; i++)
    {
        if(t[i]-t[i-1]>T)
        {
            rem-=(T-t[i]+t[i-1]);
        }
    }

    cout << t[N-1]+T-rem << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int mx=0;
  int s_mx=0;
  int mx_element=0;
  int s_mx_element=0;
  rep(i,n){
    cin >> a[i];
    if(mx<=a[i]){
      mx = a[i];
      mx_element=i;
    }
  }
  
  rep(i,n){
    if(i==mx_element) continue;
    else if(s_mx<=a[i]){
      s_mx = a[i];
      s_mx_element=i;
    }
  }
  rep(i,n){
    if(i==mx_element) cout << s_mx << endl;
    else cout << mx << endl;
  }
}

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

static const int MAX = 100;

int main()
{
  int n,A[MAX];
  cin >> n;
  for(int i=0;i<n;i++) cin >> A[i];

  for(int i=0;i<n;i++)
  {
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");

  for(int i=1;i<n;i++)
  {
    int v = A[i];
    int j = i-1;
    while(j>=0 && A[j]>v)
    {
      A[j+1] = A[j];
      j--;
    }
    A[j+1]=v;
    for(int j=0;j<n;j++)
    {
      if(j>0) printf(" ");
      printf("%d",A[j]);
    }
    printf("\n");
  }
}



Measured memory_bytes: 3128
#include<iostream>

using namespace std;

int main(){
   
    long long int N, A, B;
    long long int sho, amari;
    cin >> N >> A >> B;

    if (A == 0){
        cout << A << endl;
    }
    else if ( B == 0 ){
        cout << N << endl;
    }
    else {
        sho = N / ( A + B);
        amari = N % ( A + B);
        if ( amari > A ){
            cout << sho * A + A << endl;
        }
        else {
            cout << sho * A + amari << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

int q(const int *a,const int *b)
{
    return *(int*)a-*(int*)b;
}

int main(void)
{
    int k;
    scanf("%d",&k);
    if(k%2)printf("%d",(k/2)*((k+1)/2));
    else printf("%d",(k/2)*(k/2));
    return 0;
}

Measured memory_bytes: 128
input_line = input()

if input_line[0] != 'A' or input_line[0].islower():
    print("WA")
    exit()
if input_line[2:-1].count('C') != 1:
    print("WA")
    exit()

if input_line.count('A') == 1 and input_line.count('C') == 1:
    must_lower = input_line.replace('A', '').replace('C', '')
    if must_lower.islower():
        print("AC")
        exit()

print("WA")
exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll N, x; cin >> N >> x;
  ll a[N], b[N];
  ll res = 0;
  for (ll i = 0; i < N; i++) {
    cin >> a[i]; b[i] = a[i]; res += b[i];
  }
  for (ll k = 1; k < N; k++) {
    for (ll i = 0; i < N; i++) {
      if (i-k >= 0) {b[i] = min(a[i-k],b[i]);}
      else {b[i] = min(a[i+N-k],b[i]);}
    }
    ll num = x*k;
    for (ll i = 0; i < N; i++) {num += b[i];}
    res = min(num,res);
  }
  cout << res << endl;
}

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

int main(){
  int h, w;
  cin >> h >> w;
  map<int, int> s;
  multiset<int> vals;
  rep(i, w) s[i] = i;
  rep(i, w) vals.insert(0);
  rep(i, h){
    int l, r;
    cin >> l >> r;
    --l;
    auto it = s.lower_bound(l);
    int mr = -1;
    while (it != s.end() && it -> first <= r){
      mr = max(mr, it->second);
      int x = it->first - it->second;
      vals.erase(vals.find(x));
      s.erase(it++);
    }
    if (mr != -1 && r < w){
      vals.insert(r - mr);
      s[r] = mr;
    }
    int ans = -1;
    if (vals.size() > 0){
      ans = *vals.begin() + (i+1);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 22296
// https://atcoder.jp/contests/abc171/tasks/abc171_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  string S;
  cin >> S;

  if (islower(S[0])) drop("a");
  drop("A");
}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-


A, B, K = list(map(int, input().split()))

# print(A, K)

set_A = set()
set_B = set()

for i in range(1, A + 1):
    if A % i == 0:
        set_A.add(i)


for i in range(1, B + 1):
    if B % i == 0:
        set_B.add(i)

# print(set_A ,set_B)

seki = set_A & set_B

seki = list(seki)

seki.sort(reverse=True)

print(seki[K - 1])


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

int main(){

	int i;
	double n, s[1000], var_n = 0, sd, m, sum = 0;

	while(1){

		sum = 0;
		var_n = 0;

		scanf("%lf", &n);

		if(n == 0){
			break;
		}

		for(i = 0; i < n; i++){
			scanf("%lf", &s[i]);
		}

		for(i = 0; i < n; i++){
			sum += s[i]; 
		}

		m = sum / n;

		for(i = 0; i < n; i++){
			var_n += pow(s[i] - m, 2);
		}

		sd = sqrt(var_n / n);

		printf("%.11f\n", sd);




	}




	return 0;
}

Measured memory_bytes: 660
def I(): return int(input())
def S(): return input()
N = I()
S = S()
ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if S.find(num[0])==-1:
        continue
    S1 = S[S.find(num[0])+1:]
    if S1.find(num[1])==-1:
        continue
    S2 = S1[S1.find(num[1])+1:]
    if S2.find(num[2])==-1:
        continue
    ans += 1
print(ans)


Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    long long k;
    scanf("%d%d%d%lld",&a,&b,&c,&k);
    if(k%2==0)
        printf("%d\n",a-b);
    else
        printf("%d\n",b-a);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a+d-1)/d>=(b+c-1)/b)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int a[20]={0,9,9,909,909,90909,90909,9090909,9090909};
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	int w=n,sum=0;
	while (w>0)
	{
		sum++;
		w/=10;
	}
	sum--;
	ans+=a[sum];
	if ((sum+1)&1)
	{
		ans+=(n+1-(pow(10,sum)));
	}
	printf("%d",ans);
	return 0;
}

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

int n,pos;
vector<int> pre,post,in;


void rec(int l, int r){
    if(l>=r)return;
    int root = pre[pos];
    pos++;
    int m = distance(in.begin(),find(in.begin(),in.end(),root));
    rec(l,m);
    rec(m+1,r);
    post.push_back(root);
}

void solve(){
    pos=0;
    rec(0,pre.size());
    rep(i,n){
        if(i)cout<<" ";
        cout<<post[i];
    }
    cout<<endl;
}

int main(){
    cin >> n;
    rep(i,n){
        int k;
        cin >> k;
        pre.push_back(k);
    }
    rep(i,n){
        int k;
        cin >> k;
        in.push_back(k);
    }
    solve();
    return 0;
}


Measured memory_bytes: 3148
#include "bits/stdc++.h"
using namespace std;
const int maxn = 5050;
int main(){
    long long k, a, b;
    cin >> k >> a >> b;
    if(a >= k) cout << 1 << endl;
    else{
        long long c = - b + a;
        if(c <= 0) cout << -1 << endl;
        else cout << 1 + 2*((k - a + c - 1) / c) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> X(M), Y(M);
    rep(i, 0, M) {
        cin >> X[i] >> Y[i];
        --X[i], --Y[i];
    }
    vector<int> cnt(N, 1);
    vector<bool> exists(N, false);
    exists[0] = true;
    rep(i, 0, M) {
        if (exists[X[i]]) {
            exists[Y[i]] = true;
        }
        --cnt[X[i]];
        ++cnt[Y[i]];
        if (!cnt[X[i]]) {
            exists[X[i]] = false;
        }
    }
    int ans = 0;
    rep(i, 0, N) {
        if (exists[i]) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
import numpy as np
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

start = time.time()

D = ni()
c = na()
s = [na() for _ in range(D)]
#out = [ni() for _ in range(D)]
sat = 0
last = [0] * 26
t = []
for d in range(D):
    li = []
    for k in range(26):
        last_t = last.copy()
        sat_t = sat
        j = k
        last_t[j] = d + 1
        for i in range(26):
            sat_t -= (d + 1 - last_t[i]) * c[i]
        sat_t += s[d][j]
        li.append(sat_t)
    sat = max(li)
    day = np.argmax(li)
    last[day] = d + 1
    #print(day+1, sat)
    t.append(day+1)

now = sat
while time.time() - start < 1.855:
    d = random.randint(1, D)
    q = random.randint(1, 26)
    if t[d - 1] == q:
        continue
    old = t[d-1]
    t[d-1] = q
    sat = 0
    last = [0] * 26
    for k in range(D):
        j = t[k] - 1
        last[j] = k + 1
        for i in range(26):
            sat -= (k + 1 - last[i]) * c[i]
        sat += s[k][j]
    if now > sat:
        t[d-1] = old
    else:
        now = sat
for i in range(D):
    print(t[i])


Measured memory_bytes: 27184
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import deque, defaultdict
    n, m = map(int, readline().split())
    edge = defaultdict(list)
    for i in range(1, n + 1):
        k, *l = map(int, readline().split())
        edge[i + m].extend(l)
        for x in l:
            edge[x].append(i + m)

    visited = [False] * (n + m + 1)

    que = deque()
    que.append(m + 1)
    visited[0] = True

    while que:
        cur = que.popleft()
        for nx in edge[cur]:
            if not visited[nx]:
                que.append(nx)
                visited[nx] = True

    for i in range(1, n + 1):
        if not visited[m + i]:
            return print("NO")

    return print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 96004
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
int ans=0;
while(n>0)
{
    n/=k;
    ans++;
}
cout<<ans<<endl;
    return 0;
}


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

/**
 * @author masayamatu
 * 
 */
public class Main {
  
  public static void main(String[] args) throws IOException{
    FastScanner sc = new FastScanner();
    int m = sc.nextInt();
    int d = sc.nextInt();
    int count = 0;
    for(int i = 4; i <= m; i++) {
      for(int j = 22; j <= d; j++) {
        if((j/10)*(j%10) == i && j%10 > 1) {
          count++;
        }
      }
    }
    System.out.println(count);
 }
}
class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,p,c[3010][3010],s[3010][3010],ans;
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
ll kxm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%(p-1);
		x=x*x%(p-1);
		y/=2;
	}
	return xlh;
}
ll solve(ll x){
	ll j,now=1,sum=0,hh=ksm(2,kxm(2,n-x)),ha=ksm(2,n-x);
	for(j=0;j<=x;j++){
		sum=(sum+s[x][j]*now%p*hh%p)%p;
		now=now*ha%p;
	}
	return sum;
}
int main(){
	ll i,j,hh;
	scanf("%d%d",&n,&p);
	for(i=0;i<=n;i++)c[i][0]=1;
	for(i=1;i<=n;i++)
	 for(j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%p;
	s[0][0]=s[1][1]=1;
	for(i=1;i<=n;i++){
		s[i][0]=1;
		for(j=1;j<=i;j++)s[i][j]=(s[i-1][j-1]+s[i-1][j]*(j+1))%p;
	}
	hh=1;
	for(i=0;i<=n;i++){
	  ans=(ans+hh*c[n][i]%p*solve(i)%p)%p;
	  hh=(-hh+p)%p;
	  //printf("%lld\n",hh);
  }
     printf("%lld",ans);
}

Measured memory_bytes: 139904
#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(20);
  int N, K;
  cin >> N >> K;
  double t = 0;
  for (int i = 1; i <= N; i++){
    int c = i;
    int x = 0;
    while (c < K){
      c *= 2;
      x++;
    }
    t += (double) 1 / (1 << x);
  }
  t /= N;
  cout << t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
const int INF = 1e9;
using namespace std;

signed main() {
    int N; cin >> N;
    int sum=0;
    int A[N]; 
    rep(i,N) {
        cin >> A[i];
        sum += A[i];
    } 
    vector<int> ans;
    int a=sum;
    rep(i,N){
        if(i%2==1){
            a-=A[i]*2;
        }
    }
    ans.push_back(a);
    rep(i,N-1){
        ans.push_back(A[i]*2-ans[i]);
    }
    rep(i,N){
        cout << ans[i] << (i==N-1?"":" ");
    }
    cout << endl;
}


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Process terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    'outer: loop {
        let n: usize = sc.read();
        let y: usize = sc.read();

        for i in 0..5000 {
            for j in 0..5000 {
                if i * 10000 + j * 5000 <= y {
                    let r = y - (i * 10000 + j * 5000);
                    let k = r / 1000;
                    if i + j + k == n {
                        println!("{} {} {}", i, j, k);
                        continue 'outer;
                    }
                }
            }
        }
        println!("{} {} {}", -1, -1, -1);
    }
}


Measured memory_bytes: 8572
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def is_ok(arg):
    return a[i] + b[arg] <= k

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n, m, k = MAP()
a = [0] + list(accumulate(LIST()))
b = [0] + list(accumulate(LIST()))

ans = 0
for i in range(n+1):
    if a[i] <= k:
        ans = max(ans, i + meguru_bisect(m+1, -1))
print(ans)

Measured memory_bytes: 46576
#define _USE_MATH_DEFINES
    #include <bits/stdc++.h>
    #define ll  long long
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define vi vector<int>
    #define br cout <<"\n";
    #define all(x)  (x).begin(),(x).end()
    #define tr(c,i) for(auto i : c)
    #define pii pair< int,int >
    #define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
    #define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
    #define er(x) cout << x << " "
    #define err(x,y) cout << x << " "<<y
    using namespace std;
    clock_t time_p = clock();
    void dem()
    {
        time_p=clock()-time_p;
        cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
    }
    using namespace std ;
    const int MAX =  1000 * 1000 + 10;
    const int dx[] = { 1, -1 , 0 , 0  };
    const int dy [] = { 0 ,0 , 1 , -1  };
    const int MOD = 1000 * 1000 * 1000 + 9 ;
    const int N = 301 ;
    const int INF = INT_MAX ;
    const int M = 200005;


    int main (){
  int n ; 
  cin >> n ; 
  for ( int i =  1 ; i <= 9 ; ++ i ){
    for ( int j = 1 ; j <= 9 ; ++ j )
        if ( i * j == n ){cout << "Yes" ; return 0 ;  }
     
  }
    cout << "No" ; 
    return 0 ;
    }
/*
1
10
5 6 5 2 1 7 9 7 2 5
*/



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

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

  string S;
  cin >> S;
  
  int count = 1;
  for (int i = 0; i < N -1; i++) {    
    if (S.at(i) != S.at(i+1)) {
      count++;
    }
  }
  
  cout << count;
	  
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int X,t;

int main(int argc, char const *argv[])
{
    cin>>X>>t;
    if(X-t>=0){
        cout<<X-t<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
//#define endl "/n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n;cin>>n;
    if(n==1){
        cout<<1<<endl<<0<<endl;
    }else if(n==2){
        cout<<2<<endl<<0<<endl<<11<<endl;
    }else{
        cout<<n-1<<endl;
        rep(i,2,n){
            if(i>2){
                cout<<1;
                rep(j,2,i-1){
                    cout<<0;
                }
                cout<<1<<endl;
            }else{
                cout<<11<<endl;
            }
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#include<map>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;

long long now,D,a,t,A,T,x,y,num, N, K, M, ans;
string S;
bool h;
char cc;


int main() {
	A = 1000000;
	cin >> N>>T;
	for (int i = 0; i < N; i++) {
		cin >> a >> t;
		if (t <= T) {
			A = min(A, a);
		}
	}
	if (A == 1000000) {
		cout << "TLE" << endl;
		return 0;
	}
	cout << A << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,f;
string str;
void c()
{

}
int main()
{
	cin>>str;
	for (i=1;i<=str.length();++i)
	{
		if (str[i-1]=='C')
		{
			for (int j=i+1;j<=str.length();++j)
			{
				if (str[j-1]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
// AOJ 2026: Divisor is the Conqueror
// 2017.11.03 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <time.h>

int c[15];
int ans[54];
char f[14][365];		// 364=(13+1)*13/2*4

int rec(int j, int k)
{
	int i;

	if (!j) return 1;
	for (i = 1; i <= 13; i++) {
		if (!c[i]) continue;
		if (f[i][k-i]) {
			c[i]--, ans[j] = i;
			if (rec(j-1, k-i)) return 1;
			c[i]++;
		}
	}
	return 0;
}

int main()
{
	int n, i, v, s;
//	clock_t start, end;

//	start = clock();
	memset(f[1], 1, sizeof(f[1]));
	for (i = 2; i <= 13; i++) {
		f[i][0] = 1;
		for (v = i; v < 365; v += i) f[i][v] = 1;
	}

	while (scanf("%d", &n) && n > 0) {
		if (n == 1) { scanf("%d", &v); printf("%d\n", v); continue; }

		memset(c, 0, sizeof(c));
		for (s = 0, i = 0; i < n; i++) {
			scanf("%d", &v);
			s += v, c[v]++;
		}
		if (rec(n, s)) {
			printf("%d", ans[1]);
			for (i = 2; i <= n; i++) printf(" %d", ans[i]);
			putchar('\n');
		} else puts("No");
	}
//	end = clock();
//	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 1732
/**
 *      ABC 52 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-20 12:03:08
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    ll MOD = 1000000000 + 7;
    ll a[1000 + 5] = {};

    for (auto i = 2; i <= N; ++i) {
        int p = 2; int M = i;
        while (p <= M){
            if (M % p == 0){
                ++a[p]; M /= p;
            }
            else {
                ++p;
            }
        }        
    }

    ll answer = 1;
    for (auto i = 2; i <= N; ++i) {
        answer *= a[i] + 1;
        answer %= MOD;
    }
    cout << answer << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const double pi=acos(-1.0);
const int inf=2000000000;
struct haha
{
     int x1,y1,x2,y2;
     double max_angle,min_angle;
}a[4010];
double angle(int y,int x)
{
    double ang;
    ang=atan2(y,x);
    if (ang<0) ang+=2*pi;
    return ang;
}
double min4(double a,double b,double c,double d)
{
    double min0;
    min0=a;
    if (b<min0) min0=b;
    if (c<min0) min0=c;
    if (d<min0) min0=d;
    return min0;
}
double max4(double a,double b,double c,double d)
{
    double max0;
    max0=a;
    if (b>max0) max0=b;
    if (c>max0) max0=c;
    if (d>max0) max0=d;
    return max0;
}
bool cmp(haha a,haha b)
{
    if (fabs(a.min_angle-b.min_angle)<1e-6) return a.max_angle<b.max_angle;
    else return a.min_angle<b.min_angle;
}
int main()
{
     int n,i,j,cot;
     double answer,light;
     cin>>n;
     for(i=0;i<n;i++)
     {
           cin>>a[i].x1>>a[i].y1>>a[i].x2>>a[i].y2;
           if (a[i].x1>0 && a[i].y1<0 && a[i].y2>=0)
           {
               a[i].min_angle=angle(a[i].y1,a[i].x1);
               a[i].max_angle=angle(a[i].y2,a[i].x1)+2*pi;
           }
           else
           {
                a[i].min_angle=min4(angle(a[i].y1,a[i].x1),angle(a[i].y2,a[i].x1),angle(a[i].y1,a[i].x2),angle(a[i].y2,a[i].x2));
                a[i].max_angle=max4(angle(a[i].y1,a[i].x1),angle(a[i].y2,a[i].x1),angle(a[i].y1,a[i].x2),angle(a[i].y2,a[i].x2));
           }
     }
     sort(a,a+n,cmp);answer=inf;
     for(i=0;i<n;i++)
     {
         a[i+n].min_angle=a[i].min_angle+2*pi;
         a[i+n].max_angle=a[i].max_angle+2*pi;
     }
     for(i=0;i<n;i++)
     {
          light=-inf;cot=0;
          for(j=0;j<n;j++)
            if (light<a[i+j].min_angle)
            {
                light=a[i+j].max_angle;
                cot++;
            }
            else light=min(light,a[i+j].max_angle);
        if (cot<answer) answer=cot;
     }
     cout<<answer<<endl;
     return 0;
}

Measured memory_bytes: 1464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

map<string,ll> cnt;
set<string> st;

int main(){
	IOS();
	ll n,m;
	cin>>n;
	REP(i,n){
		string s;cin>>s;
		cnt[s]++;
		st.insert(s);
	}
	cin>>m;
	REP(i,m){
		string s;cin>>s;
		cnt[s]--;
		st.insert(s);
	}
	ll ans=0;
	for(auto it:st){
		chkmax(ans,cnt[it]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

typedef int INT;
const int SIZE = 16777216;
bool HA[SIZE];

inline INT get( char c ) {
    char T[5] = "ACGT";
    for ( INT i = 0; i < 4; ++ i ) {
        if ( c == T[i] ) return i + 1;
    }
    return 0;
}

int main() {
    INT n, sum, t, c;
    while ( scanf("%d", &n) != EOF ) {
        memset( HA, false, sizeof(HA) );
        while ( getchar() != '\n' );
        for ( register INT i = 0; i < n; ++ i ) {
            sum = 0;
            t = 1;
            bool flag = getchar() == 'i';
            while ( ( c = getchar() ) != ' ' );
            while ( ( c = get( getchar() ) ) != 0 ) {
                sum += c * t;
                t *= 4;
            }
            if ( flag ) {
                HA[sum] = true;
            } else {
                puts( HA[sum] ? "yes" : "no" );
            }
        }
    }
    return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  vector<bool> color(8,false);
  int n;cin>>n;
  int free = 0;
  rep(i,n){
    int tmp;cin>>tmp;
    if(tmp < 3200)color[tmp / 400] = true;
    else free++;
  }
  
  int ans = 0;
  rep(i,8){
    if(color[i])++ans;
  }
  cout<<max(ans,1)<<' '<<ans + free<<endl;
  return 0;
}


Measured memory_bytes: 256
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=10**6
for i in range(m):
    x,y,c=map(int,input().split())
    ans=min(ans,A[x-1]+B[y-1]-c)
print(min(ans,min(A)+min(B)))


Measured memory_bytes: 24828
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>

#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;

int main()
{
    ll a,b,x,y,t=0;
    double ans;
    cin>>a>>b>>x>>y;
    if(x*2==a and y*2==b) t=1;
    ans=(double(a)*double(b))/2.0;
    printf("%.10lf %lld",ans,t);
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
//#define int long long
#define INF 10000000
using namespace std;
bool check(char x){
    for(int i=48; i<=57; i++){
        if(x == i) return true;
    }
    return false;
}
int main(){
    int n;
    cin >> n;
    rep(i,n){
        string a,b;
        cin >> a >> b;
        int flag = 1;
        int tmp,sum = 0;
        rep(j,a.size()){
            if(check((int)a[j])) flag = a[j]-'0';
            else {
                if(a[j] == 'm') tmp = 1000;
                else if(a[j] == 'c') tmp = 100;
                else if(a[j] == 'x') tmp = 10;
                else if(a[j] == 'i') tmp = 1;
                sum += tmp*flag;
                flag = 1;
            } 
        }
        rep(j,b.size()){
            if(check(b[j])) flag = b[j]-'0';
            else {
                if(b[j] == 'm') tmp = 1000;
                else if(b[j] == 'c') tmp = 100;
                else if(b[j] == 'x') tmp = 10;
                else if(b[j] == 'i') tmp = 1;
                sum += tmp*flag;
                flag = 1;
            }
        }
        //cout << sum << endl;
        if(sum/1000 !=0) {
            if(sum/1000 == 1) cout << 'm';
            else cout << sum/1000 << 'm';
            sum -= 1000*(sum/1000);
        }
        if(sum/100 !=0) {
            if(sum/100 == 1) cout << 'c';
            else cout << sum/100 << 'c';
            sum -= 100*(sum/100);
        }
        if(sum/10 !=0) {
            if(sum/10 == 1) cout << 'x';
            else cout << sum/10 << 'x';
            sum -= 10*(sum/10);
        }
        if(sum/1 !=0) {
            if(sum/1 == 1) cout << 'i';
            else cout << sum/1 << 'i';
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>

using namespace std;


int main() {
	vector<int> r;
	int n, c=0;
	cin >> n;
	r.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> r[i];
	}

	c++;//最も西からは見える
	if(n>1)
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				if (r[i] >= r[j]) {
					if (j == i-1) {
						c++;
					}
				}
				else {
					break;
				}
			}
		}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n, k;
  string s;
  cin >> n >> k >> s;
  s[k - 1] -= 'A' - 'a';
  cout << s;
}
#endif


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<P> ans;
unsigned int n;

void solve2() {
  int k=30;
  while((n&(1<<k))==0) {
    k--;
  }
  auto s=(1<<k); // even
  auto r=(n^s^1); // odd
  ans.emplace_back(n, s);
  ans.emplace_back(n+n, r+n);
}

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

  cin >> n;
  if (__builtin_popcount(n)==1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  for(int i=2; i+1<=n; i+=2) {
    ans.emplace_back(i+1, i);
    ans.emplace_back(i, 1);
    ans.emplace_back(1, i+n+1);
    ans.emplace_back(i+n+1, i+n);
  }
  ans.emplace_back(n+1, 3);

  if (n%2==0) solve2();

  for(auto e: ans) {
    cout << e.first << ' ' << e.second << '\n';
  }
}

Measured memory_bytes: 6256