akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int N, K;
    scan(N, K);
    int ans = log(N) / log(K) + 1;
    print(ans);

    return 0;
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    
    int a[n];
    int str=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        str=str^a[i];
    }
    
    int ans[n];
    for(int i=0;i<n;i++)
    {
        ans[i]=str^a[i];
        cout<<ans[i]<<" ";
    }
}

Measured memory_bytes: 6684
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   int n,m,c;
   cin >> n >> m >> c;
   vector<int>b(m);
   vector<vector<int>> a(n,vector<int>(m));
   for(int i = 0;i < m;i++){
       cin >> b[i];
   }
   for(int i = 0;i < n;i++){
       for(int j = 0;j < m;j++){
           cin >> a[i][j];
       }
   }
   int ans = 0;
   for(int i = 0;i < n;i++){
       int sum = 0;
       for(int j = 0;j < m;j++){
           sum += a[i][j] * b[j];
       }
       sum += c;
       if(sum > 0) ans++;
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

la = ["a"] * (W+2)
lz = ["a"] * (W+2)

lall = [la]

for i in range(H):
    l = ["a"]
    s = list(input())
    l = l + s
    l.append("a")
    lall.append(l)

lall.append(lz)

for i in range(1, H+1):
    for j in range(1, W+1):
        if lall[i][j] == ".":
            cnt = lall[i-1][j-1:j+2].count("#")
            if lall[i][j-1] == "#":
                cnt += 1
            if lall[i][j+1] == "#":
                cnt += 1
            cnt += lall[i+1][j-1:j+2].count("#")
            lall[i][j] = cnt

for i in range(1, H+1):
    lans = list(map(str, lall[i]))
    ans = ''.join(lans[1:W+1])
    print(ans)

Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
X = int(input())
s = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            total = 500*a + 100*b + 50*c
            if total == X:
                s+=1
print(s)

Measured memory_bytes: 2940
A,B,C,X,Y = map(int, raw_input().split())
  
m = min(X,Y)
M = max(X,Y)
result = 0
if A + B >= 2 * C:
    result += C * m * 2
    if m == X:
        result += (Y - X) * min(B, 2*C)
    else:
        result += (X - Y) * min(A, 2*C)
else:
    result =  A * X + B * Y

print(result)

Measured memory_bytes: 2568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <complex>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <sstream>
#include <numeric>
#include <functional>
#include <bitset>
#include <iomanip>

using namespace std;

// INF
#define IINF (INT_MAX/2)
#define INF (1<<29)

// math
#define SQ(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

// rep
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define rep(i,n) REP(i,0,n)

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// conversion
template<class T> inline string toStr(T a) { ostringstream oss; oss << a; return oss.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

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

// inRange
inline bool inRange(int x, int y, int W, int H) {
  return 0<=x && x<W && 0<=y && y<H;
}

// isPalindrome
inline bool isPalindrome(string s) {
  return equal(s.begin(), s.end(), s.rbegin());
}

int N, M;
string s[100]; int val[100];

int check(string t) {
  
  rep(i, N) {
    int const SIZE = t.size();
    bool ok = 1;
    rep(j, SIZE) {
      ok = ok && ( s[i][j] == '*' || s[i][j] == t[j] );
    }
    if(ok) {
      return val[i];
    }
  }
  
  return 0;
}

int main() {
  
  while(cin >> N >> M) {
    if(N == 0) return 0;
    rep(i, N) {
      cin >> s[i] >> val[i];
    }
  
    int sum = 0;
    rep(i, M) {
      string t;
      cin >> t;
      sum += check(t);
    }
  
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
#define _USE_MATH_DEFINES

//#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
    
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int a[100];


int main(){
    int n,k;
    int d;
    cin>>n>>k;
    rep(i,100) a[i]=0;

    //vector<int> b(n);
    int c;
    rep(i,k){
        cin>>d;
        rep(j,d){
            cin>>c;
            a[c-1]++;
        } 
    }
    int ans=0;
    rep(i,n) {
        //printf("i=%d, %d\n",i, a[i]);
        if(a[i]==0) ans++;
    }
    cout<<ans<<endl;

} // end of main
    
//実行は、Opt + Ctl + N


//pythonの入力
//s, w = map(int, input().split())


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

int main() {
	long int N,A,B,c;
	cin >> N;
	A=0;
	B=0;
	c=0;
	vector<long int> a(N+1),b(N);
	for(int i=0;i<N+1;i++){
		cin >> a.at(i);
	}
	for(int i=0;i<N;i++){
		cin >>b.at(i);
		A=min(a.at(i)-B,b.at(i));
		B=min(a.at(i+1),b.at(i)-A);
		c=c+(A+B);
	}
	cout << c<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi d(N);
  rep(i,N) {
    cin >> d[i];
  }
  sort(rng(d));
  int ans = 0;
  rep(k,100010) {
    int s = lower_bound(rng(d),k) - d.begin();
    if(s==N-s) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 1e5 + 1;
ll fac[N]; 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        fac[0] = 1;
        ll n, m;
        cin >> n >> m;
        for(i = 1; i <= 1e5; i++){
            fac[i] = i * fac[i - 1];
            fac[i] %= MOD;
        }
        if(n < m){
            swap(n, m);
        }
        if(n - 2 >= m){
            cout << 0;
            return 0;
        }
        ll ans;
        if(n == m){
            
            ans = fac[n] * fac[m];
            
            ans %= MOD;
            ans *= 2;
            ans %= MOD;
        }
        else{
            
            ans = fac[n] * fac[m];
            ans %= MOD;
        }
        cout << ans;
    }
    return 0;
}

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

int main()
{
    std::vector<int> vec;
    
    while (true)
    {
        int n;
        std::cin >> n;
        
        if (n != 0)
            vec.push_back(n);
        else
            break;
    }
    
    int c = 1;
    for (const auto& n : vec)
    {
        std::cout << "Case " << c++ << ": " << n << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inp(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define f(i,a,b) for(ll i=a;i<b;i++)
#define no cout<<"NO\n"
#define yes cout<<"YES\n"
#define maxi(a,n) *max_element(a,a+n)
#define mini(a,n) *min_element(a,a+n)
#define print(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "
#define PI 3.1415926535897932

int gcd(int A, int B) {if(B == 0) return A; else return gcd(B, A % B);}

int main() {
    ll n;
    cin>>n;
    
    ll b[n];
    inp(a,n);
    
    b[0]=0;
    b[1]=abs(a[0]-a[1]);
    
    f(i,2,n)
    {
        b[i] = min(b[i-1] + abs(a[i]-a[i-1]), b[i-2] + abs(a[i]-a[i-2]));
    }
    
    cout<<b[n-1]<<endl;

return 0;
}


Measured memory_bytes: 5172
use std::collections::*;
use std::io::*;
use std::*;
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>();
            ret
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    // iterator(splitted input-string) => iterator(output-type)
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:ty),+) => {
        ($(_get!($it; $t)),*)
    };
}

fn main() {
    let n = get!(i32);
    let a = get!([i32]);
    let mut set = BTreeSet::new();
    for i in a {
        set.insert(i);
    }
    println!("{}", if set.len() == n as usize { "YES" } else { "NO" });
}


Measured memory_bytes: 4828
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    int n;
    double x1, x2, x3, y1, y2, y3, x, y;
    cin >> n;
    for(int i = 0;i < n;i++){
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	if(y1 == y2)swap(x1, x3), swap(y1, y3);
	else if(y1 == y3)swap(x1, x2), swap(y1, y2);
	double x = (x3-x1)/(y1-y3)*(x1+x3)/2-(x2-x1)/(y1-y2)*(x1+x2)/2+(y1+y2)/2-(y1+y3)/2;
	x /= ((x3-x1)/(y1-y3) - (x2-x1)/(y1-y2));
	double y = (x2-x1)/(y1-y2)*(x - (x1+x2)/2) + (y1+y2)/2;
	printf("%.3lf %.3lf %.3lf\n", x, y, hypot(x1-x,y1-y));
    }
    return 0;
}

Measured memory_bytes: 1256
import Data.List

solve :: [Int] -> Int
solve [a1, a2, a3] = task1 + task2
  where [task1, task2, task3] = sort [abs $ a1 - a2, abs $ a2 - a3, abs $ a3 - a1]

main :: IO ()
main = do
  tasks <- map read . words <$> getLine
  print $ solve tasks

Measured memory_bytes: 508
#include<iostream>
using namespace std; // 575

int main() {
	int N;
	string A, B, C;
	cin >> N >> A >> B >> C;
	int ans = 0;
	for (int i = 0;i < N;++ i) {
		int j = 0;
		if (A[i] == B[i]) ++ j;
		if (B[i] == C[i]) ++ j;
		if (A[i] == C[i]) ++ j;
		ans += j == 0 ? 2 : j == 1 ? 1 : 0;
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

各文字独立に見る
全部違う→2, どれか違う→1, 同じ→0
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define pll pair <ll,ll>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const int mod = 1e9+7;
const long double PI = acos(-1);

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	int n;
	cin >> n;
	int a = 0, b = 0, c = 0, d = 0;
	rep0(i,n){
		string s;
		cin >> s;
		if(s=="AC") a++;
		if(s=="WA") b++;
		if(s=="TLE") c++;
		if(s=="RE") d++;
	}
	cout << "AC x " << a << "\n";
	cout << "WA x " << b << "\n";
	cout << "TLE x " << c << "\n";
	cout << "RE x " << d << "\n";

	return;
}
	
int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\;
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 3796
#include <cstdio>

using namespace std;

int a[20010],b[20010],c[20010],p[20010];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;scanf("%d",&n);
	for (int i=1;i<=n;i++) {scanf("%d",&p[i]);c[p[i]]=i;}
	a[1]=1;b[1]=1000000000;
	for (int i=2;i<=n;i++)
	{
		int t=c[i]-c[i-1];
		if (t>0)
		{
			a[i]=a[i-1]+t+1;b[i]=b[i-1]-1;
		}
		else
		{
			a[i]=a[i-1]+1;b[i]=b[i-1]+t-1;
		}
	}
	for (int i=1;i<n;i++) printf("%d ",a[i]);printf("%d\n",a[n]);
	for (int i=1;i<n;i++) printf("%d ",b[i]);printf("%d\n",b[n]);
	return 0;
}


Measured memory_bytes: 896
N,L = map(int, input().split())
aji_list = []
aji_list_abs = []

for i in range(N):
    aji = L + i+1 - 1
    aji_list.append(aji)
    aji_list_abs.append(abs(aji))

aji_list = sorted(aji_list)
min_abs_aji = min(aji_list_abs)

#絶対値化して一番小さい値がaji_listに存在しないなら符号反転
if not min_abs_aji in aji_list:
    min_abs_aji = min_abs_aji * -1

aji_list.remove(min_abs_aji)

print(sum(aji_list))

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
const ll m = 1000000007;
const ll INF  = 1000000000000;
typedef pair<int, int> P;
vector<pair<ll, ll> > v; 

int prime_factorize(ll n) {

  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll ex = 0;
    while (n % i == 0) { ++ex; n /= i; }
    v.push_back( P(i, ex) );
  }
  if (n != 1) v.push_back( P(n, 1) );

  return 0;
}

ll binpow_mod(ll a, ll n, ll m) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % m;
    a = a * a % m;
    n = n >> 1;
  }
  return res;
}

