akhauriyash/Code-Regression huggingface dataset:
extern crate core;

use std::io::{self, Read};
use std::cmp;

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input);
    println!("{}", output);
}

fn run(input: String) -> String {
    let list: Vec<i32> = input
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect();
    let n = list[0];
    let a = list[1];
    let b = list[2];

    cmp::min(n * a, b).to_string()
}

#[test]
fn test() {
    let tests = vec![
        ("7 17 120", "119"),
        ("5 20 100", "100"),
        ("6 18 100", "100"),
    ];
    for (i, &(input, output)) in tests.iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
const ll mod=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K,A,B; cin >> K >> A >> B;
    if (B<=A+2){
        cout << K+1 << endl;
        return 0;
    }
    if (K<=A-1){
        cout << K+1 << endl;
        return 0;
    }
    K-=A-1;
    ll ans=A+(K/2)*(B-A)+(K-K/2*2);
    cout << ans << endl;
}

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

#define int long long

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

int N;
int a[101];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        a[d]++;
    }
    int ans = 0;
    for (int i = 1; i <= 100; i++) {
        if (a[i] > 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/

int main(){
    ll N,M;
    cin >> N;
    map<ll,ll> n;
    map<ll,ll> m;
    ll a;
    rep(i,N){
        cin >> a;
        n[a]++;
    }
    cin >> M;
    rep(i,M){
        cin >> a;
        m[a]++;
    }
    bool ans = true;
    for(auto x : m){
        if(x.second > n[x.first])ans = false;
    }
    if(ans)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 25216
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, a, b;
int main() {
	scanf("%d %d %d", &n, &a, &b);
	int c0 = 0, c1 = 0, c2 = 0;
	for (int i = 0; i < n; i++) {
		int p;
		scanf("%d", &p);
		if (p <= a)
			c0++;
		else if (p <= b)
			c1++;
		else
			c2++;
	}
	printf("%d\n", min(c0, min(c1, c2)));
}

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


int main() {
    int x,y;
    cin>>x>>y;
    int b;
    bool test=false;
    rep(a,x+1){
        b=x-a;
      
        if((2*a+4*b)==y){
            test=true;
          
        }
    }
    if(test){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    
}


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

int main() {
  
  int N;
  int A;
  int B;
  
  cin >> N >> A >> B;
  
  if ( N * A > B ) {
    
    cout << B << endl;
  }
  
  else {
    
    cout << N * A << endl;
  }
  
}

Measured memory_bytes: 3652
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,m;
    cin>>n>>m;

    vi v(m);
    int sum=0;
    for(int i=0;i<m;++i)
    {
        cin>>v[i];
        sum+=v[i];
    }

    int ans=n-sum;

    if(ans<0)
        cout<<-1;
    else
        cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        //cout<<"Case #"<<z<<": ";
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3668
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define ld long double
#define F first
#define S second
#define mem(v) memset(v,0,sizeof(v))
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define vll vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define hell 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; 
if (m == 1) {return 0;} 
while (a > 1) { ll q = a / m; ll t = m;  m = a % m, a = t; t = y; y = x - q * y; x = t; } 
if (x < 0) {x += m0;} return x; } 
inline ll add(ll a, ll b) { return (((a >= hell) ? a % hell : a) + ((b >= hell) ? b % hell : b) + hell) % hell; }
inline ll subt(ll a, ll b) { return (a - b + hell) % hell; }
inline ll mult(ll a, ll b) { return (1ll * ((a >= hell) ? a % hell : a) * ((b >= hell) ? b % hell : b)) % hell; }
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll mylog(ll n,ll b)
{ll i = 1;ll ans = 0;
while(1)
{if(i>n/b){break;} i = i*b;ans++;}return ans;
}
bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
if (a.first == b.first)
{return a.second<b.second;} 
return a.first<b.first;
}
bool comparerev(const pair<ll,ll> &a,const pair<ll,ll> &b){
if(a.first == b.first)
{return a.second>b.second;}
return a.first>b.first;
}
int main()
{
    fast
    ll t = 1;
   // cin>>t;
    while(t--){
    string s;
    cin>>s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7')
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
    }
    return 0;
}

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

struct UnionFind{
    vector<int> par,rank;

    UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        for(int i=0; i<n; i++){
            par[i]=i;
            rank[i]=0;
        }
    }

    void unite(int x,int y)
    {
        x = root(x);y = root(y);
        if(x == y) return;

        if( rank[x] < rank[y] )
        {
            par[x] = y;
        }
        else
        {
            par[y] = x;
            if(rank[x] == rank[y])
            {
                rank[x]++;
            }
        }
    }

    bool same(int x,int y)
    {
        return root(x) == root(y);
    }

    int root(int x)
    {
        if (x == par[x]) return x;

        return par[x] = root(par[x]);
    }
};


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

    UnionFind u(N);

    for(int i=0; i<Q; i++) {
        int p,a,b;
        cin >> p >> a >> b;

        if(p) {
            cout << (u.same(a,b) ? 1 : 0) << endl;
        }else{
            u.unite(a,b);
        }
    }
}

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

