akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main( void )
{
    string s;
    cin >> s;

    long long szero = 0;
    long long sone = 0;

    long long length = s.size();
    long long num = 0;
    while(num < length){
        if(num % 2 == 0){
            if(s[num] == '0'){
                sone++;
            }else{
                szero++;
            }
        }else{
            if(s[num] == '0'){
                szero++;
            }else{
                sone++;
            }
        }
        num++;
    }

    cout << min(sone, szero) << "\n";
	return 0;
}

Measured memory_bytes: 512
import math

n = int(input())

a = [int(x) for x in input().split()]

res = 0

for x in a :
    res += x

ans = 0

i = 0

while ans < res//2 :
    ans += a[i]
    i += 1

i -= 1

rmn = res - ans
print(min(ans - rmn, rmn + 2*a[i] - ans))



Measured memory_bytes: 25948
import java.util.Scanner;

public class Main {
	//問題A-Atcoder君とペンキ
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 1;
		int[] a = new int[3];//ペンキは３種類
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();//入力
		}
		if (a[0]!=a[1]) {
			count++;
		}
		if(a[1]!=a[2]&&a[2]!=a[0]){
			count++;
		}
		System.out.println(count);//何種類あったかの合計
	}

}

Measured memory_bytes: 9680
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
string s;


