akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


sys.setrecursionlimit(10**5)


def main():
    h = gete(int)

    def dfs(x):
        if x == 1:
            return 1
        else:
            return 1 + 2 * dfs(x // 2)

    print(dfs(h))


if __name__ == "__main__":
    main()

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

int main(){
	int x, y, s, a;
	while(cin >> x >> y >> s, x){
		a = 0;
		for(int i = 1;i < s;++i){
			for(int j = 1;j < s;++j){
				int px, py;
				px = (int)(i * (100 + x) / 100.) + (int)(j * (100 + x) / 100.);
				if(px == s){
					py = (int)(i * (100 + y) / 100.) + (int)(j * (100 + y) / 100.);
					a = a < py ? py : a;
				}
			}
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import math
N = int(input())

ans = 0
for i in range(math.floor(N-N*0.08),math.ceil(N+N*0.08)):
    num = int(i) * 1.08
    if math.floor(num) == N:
        ans = num
        ans_i = i
        break
if ans == 0:
    print(":(")
else:
    print(ans_i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    unsigned long int A;
    double B;
    cin >> A >> B;
 
    int C = 100 * B + 0.5;
    if(A == 0 || C == 0){
        cout << 0 << endl;
    }
    else{
    cout <<  A * C / 100 << endl;
    }
    return 0;
}

Measured memory_bytes: 3720
a,b,c,d,n,*A=`dd`.split.map &:to_i;e=f=1;a>c&&(a,c,e=c,a,-1);b>d&&(b,d,f=d,b,-1);V=A.each_slice(2).select{|x,y|a<=x&&x<=c&&b<=y&&y<=d}.map{|x,y|[x*e,y*f]}.sort;D=[F=1e9]*s=V.size;V.map{|x,y|D[D.bsearch_index{|e|e>=y}]=y};N=D.bsearch_index{|e|e>=F}||s;p 1e2*(c-a+d-b)-20*N+5*(N+(N>[c-a,d-b].min ? 1:0))*Math::PI

Measured memory_bytes: 40980
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt()+1;
        long[] nums=new long[n];
        nums[0]=0;
        long output=0;
        for(int i=1;i<n;i++){
            nums[i]=sc.nextInt();
        }
        for(int i=1;i<n;i++){
            nums[i]+=nums[i-1];
        }
        Arrays.sort(nums);
        long tmp=Integer.MIN_VALUE;
        int outtmp=0;
        for(int i=0;i<n;i++){
            if(tmp==nums[i]){
               outtmp++; 
               if(i==n-1){
                   i--;
                   tmp=Integer.MIN_VALUE;
               }
            }else{
                if(outtmp>1){
                    output+=nc2(outtmp);
                }
                tmp=nums[i];
                outtmp=1;
            }
            
        }
        System.out.println(output);
        
    }
    static long nc2(long input){
        long output=1;
        output=input*(input-1)/2;
        return output;
    }
        

    

}

Measured memory_bytes: 90640
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200500;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll sum,n;
     cin >> sum >> n;
     for(ll i=0;i<n;i++)
     {
          ll x;
          cin >> x;
          sum -= x;
     }
     if(sum<0)   sum = -1;
     cout<<sum;
}

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

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

vector<bool> IsPrime;

void sieve(ll max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(ll i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(ll j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

int main(){
    int Q;
    cin >> Q;
    sieve(100100);
    vector<int> Csum(100100);
    vector<bool> Is2017(100100,false);
    for(int i=1;i<=100000;i++){
        if(i%2==1&&IsPrime[i]&&IsPrime[(i+1)/2]){
            Is2017[i]=true;
        }
    }
    for(int i=1;i<=100000;i++){
        if(Is2017[i]){
            Csum[i] = Csum[i-1]+1;
        }else{
            Csum[i] = Csum[i-1];
        }
    }
    rep(i,Q){
        int l,r;
        cin >> l >> r;
        
        cout << Csum[r] - Csum[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;


class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String x = br.readLine();
		int count = 0;
		for (; !((str = br.readLine()).equals("END_OF_TEXT"));) {
			String[] stg = str.split(" ");
			for (String i : stg) {
				if (i.equalsIgnoreCase(x))
					count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 16976
A=3.times.map { gets.chomp.split.map(&:to_i) }
N=gets.chomp.to_i
B=N.times.map { gets.chomp.to_i }

c=Array.new(3){Array.new(3,0)}

B.each do |i|
  3.times do |x|
    3.times do |y|
      if A[y][x]==i then
        c[y][x]=1
      end
    end
  end
end

3.times do |e|
  if c[0][e]==1 && c[1][e]==1 && c[2][e]==1 then
    puts 'Yes'
    exit
  end
end

3.times do |f|
  if c[f][0]==1 && c[f][1]==1 && c[f][2]==1 then
    puts 'Yes'
    exit
  end
end
if c[0][0]==1 && c[1][1]==1 && c[2][2]==1 then
  puts 'Yes'
  exit
end


if c[0][2]==1 && c[1][1]==1 && c[2][0]==1 then
  puts 'Yes'
  exit
end
puts 'No'

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;

inline ll read(){
	ll x=0,w=1;char c=getchar();
	while(c<'0'||c>'9')w=c=='-'?-1:1,c=getchar();
	while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*w;
}

ll m,n;

int main(){
	n=read(),m=read();
	if(n==1&&m==1){
		printf("1");
		return 0;
	}
	if(n==1){
		printf("%lld",m-2);
		return 0;
	}
	if(m==1){
		printf("%lld",n-2);
		return 0;
	}
	printf("%lld",(n-2)*(m-2));
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
map<string,int> mp;
int mx=0;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		mp[s]++;
		mx=max(mp[s],mx);
	}
	for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++){
		if((*it).second==mx){
			cout << (*it).first << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 25216
#define ll long long int
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = k; i < n; i++) {
		if (a[i] > a[i - k]) { cout << "Yes" << endl; }
		else { cout << "No" << endl; }
	}
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  int w[10], k[10], i;
  
  REP(i, 10) cin >> w[i];
  REP(i, 10) cin >> k[i];
  sort(w, w + 10);
  sort(k, k + 10);
  cout << w[7] + w[8] + w[9] << " " << k[7] + k[8] + k[9] << endl;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,l;
	cin >> n;
	int ans = INF;
	for(int i = 0; i < n; i++) {
		int c = 0;
		cin >> l;
		while(l % 2 == 0){
			l /= 2;
			c++;
		}
		ans = min(ans,c);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int a,b,c,d,k;
  cin>>a>>b>>c>>d>>k;
  int leng=60*c+d-60*a-b;
  cout<<leng-k;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;
int a[5]= {11,31,41,61,71};
int i,j,N,m,p,q;

int main()
{
    scanf("%d",&N);
    if(N==5)
    {
        for(i=0; i<5; i++)
            printf("%d ",a[i]);
    }
    else if(N>5)
    {
        for(i=0; i<5; i++)
            printf("%d ",a[i]);
        m=N-5;
        p=91;
       while(m--)
        {
            for(j=p; j<55555; j=j+10)
            {
                q=sqrt(j);
                for(i=2; i<=q; i++)
                {
                    if(j%i==0)break;
                }
                if(i==q+1)break;
            }
            printf("%d ",j);
            p=j+10;
        }

    }

}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int, int> > ba(M);
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        ba[i] = make_pair(b, a);
    }

    sort(ba.begin(), ba.end());
    int cur = 1e9;
    int res = 0;
    for(int i=0; i<M; i++){
        if(cur < ba[i].second || ba[i].first <= cur){
            cur = ba[i].first - 1;
            res++;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll A, B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		 for(int a=1;a<=9;a++){
	            for(int b=1;b<=9;b++){
	                System.out.println(a+"x"+b+"="+a*b);
	            }
	        }
	    }
	}

Measured memory_bytes: 23864
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    string ab, ba;
    ab = string(b-'0', a);
    ba = string(a-'0', b);

    cout << min(ab, ba) << endl;
}

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

using namespace std;
 
 


//c++ templte for help............................................................................................................................................

typedef long long ll;

template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) {cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; }
#define vdeb(...) {cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;}

// to return everything in string
#define ret(...) {stringstream returnn;returnn<<__VA_ARGS__;return returnn.str();}

stringstream retvec;
template<typename... T>
void returnvector(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			for(ll j=0;j<(ll)ans[i].size();j++){
				retvec<<ans[i][j];
				if(j!=(ll)ans[i].size()-1)
					retvec<<" ";
			}
			if(i!=(ll)ans.size()-1)
				retvec<<endl;
		}
}
#define vret(...) {returnvector(__VA_ARGS__);return retvec.str();}
	


//for loop
#define fo(i,n) for(int i=0;i<(ll)n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
template<typename T>
void printV(T vec){
	fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	cout<<endl;
	}
	
 
#define M ll(1000000007)
const ll INF=ll(1e9+5);
 
//iterate map
template<typename T>
void itR(T map){
	 for(auto itr=map.begin();itr!=map.end();itr++){
				deb(itr->first,itr->second);
			}
	cout<<endl;
}

//c++ template for help...........................................................................................................................................

string solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ret(max(a*c,max(a*d,max(b*c,b*d))));
}

int main() {
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		string ans1=solve();
		if(ans1!="")
			cout<<ans1<<endl;
	//}
	return 0;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;
    n %= 10;

    if (n == 3) cout << "bon" << newl;
    else if (n < 2 || n == 6 || n == 8) cout << "pon\n";
    else cout << "hon\n";

    return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int MaxN = 50;
LL a[MaxN + 5];
LL cnt[MaxN + 5];
int n;
 
int main(){
	while(~scanf("%d", &n)){
		for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
		LL tot = 0, ans = 0;
		bool ok = true;
		while(ok){
			ok = false;
			tot = 0;
			for(int i = 1; i <= n; i++){
				cnt[i] = a[i] / n;
				a[i] = a[i] % n;
				tot += cnt[i];
			}
			ans += tot;
			for(int i= 1; i <= n; i++){
				a[i] += tot - cnt[i];
				if(a[i] >= n) ok = true;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf 
#define itn int
using namespace std;
const int N=2e5+5;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
char s[N];
int main(){
        cin>>(s+1);
        auto ksm=[](ll a,ll b){
                ll ans=1;
                for(;b;b>>=1,a=a*a%mod)if(b&1)ans=ans*a%mod;
                return ans;
        };
        int n=strlen(s+1);
        ll ans=0;
        int cnt=0;
        for(int i=1;i<=n;i++){
                if(s[i]=='1'){
                        ans=(ans+ksm(2,cnt)*ksm(3,n-i)%mod)%mod;
                        cnt++;
                }
        }
        o((ans+ksm(2,cnt))%mod);
}

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

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    for(int i = a; i <= min(b, a+k-1); i++){
        cout << i << endl;
    }
    for(int i = max(b-k+1, a+k);  i<= b; i++){
        cout << i << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> D(N);
  REP(i, 0, N) cin >> D[i];

  vector<bool> ok(N * N + 1, true);
  REP(i, 0, N) {
    ll x = 0;
    REP(j, i, N) {
      x = x * 10 + D[j];
      if(x > N * N) break;
      ok[x] = false;
    }
  }

  REP(i, 0, N * N + 1) {
    if(ok[i]) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 3244
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	int sum=0;
	for(int i=0;i<n;i++)
	{
		int s=0;
		for(int j=i+1;j<n;j++)
		{
			s=s+a[j];
		}
		sum=sum+a[i]*s;
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      putStrLn $ solve n
      main

solve :: Int -> String
solve n = format (findTwin n primeT)
  where
    format :: (Int,Int) -> String
    format (a,b) = (show a) ++ " " ++ (show b)

    findTwin :: Int -> [(Int,Int)] -> (Int,Int)
    findTwin n ((a,b):rt)
      | b <= n = (a,b)
      | otherwise = findTwin n rt
prime :: Int -> [Int]
prime n = loop [2..n]
  where
    loop :: [Int] -> [Int]
    loop [] = []
    loop (x:xs) = x:(loop (filter (\y -> y `mod` x /= 0) xs))
primeL = prime 10000
primeT = reverse (makeT primeL)
  where
    makeT :: [Int] -> [(Int,Int)]
    makeT [x] = []
    makeT (x:y:r)
      | y - x == 2 = (x,y):(makeT (y:r))
      | otherwise = makeT (y:r)

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

using namespace std;

#define N 1200000

int n,m,l[N],r[N],ans;
char a[N],b[N];

int main(){
	scanf("%d%s%s",&n,a+1,b+1);
	bool fl=1;
	for (int i=1;i<=n;++i) fl&=a[i]==b[i];
	if (fl){puts("0"); return 0;}
	for (int i=n,j=n;i;--i){
		for (;j>i;--j);
		for (;j&&a[j]!=b[i];--j);
		if (!j){puts("-1"); return 0;}
		if (l[m]!=j){l[++m]=j; r[m]=i;}
	}
	l[0]=n*2;
	for (int i=1,k=0;i<=m;++i){
		for (;k<=i&&l[k]-(i-k)>=r[i];++k);
		ans=max(ans,i-k+1);
	}
	printf("%d\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long a[N], sums[N+1];
  vector<vector<long long>> dp(N,vector<long long>(N,LLONG_MAX));
  sums[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sums[i+1] = sums[i]+a[i];
    dp[i][i] = 0;
  }
  for (int i = N-1; i+1; i--) {
    for (int j = i+1; j < N; j++) {
      for (int k = i; k < j; k++) {
        dp[i][j] = min(dp[i][k]+dp[k+1][j]+sums[j+1]-sums[i],dp[i][j]);
      }
    }
  }
  cout << dp[0][N-1];
}

Measured memory_bytes: 4876
import scala.math.floor
import scala.io.StdIn

object Main extends App {
  var input = StdIn.readInt()

  var firstInt = 0
  if(input % 1000 == 0) {
    firstInt = floor(input / 1000).toInt
  } else {
    firstInt = floor(input / 1000).toInt + 1
  }
  
  val money = firstInt * 1000
  println(money - input);
}

Measured memory_bytes: 54636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int dp[100010];

int main(){
  int n,k;
  cin>>n>>k;
  ll a[n+1]={};
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  for(int i=0;i<a[0];i++) dp[i]=-1;

  for(int i=0;i<k;i++){
    for(int j=0;j<n;j++){
      if(i+a[j]<=k){
        if(dp[i+a[j]]!=1){
          dp[i+a[j]]=-dp[i];
        }
      }
    }
  }

  if(dp[k]==1) cout<<"First"<<endl;
  else cout<<"Second"<<endl;

  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

const int L = 100005;

int a[L], ans1 = 0, ans2 = 0, tot = 0;

int main()
{
	char c = getchar();
	while (c < '0' || c > '1') c = getchar();
	while (c == '0' || c == '1')
		a[tot++] = c - '0', c = getchar();
	int inc1 = 0, inc2 = 1;
	for (int s = 0; s < tot; s++)
	{
		ans1 += a[s] ^ inc1;
		ans2 += a[s] ^ inc2;
		inc1 ^= 1, inc2 ^= 1;
	}
	printf("%d", min(ans1, ans2));
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> prime;
    for (int i = 2; i <= n; i++) {
        bool ok = true;
        for (int j = 2; j < i; j++) {
            if (i % j == 0) ok = false;
        }
        if (ok) prime.push_back(i);
    }
    map<ll, ll> mp;
    for (auto i : prime) {
        ll cnt = 0;
        for (int j = 2; j <= n; j++) {
            ll tmp = j;
            while(tmp > 0) {
                if (tmp % i == 0) {
                    cnt++;
                    tmp /= i;
                }
                else break;
            }    
        }
        mp[i] = cnt;
    }
    vector<int> pn(5);
    for (auto i : prime) {
        if (mp[i] >= 74) pn[4]++, pn[3]++, pn[2]++, pn[1]++, pn[0]++;
        else if (mp[i] >= 24) pn[3]++, pn[2]++, pn[1]++, pn[0]++;
        else if (mp[i] >= 14) pn[2]++, pn[1]++, pn[0]++;
        else if (mp[i] >= 4) pn[1]++, pn[0]++;
        else if (mp[i] >= 2) pn[0]++;
    }
    int ans = pn[4] + max(0, pn[3] * (pn[0] - 1)) + max(0, pn[2] * (pn[1] - 1)) + max(0, (pn[1] * (pn[1] - 1)) / 2 * (pn[0] - 2));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> prime;
void fill_prime(int n){
    vector<int> is_prime(n+1,1);
    for(ll i=2;i*i<=n;i++){
        if(is_prime[i]){
            for(ll j=i*i;j<=n;j+=i){
                is_prime[j]=0;
            }
        }
    }
    for(int i=2;i<=n;i++){
        if(is_prime[i]) prime.push_back(i);
    }
}
int main() {
	int n;
	cin>>n;
	unordered_map<ll,ll> mp;
	ll maxv=0;
	for(int i=0;i<n;i++){
	    ll x;
	    cin>>x;
	    mp[x]++;
	    maxv=max(maxv,x);
	}
	fill_prime(1000001);
	int maxn=1e6;
	vector<int> cnt(prime.size());
	
	for(int i=0;i<prime.size();i++){
	    ll c=prime[i];
	    while(c<=maxv){
	        cnt[i]+=mp[c];
	        c+=prime[i];
	    }
	}
    
	int maxi=0;
	for(int i=0;i<prime.size();i++){
	    maxi=max(maxi,cnt[i]);
	}
	if(maxi<=1) cout<<"pairwise coprime";
	else if(maxi<n) cout<<"setwise coprime";
	else cout<<"not coprime";
	return 0;
}

Measured memory_bytes: 47984
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, Y;

int main() {
    cin >> n >> Y;
    for(int x = 0; x <= n; ++x) {
        for(int y = 0; x+y <= n; ++y) {
            int z = n - (x+y);
            int sum_cost = 10000*x + 5000*y + 1000*z;
            if(sum_cost == Y) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int maxN = (int)1e5 + 10;
int k, n;
int c[maxN];
int x[maxN];
int y[maxN];
int f[4 * 1005][4 * 1005];
int p[4 * 1005][4 * 1005];
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("log.in", "r", stdin);
    //freopen("log.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
        char c;
        cin >> c;
        if (c == 'B') {
            x[i] += k;
        }
        x[i] = (x[i] % (2 * k));
        y[i] = (y[i] % (2 * k));
        if (x[i] >= k) {
            x[i] -= k;
            y[i] += k;
            y[i] %= (2 * k);
        }
        x[i]++;
        y[i]++;
        f[x[i]][y[i]]++;
        f[x[i] + 2 * k][y[i]]++;
        f[x[i]][y[i] + 2 * k]++;
        f[x[i] + 2 * k][y[i] + 2 * k]++;
    }
    for (int i = 1; i <= 4 * k + 5; i++) {
        for (int j = 1; j <= 4 * k + 5; j++) {
            p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + f[i][j];
        }
    }
    //cout << f[0] << " " << f[1] << " " << f[2] << " " << f[3] << " " << f[4] << " " << f[5] << " " << f[6];
    int opt = 0;
    for (int i = k + 1; i <= 3 * k + 5; i++) {
        for (int j = k + 1; j <= 3 * k + 5; j++) {
            opt = max(opt, p[i + k - 1][j + k - 1] - p[i - 1][j + k - 1] - p[i + k - 1][j - 1] + p[i - 1][j - 1] + p[i - 1][j - 1] - p[i - k - 1][j - 1] - p[i - 1][j - k - 1] + p[i - k - 1][j - k - 1]);
        }
    }
    cout << opt;
    return 0;
}


Measured memory_bytes: 98560
n=int(input())
if n%2==1:
    m=(n*n-2*n+1)/2
else:
    m=(n*n-2*n)/2
m=int(m)
print(m)
if n%2==0:
    for i in range(n):
        for j in range(n):
            ii=i+1
            jj=j+1
            if jj>ii and jj!=(n+1-ii):
                print(ii, jj)
else:
    for i in range(n):
        for j in range(n):
            ii=i+1
            jj=j+1
            if jj>ii and jj!=(n-ii):
                print(ii, jj)

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

using namespace std;

int n, cnt=1;
string s;

int main () {
	cin >> n;
	cin >> s;
	for(int i = 1; i < s.size(); i++) {
		if(s[i] != s[i-1]) {
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

#define N 2000

int solve(int, int, int *, int);

int main(){
  int A[N], n, q, x, i, B[N];

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

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

  for(i = 0; i < q; i++){
    x = solve(0, B[i], A, n);
    if(x == 1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i, int m, int *A, int n){
  int res;

  if(m == 0){
    return 1;
  }

  if(i >= n){
    return 0;
  }

  res = solve(i + 1, m, A, n) || solve(i + 1, m - A[i], A, n);

  return res;
}

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

int main() {
  int X; cin>>X;
  vector<bool> dp(X+1000, false);
  dp[0]=true;
  rep(i, X+1) {
    if (dp[i]) {
      rep(j, 6) dp[i+j+100]=true;
    }
  }
  if (dp[X]) cout<<1<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    return A * B


def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76788
N = int(input())
enemy = list(map(int ,input().split()))
brave = list(map(int, input().split()))
enemy = enemy[::-1]
brave = brave[::-1]
sum = 0
for i in range(N):
    star = min(enemy[i] , brave[i])
    brave[i] = brave[i] - enemy[i]
    if brave[i] > 0:
        add_star = min(enemy[i + 1], brave[i])
        enemy[i+1] = enemy[i + 1] - add_star
        star += add_star
    sum+= star
print(sum)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if(c>=a && c<=b || c>=b && c<=a)
    {
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  def count(rl: String): Array[Int] = {
    val Array(r, l) = rl.split("(?=L)", 2).map(_.size)
    val ret = new Array[Int](rl.size)
    ret(r - 1) = (r + 1) / 2 + l / 2
    ret(r) = r / 2 + (l + 1) / 2
    ret
  }

  println(readLine.split("(?=R)(?<=L)").flatMap(count).mkString(" "))
}

Measured memory_bytes: 60252
#include <iostream>
#include <algorithm>
using namespace std;
int h,w;
int G[2100][2100];
int V[2100][2100];
int E[2100][2100];
int yokoE[2100][2100];
int tateE[2100][2100];
int main(){
  int q;
  cin >> h >> w >> q;
  for(int i=0;i<h;++i){
    string s;cin>>s;
    for(int j=0;j<w;++j){
      G[i+1][j+1]=s[j]-'0';
    }
  }

  for(int i=1;i<=h;++i){
    for(int j=1;j<=w;++j){
      yokoE[i][j]=yokoE[i][j-1]+G[i][j]*G[i][j-1];
      tateE[i][j]=tateE[i-1][j]+G[i][j]*G[i-1][j];
      V[i][j]=V[i-1][j]+V[i][j-1]-V[i-1][j-1]+G[i][j];
      E[i][j]=E[i-1][j]+E[i][j-1]-E[i-1][j-1];
      if(G[i][j])
	E[i][j]+=G[i-1][j]+G[i][j-1];
    }
  }
  while(q--){
    int x1,y1,x2,y2;
    cin >> y1>>x1>>y2>>x2;
    //    cout << V[y2][x2]-V[y2][x1-1]-V[y1-1][x2]+V[y1-1][x1-1] << endl;
    //    cout << E[y2][x2]-E[y2][x1]-E[y1][x2]+E[y1][x1]+tateE[y2][x1]+yokoE[y1][x2]-tateE[y1][x1]-yokoE[y1][x1]<<endl;
    cout << V[y2][x2]-V[y2][x1-1]-V[y1-1][x2]+V[y1-1][x1-1] - (E[y2][x2]-E[y2][x1]-E[y1][x2]+E[y1][x1]+tateE[y2][x1]+yokoE[y1][x2]-tateE[y1][x1]-yokoE[y1][x1])<<endl;

  }
  return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

struct Key {
    int price, code;
    Key(int price = INT_MAX, int code = 0) : price(price), code(code) {}
    Key operator+(const Key& key) { return Key(price + key.price, code | key.code); }
};

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

    int n, m;
    cin >> n >> m;

    vector<Key> keys(m);
    rep(i, 0, m) {
        int b;
        cin >> keys[i].price >> b;
        rep(j, 0, b) {
            int c;
            cin >> c;
            keys[i].code |= (1 << (c - 1));
        }
    }

    // O(m * n)
    vector<Key> min_keys(n);
    rep(i, 0, n) {
        rep(j, 0, m) {
            if ((keys[j].code & (1 << i)) && min_keys[i].price > keys[j].price) {
                min_keys[i] = keys[j];
            }
        }
    }

    // 開けない宝箱がある場合．
    rep(i, 0, n) {
        if (min_keys[i].price == INT_MAX) {
            cout << -1 << endl;
            return 0;
        }
    }

    // O(2^n * m)
    vector<Key> dp(1 << n);
    dp[0].price = 0;

    rep(bit, 1, 1 << n) {
        // 何個の宝箱を開くか．
        int n_open = __builtin_popcount(bit);

        // 1個のみ開く場合，最小コストの鍵を使う．
        if (n_open == 1) {
            dp[bit] = min_keys[(int)log2(bit)];
            continue;
        }

        rep(i, 0, m) {
            // 1回前の状態．
            int prev_bit = bit & (~keys[i].code);

            // この鍵が関係ないときはスキップする．
            if (bit == prev_bit) { continue; }

            if (dp[bit].price == INT_MAX || dp[bit].price > dp[prev_bit].price + keys[i].price) {
                dp[bit] = dp[prev_bit] + keys[i];
            }
        }
    }

    cout << dp.back().price << endl;
    return 0;
}

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


using namespace std;


using ll = long long;


mt19937 mt(736);

const int mod = 998244353;


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	string s;

	cin >> s;

	string rgb = "RGB";

	vector<int> prf(3);

	ll ans = 1;

	for (auto it : s)
	{
		prf[rgb.find(it)]++;

		if (*min_element(prf.begin(), prf.end()) > 0)
		{
			int mid = *max_element(prf.begin(), prf.end()) ^*min_element(prf.begin(), prf.end());

			for (auto item : prf)
				mid ^= item;

			ans *= mid;
			ans %= mod;

			for (auto &m : prf)
				m--;
		}
		else
		{
			bool mx = true;

			prf[rgb.find(it)]--;

			for (auto item : prf)
				mx &= item <= prf[rgb.find(it)];

			if (!mx)
			{
				int mid = *max_element(prf.begin(), prf.end()) ^*min_element(prf.begin(), prf.end());

				for (auto item : prf)
					mid ^= item;

				ans *= *max_element(prf.begin(), prf.end()) - mid;
				ans %= mod;
			}

			prf[rgb.find(it)]++;
		}
	}

	cerr << ans << endl;

	for (int i = 1; i <= n; i++)
	{
		ans *= i;
		ans %= mod;
	}

	cout << ans << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");

	solve(fin);

	cout << "clock: " << setprecision(4) << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>
#include <iomanip> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;

	auto start = high_resolution_clock::now(); 

	ll int N, W;
	cin >> N >> W;
	vector<int> w(N), v(N);
	int max_v = 0;
	for(int i = 0; i < N; i++){
		cin >> w[i] >> v[i];
		max_v += v[i];
	}
	
	vector<vector<ll int>> dp(N+1, vector<ll int>(max_v+1, 1e15));
	dp[0][0] = 0;
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= max_v; j++){
			dp[i][j] = dp[i-1][j];
		}
		for(int j = 0; j <= max_v; j++){
			if (j + v[i-1] <= max_v)
				dp[i][j+v[i-1]] = min(dp[i][j+v[i-1]], dp[i-1][j] + w[i-1]);
		}
	}

	int ans = -1;
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= max_v; j++){
			if (dp[i][j] <= W)
				ans = max(ans, j);
		}
	}

	cout << ans << endl;

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << fixed << setprecision(9) << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 80256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
suma=[a[0]]
sumb=[b[0]]
for i in range(1,n):
    suma.append(suma[-1]+a[i])
for i in range(1,m):
    sumb.append(sumb[-1]+b[i])
tot=0
ans=0
ma=0
j=m-1
for i in range(n):
    if(suma[i]>k):
        break
    else:
        tot=i+1
        sub=k-suma[i]
        while(j>=0):
            if(sumb[j]<=sub):
                break
            else:
                j=j-1
        ans=max(tot+j+1,ans)
j=n-1
for i in range(m):
    if(sumb[i]>k):
        break
    else:
        tot=i+1
        sub=k-sumb[i]
        while(j>=0):
            if(suma[j]<=sub):
                break
            else:
                j=j-1
        ans=max(tot+j+1,ans)

print(ans)   

        
    



Measured memory_bytes: 47340
#from https://betrue12.hateblo.jp/entry/2018/10/06/224032

N = gets.to_i
xs, ys, hs = [], [], []
N.times do |i|
    xs[i], ys[i], hs[i] = gets.split.map(&:to_i)
end
 
(0..100).each do |x|
    (0..100).each do |y|
        h = nil
        hmax = 10**10
        success = true
        N.times do |i|
            dist = (xs[i]-x).abs + (ys[i]-y).abs
            if hs[i] == 0
                hmax = dist if hmax > dist
            else
                hc = hs[i] + dist
                if h && h != hc
                    success = false
                    break
                else
                    h = hc
                end
            end
        end
        if success && h <= hmax
            puts [x, y, h].join(' ')
            exit
        end
    end
end

Measured memory_bytes: 1788
#include<stdio.h>
#define SIZE 1210

int main(){
    char x[SIZE];
    int str[26]={0},i=0,num=0;

    while(scanf("%s", x)!=EOF){
        for(i = 0;x[i]!=NULL;i++){
            if(x[i] >='a' && 'z'>=x[i]){
                num=x[i]-'a';
                str[num]++;
            }else if(x[i] >='A' && 'Z'>=x[i]){
                num=x[i]-'A';
                str[num]++;
            }
        }
    }

    for(i =0;i <26;i++){
        printf("%c : %d\n",i+'a',str[i]);
    }
    return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define pb push_back
using ll = long long;

int main() {
	int n; cin >> n;
	vector<ll> a(n); rep(i, 0, n) cin >> a[i];

	vector<ll> b(n);
	ll r = 0, c = 0;
	rep(i, 0, n) {
		if (i % 2 == 0) r += a[i];
		else r -= a[i];
	}
	r /= 2;
	rep(i, 0, n) {
		if (i == 0) {
			b[i] = r * 2;
			continue;
		}
		c = a[i - 1] - b[i - 1] / 2;
		b[i] = c * 2;
	}

	rep(i, 0, n) {
		if (i > 0) cout << " ";
		cout << b[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int MAX_INPUT = 10;

int main ( int argc, char **argv )
{
    char buffer[100];
    int x = 0;
    int hill_array[MAX_INPUT];

    /*clear the memory*/
    int z = 0;
    for ( z = 0; z < MAX_INPUT; z++ )
    {
        hill_array[z] = 0;
    }
    
    for ( x = 0; x < MAX_INPUT; x++ )
    {
        int hill = 0;
        fgets(buffer, 100, stdin);
        sscanf(buffer, "%d", &hill);

        int y;
        int piv = 0;
        for ( y = 0; y < MAX_INPUT; y++ )
        {
            if ( hill_array[y] == 0)
            {
                hill_array[y] = hill;
                break;
            }
            else if ( hill_array[y] < hill )
            {
                piv = hill_array[y];
                hill_array[y] = hill;
                hill = piv;
            }
        }

    }

    printf("%d\n%d\n%d\n", hill_array[0], hill_array[1], hill_array[2]);

    return 0;
}

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

int main(){
    ll h,w,n,c[13]={0};    
    set<pair<ll,ll>> f1;
    set<pair<ll,ll>> f2;
    cin>>h>>w>>n;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        a--; b--;   
        f1.insert({a,b});
        for(int j=0;j<3;j++)
            for(int l=0;l<3;l++){
                if((a-j<0||a-j>=h-2)||(b-l<0||b-l>=w-2)) continue;
                f2.insert({a-j,b-l});
            }
    }
    c[0]=(h-2)*(w-2)-f2.size();
    for(auto i:f2){
        ll y=i.first,x=i.second;
        int num=0;
        for(int j=0;j<3;j++)
            for(int l=0;l<3;l++){
                if(f1.count({y+j,x+l})) num++; 
            }
        c[num]++;
    }
    for(int i=0;i<10;i++) cout<<c[i]<<endl;
    return 0;
}

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

using namespace std;

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

  string s;
  cin >> s;
  if (s.size() & 1) {
    cout << "No";
    return 0;
  }
  for (int i = 0; i < s.size(); i += 2) {
    if (s[i] != 'h' or s[i + 1] != 'i') {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";

  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/**
*   author: j o s e m a g o
*   user: m a m i s a k i
**/
using namespace std;

/***PLANTILLA***/

using namespace __gnu_pbds; //*st.find_by_order(1);  st.order_of_key(p);
#pragma GCC optimize ("Ofast")
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef double dbl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;

string tostring(auto a){
    stringstream ss;ss<<a;string s = ss.str();
    return s;
}

/**Mi Debug**/
#define var(x) cout<<#x<<" = ";
#define db(x) cout<<#x<<" = "<<x<<"\n";
void dbvector(vector<auto>&v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}
void dbmapa(map<auto,auto>mp){
   for(auto x : mp) cout<<"{"<<x.first<<":"<<x.second<<"} ";cout<<"\n";
}
void dbstring(string v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}

/***********Code***************/

const int JJJ = 100100;










int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

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



    string s;
    cin >> s;
    int m = s.size();
    m--;
    if(s[m] == '3'){
        cout<<"bon";
        return 0;
    }
    if(s[m] == '2' || s[m] == '4' || s[m] == '5' || s[m] == '7' || s[m] == '9'){
        cout<<"hon";
    }
    else{
        cout<<"pon";
    }







    return 0;
}


Measured memory_bytes: 3648
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    double res = ((n + 1) / 2) /(1.0 * n);

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		String[] dow={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
		int[] len={2,31,29,31,30,31,30,31,31,30,31,30,31};
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		String t;
		int m,d;
		for(int i=0;i<12;i++)len[i+1]+=len[i];
		while((t=bf.readLine())!=null){
			m=Integer.parseInt(t.split(" ")[0]);
			d=Integer.parseInt(t.split(" ")[1]);
			if(m==0)break;
			System.out.println(dow[(len[m-1]+d)%7]);
		}
	}
}

Measured memory_bytes: 9372
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Cloudy") cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
// AOJ Volume 1 Problem 0170 Lunch

#include <stdio.h>
#include <string.h>

typedef struct {
    char name[21];
    int weight;
    int strength;
    int use;
} FOOD;

int min_g;
int best_order[11];

void stack(FOOD *food, int n, int level, int total_weight, int *order)
{
    int i;
    int g;
    
    if (level >= n){
        g = 0;
        for (i = n - 1; i >= 0; i--){
            g += food[order[i]].weight * (n - i);
        }
        if ((min_g == -1) || (min_g > g)){
            min_g = g;
            memcpy(best_order, order, sizeof(best_order));
        }
        return;
    }
    
    for (i = 0; i < n; i++){
        if (food[i].use == 0){
            if (food[i].strength >= total_weight){
                food[i].use = 1;
                order[level] = i;
                stack(food, n, level + 1, total_weight + food[i].weight, order);
                food[i].use = 0;
            }
        }
    }
    
    return;
}

int main(void)
{
    FOOD food[10];
    int n;
    int order[11];
    int i;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%s%d%d", food[i].name, &food[i].weight, &food[i].strength);
            food[i].use = 0;
        }
        
        min_g = -1;
        stack(food, n, 0, 0, order);
        for (i = n - 1; i >= 0; i--){
            printf("%s\n", food[best_order[i]].name);
        }
    }
    return (0);
}

Measured memory_bytes: 380
# include <iostream>
# include <cstdio>
# include <cmath>
using namespace std;
bool is_prime(int x)
{
	if(x == 1) return false;
	for(int i = 2;i <= int(sqrt(x));i++) if(x%i == 0) return false;
	return true;
}
int main(void)
{
	int n,ans = 0,k;
	scanf("%d",&n);
	for(int i = 0;i < n;i++)
	{
		scanf("%d",&k);
		if(is_prime(k)) ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3204
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;

public class Main{
  static int n, m;
  static int[] a;

  static final boolean DEBUG = false;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

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

    Map< Integer, Set< Integer > > map = new HashMap< >();
    for(int i = 0; i  + 1 < n; i++){
      if(map.containsKey(a[i + 1])){
        map.get(a[i + 1]).add(i);
      }
      else{
        Set< Integer > set = new HashSet< >();
        set.add(i);
        map.put(a[i + 1], set);
      }
    }

    int[] count = new int[m + 1];
    for(int i = 0; i + 1 < n; i++){
      if(a[i] < a[i + 1]){
        count[a[i] + 1]++;
        count[a[i + 1]]--;
      }
      else{
        if(a[i + 1] >= 2){
          count[1]++;
          count[a[i + 1]]--;
        }
        if(a[i] + 1 <= m){
          count[a[i] + 1]++;
          count[m]--;
        }
      }
    }

    int t = 0;
    for(int i = 1; i <= m; i++){
      count[i] += count[i - 1];
      if(DEBUG){
        System.out.println("count[" + i + "] = " + count[i]);
      }
    }

    long sum = 0;
    for(int i = 0; i + 1 < n; i++){
      sum += (long)(a[i + 1] + m - a[i]) % m;
    }

    if(DEBUG){
      System.out.println("sum = " + sum);
    }

    long s = 0;
    for(int i = 0; i + 1 < n; i++){
      if(a[i] > a[i + 1] && 1 <= a[i + 1]){
        s += (long)(1 + (a[i + 1] + m - 1) % m);
      }
      else{
        s += (long)((a[i + 1] + m - a[i]) % m);
      }
    }

    if(DEBUG){
      System.out.println("s1 = " + s);
    }

    sum = Math.min(sum, s);
    for(int x = 2; x <= m; x++){
      if(map.containsKey(x - 1)){
        for(int i : map.get(x - 1)){
          s += (long)((a[i + 1] + m - a[i]) % m - 1);
        }
      }
      s -= (long)count[x - 1];
      if(DEBUG){
        System.out.println("s = " + s);
      }
      sum = Math.min(sum, s);
    }

    if(sum < 0){
      throw new Error();
    }

    System.out.println(sum);
  }
}


Measured memory_bytes: 77524