ll comb_mod(ll n, ll r, ll m) {
  ll ans = 1;
  for (ll i = 0; i <= r-1 ; i++) ans = (ans * (n-i)) % m;
  for (int i = r; i >= 1 ; i--) {
    ll num = binpow_mod(i, m-2, m);
    ans = (ans * num) % m;
  }
  return ans;
}

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

    ll N, M;
    cin >> N >> M;

    prime_factorize(M);

    ll ans = 1;
    for(int i = 0; i < v.size(); i++) {
      ll ex = v[i].second;
      ans *= comb_mod(ex + (N-1), ex, m);
      ans %= m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        for(int i=0; i<n; i++) {
            int h = sc.nextInt();
            if(h >= k) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 58224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
const int N = 105;
int d[N][2];
bool check(int i)
{
    return d[i][0] == d[i][1];
}
int main()
{
    int n;
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i)
        scanf("%d%d", &d[i][0], &d[i][1]);

    bool flag = false;
    for (int i = 1; i + 2 <= n; ++i)
    {
        if (check(i) && check(i + 1) && check(i + 2))
        {
            flag = true;
            break;
        }
    }
    if (flag)
        puts("Yes");
    else
        puts("No");
    
    return 0;
}

Measured memory_bytes: 3760
use std::io::Read;
use std::collections::HashMap;


fn freq(a: &Vec<i32>) -> Vec<(i32,usize)> {
    let mut h: HashMap<i32,usize> = HashMap::new();
    for x in a {
        let v = h.entry(*x).or_insert(0);
        *v += 1;
    }
    let mut a: Vec<_> = h.into_iter().collect();
    a.sort_by_key(|x| x.1);
    a.reverse();
    let len = a.len();
    a.resize(std::cmp::min(2, len), (0,0));
    a.push((0,0));
    a
}

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let mut v0 = Vec::new();
    let mut v1 = Vec::new();
    for i in 0..n {
        let x: i32 = iter.next().unwrap().parse().unwrap();
        if i % 2 == 0 {
            v0.push(x);
        }else {
            v1.push(x);
        }
    }
    let mut ans = std::i32::MAX;
    for (g0,f0) in freq(&v0) {
        for (g1,f1) in freq(&v1) {
            if g0 == g1 {
                continue;
            }
            let sub = v0.len() + v1.len() - f0 - f1;
            ans = std::cmp::min(ans, sub as i32);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
using namespace std;
int main(){
    char a;
cin >> a;
if(a=='A') cout<<"T"<<endl;
if(a=='T') cout<<"A"<<endl;
if(a=='G') cout<<"C"<<endl;
if(a=='C') cout<<"G"<<endl;
  return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : ABC 116 C
 *      author  : kyomukyomupurin
 *      created : 2019-01-20 21:08:35
**/

#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int h[n]; 
    rep(i, n) cin >> h[i];

    int cnt = 0;

    while (1){
        if (all_of(h, h + n, [](int x){return x == 0;})){
            print(cnt); return 0;
        }
        else {
            int pos = 0;
            while (pos < n){
                if (h[pos] == 0) ++pos;
                else {
                    while (h[pos] != 0){
                        --h[pos]; ++pos;
                    }
                    ++cnt;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	string s,t;
	cin>>s;
	cin>>t;
	sort(s.begin(),s.end());
	sort(t.rbegin(),t.rend());
	if(s<t) pf("Yes");
	else pf("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define SWAP(type,a,b) { type temp = a; a = b; b = temp; }
#define N 36

typedef struct element{
  char mark;
  int num;
}card;
 

int main(){
  int i, j, n, minj, judge=0;
  card ca[N], cb[N];
  char s;

  scanf("%d%c",&n,&s);
  for(i=0;i<n;i++){
    scanf("%c%d%c",&ca[i].mark,&ca[i].num,&s);
    cb[i] = ca[i];
  }

  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(ca[j].num < ca[j-1].num){
	SWAP(card,ca[j],ca[j-1]);
      }
    }
  }


  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(cb[minj].num > cb[j].num){
	minj = j;
      }
    }
    SWAP(card,cb[minj],cb[i]);
  }

  for(i=0;i<n;i++){
    if(i==n-1) printf("%c%d\n",ca[i].mark,ca[i].num);
    else printf("%c%d ",ca[i].mark,ca[i].num);
  }

  
  printf("Stable\n");

  
  for(i=0;i<n;i++){
    if(i==n-1) printf("%c%d\n",cb[i].mark,cb[i].num);
    else printf("%c%d ",cb[i].mark,cb[i].num);
  }


  
  for(i=0;i<n;i++){
    if(ca[i].mark != cb[i].mark) judge=1;
  }
  if(judge==1) printf("Not stable\n");
  else printf("Stable\n");


  
  return 0;
}



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

int main(){
    int N, T, A;
    cin >> N;
    cin >> T >> A;
    typedef pair<double, int> Pos;
    priority_queue<Pos, vector<Pos>, greater<Pos>> que;
    for(int i=0; i<N; i++){
        int h;
        cin >> h;
        double diff_t = abs((T - h*0.006) - A);
        Pos pos = Pos(diff_t, i);
        que.push(pos);
    }

    Pos target = que.top();
    cout << target.second + 1 << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N; cin >> N;
  ll d = 1;
  while(N > d) d <<= 1;
  if(N == d){
    puts("No");
  }
  else{
    puts("Yes");
    if(N < d-1) d >>= 1;
    // cout << d << endl;
    repi(i, 1, d-1){
      printf("%lld %lld\n", i, i+1);
      printf("%lld %lld\n", N+i, N+i+1);
    }
    printf("%lld %lld\n", d-1, N+1);
    if(N % 2){
      repi(i, d, N+1){
        if(i % 2) continue;
        printf("%lld %lld\n", i, i+1);
        printf("%lld %lld\n", N+i, N+i+1);
        printf("%d %lld\n", 1, i);
        printf("%d %lld\n", 1, N+i+1);
      }
    }
    else{
      repi(i, d, N-2){
        if(i % 2) continue;
        printf("%lld %lld\n", i, i+1);
        printf("%lld %lld\n", N+i, N+i+1);
        printf("%d %lld\n", 1, i);
        printf("%d %lld\n", 1, N+i+1);
      }
      printf("%lld %lld\n", N-2, N);
      printf("%lld %lld\n", 2*N-2, 2*N);
      printf("%lld %lld\n", N-2, (N-2)^N);
      printf("%lld %lld\n", 2*N, (N-2)^N);
      printf("%lld %lld\n", N-1, N-2);
      printf("%lld %lld\n", 2*N-1, ((N-2)^N)+1);
    }
  }
  return 0;
}


Measured memory_bytes: 2560
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  return n*n;
}

Measured memory_bytes: 22964
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	string s;
	
	cin>>s;
	
	if(s[1] == 'B') cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    vector<int> dist(N,0),l(1,0),o;
    rep(i,N){
        ll x;
        cin>>x;
        x--;
        A[i]=x;
    }
    ll p=0,np=-1;
    ll cnt=0;
    while(dist[p]<=1){
        dist[p]++;
        if(dist[p]==2)o.pb(p);
        p=A[p];
        cnt++;
        l.pb(p);
    }
    ll a=0,b=0;
    rep(i,N){
        if(dist[i]==1)a++;
        else if(dist[i]==2){
            b++;
        }
    }
    /*
    for(auto x:o)cout<<x<<" ";
    cout<<endl;
    for(auto x:l)cout<<x<<" ";
    cout<<endl;
    */
    if(a>=K){
        cout<<l[K]+1<<endl;
        //cout<<a<<endl;
        return 0;
    }
    K-=a;
    K%=b;
    cout<<o[K]+1<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 8828
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n; cin>>n;
	vector<ll> a(n);
	rep(i,0,n) cin>>a[i];
	sort(all(a));
	reverse(all(a));
	ll res = 0;
	if(n % 2 == 0){
		for(int i = 0; i < n/2; i++){
			res += 2 * a[i];
		}
	}else{
		for(int i = 0; i < n/2 + 1; i++){
			res += 2 * a[i];
		}
		res -=a[n/2];
	}
	res -= a[0];
	cout<<res<<endl;
}

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

int main(){
	int H, W;

	while(true){
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++) cout << string(W, '#') << endl;
		cout << endl;
	}
}

Measured memory_bytes: 1196
n=int(input())
l=[[]for i in range(n)]
ans=set()
ll=[set() for i in range(n)]
c=1
ab=[]
from collections import Counter
ans2=Counter()
for i in range(n-1):
    a,b=[int(j)-1 for j in input().split()]
    ab.append((a,b))
    l[a].append(b)
    #l[b].append(a)

for i in range(n):
    c=1
    for j in l[i]:
        while True:
            if (c not in ll[j]) and (c not in ll[i]):
                ll[j].add(c)
                ll[i].add(c)
                ans.add(c)
                ans2[(i,j)]=c
                break
            else:
                c+=1
print(len(ans))
#print(ans)
#print(ans2)
for i,j in ab:
    print(ans2[(i,j)])






Measured memory_bytes: 106156
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

char S[8080];
int x, y;

void solve() {
	scanf("%s", S);
	scanf("%d%d", &x, &y);
	int l = 0, L = (int)strlen(S);
	while(l < L && S[l] == 'F') ++l, --x;
	vector <int> v[2];
	for(int i=l, dir=0, c=0;i<=L;i++) {
		if(i == L || S[i] == 'T') {
			if(c > 0) v[dir].pb(c);
			c = 0;
			dir ^= 1;
		}
		else ++c;
	}
	int xx[2] = {x, y};
	rep(u, 2) {
		int vx = xx[u];
		const int ADD = 16020;
		bitset <ADD*2> B; B.reset();
		B[ADD] = 1;
		for(int e : v[u]) {
			B = (B >> e) | (B << e);
		}
		if(B[ADD + vx] == 0) {
			puts("No"); return;
		}
	}
	puts("Yes");
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}




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

typedef long long ll;

const int M=1010;
const ll mod = 1e9L + 7;

char a[M][M];
ll dp[M][M];
int n, m;
void move(ll& a, ll b){
    a = (a + b) % mod;
}

int main(){
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    dp[1][1] = 1;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            int x = i - 1, y = i - 1;
            if(a[i-1][j-1] == '#')continue;
            //move(dp[i][j], dp[i-1][j-1]);
            move(dp[i][j], dp[i-1][j]);
            move(dp[i][j], dp[i][j-1]);
        }
    }
    // for (int i = 0; i <= n; ++i)
    // {
    //     for(int j = 0; j <= m; ++j)cout << dp[i][j] << " ";
    //         cout << endl;
    // }
    cout << dp[n][m] << endl;
} 


