akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

struct edge{
	int to, dist, cost;
	edge(int t,int d,int c): to(t), dist(d), cost(c) {}
};

int N,M,d[10010];
pi city[10010];
bool ok[10010];
vector<edge> G[10010];

void shortest(){
	
	priority_queue<pi, vector<pi>, greater<pi> > Q;
	fill(d,d+N,INF);
	d[0]=0;
	Q.push(pi(0,0));
	
	while(Q.sz){
		pi p=Q.top();
		Q.pop();
		int v=p.sec;
		if(p.fir > d[v]) continue;
		rep(i,G[v].sz){
			edge e=G[v][i];
			if(d[e.to] > d[v] + e.dist){
				d[e.to] = d[v] + e.dist;
				Q.push( pi(d[e.to], e.to) );
			}
		}
	}
}

int main(){
	while(cin>>N>>M && N){
		
		rep(i,N) G[i].clear();
		
		rep(i,M){
			int u,v,d,c;
			cin>>u>>v>>d>>c;
			u--; v--;
			G[u].pb( edge(v,d,c) );
			G[v].pb( edge(u,d,c) );
		}
		
		shortest();
		
		rep(i,N) city[i] = pi(d[i], i);
		sort(city,city+N);
		fill(ok,ok+N,0);
		ok[0]=1;
		int ans=0;
		
		rep2(i,1,N){
			int v=city[i].sec,mincost=INF;
			rep(j,G[v].sz){
				edge e=G[v][j];
				if(ok[e.to] && d[e.to]+e.dist == d[v]){
					mincost=min(mincost, e.cost);
				}
			}
			ans+=mincost;
			ok[v]=1;
		}
		
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2864
import sys
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

ans=[0]*n
for i in range(n-1):
    ans[a[i]-1]+=1
for i in range(n):
    print(ans[i])


Measured memory_bytes: 49860
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    stack<char> st;
    rep(i,0,s.size()){
        if(s[i] == '0'){
            st.push('0');
        }else if(s[i] == '1'){
            st.push('1');
        }else{
            if(!st.empty()){
                st.pop();
            }
        }
    }
    string ans = "";
    while(!st.empty()){
        ans += st.top();
        st.pop();
    }
    reverse(ans.begin(), ans.end());
    print(ans);
}


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

void Solve02()
{
    int n;
    cin >> n;
    long long a;
    long long minus_sum = 0;
    long long a_min = 1e9;
    long long sum = 0;
    for (int i = 1; i < n + 1; i++)
    {
        cin >> a;
        if (a < 0)
        {
            minus_sum++;
            a = -a;
        }
        a_min = min(a_min, a);
        sum += a;
    }
    if (minus_sum % 2 == 1)
    {
        sum -= a_min * 2;
    }

    cout << sum << endl;
}

int main()
{
    Solve02();
}

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

using namespace std;

int main() {
	int n, i, j, x, total = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x;
		if (x == 2) total++;
		if (x % 2 != 0) {
			for (j = 3; j <= (double)sqrt(x); j+=2){
				if (x%j == 0) goto a;
			}
			total++;
		a:;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 1160
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n, a, b, p, ans;

int main() {
    fast_io; cout_precision;
    cin >> n >> a >> b >> p;
    ans = 0;
    for (ll i = 1, x; i < n; i++, p = x) {
        cin >> x;
        ans += min(a * (x - p), b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0] + a[1] == a[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int main(void){
    int n,i;
    scanf("%d",&n);
    int arr[n];
    for(i=0;i<n;i++)
        scanf("%d",&arr[i]);
    int arr2[n];
    for(i=0;i<n;i++)
        arr2[i] = arr[i];
    qsort(arr, n, sizeof(int), compare_int);
    int maxnum = arr[0];
    int second = arr[1];

    for(i=0;i<n;i++) {
        if(arr2[i]!=maxnum)
            printf("%d\n",maxnum);
        else
            printf("%d\n",second);
    }

    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
 
using namespace std;
 
int n, a, b, c;
vector<int> l;
 
int inf = 1e9;
 
int dfs(int v, int aa, int bb, int cc, const vector<int>& l)
{
    int ret = inf;
    if (v == n)
    {
        if (aa > 0 && bb > 0 && cc > 0)
        {
            return (abs(a - aa) + abs(b - bb) + abs(c - cc) - 30);
        }
        return ret;
    }
    for (int i = 0; i < 4; ++i)
    {
        if (i == 0)
        {
            ret = min(ret, dfs(v + 1, aa, bb, cc, l));
        }
        else if (i == 1)
        {
            ret = min(ret, dfs(v + 1, aa + l[v], bb, cc, l) + 10);
        }
        else if (i == 2)
        {
            ret = min(ret, dfs(v + 1, aa, bb + l[v], cc, l) + 10);
        }
        else if (i == 3)
        {
            ret = min(ret, dfs(v + 1, aa, bb, cc + l[v], l) + 10);
        }
    }
    
    return ret;
}
 
int main() {
    
    cin >> n >> a >> b >> c;
    
    l = vector<int>(n, 0);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> l[i];
    }
    
    int ret = dfs(0, 0, 0, 0, l);
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N,C,K = I()
T = [i() for _ in range(N)]
T.sort()
T = deque(T)
ans = [[] for _ in range(N)]
ans[0].append(T.popleft())
now = 0
while T:
    a = T.popleft()
    if len(ans[now]) == C or a-ans[now][0] > K:
        now += 1
    ans[now].append(a)
print(now+1)

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

typedef long long LL;
const int MOD=1e9+7;
const int N=1e5+10;
LL inv[N],fac[N],finv[N];

void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<N;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(LL) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

LL C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}

int a[N],b[N]; 

int main()
{
	make();
	int n,s,t;
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++)
	{
		scanf("%d",&a[i]);
		if(b[a[i]]==0) b[a[i]]=i;
		else {s=b[a[i]];t=i;break;}
	}
	for(int i=1;i<=n+1;i++)
	{
		LL ret=C(n+1,i);
		ret-=C(s+(n-t),i-1);
		if(ret<0) ret+=MOD;
		printf("%lld\n",ret);
	}
	return 0;
}

Measured memory_bytes: 4352
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int[] a = new int [200001];
        for (int i = 0; i < n; i++) a[sc.nextInt()] +=1;

        PriorityQueue<Integer> q = new PriorityQueue<>(200000);
        for (int val: a)
            if (val > 0) q.add(val);
        int ans = 0;
        while (q.size() > k) ans += q.poll();
        System.out.println(ans);
    }
}


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

int main() 
{
    ll n;
    cin >> n;
    ll minv = 1e18;
    rep(i,5) {
        ll x;
        cin >> x;
        minv = min(minv, x);
    }

    ll cnt = n/minv;
    if (n%minv != 0) cnt++;

    cout << cnt+4 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	 
	if (a % 2 == 0 || b % 2 == 0) cout << "No" << endl;
	else cout << "Yes" << endl;

    return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	int l=a[0], res=0, i=1;
	while(i<n){
		if(a[i]==l){
			res++;
			i++;
			l=a[i];
			i++;
		}
		else{
			l=a[i];
			i++;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn= new Scanner(System.in);
        int N = stdIn.nextInt();
        int M = stdIn.nextInt();
        int [] a=new int[N];
        double sum=0;
        for(int i=0;i<N;i++){
            a[i]=stdIn.nextInt();
            sum=sum+a[i];
        }
        
        int [] b=new int[M];
        int max=0;
        for(int i=0;i<M;i++){
            for(int t=0;t<N;t++){
               if(a[t]>b[i]){
                   b[i]=a[t];
                   max=t;
               }
           }
           a[max]=0;
        }

        
        boolean j=true;
        for(int t=0;t<M;t++){
            if(b[t]<sum/(4*M)){
                j=false;
                break;
            }
        }
        if(j){
             System.out.println("Yes");
        }else{
             System.out.println("No");
        }
       
    }
}

Measured memory_bytes: 35944
import math

n, m = map(int, input().split())
mod = 10 ** 9 + 7


def fact(x):
    return math.factorial(x)


if n == m:
    ans = (fact(n) ** 2) * 2 % mod
elif n == m-1 or n == m + 1:
    ans = fact(n) * fact(m) % mod
else:
    ans = 0
print(ans)

Measured memory_bytes: 5184
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

s = IS()
a = ""
for txt in s:
    if txt != "B":
        a += txt
    else:
        if len(a) != 0:
            a = a[:-1]
print(a)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
  int a[4];
  int b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    int hit = 0;
    int blow = 0;
    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i]) {
        hit++;
        continue;
      } else {
        for (int j = 0; j < 4; j++) {
          if (a[i] == b[j]) {
            blow++;
            continue;
          }
        }
      }
    }
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

int h, w, n, a, b;
ll ans[10];
map<pair<int, int>, int> sq;

int main() {
  cin >> h >> w >> n;
  for (int k = 0; k < n; k++) {
    cin >> a >> b;
    a--; b--;
    for (int j = max(0, a-2); j <= min(a, h-3); j++) {
      for (int i = max(0, b-2); i <= min(b, w-3); i++) {
        pair<int, int> p = make_pair(j, i);
        sq[p]++;
      }
    }
  }
  for (int i = 0; i < 10; i++) ans[i] = 0;
  for (auto x: sq) {
    ans[x.second]++;
  }
  ans[0] = long(h-2)*long(w-2);
  for (int i = 1; i < 10; i++) ans[0] -= ans[i];
  for (int i = 0; i < 10; i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 56576
#include<iostream>
#include<cmath>
using namespace std;
bool pr[50001];
int prime[114514];
int length = 0; 
void insert(int p) { prime[length] = p; pr[p] = true; length++; return; }
int main() {
    insert(2);
    for (int i = 3; i <= 50000; i += 2) {
        for (int j = 0; j < length; j++)
            if (i%prime[j] == 0)goto cont;
            else if (prime[j] > sqrt(i))break;
            insert(i);
        cont:;
    }
    int n;
    while (cin >> n){
        if (!n)return 0;
        int sum = 0;
        for (int i = 2; i <= n / 2; i++)
            if (pr[i] && pr[n - i])
                sum++;
        cout << sum << endl;
    }
}

Measured memory_bytes: 3152
n,m=map(int,input().split())
xlist = list(map(int,input().split()))

xlist.sort()

diflist=[]


for i in range(m-1):
    diflist.append(xlist[i+1]-xlist[i])
diflist.sort()

if n >= m:
    print(0)
else:
    print(sum(diflist[:(m-n)]))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(){
  int n;
  cin>>n;
  ll ans=0;
  vector<int>a(n+1),b(n);
  rep(i,n+1)cin>>a[i];
  rep(i,n)cin>>b[i];
  for(int i=0;i<n;i++){
    int dif =a[i]-b[i];
    if(dif<0){
      ans+=a[i];
      a[i]=0;
      int in=a[i+1];
      a[i+1]+=dif;
      if(a[i+1]<0){
        ans+=in;
        a[i+1]=0;
      }else ans-=dif;
    }else{
      ans+=b[i];
    }
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
  int x=0;
  int N;
  char *s;
  int i=0;
  int max=0;
  scanf("%d",&N);
  s=calloc(N,sizeof(char));
   scanf("%s",s);
  for (i=0;i<N;i++){
 
    if (s[i]=='I'){
      x++;
    }
    if (s[i]=='D'){
      x--;
    }
    if (x>max){
      max=x;
    }
    
  }
  printf("%d\n",max);

  return 0;
}


Measured memory_bytes: 128
#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 = 1000010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, Q;
string S;

void solve() {
	cin >> N;
	cin >> S;
	cin >> Q;
	while(Q--) {
		int k; cin >> k;
		ll res = 0;
		int D = 0, M = 0;
		ll cnt = 0;
		rep(i, 0, k) {
			if(S[i] == 'D') D++;
			if(S[i] == 'M') {
				M++;
				cnt += D;
			}
			if(S[i] == 'C') res += cnt;
		}
		rep(i, k, N) {
			if(S[i - k] == 'D') {
				D--; cnt -= M;
			}
			if(S[i - k] == 'M') M--;

			if(S[i] == 'D') D++;
			if(S[i] == 'M') {
				M++;
				cnt += D;
			}
			if(S[i] == 'C') res += cnt;
		}
		cout << res << "\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: 1948
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;


 int main()
 {
   string s,t;
   while(cin>>s>>t)
   {
       int min=27,max=-1;
       for(int i=0;i<s.length();i++) if((s[i]-'a')<min) min=s[i]-'a';
       for(int i=0;i<t.length();i++) if((t[i]-'a')>max) max=t[i]-'a';
       if(min<max) cout<<"Yes"<<endl;
       else
       {
         if(min>max) cout<<"No"<<endl;
         else
         {
           int k=0;
           int kk=0;
           for(int i=1;i<s.length();i++) if(s[i]!=s[i-1]) k=1;
           for(int i=1;i<t.length();i++) if(t[i]!=t[i-1]) kk=1;
           if(k||kk) cout<<"No"<<endl;
           else 
           {
             if(s.length()<t.length()) cout<<"Yes"<<endl;
             else cout<<"No"<<endl; 
           }
         }    
       }            
   }
   return 0;
 }
 

        

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
string S,t="ABC";
int main() {
	int cnt=0,n;
	bool F;
	cin>>n>>S;
	for(int i=0;i<S.length();i++) {
		F=true;
		for(int j=0;j<3;j++)
			if(S[i+j]!=t[j])	
				F=false;
		if(F) cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
A, B, C, K = map(int, input().split())
ans = 0
if A > 0:
    ans += min(A, K)
    K = max(0, K - A)
if B > 0:
    K = max(0, K - B)
if C > 0:
    ans -= min(C, K)
print(ans)

Measured memory_bytes: 9132
#include <iostream>
#include <stdio.h>
int main()
{
	int x, y,N;
	std::cin >> x >> y;
	
	if (x % y == 0) {
		std::cout << "-1";
		return 0;
	}
	for (int i = 1;i<100000000;i++)
	{
		N = x * i;
		if (N % y != 0) {
			std::cout << N;
			return 0;
		}
	}
    std::cout << "-1";
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        long K = sc.nextLong();

        long diff = K % 2 == 1 ? B - A : A - B;

        if (diff > 1000000000000000000L) {
            System.out.println("Unfair");
        } else {
            System.out.println(diff);
        }

        return;
    }

}


Measured memory_bytes: 23252
#include<vector>
#include<tuple>
//
class Tree {
public:
  explicit Tree(int n);
  void join(int u, int v, int w);
  int diameter() const;
private:
  struct Edge {int from, to; int weight;};
  struct Farthest {int vertex; int cost;};
  const Farthest diameter_dfs(int current, int previous) const;
  std::vector<std::vector<Edge>> edge_;
};
// ?????????????????????
Tree::Tree(int n) : edge_(n) {}
// ????????????
void Tree::join(int u, int v, int w) {
  edge_[u].push_back({u, v, w});
  edge_[v].push_back({v, u, w});
}
// ??´???
int Tree::diameter() const {
  int v = diameter_dfs(0, 0).vertex;
  return diameter_dfs(v, v).cost;
}
const Tree::Farthest Tree::diameter_dfs(int current, int previous) const {
  Farthest result({current, 0});
  for(const auto& e: edge_[current]) {
    if(e.to == previous) continue;
    auto f = diameter_dfs(e.to, e.from);
    f.cost += e.weight;
    if(result.cost < f.cost) result = f;
  }
  return result;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  Tree tree(n);
  for(int i = 0; i < n - 1; ++i) {
    int s, t, w;
    cin >> s >> t >> w;
    tree.join(s, t, w);
  }
  cout << tree.diameter() << endl;
}

Measured memory_bytes: 12876
n = int(input())
s = []
t = []
for i in range(n):
  s.append(input())
m = int(input())
for i in range(m):
  t.append(input())
ans = 0
for key in s:
  if s.count(key)-t.count(key) > ans:
    ans = s.count(key)-t.count(key)
print(ans)

Measured memory_bytes: 3064
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()
std::set<int> st;
//#define MAX(a,b) if(a>b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<int,int> >());
	sort(pairs.begin(), pairs.end());
    */

 	//stack<int> sta;   
    //queue<int> que;


int main(){
	
	long long N,M,K;
	string s;
    
	//std::cin >> N;
    //std::cin >> N >> M;
    std::cin >> N >> M >> K;
    
	std::vector<long long> v(N);
	//std::vector<long long> w(N);
    //std::cin >> s;
    
    
    // 配列入力
    
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	
	/*
	for(long long i=0; i<N; i++){
		std::cin >> w[i];
	}
	*/
    
    long long sum,sum1;
	sum=0;
	sum1=0;
	int flg,flg1,cnt,cnt1;
	flg=0;
	flg1=0;
	cnt=0;
	cnt1=0;
	long long max;
	int max1;
	max=0;
	max1=0;
	int min;
	int min1;
	min=INF;
	min1=INF;

	int work1,work2,work3,work4;
	work1=0;
	work2=0;
	work3=0;
	work4=0;
	
	//通常
	/*
    for(long long i=0; i<N; i++){
		
	}
	*/
	

	//文字列入力
	/*
	for(long long i=0; i<s.length(); i++){
		
		if(s[i]!='1'){
	}
	*/

	
	
	//ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
    //std::sort(w.begin(),w.end());//昇順ソート
    //std::sort(w.begin(),w.end(),std::greater<long long>());//降順ソート
    /*
    
    //S.substr(i, 5);
    //S.size();
    
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
		if(st.find(v[i])==st.end()){
			st.insert(v[i]);
		}
		else{
			st.erase(v[i]);
		}
	}
	*/


	/*
	int a[4];
	int value;
	value=0;
	
	a[0] = (value % 10); 
	value /= 10;// 1桁目を取り出す
	a[1] = (value % 10); 
	value /= 10;// 2桁目を取り出す
	a[2] = (value % 10); 
	value /= 10;// 3桁目を取り出す
	a[3] = (value % 10); 
	value /= 10;// 4桁目を取り出す
    work1=a[0]+10*a[1];
    work2=a[2]+10*a[3];
    */
	
	
    if(N==1){
    	printf("%d",abs(v[0]-K));
    	//printf("%lld",N);
    	//puts("Yes");
    	//printf("%d",st.size());
    	//文字列の出力
    	//std::cout << s << std::endl;
    	//printf("%.12f\n",ret);
    	//cout << sum << endl;
	}
	else{
		printf("%d",MAX(abs(v[N-2]-v[N-1]),abs(v[N-1]-K)));
	}
	return 0;
}


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


void solve(long long K, long long N, std::vector<long long> A){
    ll ans = K - A.front() - (K - A.back());
    for(ll i = 1; i < N; ++i){
        ans = min(ans, K - (A.at(i) - A.at(i - 1)));
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
int i=0,j=0,a[1000],p=0,key=0,n=0;
scanf("%d",&p);
for(i=0;i<p;i++){
scanf("%d",&a[i]);
}
for(n=0;n<p-1;n++){
printf("%d ",a[n]);
}
printf("%d\n",a[n]);
for(i=1;i<p;i++){
key=a[i];
j=i-1;
while(j>=0 && a[j]>key){
a[j+1]=a[j];
j--;
a[j+1]=key;
}
for(n=0;n<p-1;n++){
printf("%d ",a[n]);
}
printf("%d\n",a[n]);
}
return 0;
}


Measured memory_bytes: 2144
# input
N, K = map(int, input().split())

d = []
A = []
for i in range(K):
    dn = int(input())
    An = list(map(int, input().split()))
    d.append(dn)
    A.append(An)

check = []
for a in A:
    check = list(set(check + a))

print(N - len(check))

Measured memory_bytes: 9312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll p = 1000000007;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    ll dp[n][k+1];
    memset(dp,0,(n*(k+1))*sizeof(ll));
    dp[0][0] = 1;
    for(ll i = 1;i <= a[0];i++){
        dp[0][i] = dp[0][i-1]+1;
    }
    for(ll i = a[0]+1;i <= k;i++){
        dp[0][i] = dp[0][i-1];
    }
    for(ll i = 1;i < n;i++){
        dp[i][0] = 1;
    }
    for(ll i = 1;i < n;i++){
        for(ll j = 1;j <= k;j++){
            dp[i][j] = dp[i][j-1];
            if(j > a[i]){
                dp[i][j] = (dp[i][j]+(dp[i-1][j]-dp[i-1][j-a[i]-1])%p)%p;
            }
            else{
                dp[i][j] = (dp[i][j]+dp[i-1][j])%p;
            }
        }
    }
    ll ans;
    if(k == 0){
        ans = dp[n-1][k];
    }
    else{
        ans = (dp[n-1][k]-dp[n-1][k-1])%p;
    }
    if(ans < 0){
        ans += p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 78336
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        //出力を早くする
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()){AutoFlush=false});
        var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int h = hw[0];
        int w = hw[1];
        for(int i=0; i<h; i++)
        {
            string line = Console.ReadLine();
            for(int n=0; n<2; n++)
            {
                Console.WriteLine(line);
            }
        }
        Console.Out.Flush();
    }
}


Measured memory_bytes: 2904
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=0;
	}
	int A=0,B=0,c;
	int mx=0;
	for(int i=0;i<n;i++){
		mx=0;
		for(int j=0;j<n;j++){
			if(a[j]>mx){
				mx=a[j];
				c=j;
			}
		}
		if(i%2==0){
			A=A+mx;
			a[c]=0;
		}
		else{
			B=B+mx;
			a[c]=0;
		}
	}
	cout<<A-B;
}

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

int main(void) {
    int N,Z,W;
    cin >> N >> Z >> W;
    int a[N];
    for (int i=0; i<N; i++) cin >> a[i];
    if (N == 1) {
        cout << abs(a[0] - W) << endl;
        return 0;
    }
    cout << max(abs(a[N-1] - W), abs(a[N-1] - a[N-2])) << endl;
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0, cnt = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i-1] && s[i] == s[0] && cnt < k) cnt++;
    else if (s[i] != s[i-1] && cnt == k) ans += i - 1, cnt++;
    else if (s[i] == s[i-1] && cnt == k + 1) ans++;
  }
  if (cnt <= k) ans = n - 1;
  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    int variable = scanner.nextInt();
    int basisNumber = scanner.nextInt();
   
    if (variable < basisNumber) {
        System.out.println(0);
    } else {
    	System.out.println(10);
    }
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int rawPri(int a [],int b [],int al,int bl){
	int am=a[0],bm=b[0];
	for(int i=1;i<al;i++){
		if (a[i]<am){
			am=a[i];
		}
	}
	for(int i=1;i<bl;i++){
		if (b[i]<bm){
			bm=b[i];
		}
	}
	return am+bm;
}


int main(){
	int aln;
	int bln;
	int mln;
	int mm;
	int raw;
	cin>>aln>>bln>>mln;
	int a [100000], b [100000], c [100000], x [100000], y[100000];
	for(int i=0;i<aln;i++){
		cin>>a[i];
	}
	for(int i=0;i<bln;i++){
		cin>>b[i];
	}
	for(int i=0;i<mln;i++){
		cin>>x[i]>>y[i]>>c[i];
	}
	mm = a[x[0]-1]+b[y[0]-1]-c[0];
	for(int i=1;i<mln;i++){
		if(mm>a[x[i]-1]+b[y[i]-1]-c[i]){
			mm=a[x[i]-1]+b[y[i]-1]-c[i];
		}
	}
	raw = rawPri(a,b,aln,bln);
	if(raw<=mm){
		cout<<raw<<endl;
	}else{cout<<mm<<endl;}
}
	

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
typedef long long ll;
typedef pair <int,ll> pii;


int main(void)
{
  int a,b,c,x,money,ans=0;;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> x;
  money=0;
  for(int i=0;i<=a;i++)
    {
      for(int j=0;j<=b;j++)
	{
	  for(int k=0;k<=c;k++)
	    {
	      money=(500*i+100*j+50*k);
	      if(money==x) ans++;
	      money=0;
	    }
	}
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,ans;
	cin>>n;
	if(64<=n){
		ans=64;
	}
	else if(32<=n){
		ans=32;
	}
	else if(16<=n){
		ans=16;
	}
	else if(8<=n){
		ans=8;
	}
	else if(4<=n){
		ans=4;
	}
	else if(2<=n){
		ans=2;
	}
	else if(1<=n){
		ans=1;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 384
N,M = list(map(int, input().split()))
x = list(map(int, input().split()))
x = sorted(x)
#N-1個の隙間は通らなくて済む

bet = [] #iとi+1の間隔
for i in range(1,M):
  bet.append(x[i]-x[i-1])

if N == 1:
  print(max(x)-min(x))
elif N>=M:
  print(0)
else:
  bet = sorted(bet)
  print(sum(bet[:M-N]))

Measured memory_bytes: 13968
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
vector< ll > z_algorithm(const string &s) {
    vector< ll > prefix(s.size());
    for(ll i = 1, j = 0; i < s.size(); i++) {
        if(i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        }else{
            ll k = max(0LL, j + prefix[j] - i);
            while(i + k < s.size() && s[k] == s[i + k]) ++k;
            prefix[i] = k;
            j = i;
        }
    }
  prefix[0] = (ll) s.size();
  return prefix;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll ns = S.size();
    ll ans = 0;
    rep(i,0,ns){
        string st = S.substr(i, ns-i) + '$' + S;
        // print(st);
        vector<ll> za = z_algorithm(S.substr(i, ns-i) + '$' + S);
        rep(k,ns-i+1, ns-i+1+ns){
            ll p1 = i, p2 = k - (ns-i+1);
            if(p1 == p2) continue;
            if(abs(p1-p2) < za[k]) continue;
            ans = max(ans, za[k]);
        }
    }
    print(ans);

    
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int a, b;
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> a >> b;
    cout << max(max(a+b, a-b), a*b) << endl;

}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  string s[h];
  rep(i, 0, h){
    rep(j, 0, w){
      if((i < b and j < a) or (i >= b and j >= a)){
        cout << 1;
      }else{
        cout << 0;
      }
    }
    cout << endl;
  }

  return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
string s;
  cin >> s;
  if(s == "Sunny")
  {
    cout << "Cloudy";
  }
  else if(s == "Cloudy")
  {
    cout << "Rainy";
  }
  else
  {
    cout << "Sunny";
  }
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int q,t,f;
  string c;
  cin>>q;
  bool opposite = false;
  int rev = 0;
  vector<string>bef,af;
  while(q--)
  {
    cin>>t;
    
    if(t==1)
      {
          rev++;
          if(rev%2==0)
           opposite = false;
          else
            opposite =true;
      }
    else
    {
       cin>>f>>c;
       //cout<<t<<" -- "<<f<<" -- "<<c<<endl;
      if(opposite)
      {
          if(f==2)
          {
             bef.push_back(c);
          }
          else
          {
              af.push_back(c);
          }
      }
      else
      {
          if(f==2)
          {
              af.push_back(c);
          }
          else
          {
              bef.push_back(c);
          }
      }
    }
    
  }
  if(rev%2==1)
   {
       for(int i = af.size()-1;i>=0;i--)
       cout<<af[i];
       for(int i =s.length()-1;i>=0;i--)
        cout<<s[i];
        for(int i =0;i<bef.size();i++)
        cout<<bef[i];
        return 0;
   }
  
  for(int i =bef.size()-1;i>=0;i--)
  cout<<bef[i];
  cout<<s;
  for(int  i =0;i<af.size();i++)
  cout<<af[i];
}

Measured memory_bytes: 11760
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

//ABC131
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int n; cin>>n;
    vector<P> vec(n);
    rep(i,n)cin>>vec[i].second>>vec[i].first;
    sort(all(vec));

    int sum=0;
    rep(i,n){
        int b=vec[i].first;
        int a=vec[i].second;
        sum+=a;
        if(sum>b){
            cout<<"No"<<endl; return 0;
        }
    }
    cout<<"Yes"<<endl;

}

Measured memory_bytes: 3456
import copy
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
B = copy.deepcopy(A)

for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][k] + A[k][j] < A[i][j]:
                A[i][j] = A[i][k] + A[k][j]

flag = True
for i in range(N):
    for j in range(N):
        if A[i][j] != B[i][j]:
            flag = False
            break
    if not flag:
        break

if not flag:
    print(-1)
    exit()


for i in range(N):
    for j in range(N):
        for k in range(N):
            if i == k or j == k:
                continue
            if A[i][k] + A[k][j] == A[i][j]:
                B[i][j] = 0
print(sum(map(sum, B))//2)


Measured memory_bytes: 57052
N, A, B = map(int, input().split())
H = [int(input()) for i in range(N)]
H.sort(reverse=True)

def f(k):
    n = 0
    for h in H:
        if h <= B * k:
          break
        h -= B * k
        n += (h - 1) // (A - B) + 1
        if n > k:
            return False
    return True

hi = max(H)
lo = 0
while hi - lo > 1:
    m = (hi + lo) // 2
    if f(m):
        hi = m
    else:
        lo = m
print(hi)


Measured memory_bytes: 7444
n = int(input())
argList = list(map(int, input().split()))
argList.sort()
argList.reverse()
a=0
b=0

for i in range(0, n):
    if i % 2 == 0:
        a+=argList[i]
    else:
        b+=argList[i]
print(a-b)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	string s;
	cin >> s;
	if(s.size() % 2 == 1)
		return cout << "No\n", 0;
	for(int i = 0; i < s.size(); i += 2)
	{
		if(s[i] == 'h' && s[i + 1] == 'i');
		else
			return cout << "No\n", 0;
	}
	cout << "Yes\n";





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k; cin>>n>>k;
	vector<int> v(n+1);
	for(int i=1;i<=n;i++)
		cin>>v[i];
	vector<int> cost(n+1,INT_MAX);
	cost[1]=0;
	for(int i=2;i<=n;i++){
		for(int j=i-1;j>=1 && j>=i-k;j--){
			cost[i]=min(cost[i],cost[j]+abs(v[j]-v[i]));
		}
	}
	cout<<cost[n];
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            char[] S = sc.next().toCharArray();
            char[] T = sc.next().toCharArray();

            char[] U = new char[N * 2];
            for (int i = 0; i < N; i++) {
                U[i * 2] = S[i];
                U[i * 2 + 1] = T[i];
            }

            System.out.println(new String(U));
        }
    }

}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll,ll> vll;
typedef pair<ll,ll> pll;

