akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
  int64_t n, m, R;
  cin >> n >> m >> R;
  
  vector<int64_t> r(R);
  for (auto&& rr : r) {
    cin >> rr;
    --rr;
  }
  
  vector<vector<int64_t>> distance(n, vector<int64_t>(n, numeric_limits<int32_t>::max()));
  for (auto i : irange(0L, m)) {
    int64_t a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    distance[a][b] = c;
    distance[b][a] = c;
  }
  
  for (auto i : irange(0L, n)) {
    for (auto j : irange(0L, n)) {
      for (auto k : irange(0L, n)) {
        distance[j][k] = min(distance[j][k], distance[j][i] + distance[i][k]);
      }
    }
  }
  
  vector<vector<int64_t>> dp(1uL << R, vector<int64_t>(R, numeric_limits<int32_t>::max()));
  for (auto s : irange(0uL, 1uL << R)) {
    bitset<8> bs(s);
    for (auto i : irange(0L, R)) {
      if (!bs[i]) {
        continue;
      }
      
      if (s == (1uL << i)) {
        dp[s][i] = 0;
        continue;
      }
      
      for (auto j : irange(0L, R)) {
        if (i == j || !bs[j]) {
          continue;
        }
        dp[s][i] = min(dp[s][i], dp[s & ~(1uL << i)][j] + distance[r[j]][r[i]]);
      }
    }
  }
  
  cout << *min_element(dp.back().begin(), dp.back().end()) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc168/abc168_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

using R = long double;
constexpr R EPS = 1E-3;

// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(const R& r) { return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(const R& a, const R& b) { return sgn(a - b); }

int main() {
  INPUT_FILE CIN_OPTIMIZE;
  const double PI = 3.14159265358979323846;
  const double PI_ROUGH = 3.14;

  int A, B, H, M;
  cin >> A >> B >> H >> M;

  double br = (2 * PI / (60 * 12)) * (60 * H + M);
  double ar = (2 * PI / 60) * M;
  double theta = br - ar > 0 ? br - ar : ar - br;
  // if (theta > PI) {
  //   theta -= PI;
  // }
  if (sgn(theta, PI) == 0) {
    printf("%d", A + B);
    return 0;
  } else if (sgn(theta, 0) == 0) {
    printf("%d", abs(A - B));
    return 0;
  }
  // 余弦定理
  double c = sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * cos(theta));

  printf("%0.12lf", c);
}

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

int main(){
  string a;
  getline(cin,a);
  if(a[0] ==a[1] && a[1] == a[2]){cout << "Yes" << endl;}
  else if(a[1] ==a[2] && a[2] == a[3]){cout << "Yes" << endl;}else
  {cout << "No" << endl;}
}

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    string S; cin >> S;
    int N = S.size();
    int ans = 0;
    for (int i = 0; i < N/2; i++) {
        if (S[i] != S[N-1-i]) ans++;
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3536
N = int(input())
S = input()
S1 = S[:N]
S2 = S[N:][::-1]
from itertools import groupby, accumulate, product, permutations, combinations
from collections import defaultdict
def half(S):
  dic = defaultdict(lambda: 0)
  for pro in product([0,1],repeat=N):
    s1 = s2 = ''
    for i,p in enumerate(pro):
      s1 += S[i]*p
      s2 += S[i]*(1-p)
    dic[(s1,s2)] += 1
  return dic
dic1 = half(S1)
dic2 = half(S2)
ans = 0
for k,v in dic1.items():
  ans += v*dic2[k]
print(ans)

Measured memory_bytes: 262420
N, C, K = map(int, input().split())
T = sorted(list(int(input()) for _ in range(N)))

bus = 0
pa = 1
S = T[0]

for i in T[1:]:
    pa += 1
    if K < i-S or pa > C:
        bus += 1
        pa = 1
        S = i
print(bus+1)

Measured memory_bytes: 14036
H,W = map(int,input().split())
src = [input() for i in range(H)]
ans = []
for row in src:
    ans.append(list(row))
dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1)]
for y in range(H):
    for x in range(W):
        if src[y][x] == '#': continue
        c = 0
        for dx,dy in dxy:
            if x+dx < 0 or x+dx > W-1 or y+dy < 0 or y+dy > H-1: continue
            if src[y+dy][x+dx] == '#': c += 1
        ans[y][x] = c
for row in ans:
    print(''.join(list(map(str,row))))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N, Ma, Mb;
vector<int> a(41, 0), b(41, 0), c(41, 0);

