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

using namespace std;

#define ll long long




void solve() {

	int n, k, q;
	cin >> n >> k >> q;
	ll arr[n];
	ll mx = 0;
	fill(arr, arr + n, k - q);
	while(q--) {
		int x;
		cin >> x;
		x--;
		arr[x]++;
	}
	for(int i = 0; i < n; i++) {
		if(arr[i] > 0) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}

	}
	
	




	
}

int main() {

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

	return 0;
}	

Measured memory_bytes: 4448
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] ary = {"", "SUN","MON","TUE","WED","THU","FRI","SAT"};
        for (int i = 0; i < ary.length; i++) {
            if (s.equals(ary[i])) {
                System.out.println(Math.abs(7 - i) + 1);
                return;
            }
        }
    }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int a[100000], b[100000];
	int c[100001]={}, cs[100001];
	vector<P> v;
	for(int i=0; i<m; i++){
		scanf("%d %d", &a[i], &b[i]);
		v.push_back(P(a[i], b[i]));
		c[a[i]]++;
	}
	cs[0]=0;
	for(int i=1; i<=n; i++){
		cs[i]=cs[i-1]+c[i];
	}
	int as[100000], bs[100000];
	for(int i=0; i<m; i++){
		bs[cs[a[i]]-c[a[i]]]=b[i];
		as[cs[a[i]]-c[a[i]]]=a[i];
		c[a[i]]--;
	}
	int ans=1;
	int b0=bs[0];
	for(int i=0; i<m; i++){
		if(as[i]>=b0){
			ans++;
			b0=bs[i];
		}else{
			b0=min(b0, bs[i]);
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> card(N);
  for (int i=0; i<N; i++) cin >> card.at(i);
  
  for (int i=0; i<N-1; i++){
    for (int j=N-1; j>i; j--){
      int tmp;
      if (card.at(j-1)<card.at(j)){
        tmp=card.at(j-1);
        card.at(j-1)=card.at(j);
        card.at(j)=tmp;
      }
    }
  }
  
  int a=0,b=0;
  
  for (int i=0; i<N; i+=2) a+=card.at(i);
  for (int i=1; i<N; i+=2) b+=card.at(i);
  
  cout << a-b << endl;
}

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

using namespace std;
#define ll long long
int n,dem,res,k;
int a[200010];

int main()
{
    cin>>n>>k;
    int l=1;
    int r=1;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
        r=max(r,a[i]);
    }
    ll mid;
    while (l!=r)
    {
        mid=(l+r)/2;
        ll s=0;
        for (int i=1; i<=n; i++)
            s+=(a[i]-1)/mid;
        if (s>k) l=mid+1; else r=mid;
    }
    cout<<l;
}


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

using ll = long long;

