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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int count = 0;
  if (a != b && b != c && c != a)
    count = 3;
  else if ((a == b && b != c) || (b == c && c != a) || (c == a && a != b)) {
    count = 2;
  }
  else
    count = 1;
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int A = in(),B  = in();
    cout << (B % A == 0 ? A + B : B - A) << "\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String O = sc.next();
    String E = sc.next();
    
    for(int i=0; i<O.length(); i++){
      System.out.print(O.charAt(i));
      if(i<E.length()){
        System.out.print(E.charAt(i));
      }
    }
  }
}
    

Measured memory_bytes: 35552
#include <stdio.h>

int main(){
	int stuck[10];
	int i,carCnt=0,input;
	for(i=0;i<10;i++){
		stuck[i]=0;
	}
	
	while(scanf("%d",&input)!=EOF){
		if(input==0){
			carCnt--;
			printf("%d\n",stuck[carCnt]);
			stuck[carCnt]=0;
		}else{
			stuck[carCnt]=input;
			carCnt++;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ss := make(map[string]bool)
	var s string
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		ss[s] = true
	}

	fmt.Println(len(ss))
}


Measured memory_bytes: 18904
#include<cstdio>
#include<cstring>


int main(){
  char s[30],t[] = "CODEFESTIVAL2016";
  int ans = 0;
  scanf("%s",s);
  int l = strlen(s);
  for(int i=0;i<l;i++) if(s[i]!=t[i]) ans++;
  printf("%d\n",ans);
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector<ll> dp(n, 0);
    vector<ll> wyst(n + 100, 0);
    if (a[0] != 0)
    {
        cout << "0";
        return 0;
    }
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == 0)
        {
            if (wyst[0] == 0)
                dp[i] = 3;
            if (wyst[0] == 1)
                dp[i] = (dp[i - 1] * (ll) 2) % MOD;
            if (wyst[0] == 2)
                dp[i] = dp[i - 1];
        }
        else
        {
            if (wyst[a[i]] == 0)
            {
                if (wyst[a[i] - 1] == 0)
                    dp[i] = 0;
                if (wyst[a[i] - 1] == 1)
                    dp[i] = dp[i - 1];
                if (wyst[a[i] - 1] == 2)
                    dp[i] = (dp[i - 1] * (ll) 2) % MOD;
                if (wyst[a[i] - 1] == 3)
                    dp[i] = (dp[i - 1] * (ll) 3) % MOD;
            }
            if (wyst[a[i]] == 1)
            {
                if (wyst[a[i] - 1] < 2)
                    dp[i] = 0;
                if (wyst[a[i] - 1] == 2)
                    dp[i] = dp[i - 1];
                if (wyst[a[i] - 1] == 3)
                    dp[i] = (dp[i - 1] * (ll) 2) % MOD;
            }
            if (wyst[a[i]] == 2)
            {
                if (wyst[a[i] - 1] < 3)
                    dp[i] = 0;
                if (wyst[a[i] - 1] == 3)
                    dp[i] = dp[i - 1];
            }
        }
        ++wyst[a[i]];
    }
    cout << dp[n - 1] % MOD;
    return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
int main(){
	int a,b,c,x,i=0;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++){
		if(c%x==0){
			i++;
		}
	}
	printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 2108