const ll MOD = 1e9+7;
int n;
//# ways first i ppl can be paired with bitmask mask
ll DP[1 << 21];
vector<vi> adj(21, vi (21));

ll solve(int mask) {
	if(DP[mask] != -1) return DP[mask];
	int men = __builtin_popcount(mask);
	DP[mask] = 0;
	M00(i, n) {
		if(adj[men-1][i] && ((1 << i) & mask)) {
			DP[mask] += solve(mask ^ (1 << i));
		}
	}
	DP[mask] %= MOD;
	return DP[mask];
}


int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin >> n;
	M00(i, 1 << 21) DP[i] = -1;
	M00(i, n) M00(j, n) cin >> adj[i][j];

	DP[0] = 0;
	M00(i, n) if(adj[0][i]) DP[1 << i] = 1;

	finish(solve((1 << n) - 1));
}


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

using namespace std;

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

    int a, b; cin >> a >> b;
    if (a > 0 && a < 10 && b > 0 && b < 10) {
        cout << a * b;
    } else {
        cout << -1;
    }

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	string s,t; cin >> s >> t;
	int a, b; cin >> a >> b;
	string u; cin >> u;
	if(s == u) a--;
	else b--;
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
#define A_MAX 1000000
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
int N;

int main() {
 
    for (int i = 2; i <= A_MAX; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
        }
        int j = 0;
        for (int p = 2; ; p = primes[++j]) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 

    char c = getchar_unlocked();
    while (c > 47) {
        N = 10 * N + c - 48;
        c = getchar_unlocked();
    }

    for (int i = 0; i < N; ++i) {
        int x = 0;
        c = getchar_unlocked();
        while (c > 47) {
            x = 10 * x + c - 48;
            c = getchar_unlocked();
        }
        ++a[x];
    }
 
    int is_pairwise_coprime = 1;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = 0;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 13208
extern crate core;

use std::collections::HashMap;
use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize){n;list:#});
    let mut map = HashMap::<Vec<char>, i64>::new();
    for s in list {
        let mut sorted = s.chars().collect::<Vec<_>>();
        sorted.sort();
        if map.contains_key(&sorted) {
            *map.get_mut(&sorted).unwrap() += 1;
        } else {
            map.insert(sorted, 1);
        }
    }

    // 0 0
    // 1 1 + 0
    // 3

    map.into_iter()
        .map(|(_, x)| x)
        .map(|x| (x * (x - 1)) / 2)
        .fold(0, |sum, i| sum + i)
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3\nacornistnt\npeanutbomb\nconstraint\n" => "1\n",
    test2: "2\noneplustwo\nninemodsix\n" => "0\n",
    test3: "5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa\n" => "4\n",
}


Measured memory_bytes: 22712
s=input()
n=len(s)
q=s.count('?')

mod=10**9+7

target='ABC'
ans=0
for i in range(2**3):
    bdp=[1]*(n+1)
    cnt=0
    for j in range(2,-1,-1):
        if (i>>j)&1==1:
            c='?'
            cnt+=1
        else:
            c=target[j]
        
        cdp=[0]*(n+1)
        for k in range(n):
            if s[k]==c:
                cdp[k]=bdp[k+1]
        
        for k in range(n,0,-1):
            cdp[k-1]+=cdp[k]
            cdp[k-1]%=mod
        
        bdp=cdp
    
    if q>=cnt:
        ans+=bdp[0]*pow(3,q-cnt,mod)
        ans%=mod

print(ans)

Measured memory_bytes: 95920