Measured memory_bytes: 9216
//??????????????????????????????
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;
typedef complex<double> Point;

namespace std {
  bool operator < (const Point& a, const Point& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

double cross(Point u, Point v) {
	return u.real() * v.imag() - u.imag() * v.real();
}

double dot(Point u, Point v) {
	return u.real() * v.real() + u.imag() * v.imag();
}

//Define : e_Re(???), e_Im(???)
//a -> b -> counter clockwise -> c ???  1
//a -> b -> clockwise -> c         ??? -1
//c--a--b  ???  2
//a--b--c  ??? -2
//a--b(=c) ???  0
int ccw(Point a, Point b, Point c) {
	b -= a; c -= a;
	if (cross(b, c) > 0) return 1;
	if (cross(b, c) < 0) return -1;
	if (dot(b, c) < 0) return 2;
	if (norm(b) < norm(c)) return -2;
	return 0;
}

//counter clockwise, ring buffer(ch[0] == ch[last])
vector<Point> convex_hull(vector<Point> points) {
	int n = points.size();
	int k = 0;
	vector<Point> ch(2 * n);
	
	sort(points.begin(), points.end());
	
	//lower hull
	for (int i = 0; i < n; i++) {
		while (k >= 2 && ccw(ch[k - 2], ch[k - 1], points[i]) <= 0) k--;
		ch[k] = points[i];
		k++;
	}
	
	//upper hull
	int low_k = k;
	for (int i = n - 1; i >= 0; i--) {
		while (k > low_k && ccw(ch[k - 2], ch[k - 1], points[i]) <= 0) k--;
		ch[k] = points[i];
		k++;
	}
	ch.resize(k);
	return ch;
}

//If line (a->b), (c->d) are hit with a point, return true.
bool is_hit_line(Point a, Point b, Point c, Point d) {
	double u = cross(b - a, c - a) * cross(b - a, d - a);
	double v = cross(d - c, a - c) * cross(d - c, b - c);
	if (u > 0 || v > 0) return false;
	if (u != 0 || v != 0) return true;
	
	if (b < a) swap(a, b);
	if (d < c) swap(c, d);
	
	double eps = 1e-10;
	if (abs(d - a) + eps > abs(b - a) + abs(d - c)) return false;
	return true;
}

//poly1, poly2 is convex polygon.
bool is_hit(vector<Point> poly1, vector<Point> poly2) {
	for (int i = 0; i < (int)poly1.size() - 1; i++) {
		for (int j = 0; j < (int)poly2.size() - 1; j++) {
			if (is_hit_line(poly1[i], poly1[i + 1], poly2[j], poly2[j + 1])) {
				return true;
			}
		}
	}
	return false;
}

bool is_cover(vector<Point> poly, Point point) {
	bool in = false;
	for (int i = 0; i < (int)poly.size() - 1; i++) {
		Point a = poly[i] - point;
		Point b = poly[i + 1] - point;
		if (imag(a) > imag(b)) swap(a, b);
		if (imag(a) <= 0 && 0 < imag(b)) if (cross(a, b) < 0) in = !in;
		if (cross(a, b) == 0 && dot(a, b) <= 0) return false;	//on poly
	}
	return in;
}

int main() {
	int n, m;
	while (cin >> n >> m) {
		if (!n) break;
		
		vector<Point> poly1, poly2;
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			poly1.push_back(Point((double)x, (double)y));
		}
		for (int i = 0; i < m; i++) {
			int x, y;
			cin >> x >> y;
			poly2.push_back(Point((double)x, (double)y));
		}
		poly1 = convex_hull(poly1);
		poly2 = convex_hull(poly2);
		
		if (is_hit(poly1, poly2) || is_cover(poly1, poly2[0]) || is_cover(poly2, poly1[0])) { cout << "NO" << endl; }
		else { cout << "YES" << endl; }
	}
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
using namespace std;

void solve()
{
    ll n,x,t;
    cin >> n >> x >> t;
    ll p= (n/x)+(1 && n%x);
    cout << p*t << endl;
}

int main()
{
    int t=1;
    //cin >> t;
    while(t--)
    solve();

    return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

vs input(string& s)
{
	int t = s.find('-');
	string l = s.substr(0, t);
	string r = s.substr(t + 1);
	vs res;
	res.push_back(l); res.push_back(r);
	return res;
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<vs> v(n);
		map<string, int> mp;
		REP(i, n)
		{
			string s; cin >> s;
			v[i] = input(s);
		}
		int p = 0;
		REP(i, n)REP(j, 2)
		{
			string tmp = v[i][j];
			if (mp.count(tmp)) continue;
			mp[tmp] = p;
			p++;
		}
		cout << p << endl;
		Graph g(p);
		Matrix dist(p, Array(p));
		REP(i, n)
		{
			int l = mp[v[i][0]], r = mp[v[i][1]];
			add_edge(g, l, r, 1);
			add_edge(g, r, l, 1);
			dist[r][l] = 1;
		}
		vector<pii> same;
		REP(i, p)REP(j, i)
		{
			bool f1 = false, f2 = true;
			REP(k, p)
			{
				if ((dist[i][k] || dist[k][i]) && (dist[j][k] || dist[k][j])) f1 = true;
				if ((dist[i][k] && dist[k][j]) || (dist[k][i] && dist[j][k])) f2 = false;
			}
			if (f1&&f2) same.emplace_back(i, j);
		}
		for (auto i : same)
		{
			dist[i.first][i.second] = 1;
			dist[i.second][i.first] = 1;
		}
		REP(k, p)REP(i, p)REP(j, p)
		{
			if (dist[i][k] && dist[k][j])
			{
				dist[i][j] = 1;
			}
		}
		vi color(p);
		int col = 1;
		REP(i, p)
		{
			if (color[i]) continue;
			queue<int> que;
			que.push(i);
			int c = col, d = -col;
			color[i] = c;
			while (!que.empty())
			{
				int t = que.front();
				que.pop();
				int nx = (color[t] == c ? d : c);
				REP(j, g[t].size())
				{
					if (color[g[t][j].to]) continue;
					color[g[t][j].to] = nx;
					que.push(g[t][j].to);
				}
			}
			col++;
		}
		int q;
		cin >> q;
		REP(i, q)
		{
			string s; cin >> s;
			vs t = input(s);
			if (!mp.count(t[0]) || !mp.count(t[1]))
			{
				puts("NO");
				continue;
			}
			int l = mp[t[0]], r = mp[t[1]];
			if (color[l] == -color[r] && dist[r][l])
			{
				puts("YES");
			}
			else
			{
				puts("NO");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3348
function Main(input) {
    var res = Number(input);
    var ans = 0;
    for(var i = 0;i <= 9; i++){
      for(var j = 0;j <= 9;j++){
        if(i * j === res) {
          ans++;
        }
      }
    }
    if(ans > 0){
      console.log("Yes");
    }else{
      console.log("No");
    }
 }
 
/* var input = `81`;
Main(input);
 */ 
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10060
#include <stdio.h>
#include <string.h>
 
int main(int argc, char *argv[]){
   int a[8], min, max;
   for(int i = 0; i<3; i++){
      scanf("%d", &a[i]);
   }
 
   min = max = a[0];
 
  for(int i = 1 ; i < 3; i++){
      if(min>a[i]){
        min = a[i];
      }else if(max<a[i]){
         max = a[i];
      }
   }
   
   printf("%d\n",max-min);
   return 0;
}
 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n>>x;
    int d[n+2],l[n+1];
    d[1]=0;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i];
    }
    for(int i=2; i<n+2; i++)
    {
        d[i]=d[i-1]+l[i-1];
    }
    int ans=0;
    for(int i=1; i<n+2; i++)
    {
        if(d[i]<=x)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define endl '\n'
#define gcd __gcd
#define lcm(a,b) (a*b)/gcd(a,b)
#define inf 0xFFFFFFFF/2
#define uinf 0xFFFFFFFF
#define infl 0xFFFFFFFFFFFFFFFF/2
#define uinfl 0xFFFFFFFFFFFFFFFF
#define TEST int t; cin>>t; while(t--)
#define rep(i,a,b) for(int i=(int)a; i<b; i++)
#define repc(i,a,c) for(int i=(int)a; c; i++)
#define reps(i,a,b,s) for(int i=(int)a; i<b; i+=s)
#define repcs(i,a,c,s) for(int i=(int)a; c; i+=s)
#define repn(i,n)  for(int i=0; i<n; i++)
#define per(i,a,b) for(int i=b; i >= a; i--)
#define linv(a,n)  vector<int> a(n); for(int i=0; i<n; i++) cin>>a[i];
#define linp(a,n)  int arr[n]; for(int i=0; i<n; i++) cin>>a[i];
#define lgenv(t,a,n) vector<t> a(n); for(int i=0; i<n; i++) cin>>a[i];
#define lgenp(t,a,n) t a[n]; for(int i=0; i<n; i++) cin>>a[i];
#define lgeni(t,a,n,v) t a[n]; memset(a, v, (sizeof(a)/sizeof(t)));
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define SZ(x) (x).size()
#define DEBUG_ARR(a,n) for(int i=0; i<n; i++) cerr<<a[i]<<" "; cerr<<endl;
#define PRINT_ARR(a,n) for(int i=0; i<n; i++) cout<<a[i]<<" "; cout<<endl;
#define RD_I(fi) freopen(fi, "r", stdin);
#define RD_O(fo) freopen(fo, "w", stdout);
#define RD_IO(fi,fo) RD_I(fi); RD_O(fo);
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector<int> > vvi;

int main()
{
	FIO
	string s;
	cin>>s;
	int len = SZ(s);
	len -= 8;
	repn(i,len)
		cout<<s[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
strs = input()
ans = 0 
curcount = 0
for i in strs:
    if i == "R":
        curcount += 1 
    else:
        if curcount > ans:
            ans = curcount 
        curcount = 0 
if curcount > ans:
    ans = curcount 
    curcount = 0 
print(ans)

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

int main()
{
    int x, y, z;
    int k;
    cin >> x >> y >> z;
    cin >> k;

    vector<long long> a(x), b(y), c(z);
    for (int i = 0; i < x; ++i) cin >> a[i];
    for (int i = 0; i < y; ++i) cin >> b[i];
    for (int i = 0; i < z; ++i) cin >> c[i];

    vector<long long> ab;
    for (int i = 0; i < x; ++i) {
        for (int j = 0; j < y; ++j) {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());

    vector<long long> abc;
    for (int i = 0; i < min(k, (int)ab.size()); ++i) {
        for (int j = 0; j < z; ++j) {
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(abc.begin(), abc.end());
    reverse(abc.begin(), abc.end());

    for (int i = 0; i < k; ++i) {
        cout << abc[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43368
#include <stdio.h>
int main(void){
    int N;
    
    scanf("%d", &N);
    //printf("%d\n", N / 1000);
    if(N % 1000 == 0){
        printf("0\n");
    }else{
        printf("%d\n", (1000) * ((N / 1000) + 1) - N);
    }
    
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
 {
	ll n;
  ll sum=0;
	cin>>n;
  for(int i=1;i<=n;i++){
    if(i%3==0||i%5==0)continue;
    sum+=i;}
  cout<<sum<<endl;}

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

int main () {
        string s; cin >> s;
        for (int i = 0; i < s.size()-1; ++i) {
                if (s[i] == s[i+1]) {
                        cout << i + 1 << " " << i + 2 << endl;
                        return 0;
                }
        }
        for (int i = 0; i < s.size()-2; ++i) {
                if (s[i] == s[i+2]) {
                        cout << i + 1 << " " << i + 3 << endl;
                        return 0;
                }
        }
        cout << -1 << " " << -1 << endl;
        return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll n; cin >> n;
  vector<ll> a(n+1);
  a[0]=-1;
  rep(i,n){
    cin >> a[i+1];
  }
  set<ll> ans;
  for(ll i=n; i>0; i--){
    if(i>n/2){
      if(a[i]==1){
        ans.insert(i);
      }
      continue;
    }
    ll cnt=0;
    for(ll j=2; j<=n/i; j++){
      if(ans.count(i*j)){
        cnt++;
      }
    }
    if(cnt%2!=a[i]){
      ans.insert(i);
    }
  }
  cout << ans.size() << endl;
  for(auto p : ans){
    cout << p << " ";
  }
  return 0;
}




Measured memory_bytes: 8448