int main(){
	int m,d;
	cin >> m >> d;
	int cnt = 0;
	for(int i = 22;i <= d;i++){
		int a = i/10,b = i % 10;
		if(a >=2 && b >= 2){
			if(a * b <= m){
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll cnt[110];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		ll A;
		cin >> A;
		for (int i = 0; i < 60; i++) {
			cnt[i] += A % 2;
			A /= 2;
		}
	}
	ll ans = 0;
	ll power = 1;
	for (int i = 0; i < 60; i++) {
		ll r = N - cnt[i];
		ans += (((r * cnt[i]) % mod) * power) % mod;
		ans %= mod;
		power = power * 2 % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	string S,T;
	cin>>S>>T;
	bool ok=false;
	For(i,0,S.size())
	{
		if(S==T)ok=true;
		S.push_back(S[0]);
		S.erase(S.begin());
	}
	puts(ok?"Yes":"No");
	return 0;
}



Measured memory_bytes: 256
//============================================================================
// Name        : D.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

using ld = long double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b){
	return a.real() * b.imag() - a.imag()*b.real();
}

ld dot(const P& a, const P& b){
	return a.real()*b.real() + a.imag()*b.imag();
}


enum {
	CCW = +1,
	CW=-1,
	BEHIND = +2,
	FRONT = -2,
	ON = 0
};

int ccw(P a, P b, P c){
	b -= a;
	c -= a;
	if(cross(b,c) > eps) return CCW;
	if(cross(b,c) < -eps) return CW;
	if(dot(b,c) < 0) return BEHIND;
	if(norm(b) < norm(c)) return FRONT;
	return ON;
}

struct L : public vector<P> {
	L(const P &a, const P& b){
		push_back(a);
		push_back(b);
	}
};

P crosspointLL(const L &l, const L &m){
	ld A = cross(l[1]-l[0], m[1]-m[0]);
	ld B = cross(l[1]-l[0], l[1]-m[0]);
	if(abs(A) < eps && abs(B) < eps) return m[0];
	if(abs(A) < eps) assert(false);
	return m[0] + B/A*(m[1]-m[0]);
}

#define curr(pol, i) pol[i]
#define next(pol, i) pol[(i+1)%pol.size()]
G convex_cut(const G &pol, const L &l){
	G res;
	for(int i = 0; i < (int)pol.size(); ++i){
		P A = curr(pol, i), B = next(pol, i);
		if(ccw(l[0],l[1],A) != -1) res.push_back(A);
		if(ccw(l[0],l[1],A)*ccw(l[0],l[1],B)<0){
			res.push_back(crosspointLL(L(A,B),l));
		}
	}
	return res;
}

int n;
G g;

int main() {
	while(cin >> n && n){
		g.resize(n);
		for(int i = 0; i < n; ++i){
			ld x,y;
			cin >> x >> y;
			g[i] = P(x,y);
		}
		G S;
		S.push_back(P(-20000,-20000));
		S.push_back(P(-20000,20000));
		S.push_back(P(20000,20000));
		S.push_back(P(20000,-20000));

		for(int i = 0; i < n; ++i){
			L l(curr(g,i), next(g,i));
			S = convex_cut(S, l);
		}
		cout << min<int>(1,S.size()) << endl;
	}
}

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

#define LL long long int
#define L long int
#define IM INT_MAX
#define Im INT_MIN
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define read  freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define pb(x) push_back(x)
#define all(v) sort(v.begin(),v.end())

int main(){

fast;

string s;

cin>>s;

LL ans=0;

int n=s.size();

for(int i=0;i<n;i++)ans+=(s[i]-'0');

if(ans%9==0)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

ll mod=1000000007, a[100010];
const int SIZE=110000;
ll fac[SIZE], finv[SIZE], inv[SIZE];
void COMinit(ll m){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<SIZE; ++i){
        fac[i]=(fac[i-1]*i)%m;
        inv[i]=m-(inv[m%i]*(m/i))%m;
        finv[i]=(finv[i-1]*inv[i])%m;
    }
}
ll COM(int n, int k, ll m){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return (fac[n]*((finv[k]*finv[n-k])%m))%m;
}

int main() {
	int N, K;
	cin >> N >> K;
	for(int i=0; i<N; ++i) cin >> a[i];
	sort(a, a+N);
	COMinit(mod);
	ll ans=0;
	for(int i=0; i<N; ++i){
		if(a[i]<0) a[i] += mod;
		ans=(ans+(a[i]*COM(i, K-1, mod))%mod)%mod;
		ans=(ans+mod-(a[i]*COM(N-i-1, K-1, mod))%mod)%mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll a, b, n;
    cin >> a >> b >> n;

    if (a > n)
        cout << a - n << " " << b << endl;
    else
    {
        ll taka = 0, auki = 0;
        if (b > 0)
        {
            ll rem = n - a;
            if (b >= rem) auki = b - rem;
        }

        cout << taka << " " << auki << endl;
    }

    return 0;
}

Measured memory_bytes: 3160
#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++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

int main() {
	int INF = pow(10, 8); // cout << INF;
  int H, N;
	cin >> H >> N;
	vi A(N), B(N); int A_max = 0;
	rep(i, N) {
		cin >> A.at(i) >> B.at(i); // 魔法の番号iは0-ind
		A_max = max(A_max, A.at(i));
	}	
	vi dp(H + A_max, INF); dp.at(0) = 0; // ダメージjを与えるのに必要な魔力の最小値
	// for (int dpi : dp) cout << dpi << " "; cout << endl; //DB
	rep(i, N) {
		rep(j, H + A_max) {
			dp.at(j) = min(dp.at(j), dp.at(max(j - A.at(i), 0)) + B.at(i));
		}
	}	
	int ans = INF;
	rep2(j, H, H + A_max) {
		ans = min(ans, dp[j]);
	}	
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
double a,b,c,d,e,f;
double x,y;
while(cin >> a >> b >> c >> d >> e >> f){
  x = (double)((e*c-b*f) / (a*e-b*d));
  y = (double)((-(d*c)+a*f) / (a*e-b*d));
  if(x == 0){x = 0;}
  if(y == 0){y = 0;}
  printf("%.3f %.3f\n",x,y);
 }
}

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

int main(){
  int num, n;
  string s1;
  while(cin >> num >> n, num | n){
    map<int, int> mp;
    int idx = 0;
    while(mp.find(num) == mp.end()){
      mp[num] = idx;
      stringstream s;
      s << num;
      s >> s1;
      string tmp;
      for(int i = 0; i < n - s1.size(); i++) tmp += "0";
      s1 = tmp + s1;
      sort(s1.begin(), s1.end());
      int mmin = atoi(s1.c_str());
      reverse(s1.begin(), s1.end());
      int mmax = atoi(s1.c_str());
      num = mmax - mmin;
      idx++;
    }
    cout << mp[num] << " " << num << " " << idx - mp[num] << endl;
  }
  return 0;
}



Measured memory_bytes: 3140
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

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

        char[][] c = new char[h][w];
        int numCandidateSite = 0;
        for(int y = 0;y < h;y++) {
            char[] line = sc.next().toCharArray();
            for(int x = 0;x < w;x++) {
                c[y][x] = line[x];
                if(line[x] == '.') numCandidateSite++;
            }
        }

        int result = bfs(0, 0, h, w, c);
        int answer = result == -1 ? result : numCandidateSite - result;
        System.out.println(answer);
    }

    private static int bfs(int startX, int startY, int h, int w, char[][] c) {
        Deque<Point> q = new ArrayDeque<>();
        q.offer(new Point(startX, startY));
        boolean[][] footprints = new boolean[h][w];
        footprints[startY][startX] = true;

        int[] dx = {0, 0, 1, -1};
        int[] dy = {1, -1, 0, 0};
        int[][] costMap = new int[h][w];
        for(int y = 0;y < h;y++) {
            for(int x = 0;x < w;x++) costMap[y][x] = Integer.MAX_VALUE;
        }
        costMap[0][0] = 0;

        while(!q.isEmpty()) {
            Point p = q.poll();

            for(int i = 0;i < 4;i++) {
                int nextX = p.x + dx[i];
                int nextY = p.y + dy[i];
                if(canGo(nextX, nextY, h, w, c, footprints)) {
                    q.offer(new Point(nextX, nextY));
                    footprints[nextY][nextX] = true;
                    int pScore = costMap[p.y][p.x];
                    if(pScore + 1 < costMap[nextY][nextX]) costMap[nextY][nextX] = pScore + 1;
                }
            }
        }

        int shortestTime = costMap[h - 1][w - 1];
        if(shortestTime == Integer.MAX_VALUE) return -1;
        else return shortestTime + 1;
    }

    private static boolean canGo(int x, int y, int h, int w, char[][] c, boolean[][] footprints) {
        if(x < 0 || x >= w || y < 0 || y >= h) return false;
        if(footprints[y][x]) return false;
        if(c[y][x] == '#') return false;

        return true;
    }

}

Measured memory_bytes: 23764
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])
t = 0
for i in range(n):
    t += ab[i][0]
    if t > ab[i][1]:
        print('No')
        exit()