void solve(std::string S){
    int cnt = 0;
    int ans = 0;
    for(int i = 0;i < 3;i++){
        if(S[i] == 'R'){
            cnt++;
        }else{
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    cout<<ans<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define N 109
#define ll long long
ll n, w, wt[N], v[N];
ll dp[N][100009];


int main()
{
    //memset(dp, -1, sizeof(dp));
    for(int i=0;i<=n;i++)
    {
        for(int j=1;j<=100000;j++) dp[i][j] = 10000000000000;
    }
    cin >> n >> w;
    //dp[0][0] = 0;
    for(int i = 1; i <= n; i++) cin >> wt[i] >> v[i];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=100000;j++)
        {
            dp[i][j] = min(dp[i-1][j], j-v[i]>=0?(dp[i-1][j-v[i]] + wt[i]):10000000000000);
            //cout<<dp[i][j] << " ";
        }
        //cout<<endl;
    }
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        for(int j = 1;j<=100000;j++)
        {
            if(dp[i][j]<=w) ans = max(ans, (ll)j);
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 80128
x = input().split()
N = int(x[0])
X = int(x[1])
Y = int(x[2])

L = [0 for _ in range(N+1)]

for i in range(1,N):
    for j in range(i+1,N+1):
        L[min(j-i,abs(X-i)+abs(Y-j)+1)] +=1
            
for k in range(1,N):
    print(L[k])

Measured memory_bytes: 3444
n = gets.to_i
x, l = Array.new(n) { gets.split.map(&:to_i) }.transpose
tmp = -10**9
count = 0

x.zip(l).sort_by { |x, l| x + l }.each do |x, l|
  if tmp <= x - l
    count += 1
    tmp = x + l
  end
end

puts count

Measured memory_bytes: 16376
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ld = long double;

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

    int a, b, x;
    cin >> a >> b >> x;
    int bound = a * a * b;
    ld ans = 0;
    ld foo = 0, bar = 0;
    if(x * 2 >= bound){
        foo = 2.0 * (a * a * b - x);
        bar = a * a * a;
    }
    else{
        foo = a * b * b;
        bar = 2.0 * x;
    }
    ans = atan2(foo, bar);
    ans *= 180.0 / acos(-1);
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
void getValue(string& line, int& a, int& b, int& c){
	string::size_type p1 = line.find(',');
	string::size_type p2 = line.rfind(',');
	a = atoi(line.substr(0, p1).c_str());
	b = atoi(line.substr(p1 + 1, p2 - p1 - 1).c_str());
	c = atoi(line.substr(p2 + 1).c_str());
}
int main()
{
	int a, b, c, n1, n2;
	n1 = n2 = 0;
	string s;
	while (cin >> s){
		getValue(s, a, b, c);
		if (c*c == a*a + b*b)
			++n1;
		else if (a == b)
			++n2;
	}
	cout << n1 << "\n" << n2 << "\n";
	return 0;
}

Measured memory_bytes: 1192
using System;
class ITP1_8_3
{
    static void Main()
    {
        int[] counter=new int[26];
        while (true)
        {
            string input=Console.ReadLine();
            if(input==null)break;
            foreach(char chr in input.ToLower()){
                if(char.IsLower(chr))counter[chr-'a']++;
            }
        }
        for(int i=0;i<26;i++){
            Console.WriteLine("{0} : {1}",(char)(i+'a'),counter[i]);
        }
    }
}

Measured memory_bytes: 5656
#include<bits/stdc++.h>
using namespace std;
#define M 100000007
typedef pair<int,int> P;
/*int main(){
	cout<<8979879<<endl;
}*/
int ri[3001][3001];
int main(void){
	int n,m,k,
		i,j,
		mx,t,ans,
		a[100001],b[100001],l[100001],s[3000],
		d[3001];
		
	priority_queue<P,vector<P>,greater<P> > que;
	
	cin>>n>>m>>k;
	for(i=0;i<m;i++) cin>>a[i]>>b[i]>>l[i];
	for(i=0;i<k;i++) cin>>s[i];
//	for(i=0;i<k;i++) cout<<s[i]<<endl;
	
	for(i=1;i<=n;i++) for(j=1;j<=n;j++) ri[i][j]=M;
	for(i=0;i<m;i++) ri[a[i]][b[i]]=l[i],ri[b[i]][a[i]]=l[i];
/*	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)cout<<ri[i][j]<<' ';
		cout<<endl;
	}*/
	
	int leng[3001];
	for(i=1;i<=n;i++) leng[i]=M;
	for(i=0;i<k;i++){
		leng[s[i]]=0;
		que.push(P(0,s[i]));
	}
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		if(leng[v]<p.first) continue;
		for(j=1;j<=n;j++){
			t=leng[v]+ri[v][j];
//			cout<<j<<' '<<leng[j]<<' '<<t<<endl;
			if(leng[j]>t){
				leng[j]=t;
//				cout<<leng[j]<<' '<<j<<endl;
				que.push(P(leng[j],j));
			}
		}
	}
/*	for(i=1;i<=n;i++) cout<<leng[i]<<' ';
	cout<<endl;*/
	ans=0;
	for(i=1;i<=n;i++){
		int mx=0,y;
		double x;
		for(j=1;j<=n;j++){
			if(ri[i][j]!=M){
				mx=max(mx,ri[i][j]+leng[j]+leng[i]);
			}
		}
		x=(double)mx/2;
//		cout<<x<<' '<<mx<<' '<<mi<<endl;
		y=round(x);
		ans=max(ans,y);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 39636
import math
n, m = map(int, input().split())
R = 1000000007

if abs(n - m) >= 2:
    ans = 0
else:
    nf = math.factorial(n)
    mf = math.factorial(m)
    if n == m:
        ans = (nf * mf * 2) % R
    else:
        ans = (nf * mf) % R

print(ans)

Measured memory_bytes: 11156
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan_ = new Scanner(System.in);
        int w_ = scan_.nextInt();
        int h_ = scan_.nextInt();
        int x_ = scan_.nextInt();
        int y_ = scan_.nextInt();
        int r_ = scan_.nextInt(); 
    
        if(w_ -(x_ + r_) >= 0 && h_ - (y_ + r_) >= 0
           && x_ - r_ >= 0 && y_ - r_ >= 0){

            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26400
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<29)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    int n, h1 = 0 ,h2 = 0;
    bool ans = true;
    cin >> n >> h1;
    for (int i = 0; i < n - 1; i++) {
        cin >> h2;
        if (h1 > h2) {
            ans = false;
            break;
        }
        if (h1 < h2)h2--;
        h1 = h2;
    }
    if (ans)Yes;
    else No;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

int main(){
    using namespace std;
    string str;
    int count;
    cin >> str;
    while(str[0]!='0'){
        count=0;
        for(int i{0};i<str.size();i++){
            count+=str[i]-'0';
        }
        cout << count << endl;
        cin >> str;
  }
}


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

long N,n;
vector<long> A;

main(){
    for(cin>>N;cin>>n;n=1LL<<50)A.push_back(n);
    auto a=A.begin(),t=a+1,d=A.end(),b=t+1;
    partial_sum(a,d,a);
    for(--d;t+1!=d;++t){
        while(a+1!=t)
            if(*a<*t-*(a+1))++a;
            else break;
        if(b==t)++b;
        while(b+1!=d)
            if(*b-*t<*d-*(b+1))++b;
            else break;
        n=min(n,max({*a,*t-*a,*b-*t,*d-*b})-min({*a,*t-*a,*b-*t,*d-*b}));
    }
    cout<<n<<" ";
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<pii, int> para;
const int inf = 1e9 + 7;
const int maxN = 5e6 + 5;

int n, t[maxN], x[20][20], y[20][20];

bool solve(string s) {
	REP(i, n) {
		if (s[i] == '1') {
			REP(j, t[i]) {
				if (y[i][j] == 0) {
					if (s[x[i][j] - 1] == '1') {
						return false;
					}
				} else {
					if (s[x[i][j] - 1] == '0') {
						return false;
					}
				}
			}
		}
	}
	return true;
}

int count(string s) {
	int ans = 0;
	REP(i, sz(s)) {
		if (s[i] == '1') ans++;
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	REP(i, n) {
		cin >> t[i];
		REP(j, t[i]) {
			cin >> x[i][j] >> y[i][j];
		}
	}
	int ans = 0;
	for(int i = 0; i < (1 << n); i++) {
		std::bitset<15> bs(i);
		string c = bs.to_string();
		reverse(c.begin(), c.end());
		if (solve(c)) {
			ans = max(ans, count(c));
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a, b, c;
  
  cin >> a >> b >> c;
  
  if(a == b && b != c){
    cout << "Yes";
  } 
  else if(a == c && b != c){
    cout << "Yes";
  }
  else if(b == c && a != c){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc177
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc177A();
            Console.Out.Flush();
        }

        public static void solve_abc177B()
        {
        }

        public static void solve_abc177A()
        {
            int[] dts = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int d = dts[0];
            int t = dts[1];
            int s = dts[2];
            double taken = (double)d / s;
            Console.WriteLine(taken > t ? "No" : "Yes");
        }

        public static int binSerachLeft(int[] a, int x)
        {
            int l = -1;
            int r = a.Length;
            while (r > l + 1)
            {
                int m = (l + r) / 2;
                if (a[m] <= x)
                {
                    l = m;
                }
                else
                {
                    r = m;
                }
            }
            return l;
        }
    }
}

Measured memory_bytes: 28424
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int x = int.Parse(Console.ReadLine());
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());

        int money = x - a;

        money %= b;

        Console.WriteLine(money);
    }
}


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

int main()
{
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s[0]==s[1] and s[2]==s[3] and s[1]!=s[2])cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3564
from heapq import heappop,heappush
from copy import deepcopy
from collections import deque
N,K=map(int,input().split())
V=[int(i) for i in input().split()]
ans=0
for s in range(K+1):
    for t in range(K+1-s):
        i=s
        j=t
        U=deque(V)
        #print(U)
        num=0
        H=[]
        while len(U) > 0 and i > 0:
            i -= 1
            x = U.popleft()
            heappush(H, x)
            num+=x
        while len(U) > 0 and j > 0:
            j -= 1
            x = U.pop()
            heappush(H, x)
            num+=x
        k=K-s-t
        #print(s+t+k,s,t,k,H,num)
        while len(H)>0 and k>0:
            k-=1
            y=heappop(H)
            #print(y)
            if y<=0:
                num-=y
        ans=max(num,ans)
print(ans)




Measured memory_bytes: 3572
#include<stdio.h>

char room[21][21];
int count,W,H;

void root(int W_n,int H_n){
	if((H_n+1)<H&&room[H_n+1][W_n]=='.'){
		room[H_n+1][W_n]='#';
		count++;
		root(W_n,H_n+1);
	}
	if(W_n>0&&room[H_n][W_n-1]=='.'){
		room[H_n][W_n-1]='#';
		count++;
		root(W_n-1,H_n);
	}
	if(H_n>0&&room[H_n-1][W_n]=='.'){
		room[H_n-1][W_n]='#';
		count++;
		root(W_n,H_n-1);
	}
	if((W_n+1)<W&&room[H_n][W_n+1]=='.'){
		room[H_n][W_n+1]='#';
		count++;
		root(W_n+1,H_n);
	}

}


int main(void){
	
	scanf("%d%d",&W,&H);
	while(W!=0&&H!=0){
		count=1;
		for(int i=0;i<H;i++){
			scanf("%s",room[i]);
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(room[i][j]=='@'){
					root(j,i);
				}
			}
		}
		printf("%d\n",count);
		scanf("%d%d",&W,&H);
	}
	return 0;
}

Measured memory_bytes: 2628
#include <iostream>

int main() {
  int A, B, C;
  std::cin >> A >> B >> C;

  if ( C >= A ) {
    if ( C <= B ) {
      std::cout << "Yes" << std::endl;
    } else {
      std::cout << "No" << std::endl;
    }
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i).sort!
bs = gets.split.map(&:to_i)
cs = gets.split.map(&:to_i).sort!

ans = bs.map do |b|
  x = as.bsearch_index { |a| a >= b } || n
  y = n - (cs.bsearch_index { |c| b < c } || n)
  x * y
end.inject(:+)
puts ans

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

using namespace std;

#define int long long

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

        int temp=a+2;

        if(a>k+1)
        {
                cout<<k+1<<endl;
        }
        else
        {
                int ans1=k+1;
                k-=a-1;
                int cur=a;
                int ans=0;
                if(k%2!=0)
                {
                        ans++;
                }
                //cout<<k<<endl;
                k/=2;
                ans+=(b-a)*k;
                ans+=a;
                ans=max(ans,ans1);
                cout<<ans<<endl;
        }

        return 0;
}

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

for n1k in range(N + 1):
    for n5k in range(N + 1 - n1k):
        n10k = N - n5k - n1k
        if Y == (n1k * 1 + n5k * 5 + n10k * 10) * 1000:
            print(n10k, n5k, n1k)
            exit()

print(-1, -1, -1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,x;
  cin >> a >> b >> x;
  ll a2 = (a==0 ? 0 : (a-1)/x+1);
  ll b2 = b/x+1;

  cout << b2-a2 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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 main(){
    ll S,W;
    cin>>S>>W;
    if(S<=W) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n;
  while(cin>>n,n){
    int d;
    cin>>d;
    set<string> ss;
    for(int i=0;i<n;i++){
      string s;
      cin>>s;
      ss.emplace(s);
    }
    using P = pair<string, string>;
    set<P> ans;
    auto calc=[](string s){
      int n=s.size();
      set<string> ss;
      for(int i=0;i<n;i++){
	string t=s;
	t.erase(t.begin()+i);
	ss.emplace(t);
      }
      for(int i=0;i<=n;i++){
	for(char c='a';c<='z';c++){
	  string t=s;
	  t.insert(t.begin()+i,c);
	  ss.emplace(t);
	}
      }
      for(int i=0;i<n;i++){
	for(char c='a';c<='z';c++){
	  string t=s;
	  t[i]=c;
	  ss.emplace(t);
	}
      }
      for(int i=0;i<n-1;i++){
	swap(s[i],s[i+1]);
	ss.emplace(s);
	swap(s[i],s[i+1]);
      }
      return ss;
    };
    map<string,vector<string> > ms;
    for(string s:ss){
      if(d==1){
	map<string,int> dp;
	queue<string> q;
	dp[s]=0;
	q.emplace(s);
	while(!q.empty()){
	  string t=q.front();q.pop();
	  if(dp[t]>=d) continue;
	  auto xs=calc(t);
	  for(string x:xs){
	    if(dp.count(x)) continue;
	    dp[x]=dp[t]+1;
	    q.emplace(x);
	  }
	}
	for(auto p:dp){
	  if(p.first==s||p.second>d) continue;
	  if(ss.count(p.first)) ans.emplace(minmax({s,p.first}));
	}
      }
      if(d==2){
	map<string,int> dp;
	queue<string> q;
	dp[s]=0;
	q.emplace(s);
	while(!q.empty()){
	  string t=q.front();q.pop();
	  if(dp[t]>=1) continue;
	  auto xs=calc(t);
	  for(string x:xs){
	    if(dp.count(x)) continue;
	    dp[x]=dp[t]+1;
	    q.emplace(x);
	  }
	}
	for(auto p:dp){
	  if(p.second==1){
	    for(auto x:ms[p.first])
	      ans.emplace(minmax({s,x}));
	    
	    ms[p.first].emplace_back(s);
	  }
	  if(p.first==s||p.second>d) continue;
	  if(ss.count(p.first)) ans.emplace(minmax({s,p.first}));
	}
      }
    }
    for(P p:ans)
      cout<<p.first<<","<<p.second<<endl;
    cout<<ans.size()<<endl;
  }
  return 0;
}



Measured memory_bytes: 26488
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#define ll long long
#define pii pair<int,int>
#define MP make_pair
using namespace std;
ll n;
map<ll,int>rev;
struct node{ll d,siz,val;int id;}a[100005];
bool cmp(node x,node y){return x.d>y.d;}
int back[100005];
vector<pii>ans;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i].d);
        a[i].siz=1;a[i].id=i;
        rev[a[i].d]=i;
    }
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=n;i++) back[a[i].id]=i;
    for(int i=1;i<n;i++){
        if(n-2*a[i].siz<=0){puts("-1");return 0;}
        ll dd=a[i].d+2*a[i].siz-n;
        if(!rev[dd]){puts("-1");return 0;}
        int fa=rev[dd];
        ans.push_back(MP(min(fa,a[i].id),max(fa,a[i].id)));
        a[back[fa]].siz+=a[i].siz;
        a[back[fa]].val+=a[i].val+a[i].siz;
    }
    if(a[n].d!=a[n].val) return puts("-1"),0;
    sort(ans.begin(),ans.end());
    for(int i=0;i<n-1;i++) printf("%d %d\n",ans[i].first,ans[i].second);
    return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  
  int i=0;
  int rot=0; 
  
  while(i<N && rot<K){
    while(i<N-1 && S.at(i)==S.at(i+1)){
      ++i;
    }
    if(i==N-1){
      break;
    }
    
    else{
      ++rot;
      int j=i+1;
    while(j<N && S.at(j)!=S.at(i)){
      S.at(j)=S.at(i);
      ++j;
      }
    }
    
    ++i;
}

  int count=0;
  if(N==1){
    cout<<0<<endl;
  }
  else{
  for(int i=0;i<N-1;++i){
    if(S.at(i)==S.at(i+1)){
      ++count;
    }
  }
     cout<<count<<endl;
}
  
}

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