int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n>>s;
	ll ans = 0;
	rep(i,n){
		ll tmp = 0;
		map<char,ll> ma;
		rep(j,i){
			ma[s[j]]++;
		}
		set<char> st;
		repi(j,i,n){
			st.insert(s[j]);
		}
		for(auto& id: st){
			if(ma[id])tmp++;
		}
		chmax(ans,tmp);
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 256
N,X,Y = map(int,input().split())
A = [0 for i in range(N)]
for i in range(N-1):
    a = i+1
    for j in range(i+1,N):
        b = j+1
        A[min([b-a,abs(X-a)+abs(Y-b)+1])] += 1
for i in range(1,N):
    print(A[i])

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll MAX_J = 100;
ll dp[110][2][110];

int main(int argc, char **argv)
{
	string S; cin >> S;
	ll K; cin >> K;
	ll N = S.size();

	memset(dp, 0, sizeof dp);
	***dp = 1;

	REP(i, N)
	{
		REP(j, MAX_J)
		{
			REP(k, 10)
				dp[i+1][true][j+(k!=0)] += dp[i][true][j];

			ll Ni = S[i] - '0';

			REP(k, Ni)
				dp[i+1][true][j+(k!=0)] += dp[i][false][j];

			dp[i+1][false][j+(Ni!=0)] += dp[i][false][j];
		}
	}

	std::cout << dp[N][0][K] + dp[N][1][K] << std::endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n, q;
  string s;
  cin >> n >> s >> q;
  vector<tuple<int, int, int>> query;
  REP(i, q){
    int x, y, z;
    cin >> x;
    if(x == 1){
      char c;
      cin >> y >> c;
      z = (int)c;
    }else{
      cin >> y >> z;
    }
    query.emplace_back(x, y, z);
  }
  vector<set<int>> a(26, {INF});
  REP(i, n){
    int m = s[i] - 'a';
    a[m].insert(i);
  }
  vector<int> ans;
  REP(i, q){
    int x, y, z;
    tie(x, y, z) = query[i];
    if(x == 1){
      y--;
      if(s[y] == (char)z) continue;
      int m = s[y]-'a';
      a[m].erase(y);
      s[y] = (char)z;
      m = s[y]-'a';
      a[m].insert(y);
    }else{
      int l = y-1, r = z-1;
      int count = 0;
      REP(j, 26){
        int p = *a[j].lower_bound(l);
        if(p <= r) count++;
      }
      ans.emplace_back(count);
    }
  }

  for(int c : ans) cout << c << endl;
  return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    int l;
    cin>>l;
    a[i]=l;
  }
  long long dp[100010];
  for(int i=0;i<100010;i++)dp[i]=9999999999;
  dp[0]=0;
  for(int i=1;i<n+1;i++){
    for(int j=1;j<k+1;j++){
      if(i>j-1)dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int r[200001]={0},d[200001]={0};
vector<int> A[200001],B[200001];
int search(int x){
  r[x]=1;
  for(auto i:A[x]) if(!r[i]) d[i]=d[x]+1,B[d[i]].push_back(i),search(i);
}
int main(){
    int n,a,b,c[200000],ans=0,z=0;
    cin>>n;
    rep(i,n-1) cin>>a>>b,A[a].push_back(b),A[b].push_back(a);
    c[0]=0;
    rep(i,n) cin>>c[i],ans+=c[i];
    search(1);
    B[0].push_back(1);
    sort(c,c+n,greater<int>());
    cout<<ans-c[0]<<endl;
    vector<pair<int,int>> Q;
    rep(i,n) for(auto j:B[i]) Q.push_back(make_pair(j,c[z])),z++;
    sort(Q.begin(),Q.end());
    rep(i,n) cout<<Q[i].second<<" ";
}

Measured memory_bytes: 11904
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main(){
	int N,Q,i,x,y;
	string s;
	for(;cin>>N>>Q,N;){
		vector<pair<int,pair<int,string> > >v;
		for(i=0;i<N;i++)cin>>s>>x>>y,v.push_back(make_pair(y-x,make_pair(y,s)));
		for(i=0;i<Q;y<N?cout<<v[y].second.second<<' '<<x-v[y].first<<endl:cout<<"Unknown"<<endl,i++)for(cin>>x,y=0;y<N;y++)if(v[y].first<x&&x<=v[y].second.first)break;
	}
}

Measured memory_bytes: 1292
/*
AIZU ONLINE A0522
JOI and IOI
*/
#include <stdio.h>
#include <string.h>

char str[10001];


main()
{
	int i,cnt_ioi,cnt_joi;

	while(EOF != scanf(" %s",str))
	{	cnt_ioi=0; cnt_joi=0;
		for(i=0;i<=strlen(str)-3;i++)
		{	if(0 == strncmp("IOI",&str[i],3))
				cnt_ioi++;
                        if(0 == strncmp("JOI",&str[i],3))
				cnt_joi++;
		}
		printf("%d\n",cnt_joi);
		printf("%d\n",cnt_ioi);
	}
return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

    if (b >= a) {
        cout << a << endl;
    } else {
        cout << (a - 1) << endl;
    }
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	REP(i, h) cin >> s[i];
	REP(i, w+2) cout << "#";
	cout << endl;
	REP(i, h) cout << "#" << s[i] << "#" << endl;
	REP(i, w+2) cout << "#";
	cout << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(){
	string s;
	cin>>s;
	int len=s.size();
	cout<<s[0]<<len-2<<s[len-1]<<endl;
	return 0;

}


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

int cmp(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int n;
	int *d;
	scanf("%d", &n);
	d = malloc(sizeof(int) * n);
	for(int i = 0; i < n; i++)
		scanf("%d", d + i);
	qsort(d, n, sizeof(int), cmp);
	printf("%d\n", d[n / 2] - d[n / 2 - 1]);
	return 0;
}


Measured memory_bytes: 892
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <fstream>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*ll t,tcitr;
    cin>>t;
    tcitr=0;
    while(tcitr<t)
    {*/
        //cout<<"Case #"<<tcitr+1<<": ";
        string s;
        cin>>s;
        ll n=s.length();
        ll sm=0;
        for(ll i=0;i<n;i++)sm+=(s[i]-'0');
        (sm%9)?cout<<"No\n":cout<<"Yes\n";
        /*tcitr++;
    }*/
    return 0;
}


Measured memory_bytes: 3784
N = int(input().rstrip())
A = []
mx1 = 0
mx2 = 0
for i in range(N):
    A.append(int(input().rstrip()))
    if A[i] > mx1:
        mx1, mx2 = A[i], mx1
    elif A[i] > mx2:
        mx2 = A[i]
for j in range(N):
    if A[j] == mx1:
        print(mx2)
    else:
        print(mx1)

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

using namespace std;

int main(){
    string S; cin >> S;
    int res = 0;
    for(auto& c : S) res += c - '0';
    for(int i=0;i<S.size();i++){
        if(S[i] == '0') continue;
        int cur = 0;
        for(int j=0;j<S.size();j++){
            if(j < i) cur += S[j] - '0';
            else if(j == i) cur += S[j] - '0'  - 1;
            else cur += 9;
        }
        res = max(cur, res);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#define MAX 10000000
using namespace std;

bool prime[MAX];

void create(){
   for(int i=0;i<=MAX;i++)prime[i]=false;
   for(int i=3;i<=MAX;i+= 2)prime[i] = true;
   prime[2] = true;
   int limit = (int)sqrt(MAX)+1; 
     for(int i=3;i<=limit;i+=2){
	if(!prime[i])continue;
      for(int j=i+i;j<=MAX;j+=i){
	    prime[j]=false;
      }
      
   }

}


int main(){
   int a,d,n;
   create();


   while(true){
      int count = 0,i;
      cin >> a >> d >> n;
      if(a+d+n == 0)break;
      for(i=a;count < n;i+=d){
	 if(prime[i])count++;  
      }
      
      cout<<i-d<<endl;
   }
   return 0;
}

Measured memory_bytes: 10000
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

typedef pair<int, pair<string, int> > P;

#define INF 1000000000

int main(){
    int n,q;
    while(cin>>n>>q, n|q){
        vector<P> vec;
        rep(i,n){
            string a; int y1,y2;
            cin>>a>>y1>>y2;
            vec.pb(mp(y2, mp(a, y1)));
            vec.pb(mp(y2-y1+1, mp(a,1)));
        }

        sort(all(vec));
        vec.erase(unique(all(vec)), vec.end());

        rep(i,q){
            int query;
            cin>>query;
            P que = mp(query, mp("",0));
            auto itr = lower_bound(all(vec), que);

            const string uk = "Unknown";
            if(itr==vec.end()){
                cout<<uk<<endl;
                continue;
            }
            if(itr->second.second==1){
                if(itr->first == query)
                    cout<<itr->second.first<<" 1"<<endl;
                else
                    cout<<uk<<endl;
            } else {
                itr--;
                int year = query - itr->first +1;
                cout<<itr->second.first<<" "<<year<<endl;
            }

        }

    }

    return 0;
}

Measured memory_bytes: 3268
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 456;
char s[MAXN][MAXN];
int bz[MAXN * MAXN], wz[MAXN * MAXN], par[MAXN * MAXN];
bool visit[MAXN * MAXN];

int find(int x) {
    return par[x] == x ? x : par[x] = find(par[x]);
}

void merge(int x, int y) {
     x = find(x);
     y = find(y);
     if (x == y) return;
     par[x] = y;
     wz[y] += wz[x];
     bz[y] += bz[x];
}

int main() {
    int H, W;
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; i++) {
        scanf("%s", s[i]);
        for (int j = 0; j < W; j++) {
            int idx = i * W + j;
            par[idx] = idx;
            if (s[i][j] == '#') bz[idx] = 1;
            else wz[idx] = 1;
            if (j && s[i][j - 1] != s[i][j]) merge(idx, idx - 1);
            if (i && s[i - 1][j] != s[i][j]) merge(idx, idx - W);
        }
    }
    LL ans = 0;
    for (int i = 0; i < H * W; i++) {
        int cur = find(i);
        if (visit[cur]) continue;
        visit[cur] = 1;
        ans += (LL)bz[cur] * wz[cur];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2432
one_word = raw_input()
word_count = 0
word_list = []

while 1:
	temp = raw_input()
	word_list += temp.split()
	
	if word_list[len(word_list)-1] == "END_OF_TEXT":
		break

for word in word_list:
	if one_word.lower() == word.lower():
		word_count += 1

print word_count

Measured memory_bytes: 4200
#include<bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl;
using namespace std; 

//int _; 

int n; 

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> n;
	if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9)
		puts("hon");
	if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8)
		puts("pon");
	if(n%10 == 3)
		puts("bon");
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  std::string S;
  std::cin >> S;
  std::cout << (S == "ABC" ? "ARC" : "ABC") << '\n';
  return 0;
}


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


int main() {
  int a,b,c,k;
  cin >> a;
  for(int i = 0;i < 3;i++){
    cin >> b;
  }
  cin >> c >> k;
  if(c-a > k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
}


Measured memory_bytes: 256
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
a = []
for i in range(2,n+1):
    a += prime_factorize(i)
b = set(a)
c = collections.Counter(a)
ans = 1
for i in b:
    ans *= c[i]+1
    ans %= 10**9+7
print(ans)


Measured memory_bytes: 39408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int len = 9;
    vector<pair<int, bool>> a(len);
    for (int i = 0; i < len; i++)
    {
        cin >> a[i].first;
        a[i].second = false;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int b;
        cin >> b;
        for (int j = 0; j < len; j++)
        {
            if (b == a[j].first)
            {
                a[j].second = true;
                break;
            }
        }
    }
    /*
        0 1 2
        3 4 5
        6 7 8
    */
    if (a[4].second)
    {
        if (a[0].second && a[8].second || a[1].second && a[7].second || a[2].second && a[6].second || a[3].second && a[5].second)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (a[0].second)
    {
        if (a[1].second && a[2].second || a[3].second && a[6].second)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (a[8].second)
    {
        if (a[6].second && a[7].second || a[2].second && a[5].second)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {

    private static void nCombination3(int c) {
        int count = c;
        int num = 0;
        for (int i = 0; i < count - 2; i++) {
            for (int j = i + 1; j < count - 1; j++) {
                for (int k = j + 1; k < count; k++) {
                    num++;
                }
            }
        }
    }



    public static void main(String[] args) {
        // write your code here
        Scanner sc=new Scanner(System.in);
        String S=sc.next(),T=sc.next();
        if(T.length()-S.length()==1&&S.equals(T.substring(0,S.length()))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 35824
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;
LLI n,a,b,h[100003];
LLI om(LLI a,LLI b){
    if(a<=0) return -((-a)/b);
    else return (a-1)/b+1;
}
bool solve(LLI k){
    LLI sum=0;
    FOR(i,0,n) sum+=max(om(h[i]-b*k,a-b),(LLI)0);
    return (sum<=k);
}
int main(){
    cin>>n>>a>>b;
    FOR(i,0,n) cin>>h[i];
    int st=0,en=1e9+7;
    while(st+1!=en){
        int mid=(st+en)/2;
        if(solve(mid)) en=mid;
        else st=mid;
    }
    cout<<en<<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define MP_ make_pair
#define PB_ push_back
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;
int c2i(char c){if(c>='0' and c<='9'){return (int)(c-'0');}return -1;}


  
int digiS(int n)
{
  int cnt = 0;
  int m = n;
  string S = to_string(m);
  
  REP(i,SIZ(S))
    {
      cnt += c2i(S[i]);
      
    }
  return cnt;
  
  
}

int main()
{
  IOS; /* making cin faster */
  int N;
  cin >> N;

  int b;
  int mn = INF;
  
  FOR(a,1,N)
    {
      b = N - a;

      if( digiS(a) + digiS(b) < mn )
	{
	  mn = digiS(a) + digiS(b);
	  
	}
      
    }

  
  cout << mn << endl;
  

}


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

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

	string sub = "";

	int ans = 0;
	for(int i = 0; i < s.size(); i++)
	{
		string s2 = "";
		for(int j = i; j < s.size(); j++)
		{
			s2 += s[i];
			if(s2.size() != sub.size()) break;
			else
			{
				bool flag = true;
				for(int k = 0; k < s2.size(); k++)
				{
					if(s2[k] != sub[k])
					{
						flag = false;
						break;
					}
				}
				if(flag == true) i++;
				else break;
			}
		}

//		cout << "test" << endl;
//		cout << i << endl;
//		cout << sub << endl;
//		cout << s2 << endl;
//		cout << "ans1:" << ans << endl;

		//last
		if(i >= s.size()-1 and s2.size() == sub.size())
		{
			bool flag = true;
			for(int k = 0; k < s2.size(); k++)
			{
				if(s2[k] != sub[k])
				{
					flag = false;
					break;
				}
			}
			if(flag == true) ans--;
		}

		ans++;
		sub = s2;
//		cout << "ans2:" << ans << endl;
	}

	cout << ans << endl;

	return 0;
}


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

const ll M = 1e9+7;

ll mypow(ll x, ll n){
        ll result = 1;
        for(ll i = 0; i < n; i++){
                result = result * x % M;
        }
        return result % M;
}

int main(void){
        ll n;
        cin >> n;
        ll ans = (mypow(10, n) - mypow(9, n) * 2 + mypow(8, n)) % M;
        if(ans < 0) ans += M;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,now;
  std::cin >> n;

  std::vector<int> v;
  for (int i = 0; i < n; i++) {
    std::cin >> now;
    v.push_back(now);
  }

  vector<int> v2(n);
  v2=v;
  sort(v2.begin(),v2.end());

  for (int i = 0; i < n; i++) {
    if(v[i]!=v2[v.size()-1])std::cout << v2[v.size()-1] << '\n';
    else std::cout << v2[v.size()-2] << '\n';
  }

  return 0;
}


Measured memory_bytes: 3316
using System;

namespace PrintaFrame
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			while (true)
			{
				string[] data = Console.ReadLine().Split(' ');
				int H = int.Parse(data[0]);
				int W = int.Parse(data[1]);
				if (H == 0 && W == 0)
				{
					return;
				}

				string line = "";
				string line2 = "";
				for (int i = 0,count = W -1; i < W; i++)
				{
					line = line + "#";
					if (i == 0 || i == count)
					{
						line2 = line2 + "#";
					}
					else
					{
						line2 = line2 + ".";
					}
				}

				for (int i = 0,count = H - 1; i < H; i++)
				{
					if (i == 0 || i == count)
					{
						Console.WriteLine(line);
					}
					else
					{
						Console.WriteLine(line2);
					}
				}
				Console.WriteLine();
			}
		}
	}
}

Measured memory_bytes: 5356
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
int main(){
  int n,i;cin>>n;int ans=0;
  vint h(n);
  vint maxi(n);maxi[0]=0;//iまで（i含まず）最大
  for(i=0;i<n;i++){cin>>h[i];if(i){maxi[i]=max(maxi[i-1],h[i-1]);}}
  for(i=0;i<n;i++){if(h[i]>=maxi[i]){ans++;}}
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i=0 ; i<n; ++i)
#define rep2(i, j, n) for(int i=j; i<n; ++i)
using namespace std;
typedef long long ll;
typedef unsigned long ul;


int main(){
    ll N;
    cin>>N;
    vector<ll>x(10000);
    rep2(i, 1, 10){
        rep2(j, 1, 10){
            x[i*j] = 1;
        }
    }
    string ans="No";

    if(x[N]==1)ans="Yes";

cout<<ans<<endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5+10 , M = 5e5+10 ,  MOD = 1e9+7;
const ll OO = 0x3f3f3f3f;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 


    
int main(){
    
 
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
 

    string s , frst = "" , sec = "";
    cin >> s;
    int len = s.length();
    
    if(len&1){
        for(int i = 0 ; i < (len/2) ; ++i)
            frst += s[i];
        for(int i = (len/2)+1 ; i < len ; ++i)
            sec += s[i];
        int nl = frst.length() , cnt = 0;
        reverse(sec.begin() , sec.end());
        for(int i = 0 ; i < nl ; ++i)
            if(frst[i] != sec[i])
                cnt++;

        printf("%d\n",cnt);    
    }
    else{
        for(int i = 0 ; i < (len/2) ; ++i)
            frst += s[i];
        for(int i = (len/2) ; i < len ; ++i)
            sec += s[i];
        int nl = frst.length() , cnt = 0;
        reverse(sec.begin() , sec.end());
        for(int i = 0 ; i < nl ; ++i)
            if(frst[i] != sec[i])
                cnt++;

        printf("%d\n",cnt);

    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
int main() {
  ios_base::sync_with_stdio(false);
  int n, d;
  cin >> n >> d;
  d = d + d + 1;
  cout << (n + d - 1) / d << endl;
}


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

ll mod;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

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

ll modpow(ll a, ll n, ll m) {
  ll result = 1;

  while (n > 0) {
    if (n & 1) result = result * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return result;
}

int f(int n, int count) {
  if (n == 0) return count;
  return f(n % __builtin_popcount(n), count + 1);
}

mint getrem(string X, ll icount) {
  mint rem = 0;
  for (int i = 0; i < X.size(); i++) {
    if (X[i] == '1') {
      rem += modpow(2, X.size() - i - 1, icount);
    }
  }
  return rem;
}

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

  ll icount = 0;

  rep(i, N) {
    if (X.at(i) == '1') icount++;
  }

  mod = icount - 1;
  if (mod == 0) mod = 1;  // foo
  mint lessrem = mod > 0 ? getrem(X, mod) : 0;
  mod = icount + 1;
  mint morerem = getrem(X, icount + 1);

  rep(i, N) {
    mod = 1;  // foo
    mint rem;
    if (X.at(i) == '1') {
      rem = lessrem;
      mod = icount - 1;
      if (mod == 0) {
        cout << 0 << endl;
        continue;
      }
      rem -= modpow(2, X.size() - i - 1, mod);
    } else {
      rem = morerem;
      mod = icount + 1;
      rem += modpow(2, X.size() - i - 1, mod);
    }

    cout << f(rem.x, 0) + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3908
#include<iostream>
using namespace std;
int main(){
  string s;
  string j;
  cin>>s;
  cin>>j;
  if((s[0]==j[2]&&s[2]==j[0])&&s[1]==j[1]){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
}
  


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1176&lang=jp
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60
void initialize();
void calc_Sum();
pair<int,int> dfs(int sy, int sx, int ty, int tx);
int h, w, s;
int u[33][33];
int Sum[33][33][33][33];
pair<int, int> dp[33][33][33][33];

void initialize() {
	for (int i = 0; i < 33;i++)for (int j = 0; j < 33;j++)u[i][j] = 0;
	for(int i = 0;i < 33;i++)
		for(int j = 0; j < 33;j++)
			for(int k = 0; k < 33;k++)
				for (int l = 0; l < 33;l++) {
					Sum[i][j][k][l] = 0;
					dp[i][j][k][l] = { -1,-1 };
				}
}

void calc_Sum() {
	for (int sy = 0; sy < h;sy++) {
		for (int sx = 0; sx < w;sx++) {
			for (int ty = sy; ty < h; ty++) {
				for (int tx = sx; tx < w;tx++) {
					if (sy == ty && sx == tx) { Sum[sy][sx][ty][tx] = u[ty][tx]; continue; }
					if (sy == ty) { Sum[sy][sx][ty][tx] = Sum[sy][sx][ty][tx - 1] + u[ty][tx]; continue; }
					if (sx == tx) { Sum[sy][sx][ty][tx] = Sum[sy][sx][ty - 1][tx] + u[ty][tx]; continue; }
					Sum[sy][sx][ty][tx] = Sum[sy][sx][ty - 1][tx] + Sum[sy][sx][ty][tx - 1] 
												- Sum[sy][sx][ty - 1][tx - 1] + u[ty][tx];
				}
			}
		}
	}
}

pair<int, int> dfs(int sy, int sx, int ty, int tx) {
	if (dp[sy][sx][ty][tx].first != -1 && dp[sy][sx][ty][tx].second != -1) return dp[sy][sx][ty][tx];

	int demand = Sum[0][0][h - 1][w - 1] - Sum[sy][sx][ty][tx];
	if (demand > s) return dp[sy][sx][ty][tx] = make_pair(0, -1);
	auto ret = make_pair(1, demand);

	/* horizontal */
	for (int i = sy;i < ty;i++) {
		auto c1 = dfs(sy, sx, i, tx), c2 = dfs(i + 1, sx, ty, tx);
		if (c1.first == 0 || c2.first == 0)continue;
		auto x = make_pair(c1.first + c2.first, max(c1.second, c2.second));
		if (ret.first < x.first) {
			ret = x; continue;
		}
		if (ret.first == x.first) {
			if (ret.second > x.second) {
				ret = x; continue;
			}
		}
	}

	/* vertical */
	for (int i = sx; i < tx; i++) {
		auto c1 = dfs(sy, sx, ty, i), c2 = dfs(sy, i + 1, ty, tx);
		if (c1.first == 0 || c2.first == 0)continue;
		auto x = make_pair(c1.first + c2.first, max(c1.second, c2.second));
		if (ret.first < x.first) {
			ret = x; continue;
		}
		if (ret.first == x.first) {
			if (ret.second > x.second) {
				ret = x; continue;
			}
		}
	}
	return dp[sy][sx][ty][tx] = ret;
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	while (cin >> h >> w >> s, h | w | s) {
		initialize();
		for (int i = 0;i < h;i++)for (int j = 0; j < w;j++)cin >> u[i][j];
		calc_Sum();
		auto ans = dfs(0, 0, h - 1, w - 1);
		cout << ans.first << " " << s - ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 16992
h, w = map(int, input().split())
s = ['.'*(w+2)] + ['.' + input() + '.' for _ in range(h)] + ['.'*(w+2)]

for i in range(1,h+1):
    ans = ''
    for j in range(1,w+1):
        if s[i][j] != '#':
            ans += str([s[i-1][j], s[i+1][j], s[i][j-1], s[i][j+1], s[i+1][j+1], s[i-1][j+1], s[i-1][j-1], s[i+1][j-1]].count('#'))
        else:
            ans += '#'
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, V;
int M, SM;

int T[22][MAX_N];
int nex[22][MAX_N];

int dp[(1 << 22)], rdp[(1 << 22)];
int ok[MAX_N];

vector<ll> v;
ll A[MAX_N];

void pre(int dp[MAX_N]) {
	rep(i, 0, M) {
		rep(j, 0, N - 1) {
			T[0][j] = (abs(A[j + 1] - A[j]) > v[i]) ? j : (j + 1);
		}
		T[0][N - 1] = N - 1;
		rep(q, 0, 20) {
			rep(j, 0, N) {
				T[q + 1][j] = T[q][T[q][j]];
			}
		}
		rep(j, 0, N) {
			nex[i][j] = T[20][j];
		}
	}
	fill(dp, dp + (1 << SM), -1);
	rep(bit, 0, (1 << SM)) {
		if(dp[bit] == N - 1) continue;
		rep(i, 0, SM) {
			if(bit & (1 << i)) continue;
			MAX(dp[bit | (1 << i)], nex[i][dp[bit] + 1]);
		}
	}
	rep(bit, 0, (1 << SM)) {
		if(dp[bit] == N - 1) continue;
		dp[bit] = nex[SM][dp[bit] + 1];
	}
}

void solve() {
	cin >> N >> V;
	rep(i, 0, N) cin >> A[i];
	while(V >= 1) {
		v.pb(V);
		V /= 2;
	}
	v.pb(0);
	M = sz(v);
	SM = M - 1;

	reverse(all(v));
	
	pre(dp);

	reverse(A, A + N);
	pre(rdp);

	rep(bit, 0, (1 << SM)) rdp[bit] = N - 1 - rdp[bit];

	rep(bit, 0, (1 << SM)) {
		int rbit = (1 << SM) - 1 - bit;
		int l = dp[bit], r = rdp[rbit];
		l++;
		if(l > r) {
			ok[l]--;
			ok[r]++;
		}
	}
	rep(i, 0, N) {
		ok[i + 1] += ok[i];
		if(ok[i]) cout << "Possible\n";
		else cout << "Impossible\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            // 写経
            var HW = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long H = HW[0], W = HW[1];
            var ans = long.MaxValue;

            for (var k = 0; k < 2; k++)
            {
                for (var i = 1; i < H; i++)
                {
                    // T時に分割した時
                    var a = i * W;
                    var b = (W / 2) * (H - i);
                    var c = (W - (W / 2)) * (H - i);
                    ans = Math.Min(ans, Math.Abs(Math.Max(Math.Max(a, b), c) - Math.Min(Math.Min(a, b), c)));

                    // 同じ方向に3分割した時
                    b = W * ((H - i) / 2);
                    c = W * (H - (((H - i) / 2) + i));
                    ans = Math.Min(ans, Math.Abs(Math.Max(Math.Max(a, b), c) - Math.Min(Math.Min(a, b), c)));
                }

                Swap(ref H, ref W);
            }

            Console.WriteLine(ans);
        }

        static void Swap<T>(ref T one, ref T two)
        {
            var temp = one;
            one = two;
            two = temp;
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#define REP(i,a) for(int i = 0; i < (a); i++)
using namespace std;

#define M 1046527

string H[M];

int getChar(char ch){
	if(ch == 'A') return 1;
	else if(ch == 'C') return 2;
	else if(ch == 'G') return 3;
	else if(ch == 'T') return 4;
	else return 0;
}

int getKey(string str){
	int sum = 0, p = 1;
	REP(i,str.length()){
		sum += p * getChar(str[i]);
		p *= 5;
	}
	return sum;
}

int h1(int key){
	return key % M;
}

int h2(int key){
	return 1 + key % (M - 1);
}

int find(string str){
	int key,hash;
	key = getKey(str);
	for(int i = 0; ; i++){
		hash = (h1(key) + i * h2(key)) % M;
		if(H[hash] == str) return 1;
		else if(H[hash].length() == 0) return 0;
	}
	return 0;
}

int insert(string str){
	int key,hash;
	key = getKey(str);
	for(int i = 0; ; i++){
		hash = (h1(key) + i * h2(key)) % M;
		if(H[hash] == str) return 1;
		else if(H[hash].length() == 0){
			H[hash] = str;
			return 0;
		}
	}
	return 0;
}

int main(){
	int n;
	cin >> n;
	string com[n],str[n];
	REP(i,n) cin >> com[i] >> str[i];
	REP(i,n){
		if(com[i] == "insert") insert(str[i]);
		else{
			if(find(str[i])) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
}


Measured memory_bytes: 126948
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <climits>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int N, K;
    if (scanf("%d%d", &N, &K) < 2) return 0;

    vector<int> a(N);
    for (int i = 0; i < N; i++) if (scanf("%d", &a[i]) < 1) return 0;

    long long ans = LLONG_MAX;
    for (int i = 0; i < (1 << N); i++)
    {
        // 最大で15個の建物
        bitset<15> bs(i);

        if (bs.count() != K) continue;

        // ビットが立っている数がKならば
        long long cost = 0;
        int h = 0;
        for (int i = 0; i < N; i++)
        {
            // 見えていたい建物
            if (bs[i])
            {
                // 史上最高保持
                h = max(a[i], h + 1);

                // コスト足し込み 自分が史上最高ならゼロ
                cost += h - a[i];
            }
            // 史上最高保持
            else h = max(a[i], h);
        }

        // 最小コスト保持
        ans = min(ans, cost);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    REP(i,n){
        cin>>v[i];
    }
    ll max=MAX(v), second=0;
    ll count=0;
    REP(i,n){
        if(v[i]==max){
            count++;
        }
        if(v[i]!=max&&second<v[i]){
            second=v[i];
        }
    }
    if(count>1){
        REP(i,n){
            cout<<max<<endl;
        }
    }else{
        REP(i,n){
            if(v[i]==max){
                cout<<second<<endl;
            }else{
                cout<<max<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3200
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	_ = readInt()
	s, t := readBytes(), readBytes()
	for i := range s {
		fmt.Print(string(s[i]))
		fmt.Print(string(t[i]))
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,a,b,c,k,x;
int main()
{
  for(cin>>n>>m>>x;i<m;i++){
    cin>>a;
    if(a<x)b++;
    else c++;
  }
  cout<<min(b,c)<<endl;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

mid_list = [0]*N
for i in range(N):
    index = bisect.bisect_left(A,B[i])
    if i == 0:
        mid_list[i] = index
    else:
        mid_list[i] = mid_list[i-1] + index

ans = 0
for i in range(N):
    index = bisect.bisect_left(B,C[i])
    if index == 0:
        continue
    ans += mid_list[index-1]

print(ans)

Measured memory_bytes: 24180
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ab(m);
    rep(i, m) {
        int tmp_a, tmp_b;
        cin >> tmp_a >> tmp_b;
        ab[i] = make_pair(tmp_b, tmp_a);
    }
    sort(ab.begin(), ab.end());
    int ans = 0;
    int now = 0;
    rep(i, m) {
        if (now <= ab[i].second) {
            ++ans;
            now = ab[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
   int prime[50000];
   prime[0] = 2;
   prime[1] = 3;
   int ptr = 2;
   for(int num = 5; num <= 50100; num++){
       bool f = false;
       for(int i=0;i<ptr;i++){
           if(prime[i]*prime[i]>num){
               break;
           }
           if(num%prime[i]==0){
               f=true;
               break;
           }
       }
       if(!f){
           prime[ptr++] = num;
       }
   }
   int n;
   while(cin>>n){
       int j=0;
       while(prime[j]<=n){
           j++;
       }
       if(prime[j-1]==n){
           cout<<prime[j-2]<<" "<<prime[j];//printf("%d %d",prime[j-2],prime[j]);
       }else{
           cout<<prime[j-1]<<" "<<prime[j];//printf("%d %d",prime[j-1],prime[j]);
       }
       cout<<endl;
   }
   return 0;
}


Measured memory_bytes: 3008
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=list(map(int,input().split()))
    #区間[i,j)のときのX-Yの最大値
    dp=[[0]*(n+1) for _ in range(n+1)] 
    for length in range(1,n+1): #長さ l=j-i
        for i in range(n-length+1): #区間開始0~n-l
            j=i+length #区間右
            if (n-length)%2==0:#先手:それまでに取った数が偶数 
                dp[i][j]=max(dp[i+1][j]+A[i],dp[i][j-1]+A[j-1])
            else: #後手:取った数が奇数
                dp[i][j]=min(dp[i+1][j]-A[i],dp[i][j-1]-A[j-1])
    print(dp[0][n])

if __name__=='__main__':
    main()

Measured memory_bytes: 112348
#include<bits/stdc++.h>
using namespace std ;
int main () {
	int k ;
	cin >> k ;
	string s ;
	cin >> s ;
	int sz = s.size() ;
	for (int i = 0 ; i < min(k , sz) ; ++i){
		cout << s[i] ;
	} 
	if (sz > k) {
		cout << "..." ;
	}
	return 0 ;
}

Measured memory_bytes: 3628
n, q = map(int, input().split())
l = []
for i in range(n):
  t = []
  for j in input().split():
    t += [j]
  t[1] = int(t[1])
  l += [t]

c = 0
while len(l) > 0:
  if l[0][1] > q:
    l[0][1] -= q
    l += [l[0]]
    l.pop(0)
    c += q
  else:
    c += l[0][1]
    print(l[0][0], c)
    l.pop(0)


Measured memory_bytes: 13784
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
N = inp.shift() * 1
l = inp.shift().split(' ').map(x => +x).sort((a, b) => a - b)
c = 0 
for (i=0; i<N-2; i++) {
  for (j=i+1; j<N-1; j++) {
      if (l[i] == l[j]) {
          continue;
      }
      len = l[i] + l[j]
      for (k=j+1; k<N; k++) {
          if (l[i] == l[k] || l[j] == l[k]) {
              continue;
          }
          if (l[k] < len) {
              c++
          }
      }
  }
}
console.log(c)

Measured memory_bytes: 32544