print('Yes')


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

int main() {
  int n, x, ans = 1, sum = 0;
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; i++) {
    int z;
    scanf("%d", &z);
    sum += z;
    ans += sum <= x;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, i;
    map<map<char,long int>, long int> index;
    cin >> n;
    for(i=0; i<n; i++){
        string input;
        map<char,long int> cnt;
        cin >> input;
        for(int j=0; input[j]; j++){
            cnt[input[j]]++;
        }
        index[cnt]++;
    }
    long int res = 0;
    for(auto it=index.begin(); it!=index.end(); it++){
        if(it->second > 1){
            res += ((it->second)*(it->second - 1))/2;
        }
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 62336
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
func main() {
	s := ScanWord()
//P(s)
	aCount := 0
	bCount := 0
	if s[0] == 'A' {
		aCount++
	} else {
		bCount++
	}
 
	if s[1] == 'A' {
		aCount++
	} else {
		bCount++
	}
	if s[2] == 'A' {
		aCount++
	} else {
		bCount++
	}
 
	if aCount > 0 && bCount > 0 {
		P("Yes")
	} else {
		P("No")
	}
}
 
/*********************** I/O ***********************/
 
var in *bufio.Scanner
var P func(a ...interface{}) (n int, err error)
 
func init() {
	P = fmt.Println
 
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
 
}
 
func ScanWord() string {in.Scan(); return in.Text() }
func ScanInt() int {i, _ := strconv.Atoi(ScanWord()); return i}
func ScanInt64() int64 {i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i}
func ScanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = ScanWord()}; return s}
func ScanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = ScanInt()}; return arr}
func ScanInt64Slice(n int) []int64 {arr := make([]int64, n); for i := 0; i < n; i++ {arr[i] = ScanInt64()}; return arr}

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