int main() {
  long long int n;
  cin >> n;
  map<string, int> m;
  int mx = 0;
  for(int i=0; i < n; i++) {
    string s; cin >> s;
    if(m.find(s) == m.end()) {
      m[s] = 1;
      mx = max(mx, m[s]);
    } else {
      m[s]++;
      mx = max(mx, m[s]);
    }
  }
  vector<string> v;
  for(auto itr = m.begin(); itr != m.end(); itr++) {
    if(itr->second == mx) v.push_back(itr->first);
  }
  sort(v.begin(), v.end());
  for(int i=0; i < v.size(); i++) cout << v[i] << endl;
}


Measured memory_bytes: 26868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[3005][3005];

int lcs(string a,string b,int m,int n){
    for(int i=0;i<=m;i++){
        for(int j=0;j<=n;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(a[i-1]==b[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    return dp[m][n];
}

void solve(){
    string a,b;
    cin>>a>>b;
    int m=a.length();
    int n=b.length();
    memset(dp,-1,sizeof(dp));
    int x=lcs(a,b,m,n);
    string res;
    int i=m,j=n;
    while(i>0 && j>0){
        if(a[i-1]==b[j-1]){
            res+=a[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }
    }
    reverse(res.begin(),res.end());
    cout<<res<<endl;

    }

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
//    int t;
//    cin>>t;
//    while(t--)
        solve();
    return 0;
    }


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

int main(){
   int a,b,c,t;
   cin >> a >> b >> c;
   if(a > b){
      t=a;
      a=b;
      b=t;
   }
   if(a > c){
      t=a;
      a=c;
      c=t;
   }
   if(b > c){
      t=b;
      b=c;
      c=t;
   }
   cout << a << " " << b << " " << c <<endl;
   return 0;
}

Measured memory_bytes: 3028
#include <stdio.h>

int main()
{
    int b = 0, w = 0, ans;
    char read = '\0';
    while(read != '\n'){
        scanf("%c", &read);
        if(read == '0') b++;
        else if(read == '1') w++;
    }
    if(b < w) printf("%d\n", b*2);
    else printf("%d\n", w*2);

    return 0;
}

Measured memory_bytes: 128
//import lib.primeAndIndex
import kotlin.math.sqrt


fun primeAndIndex(n : Long): MutableMap<Long, Int> {
    var primeAndIndex: MutableMap<Long, Int> = mutableMapOf()
    var tmp = n
    var i = 2L
    while (tmp != 1L) {
        //println(tmp)
        var indexCount = 0
        while (tmp % i == 0L) {
            tmp /= i
            indexCount++
            //println(tmp)
        }
        //println("end")
        if (indexCount > 0) primeAndIndex[i] = indexCount
        i++
        if (i >= sqrt(n.toDouble())) {
            primeAndIndex[n] = 1
            break
        }
        //println(primeAndIndex)
        //println(tmp)
        //println(i)
    }
    return primeAndIndex
}



fun main(){
    val n = readLine()!!.toLong()
    //var primeList : List<Map<Int, Int>> = listOf()
    val primeAndIndex = primeAndIndex(n)
    //print(primeAndIndex)
    var count = 0
    primeAndIndex.forEach{
        var j = 1
        var index = it.value
        while(true){
            index -= j
            if(index < 0) break
            //println(index)
            j++
            count++
        }
    }
    println(count)
}

Measured memory_bytes: 34560
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int m,h;
  while(true){
      cin>>s;
      if(s[0] == '-')break;
      cin>>m;
      for(int i=0;i<m;i++){
          cin>>h;
          for(int j=0;j<h;j++){
              s+=s[0];
              s.erase(0,1);
          }
      }
    cout<<s<<endl;
  }
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n,m,q;
    vector<vector<int>> s,h,v;
    Problem(LL n ,LL m):n(n),m(m),s (n+1,vector<int>(m+1)),h (n+1,vector<int>(m+1)),v(n+1,vector<int>(m+1)){};

    void solve(){
        cin >> q;
        for(int i=0; i<n; ++i){
            for(int j=0; j<m; ++j){
                char tmp;
                cin >> tmp;
                s[i+1][j+1]=tmp-'0';
            }
        }
        for(int i=1; i<=n; ++i){
            for(int j=1; j<=m-1; ++j){
                if(s[i][j] and s[i][j+1]){
                    h[i][j+1]=1;
                }
            }
        }
        for(int i=1; i<=m; ++i){
            for(int j=1; j<=n-1; ++j){
                if(s[j][i] and s[j+1][i]){
                    v[j+1][i]=1;
                }
            }
        }
        for(int i=0; i<=n; ++i){
            for(int j=1; j<=m; ++j){
                s[i][j]+=s[i][j-1];
                h[i][j]+=h[i][j-1];
                v[i][j]+=v[i][j-1];
            }
        }
        for(int i=0; i<=m; ++i){
            for(int j=1; j<=n; ++j){
                s[j][i]+=s[j-1][i];
                h[j][i]+=h[j-1][i];
                v[j][i]+=v[j-1][i];
            }
        }
        DBG(s)
        DBG(v)
        DBG(h)
        for(int i=0; i<q; ++i){
            DBG(i)
            int a,b,c,d,ans=0;
            cin >> a >> b >> c >> d;--a;--b;
            ans+=s[c][d]-s[a][d]-s[c][b]+s[a][b];
            ans-=h[c][d]-h[a][d]-h[c][b+1]+h[a][b+1];
            ans-=v[c][d]-v[a+1][d]-v[c][b]+v[a+1][b];
            cout << ans <<"\n";
        }
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0,m;
    cin >> n >> m;

    Problem p(n,m);
    p.solve();
    return 0;
}



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

struct SgTree{
private:
	vector<pair<long long, bool>> node;
	long long defval;
	int N;
	int n;
public:
	void init(int n, long long defval = INT64_MAX){
		N = 1;
		while(N < n)N<<=1;
		this->n = n;
		this->defval = defval;
		node.assign(N*2-1, make_pair(defval, false));
	}
	long long query(int a, int b, int l = 0, int r = -1, int i = 0){
		if(r == -1) r = N;
		if(b <= l || r <= a) return defval;
		if(a <= l && r <= b) return node[i].first;
		if(node[i].second) return node[i].first;
		return min(query(a,b,l,(l+r)/2,i*2+1),query(a,b,(l+r)/2,r,i*2+2));
	}
	void update2(int a, int b, long long v, int l, int r, int i, long long defv){
		if(b <= l || r <= a) { node[i] = make_pair(defv, true); return; }
		if(a <= l && r <= b) { node[i] = make_pair(v, true); return; }
		
		update2(a,b,v,l,(l+r)/2,i*2+1,defv);
		update2(a,b,v,(l+r)/2,r,i*2+2,defv);

		node[i].second = false;
		node[i].first = min(node[i*2+1].first, node[i*2+2].first);
	}
	void update(int a, int b, long long v, int l = 0, int r = -1, int i = 0){
		if(r == -1) r = N;
		if(b <= l || r <= a) return;
		if(a <= l && r <= b) { node[i] = make_pair(v, true); return; }
		if(node[i].second) return update2(a,b,v,l,r,i,node[i].first);
		
		update(a,b,v,l,(l+r)/2,i*2+1);
		update(a,b,v,(l+r)/2,r,i*2+2);

		node[i].first = min(node[i*2+1].first, node[i*2+2].first);
	}

};


int main() {
	int n, q; cin >> n >> q;
	SgTree tr; tr.init(n, INT_MAX);

	vector<long long> ans;

	for(int i = 0; i < q; i++){
		int c; cin >> c;
		if(c == 0){
			int s,t,x; cin >> s >> t >> x;
			tr.update(s, t+1, x);
		}
		else {
			int s, t; cin >> s >> t;
			ans.push_back(tr.query(s, t+1));
		}
	}

	for(int i = 0; i < ans.size(); i++){
		cout << ans[i] << endl;
	}

    return 0;
}



Measured memory_bytes: 7976
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> ans(n);
  for(int x=1;x<=100;x++){
    for(int y=1;y<=100;y++){
      for(int z=1;z<=100;z++){
        int a=x*x+y*y+z*z+x*y+y*z+z*x;
        if(a<=n){
          ans.at(a-1)++;
        }
      }
    }
  }
  
  for(int i=0;i<n;i++){
    cout<<ans.at(i)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3544
#include<stdio.h>

int min(int x,int y){
	if(x<y)return x;
	return y;
}

int main(){
	int K,S,ans=0;
	scanf("%d%d",&K,&S);
	for(int x=0;x<=min(K,S);x++)
		for(int y=0;y<=min(K,S);y++)if(S-x-y>=0 && S-x-y<=K)ans++;
			
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var a = p[0];
		var b = p[1];
		
		for(int i = 1; i <= 1000; i++)
		{
			int q = (int)(i * 0.08);
			int s = (int)(i * 0.1);
			if(q==a && s == b)
			{
				Console.WriteLine(i);
				return;
			}
		}
		Console.WriteLine(-1);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)1e5 + 5;

int N;
int T[MAX];
int A[MAX];
int height[MAX];

int solve() {
	ll cnt = 1;
	REP(i, 1, N + 1) {
		if (T[i - 1] < T[i]) continue;
		if (A[i] > A[i + 1]) continue;
		if (T[i - 1] > T[i]
			|| A[i] < A[i + 1]) {
			return 0;
		}
		cnt *= min(T[i], A[i]);
		cnt %= mod;
	}
	REP(i, 1, N + 1) {
		if (T[i - 1] < T[i]) {
			height[i] = T[i];
		}
	}
	REP(i, 1, N + 1) {
		if (A[i] > A[i + 1]) {
			if (height[i] != 0 && A[i] != height[i]) {
				return 0;
			}
			height[i] = A[i];
			if (height[i] > T[i]) return 0;
		}
		if (height[i] > A[i]) return 0;
	}
	if (T[N] != A[1]) {
		return 0;
	}
	return cnt;
}

signed main() {
	cin >> N;
	REP(i, 1, N + 1) cin >> T[i];
	REP(i, 1, N + 1) cin >> A[i];
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main()
{
  finp;
  ll a,b,c;
  cin>>a>>b>>c;
  if(a%2==0 || b%2==0 || c%2==0)
  {
    cout<<0;
  }
  else
  {
    ll ans = min(a*b,b*c);
    ans = min(ans,a*c);
    cout<<ans;
  }
  
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <limits.h>
#include <stdio.h>
#include <string.h>
using namespace std;
 
 
int main()
{
    long long int hh,ww,m;
    cin >> hh >> ww >> m;
    
    std::vector<int> hw[hh];
    std::vector<std::pair<int, int>> p;
    std::vector<int> mph(hh), mpw(ww);  // 各行・列毎のカウンタ
    for(long long int i=0; i<m; i++){
        int h, w;
        cin >> h >> w;
        h--; w--;
        mph[h]++;
        mpw[w]++;
        hw[h].push_back(w);
        p.push_back(std::make_pair(h, w));
    }
    
    long long int maxh=0, maxw=0;
    std::multimap<long long int, long long int> mh, mw;    
    for(long long int i=0; i<hh; i++){
        mh.emplace(mph[i], i);
        if(mph[i] > maxh) maxh = mph[i];
    }
    for(long long int i=0; i<ww; i++){
        mw.emplace(mpw[i], i);
        if(mpw[i] > maxw) maxw = mpw[i];
    }
    //cout << maxh << ", " << maxw << endl;
    
    /*
    auto ph = mh.equal_range(maxh);
    for (auto it = ph.first; it != ph.second; ++it) {
        //cout << "i:" << it->second << endl;
        auto pw = mw.equal_range(maxw);
        for (auto it2 = pw.first; it2 != pw.second; ++it2) {
            //cout << "j:" << it2->second << endl;
            if(std::find(hw[it->second].begin(), hw[it->second].end(), it2->second) == hw[it->second].end()){
                cout << maxh+maxw << endl;
                return 0;
            }
            
        }
    }
    */
    int ph = mh.count(maxh);
    int pw = mw.count(maxw);
    int cnt = 0;
    for(int i=0; i<m; i++){
        std::pair<int, int> tmp = p[i];
        if(mph[tmp.first] == maxh && mpw[tmp.second] == maxw) cnt++;
    }    
    if(cnt == ph*pw) cout << maxh+maxw-1 << endl;
    else cout << maxh+maxw << endl;
    return 0;
}
 

Measured memory_bytes: 61836
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n,k;
    string s;
    Problem(LL n):n(n){};
    void out(int pos){
        vector<char> ab;
        for(int i=0; i<pos; ++i){
            if(i%2==0) ab.push_back('A');
            else ab.push_back('B');
        }
        reverse(ab.begin(),ab.end());
        for(int i=pos; i<n; ++i){
            if(pos%2==0)cout << s[i];
            else if(s[i]=='A')cout << 'B';
            else cout << 'A';
        }
        for(auto c : ab){
            cout << c;
        }
        cout << "\n";
    }
    void ba(int l){
        for(int i=0; i<l; ++i){
            if(i%2==0) cout << 'B';
            else cout << 'A';
        }
        cout << "\n";
    }
    void solve(){
        cin >> k >> s;
        int cnt=0;
        for(int i=0; i<n; ++i){
            if(cnt==k){out(i);return;}
            if((s[i]=='A' and i%2==0)or(s[i]=='B' and i%2==1)){
                if(s[i]=='A')s[i]='B';
                else s[i]='A';
                ++cnt;
                if(cnt==k){out(i);return;}
            }
            ++cnt;
        }
        if(n%2==0){
            ba(n);
        }else{
            if((k-cnt)%2==0)cout <<'A';
            else cout << 'B';
            ba(n-1);
        }
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 916
N = gets.to_i
a = N.times.map{gets.split.map &:to_i}
b = N.times.map{gets.split.map &:to_i}
a.sort_by!{|x,y|[-x, -y]}
b.sort_by!{|x,y|[y, x]}
ans = 0
a.each{|ax, ay|
  idx = b.index{|bx, by| bx > ax && by > ay}
  if idx
    b.delete_at(idx)
    ans += 1
  end
}
p ans

Measured memory_bytes: 1788
"""
P = []
for p in range(6,55555,5):
  for x in range(2,p):
    if p%x==0:
      break
  else:
    P += [p]
    if len(P)>=55:
      break
print P
"""
P = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]
print " ".join(map(str, P[:input()]))


Measured memory_bytes: 2568
#include "bits/stdc++.h"
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    A=(A+13)%15;B=(B+13)%15;
    if(A>B)cout<<"Alice"<<endl;
    if(B>A)cout<<"Bob"<<endl;
    if(B==A)cout<<"Draw"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
  std::string s;
  std::cin >> s;

  int len = s.length();

  bool isHitachi = true;
  for (int i = 0; i < len; i += 2)
  {
    if (s[i] != 'h') { isHitachi = false; break; }
    if (s[i + 1] != 'i') { isHitachi = false; break; }
  }

  if (isHitachi)
  {
    std::cout << "Yes\n";
  }
  else
  {
    std::cout << "No\n";
  }

  return 0;
}


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


int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  int ans = 1;
  rep(i,n-1){
    int x;
    cin >> x;
    if(m <= x){
      m = x;
      ans++;
    }
  }
  cout << ans;
      
  return 0;
}





Measured memory_bytes: 3604
/*
D - Anticube
by.YXH_XianYu
   2018.6.15

题意:

给你n个数,分别为s1,s2,...,sn.
求一个s的子集，
使得不存在si*sj=平方数(i!=j).

----- ----- ----- ----- -----

题解:

我们将平方数质因数分解,可得每项指数均=3
那如果si*sj的每项质因数的指数均=3
则si,sj不能同时选取

将si分解质因数,把每个因子的指数%3,得到si(新).
寻找与si配对的sj(si*sj=平方数),
则si与sj不能同时选进子集,
最后判断si出现次数多,还是sj出现次数多,
选取出现次数多的记入答案.
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LLI long long
#define REG register
#define MXN 100010

LLI n,
	l1[MXN],
	l2[MXN];
#include<map>
std::map<LLI,int>cnt;

/* 欧拉筛法把1~3000质数筛出来 */
/* 筛到3000是因为3000^3 > 10^10 */
LLI pri_[MXN],	//3000内质数的立方
	pri[MXN];	//3000内质数
bool wth[MXN];	//wth[i]==0?i质:i合
void Euler(int n){
	wth[1]=1;
	for(int i=2;i<=n;i++){
		if(!wth[i])
			pri[++pri[0]]=i;
		for(int j=1;j<=pri[0]&&i*pri[j]<=n;j++){
			wth[i*pri[j]]=1;
			if(i%pri[j]==0)
				break;
		}
	}
	for(int i=1;i<=pri[0];i++)
		pri_[i]=pri[i]*pri[i]*pri[i];
}

int main(){

	scanf("%d",&n);
	Euler(3000);
	REG int i,j;
	for(i=1;i<=n;i++){
		LLI si,sj;

		scanf("%lld",&si);
		/* 将si的每个质因子的指数%3 */
		for(j=1;pri_[j]<=si;j++)
			while(si%pri_[j]==0)
				si/=pri_[j];
		cnt[si]++;	//记录si
		l1[i]=si;	//链表记录
		
		sj=1;		//寻找与si配对的sj
		for(j=1;pri_[j]<=si;j++)
			if(si%pri[j]==0){
				//使得si*sj的质因子指数=3
				sj*=(si%(pri[j]*pri[j])==0)?(pri[j]):(pri[j]*pri[j]);
				while(si%pri[j]==0)
					si/=pri[j];
			}
		//前面的循环退出条件为pri[j]^3>si
		//而会存在一种情况 si(现在)%pri[j]^2==0
		//这里对这个局面进行处理:
		//若si是平方数  ,则sj*=sqrt(si)
		//若si不为平方数,则sj*=si*si
		//均使得si*sj的质因子指数=3
		//赠:printf("<%lld>\n",si);
		sj*=((LLI)sqrt(si)*(LLI)sqrt(si)==si)?((LLI)sqrt(si)):(si*si);
		l2[i]=sj;//链表记录
	}
	/* 计算答案并输出 */
	int ans=0;
	if(cnt[1]>0) ans++,cnt[1]=0;//对质因数分解后为=1的数进行特判
	for(i=1;i<=n;i++)			//选取每对si,sj中,出现次数多的数选取
		ans+=std::max(cnt[l1[i]],cnt[l2[i]]),
		cnt[l1[i]]=cnt[l2[i]]=0;
	printf("%d\n",ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define  rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
    string w,ans="Yes";
    cin>>w;
    int a[26]={0};
    for(char c:w) a[c-'a']++;
    for(int i:a) if(i%2) ans="No";
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import itertools
import decimal
import math
import collections
import sys
#input = sys.stdin.readline
import copy

# S=(input())
# N=int(input())
# N,K=map(int,input().split())
# ListA=list(map(int,input().split()))
# ListA.sort()#reverse=True)

def resolve():
    
    N=int(input())
    ans=[0]*(N+1)
    cnt=0
    for x in range(1,110):
        for y in range(1,110):
            for z in range(1,110):
                tmp=x**2+y**2+z**2+x*y+y*z+z*x
                if(tmp<=N):
                    ans[tmp]+=1


    for i in range(1,N+1):
        print(ans[i])



resolve()

Measured memory_bytes: 10160
/******************************************
* AUTHOR : kamesh_11 *
* INSTITUTION : GVPCOE *
******************************************/

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

#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bs binary_search
#define endl '\n'
#define start_clock clock_t beginn=clock()
#define end_clock clock_t endd=clock()
#define cal_exec_time double time_spent=(double)(endd-beginn)/CLOCKS_PER_SEC
#define print_exec_time cout<<endl<<time_spent<<" secs"

typedef long long int ll;

const ll MOD = 1e9 + 7;

ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

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

	int n, c1 = 0, c2 = 0, c3 = 0, c4 = 0;
	cin>>n;
	string str;
	for(int i=0;i<n;i++){
		cin>>str;
		if(str == "AC") c1++;
		if(str == "WA") c2++;
		if(str == "TLE") c3++;
		if(str == "RE") c4++;
	}

	cout<<"AC x "<<c1<<endl;
	cout<<"WA x "<<c2<<endl;
	cout<<"TLE x "<<c3<<endl;
	cout<<"RE x "<<c4;

	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int h,k,i,miku=1;
    cin>>h>>k;
    for(i=1;i<=h;i++)
    miku+=min(miku,k);
    cout<<miku<<endl;
    return 0;
    //初音殿下赛高吖
}

Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int N = 100005;
  const int INF = 1e16;
  const double PI = acos(-1);


int dp[10005][105][2];

int32_t main()
{
       

    IOS


    string s;
    cin >> s;

    int d;
    cin >> d;

    dp[0][0][0] = 1;

    

    for(int i = 0; i < s.length(); i++)
    {
      // i is terating over the string

      for(int j = 0; j < d; j++)
        {
          // j is iterating over the digit sum modulo d

          for(int k = 0; k < 2; k++)
          {
            /*
            if k is zero then we did'nt place a digit so far which 
            is less significant than the digit in the string so 
            */

            /*
            if k is one then we have placed placed a digit earlier 
            such that is less significant than the digit in the string 
            */
            for(int x = 0; x < 10; x++)
            {
              // x iterating over the digits we are placing at the ith position
              if(k == 0 and x > s[i]-'0')
              {
                continue;
                // if k is zero we can only place digits from 0 to the corresponding digit
                //in the string
              }
              int kk = k;
              if(x < s[i]-'0')
              {
                kk = 1;
                // if kk is one now we can only place digits from 0 to 9 due to the less significant digit placed before
              }
              dp[i+1][(j+x)%d][kk] += dp[i][j][k]%mod;
              dp[i+1][(j+x)%d][kk]%=mod;
            }
          }
        }
    }



    cout << (dp[s.length()][0][0]%mod + dp[s.length()][0][1]%mod - 1 + mod)%mod;
  return 0;
} 

Measured memory_bytes: 16640
#include <string>
#include <map>
#include <iostream>
using namespace std;
int main() 
{
	map<string,int> table;
	string word,frequent,longest;
	size_t N=0;
	while(cin>>word)
	{
		table[word]++;
		if(table[word]>N)
		{
			N=table[word];
			frequent=word;
		}
		if(word.size()>longest.size())
			longest=word;
	}
	cout<<frequent<<" "<<longest<<endl;
}

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

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

int main(){
	int l, a, b, c, d;
	cin >> l >> a >> b >> c >> d;
	int n = max( (a+c-1)/c, (b+d-1)/d );
	cout << l-n << endl;
	return 0;
}

Measured memory_bytes: 1160
S = list(input())
S1 = int(S[0] + S[1])
S2 = int(S[2] + S[3])
if 0 < S1 <= 12 and 0 < S2 <= 12:
    print('AMBIGUOUS')
elif 0 < S1 <= 12:
    print('MMYY')
elif 0 < S2 <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940