akhauriyash/Code-Regression huggingface dataset:
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)*}
    };
}

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

fn main() {
    input! {
        p: u32,
        q: u32,
        r: u32,
    }
    println!("{}",
        std::cmp::min(q+r, std::cmp::min(p+q,p+r)));
}


Measured memory_bytes: 4352
n=input()
k=int(input())
keta=len(n)
#桁dp
#dp0 n以下確定
#dp1 未確定
#dp[桁][個数]
dp0=[[0]*(k+1) for _ in range(keta)]
dp1=[[0]*(k+1) for _ in range(keta)]
dp0[0][0]=1
dp0[0][1]=int(n[0])-1
dp1[0][1]=1
for i in range(1,keta):
	# if n[i]=="0":
	# 	for j in range(k+1):
	# 		dp1[i][j]=dp1[i-1][j]
	# 	dp0[i][0]=dp0[i-1][0]
	# 	for j in range(k+1):
	# 		dp0[i][j]=dp0[i-1][j-1]*9+dp0[i-1][j]
	if n[i]=="0":
		conf=dp0
		notconf=dp1
		for j in range(k+1):
			notconf[i][j]=notconf[i-1][j]
		conf[i][0]=conf[i-1][0]
		for j in range(1,k+1):
			conf[i][j]=9*conf[i-1][j-1]+conf[i-1][j]
	else:
		for j in range(1,k+1):
			dp1[i][j]=dp1[i-1][j-1]
		dp0[i][0]=dp0[i-1][0]
		for j in range(1,k+1):
			dp0[i][j]=dp1[i-1][j]+dp1[i-1][j-1]*(int(n[i])-1)+dp0[i-1][j-1]*9+dp0[i-1][j]
print(dp0[-1][k]+dp1[-1][k])





Measured memory_bytes: 3064
function judge(num) { return num === Math.floor(num) }

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var sp = input.split(" ").map(Number);
var count = 0;
for( var i = sp[0]; i <= sp[1]; i++ ) {
  if( judge( sp[2] / i ) ) count++;
}
console.log(count);

Measured memory_bytes: 16252
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut x: usize = read();
    let m: usize = read();
    let mut counter = 0;
    let mut ans = 0;
    let mut surplus: HashMap<usize, usize> = HashMap::new();
    let mut sums: Vec<usize> = Vec::new();
    sums.push(0);
    // 方針 あまりの繰り返しを探して計算
    while counter != n {
        let val = surplus.get(&x);
        ans += x;
        sums.push(ans);
        counter += 1;
        match val {
            None => {
                surplus.insert(x, counter);
            }
            Some(&i) => {
                let loopVal = (n - counter) / (counter - i);
                let div = (n - counter) % (counter - i);
                ans += loopVal * (ans - sums[i]);
                ans += sums[div + i] - sums[i];
                break;
            }
        }
        x = (x * x) % m;
        if x == 0 {
            break;
        }
    }
    print!("{}", ans);
}


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

const int MOD = 998244353;
const int MAX_N = 2e5 + 10;

long long fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    COMBinit();
    ll N, M, K; cin >> N >> M >> K;
    ll M1pow[N]; M1pow[0] = 1;
    for (int i = 1; i < N; i++) {
        M1pow[i] = M1pow[i-1] * (M-1);
        M1pow[i] %= MOD;
    }
    ll ans = 0;
    for (int i = 0; i <= K; i++) {
        ans += ((COMB(N-1, i) * M ) % MOD) * M1pow[N-1-i];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9772
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <deque>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define ctoi(c) c - '0'
#define tos(s) to_string(s)

typedef long long ll;


int main() {
    ll n;
    cin >> n;
    ll m = sqrt(n) + 1;
    int s = 0;
    int ans = 0;
    rep(i,m+2) {
        s = 0;
        while(1) {
            if (n % (i+2) == 0) {
                n /= (i+2);
                s++;
            } else {
                break;
            }
        }
        for (int k=1;k*(k+1)/2<=s;k++) {
            ans++;
        }
    }
    if (n > sqrt(n)) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}

/*
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC                                                                              
                                   ******,  .,, .,, ,,,    ****.**              
                                   ** . .,,,,,,,,,,,,,,,,,,,,,. .,*             
                                   **,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.            
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                    ****      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,      
              ***************,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,    
         ********************,,,,,,,,,,,,,,@@@,,,,,,,,,,,/@@@,,,,,,,,,,,,,,,    
        ******************,,,,,,,,,,,,,,,,,,(,,.         ,,,,,,,,,,,,,,,,,,,    
       ********************,,,,,,,,,,,*,,,,,.     %&&&     .,,,,*,,,,,,,,,,,,.  
       ***,,,,,,,,,,,,,,*,,,,,,,,,,,,,,,,,,,,               ,,,,,,,,,,,,,,,,,   
       ,,,,,,,,,,,,,,,,,,,**,,,,,,,,,,.......      ##(     ........,,,,,,,,,,.  
     .,,,,,,,,,,,,,,,,,,**,,,,,,,,,,..............    ..............,,,,,,,,    
    .,,,,,,,,,,,,,,,,,,,**,,,,,,,,,.................................,,,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,***,,,,,,,....................................,,,,,,,,,  
   ,,,,,,,,,,,,,,,,,,,,**,,,,,,,,.....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,**,,,,,,,,....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,,,     
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,.,,,,,     
    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,        
     ,,,,,,,,,,,,,,,,,,,,,,,,,,,,....................................,,,        
      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,          
       ..,,,,,,,,,,,,,,,,,,,,,,,,,,.................................,           
       .........**.....       ,,,,,..............................               
        .......*......                  ****,**,       ,..****                  
        .......*,....                   .......        ......                   
          .......*....                   .....          .....                   
                                         ......          .....                  
*/

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    cin >> n;

    cout << (1 + n) * n / 2 << endl;
}

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