int main(void){
    
    scanf("%d %d %d", &N, &Ma, &Mb);
    int amax = 0, bmax = 0;
    for(int i = 0; i < N; ++i){
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
        amax += a[i], bmax += b[i];
    }
    
    vector<vector<int>> dp(401, vector<int>(401, INT_MAX));
    dp[0][0] = 0;
    for(int i = 0; i < N; ++i){
        for(int y = amax; y >= 0; --y){
            for(int x = bmax; x >= 0; --x){
                if(dp[y][x] == INT_MAX) continue;
                dp[y + a[i]][x + b[i]] = min(dp[y + a[i]][x + b[i]], dp[y][x] + c[i]);
            }
        }
    }
    
    int ans = INT_MAX;
    int ma = Ma, mb = Mb;
    while(ma <= amax && mb <= amax){
        ans = min(ans, dp[ma][mb]);
        ma += Ma, mb += Mb;
    }
    printf("%d\n", (ans == INT_MAX) ? -1 : ans);
    
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=(a),i##Len_=(b);i<i##Len_;i++)

//参考
//http://drken1215.hatenablog.com/entry/2019/06/15/135300
int main() {

    ll N,M,res;
    cin >> N >> M;
    vector <vector<ll>> s(M);
    REP(i,M)
    {
        ll K;
        cin >> K;
        REP(j,K)
        {
            ll a;
            cin >> a;
            a--;
            s[i].push_back(a);
        }
    }
    vector <ll> p(M);
    REP(i,M)
    {
        cin >> p[i];
    }

    res = 0;

    //bit全探索
    //bit 0b0101 → 4個のスイッチ
    for(ll bit = 0; bit < (1<<N); ++bit)
    {
        bool isOK = true;
        REP(i,M)
        {
            ll con = 0;
            //スイッチ s[i][0],s[i][2],…, のうち on になっている個数を
            //2 で割った余りが p[i] に等しい時に点灯
            for(auto v:s[i])
            {
                //s[i]について、ONを数え上げ
                if(bit & (1 << v))++con;
            }
            //すべての電球で成立する必要がある
            if(con % 2 != p[i])isOK = false;
        }
        if(isOK)res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	while(1){
		int n,m,p,q,r;
		scanf("%d",&n); if(n == 0)break;
		scanf("%d%d%d%d",&m,&p,&q,&r);
		
		vector<P> vec;
		vec.pb( P ( 1 , n+1 ) );
		
		rep(i,m){
			int x,y;
			scanf("%d%d",&x,&y);
			
			int a=-1,b,c=-1,d;
			int sum = 0;
			rep(j,vec.size()){
				sum += vec[j].sc-vec[j].fr;
				if(sum > x && a == -1){
					a = j;
					b = vec[j].sc-vec[j].fr-sum+x;
				}
				if(sum > y && c == -1){
					c = j;
					d = vec[j].sc-vec[j].fr-sum+y;
				}
			}
			
			vector<P> vec_;
			if(a != c){
				vec_.pb ( P ( vec[c].fr+d , vec[c].sc ) );
				for(int j = c+1 ; j < vec.size() ; j ++){
					vec_.pb( vec[j] );
				}
				vec_.pb ( P ( vec[a].fr+b , vec[a].sc ) );
				for(int j = a+1 ; j < c ; j ++ ){
					vec_.pb ( vec[j] );
				}
				vec_.pb ( P ( vec[c].fr , vec[c].fr+d ) );
				for(int j = 0 ; j < a ; j ++){
					vec_.pb ( vec[j] );
				}
				vec_.pb ( P ( vec[a].fr , vec[a].fr+b ) );
			}
			else {
				vec_.pb ( P ( vec[c].fr+d , vec[c].sc ) );
				for(int j = c+1 ; j < vec.size() ; j ++){
					vec_.pb( vec[j] );
				}
				vec_.pb ( P ( vec[a].fr+b , vec[a].fr+d ) );
				for(int j = 0 ; j < a ; j ++){
					vec_.pb ( vec[j] );
				}
				vec_.pb ( P ( vec[a].fr , vec[a].fr+b ) );
			}
			
			vec = vec_;
		}
		
		int p_ = 0,q_ = 0;
		int sum = 0;
		rep(i,vec.size()){
			//printf("%d %d\n",vec[i].fr,vec[i].sc);
			p_ += min ( max ( min ( r+1 , vec[i].sc ) - vec[i].fr , 0) , max ( p-1 - sum , 0 ) );
			q_ += min ( max ( min ( r+1 , vec[i].sc ) - vec[i].fr , 0) , max ( q - sum , 0 ) );
			sum += vec[i].sc-vec[i].fr;
		}
		
		printf("%d\n",q_ - p_);
	}
}

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

void connectCite(
    int p,
    const vector<vector<int>>& graph,
    vector<bool>& status)
{
    queue<int> Q;
    Q.push(p);
    status[p] = true;
    while (!Q.empty())
    {  
        int k = Q.front();
        Q.pop();
        for (const auto& q : graph[k]) {
            if (!status[q]) {
                Q.push(q);
                status[q] = true;
            }
        }
    }
}

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

    vector<vector<int>> graph(N);
    vector<bool> status(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        graph[A-1].push_back(B-1);
        graph[B-1].push_back(A-1);
    }
    int count = 0;
    for (int i = 0; i < N; ++i) {
        if (!status[i]) {
            connectCite(i, graph, status);
            ++count;
        }
    }
    cout << count - 1 << endl;
}

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



int main(){
	int n;
	cin >> n;
	int dd = -2; int d = -1;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		if (d - 1 > a) { cout << "No" << endl; return 0; }
		else if (d - 1 == a) {

		}
		else {
			d = a;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100; B *= 100;
    
    int ans_sw = 0, ans_s = 0;
    
    for (int a = 0; a <= F/A; a++) {
        for (int b = 0; b <= (F-A*a)/B; b++) {
            int w = a*A + b*B;
            int max_s = min(E*(w/100), F-w);
            
            for(int c = 0; c <= max_s/C; c++) {
                for(int d = 0; d <= (max_s-c*C)/D; d++) {
                    int s = c*C + d*D;
                    int sw = s + w;
                    if(sw==0) continue;
                    if(sw*ans_s <= s*ans_sw) {
                        ans_s = s;
                        ans_sw = sw;
                    }
                }
            }
            
        }
    }
    
    cout << ans_sw << " " << ans_s << endl;
    
}


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

int main() {
  double h=0,l=999999999,m;
  while(cin >> m) {
	  if (m > h) h=m;
	  if (m < l) l=m;
  }
  printf("%f\n",h-l);
  return 0;
}

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

//       idxの店, 宝箱状況(bit)
long long dp[1005][5000];
long long N, M;
long long a[1005];
long long key[1005];

int main(){
	cin >> N >> M;

	for(long long i = 0; i < M; i++){
		long long tmpb;
		cin >> a[i] >> tmpb;
		long long keystate = 0;
		for(long long j = 0; j < tmpb; j++){
			long long c;
			cin >> c;c--;
			keystate += (1LL << c);
		}
		key[i] = keystate;
	}

	for(long long i = 0; i <= M; i++){
		for(long long j = 0; j <= (1LL << N); j++){
			dp[i][j] = LONG_MAX;
		}
	}
	dp[0][0] = 0;

	for(long long i = 0; i < M; i++){
		long long cost = a[i];
		long long keystate = key[i];
		for(long long j = 0; j < (1LL << N); j++){
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			if(dp[i][j] != LONG_MAX){
				dp[i+1][(j|keystate)] = min(dp[i+1][(j|keystate)], dp[i][j] + cost);
			}
		}
	}

	if(dp[M][(1LL<<N) - 1] == LONG_MAX){
		cout << -1 << endl;
	}else{
		cout << dp[M][(1LL<<N) - 1] << endl;
	}
}


Measured memory_bytes: 39168
//区間更新、一点取得を出来るBIT
#include<bits/stdc++.h>
using namespace std;
struct BinaryIndexedTree{
  int N;
  vector<int> bit;  
  //全て0で初期化
  BinaryIndexedTree(int size){
    bit.resize(size+1,0);
    N=size+1;
  }

  //区間[a,b]の所v[a],v[a+1], v[b]に値wを加える。O(log n)
  void add(int a,int b,int w){
    //bit[a]にwを、bit[b+1]に-wを加える
    for(int x=a;x<=N;x+=(x & -x)) bit[x]+=w;
    for(int x=b+1;x<=N;x+=(x & -x)) bit[x]-=w;
    return;
  }

  //v[a]の値を求める。
  int sum(int a){
    //和 bit[1]+bit[2]+  +bit[a]を求める。
    int ret=0;
    for(int x=a;x>0;x-=(x & -x)) ret+=bit[x];
    return ret;
  }
};
//AOJ DSL 2 E Range Add Query(RAQ) で動作確認しました。
int main(){
    int n,q;
    cin>>n>>q;
    BinaryIndexedTree BIT(n+5);
    int que,s,t,x,a;
    for(int i=0;i<q;i++){
      cin>>que;
      if(que==0){
        cin>>s>>t>>x;
        BIT.add(s,t,x);
      }
      else{
        cin>>a;
        cout<<BIT.sum(a)<<'\n';
      }
    }
    return(0);
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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 (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,n;cin >> a >> b >> n;
    ll t=min(b-1,n);
    cout << a*t/b << endl;
}

Measured memory_bytes: 3576
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
int main()
{
	int q;scanf("%d",&q);
	while(q--)
	{
		LL a,b,m;scanf("%lld %lld",&a,&b);
		m=a*b;
		LL l=1,r=sqrt(m)+10;
		while(l<=r)
		{
			LL mid=l+r>>1;
			if(mid*mid<=m-1) l=mid+1;
			else r=mid-1;
		}
		LL M=l-1,ans=M*2LL,t;
		if(a!=b)
		{
			if(a<=M) ans--;
			if(b<=M) ans--;
			if(m%M==0) t=m/M-1;
			else t=m/M;
			if(t==M) ans--;
		}
		printf("%lld\n",ans);
	}
}

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

int main() {
	int n; cin >> n;
  	map<int, int> m;
  	for (int i = 1; i <= n; i++) {
    	int x; cin >> x;
      	m[x] = i;
    }
  	for (auto x : m) {
    	cout << x.second << " ";
    } cout << endl;
}

Measured memory_bytes: 5504
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

bool acgt(char c) {
    return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

void main()
{
    auto S = readln.chomp.to!(char[]);

    int max_l = 0;
    foreach (int i; 0..cast(int)S.length) {
        if (!acgt(S[i])) continue;
        auto j = i;
        while (j < S.length && acgt(S[j])) ++j;
        max_l = max(max_l, j-i);
    }
    writeln(max_l);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    bool ans = false;
    for (int i = 1; i <= N; i++) {
        if (N % i == 0) {
            int aux = N / i;
            if (i < 10 && aux < 10 && !ans) {
                cout << "Yes" << endl;
                ans = true;
            }
        }
    }

    if (!ans) {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007)
#define l_ength size

void mul_mod(int& a, int b){
	a *= b;
	a %= MOD;
}

void add_mod(int& a, int b){
	a += b;
	a %= MOD;
}

struct edge{
	int l, x;
};

vector<edge> g[334];
int dp[334][334][334];

int main(void){
	int n,m,i,j,k,t,l,r,x,ans=0;
	edge e;
	cin >> n >> m;
	for(t=0; t<m; ++t){
		cin >> l >> r >> x;
		e.l = l; e.x = x;
		g[r].push_back(e);
	}
	dp[0][0][0] = 1;
	for(i=0; i<=n; ++i){
		for(j=0; j<=n; ++j){
			for(k=0; k<=n; ++k){
				r = max(i,max(j,k));
				l = min(i,min(j,k));
				m = (i+j+k)-(l+r);
				if(l && (l == m || m == r)){
					continue;
				}
				for(t=(g[r].l_ength()-1); t>=0; --t){
					e = g[r][t];
					switch(e.x){
						case 3:
							if(!(e.l<=l)){
								dp[i][j][k] = 0;
							}
							break;
						case 2:
							if(!(l<e.l && e.l<=m)){
								dp[i][j][k] = 0;
							}
							break;
						case 1:
							if(!(m<e.l)){
								dp[i][j][k] = 0;
							}
							break;
					}
				}
				if(r==n){
					add_mod(ans,dp[i][j][k]);
					continue;
				}
				add_mod(dp[r+1][j][k],dp[i][j][k]);
				add_mod(dp[i][r+1][k],dp[i][j][k]);
				add_mod(dp[i][j][r+1],dp[i][j][k]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 133248
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  int a[n + 10];
  rep(i, n) cin >> a[i];

  ll sum = 0;
  rep(i,n){
    sum += a[i] - 1;
  }
  out(sum);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio std::ios_base::sync_with_stdio(false), std::cout.tie(0), std::cin.tie(0);
#define N 100007
#define mxx INT_MAX

typedef long long ll;

int main() {
	bool f = 1;
	int num1, num2, num3, num4;
	std::cin >> num1 >> num2 >> num3 >> num4;
	
	while (num1 > 0 && num3 > 0)
	{
		if (f) {
			num3 -= num2;
			f = 0;
		}
		else {
			num1 -= num4;
			f = 1;
		}
		//if (num1 <= 0 || num3 <= 0)break;
		//if (f)f = 0;
		//else f = 1;

	}
	if (num1 <= 0)std::cout << "No";
	else {
		std::cout << "Yes";
	}
}

Measured memory_bytes: 3632
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    if len(s)%2==1:
        print("No")
        sys.exit()
    for i in range(len(s)//2):
        if s[2*i:2*i+2]!="hi":
            print("No")
            break
    else:print("Yes")

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
import math
x = int(input()) -1
def is_prime(x):
    prime = True
    for i in range(2,int(math.sqrt(x))):
        if x % i == 0:
            prime = False
            break
    return prime

while True:
    x += 1
    if is_prime(x):
        print(x)
        break

Measured memory_bytes: 9180
function Main(s){
  s = s.split(" ");
  var k = s[3];
  var a = +s[0];
  var b = +s[1];
  k = k[k.length-1];
  console.log(k % 2 === 0 ? a - b: b - a);
}

Main(require("fs").readFileSync("/dev/stdin","utf8").trim());

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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  for(int i=0;i<N;i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int answer=0;
  for(int i=0;i<vec.size()-1;i++) {
    if(vec.at(i)!=vec.at(i+1)) {
      answer++;
    }
  }
  answer++;
  cout << answer << endl;
}

Measured memory_bytes: 764
n,a,b=map(int,input().split())
sumall=0
for i in range(1,n+1):
    n1=int(i/10**4)
    n2=int((i-n1*10**4)/10**3)
    n3=int((i-n1*10**4-n2*10**3)/10**2)
    n4=int((i-n1*10**4-n2*10**3-n3*10**2)/10)
    n5=int(i-n1*10**4-n2*10**3-n3*10**2-n4*10)
    if (n1+n2+n3+n4+n5)>=a and (n1+n2+n3+n4+n5)<=b:
        sumall=sumall+i
print(sumall)

Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k, x, y = IR(4)
    ans = 0
    for i in range(n):
        if i >= k:
            ans += y
        else:
            ans += x
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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

dic = {}
for _ in range(N):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(-1, 2):
        for j in range(-1, 2):
            if a+i <= 0 or a+i >= H-1 or b+j <= 0 or b+j >= W-1:
                continue
            if (a+i, b+j) in dic:
                dic[(a+i, b+j)] += 1
            else:
                dic[(a+i, b+j)] = 1
                
ans = [0]*10
for t in dic.values():
    ans[t] += 1
ans[0] = (H-2)*(W-2)-sum(ans)

for i in range(10):
    print(ans[i])

Measured memory_bytes: 166608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define ld long double
#define hell 1000000007
#define dd double
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define sep(i,n,b) for(ll i=n-1;i>=b;i--)
#define pb push_back
#define mp make_pair
#define Mll map<ll,ll>
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin >> s >> t;
	if(t.substr(0,t.length()-1)==s){
		cout << "Yes\n";
	}	
	else{
		cout << "No\n";
	}
	return 0;
}

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

using namespace std;

int solve(int y,int m,int d){
    int res=0;
    res+=((y-1)/3)*590;
    if(y%3==0){
        res+=390;
        res+=(m-1)*20;
        res+=d;
    }
    else if(y%3==1){
        res+=((m-1)/2)*39;
        if(m%2==0) res+=20;
        res+=d;
    }
    else{
        res+=195;
        res+=((m-1)/2)*39;
        if(m%2==0) res+=20;
        res+=d;
    }
    return res;
}

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

  int n;cin>>n;
  for(int i=0;i<n;i++){
      int y,m,d;cin>>y>>m>>d;
      cout<<solve(1000,1,1)-solve(y,m,d)<<endl;
  }
}

Measured memory_bytes: 3100
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)
	
	judge := ""
	if a == b {
		judge = "Draw"
	} else if a == 1 {
		judge = "Alice"
	} else if b == 1  {
		judge = "Bob"
    } else if a > b {
    	judge = "Alice"
    } else if a < b {
    	judge = "Bob"
    } 
	fmt.Println(judge)
}

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

using namespace std;
#define int long long
const int N = 4e6 + 10, M = 2e3 + 10, MOD = 1e9 + 7;
int fac[N], inv[N], dp[M][M], ps[M][M];

int sum(int a, int b) {return (a + b) % MOD;}
int mul(int a, int b) {return (a * b) % MOD;}
int Pow(int a, int b)
{
    int res = 1;
    for (; b; b>>=1, a = mul(a, a)) if (b & 1) res = mul(res, a);
    return res;
}

int C(int n, int k)
{
    if (k < 0 || n < 0 || k > n) return 0;
    return mul(fac[n], mul(inv[k], inv[n - k]));
}


int32_t main()
{
    fac[0] = 1;
    for (int i = 1; i < N; i++) fac[i] = mul(fac[i - 1], i);
    inv[N - 1] = Pow(fac[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; i--) inv[i] = mul(inv[i + 1], i + 1);
    int n, k; cin >> n >> k;
    if (k == 1) return cout << "1\n", 0;
    ps[1][1] = dp[1][1] = 1;
    for (int i = 2; i <= n; i++) {
        dp[i][1] = mul(ps[i - 1][1], C(i * k - 2, k - 2));
        for (int j = 2; j <= i; j++) {
            dp[i][j] = mul(ps[i - 1][j - 1], C(i * k - j - 1, k - 2));
        }
        for (int j = i; j >= 1; j--) ps[i][j] = sum(ps[i][j + 1], dp[i][j]);
    }
    cout << mul(ps[n][1], fac[n]) << "\n";
}


Measured memory_bytes: 124416
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 数入力 */
  ll    answer;
  ll    n;
  ll    d; 
  ll    *x;
  ll    *y;
  answer = 0;
  scan = scanf("%lld", &n);
  scan = scanf("%lld", &d);
  x = (ll *)malloc(sizeof(ll) * n);
  y = (ll *)malloc(sizeof(ll) * n);

  for (ll i = 0; i < n; i++) {
    scan = scanf("%lld", &x[i]);
    scan = scanf("%lld", &y[i]);
  } 

  /* プログラムを書く */
  for (ll i = 0; i < n; i++) {
    if (x[i] * x[i] + y[i] * y[i] <= d * d) {
      answer += 1;
    }
  } 

  /* 数回答 */
  printf("%lld", answer);

  return (0);
}



Measured memory_bytes: 4856
def mCk(m, k):
  if k == 3:
    return m * (m - 1) * (m - 2) // 6
  elif k == 2:
    return m * (m - 1) // 2
  elif k == 1:
    return m
  return None

def count_up(n, k):
  digit_n = len(n)
  if digit_n < k: #桁不足
    return 0
  top_n = int(n[0])
  if k == 1:
    return (top_n + 9 * (digit_n - 1))
  return (
    count_up(str(int(n[1:])), k - 1) 
    + (top_n - 1) * mCk(digit_n - 1, k - 1) * (9 ** (k - 1))
    + mCk(digit_n - 1, k) * (9 ** k)
  )


def main():
  n = input() 
  k = int(input())
  print(count_up(n, k))

if __name__ == "__main__":
  main()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  ll count = 0;
  rep(i, n) cin >> v.at(i);
  rep(i, n) {
    ll minj = i;
    for (ll j = i; j < n; j++) {
      if (v.at(j) < v.at(minj)) {
        minj = j;
      }
    }
    if (i != minj) {
      count++;
      swap(v.at(i), v.at(minj));
    }
  }
  rep(i, n) {
    if (i < n-1) {
      cout << v.at(i) << ' ';
    } else {
      cout << v.at(i) << endl;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

pii vec[200000];
int ord[200000];
int p[200000];
int ans[200000];
int rotn[200000];
map<int, int> ma;

// 자신보다 엄격하게 저ㅏㄱ아야하는데..
int find(int a) {
    if (p[a] == -1) return a;
    return p[a] = find(p[a]);
}

void merge(int a, int b) {
    a = find(a); b = find(b);
    if (a == b) return;
    p[b] = a;
    rotn[a] += rotn[b];
}

int main() {
    memset(p, -1, sizeof(p));
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &vec[i].first ,&vec[i].second);
        ord[i] = i;
        rotn[i] = 1;
    }
    sort(ord, ord + n, [](int a, int b){return vec[a] < vec[b];});
    sort(vec, vec + n);

    for (int i = 0; i < n; i++) {
        int val = vec[i].second;
        auto t = ma.lower_bound(val);

        if (t == ma.begin()) {
            ma[val] = i;
            continue;
        }

        vector<int> tmp;
        while (1) {
            t--;
            merge(t->second, i);
            if (t == ma.begin()) break;
            tmp.push_back(t->first);
        }
        for (int j : tmp) ma.erase(j);
    }

    for (int i = 0; i < n; i++) ans[ord[i]] = rotn[find(i)];
    for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
}


// author: rdd6584


Measured memory_bytes: 17176
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn warchall_floyd(vertex: usize, cost: &mut Vec<Vec<usize>>) {
    for k in 0..vertex {
        for j in 0..vertex {
            for i in 0..vertex {
                let ij = cost[i][j];
                let ik = cost[i][k];
                let kj = cost[k][j];
                cost[i][j] = min(ij, ik + kj);
            }
        }
    }
}

fn main() {
    let (h, w) = read!(usize, usize);
    let mut c = vec![];
    for i in 0..10 {
        let t: Vec<usize> = read![[usize]];
        c.push(t);
    }
    let mut a = Vec::with_capacity(h);
    for i in 0..h {
        let t: Vec<i32> = read![[i32]];
        a.push(t);
    }

    warchall_floyd(10, &mut c);

    let mut cost = 0;

    for i in 0..h {
        for j in 0..w {
            if a[i][j] == -1 || a[i][j] == 1 {
                continue;
            }
            cost += c[a[i][j] as usize][1];
        }
    }

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


Measured memory_bytes: 4352
import java.util.*;

public class Main{
	public static void main(String args[] ) {
	     Scanner sc = new Scanner(System.in);
	     int n;
	     int[] a;
	     long res;
	     int i, min, max;

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

	     res = 0;
	     min = a[0];
	     max = a[0];
	     for(i = 0;i < n;i++){
	       if(min > a[i])min = a[i];
	       if(max < a[i])max = a[i];      
	       res += a[i];
	     }

	     System.out.println(min + " " + max + " " + res);
	  }
}



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

bool isprime(ll a)
{
	ll count=0;
	for(int i=1;i*i<=a;i++)
	{
		if(a%i==0)count+=2;
		if(i*i==a)count--;
	}
	
	if(count==2)return true;
	else
	return false;
	
}
void solve()
{

	ll a ,b;
	cin>>a>>b;
	
	ll x=__gcd(a,b);

	if(x==1)
	{
		cout<<1;
		return ;
		
	}
	
ll ans=1;
for(int i=2;i<1000000;i++)
{
bool s,f;
s=f=false;
	while(a%i==0)
	{
		a=a/i;
		f=true;
	}
	while(b%i==0)
	{
		b=b/i;
		s=true;
	}
	
	if(s&&f)ans++;

}
if(a>1&&a==b)
ans++;
cout<<ans;

}
int main()
{


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

		solve();
	
return 0;

		
	}
	
	
	


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

int main(){
  int i, n, b;
  int a=0;
  int c=0;
  cin >> n;
  vector<int> x(n);
  
  for(i=0;i<n;i++){
    cin >> x.at(i);
  }
  
  b=x.at(0);
  
  for(i=0;i<n;i++){
    if(b!=2){
      b=x.at(b-1);
      c++;
    }
    else{
      c++;
      break;
    }
  }
    
  if(c<n){
    cout << c << endl;
  }
  else if(c==n&&b==2){
    cout << n << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;



int main(void){
	ll H,W,c[10][10],a,A[10]={},p[10];
	cin>>H>>W;
	rep(i,10){
		rep(j,10)cin>>c[i][j];
	}
	rep(i,H){
		rep(j,W){
			cin>>a;
			A[a]++;
		}
	}
	rep(i,10){
		queue<ll> Q;
		Q.push(i);
		ll cost[10];
		rep(j,10){
			cost[j]=99999999;
		}
		cost[i]=0;
		while(!Q.empty()){
			ll v=Q.front();
			Q.pop();
			rep(j,10){
				if(cost[v]+c[v][j]<cost[j]){
					cost[j] = cost[v]+c[v][j];
					Q.push(j);
				}
			}
		}
		p[i]=cost[1];
	}
	ll sum=0;
	rep(i,10){
		// cout<<p[i]<<endl;
		sum+=A[i]*p[i];
	}
	cout<<sum<<endl;
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  vi a(n);
  rep(i,0,n) {
    cin>>a[i];
  }
  long long sum = 0;
  rep(i,0,n) sum += a[i];
  if(sum % ((n*1LL*(n+1))/2) != 0) {
    cout<<"NO"<<endl;
    return 0;
  }
  lli k = sum / ((n*1LL*(n+1))/2);
  debug(k);
  rep(i,0,n-1) {
    if((a[i]-a[i+1]+k)<0 || (a[i]-a[i+1]+k)%n != 0) {
      cout<<"NO"<<endl;
      return 0;
    }
  }
  if(((a[n-1]-a[0]+k)<0 || (a[n-1]-a[0]+k)%n != 0)) {
    cout<<"NO"<<endl;
    return 0;
  }
  cout<<"YES"<<endl;
}



Measured memory_bytes: 640
<?php
// 文字列の入力
fscanf(STDIN, "%s", $s);

//文字列の長さを求める
$len = strlen($s);

if ($len === 2) {
  echo $s;
} else {
  $first = $s[0];
  $mid = $s[1];
  $last = $s[2];

  echo $last. $mid. $first;
}
?>


Measured memory_bytes: 3956
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	string ss;
	cin >> ss;
	if(nn % 2 != 0)
	{
		puts("No");
		return 0;
	}
	for(int64 ii = 0;ii < nn / 2;ii++)
	{
		if(ss[ii] != ss[ii + (nn / 2)])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7;

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

const int N = 2e5 + 20, M = 3e3 + 20;
 
int l[N], f[N], dp[M];
 
int power(int a, int b) {
    int ans = 1;
    while(b) {
        if (b & 1) ans = (ans * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return ans;
}
 
int c(int a, int b) { return (a > b ? 0 : (f[b] * ((l[a] * l[b - a]) % MOD)) % MOD); }
 
int32_t main() {
 
    sync; 
    
    f[0] = 1;
    for(int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % MOD;
    l[N - 1] = power(f[N - 1], MOD - 2);
    for(int i = N - 2; i >= 0; i--) l[i] = (l[i + 1] * (i + 1)) % MOD;
 
    int h, w, n; cin >> h >> w >> n;
    vpii v;
    for(int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        v.push_back(make_pair(x, y));
    }
    v.push_back(make_pair(h, w));
    sort(all(v));
    
    for(int i = 0; i < v.size(); i++) {
        dp[i] = c(v[i].first - 1, v[i].first + v[i].second - 2);
        for(int j = 0; j < i; j++) {
            dp[i] -= (dp[j] * c(v[i].first - v[j].first, v[i].first + v[i].second - v[j].first - v[j].second)) % MOD;
            dp[i] = (dp[i] + MOD) % MOD;
        }
    }
 
    cout << dp[n] << endl; 
 
    return 0;
}

Measured memory_bytes: 3584
fun main(args: Array<String>) {
    // Your code here!
    val (s,b,r) = readLine()!!.split(" ").map{it.toLong()}
    val all = b + r
    val sub = s % all
    val div = s / all
    var blue = div * b
    
    var x:Long = 0
    if(sub > b){
        x = b
    }else{
        x = sub
    }
    
    blue += x
    
    println(blue)

}


Measured memory_bytes: 37944
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x&-x)
const int M=3e5+5;
struct d{int l,r;}a[M];
bool cmp(d a,d b){return a.r-a.l<b.r-b.l;}
int sum[M];
void upd(int pos,int x){for(int i=pos;i<M;i+=lowbit(i))sum[i]+=x;return ;}
int que(int pos){int res=0;for(int i=pos;i>0;i-=lowbit(i))res+=sum[i];return res;}
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d%d",&a[i].l,&a[i].r);
    sort(a+1,a+1+n,cmp);
    for(int d=1,j=1;d<=m;d++)
    {
        while(j<=n&&a[j].r-a[j].l<d-1)
        {
            upd(a[j].l,1);
            upd(a[j].r+1,-1);
            j++;
        }
        int ans=n-j+1;
        for(int i=d;i<=m;i+=d)ans+=que(i);
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 3712
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        int n;
        cin >> n;
        int a[n];
        map<int, int> mp;
        for(int i = 0 ; i< n; i++)
        {
            cin >> a[i];
            mp[a[i]]++;
        }

        if(mp.size() == n)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    
    return 0;
}



Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j,c;
	cin >> a >> b >> c;
	cin >> k;
	m=0;
	while(b<=a)
	{
		b*=2;
		m++;
	}
	// deb(m,a,b)
	while(c<=b)
	{
		c*=2;
		m++;
	}
	// deb(m,b,c)
	if(m<=k)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3636
def main (): 
    while True:
        m, f, r = map(int, input().split())
        if m == -1 and f == -1 and r == -1: break
        print (findGrade(m, f, r), end = '\n', flush = True)
    
    
    
    
def findGrade(m ,f, r):
    total = m + f
    if m == -1 or f == -1:
        return 'F'
    elif total >= 80:
        return 'A'
    elif total >= 65:
        return 'B'    
    elif total >= 50:
        return 'C'
    elif total >= 30:
        if r >= 50:
            return 'C'
        else: return 'D'
    else: return 'F'

if __name__ == '__main__': main()


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

bool check(int n){
	for(int i = 2; i < n; ++i){
		if(n % i == 0) return false;
	}
	return true;
}
int main(){
	int x; cin >> x;
	for (int i = x; i < 100005; ++i)
	{
		if(check(i)){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N, x;
    cin >> N >> x;
    ll a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a, a + N);
    int ans = 0;
    bool ok = false;
    for (int i = 0; i < N; i++) {
        if (x < a[i]) {
            ok = true;
            break;
        }
        x -= a[i];
        ans++;
    }
    if (!ok) {
        if (x != 0) {
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	long long int num[200000];
	for (int i = 0; i < N; i++)cin >> num[i];
	for (int i = 1; i < N; i++)num[i] += num[i - 1];
	ans = 100000000000000000;
	for (int i = 1; i < N; i++) {
		ans = min(ans, abs(num[N - 1] - 2 * num[i - 1]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
 
int stricmp(char* ch1,char* ch2){
    int ch1_length = 0,ch2_length = 0,div;
    for(int i = 0; ch1[i] != '\0';i++) ch1_length++;
    for(int i = 0; ch2[i] != '\0';i++) ch2_length++;
    if(ch1_length != ch2_length) return -1;
    for(int i = 0; ch1[i] != '\0';i++)
    {
        div = ch1[i] -ch2[i];
        if(div != 0 && div != 32 && div != -32)
            return -1;
    }
    return 0;
}
 
int main(){
    char W[11],T[1001];
    int count = 0;
    scanf("%s",W);
    while(true){
        scanf("%s",T);
        if(strcmp("END_OF_TEXT",T) == 0) break;
        if(stricmp(T, W) == 0) count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2724
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if c/b+bool2int(c%b > 0) <= a/d+bool2int(a%d > 0) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func bool2int(value bool) int {
	var integer int
	if value == true {
		integer = 1
	}
	return integer
}


Measured memory_bytes: 1748
// URL: https://atcoder.jp/contests/abc131/tasks/abc131_e

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int n, k; io.getV(n, k);

  if (k > (n-1)*(n-2)/2) {
    io.put(-1);
    return;
  }

  io.put(n*(n-1)/2-k);

  foreach (i; 0..n-1)
    foreach (j; i+1..n-1)
      if (k > 0)
	--k;
      else
	io.put(i+1, j+1);

  foreach (i; 0..n-1)
    io.put(i+1, n);
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, T v)
  {
    v = new T(r, c);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


Measured memory_bytes: 256