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

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

struct Sieve{
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1){
        f[0] = f[1] = -1;
        for(ll i = 2; i <= n; i++){
            if(f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for(ll j = i*i; j <= n; j += i){
                if(!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) {return f[x] == x;}
    vector<int> factorList(int x){
        vector<int> res;
        while(x != 1){
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x){
        vector<int> fl = factorList(x);
        if(fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for(int p : fl){
            if(res.back().first == p){
                res.back().second++;
            }
            else{
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main(){
    Sieve sieve(1e6);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> mp;
    
    rep(i,n){
        auto f = sieve.factor(a[i]);
        for(auto p : f){
            mp[p.first] = max(mp[p.first], p.second);
        }
    }

    mint lcm = 1;
    for(auto p : mp){
        rep(i, p.second){
            lcm *= p.first;
        }
    }

    mint ans = 0;
    rep(i,n){
        mint b = lcm/a[i];
        ans += b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7708
#define _USE_MATH_DEFINES

#pragma GCC optimize("Ofast,no-stack-protector") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") 
#pragma GCC optimize("unroll-loops") 
#pragma GCC optimize("fast-math")
  
#include <bits/stdc++.h> 
  
using namespace std;
  
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
  
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
  
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
  
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i; 
    }
    return str;
}
  
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
  
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    // freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();   
    return 0;
}

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(3*n);
    for(int i = 0; i < 3*n; i++){
        cin >> a[i];
    }

    priority_queue<int,vector<int>,greater<int>> bigger_remain;
    priority_queue<int> smaller_remain;

    vector<ll> bigger_sum(n+1);
    vector<ll> smaller_sum(n+1);
    ll tmp_bigger_sum = 0;
    ll tmp_smaller_sum = 0;
    for(int i = 0; i < n; i++){
        bigger_remain.push(a[i]);
        tmp_bigger_sum += a[i];
        smaller_remain.push(a[3*n-1-i]);
        tmp_smaller_sum += a[3*n-1-i];
    }
    bigger_sum[0] = tmp_bigger_sum;
    smaller_sum[0] = tmp_smaller_sum;
    int tmp_pop;
    for(int i = 0; i < n; i++){
        tmp_bigger_sum += a[n+i];
        bigger_remain.push(a[n+i]);
        tmp_pop = bigger_remain.top();
        bigger_remain.pop();
        tmp_bigger_sum -= tmp_pop;
        bigger_sum[1+i] = tmp_bigger_sum;
        tmp_smaller_sum += a[2*n-1-i];
        smaller_remain.push(a[2*n-1-i]);
        tmp_pop = smaller_remain.top();
        smaller_remain.pop();
        tmp_smaller_sum -= tmp_pop;
        smaller_sum[1+i] = tmp_smaller_sum;
    }
    ll ans = -9999999999999999;
    for(int i = 0; i < n+1; i++){
        ans = max(ans,bigger_sum[i]-smaller_sum[n-i]);
    }

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


Measured memory_bytes: 4092
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int d1[n];
    int d2[n];
    for (int i = 0; i < n; i++)
    {
        cin >> d1[i] >> d2[i];
    }
    int numInRow = 0;
    for (int i = 0; i < n; i++)
    {
        if (d1[i] == d2[i])
        {
            numInRow++;
        }
        else
        {
            numInRow = 0;
        }
        if (numInRow == 3)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ll a, b, x, y, c = 0;
    cin >> a >> b >> x;
    y = a % x;
    if(y == 0) ++c;
    a += (x - y);
    if (a <= b)
    {
        c += (b - a) / x + 1;
    }
    cout << c << endl;
}


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

const int mxn = 2e5;
vector<int> adj[mxn];
vector<bool> vis(mxn, 1);
vector<int> ans(mxn, 0), acc(mxn, 0);

void dfs(int v){
	vis[v] = 0;
	ans[v] += acc[v];
	for(int u : adj[v]){
		if(vis[u]){
			acc[u] += acc[v];
			dfs(u);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, q; cin >> n >> q;
	for(int i = 0, a, b; i < n - 1; ++i){
		cin >> a >> b; --a, --b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 0, a, b; i < q; ++i){
		cin >> a >> b; --a;
		acc[a] += b;
	}
	dfs(0);
	for(int i = 0; i < n; ++i){
		if(i) cout << ' ';
		cout << ans[i];
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 25128
#include <iostream>

using namespace std;

string s;
int nA, nB;

int main() {
	cin>>s;
	for (int i=0; i<3; i++) {
		if (s[i]=='A') nA++;
		if (s[i]=='B') nB++;
	}
	if (nA>=1 && nB>=1) {
		cout<<"Yes";
	} else {
		cout<<"No";
	}
	cout<<'\n';
}

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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  unordered_map<char, unordered_set<char>> cnt1, cnt2;
  for (int i = 0; i < s.size(); ++i) {
    cnt1[s[i]].insert(t[i]);
    cnt2[t[i]].insert(s[i]);
  }
  bool ans = 1;
  for (auto mp : cnt1)
    if (mp.second.size() > 1) ans = 0;
  for (auto mp : cnt2)
    if (mp.second.size() > 1) ans = 0;
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin >> h >> w;
    vector<bool> a(h*w,false);

    queue<int> que;
    for(int i = 0; i < h; i++) {
        string tmp;
        cin >> tmp;
        for(int j = 0; j < w; j++) {
            int idx=i*w+j;
            if(tmp[j]=='#'){
                a[idx]=true;
                que.push(idx);
            }
        }
    }

    int cnt=0;
    int ans=0;
    while(cnt<h*w) {
        int n=que.size();
        cnt+=n;
        for(int i = 0; i < n; i++) {
            int idx=que.front();
            int add[4]={1,-1,w,-w};
            for(int j = 0; j < 4; j++) {
                int t=idx+add[j];
                int r=idx/w+add[j]/w;
                int c=idx%w+add[j]%w;
                if(r<0||r>=h||c<0||c>=w||a[t]==true) continue;
                a[t]=true;
                que.push(t);
            }
            que.pop();
        }
        ans++;
    }
    cout << ans-1 << "\n";

    return 0;
}

Measured memory_bytes: 7404
import bisect

a, b, q = map(int, input().split())
ss = sorted([int(input()) for _ in range(a)] + [float('inf'), -float('inf')])
ts = sorted([int(input()) for _ in range(b)] + [float('inf'), -float('inf')])
xs = [int(input()) for _ in range(q)]

for x in xs:
    sindex = bisect.bisect(ss, x)
    sl = x - ss[sindex - 1]
    sr = ss[sindex] - x
    tindex = bisect.bisect(ts, x)
    tl = x - ts[tindex - 1]
    tr = ts[tindex] - x
    print(
        min([
            max(sl, tl),
            max(sr, tr),
            2 * sl + tr,
            2 * tl + sr,
            2 * sr + tl,
            2 * tr + sl,
        ]))

Measured memory_bytes: 17700
#include<stdio.h>
#include<algorithm>
int p[3];
using namespace std;
int main(){
    int a=0,b=0,c=0,d=0;
    while(~scanf("%d%d%d",p,p+1,p+2)){
        std::sort(p,p+3);
        if(p[0]+p[1]<=p[2]){
            printf("%d %d %d %d\n",a,b,c,d);
            return 0;
        }
        a++;
        if(p[0]*p[0]+p[1]*p[1]==p[2]*p[2])b++;
        if(p[0]*p[0]+p[1]*p[1]>p[2]*p[2])c++;
        if(p[0]*p[0]+p[1]*p[1]<p[2]*p[2])d++;
    }
}


Measured memory_bytes: 2780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  map<char, int> count;
  bool ans=true;
  for(int i=0;i<s.size();i++){
    char c=s[i];
    count[c]++;
    if(count[c]>=2){ans=false;break;}
  }
  cout << (ans?"yes":"no") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, d;
    cin >> n >> d;
    vector<P> v(n);
    rep(i, n) cin >> v[i].first >> v[i].second;
    two_sat g(n);
    rep(i, n) rep(j, i) {
        rep(ii, 2) {
            rep(jj, 2) {
                if (abs(v[i].first-v[j].first)<d) {
                    g.add_clause(i, ii==0, j, jj==0);
                }
                swap(v[j].first, v[j].second);
            }
            swap(v[i].first, v[i].second);
        }
    }
    bool ok = g.satisfiable();
    if (!ok) {
        pr("No");
        return 0;
    }
    pr("Yes");
    auto ans = g.answer();

    rep(i, n) {
        if (!ans[i]) pr(v[i].first);
        else pr(v[i].second);
    }
    
    return 0;
}


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

class A {
	static void Main() {
		var n = Console.ReadLine().Split().Select(int.Parse).ToArray();
		if(n[0] > 0) {
			Console.WriteLine("Positive");
		} else if(n[0] <= 0 && n[1] >= 0) {
			Console.WriteLine("Zero");
		} else if((n[1] - n[0]) % 2 == 1) {
			Console.WriteLine("Positive");
		} else {
			Console.WriteLine("Negative");
		}
	}
}

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

int main()
{
    int x,y;
    cin>>x>>y;
    int cnt=1;
    int temp=y;
    while(temp>=9)
    {
        temp=temp/10;
        cnt++;
    }
    long long number;
    number=(x*powl(10,cnt)+y);
    //cout<<number<<endl;
    int s=sqrt(number);
    if(s*s==number)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

long long DP[1 << 16];
long long N;
vector<vector<long long>> A;

long long dp(long long code) {
	if (DP[code] != LLONG_MIN)return DP[code];
	//分割
	long long ans = LLONG_MIN;
	//立っている1の数を数える
	long long sub = code;
	sub = ((sub & 0xAAAA) >> 1) + (sub & 0x5555);
	sub = ((sub & 0xCCCC) >> 2) + (sub & 0x3333);
	sub = ((sub & 0xF0F0) >> 4) + (sub & 0x0F0F);
	sub = ((sub & 0xFF00) >> 8) + (sub & 0x00FF);
	if (sub <= 1) {
		DP[code] = 0;
		return 0;
	}
	else if (sub == 2) {
		DP[code] = 0;
		vector<long long > c;
		for (long long s = 0; s < N; s++) {
			if ((code >> s) & 1)c.push_back(s);
		}
		DP[code] = max((long long)0, A[c[0]][c[1]]);
		return DP[code];
	}
	//ある自然数集合Sの部分集合を降順に列挙
	sub = code;
	ans = LLONG_MIN;
	do {
		if(sub != code && sub != 0)ans = max(ans, dp(sub)+dp(code-sub));
		sub = (sub - 1) & code;
	} while (sub != code);
	//全員で1グループの時
	long long sum = 0;
	for (long long s = 0; s < N; s++) {
		if((code>>s)&1){
			for (long long t = 0; t < N; t++) {
				if (!((code >> t) & 1))continue;
				sum += A[s][t];
			}
		}
	}
	ans = max(ans, sum >> 1);
	DP[code] = ans;
	return DP[code];
}

int main() {
	cin >> N;
	A.resize(N, vector<long long>(N, 0));
	for (long long t = 0; t < N; t++) {
		for (long long s = 0; s < N; s++) {
			cin >> A[s][t];
		}
	}
	for (long long code = 0; code < (1 << N); code++) {
		DP[code] = LLONG_MIN;
	}
	cout << dp((1 << N) - 1) << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  vector<vector<int>> g(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  rep(i,n){
    bool is = true;
    for(auto nv:g[i]){
      if(h.at(i)<=h.at(nv))is=false;
    }
    if(is)ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

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


int main()
{
  int n;
  cin >> n;
  int gusu = 0, kisu = 0;
  vector<int> v(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if(v[i] % 2 == 0) gusu++;
    else kisu++;
  }
  ll res = pow(3, n) - pow(2, gusu);
  cout << res << endl;


}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split(' ')))
a = 0
for i in range(N):
  a += (-1) ** i * A[i]
res = [0 for _ in range(N)]
res[0] = a
print('{} '.format(res[0]), end='')
for i in range(1, N - 1):
  res[i] = 2 * A[i-1] - res[i-1]
  print('{} '.format(res[i]), end='')
res[N-1] = 2 * A[N-2] - res[N-2]
print(res[N-1])

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
map<int,int> GetPrimeFactors(int n) {
  map<int,int> mp;
  // dived by 2, 3, 5, ...
  for(int i=2; i*i<=n; i+=2) {
    if(i==4) i = 3;
    while(n%i == 0) {
      ++mp[i];
      n /= i;
    }
  }
  if(n!=1) ++mp[n];

  return mp;
}
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int p;
  cin >> p;
  if(n == 1) {
    cout << p << endl;
    return 0;
  }
  if(p == 1) {
    cout << 1 << endl;
    return 0;
  }
  map<int, int> mp = GetPrimeFactors(p);
  int ans = 1;
  REPOBJ(itr, mp) {
    int tmp = itr->second / n;
    if(tmp) ans *= pow(itr->first, tmp);
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;

  int count = 1;
  for (int i = min(a, b); i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      if (count == k) {
        cout << i << endl;
        return 0;
      } else if (count < k)
        count++;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 10000000
#define M 2000000000
 
int n, S[N];

int count = 0;
 
void merge(int,int);
void Merge(int,int,int);

 
int main() {
 
  int i,left, right;
 
    scanf("%d", &n);
    
    for(i = 0; i < n; i++)
      {
	scanf("%d", &S[i]);
      }
    
    left = 0;
    
    right = n;
 
    merge(left, right);
 
    for(i = 0; i < n-1; i++)
      {
	printf("%d ", S[i]);
      }
    
    printf("%d\n", S[n-1]);

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

void Merge(int left, int mid, int right){
 
    int n1 = mid - left;
    int n2 = right - mid;
 
    int L[n1+1], R[n2+1];
 
    int i, j, k;
 
    for(i = 0; i < n1; i++)
      {
	L[i] = S[left + i];
      }
    
    for(i = 0; i < n2; i++)
      {
	R[i] = S[mid + i];
      }
    
    L[n1] = R[n2] = M;
 
    i = j = 0;
    
    
    for (k = left; k < right; k++)
      {
        count ++;
	
        if(L[i] <= R[j]) S[k] = L[i++];
	
        else S[k] = R[j++];
    }
 
}
 
void merge(int left, int right)
{

  int mid;
 
    if(right - left <= 1) return;
 
    mid = (left + right) / 2;

    merge(left, mid);

    merge(mid, right);
 
    Merge(left, mid, right);
}

Measured memory_bytes: 4500
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "SUN") cout << "7";
	if (s == "MON") cout << "6";
	if (s == "TUE") cout << "5";
	if (s == "WED") cout << "4";
	if (s == "THU") cout << "3";
	if (s == "FRI") cout << "2";
	if (s == "SAT") cout << "1";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3136
N = int(input())
A = list(map(int, input().strip().split()))
a = True
for i in list(filter(lambda x: x % 2 == 0, A)):
    if i % 3 != 0 and i % 5 != 0:
        print("DENIED")
        a = False
        break

if a:
    print("APPROVED")

Measured memory_bytes: 3060
//0055

#include<cstdio>

int main(void)
{
	const int N = 10;
	double a[N];
	double n;
	double s;
	int i;
	while(scanf("%lf", &n) == 1)
	{
		a[0] = n;
		for(i = 1; i < N; i++)
		{
			a[i] = (i&1 ? 2*a[i-1] : a[i-1]/3);
		}
		s = 0;
		//ツ古」ツづォツづ個要ツ素ツづ個づ卍つ、ツつェツ渉ャツつウツつ「ツづ個づ、ツ古ォツ債キツづーツ渉ュツづ按つュツつキツづゥツつスツづ淞づ可古」ツづォツつゥツづァツ堕ォツつオツづつ「ツつュ
		for(i = N-1; i >= 0; i--)
			s += a[i];
		printf("%.8f\n", s);
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    char c;
    cin >> c;
    if (c == 'z') cout << 'a' << endl;
    else {
        ++c;
        cout << c << endl;
    }
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool debug = 0;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  ll a;
  cin >> a;
  typedef pair<int,int> ii;
  set<ii> S;
  REP(i,1,a) {
    int s = i;
    int t = a - s;
    if( s == t ) continue;
    if( s > t ) swap(s,t);
    S.insert(ii(s,t));
  }
  cout << S.size() << endl;
  compute();
  return 0;
}


Measured memory_bytes: 23680
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
using namespace std;

int main() {
	char a, b;
	cin >> a >> b;
	if ((a == 'H'&&b == 'H') || (a == 'D'&&b == 'D'))
		cout << 'H';
	else
		cout << 'D';
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<char, vector<ll>> M;
    rep (i, n) {
        string S;
        cin >> S;
        for (char c = 'a'; c <= 'z'; ++c) {
            M[c].pb(0);
        }
        for (char c : S) {
            M[c][i] += 1;
        }
    }
    vector<pair<char, ll>> V;
    for (auto it : M) {
        ll c = linf;
        for (ll i : it.snd) {
            c = min(c, i);
        }
        V.pb({it.fst, c});
    }
    sort(all(V));
    for (auto v : V) {
        while (v.snd > 0) {
            v.snd -= 1;
            cout << v.fst;
        }
    }
    cout << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long inf = 2e9;
int n;
int a[maxn], p[maxn];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(&a[1],&a[n+1]);
	int ex = 0;
	for(int i=1;i<=n;i++) if(a[i]<=0) ex++;
	if(ex<=1) {
		int ans = 0;
		for(int i=2;i<=n;i++) ans += a[i];
		ans -= a[1];
		for(int i=1;i<=n;i++) p[i] = a[i];
		printf("%d\n",ans);
		int cur = p[1];
		for(int i=3;i<=n;i++) printf("%d %d\n",cur,p[i]), cur = cur-p[i];
		printf("%d %d\n",p[2],cur);
	}
	else if(ex==n) {
		int ans = 0;
		for(int i=1;i<=n;i++) p[i] = a[i];
		for(int i=1;i<n;i++) ans -= a[i];
		ans += a[n];
		printf("%d\n",ans);
		int cur = p[n];
		for(int i=1;i<n;i++) printf("%d %d\n",cur,p[i]), cur = cur-p[i];
		assert(cur==ans);
	}
	else {
		int ans = 0;
		for(int i=1;i<=n;i++) p[i] = a[i];
		for(int i=1;i<=n;i++) ans += a[i] * (a[i]>0 ? 1 : -1);

		printf("%d\n",ans);
		int cur = p[ex];
		for(int i=ex+1;i<n;i++) printf("%d %d\n",cur,p[i]), cur = cur-p[i];
		printf("%d %d\n",p[n],cur);
		cur = p[n]-cur;
		for(int i=1;i<ex;i++) printf("%d %d\n",cur,p[i]), cur = cur-p[i];
	}
}

Measured memory_bytes: 2688
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int n;
    cin >> n;
    map<pair<char, int>, int> C;
    rep(i, n) {
        int v;
        char s;
        cin >> s >> v;
        C[{s, v}] = 1;
    }
    char c[4] = {'S', 'H', 'C', 'D'};
    rep(i, 4) {
        for (int j = 1; j < 14; j++) {
            if (C[{c[i], j}] == 0) {
                cout << c[i] << " " << j << "\n";
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n,d;
    cin >> n >> d;
    
    int a[n+5][d+5];
    
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> a[i][j];
        }
    }
    
    int cnt=0;
    
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            double res = 0.0;
            
            for(int k=0;k<d;k++)
                res += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
                
            if(floor(sqrt(res)) == ceil(sqrt(res))) cnt++;
        }
    }
    cout << cnt << endl;
	
	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

const ll mod=1000000007LL;
ll dp[100010],t[100010],a[100010];

int main(void){
	int n;
	cin >> n;

	rep(i,n) cin >> t[i];
	rep(i,n) cin >> a[i];

	dp[0]=1LL;
	rep(i,n){
		ll tlb=t[i],tub=t[i];
		if(i-1 >=0 and t[i-1]==t[i])  tlb=1LL;
		ll alb=1LL,aub=a[i];
		if(a[i+1]!=a[i]) alb=a[i];
		//cout << tlb << " " << tub << endl;
		//cout << alb << " " << aub << endl;
		dp[i+1]=dp[i]*max(0LL,min(tub,aub)-max(tlb,alb)+1LL)%mod;
	}

	//rep(i,n) cout << dp[i] << endl;
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll A,B,C; cin >> A >> B >> C;
    ll ma = max(A, max(B,C));
    if(A % 2 == 0 or B % 2 == 0 or C % 2 == 0) {cout << 0 << endl; return 0;}
    else {
        if(A == ma) {cout << B*C << endl; return 0;}
        if(B == ma) {cout << A*C << endl; return 0;}
        if(C == ma) {cout << A*B << endl; return 0;}
    }
}

Measured memory_bytes: 256
import math
n=int(input())
tmp = int(math.sqrt(n)) + 1
ans=0
for num in range(2,tmp):
  count=0
  while n % num == 0:
    n //= num
    count+=1
  ans+=int(math.sqrt(2*count+0.25)-0.5)
if n!=1:
  ans+=1
print(ans)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007
#define M 1000006
# define N 100005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

int main()
{
	int a,b;
	cin >> a >> b;
	a--;
	string s;
	cin >> s;
	for(int i=0;i<s.length();i++)
	{
		if(s[a+1]!='-')
		{
          cout << "No";
          return 0;
		}
		if(i!=(a+1))
		{
			int t=s[i]-'0';
			if(t<0 ||  t>9)
			{
				cout << "No";
				return 0;
			}
		}

	}
	cout << "Yes";

}

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

int main() {
	string S, T;
	cin >> S >> T;
	int ans = S.length();
	for (int i = 0; i <= S.length() - T.length(); i++) {
		int now = 0;
		for (int j = 0; j < T.length(); j++) {
			now += (S[i + j] != T[j]);
		}
		ans = min(ans, now);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    vll x(n);
    rep(i, n){
        cin >> x[i];
    }
    ll ans = 0;
    rep(i, n-1){
        ans += min(a*(x[i+1]-x[i]), b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include<stdlib.h>
int main(void)
{
	int a, b;
    scanf("%d %d", &a, &b);
    
    if(a < b)
    {
    	printf("a < b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else 
	{
		printf("a == b\n");
	}
	return 0;
}


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

int main() {
    string s, t; cin >> s >> t;
    int len = t.size();
    if (s == t.erase(len - 1)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3068
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    if h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    if h[A[i] - 1] == h[B[i] - 1]:
        p[A[i]] = False
        p[B[i]] = False
    
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))


Measured memory_bytes: 25832
def main():
    # n = int(input())
    # n, m = map(int, input().split())
    # a = list(map(int, input().split()))
    s = input()
    # h = [int(input()) for _ in rane(n)]
    count = 0
    maxi = 0
    for string in s:
        if string == "A" or string == "C" or string == "G" or string == "T":
            count += 1
            maxi= max(count, maxi)
        else:
            count = 0

    print(maxi)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61836
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define PB push_back
#define rep(i, a, n) for(int i = a; i < n; i++)
#define Y "Yes"
#define N "No"
using namespace std;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a + b) cout << min(a, k);
	else cout << min(a, k) - k + a + b;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int mod = 1e9 + 7;

int n, k;
ll ans;

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

inline ll comb(ll x) {
	return x * (x + 1) / 2;
}

int main() {
	read(n), read(k);
	for (R int i = k; i <= n + 1; ++i)
		ans = (ans + comb(n) - comb(n - i) - comb(i - 1) + 1) % mod;
	cout << ans << endl;
	return 0;
}

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

const int oo = 1e9;

#define pb push_back

using namespace std;

int n , m , l[200001], r[200001], seg[4 * 200001], lazy[4 * 200001];

vector<int> q[200001];

void build(int n , int s , int e) {
	if (s == e) {
		if(s == m+1)
			seg[n] = 0;
		else
			seg[n] = -(m - s + 1);
		return;
	}
	build(2 * n, s, (s + e) / 2);
	build(2 * n + 1, (s + e) / 2 + 1, e);
	seg[n] = max(seg[2 * n], seg[2 * n + 1]);
}
void push(int n , int s, int e) {
	seg[n] += lazy[n];
	if (s != e) {
		lazy[2 * n] += lazy[n];
		lazy[2 * n + 1] += lazy[n];
	}
	lazy[n] = 0;
}
void update(int n , int s , int e,  int l , int r , int val) {
	push(n, s, e);
	if (s > r || e < l)return;
	if (s >= l && e <= r) {
		lazy[n] = val;
		push(n, s, e);
		return;
	}
	update(2 * n, s, (s + e) / 2, l, r, val);
	update(2 * n + 1, (s + e) / 2 + 1, e, l, r, val);
	seg[n] = max(seg[2 * n], seg[2 * n + 1]);
}
int get(int n , int s , int e, int l , int r) {
	push(n, s, e);
	if (s > r || e < l)return -oo;
	if (s >= l & e <= r)return seg[n];
	return max(get(2 * n, s, (s + e) / 2, l, r), get(2 * n + 1, (s + e) / 2 + 1, e, l, r));
}
int main() {
	scanf("%d%d", &n, &m);
	build(1, 1, m+1);
	int mx = n - m;
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &l[i], &r[i]);
		q[l[i]].pb(i);
	}
	// L + (M-R+1) - Charis in Left - Chairs in Right
	for(int i = 0; i <= m ; ++i){
		for(int j = 0 ; j < q[i].size();++j){
			int v = q[i][j];
			//cout << "UPDATE " << 1 << " " << r[v] << endl;
			update(1,1,m+1,1,r[v],+1);
		}
		mx = max(mx,get(1,1,m+1,i+1,m+1)-i);
	}
	mx = max(0,mx);
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 16384
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::string s;
  cin >> s;
  int result = 0;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] != s[i - 1]) result++;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MAX_N = 1<<24;
bool Hash[MAX_N];
int getHash(string s)
{
    int res = 1, x = 1;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A') res += x * 1;
        if(s[i] == 'C') res += x * 2;
        if(s[i] == 'G') res += x * 3;
        if(s[i] == 'T') res += x * 4;
        x *= 5;
    }
    return res;
}
void insert(string s)
{
    int num = getHash(s);
    Hash[num] = true;
}
bool find(string s)
{
    int num = getHash(s);
    return (Hash[num] ? true : false);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 0; i < MAX_N; i++) Hash[i] = false;
    int n; cin >> n;
    for(int i = 0; i < n; i++)
    {
        string s, t; cin >> s >> t;
        if(s == "insert") insert(t);
        else cout << (find(t) ? "yes" : "no") << endl;
    }
    return 0;
}



Measured memory_bytes: 19604
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        long K = NextLong();
        List<int>[] G = Enumerable.Range(0, N + 1).Select(v => new List<int>()).ToArray();
        for (int i = 0; i < N - 1; i++)
        {
            int a = NextInt(), b = NextInt();
            G[a].Add(b);
            G[b].Add(a);
        }
        int[] rel = Enumerable.Range(0, N + 1).Select(v => 0).ToArray();
        long[] ans = Enumerable.Range(0, N + 1).Select(v => (long)-1).ToArray();

        Stack<int> S = new Stack<int>();
        S.Push(1);
        while (S.Count() != 0)
        {
            int u = S.Pop();
            long cou = 0;
            foreach (var e in G[u]) { cou += rel[e]; rel[e] += 1; }
            rel[u] += 1;
            ans[u] = K - cou;
            foreach (var e in G[u]) { if (ans[e] == -1) S.Push(e); }
            //Console.WriteLine(u);
        }

        long sum = 1;
        for (int i = 1; i <= N; i++) { sum *= ans[i]; sum %= MOD; }
        Console.WriteLine(sum);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 37644
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int ans = ( n + max(h, w) - 1 ) / max(h, w);
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
	int w;
	int i;
	
	while (scanf("%d", &w) != EOF){
		int weight[10] = {0};
		int n;
		int flag = 0;
		
		for (i = 9; i >= 0; i--){
			if (w - (int)pow(2, i) >= 0){
				weight[i] = 1;
				w -= (int)pow(2, i);
			}
		}
		for (i = 0; i < 10; i++){
			if (!flag && weight[i]){
				printf("%d", (int)pow(2, i));
				flag = 1;
			}
			else if (weight[i]){
				printf(" %d", (int)pow(2, i));
			}
		}
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 648
n = int(input())
al = list(map(int, input().split()))

ol =al[::2]
el =al[1::2]

from collections import Counter
col = Counter(ol)
cel = Counter(el)
scol = sorted(col.items(), key=lambda x: x[1], reverse=True)  
scel = sorted(cel.items(), key=lambda x: x[1], reverse=True)  
scol.append(("x",0))
scel.append(("y",0))


temp = scol[0][1] + scel[0][1]

if scol[0][0]==scel[0][0]:
    temp2 = scol[0][1]+scel[1][1]
    temp3 = scol[1][1]+scel[0][1]
    print(n-max(temp2,temp3))
    
else:
    print(n-temp)

Measured memory_bytes: 27672
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

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

	ll A, B, C;
	cin >> A >> B >> C;

	vector<ll> list;
	list.emplace_back (A);
	list.emplace_back (B);
	list.emplace_back (C);

	ll ans = 0;

	while (!(list[0] == list[1] && list[1] == list[2])) {
		sort (list.begin (), list.end ());

		if (list[1] != list[2]) {
			++list[0];
			++list[1];
			++ans;
			continue;
		}

		if (list[1] - list[0] <= 1) {
			++list[0];
			++list[1];
			++ans;
			continue;
		}
		
		list[0] += 2;

		++ans;
	}

	cout << ans << endl;
}



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

const int mod = 1e9+7;

#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    int n, k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i = 0;i<n;i++)
        cin>>a[i];
    int ans = 0;
    int mul = k*(k-1)/2;
    mul %= mod;
    for(int i = 0;i<n;i++)
    {
        int one = 0, all = 0;
        for(int j = 0;j<i;j++)
            if(a[j] > a[i])
                one++;
        for(int j = 0;j<n;j++)
            if(a[j] > a[i])
                all++;
        ans = (ans + ((k*one)%mod + (mul*all)%mod)%mod)%mod;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let C: Vec<Vec<char>> = (0..H).map(|_| {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    }).collect();

    let ans = (0..(2 * H))
        .map(|i| C[i / 2].iter().map(|&c| c).collect::<String>())
        .collect::<Vec<_>>()
        .join("\n");

    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        ans += Math.min(a, k);
        k -= a+b;
        if(0 < k){
            ans -= k;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 35780
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;

public class Main{
  public static void main(String[]args){
    InputStreamReader isr=new InputStreamReader(System.in);
    BufferedReader br=new BufferedReader(isr);
    String str=null;
    try{
      str=br.readLine();
      br.close();
     }catch(IOException e){
       e.printStackTrace();
     }
    if(str.equals("Sunny")){
      System.out.println("Cloudy");
    }
    if(str.equals("Cloudy")){
      System.out.println("Rainy");
    }
    if(str.equals("Rainy")){
      System.out.println("Sunny");
    }
  }
  }
       
      
    

Measured memory_bytes: 21076