using namespace std;

const int N = 1e5 + 9;
int n, k, h[N], dp[N];

int sol(int i){
    if(i<0) return 1E9;
    if(i==0) return 0;

    if(~dp[i]) return dp[i];

    int mini = 1E9;
    for(int j=1; j<=k; j++)
        mini = min(mini, abs(h[i]-h[i-j]) + sol(i-j));

    return dp[i] = mini;
}

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

    memset(dp, -1, sizeof dp);
    cout << sol(n - 1);
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
    string S[102];
    int N, L, i, j;

    cin >> N >> L;

    for(i=1; i<=N; i++){
        cin >> S[i];
    }

    sort(S+1, S+N+1);

    for(i=1; i<=N; i++){
        cout << S[i];
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

using III = pair<int, II>;
signed main() {
  int n; cin >> n;
  vector<III> x(n);
  REP (i, n) {
    int a, b; cin >> a >> b;
    x[i] = {a + b, {a, b}};
  }
  sort(RALL(x));
  int ans = 0;
  REP (i, n) {
    if (i % 2 == 0) {
      ans += x[i].se.fi;
    } else {
      ans -= x[i].se.se;
    }
  }
  cout << ans << endl;
}


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

int main(){
    string s;
    cin >> s;
    string result;
    if(s == "Sunny") result = "Cloudy" ;
    if(s == "Cloudy") result = "Rainy";
    if(s == "Rainy") result = "Sunny";
    cout << result << endl;
    return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int h, n;
    cin >> h >> n;

    int a = 0;
    int temp;
    rep (i, n)
    {
        cin >> temp;
        a += temp;
    }

    cout << (a >= h ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,n) for(int i=0;i<(n);++i)
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int INF = 1e9;


int N, M, P;

struct Edge {
  int from, to, cost;
  Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

void visitable(int start, vector<bool> &visited, vvi &edge) {
  queue<int> q;
  q.push(start);
  while (!q.empty()) {
    int from = q.front(); q.pop();
    if (visited[from])
      continue;
    visited[from] = true;
    for (const auto& to : edge[from]) {
      if (!visited[to])
        q.push(to);
    }
  }
}

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

  vector<Edge> edges;
  vvi edge(N, vi()), redge(N, vi());
  rep(i, M) {
    int from, to, cost;
    cin >> from >> to >> cost;
    --from; --to;
    cost = -(cost - P);
    edges.emplace_back(from, to, cost);
    edge[from].push_back(to);
    redge[to].push_back(from);
  }

  vector<bool> can_visit_from_1(N, false),
    can_visit_from_N(N, false);
  visitable(0, can_visit_from_1, edge);
  visitable(N-1, can_visit_from_N, redge);

  int d[N]; fill(d, d+N, INF);
  d[0] = 0;
  rep(i, N) rep(j, M) {
    int from = edges[j].from, to = edges[j].to;
    if (chmin(d[to], d[from] + edges[j].cost)) {
      if (i == N-1) {
        if (can_visit_from_1[from] && can_visit_from_N[from] ||
            can_visit_from_1[to] && can_visit_from_N[to]) {
          cout << "-1\n";
          return 0;
        }
      }
    }
  }
  cout << max(0, -d[N-1]) << endl;

  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void) {
	char a[10], b[10], c[10];
	int alas, bfas, blas, cfas;
	int i;

	scanf("%s", a);
	scanf("%s", b);
	scanf("%s", c);

	for (i = 0; a[i] != NULL; i++) {
		alas = a[i];
	}
	bfas = b[0];
	cfas = c[0];
	for (i = 0; b[i] != NULL; i++) {
		blas = b[i];
	}
	if (alas == bfas && blas == cfas) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
int maxN = 1e5 +1;
long long dp[101][100001];
int main()
{
	int n, k;
	cin>>n>>k;
	vector<int> arr;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		arr.push_back(a);
	}
	for(int i = 0; i <= k; i++){
    	dp[0][i] = (i <= arr[0]);
    		if(i == 0)
			dp[0][i] =1;
    	else if(i <= arr[0])
    		dp[0][i] = 1;
    	else
    		dp[0][i] = 0;
    }
 	
    for(int i = 1; i < n; i++){
        dp[i][0]  = 1;
 
        for(int c = 1; c <= arr[i]; c++){
            dp[i][c] = (dp[i-1][c]+ dp[i][c-1]) % mod;
        }
        for(int c = arr[i]+1;  c <= k; c++){
            dp[i][c] = (dp[i-1][c] + dp[i][c-1] - dp[i-1][c-arr[i]-1] + mod) %mod;
        }
    }
    cout<<dp[n-1][k]<<endl;
    return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n-1; i++) {
        if(a[i] == a[i+1]) {
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
// combination c(max);
// mint c(n, k)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m, k;
    cin >> n >> m >> k;
    mint ans = 0;
    combination c(n);
    for (ll j = 0; j <= k; ++j) {
        ans += c(n-1, j) * mint(m) * mint(m-1).pow(n-1-j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6352
#include <iostream>

using namespace std;

int main(){

  int n,num;
  char s;
  int S[13]={0},H[13]={0},C[13]={0},D[13]={0};

  cin >>n;

  for(int i=0; i<n; i++){
    cin >>s >>num;
    
    if(s=='S'){
      S[(num-1)]=num;
	}
    else if(s=='H'){
      H[(num-1)]=num;
    }
    else if(s=='C'){
      C[(num-1)]=num;
    }
    else if(s=='D'){
      D[(num-1)]=num;
    }
  }
    //S,H,C,Dの順に小さいものから出力
    for(int i=0; i<13; i++){
      if(S[i]==0){
	cout <<"S "<<(i+1)<<endl;
	 }
    }

    for(int i=0; i<13; i++){                                                       
      if(H[i]==0){                                                                   
        cout <<"H "<<(i+1)<<endl;
      }                                                                           
    }
    
    for(int i=0; i<13; i++){                                                           
      if(C[i]==0){                                                                  
        cout <<"C "<<(i+1)<<endl;                                                    
         }                                                                           
    }                                                                               
                                                                                       
    for(int i=0; i<13; i++){                                                           
      if(D[i]==0){                                                                     
        cout <<"D "<<(i+1)<<endl;                                                      
      }                                                                               
    }            
  


  return 0;
}



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


int main() {
	
	string s, t;
	cin >> s >> t;
	vector<int> a(s.size());
	for(int i=0; i<s.size(); i++) a.at(i) = i;
	
	for(int i=0; i<s.size(); i++){
		bool flg = 1;
		for(int i=0; i<s.size(); i++){
			a.at(i)--;
			if(a.at(i)<0) a.at(i) += s.size();
			if(s.at(a.at(i))!=t.at(i)) flg = 0;
		}
		if(flg){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int ma;
int m,n;
int ve[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
void solve(int ni,int nj,int nstep,int isice[100][100]){
    isice[ni][nj]=0;
    bool is=false;
    for(int i=0;i<4;i++){
        int newi=ni+ve[i][0],newj=nj+ve[i][1];
        if(0<=newi&&newi<n&&0<=newj&&newj<m&&isice[newi][newj]!=0){
            solve(ni+ve[i][0],nj+ve[i][1],nstep+1,isice);
            is=true;
        }
    }
    isice[ni][nj]=1;
    if(!is)ma=max(nstep,ma);
}
int main(){
    for(;;){
        scanf("%d%d",&m,&n);
        if(m==0&&n==0)break;
        int isice[100][100];
        for(int i=0;i<n;i++)for(int j=0;j<m;j++)scanf("%d",&isice[i][j]);
        ma=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(isice[i][j]!=0)solve(i,j,1,isice);
            }
        }
        printf("%d\n",ma);
    }
}

Measured memory_bytes: 0
s = input()
q = int(input())
count = 0
top = ""
end = ""
ans = s
for i in range(q):
    tmp = input()
    if tmp[0] == "1":
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if count % 2 == 0:
            if f == "1":
                top = c + top
            else:
                end = end + c
        else:
            if f == "1":
                end = end + c
            else:
                top = c + top

ans = top + ans + end
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)

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

int findSum(int n) {
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}


int main(){
  int a,b,N,X;
  X = 10000;
  cin >> N;
  for(a=1; a<N ;a++){
      b = N -a;
    if (X > findSum(a) + findSum(b)) {
        X = findSum(a) + findSum(b);
    }
  }
   cout << X << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	
int N,A,i,B[200001]={0};
scanf("%d",&N);
for(i=1;i<N;i++)
{scanf("%d",&A);
B[A]++;
}
	for(i=1;i<=N;i++)
	printf("%d\n",B[i]);
		return 0;

 } 


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

using namespace std;

#define ll			long long
#define ALL(s)			(s).begin(),(s).end()
#define ALLn(s,n)		s,s+n
#define F			first
#define S			second
#define pb			push_back
#define tc(t)			int t; cin >> t; while(t--)
#define _			ios_base::sync_with_stdio(false); cin.tie(NULL);
#define PI 3.141592653589793238
const ll MOD = 1e9 + 7;
const ll INF = INT_MAX;
const ll MAX_N = 1e6 + 7;


void solve() {
    int r;
    cin >> r;
    cout << fixed << setprecision(20) << 2*PI*r << "\n";
}

int main() {_
    //tc(t) 
	solve();
}


Measured memory_bytes: 3804
n,k = map(int,input().split())

#modありのコンビネーション計算
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9 + 7
N = n #必要な数
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1,k+1):
    print(cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod)%mod)

Measured memory_bytes: 9260
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

int n;
int a[1001000];
int b[1001000]={};

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    b[a[i]]++;}
  int ans=0;
  for(int i=1;i<=1000000;i++){
    if(b[i]==1)ans++;
    if(b[i]>0){
    for(int j=2;j*i<=1000000;j++){
      b[i*j]=0;}}}
  
  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 6372
import math
N = int(input())
K = list(map(int,input().split()))
hashmap = {}
for k in K:
  if k not in hashmap:
    hashmap[k] = 0
  hashmap[k]+=1
total = 0
for v in hashmap.values():
  if v>=2:
  	total+=math.factorial(v) // (math.factorial(v - 2) * 2)

for k in K:
  print(total-(hashmap[k]-1))

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
string S;
int w, cur;
vi id_B, id_W;

void solve(){
    cur = w-1;
    rep(i, w){
        if(S[i]=='B') id_B.push_back(i);
        else id_W.push_back(i);
    }

    reverse(id_B.begin(), id_B.end());

    rep(i, id_B.size()){
        ans += cur - id_B[i];
        --cur;        
    }

    cout << ans << endl;
}

int main(){
    cin >> S;
    
    while(S[S.size()-1] == 'B') S.pop_back();

    w = S.size();

    solve();
}


Measured memory_bytes: 1532
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;int main(){int i,j=0;string s,l[2]={" ","*"};char x[6];while(cin>>i){if(j)cout<<endl;sprintf(x,"%05d",i);for(j=5;j-->0;)x[j]-='0';s="";while(j++<1){for(i=0;i<5;i++)s+=l[j+(x[i]<5)&1];s+="\n";}for(j=5;j-->0;)s+="=";s+="\n";while(j++<4){for(i=0;i<5;i++)s+=l[x[i]%5!=j];s+="\n";}cout<<s;}return 0;}

Measured memory_bytes: 0
N, Q = map(int, input().split())


class Queue:
    def __init__(self, n):
        self.n = n
        self.q = [0] * (n + 1)
        self.head = 0
        self.tail = 0

    def enqueue(self, e):
        self.q[self.tail] = e
        self.tail = (self.tail + 1) % (self.n + 1)

    def dequeue(self):
        x = self.q[self.head]
        self.head = (self.head + 1) % (self.n + 1)
        return x

    def isEmpty(self):
        return self.head == self.tail


queue = Queue(N)
for _ in range(N):
    i = input().split()
    queue.enqueue([i[0], int(i[1])])
time = 0
while not queue.isEmpty():
    p = queue.dequeue()
    if p[1] <= Q:
        time += p[1]
        print(p[0], time)
    else:
        time += Q
        queue.enqueue([p[0], p[1] - Q])


Measured memory_bytes: 14140
import time
import random
import math
def sigmoid(x):
  if x<-100:
    return 0
  return 1/(1+math.exp(-x))
def score(a,c,s,d):
  l=[-1 for i in range(26)]
  r=0
  for i in range(d):
    l[a[i]]=i
    r+=s[i][a[i]]
    for j in range(26):
      r-=c[j]*(i-l[j])
  return r
  
st=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

ans=[]
l=[-1 for i in range(26)]
ld=[]
for i in range(d):
  ms=-10**9
  mt=None
  for j in range(26):
    js=c[j]*(i-l[j])+s[i][j]
    if ms<js:
      ms=js
      mt=j
  l[mt]=i
  ans.append(mt)
  ld.append([l[mt],d])
  if l[mt]>=0:
    ld[l[mt]][1]=i

os=score(ans,c,s,d)
nt=st
rate=300
while nt-st<1.70:
  nt=time.time()
  na=[ans[i] for i in range(d)]
  na[random.randint(1,d-1)]=random.randint(0,25)
  ns=score(na,c,s,d)
  if sigmoid((ns-os)/rate/((2-nt+st)**4))>random.random():
    os=ns
    ans=na
 
  


for i in ans:
  print(i+1)

Measured memory_bytes: 85216
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	string s;
	getline(cin, s);
	transform(s.begin(), s.end(), s.begin(), ::toupper);
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1176
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-7
#define MOD 999377ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pr;
typedef pair<pair<ll, ll>, pair<ll, ll>> tup;

inline void solve()
{
	int h, n;
	cin >> h >> n;
	vector<int> v(n);
	ll sum = 0;
	fore(i, 0, n)
	{
		cin >> v[i];
		sum += v[i];
	}
	cout << (sum >= h ? "Yes" : "No");
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll N=1e5+5,M=1e6+5;
struct node{
    ll u,v,w,nxt;
}G1[M],G2[M];
ll head1[N],mcnt1;
ll head2[N],mcnt2;
void add_edge1(ll u,ll v,ll w){
    mcnt1++;
    G1[mcnt1].u=u;
    G1[mcnt1].v=v;
    G1[mcnt1].w=w;
    G1[mcnt1].nxt=head1[u];
    head1[u]=mcnt1;
}
void add_edge2(ll u,ll v,ll w){
    mcnt2++;
    G2[mcnt2].u=u;
    G2[mcnt2].v=v;
    G2[mcnt2].w=w;
    G2[mcnt2].nxt=head2[u];
    head2[u]=mcnt2;
}
ll ans1[N],ans2[N];ll ans[N];
struct mode{
    ll u,val;
    mode(ll _u,ll _val){
        u=_u;
        val=_val;
    }
};
queue<mode>q;
void SPFA(ll *dist,ll s,node edge[],ll head[]){
    dist[s]=0;
    q.push(mode(s,0));
    while(!q.empty()){
        mode x=q.front();
        q.pop();
        ll u=x.u,val=x.val;
        if(val>dist[u])
            continue ;
        for(ll i=head[u];i;i=edge[i].nxt){
            ll v=edge[i].v,w=edge[i].w;
            if(dist[v]==-1||w+val<dist[v]){
                q.push(mode(v,w+val));
                dist[v]=w+val;
            }
        }
    }
}
const ll fg=1e15;
int main()//ll
{
    ll n,m,s,t;
    scanf("%lld%lld%lld%lld",&n,&m,&s,&t);
    for(ll i=1;i<=m;i++){
        ll u,v,a,b;
        scanf("%lld%lld%lld%lld",&u,&v,&a,&b);
        add_edge1(u,v,a);
        add_edge1(v,u,a);
        add_edge2(u,v,b);
        add_edge2(v,u,b);
    }
    memset(ans1,-1,sizeof ans1);
    memset(ans2,-1,sizeof ans2);
    SPFA(ans1,s,G1,head1);
    SPFA(ans2,t,G2,head2);
    for(ll i=1;i<=n;i++)
        ans[i]=ans1[i]+ans2[i];
    for(ll i=n-1;i>=1;i--){
        ans[i]=min(ans[i],ans[i+1]);
    }
    for(ll i=1;i<=n;i++)
        printf("%lld\n",fg-ans[i]);
}


Measured memory_bytes: 20608
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

vector<string> vs(1023);
int sx, sy, ex, ey, N, M;

template<typename T>
struct DijkstraGrid {
  int R, C;
  const T INF;
  vector<vector<T>> d;

  DijkstraGrid(int R, int C, T INF): R(R), C(C), INF(INF) {
    if(is_same<T, int>::value) {
      INF = INT_MAX;
    } else {
      INF = LONG_LONG_MAX;
    }
    d = vector<vector<T>>(R, vector<T>(C, INF));
  }

	bool outside_grid(int x, int y) {
		return (x < 0 || y < 0 || x >= R || y >= C);
	}

  T getINF() {
    return INF;
  }

  void find_to_nodes(pair<int, int> &from,
		vector<pair<T, pair<int, int>>> &to_nodes) {
			to_nodes.clear();
			int x = from.F, y = from.S;
      for(int i = -2;i <= 2;i++) {
				for(int j = -2;j <= 2;j++) {
					int xn = x+i, yn = y+j;
					if(outside_grid(xn, yn)) continue;
					if(vs[xn][yn] == '#') continue;
					if(x == xn && y == yn) continue;
					T edge_cost = (abs(x-xn) + abs(y-yn) == 1) ? 0 : 1;
					to_nodes.push_back({edge_cost, {xn, yn}});
				}
		}
	}

  void runDijkstra(int sx, int sy) {
    set<pair<T, pair<int, int>>> q;
    d[sx][sy] = 0;
    q.insert({0, {sx, sy}});
		vector<pair<T, pair<int, int>>> to_nodes;
    while (!q.empty()) {
      auto from = q.begin()->S;
			int x = from.F, y = from.S;
      q.erase(q.begin());
      find_to_nodes(from, to_nodes);
      // cout << x << " " << y << endl;
      for(auto to: to_nodes) {
				T edge_cost = to.F;
				int xn = to.S.F, yn = to.S.S;
        // cout << xn << " " << yn << " " << edge_cost << " : ";
        if(d[x][y] + edge_cost < d[xn][yn]) {
					q.erase({d[xn][yn], {xn, yn}});
          d[xn][yn] = d[x][y] + edge_cost;
          q.insert({d[xn][yn], {xn, yn}});
				}
      }
      // cout << endl;
    }
  }

};


int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);

 cin>>N>>M>>sx>>sy>>ex>>ey;
 sx--;sy--;ex--;ey--;
 rep(i,N) cin>>vs[i];
 DijkstraGrid<int> dg(N,M,INT_MAX);
 dg.runDijkstra(sx, sy);

 if(dg.d[ex][ey] == dg.getINF()) cout<<-1;
 else cout<<dg.d[ex][ey];


 return 0;
}


Measured memory_bytes: 8688
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    ll a,b,c;
    s ss;
    cin>>a>>b>>c;
    ll z = c*(a+b)/2;
    cout<<z;
return 0;}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc128/tasks/abc128_c

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int N, M, k, t, p[10], result = 0;
bool s[10][10];

bool checkLL(bool on[10])
{
  REP(i, M)
  {
    int cnt = 0;
    REP(j, N)
    {
      if (on[j] && s[i][j])
        cnt++;
    }
    if (cnt % 2 != p[i])
      return false;
  }
  return true;
}

int main()
{
  cin >> N >> M;
  REP(i, M)
  {
    cin >> k;
    REP(j, k)
    {
      cin >> t;
      s[i][t - 1] = true;
    }
  }
  REP(i, M)
  {
    cin >> p[i];
  }
  REP(bit, 1 << N)
  {
    bool on[10];
    REP(i, N)
    {
      on[i] = bit & (1 << i);
    }
    if (checkLL(on))
      result++;
  }
  cout << result << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int intcat(int a,int b){
	int d;
	stringstream s;
	s<<a;
	s<<b;
	s>>d;
	return(d); 
}
 
int main(){
    int a,b,d;
    double c;
    cin >> a >> b;
    d=intcat(a,b);
    c=sqrt(d);
    if(c==(int)c){
    	cout << "Yes" << endl;
    }
    else {
    	cout << "No" << endl;
    }
	return 0;
}

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

typedef long long ll;

int main() {
    // dpx[i][j] Xの番で相手がa[i]を持っていて山札の上がa[j]のときの最終スコア
    // dpy[i][j] Yの番で相手がa[i]を持っていて山札の上がa[j]のときの最終スコア
    ll N, Z, W;
    cin >> N >> Z >> W;
    vector<ll> a(N + 2);
    a[0] = Z;
    a[1] = W;
    rep(i, N) cin >> a[i + 2];
    //rep(i, N + 2) cout << a[i] << "\n";
    vector<vector<ll>> dpx(N + 2, vector<ll>(N + 2, 0));
    vector<vector<ll>> dpy(N + 2, vector<ll>(N + 2, 1e18));
    rep(i, N + 1) {
        dpx[i][N + 1] = abs(a[i] - a[N + 1]);
        dpy[i][N + 1] = abs(a[i] - a[N + 1]);
    }
    for (int j = N; j >= 0; j--) {
        rep(i, j) {
            dpx[i][j] = max(dpy[j][j + 1], dpx[i][j + 1]);
            dpy[i][j] = min(dpx[j][j + 1], dpy[i][j + 1]);
        }
    }
    /*
    rep(i, N + 2) {
        rep(j, N + 2) {
            cout << "dpx[" << i << "][" << j << "]=" << dpx[i][j] << "\n";
            cout << "dpy[" << i << "][" << j << "]=" << dpy[i][j] << "\n";
        }
    }
    */
    cout << dpx[1][2] << "\n";
}

Measured memory_bytes: 63104
import java.io.*;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int a[][];
    int b[];
    a=new int[n][m];
    b=new int[m];
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        a[i][j]=sc.nextInt();
      }
    }
    for(int j=0;j<m;j++) b[j]=sc.nextInt();
    for(int i=0;i<n;i++){
      int sum=0;
      for(int j=0;j<m;j++){
        sum+=a[i][j]*b[j];
      }
      System.out.println(sum);
    }
  }
}