// https://atcoder.jp/contests/abc082/tasks/abc082_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, ans = 0;
    cin >> n;
    unordered_map<int, int> mp;
    REP(i, n) {
        cin >> t;
        mp[t]++;
    }
    for (auto &x : mp) {
        if (x.second >= x.first) {
            ans += x.second - x.first;
        } else {
            ans += x.second;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<long> a = vector<long>(n);
    vector<long> b = vector<long>(n);
    vector<long> c = vector<long>(n);
    vector<long> margin;
    long totalMargin = 0;
    long totalShortage = 0;
    int diffNum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        c[i] = a[i] - b[i];
        if (c[i] > 0) {
            margin.push_back(c[i]);
            totalMargin += c[i];
        } else if (c[i] < 0) {
            totalShortage += c[i];
            diffNum += 1;
        }
    }
    if (totalMargin + totalShortage < 0) {
        cout << "-1" << endl;
        return 0;
    }
    sort(margin.begin(), margin.end(), greater<long>());
    int idx = 0;
    while (totalShortage < 0) {
        totalShortage += margin[idx];
        idx += 1;
        diffNum += 1;
    }
    cout << diffNum << endl;
    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define rrep(i, a, b) for(int i=(a); i>=(b); i--)
typedef long long ll;

int main()
{
  string S;
  cin >> S;
  rep(i, 0, (int)(S.size())) cout << "x";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
typedef pair<ll, ll> P;

//const int MAX = 700000;
//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    ll N, ans = 0;
    string S;

    // input
    cin >> N >> S;

    // process
    bool pass_map[11][11][11] = {false};

    for (ll i = 0; i < N; i++) {
        int num = S[i] - '0';
        for (ll j = 0; j < 10; j++) {
            for (ll k = 0; k < 10; k++) {
                if (pass_map[j][k][10]) {
                    pass_map[j][k][num] = true;
                }
            }
            if (pass_map[j][10][10]) {
                pass_map[j][num][10] = true;
            }
        }
        if (!pass_map[num][10][10]) {
            pass_map[num][10][10] = true;
        }
    }

    for (
            ll i = 0;
            i < 10; i++) {
        for (
                ll j = 0;
                j < 10; j++) {
            for (
                    ll k = 0;
                    k < 10; k++) {
                if (pass_map[i][j][k]) {
                    ans++;
                }
            }
        }
    }

    cout <<
         ans;

    return 0;
}

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

bool prime(int x){
	if(x <= 1){
		return false;
	}

	for(int i = 2;i*i <= x;i++){
		if(x%i == 0){
			return false;
		}
	}
	return true;
}


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

	int a = x;
	while(!prime(a)){
		a++;
	}

	cout << a << endl;
}


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

using namespace std;

long long inf = 1e18 + 5;
vector<int> dp(100010, -1);
vector<vector<int> > g(100010, vector<int>());

int calc_dp(int v) {
    if(dp[v] > -1) {
        return dp[v];
    }
    if(g[v].size() == 0) {
        return dp[v] = 0;
    }
    int m = 0;
    for(int i = 0; i < g[v].size(); i++) {
        m = max(m, calc_dp(g[v][i]));
    }
    return dp[v] = m+1;
}

int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        g[y].push_back(x);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        ans = max(ans, calc_dp(i));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> graph[n];
    
    int i;
    int a, b;
    for(i = 0; i < m; i++){
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    
    for(i = 0; i < n; i++){
        cout << graph[i].size() << endl;
    }
}


Measured memory_bytes: 256
while line = gets do
  a, b, c, d, e, f = line.chomp.split.map(&:to_f)
  case
  when d * e != 0
    g = b / e
    h = a / d
    x = c - g * f
    x = ( x == 0.0 )? x : x / ( a - g * d )
    y = c - h * f
    y = ( y == 0.0 )? y : y / ( b - h * e )
  when a * b != 0
    g = e / b
    h = d / a
    x = f - g * c
    x = ( x == 0.0 )? x : x / ( d - g * a )
    y = f - h * c
    y = ( y == 0.0 )? y : y / ( e - h * b )
  when a == 0
    x = f / d
    y = c / b
  when b == 0
    x = c / a
    y = f / e
  end
  puts sprintf( "%1.3f %1.3f", x, y )
end