using namespace std;

uint64_t factorial(int n) {
  uint64_t ans = 1;
  for (int i = 2; i < n; ++i) {
    ans *= i;
  }
  return ans;
}

uint64_t combination(int n, int r) {
  if (r * 2 > n) r = n - r;
  uint64_t dividend = 1;
  uint64_t divisor = 1;
  for (unsigned int i = 1; i <= r; ++i) {
    dividend *= (n-i+1);
    divisor *= i;
    if (dividend % divisor == 0) {
      dividend = dividend / divisor;
      divisor = 1;
    }
  }
  return dividend / divisor;
}

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

  int n, a, b;
  cin >> n >> a >> b;
  vector<uint64_t> v(n);
  unordered_map<uint64_t, int> counter;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    counter[v[i]] += 1;
  }
  sort(v.rbegin(), v.rend());

  uint64_t patterns = 0;
  uint64_t sum = 0;
  double avg = 0;

  if (v[0] != v[a]) {
    unordered_map<uint64_t, int> used;
    for (int i = 0; i < a; ++i) {
      sum += v[i];
      used[v[i]] += 1;
    }
    avg = (double)sum / a;

    uint64_t pat = 1;
    for (auto& u : used) {
      auto count = counter[u.first];
      auto used_cnt = u.second;
      pat *= combination(count, used_cnt);
    }
    patterns += pat;
  } else {
    avg = v[0];
    for (int i = a; i <= b; ++i) {
      uint64_t c = combination(counter[v[0]], i);
      patterns += combination(counter[v[0]], i);
      if (i == b || v[0] != v[i]) break;
    }
  }
  printf("%.7f\n%lu\n", avg, patterns);
}

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

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    ll idx = lower_bound(A.begin(), A.end(), 0) - A.begin();
    vector<ll> x(N-1), y(N-1);
    ll tmp = 0;
    auto disp = [](vector<ll> a) {
        for (ll e : a) {
            cout << e << " ";
        }
        cout << "\n";
    };
    // disp(A);
    if (idx == 0) {
        idx = 1;
    } else if (idx == N) {
        idx = N-1;
    }
    Rep (i, N-idx-1) {
        x[tmp] = A[0];
        y[tmp] = A[idx+i];
        A[0] -= A[idx+i];
        A[idx+i] = 0;
        tmp++;
        // disp(A);
    }



    Rep (i, idx) {
        x[tmp] = A[N-1];
        y[tmp] = A[i];
        A[N-1] -= A[i];
        A[i] = 0;
        tmp++;
        // disp(A);
    }

    cout << A[N-1] << "\n";
    Rep (i, N-1) {
        cout << x[i] << " " << y[i] << "\n";
    }
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	if(c=='-')f=-1,c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n,ans,k;
char c[1000010];
int main(){
	n=d;
	f(i,1,n){cin>>c[i];if(c[i]=='R')ans++,k++;}
	f(i,1,k)if(c[i]=='R')ans--;
	cout<<ans; 
	return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>
int main(void){

int a=0,b=0,c=0,d=0,n=0,x=0;

while(1){
scanf("%d %d",&n,&x);

if(n==0&&x==0){
break;
}

for(a=1;a<=n-2;a++){
	for(b=a+1;b<=n-1;b++){
		for(c=b+1;c<=n;c++){
			//printf("a %d\n",a);
			//printf("b %d\n",b);
			//printf("c %d\na+b+c=%d\n",c,a+b+c);
			if(a+b+c==x){
			d++;
			}
		}
	}
}

printf("%d\n",d);
d=0;
}

return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long ll;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    int c[40];
    memset(c, 0, sizeof(c));
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        for (int j = 0; j < 40; j++) {
            c[j] += a % 2;
            a /= 2;
        }
    }

    ll sum[40];
    sum[0] = max(c[0], n - c[0]);
    for (int i = 1; i < 40; i++) {
        sum[i] = sum[i-1] + (1ll << i) * max(c[i], n - c[i]);
    }

    int kb[40];
    for (int i = 0; i < 40; i++) {
        kb[i] = (k >> i) & 1;
    }

    ll ans = 0, cur = 0;
    for (int i = 39; i >= 0; i--) {
        if (i == 0) {
            ans = max(ans, cur + (kb[i] ? max(c[i], n - c[i]) : c[i]));
        }
        else if (kb[i]) {
            ans = max(ans, cur + (1ll << i) * c[i] + sum[i-1]);
        }
        cur += (1ll << i) * (kb[i] ? n - c[i] : c[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// Walk and Teleport
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
    long long N, A, B; cin >> N >> A >> B;
    vector<long long> X(N); for (int i = 0; i < N; i++) cin >> X[i];
    long long hirou = 0;
    for (int n = 0; n < N - 1; n++) {
        long long dist = X[n+1] - X[n];
        // if (A * dist >= B) hirou += B;
        // else hirou += A * dist;
        hirou += min(A*dist, B);
    }
    cout << hirou << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <random>

int main() {
	int n; std::cin >> n;
	std::vector<std::vector<int>> competitor(n, std::vector<int>(n - 1));
	for (auto& line : competitor) for (auto& c : line) { std::cin >> c; --c; };
	std::vector<int> current_schedule(n, 0);
	int count = 0;
	std::queue<std::pair<int, int>> queue;
	for (auto i = 0; i < n; ++i) {
		auto c = competitor[i][current_schedule[i]];
		if (i < c && competitor[c][current_schedule[c]] == i) {
			queue.emplace(i, c);
		}
	}
	while (!queue.empty()) {
		++count;
		for (int match = queue.size(); match > 0; --match) {
			auto top = queue.front(); queue.pop();
			current_schedule[top.first]++;
			current_schedule[top.second]++;
			if (current_schedule[top.first] != n - 1) {
				auto c = competitor[top.first][current_schedule[top.first]];
				if (competitor[c][current_schedule[c]] == top.first) {
					queue.emplace(top.first, c);
				}
			}
			if (current_schedule[top.second] != n - 1) {
				auto c = competitor[top.second][current_schedule[top.second]];
				if (competitor[c][current_schedule[c]] == top.second) {
					queue.emplace(top.second, c);
				}
			}
		}
	}
	if (std::all_of(current_schedule.begin(), current_schedule.end(), [n](const int a) {return a == n - 1; })) {
		std::cout << count << std::endl;
	}
	else {
		std::cout << -1 << std::endl;
	}
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int h, w, k, ans = 0;
	cin >> h >> w >> k;
	vector<string> a(h);
	rep(i,h){
		cin >> a[i];
	}
	
	for(int bitw=0; bitw<(1<<w); bitw++){
		for(int bith=0; bith<(1<<h); bith++){
			int sum = 0;
			map<int, int> mh;
			map<int, int> mw;
			for(int i=0; i<h; i++){
				if(bith&(1<<i)){
					mh[i]++;
				}
			}
			for(int j=0; j<w; j++){
				if(bitw&(1<<j)){
					mw[j]++;
				}
			}
			rep(i,h){
				if(mh[i]>0) continue;
				rep(j,w){
					if(mw[j]>0) continue;
					if(a[i][j] == '#'){
						sum++;
					}
				}
			}
			if(sum == k) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  map<int, int> A;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    A[a] += 1;
  }
  
  for(auto a : A){
    if(a.second != 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;
  
}

// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));

  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
    //}
  //}

Measured memory_bytes: 9600
use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input! {
        n: Chars,
    }

    let mut sum = 0;
    for c in n {
        let num: usize = c as usize - '0' as usize;
        sum += num;
    }

    println!("{}", if sum % 9 == 0 { "Yes" } else { "No" })
}


Measured memory_bytes: 3056
function Main(input) {
    var A = parseInt(input[0], 10);
    
    for (var i = 1; i <= 9; i++) {
        if (A % i === 0) {
            if (A / i <= 9) {
                return console.log('Yes');
            }
        }
    }
    return console.log('No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
import sys
readline = sys.stdin.buffer.readline

n,m,k = map(int,readline().split())

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#xが属するグループの要素全てを返す
def members(x):
    root = find(x)
    return [i for i in range(n) if find(i) == root]

#全ての根の要素をlistで返す(一個下の関数で使う)
def roots():
    return [i for i,x in enumerate(par) if x < 0]

#グループ数を返す
def group_count():
    return len(roots())

#根をkey,そのグループに含まれる要素をvalueとして全てを辞書型で返す
def all_group_members():
    return {r: members(r) for r in roots()}

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n
lst2 = [0]*n
lst3 = [0]*n
for i in range(m):
    a,b = map(int,readline().split())
    a,b = a-1,b-1
    lst2[a] += 1
    lst2[b] += 1
    unite(a,b)

block = 0

for i in range(k):
    a,b = map(int,readline().split())
    a,b = a-1,b-1
    if same(a,b):
        lst3[a] += 1
        lst3[b] += 1

ans = [0]*n

for i in range(n):
    res = size(i) -1
    res -= lst2[i]+lst3[i]
    ans[i] = res


print(*ans)


Measured memory_bytes: 81884
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPE(i,a,n) for(int i=a;i<=n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}

int atcoder(){
    //入力
    int n,l;
    cin >> n >> l;
    string s[110];
    REP(i,0,n) cin >> s[i];
    string ans = "";
    
    sort(s,s+n);
    REP(i,0,n) ans += s[i];
    
    cout << ans;
    
    return 0;
}

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


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

#define ll unsigned long long int
#define ld long double
#define mod 1000000007LL
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define pb(x) push_back(x)
#define fo(i, a, n) for (i = (a); i < (n); i++)
#define foe(i, a, n) for (i = (a); i <= (n); i++)
// clang-format off
#define vin(a) for (ll i = 0; i < sz(a); i++) { cin >> a[i]; } 
#define vout(a) for (auto x : a) { cout << x << " "; }
#define sws                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
// clang-format on
#define pd(x) cout << x
#define sd(x) cin >> x
#define nl cout << endl
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define foreach(i, a)                                                          \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
// int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve() {
  ll n;
  string x;
  cin >> n >> x;

  ll m = 0;
  m += x[0] - '0';
  m *= 10;
  m += x[2] - '0';
  m *= 10;
  m += x[3] - '0';

  n *= m;

  cout << n / 100LL << endl;
}

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define INF 100000000;
bool comp[10];
int d, g, p[10], c[10], ans=INF;

void dfs(int i, bool s){
  comp[i]=s;
  if(i<d-1){dfs(i+1,1); dfs(i+1,0); return;}
  int sc=0, num=0;
  REP(j,d){sc+=comp[j]*c[j]; num+=comp[j]*p[j];}
  if(sc<g) for(int ii=d-1;ii>=0;ii--){
    if(comp[ii]) continue;
    else{
      if((g-sc)/((ii+1)*100)<p[ii]) num+=max(1,(g-sc)/((ii+1)*100));
      else num=INF;
      break;
    } 
  }    
  ans=min(ans,num);
}

int main(){
  REP(i,10) {comp[i]=0; p[i]=0; c[i]=0;}
  cin >> d >> g;
  REP(i,d) cin >> p[i] >> c[i];
  REP(i,d) c[i]=(i+1)*100*p[i]+c[i];
  dfs(0,1); dfs(0,0);
  cout << ans << endl;
}

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




int main() 
{ 
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	
	int n; cin >> n; long long int arr[n];

	for (int i = 0; i < n; i++) cin >> arr[i];

	long long int maxx = 0, steps = 0;

	for (int i = 1; i < n; i++)
	{
		if (arr[i - 1] > maxx) maxx = arr[i - 1];
		if (arr[i] < maxx)
		{
			steps += (maxx - arr[i]);
		}
	}
	
	cout << steps;
} 


Measured memory_bytes: 5192
/**
 * 0022 Maximum Sum Sequence
 */

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line;
        while (!(line = br.readLine()).equals("0")) {
            int n = Integer.parseInt(line);

            // 累積和配列を用いたアルゴリズムO(n^2)
            int[] s = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                s[i] = Integer.parseInt(br.readLine()) + s[i - 1];
            }

            int sum = Integer.MIN_VALUE;

            for (int l = 0; l <= n-1; l++) {
                for (int r = l+1; r <= n; r++) {
                    sum = Math.max(sum, s[r] - s[l]);
                }
            }

            System.out.println(sum);
        }

    }
}


Measured memory_bytes: 26532
#include<iostream>
#include<stdlib.h>
using namespace std;
int main() {
	int x1, y1, x2, y2;
	cin >> x1;
	cin >> y1;
	cin >> x2;
	cin >> y2;
	int x3, y3, x4, y4;
	if (abs(x1 - x2) >= abs(y1 - y2)) {
		x3 = x2 + (y1 - y2);
		y3 = y2 - (x1 - x2);
		x4 = x3 + x1 - x2;
		y4 = y3 + y1 - y2;
	}
	else {
		x3 = x2 + (y1 - y2);
		y3 = y2 - (x1 - x2);
		x4 = x3 + x1 - x2;
		y4 = y3 + y1 - y2;
	}
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}

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

int     main() {
        int N, M, X;
        cin >>N >>M >>X;
        int i=0;
        int A=0;
        while (A<X) {
                cin >>A;
                i++;
        }
        i--;
        i=min(i, M-i);
        cout <<i <<endl;
        return 0;
};

Measured memory_bytes: 256
<?php
/*
    http://cf16-final-open.contest.atcoder.jp/tasks/cf16-final-open_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d", $H, $W);
for ($i = 0; $i < $H; $i++) {
	$S = explode(" ", trim(fgets(STDIN)));
	// var_dump($S);
	$loc = array_search("snuke", $S);
	// var_dump($loc);
	if ($loc !== false) {
		echo chr(ord('A') + $loc);
		echo $i + 1;
		echo PHP_EOL;
		exit;
	}
}


Measured memory_bytes: 3064
#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> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    string S;
    cin >> S;
    int count = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == 'x'){
            count++;
        }
    }
    if (count > 7){
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;
    }
}



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

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std ;
int a[10100] ;

int main()
{
  int n , m ;
  string s ;
  cin >> n >> m >> s ;
  long long ans = 0 ;
  if(m == 2 || m == 5)
   {
     for(int i = 0 ;i < n ;i ++)
      if((s[i] - '0') % m == 0)
       ans += i + 1 ;
   }
  else
   {
     a[0] = 1 ;
     int v = 0 , t = 1 ;
     for(int i = n - 1; i >= 0 ;i --)
      {
        v += t * (s[i] - '0') ;
        v %= m ;
        ans += a[v] ;
        a[v] ++ ;
        t *= 10 ;
        t %= m ;
      }

   }
   cout << ans << endl ;
   return 0 ;
}


Measured memory_bytes: 644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a+b+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int k = scan.nextInt();

		unionFind uf = new unionFind(n);

		int i,x,y;

		int[] f = new int[n + 1];
		int[] rc = new int[n + 1];
		for(i = 0; i < m; i++) {
			x = scan.nextInt();
			y = scan.nextInt();

			f[x]++;
			f[y]++;

			uf.union(x, y);
		}

		for(i = 1; i <= n; i++) {
			rc[i] = uf.size(i) - f[i] - 1;
		}

		for(i = 0; i < k; i++) {
			x = scan.nextInt();
			y = scan.nextInt();

			if(uf.same(x, y)) {
				rc[x]--;
				rc[y]--;
			}
		}

		for(i = 1; i <= n; i++) {
			System.out.print(rc[i] + " ");
		}
	}

}
class unionFind{
	int[] par;
	int[] size;

	unionFind(int x){
		this.par = new int[x + 1];
		this.size = new int[x + 1];

		int i;
		for(i = 0; i <= x; i++)
			this.par[i] = i;
		Arrays.fill(this.size, 1);
	}

	int root(int x) {
		int r = x;
		while (r != this.par[r]) {
	        r = this.par[r];
	      }

		return r;
	}

	void union(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if(rx == ry)
			return;

		if(this.size[rx] < this.size[ry]) {
			this.size[ry] += this.size[rx];
			this.par[rx] = ry;
		}else {
			this.size[rx] += this.size[ry];
			this.par[ry] = rx;
		}
	}

	int size(int x) {
		return this.size[root(x)];
	}

	boolean same(int x, int y) {
		int rx = root(x);
		int ry = root(y);

		return rx == ry;
	}
}

Measured memory_bytes: 96260
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",max(a*10+b+c,max(b*10+a+c,c*10+a+b)));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    
    string a;
    cin >> a;
    
    if(a[0] == 'S' ) cout << "Cloudy" << endl;
    if(a[0] == 'C' ) cout << "Rainy" << endl;
    if(a[0] == 'R' ) cout << "Sunny" << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 3592
fun main(args: Array<String>) {
    var (D,N) = readLine()!!.split(" ").map { it.toInt() }
    var i: Int = Math.pow(100.0, D.toDouble()).toInt()
  	when(N) {
      100 -> {
        println(i * (N+1))
      }
      else -> {
        println(i * N)
      }   
    }	
}

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

int main() {
	int n; cin >> n;
	multiset<int> s;
	int m = 0;
	for (int i = 0; i < 1<<n; ++i)
	{
		int x; cin >> x;
		s.insert(x);
		m = max(m, x);
	}
	vector<int> exist;
	exist.push_back(m);
	s.erase(s.lower_bound(m));

	for (int i = 0; i < n; ++i)
	{
		for (int k = 0; k < 1<<i; ++k)
		{
			int j = exist[k];
			auto it = s.lower_bound(j);
			if (it == s.begin()) {
				cout << "No" << endl;
				return 0;
			}
			else {
				it--;
				int v = *it;
				exist.push_back(v);
				s.erase(it);
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 13820
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

int XX[8] = { +1, +1, +1, 0, 0, -1, -1, -1};
int YY[8] = { +1, 0, -1, +1, -1, +1, 0, -1};
int dx[4] = { -1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

vector<int> adj[100005];
int dp[100005][2];
int n;

int dfs(int node, int col, int par) {
	if (dp[node][col] != -1) return dp[node][col];
	int ans = 0, w1 = 1;
	for (auto it : adj[node]) {
		if (it != par) {
			w1 = (w1 * dfs(it, 0, node)) % mod;
		}
	}

	ans += w1;
	if (ans >= mod) ans -= mod;
	if (!col) {
		int w2 = 1;
		for (auto it : adj[node]) {
			if (it != par) {
				w2 = (w2 * dfs(it, 1, node)) % mod;
			}
		}
		ans += w2;
		if (ans >= mod)ans -= mod;
	}

	return dp[node][col] = ans;
}

signed main() {

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

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n;

	for (int i = 1; i <= n - 1; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	memset(dp, -1, sizeof(dp));

	cout << dfs(1, 0, -1) << endl;

	return 0;
}

Measured memory_bytes: 17488
#include<stdio.h>
#define M 1001000
int main(){
  int i,j,a,b,c;
  char p[M]={1,1};
  for(i=2;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d %d %d",&a,&b,&c),a||b||c){
    for(;c--;a+=b)c+=p[a];
    printf("%d\n",a-b);
  }
  return 0;
}

Measured memory_bytes: 1584
N,A,B=map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    tmp=A-1+(B-A+1)//2
    a=A+(N-B);b=N
    tmpp=N-B+(b-a+1)//2
    print(min(tmp,tmpp))

Measured memory_bytes: 38256
// AtCoder Grand Contest 005
// A - STring

#include <cstdio>
#include <cstring>
#define MAX_X 200000
using namespace std;

typedef long long int ll;


char x[MAX_X + 2];
int ans;

int main() {

  int len, h;

  scanf("%s", x);
  len = strlen(x);

  ans = 0;
  h = 0;
  for (int i = 0; i < len; i++) {
    if (h <= 0 && x[i] == 'T') {
      ans++;
    } else {
      h += (x[i] == 'T') ? -1 : 1;
    }
  }

  ans *= 2;
  printf("%d\n", ans);

  return 0;

}




Measured memory_bytes: 384
from collections import Counter

s = input()
K = int(input())
c = Counter(s)

key = sorted(c.keys())
ans = []
queue = []

while (len(ans) < K):
    if queue:
        #print("q", queue)
        queue = sorted(list(set(queue)))
        res = queue.pop(0)
        ans.append(res)
        ans = list(set(ans))
    else:
        c = key.pop(0)
        #print("pop", c)
        queue.append(c)
        ind = [i for i in range(len(s)) if s[i] == c]
        for i in ind:
            for j in range(min(5, len(s) - i)):
                queue.append(s[i:i+j+1])

print(sorted(ans)[K-1])


Measured memory_bytes: 4844