Measured memory_bytes: 40900
/*
 * 黒板に N 個の整数が書かれています。i 番目の整数は Aiです。
 * 
 * これらの数に対して、高橋君は以下の操作を繰り返します。
 * 
 *     偶奇が等しい 2つの数 Ai,Ajを一組選び、それらを黒板から消す。
 *     その後、二つの数の和 Ai+Ajを黒板に書く。
 * 
 * 最終的に黒板に数が 1つだけ残るようにできるかどうか判定して下さい。
 */

import java.util.*;
	public class  Main{
		public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            // 入力
            int n = Integer.parseInt(sc.next());
            int count = 0;
            
            for(int i=0; i<n; i++){
            	int a = Integer.parseInt(sc.next());
            	if(a%2==1){
            		count++;
            	}
            }
            // 出力
            if(count%2==0){
            	System.out.println("YES");
            }else{
            	System.out.println("NO");
            }
            sc.close();
        }
    }
	


Measured memory_bytes: 46628
def chmax(DP,b,i,j):
    if DP[i+1][j] < b:
        DP[i+1][j] = b
        return True
    return False
N = int(input())
A = []
for i in range(N):
    L = [i for i in map(int,input().split())]
    A.append(L)
DP = [[0] * 3 for i in range(2*N)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            chmax(DP,DP[i][k] + A[i][j],i,j)
res = 0
for i in range(3):
    res = max(res,DP[N][i]) 
print(res)

Measured memory_bytes: 54308
import math

A, B, C, D = input().split()

T_hp = int(A)
T_atk = int(B)
A_hp = int(C)
A_atk = int(D)

T_burstturn = math.ceil(T_hp / A_atk)
A_burstturn = math.ceil(A_hp / T_atk)

if T_burstturn < A_burstturn:
    print("No")
else:
    print("Yes")

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

int main(void){
    int H,W;
    cin>>H>>W;
    vector<string> s(H);
    rep(y,H)cin>>s[y];

    rep(y,H)rep(x,W){
        if(s[y][x] != '.')continue;
        int cnt = 0;
        for(int dy:{-1,0,+1}){
            for(int dx:{-1,0,+1}){
                if(y+dy==-1 || y+dy==H || x+dx==-1 || x+dx==W)continue;
                if(s[y+dy][x+dx]=='#')cnt++;
            }
        }
        s[y][x]='0'+cnt;
    }
    rep(y,H){
        cout<<s[y]<<endl;
    }
    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

    lli n;
    cin>>n;

    lli num=0;
    cout<<num<<endl;

    string s;
    cin>>s;

    lli start;
    if(s=="Male")start=0;
    else if(s=="Female")start=1;
    else{
        cout<<endl;
        return 0;
    }

    lli small=0,large=n;
    while(1){
        lli middle = (small+large)/2;
        cout<<middle<<endl;

        string q;
        cin>>q;
        lli now;
        lli hope = (start+middle)%2;
        if(q=="Male")now=0;
        else if(q=="Female")now=1;
        else{
            cout<<endl;
            return 0;
        }

        if(hope == now)small=middle+1;
        else large = middle-1;
    }


	return 0;
}

Measured memory_bytes: 852
# UnionFind
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
from dataclasses import *
@dataclass
class UnionFind:
  def __init__(self, n):
    self.n = [-1]*n
    self.r = [0]*n
    self.siz = n

  def find_root(self, x):
    if self.n[x] < 0:
      return x
    else:
      self.n[x] = self.find_root(self.n[x])
      return self.n[x]

  def unite(self, x, y):
    x = self.find_root(x)
    y = self.find_root(y)
    if x == y:
      return
    elif self.r[x] > self.r[y]:
      self.n[x] += self.n[y]
      self.n[y] = x
    else:
      self.n[y] += self.n[x]
      self.n[x] = y
      if self.r[x] == self.r[y]:
        self.r[y] += 1
    self.siz -= 1

  def root_same(self, x, y):
    return self.find_root(x) == self.find_root(y)

  def count(self, x):
    return -self.n[self.find_root(x)]

  def size(self):
    return self.siz

n,q=map(int,input().split())
uf=UnionFind(n)
for _ in range(q):
  t,u,v=map(int,input().split())
  if t==0:
    uf.unite(u,v)
  else:
    print(uf.root_same(u,v)+0)

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

int main(int argc, const char * argv[]) {
    int N;
    int V[20] = {0};
    int C[20] = {0};
    int result = 0;
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    
    for (int i = 0; i < N; i++) {
        if (V[i] > C[i]) {
            result += V[i] - C[i];
        }
    }
    
    cout << result << endl;
    
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

    vector<int> P(N);

    REP(i, N){
        cin >> P[i];
    }

    // sort(P.begin(), P.end());

    int count = 0;
    REP(i, N){
        if(i+1 != P[i]){
            count++;
        }
    }
    if(count > 2){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      vector<int> p;
      for(;n--;)
	{
	  int t;
	  cin>>t;
	  p.push_back(t);
	}
      sort(p.begin(),p.end());
      int sum=0;
      for(int i=1;i<p.size()-1;i++)
	sum+=p[i];
      cout<<sum/(p.size()-2)<<endl;
    }

}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;
const int MOD = 1000000007;

int h[N], a[N], i, n, M;
LL w[3 * N];

void insert (int v, LL b) {
	int s = M + v;
 	while (s) {
       	w[s] = max(w[s], b);
       	s /= 2;
 	}
}

LL query (int a, int b) {
	int va = M + a, vb = M + b;
	LL wyn = w[va];
	if (va != vb) wyn = max(wyn, w[vb]);
	while (va / 2 != vb / 2) {
      	if (va % 2 == 0) wyn = max(wyn, w[va + 1]);
      	if (vb % 2 == 1) wyn = max(wyn, w[vb - 1]);
      	va /= 2; vb /= 2;
	}
	return wyn;
}

void init (int a) {
 	M=1;
 	while (M<a) M*=2;
 	for (int i=1;i<2*M;i++) w[i]=0;
 	M--;
}

int main() {
scanf("%d", &n);
for (i=1;i<=n;i++) scanf("%d", &h[i]);
for (i=1;i<=n;i++) scanf("%d", &a[i]);
init(n);
for (i=1;i<=n;i++) {
	if (h[i] == 1) insert(h[i], a[i]); else insert(h[i], query(1, h[i] - 1) + a[i]);
}
printf("%lld\n", query(1, n));
return 0;
}

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


int main()
{
    long long int n,k,sum=0;
    cin>>n>>k;
    if(n<=k)
    {
        cout<<0;
        return 0;
    }
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    int i,j;
    for(i=n-1,j=0;j<k;--i,++j)
    {
        sum-=a[i];
    }
    cout<<sum;
    
    return 0;
}

Measured memory_bytes: 1024
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int x, n; cin >> x >> n;
    map<int, bool> m;
    FOR(i, 0, n) {
        int p; cin >> p;
        m[p] = true;
    }

    int ans = INF, res = INF;
    eFOR(i, -200, 200) {
        if (m[i])continue;
        if (chmin(res, abs(i - x)))ans = i;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 3636