Measured memory_bytes: 8668
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct frep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr frep(int l_, int r_): l(std::min(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct brep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr brep(int l_, int r_): r(std::max(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  int H, A;
  std::cin >> H >> A;
  std::cout << (H + A - 1) / A << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main()
{
    int K;
    double N,b=0;
    cin>>N>>K;
     for(int i=1;i<=N;i++){
         int c=i;
         double a=1,d;
                d=1/N;
        while(c<K){
            a/=2;
            c*=2;
        }
        b+=a*d;
     }
     cout<< fixed <<setprecision(10)<<b<<endl;
}

Measured memory_bytes: 256
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
double x[100000];
ll m, k;
int a[100000];

int main(){
  auto inv = [&](vector<int> a){
    vector<int> b(a.size());
    rep(i, a.size()) b[a[i]] = i;
    return b;
  };
  
  cin >> n;
  rep(i, n) cin >> x[i];
  cin >> m >> k;
  rep(i, m) cin >> a[i], a[i]--;

  vector<int> g(n - 1);
  iota(all(g), 0);
  rep(i, m) swap(g[a[i] - 1], g[a[i]]);
  g = inv(g);

  vector<int> h(n - 1);
  iota(all(h), 0);

  while (k){
    auto f = [&](vector<int> a, vector<int> b){
      vector<int> c(a.size());
      rep(i, a.size()) c[i] = b[a[i]];
      return c;
    };

    if (k & 1) h = f(h, g);
    g = f(g, g);
    k >>= 1;
  }

  vector<double> y(n - 1);
  rep(i, n - 1) y[i] = x[i + 1] - x[i];
  vector<double> z(n - 1);
  rep(i, n - 1) z[h[i]] = y[i];
  
  vector<double> res(n);
  res[0] = x[0];
  rep(i, n - 1) res[i + 1] = res[i] + z[i];

  rep(i, n) cout << res[i] << endl;
}


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

int main(){
    int i, n;
    string s;
    cin >> n >> s;
    int m = s.size();
    int aloc='A', zloc='Z';
    // cout << aloc << " " << zloc << endl;
    int loc;
    for(i=0; i<m; i++){
        loc = s.at(i);
        // cout << loc << endl;
        if(loc + n > zloc) s.at(i) = aloc + n - zloc + loc-  1; 
        else s.at(i) += n;
    }
    cout << s << endl;
}

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


int main()
{
	int k;
	char s[105];
	scanf("%d%s",&k,s);
	if(strlen(s)<=k) printf("%s",s);
	else {for(int i=0;i<k;++i) putchar(s[i]);puts("...");}
}

Measured memory_bytes: 3708
open System

let n, m, x =
    let l = Console.ReadLine().Split(' ') |> Array.map int
    l.[0], l.[1], l.[2]

let lines =
    [ for i in 0 .. n - 1 do
        yield Console.ReadLine().Split(' ') |> Array.map int ]

let a = Array2D.init n m (fun i j -> lines.[i].[j + 1])
let c = Array.init n (fun i -> lines.[i].[0])

let ans =
    let mutable ans = Int32.MaxValue

    let rec dfs is k =
        if k = n then
            let ok =
                [ for j in 0 .. m - 1 ->
                    [ for i in is -> a.[i, j] ] ]
                |> List.map (fun l -> l |> List.sum)
                |> List.forall (fun sum -> sum >= x)

            if ok then
                let cost =
                    is
                    |> List.map (fun i -> c.[i])
                    |> List.sum
                cost
            else
                -1
        else
            let a, b = dfs is (k + 1), dfs (k :: is) (k + 1)
            match a, b with
            | a, -1 -> a
            | -1, b -> b
            | _ -> min a b
    dfs [] 0

ans |> Console.WriteLine


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

int main(){
	int n;
	while(cin >> n,n){
		int sum = 0,mon = -1;
		for(int i = 0;i < 12;i++){
			int a,b;
			cin >> a >> b;
			sum += a - b;
			if(n <= sum && mon == -1) mon = i;
		}
		if(mon == -1) cout << "NA" << endl;
		else cout << mon + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include<stdio.h>
#include<math.h>
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int i,j;
	int a[55],b[55],c[55],d[55];
	for(i=0;i<n;i++)
	  scanf("%d %d",&a[i],&b[i]);
	for(i=0;i<m;i++)
	  scanf("%d %d",&c[i],&d[i]);
	int min,ans;
	int x;
	for(i=0;i<n;i++)
	{
		min=abs(a[i]-c[0])+abs(b[i]-d[0]);
		ans=1;
		for(j=1;j<m;j++)
		{
			x=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(min>x)
			{
				min=x;
				ans=j+1;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    int k,a,b;
    cin>>k>>a>>b;
    int count=0;
    for(int i=a;i<=b;i++){
        if(i%k==0) {
            count++;
            break;
        }
    }
    if(count) cout<<"OK";
    else cout<<"NG";
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

#define all(x)  x.begin(), x.end()

struct UnionFind {
        int n;
        vector<int> parent;
        vector<int> rank;
        vector<int> num;
        int find(int x) {
                if (parent[x] == x) return  x;
                return parent[x] = find(parent[x]);
        }
        UnionFind(int n_) {
                n = n_;
                parent.resize(n);
                for (int i = 0; i < n; i ++) parent[i] = i;
                rank.assign(n, 0);
                num.assign(n, 1);
        }
        void unite(int x, int y) {
                if ((x = find(x)) != (y = find(y))) {
                        if (rank[x] < rank[y]) {
                                parent[x] = y;
                                num[y] += num[x];
                        } else {
                                parent[y] = x;
                                if (rank[x] == rank[y]) rank[x] ++;
                                num[x] += num[y];
                        }
                        n --;
                }
        }
        bool same(int x, int y) { return find(x) == find(y); }
        int get() { return n; }
        int get(int x) { return num[find(x)]; }
};

struct edge { 
        int a, b, c; 
        edge(int a, int b, int c) : a(a), b(b), c(c) { }
};

static const int INF = 0x3f3f3f3f;
                                 
int main() {
        int n, m;
        while (cin >> n >> m && n) {
                vector<edge> es;
                for (int i = 0; i < m; i ++) {
                        int a, b, c;
                        cin >> a >> b >> c;
                        a --, b --;
                        edge e(a, b, c);
                        es.push_back(e);
                }
                sort(all(es), [](const edge &a, const edge &b) {
                        return a.c < b.c;
                });
                int ans = INF;
                for (int i = 0; i < m; i ++) {
                        int cnt = 0;
                        UnionFind uf(n);
                        for (int j = i; j < m; j ++) {
                                if (uf.same(es[j].a, es[j].b)) continue;
                                uf.unite(es[j].a, es[j].b);
                                cnt ++;
                                if (cnt == n - 1) {
                                        ans = min(ans, es[j].c - es[i].c);
                                        break;
                                }
                        }
                }
                if (ans == INF) ans = -1;
                cout << ans << endl;
        }
        return 0;
}

Measured memory_bytes: 3132
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var h, w int
	fmt.Fscan(r, &h)
	fmt.Fscan(r, &w)

	if min(h, w) == 1 {
		fmt.Println(1)
		return
	}

	n := h * w
	ans := (n + 1) / 2
	fmt.Println(ans)
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 640
N, T = gets.chomp.split(" ").map(&:to_i)
S = []
N.times{
  S << gets.chomp.split(" ").map(&:to_i)
}

sel = S.select{|c, t| t <= T}

if sel.empty? then
  puts 'TLE'
else
  puts sel.min_by{|c, t| c}[0]
end


Measured memory_bytes: 1788
import bisect

n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(n - 2):
    a = L[i]
    for j in range(i + 1, n - 1):
        b = L[j]
        k = bisect.bisect_left(L, a + b)
        ans += k - j - 1
print(ans)


Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
int main(void){
    
    double money[11];
    char s[11][4];
    int n;
    double btc=0;
    double jpy=0;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
    {
        scanf("%lf",&money[i]);
        scanf("%s",s[i]);
    }
    
    for(int i=0;i<n;i++)
    {
        if(s[i][0]=='J')
        {
            jpy = jpy + money[i];
        }
        else
        {
            btc = btc + ( money[i] * 380000);
            
        }
        
    }
    
    printf("%lf",jpy + btc);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main(){
    string s;
    cin >> s;
    int a[3]={0};
    for (int i=0;i<3;i++){
	if (s[i] == 'a') a[0]++;
	else if (s[i] == 'b') a[1]++;
	else if (s[i] == 'c') a[2]++;
    }
    for (int i=0;i<3;i++){
	if (a[i] == 0){
	    cout << "No" << endl;
	    return 0;
	}
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
n, y = map(int,input().split())
s = []
for i in range(n+1):
    for j in range(n+1):
        if i * 10000 + j * 5000 + (n-i-j) * 1000 == y and n-i-j > -1:
            s.append(i)
            s.append(j)
            s.append(n-i-j)
            break
            
if s ==[]:
    print('-1 -1 -1')
else:
    print(str(s[0]) + ' ' + str(s[1]) + ' ' + str(s[2]))
            


Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  char x, y;
  cin>>x>>y;
  if(x>y) cout << '>';
  if(x<y) cout << '<';
  if(x==y) cout <<'=';
  cout << endl;
}

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
using namespace std;





int main(void){
  int N;
  cin >> N;
  vector<int> x;
  vector<int> y;
  for(int i=0;i<N;i++){
    int x_,y_;
    cin >> x_ >> y_;
    x.push_back(x_);
    y.push_back(y_);
  }
  
  vector<int> route;
  for(int i=0;i<N;i++){
    route.push_back(i);
  }
  
  long double fact = 1.0;
  for(int i=1;i<=N;i++){
    fact *= i;
  }
  
  long double length = 0.0;
  do {
    for(int i=0;i<N-1;i++){
      length += sqrt(pow(x[route[i]] - x[route[i+1]],2.0) + pow(y[route[i]] - y[route[i+1]],2.0));
    }
  } while(next_permutation(route.begin(),route.end()));
  
  cout << fixed << setprecision(10) << length / fact << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int N;
  scanf("%d",&N);
  char s[200001][11];
  for(int i=0;i<N;i++){	
    scanf("%s",s[i]);
  }
  if(N==1){
    printf("%s",s[0]);
    return 0;
  }
  
  qsort(s,N,sizeof(char)*11,strcmp);
  
 /* for(int i=0;i<N;i++){	
    printf("%s\n",s[i]);
  }*/
 int max=-1;
  int anser[200001];
  for(int i=0;i<N;i++){
     anser[i]=1;
    }
  for(int i=0;i<N-1;i++){
    if(strcmp(s[i],s[i+1])==0){
      anser[i+1]=anser[i]+1;
    }
    if(anser[i+1]>max)max=anser[i+1];
  }
  
 /* for(int i=0;i<N;i++){
      printf("%d\n",anser[i]);
    }
  */
 for(int i=0;i<N;i++){
    if(anser[i]==max){
      printf("%s\n",s[i]);
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 4988
mod = 2019
# import time

a = input()
n = len(a)
x = [0] * n
# begin = time.time()
for i in range(n):
    x[n - i - 1] = int(a[i])
# print("elapsed 1 = ", time.time() - begin)

# begin = time.time()
ans = 0
cnt = [0] * mod
cnt[0] = 1
s = [0] * (n + 1)
e = 1
# print("elapsed 2 = ", time.time() - begin)

# begin = time.time()
for i in range(n):
    s[i + 1] = ((x[i] * e) % mod + s[i]) % mod
    _ = s[i + 1]
    ans += cnt[_]
    cnt[_] += 1
    e = (e * 10) % mod
# print("elapsed 3 = ", time.time() - begin)

print(ans)



Measured memory_bytes: 77024
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;

LL n , s;
LL b , x , y;

int main(){
	scanf("%lld%lld" , &n , &s);
	for(b = 2 ; b * b <= n ; ++b){
		x = 0;
		y = n;
		while(y > 0){
			x += y % b;
			y /= b;
		}
		if(x == s){
			printf("%lld\n" , b);
			return 0;
		}
	}
	for(b = Mn(s , b - 1) ; b > 0 ; --b){
		if(b * b >= n) continue;
		if((n + b - s) % b == 0 && (s - b) * (b + 1) < n){
			printf("%lld\n" , (n + b - s) / b);
			return 0;
		}
	}
	printf("%lld\n" , s == n ? s + 1 : -1);
	return 0;
}


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

#define int long long
const int N = 3e5 + 10 ;
pair<int,int> row[N] , col[N] ;
map<pair<int,int> , int> mp ;
int32_t main(){
	int n , m , k ;
	cin >> n >> m >> k ;
	for(int i = 0 ; i < N ; i++){
		row[i].second = col[i].second = i ;
	}
	for(int i = 0 ; i < k ; i++){
		int x , y ;
		cin >> x >> y ;
		row[x].first++ , col[y].first++ ;
		mp[{x,y}]++ ;
	}
	sort(row , row + N , greater<pair<int,int>>()) ;
	sort(col , col + N , greater<pair<int,int>>()) ;
	vector<int> f , s ;
	int val = row[0].first + col[0].first ;
	for(int i = 0 ; i < N ; i++){
		if(row[0].first == row[i].first){
			f.push_back(row[i].second) ;
		} else {
			break ;
		}
	}
	for(int i = 0 ; i < N ; i++){
		if(col[0].first == col[i].first){
			s.push_back(col[i].second) ;
		}
	}
	for(auto i : f){
		for(auto j : s){
			if(mp.count({i,j})){
				mp.erase({i,j}) ;
			} else {
				cout << val ;
				return 0 ;
			}
		}
	}
	cout << val - 1 ;
	return 0 ;
}



Measured memory_bytes: 39612
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	static int Y,N;
	public static void main(String[] args) {
	int N=sc.nextInt();
	int X=sc.nextInt();
	if(N*500>=X) {
		p("Yes");
	}else {
		p("No");
	}
    int ans=0;
	int ctn;
	
   /* for(int i=1;i<=N;i++) {
    	String md=sc.next();
    }*/
	
 }
}

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

int main(){
	int n;
	long long pro =1;
	vector<int> array;
	cin >> n;
	for(int i = n; i > 0; i--){
			array.push_back(i);
	}
	for(int i = 0; i < array.size(); i++){
		pro *= array[i];
	}
	cout << pro << endl;
	return 0;
}

Measured memory_bytes: 1212
import collections

n = int(input())
s = input()

s1 = s[:n]
s2 = s[-1:-(n + 1):-1]

s_1 = collections.defaultdict(int)
s_2 = collections.defaultdict(int)

strlist = []

for i in range(2 ** n):
    bin_i = bin(i + 2 ** n)
    sequence1 = ""
    sequence1_inverse = ""
    sequence2 = ""
    sequence2_inverse = ""
    for j in range(n):
        if bin_i[j + 3] == "1":
            sequence1 += s1[j]
            sequence2 += s2[j]
        else:
            sequence1_inverse += s1[j]
            sequence2_inverse += s2[j]
    s_1[sequence1 + "-" + sequence1_inverse] += 1     
    s_2[sequence2 + "-" + sequence2_inverse] += 1
ans = 0

for i in dict(s_1):
    ans += s_1.get(i, 0) * s_2.get(i, 0)
    '''
    if i in dict(s_2):
        ans += dict(s_1)[i] * dict(s_2)[i]
    '''
print(ans)


Measured memory_bytes: 90044
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 5;
typedef long long ll;
template <typename T> void read(T &x) {
	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';
	x *= f;
}
int tot, prime[MAXN], f[MAXN];
void sieve(int n) {
	for (int i = 2; i <= n; i++) {
		if (f[i] == 0) prime[++tot] = f[i] = i;
		for (int j = 1; j <= tot && prime[j] <= f[i]; j++) {
			int tmp = prime[j] * i;
			if (tmp > n) break;
			f[tmp] = prime[j];
		}
	}
}
int a[MAXN], b[MAXN];
int main() {
	int n; read(n), sieve(1e4);
	int now = 1;
	for (int i = 0; i <= n + 1; i++) {
		a[i] = prime[now];
		if (i & 1) now++;
	}
	now++;
	for (int i = 0; i <= n + 1; i++) {
		b[i] = prime[now];
		if (i & 1) now++;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++)
			if ((i + j) & 1) {
				if (i & 1) printf("%lld ", 2ll * a[i - 1] * a[i + 1] * b[j - 1] * b[j + 1] + 1);
				else printf("%lld ", 4ll * a[i - 1] * a[i + 1] * b[j - 1] * b[j + 1] + 1);	
			} else {
				if (i & 1) printf("%lld ", 1ll * a[i] * b[j]);
				else printf("%lld ", 2ll * a[i] * b[j]);
			}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2944
A, B = map(int, input().split())
diff = A - B
if diff == -12:
    print('Alice')
elif -11 <= diff <= -1:
    print('Bob')
elif diff == 0:
    print('Draw')
elif 1 <= diff <= 11:
    print('Alice')
elif diff == 12:
    print('Bob')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;

int main(){
	int h, w, n; scanf("%d%d%d", &h, &w, &n);
	int ans = 0;
	n = h * w - n;
	while(h * w > n){
		if(h < w) h--;
		else w--;
		ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
typedef long long ll;


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

    unordered_set<int> s;
    int N;
    cin>>N;
    for (int i=0; i<N; i++) {
        int a;
        cin>>a;
        s.insert(a);
    }
    if(s.size()==N){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


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

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

int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<char> > field(h+2, vector<char>(w+2, '.'));
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			cin >> field[i][j];
		}
	}
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			if(field[i][j] == '#'){
				cout << "#";
				continue;
			}
			int count = 0;
			for(int d=0; d<8; d++){
				if(field[i+dx[d]][j+dy[d]] == '#'){
					count++;
				}
			}
			cout << (char)('0' +count);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from bisect import bisect_left
from operator import lt, le
def findNearstValue(lst, val, left=True):
    """ソート済のリストから，valに最も近い要素を返す.
    @param lst: ソート済のリスト
    @param left:
        lv < val < rv，val-lv == rv-val のとき，
        Trueならばlvを，Falseならばrvを選択する
    @return もっともvalに値が近いlstの要素
    """
    pos = bisect_left(lst, val)
    if pos == 0: return lst[0]
    if pos == len(lst): return lst[-1]
    lv, rv = lst[pos-1:pos+1]
    op = le if left else lt
    return lv if op(val-lv, rv-val) else rv

def main():
    n = II()
    aa = MII()
    aa.sort()
    ans_n = aa[-1]
    m = ans_n/2
    ans_r = findNearstValue(aa, m)
    print(ans_n, ans_r, end= ' ')

if __name__ == '__main__':
    main()


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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) << " : " << arg1 << " , " ; __f( comma + 1 , args... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;


int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        int a , b;
        cin >> a >> b;
        if( b%a == 0 ) cout << a+b << endl;
        else cout << b-a << endl;
        return 0;
}














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

/*
l : 左, r : 右
f : 前, b : 後ろ
d : 下, u : 上
*/

struct Dice
{
    int l, r, f, b, d, u;

    void RollN()
    {
        int buff = d;
        d = f, f = u, u = b, b = buff;
    }
    void RollS()
    {
        int buff = d;
        d = b, b = u, u = f, f = buff;
    }
    void RollW()
    {
        int buff = d;
        d = l, l = u, u = r, r = buff;
    }
    void RollE()
    {
        int buff = d;
        d = r, r = u, u = l, l = buff;
    }
};

/*
0 -> 上, 1-> 後ろ
2 -> 右, 3-> 左
4 -> 前, 5-> 下
*/

Dice meke_dice(int a[6])
{
    Dice dice;
    dice.u = a[0], dice.b = a[1], dice.r = a[2], dice.l = a[3], dice.f = a[4], dice.d = a[5];
    return dice;
}

int main()
{
    string s;
    int a[6];
    for (int i = 0; i < 6; i++)
        cin >> a[i];
    Dice dice = meke_dice(a);

    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'N')
            dice.RollN();
        if (s[i] == 'E')
            dice.RollE();
        if (s[i] == 'W')
            dice.RollW();
        if (s[i] == 'S')
            dice.RollS();
    }
    cout << dice.u << endl;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>

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

int main()
{
    int D{ 0 }, ret{ 0 };
    cin >> D;

    std::vector<int> c(26), t(D), last(26);
    std::vector<std::vector<int>> s(D, vector<int>(26));

    for (auto& i : c)
    {
        cin >> i;
    }

    for (auto& i : s)
    {
        for (auto& j : i)
            cin >> j;
    }

    for (auto& i : t)
        cin >> i;

    for (int day{ 0 }; day < D; ++day)
    {
        for (int num{ 1 }; num <= 26; ++num)
        {
            if (t.at(day) == num)
            {
                ret += s.at(day).at(num - 1);
                last.at(num - 1) = day + 1;
            }
            else
            {
                ret -= c.at(num - 1) * ((day + 1) - last.at(num - 1));
            }
        }
        cout << ret << "\n";
    }
}


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

int main(){
	int n;	cin>>n;
	vector<int> a(n),b(n),c(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++) cin>>c[i];

	sort(a.begin(), a.end());	sort(c.begin(), c.end());

	long long ans=0;
	for(int j=0;j<n;j++){
		long long i= n-( a.end()-lower_bound(a.begin(), a.end(), b[j]) );
		long long k=c.end()-upper_bound(c.begin(), c.end(),b[j]);

		ans+=i*k;
	}

	cout<<ans<<endl;


	return 0;
}


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

using namespace std;

int main() {

	int n;
	cin >> n;
	
	vector<int> res(4);
	string s;
	for (int i = 1; i <= n; i++) {
		cin >> s;
		if (s == "AC") { res[0]++; }
		if (s == "WA") { res[1]++; }
		if (s == "TLE") { res[2]++; }
		if (s == "RE") { res[3]++; }
	}

	cout << "AC x " << res[0] << endl;
	cout << "WA x " << res[1] << endl;
	cout << "TLE x " << res[2] << endl;
	cout << "RE x " << res[3] << endl;

	return 0;

}

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


int main(){
  int n;
  cin >> n;
  bool k=true;
  vector<int> a(n);
  for(int i=0;i<n;++i){
    cin >> a[i];
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        k=false;
      }
    }
  }
  if(k==true){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    ll H,W;
    cin >> H >> W;
    
    if(H == 1 || W == 1){
        cout << 1 << endl;
    }
    else if(H%2==1 && W%2 == 1){
        cout << (H*W+1)/2 << endl;
    }else{
        cout << H*W/2 << endl;
    }

    
    
    
    

    return 0;
}


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

void cons_rainy_days(void) {
  char str[4];
  scanf("%s", str);
  if (!strcmp(str,"RRR")) {
    printf("3\n");
  } else if ((!strcmp(str,"RRS")) || (!strcmp(str,"SRR"))) {
    printf("2\n");
  } else if (!strcmp(str,"SSS")) {
    printf("0\n");
  } else {
    printf("1\n");
  }
}

int main(void) {
  cons_rainy_days();
  return 0;
}


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

int main()
{
  int n;
  int* p;
  cin >> n;
  p = new int[n];
  for(int i = 0; i < n; i++)
    cin >> p[i];
  int count = 0; 
  for(int i = 1; i < n - 1; i++)
  {
    int c = 0;
    if(p[i - 1] < p[i])
      c++;
    else
      c--;
    if(p[i + 1] < p[i])
      c++;
    else
      c--;
    if(c == 0)
      count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    g = {'Vacant':0, 'Male':1, 'Female':2}



    print(0,flush=True)
    sl = g[input()]
    if sl == 0:
        return

    print(N-1,flush=True)
    sr = g[input()]
    if sr == 0:
        return
    
    l = 0
    r = N-1
    while r-l>1:

        m = (l+r)//2
        print(m,flush=True)
        a = g[input()]
        if a == 0:
            return
        
        if (m-l) % 2 == 1:
            if sl == a:
                r = m
                sr = a
            else:
                l = m
                sl = a

        else:
            if a != sl:
                r = m
                sr = a
            else:
                l = m
                sl = a
        

    print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 77208
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ull = unsigned long long int;
using ll = long long int; 

using namespace std;

int main(){
    ll N,K,Q;

    cin >> N >> K >> Q;

    vector<ll> score(N,0);

    for(int i=0;i<Q;i++){
        ll a;
        cin >> a;
        score[a-1]++;
    }

    for(int i=0;i<N;i++){
        if(Q-score[i]>=K) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

struct State {
  int point;
  int total_cost;
  int cost2zero_times;
  State(int p) : point(p),total_cost(0),cost2zero_times(0) {}
  State(int p,int tc,int cz)
    : point(p), total_cost(tc),cost2zero_times(cz) {}
  bool operator<(const State& s) const{
    return cost2zero_times < s.cost2zero_times;
  }
  bool operator>(const State& s) const{
    return cost2zero_times > s.cost2zero_times;
  }
};

int dp[101][1001];

int bfs(const vector<P> edges[101],int num_of_nodes,int target_cost){
  int res = INF;
  priority_queue<State,vector<State>,greater<State> > que;
  que.push(State(0));
  while(!que.empty()){
    State s = que.top();
    if(s.point == num_of_nodes - 1 && dp[s.point][s.cost2zero_times] < target_cost){
      return s.cost2zero_times;
    }
    que.pop();
    for(int edge_i = 0; edge_i < edges[s.point].size(); edge_i++){
      int next = edges[s.point][edge_i].first;
      int cost = edges[s.point][edge_i].second;
      if(dp[next][s.cost2zero_times] > s.total_cost + cost){
        dp[next][s.cost2zero_times] = s.total_cost + cost;
        que.push(State(next,s.total_cost + cost,s.cost2zero_times));
      }
      if(dp[next][s.cost2zero_times + 1] > s.total_cost){
        dp[next][s.cost2zero_times + 1] = s.total_cost;
        que.push(State(next,s.total_cost,s.cost2zero_times + 1));
      }
    }
  }
  return res;
}

int main(){
  int num_of_nodes;
  int num_of_edges;
  int target_cost;
  while(~scanf("%d %d %d",
               &num_of_nodes,
               &num_of_edges,
               &target_cost)){
    if(num_of_nodes == 0 && num_of_edges == 0 && target_cost == 0){
      break;
    }
    memset(dp,0x3f,sizeof(dp));
    vector<P> edges[101];
    for(int edge_i = 0; edge_i < num_of_edges; edge_i++){
      int src,dst,cost;
      scanf("%d %d %d",&src,&dst,&cost);
      src--; dst--;
      edges[src].push_back(P(dst,cost));
    }
    vector<int> current_cost;
    dp[0][0] = 0;
    printf("%d\n",bfs(edges,num_of_nodes,target_cost));
  }
}

Measured memory_bytes: 1652
using System;
using System.Linq;

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            var house = new int[4, 3, 10];
            for (var i = int.Parse(Console.ReadLine()); i > 0; --i) {
                var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                house[input[0] - 1, input[1] - 1, input[2] - 1] += input[3];
            }

            for (var b = 0; b < 4; ++b) {
                if (b > 0) {
                    Console.WriteLine("####################");
                }
                for (var f = 0; f < 3; ++f) {
                    for (var r = 0; r < 10; ++r) {
                        Console.Write(" " + house[b, f, r]);
                    }
                    Console.WriteLine();
                }
            }
        }
    }
}



Measured memory_bytes: 9528
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vp in;
	rep(i,a){
		int w;
		cin>>w;
		in.pb({-w,0});
	}
	rep(i,b){
		int w;
		cin>>w;
		in.pb({-w,1});
	}
	rep(i,c){
		int w;
		cin>>w;
		in.pb({-w,2});
	}
	sort(all(in));
	int co1=0,co2=0,co3=0,out=0;
	rep(i,in.size()){
		int a=-in[i].first,b=in[i].second;
		if(b==0&&co1<x)co1++,out+=a;
		if(b==1&&co2<y)co2++,out+=a;
		if(b==2)co3++,out+=a;
		if(co1+co2+co3==x+y)break;
	}
	cout<<out<<endl;
}












Measured memory_bytes: 10604
#include <iostream>

using namespace std;

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

  cin >> a >> b >> c;
  if( (a == b) && (a == c))
    cout << 1;
  else if((a == b) || (b == c) || (a == c))
    cout << 2;
  else
    cout << 3;
    return 0;
}


Measured memory_bytes: 256