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


int main(void)
{
    //const double PI=3.141592653589793238;


    long long a, b, c, judge=-1, _judge=-1;
    cin >> a >> b >> c;

    if(a+b-c>0) cout << "No" << endl;
    else if(((a+b-c)*(a+b-c) > 4*a*b)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  int s1=0, s2=0, s3=0, s4=0;
  for(int i=0; i<n; i++){
    cin>>s;
    if(s=="AC")s1++;
    if(s=="WA")s2++;
    if(s=="TLE")s3++;
    if(s=="RE")s4++;
  }
  cout<<"AC"<<" "<<"x"<<" "<<s1<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<s2<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<s3<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<s4<<endl;
  return 0;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

int main() {
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        map<char, int> mp;
        mp[a[i]]++; mp[b[i]]++; mp[c[i]]++;
        int u = 0;
        for (auto p: mp) u = max(u, p.second);
        ans += 3 - u;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


nn=int(input())

if nn==1:
  print(0)
  exit(0)

dct=defaultdict(int)
for i in range(2,nn+1):
  for k,m in factorization(i):
    dct[k]+=m

li=[0]*1000

for k,v in dct.items():
  li[v]+=1

a74=sum(li[74:])
a24=sum(li[24:])
a14=sum(li[14:])
a4=sum(li[4:])
a2=sum(li[2:])

print(a74+(a24*(a2-1)+a14*(a4-1))+(max(a4*(a4-1)//2,0))*max(a2-2,0))




Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(rALL(A));
    for (int i = 0; i < K; i++) {
        ans += A.at(i);
    }
    cout << ans << endl;
}

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

typedef long long ll;

/*
  let's try computer shogi!!!
 */

int main(){
  ll a,b,c,k;
  cin >> a >> b>> c >> k;
  ll diff = (k%2 == 0 ? a-b : b-a);
  if(abs(diff)>1e+18){
    cout<<"Unfail"<<endl;
  }else{
    cout<<diff<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
let a, b, c, d = Scanf.scanf " %c%c%c%c" @@ fun a b c d -> a, b, c, d
let res = if a = b then c = d && b <> c else if a = c then b = d && c <> b else if a = d then b = c && d <> b else false
let _ = print_endline @@ if res then "Yes" else "No"

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v= {1,4,7,9};
int n1,n2,n3,n4;
cin>>n1>>n2>>n3>>n4;
if(n1!=n2 && n1!=n3 && n1!=n4 )
{
if(n2!=n3 && n2!=n4)
{
if(n3!=n4)
{
if(count(v.begin(),v.end(),n1) && count(v.begin(),v.end(),n2) && count(v.begin(),v.end(),n3) && count(v.begin(),v.end(),n4))
cout<<"YES";
else
cout<<"NO";
}
else
cout<<"NO";
}
else
cout<<"NO";
}
else
cout<<"NO";
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<vector<ll> > Graph;
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; }
const int INF = 1e9;


int main(){
    int n,m;
    cin >> n >> m;
    vector<int>k(n,0);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        k[a]++;k[b]++;
    }
    rep(i,n){
        if(k[i]%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

static const int invalid_order = 1000000;
struct data {
	int ID;
	long long total;
	int order;

	data() {
		ID = -1;
		total = 0;
		order = invalid_order;
	}
	data(int n) {
		ID = n;
		total = 0;
		order = invalid_order;
	}

	bool operator<(const data d) const {
		return order < d.order;
	}
};

int main() {
	int n;

	while(cin >> n, n) {
		int price, sale;
		int ID;
		data table[4096];
		bool flag = false;
		int order_count = 0;

		for(int i = 0; i < 4096; i++) {
			table[i].ID = i;
		}

		for(int i = 0; i < n; i++) {
			// input
			/*
			char in[128];
			char ID_s[32], price_s[32], sale_s[32];
			int j, k;
			fgets(in, 120, stdin);
			for(j = 0,k = 0; in[j + k] != ' ' && in[j + k] != ';'; k++)
				ID_s[k] = in[j + k];
			ID_s[k] = '\0';
			j = k + 1;
			for(k = 0; in[j + k] != ' ' && in[j + k] != ';'; k++)
				price_s[k] = in[j + k];
			price_s[k] = '\0';
			j += k + 1;
			for(k = 0; in[j + k] != ' ' && in[j + k] != ';' && in[j + k] && in[j + k] != '\n'; k++)
				sale_s[k] = in[j + k];
			sale_s[k] = '\0';

			ID = atoi(ID_s);
			price = atoi(price_s);
			sale = atoi(sale_s);
			// */ cin >> ID >> price >> sale;

			if(table[ID].order == invalid_order) {
				table[ID].order = order_count;
				order_count++;
			}
			table[ID].total += (long long)price * sale;
		}

		sort(table, table + 4096);

		for(int i = 0; i < order_count; i++) {
			if(table[i].total >= 1000000) {
				cout << table[i].ID << endl;
				flag = true;
			}
		}

		if(!flag)
			cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;


int main() {
int64_t a,b;
cin >> a >> b;
int ans = 0;
for (int i = 1;i < b-a;i++) {
    ans +=i;
}
cout << ans - a << endl;


return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to find the minimum number of 
// characters to be replaced in string S2, such 
// that S1 is a substring of S2 
int main()
{ string S1,S2;
 cin>>S2>>S1;
    int n = S1.size(), m = S2.size(); 
  
    int ans = INT_MAX; 
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar=0; 
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                minRemovedChar++; 
            } 
        }
        ans = min(minRemovedChar, ans); 
    } 
 cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include<algorithm>

using namespace std;

int main (){
	int N;
	cin >> N;
	int a[150];
	for(int i=0; i<N ;i++){
		cin  >> a[i] ;
	}
	sort(a,a+N,greater<int>());
	int B=0, A=0;
	
	for(int i=0; i<N ; i++){
		if(i%2==0){
			B=B+a[i];
			
		}else{
			A=A+a[i];
		}
	}
	cout<< B-A << endl;
	
	return 0;
}


Measured memory_bytes: 256
N,M= map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))
mod=10**9+7
ans=[[0 for e in range(M)] for f in range(N)]
rui=[[0 for e in range(M)] for f in range(N)]
for j in range(M):
 if j!=0:
  rui[0][j]=rui[0][j-1]
 if S[0]==T[j]:
  ans[0][j]=1
  rui[0][j]+=ans[0][j]
for i in range(1,N):
 rui[i][0]=rui[i-1][0]
 if S[i]==T[0]:
  ans[i][0]=1
  rui[i][0]+=ans[i][0]
for i in range(1,N):
 for j in range(1,M):
  rui[i][j]=rui[i][j-1]+rui[i-1][j]-rui[i-1][j-1]
  if S[i]==T[j]:
   ans[i][j]=(rui[i-1][j-1]+1)
   rui[i][j]+=ans[i][j]
  rui[i][j]%=mod
print((rui[N-1][M-1]+1)%mod)

Measured memory_bytes: 107740
use rand::prelude::*;

fn main() {
    let start_time = get_time();

    let mut rnd: rand::rngs::StdRng = rand::SeedableRng::from_seed([0; 32]);

    proconio::input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    }

    let mut t = make_first_t(d, &c, &s);
    let mut sum_v = calc(d, &c, &s, &t).iter().sum::<i64>();

    while get_time() - start_time < 1000_000_000 {
        let dqi = (rnd.gen_range(1, d), rnd.gen_range(1, 26));
        let pret = t[dqi.0 - 1];
        t[dqi.0 - 1] = dqi.1;
        let sum_vi = calc(d, &c, &s, &t).iter().sum::<i64>();
        if sum_vi > sum_v {
            sum_v = sum_vi;
        } else {
            t[dqi.0 - 1] = pret;
        }
    }

    for di in 0..d {
        println!("{}", t[di]);
    }
}

fn get_time() -> u64 {
    let t = std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .unwrap();
    t.as_secs() * 1000_000_000 + t.subsec_nanos() as u64
}

fn make_first_t(
    d: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
) -> Vec<usize> {
    let mut t = vec![0; 365];
    let mut last_d = vec![0; 26];
    let mut prev = 0;
    for di in 0..d {
        let mut max_v = 0;
        let mut max_i = 0;
        for i in 0..26 {
            let pre_last_di = last_d[i];
            last_d[i] = di + 1;
            let v = sum_di(di, prev, &c, &s, i + 1, &last_d);
            last_d[i] = pre_last_di;
            if v > max_v {
                max_v = v;
                max_i = i;
            }
        }
        prev = max_v;
        last_d[max_i] = di + 1;
        t[di] = max_i + 1;
    }
    t
}

fn calc(d: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    t: &Vec<usize>,
) -> Vec<i64> {
    let mut last_d = vec![0; 26];

    let mut prev = 0;
    let mut v = vec![0; 365];
    for di in 0..d {
        last_d[t[di] - 1] = di + 1;
        prev = sum_di(di, prev, &c, &s, t[di], &last_d);
        v[di] = prev;
    }
    v
}

fn sum_di(
    di: usize,
    prev: i64,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    t: usize,
    last_d: &Vec<usize>,
) -> i64 {
    let mut v = prev + s[di][t - 1];
    for i in 0..26 {
        v -= c[i] * ((di + 1 - last_d[i]) as i64);
    }
    v
}


Measured memory_bytes: 2324
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef ll T;
int sgn(T x){return (x>0)-(x<0);}
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lld%lld",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    P operator * (const T&k) const {return P(x*k,y*k);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
};
bool onPS(P p,P s,P t){
    return sgn((t-s)^(p-s))==0&&sgn((p-s)*(p-t))<=0;
}
typedef vector<P> polygon;
int inPpolygon(P p,polygon A){
    int res=0;
    rep(i,0,sz(A)){
        P u=A[i],v=A[(i+1)%sz(A)];
        if(onPS(p,u,v)) return -1;
        T cross = sgn((v-u)^(p-u)) , d1 = sgn(u.y-p.y) , d2 = sgn(v.y-p.y);
        if(cross > 0 && d1 <= 0 && d2 > 0) ++res;
        if(cross < 0 && d2 <= 0 && d1 > 0) --res;
    }
    return res != 0;
}

int main(){
    int n;scanf("%d",&n);
    polygon A;
    rep(i,0,n){
        P p;p.read();
        A.pb(p);
    }
    int Q;scanf("%d",&Q);
    rep(i,0,Q){
        P p;p.read();
        int res=inPpolygon(p,A);
        if(res==-1) puts("1");
        else if(res==0) puts("0");
        else puts("2");
    }
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
どこ通ればいいんだろう
最短というわけでもなさそう
45000ほどの道
補給回数で仮定してるーととるか
DPかな
つど最短とったとして、その先が詰むとかもあるか
通れない道
BFSかな
残り燃料と補給回数
いけそうなきがする
DFSよりBFSのほうが軽そう

まんたんでもいけないばあいあるか
WAぬけた。まだTLE･･･

あーBFSDFSは最悪N^Nなのか
ワーシャルフロイドで最短。N^3
最短わかったけどどういうるーとなのかわかんないな
復元用のデータか
1-2-3-4-5として1-5の最短ルートは
1-5=2
2-5=3
3-5=4
4-5=5
5-5=完

ああ、ゴールまでの最短ルートが通行できるとは限らないんだな
L=3
5-1
3-3-3-3-3
があったら5回補給ルートをとるべきか
Lをこえる長さのみちは通らないとする

なぜWA抜けぬ･･・

ああああ
最短経路でLよりおおきかったらoo、以下で1、和-1が解答は天才。
でも経路保存方法も今後のために通しておきたい･･･。
なんでだめなんだ

ああ、総合距離は短いけど、補給が多いルート、ということか
*/
ll N,M,L,oo=1e12;
vector<vector<ll>> Z;
void wf(){
  for(ll k=1; k<=N; k++){//中継地点だっけ
    for(ll i=1; i<=N; i++){//s
      if(i==k) continue;
      for(ll j=1; j<=N; j++){//g
        if(i==j || k==j) continue;
        ll now=Z[i][j], next=Z[i][k]+Z[k][j];
        if(now<=next) continue;
        Z[i][j]=next;
      }
    }
  }
}

int main(){
  cin>>N>>M>>L;
  Z.assign(N+1,vector<ll>(N+1,oo));
  for(ll i=0; i<M; i++){
    ll a,b,c; cin>>a>>b>>c;
    if(c>L) continue;
    Z[a][b]=Z[b][a]=c;
  }
  wf();
  for(ll i=1; i<=N; i++) for(ll j=1; j<=N; j++) Z[i][j]=(Z[i][j]>L)?oo:1;
  wf();
  ll Q; cin>>Q;
  for(ll i=0; i<Q; i++){
    ll s,t; cin>>s>>t;
    ll ans=(Z[s][t]>=oo)?-1:Z[s][t]-1;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 1280
import itertools

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    a = list(itertools.accumulate(A))
    func1 = (plus, minus)
    func2 = (minus, plus)

    cnt1, cnt2 = 0, 0
    offset1, offset2 = 0, 0
    for i, v in enumerate(a):
        ret = func1[i%2](v + offset1)
        offset1 += ret
        cnt1 += abs(ret)
        ret = func2[i%2](v + offset2)
        offset2 += ret
        cnt2 += abs(ret)
    print(min(cnt1, cnt2))

def plus(n):
    if n <= 0:
        x = 1 - n
        return x
    else:
        return 0

def minus(n):
    if n >= 0:
        x = -1 - n
        return x
    else:
        return 0

main()


Measured memory_bytes: 14340
n, *aa = map(int, open(0).read().split())
MOD = 10**9+7
print(
    (
        (sum(aa)%MOD) ** 2 % MOD
        - sum(a**2%MOD for a in aa) % MOD
    )
    * pow(2, MOD-2, MOD)
    % MOD
)

Measured memory_bytes: 94188
import math
import itertools


N = int(input())
xy = []
for i in range(N):
    xy.append(list(map(int, input().split())))
    
length = 0
for positions in itertools.permutations(xy, N):
    ahead = positions[0]
    for pos in positions[1:]:
        length += ((ahead[0] - pos[0]) ** 2 + (ahead[1] - pos[1]) ** 2) ** 0.5
        ahead = pos
print(length / math.factorial(N))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n + 1; ++i) {
		ll mx = (n - i + n + 1) * i / 2;
		ll mn = i * (i - 1) / 2;
		(ans += mx - mn + 1) %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int N,Y,x,y,z;
int main()
{
	ios::sync_with_stdio(false);
	cin>>N>>Y;
	for (x=0;x<=N;x++)
	for (y=0;y<=N;y++)
	{
		z=N-x-y;
		if (z>=0 && x+y+z==N && x*10000+y*5000+z*1000==Y)
		{
			cout<<x<<' '<<y<<' '<<z;
			return 0;
		}
	}
	cout<<-1<<' '<<-1<<' '<<-1<<' ';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){

  int i, j, n, q, count = 0, S[10000], T[500];

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

  scanf("%d", &q);
  for(i = 0;i < q;i++){
    scanf("%d", &T[i]);
    for(j = 0;j < n;j++){
      if(T[i] == S[j]){
        count++;
        break;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

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

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    int a = A / K;
    int b = a * K;
    a = b;
    b += K;
    if(a == A || (A <= b && b <= B)){
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }

    return 0;
}


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

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    if (A >= H && B >= W) ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3580
#include <iostream>
#include <math.h>

using namespace std;

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;
    int a[n];
    for (int i = 0; i < n; i++)
      cin >> a[i];
    double m = 0.0;
    for (int i = 0; i < n; i++)
      m += a[i];
    m /= n;
    double d = 0.0;
    for (int i = 0; i < n; i++)
      d += pow(a[i]-m, 2);
    d /= n;
    cout << fixed << sqrt(d) << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
using namespace std;
int n,C,s,t,c;
bool cn[30][100001];
int main(){
    cin>>n>>C;
    for(int i=0;i<n;i++){
        cin>>s>>t>>c;
        for(int j=s;j<=t;j++)cn[c-1][j]=1;
    }
    int ans=0,num;
    for(int i=0;i<=100000;i++){
        num=0;
        for(int j=0;j<C;j++)if(cn[j][i])num++;
        ans=max(ans,num);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)
#define IN(v) cin>>v
#define OUT(v) cout<<v<<endl


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

  VVI X;
  REP(i, N) {
    VI v;
    REP(j, D) {
      int x;
      cin >> x;
      v.PB(x);
    }
    X.PB(v);
  }
  int count = 0;
  REP(i, N) {
    FOR(j, i+1, N) {
      int sum = 0;
      REP(k, D) {
        sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      if (sqrt(sum) == floor(sqrt(sum)))
        ++count;
    }
  }
  OUT(count);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
using pp=pair<int,pair<int,int>>;
#define MOD 1000000007
#define INF 1000000000

int main(){
  int N;
  string S;
  cin>>N>>S;
  int r=0;
  int b=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      r++;
    }else{
      b++;
    }
  }

  if(r>b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

#define ll long long
ll x, n, m, res=1, ans;
set<ll>s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n >> m;
    while(n--) {
        cin >> x;
        x /= 2;
        if(s.find(x) == s.end()) {
            s.insert(x);
            res = res / __gcd(res, x) * x;
        }
    }

    for(auto x : s)
        if(res / x % 2 == 0) {
            cout << 0;
            return 0;
        }

    ans = m / res;
    ans = (ans+1) / 2;
    cout << ans;
}

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

struct Mod
{
    static const auto P = int(1e9+7);
    long long k;

    Mod() = default;
    Mod(const long long k) : k(k%P) {}
};

Mod operator*(const Mod a, const Mod b) { return a.k * b.k; }
Mod& operator*=(Mod& a, const Mod b) { return a = a*b; }
Mod power(const Mod a, const int k)
{
    if (k == 0) return 1;
    else if (k % 2 == 0) return power(a*a, k/2);
    else return a * power(a*a, k/2);
}
Mod inverse(const Mod a) { return power(a, Mod::P-2); }

int main()
{
    int N, X, Y; cin >> N >> X >> Y;

    struct Ball { int index, color, weight; };
    auto balls = vector<vector<Ball>>(N);
    for (auto i = 0; i < N; i++)
    {
        int c, w; cin >> c >> w;
        c--;
        balls[c].push_back({i, c, w});
    }

    for (auto& bs : balls)
    {
        sort(begin(bs), end(bs), [](const Ball a, const Ball b) { return a.weight < b.weight; });
        for (auto& b : bs)
            if (b.weight + bs[0].weight <= X)
                b.weight = bs[0].weight;
    }

    const auto compare = [](const vector<Ball>& a, const vector<Ball>& b)
    {
        if (a.empty() && b.empty()) return false;
        else if (a.empty()) return false;
        else if (b.empty()) return true;
        return a[0].weight < b[0].weight;
    };
    sort(begin(balls), end(balls), compare);

    if (N == 1 || balls[1].empty())
    {
        cout << 1 << endl;
        return 0;
    }

    auto counts = vector<int>(N);
    for (const auto& bs : balls) for (const auto b : bs)
    {
        const auto x = b.color == balls[0][0].color ? balls[1][0].weight : balls[0][0].weight;
        if (b.weight + x <= Y) counts[b.color]++;
    }

    auto factorials = vector<Mod>(N+1);
    factorials[0] = 1;
    for (auto n = 1; n <= N; n++)
        factorials[n] = n * factorials[n-1];

    auto inverse_factorials = vector<Mod>(N+1);
    inverse_factorials[N] = inverse(factorials[N]);
    for (auto n = N; n >= 1; n--)
        inverse_factorials[n-1] = n * inverse_factorials[n];

    auto result = factorials[accumulate(begin(counts), end(counts), 0)];
    for (const auto x : counts) result *= inverse_factorials[x];
    cout << result.k << endl;
}


Measured memory_bytes: 13696
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

bool v[1000];

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

  int n;
  cin >> n;
  Vi v;
  while(n){
    v.pb(n % 26);
    bool con = n % 26 == 0;
    n /= 26;
    if (con)
      n --;
  }
  for (int i = v.size() - 1; i >= 0; i--)
    if (v[i])
      cout << char('a' + (v[i] - 1));
    else
      cout << 'z';
  cout << endl;

  
}

Measured memory_bytes: 3612
N,M = map(int,input().split())
res = {}
for i in range(1,N+1):
    res[i] = 0
for _ in range(M):
    a,b = map(int,input().split())
    res[a] += 1
    res[b] += 1
for key in sorted(res.keys()):
    print(res[key])

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
 
int main()
{
    ios::sync_with_stdio(false);
    int n;
    unsigned long long int ans = 0;
 
    cin >> n;
 
    for (int i = 1; i <= n; i++)
    {
        if (!((i % 3 == 0 && i % 5 == 0) or (i % 3 == 0) or (i % 5 == 0)))
        {
            // cout<<i<<endl;
            ans += i;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

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

using namespace std;

/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
/* }}} */

int main(void)
{
  int n, m;
  int my, miss;
  int target[110];
  int ans[110] = {};

  cin >> n >> m;
  rep(i, m){
    cin >> target[i];
  }

  rep(i, m){
    miss = 0;
    rep(j, n){
      cin >> my;
      if (my == target[i]) ans[j]++;
      else miss++;
    }
    ans[target[i] - 1] += miss;
  }

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

  return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int R, C, N;
//---------------------------------------------------------------------------------------------------
int parse(int x, int y) {
    if (x != 0 && x != R && y != 0 && y != C) return -1;
    if (y == 0) return x;
    else if (x == R) return R + y;
    else if (y == C) return R + C + (R - x);
    else return 2 * R + C + (C - y);
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> R >> C >> N;
    vector<pair<int, int>> v;
    rep(i, 0, N) {
        int a, b, c, d; cin >> a >> b >> c >> d;

        int x = parse(a, b);
        if (x < 0) continue;
        int y = parse(c, d);
        if (y < 0) continue;

        v.push_back({ x, i });
        v.push_back({ y, i });
    }
    sort(v.begin(), v.end());

    stack<int> sta;
    for (auto p : v) {
        if (!sta.empty()) {
            if (sta.top() == p.second) sta.pop();
            else sta.push(p.second);
        }
        else sta.push(p.second);
    }

    if(sta.empty()) printf("YES\n");
    else printf("NO\n");
}

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

int main() {
  long long int N,M,i,j=0,k=0;
  cin>>N;
  long long int A[N];
  for(i=0;i<N;i++) cin>>A[i];
  k=A[0];
  for(i=0;i<N;i++) {
      if(k>=A[i]) j++;
      k = min(k, A[i]);
  }
  cout<<j<<endl;
  return (0);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
char a[25][25];
int ans=0,dx[4]={0,0,1,-1},dy[4]={1,-1,0,0},n,m,num[25][25];
void bfs(int sx,int sy){
	queue<pair<pair<int,int>,int>> q;
	map<pair<int,int>,int> vis;
	q.push({{sx,sy},0});
	vis[{sx,sy}]=1;num[sx][sy]=max(num[sx][sy],0);
	while(!q.empty()){
		int x=q.front().first.first;
		int y=q.front().first.second;
		int v=q.front().second;q.pop();
		for(int i=0;i<4;i++){
			int nx=x+dx[i],ny=y+dy[i];
			if(nx<1||nx>n||ny<1||ny>m||a[nx][ny]=='#'||vis[{nx,ny}]==1) continue;
			vis[{nx,ny}]=1;num[nx][ny]=max(num[nx][ny],v+1);
			q.push({{nx,ny},v+1});
		}
	}
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#') continue;
			bfs(i,j);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			ans=max(ans,num[i][j]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main()
{
    ll a,b,q;
    cin >> a >> b >> q;
    vector<pll> s(a),t(b);
    rep(i,a){
        cin >> s[i].fi;
    }
    rep(i,b){
        cin >> t[i].fi;
    }
    rep(i,a){
        auto it=lower_bound(t.begin(),t.end(),make_pair(s[i].fi,s[i].se))-t.begin();
        ll v=abs(t[it].fi-s[i].fi);
        if(it!=0) v=min(v,abs(t[it-1].fi-s[i].fi));
        s[i].se=v;
    }
    rep(i,b){
        auto it=lower_bound(s.begin(),s.end(),make_pair(t[i].fi,t[i].se))-s.begin();
        ll v=abs(s[it].fi-t[i].fi);
        if(it!=0) v=min(v,abs(s[it-1].fi-t[i].fi));
        t[i].se=v;
    }
    rep(i,q){
        ll x;
        cin >> x;
        ll ans=INF;
        auto it1=lower_bound(s.begin(),s.end(),make_pair(x,0LL))-s.begin();
        auto it2=lower_bound(t.begin(),t.end(),make_pair(x,0LL))-t.begin();
        if(it1!=a){
            ans=min(ans,abs(x-s[it1].fi)+s[it1].se);
        }
        if(it2!=b){
            ans=min(ans,abs(x-t[it2].fi)+t[it2].se);
        }
        if(it1!=0){
            ans=min(ans,abs(x-s[it1-1].fi)+s[it1-1].se);
        }
        if(it2!=0){
            ans=min(ans,abs(x-t[it2-1].fi)+t[it2-1].se);
        }
        cout << ans << endl;
    }
    return 0;
} 

Measured memory_bytes: 4480
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
xy = [LI() for i in range(N)]

sum = 0  # 2点間の距離の総和*2
for i in range(N):
    for j in range(N):
        sum += ((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)**.5

print(sum/N)

Measured memory_bytes: 62400
n = gets.to_i
sticks = gets.split.map(&:to_i)
sides = [0, 0]
sticks.tally.each do |k, v|
  if v >= 4
    2.times { sides << k }
  elsif v >= 2
    sides << k
  end
end
puts sides.sort.reverse[0, 2].inject(:*)

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  int a, b, c;
  cin>>a>>b>>c;
  if((b-a) == (c-b)) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    string s;
    ll K;
    cin>>s>>K;
    ll same=0;
    ll ans=0;
    ll a=-1,b=-1;
    if(s.size()==1){
        cout<<s.size()*K/2<<endl;
        return 0;
    }
    for(ll i=0; i<s.size()-1; i++){
        if(s[i]!=s[i+1]){
           a=i; break; 
        }
    }
    for(ll i=s.size()-1; i>0; i--){
        if(s[i-1]!=s[i]){
            b=i; break;
        }
    }
    if(a==-1||b==-1){
        cout<<s.size()*K/2<<endl;
        return 0;
    }
    for(ll i=a; i<b; i++){
        if(s[i]==s[i+1]){
            same++;
            while(s[i]==s[i+1] && i<b){
                same++;
                i++;
            }
            ans+=same/2;
            same=0;
        }
    }
    ll size=s.size();
    ans*=K;
    if(s[0]==s[s.size()-1]){
        ans+=(a+1)/2;
        ans+=(size-b)/2;
        ans+=( (a+1+size-b)/2 )*(K-1);        
    }else{
        ll tmp=(a+1)/2;
        ans+=tmp*K;
        tmp=(size-b)/2;
        ans+=tmp*K;
    }
    cout<<ans<<endl;
}

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

int main(){
    int n;
    long long mini = 1000010,maxi = -1000010;
    long long sum = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        long long x;
        cin >> x;
        if(mini > x){
            mini = x;
        }
        if(maxi < x){
            maxi = x;
        }
        sum += x;
    }
    printf("%d %d %lld\n",mini,maxi,sum);
    return 0;
}


Measured memory_bytes: 3232
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=300,MAX_M=300;

int N,M,A[MAX_N][MAX_M];

bool flg[MAX_M];
int ite[MAX_N];
vector<int> sp[MAX_M];
int main(){
	cin>>N>>M;
	REP(i,N){
		REP(j,M){
			cin>>A[i][j];
			A[i][j]--;
		}
	}
	REP(i,N){
		sp[A[i][0]].push_back(i);
	}
	int ans=N;
	memset(flg,true,sizeof(flg));
	REP(i,M){
		int mx=-1;
		FOR(j,0,M){
			if (flg[j] && (mx==-1 || sp[j].size()>sp[mx].size())){
				mx=j;
			}
		}
		ans=min(ans,(int)sp[mx].size());
		flg[mx]=false;
		for(auto j:sp[mx]){
			while(ite[j]<M && !flg[A[j][ite[j]]]){
				ite[j]++;
			}
			if (ite[j]<M){
				sp[A[j][ite[j]]].push_back(j);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

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

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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

void solve() {
	int n, r; cin >> n >> r;
	if (n >= 10) {
		cout << r << endl;
	}
	else {
		cout << r + 100 * (10 - n) << endl;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
	return 0;
}


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

constexpr auto DictSize = ((1 << 26) - 1)/3;

bool dict[DictSize];

int myhash(char* str){
    int n = strlen(str);
    int num = 0;
    for (int i = 0; i != n; ++i){
        num *= 4;
        if (str[i] == 'A'){
            num += 0;
        }else if (str[i] == 'C'){
            num += 1;
        }else if (str[i] == 'G'){
            num += 2;
        }else if (str[i] == 'T'){
            num += 3;
        }
    }
    num += ((1 << (2*n)) - 4) / 3;
    return num;
}


int main()
{
    ios::sync_with_stdio(false);
    memset(dict, false, DictSize);
    int n = 0;
    cin >> n;
    char command[7];
    char str[13];
    for (int i = 0; i != n; ++i){
        cin >> command >> str;
        if (command[0] == 'i'){
            dict[myhash(str)] = true;
        }else if(dict[myhash(str)]){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24988
def main():
  n,k,*t=map(int,open(0).read().split())
  e=[set()for _ in[0]*n]
  for a,b in zip(t[::2],t[1::2]):
    e[a-1]|={b-1}
    e[b-1]|={a-1}
  c,q=k,[0]
  while q:
    v,i=q.pop(),1
    for w in e[v]:
      c=c*(k-i-(v>0))%(10**9+7)
      e[w]-={v}
      q+=w,
      i+=1
  print(c)
main()

Measured memory_bytes: 49216
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> VU.Vector Int -> Int
solve !n !k !an = VU.last $ V.last dp
 where
  dp :: V.Vector (VU.Vector Int)
  dp = V.postscanl'
    (\(!dpi) (!i) -> VU.scanl'
      (\(!dpij) (!j) ->
        let
          !p =
            if j - an VU.! i - 1 >= 0 then dpi VU.! (j - an VU.! i - 1) else 0
          !q = dpi VU.! j
          !a = dpij + q - p
        in
          a `mod` (10 ^ 9 + 7)
      )
      1
      (VU.fromList [1 .. k])
    )
    (VU.generate (k + 1) (\i -> if i == 0 then 1 else 0))
    (V.convert $ VU.fromList [0 .. n - 1])

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, k) <-
    (\(!vec) -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n k an


Measured memory_bytes: 5756
#include<iostream>
#include<algorithm>
using namespace std;
long X,L[2<<17],R[2<<17],ans;
long Ls[2<<17],Rs[2<<17];
int n;
long Lsum(int id,int c)
{
	return Ls[id+1]-Ls[id+1-c];
}
long Rsum(int id,int c)
{
	return Rs[id+1]-Rs[id+1-c];
}
main()
{
	cin>>X>>n;
	for(int i=0;i<n;i++)
	{
		cin>>L[i];
		R[n-i-1]=X-L[i];
	}
	for(int i=0;i<n;i++)Ls[i+1]=Ls[i]+L[i],Rs[i+1]=Rs[i]+R[i];
	for(int i=0;i<n;i++)
	{
		long now=L[i];
		int cnt=min(i,n-i-1);
		now+=Lsum(i-1,cnt)*2+Rsum(n-i-2,cnt+(i<n-i-1))*2;
		ans=max(ans,now);
		now=X-L[i];
		now+=Lsum(i-1,cnt+(i>n-i-1))*2+Rsum(n-i-2,cnt)*2;
		ans=max(ans,now);
	}
	cout<<ans<<endl;
}


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

int main() {
    int n;cin>>n;
    long ans=0,tmp=0;
    vector<string>a;
    string str;
    
    for(int i=0;i<n;++i){
        cin>>str;
        sort(str.begin(),str.end());
        a.push_back(str);
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;++i){
        if(a[i]==a[i+1]) tmp+=1;
        else {
            ans+= tmp*(tmp+1)/2;
            tmp=0;
        }
    }
        ans+= tmp*(tmp+1)/2;
    cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n;
    cin >> n;
    int b = 0;
    int e = n-1;
    cout << b << endl;
    string s, bs;
    cin >> s;
    bs = s;
    int cnt = 0;
    while (s != "Vacant") {
        int i = (b+e+1) / 2;
        cout << i << endl;
        cin >> s;
        cnt++;
        if (cnt > 20) break;
        if (((i-b) % 2 && bs != s) || ((i-b)%2 == 0 && bs == s)) {
            b = i;
            bs = s;
        }
        else {
            e = i;
        }
    }
}


Measured memory_bytes: 852
#include<cstdio>
#include<cstring>
#define ll long long
const int mo=1e9+7;
char s[100050];
int dp[100050][4];
int pow(int a,int k){
	int ret=1;
	while (k){
		if ((k&1))ret=ret*1ll*a%mo;
		a=a*1ll*a%mo;k>>=1;
	}
	return ret;
}
int main(){
	scanf("%s",s);
	int len=strlen(s),t=0;
	for (int i=0;i<len;i++){
		dp[i+1][0]=dp[i][0];
		dp[i+1][1]=dp[i][1];
		dp[i+1][2]=dp[i][2];
		if (s[i]=='?'){
			dp[i+1][0]=dp[i][0]*3ll%mo;
			dp[i+1][1]=dp[i][1]*3ll%mo;
			dp[i+1][2]=dp[i][2]*3ll%mo;
			dp[i+1][0]+=pow(3,t);
			dp[i+1][1]+=dp[i][0];
			dp[i+1][2]+=dp[i][1];
			t++;
		}
		else if (s[i]=='A')dp[i+1][0]+=pow(3,t);
		else dp[i+1][s[i]-'A']+=dp[i][s[i]-'A'-1];
		dp[i+1][0]%=mo;
		dp[i+1][1]%=mo;
		dp[i+1][2]%=mo;
	}
	printf("%d\n",dp[len][2]);
} 

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
long long m[111], k[111111];
long long dp[111][111111];
int main() {
	int n,w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		cin >> m[i] >> k[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= w; j++) {
			if (j >= m[i]) {
				dp[i][j] = max(dp[i - 1][j], dp[i-1][j - m[i]] + k [i]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	long long m=0;
	for (int i = 1; i <= w; i++) {
		m = max(m, dp[n][i]);
	}
	cout << m;
}

Measured memory_bytes: 81492
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll n;
int main() {
    cin >> n;
    ll a = 0;
    ll b = n;
    for(ll i = 1; i * i <= n; i++){
        if(n%i == 0){
            if(n/i <= b){
                a = i;
                b = n/i;
            }
        }
    }
    cout << a+b-2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,i,ans=0;
  cin>>n>>m;
  vector<int> a(m),b(m);
  vector<vector<int>> g(n);
  for(i=0;i<m;i++){
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
    g.at(a.at(i)).push_back(b.at(i));
    g.at(b.at(i)).push_back(a.at(i));
  }
  for(i=0;i<m;i++){
    queue<int> q;
    vector<int> f(n,-1);
    q.push(a.at(i));
    f.at(a.at(i))=0;
    while(!q.empty()){
      int x=q.front();
      q.pop();
      for(auto z:g.at(x)){
        if(x==a.at(i)&&z==b.at(i)) continue;
        if(f.at(z)>-1) continue;
        f.at(z)=f.at(x)+1;
        q.push(z);
      }
    }
    if(f.at(b.at(i))==-1) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
		int h = sc.nextInt();
		int[][] c = new int[n][2];
		int cnt = 0;

		for (int i = 0; i < n; i++) {
			c[i][0] = sc.nextInt();
			c[i][1] = sc.nextInt();
		}

		// Sort c by b
		Comp comp = new Comp();
		comp.setIndex(1);
		Arrays.sort(c, comp);

		int maxA = 0;
		int maxAindex = 0;
		for (int i = 0; i < n; i++) {
			if (c[i][0] > maxA) {
				maxA = c[i][0];
				maxAindex = i;
			}
		}

		// Throw session
		for (int i = n - 1; i >= 0; i--) {
			if (h <= c[maxAindex][1]) {
				h -= c[maxAindex][1];
				cnt++;
			} else if (c[i][1] > maxA && i != maxAindex) {
				h -= c[i][1];
				cnt++;
			}
			if (h <= 0) {
				System.out.println(cnt);
				return;
			}
		}

		// Wield and throw session
		while (true) {
			if (h <= c[maxAindex][1]) {
				h -= c[maxAindex][1];
			} else {
				h -= c[maxAindex][0];
			}
			cnt++;
			if (h <= 0) {
				System.out.println(cnt);
				return;
			}
		}
  }

	static class Comp implements Comparator {
		int index = 0;

		public void setIndex(int i) {
			index = i;
		}

		public int compare(Object a, Object b) {
			int[] intA = (int[]) a;
			int[] intB = (int[]) b;
			return (intA[index] - intB[index]);
		}
	}
}


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

int main()
{
  int k,a,b,flag = 0;
  cin>>k;
  cin>>a>>b;
  for(int i=a;i<=b;i++)
  {
      if(i%k == 0)
      {
        flag = 1;
        cout<<"OK\n";
        break;
      }
  }
if(!flag)
  cout<<"NG\n";

  return 0;
}


Measured memory_bytes: 3132
n = int(input())
a = [int(input()) for _ in range(n)]
max_a = max(a)
max_idx = a.index(max_a)
for i in range(n):
    if i == max_idx:
        tmp = a
        tmp.sort(reverse=True)
        print(tmp[1])
    else:
        print(max_a)

Measured memory_bytes: 12692
#include<bits/stdc++.h>
using namespace std;
const long long mod = 998244353LL;
const int maxn = 1e5 + 5;
int n;
int cnt[maxn];
int main() {
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    int x; scanf("%d",&x);
    cnt[x]++;
    if(i == 1 && x!=0) return !printf("0");
  }
  if(cnt[0] > 1) return !printf("0");
  long long ans = 1;
  for(int i=1;i<=n;i++) for(int j=0;j<cnt[i];j++) ans = (ans * cnt[i-1])%mod;
  printf("%lld",ans);
}


Measured memory_bytes: 640
N,Y = map(int,input().split())

def otosidama(N,Y):
    for y in range(N+1,-1,-1):
        if y*10000 > Y:
            continue
        for i in range(N+1-y):
            if (N-y-i)*1000 > Y-y*10000:
                break
            else:
                if y*10000 + i*5000 + (N-y-i)*1000 == Y:
                    return y,i,N-y-i
    
    return -1,-1,-1

if Y > N*10000:
    print(-1,-1,-1)
else:
    y,i,h = otosidama(N,Y)
    print(y,i,h)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    static final int NUMBER = 1000000007;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long sum = 0;
        long[] ai = new long[n];
        for(int i=0; i<n; i++) {
            ai[i] = in.nextLong();
            sum += ai[i];
        }
        long ans = 0;
        for(int i=0; i<n-1; i++) {
            sum -= ai[i];
            long tempSum = sum % NUMBER;
            long toBeAdded = ai[i] * tempSum;
            ans += toBeAdded % NUMBER;
            ans = ans % NUMBER;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 63400