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

int main(){
    string s,t;
    cin >> s >> t;
    int nums[26];
    int numt[26];
    for(int i=0;i<26;i++){
        nums[i] = 0;
        numt[i] = 0;
    }
    int is = '1',it='1';
    for(int i=0;i<s.size();i++){
        if(nums[s[i]-'a'] == 0){
            nums[s[i]-'a'] = is;
            s[i] = is;
            is++;
        }
        else{
            s[i] = nums[s[i]-'a'];
        }


        if(numt[t[i]-'a'] == 0){
            numt[t[i]-'a'] = it;
            t[i] = it;
            it++;
        }
        else{
            t[i] = numt[t[i]-'a'];
        }
    }

    /*cout << s << endl;
    cout << t << endl;*/
    for(int i=0;i<s.size();i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            break;
        }
        if(i == s.size()-1){
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 776
#! python3
# binary_search.py

n = int(input())
S = [int(x) for x in input().split(' ')]
q = int(input())
T = [int(x) for x in input().split(' ')]

def binary_search(t):
    global S
    min_i, max_i = 0, len(S)-1
    i = int((min_i + max_i)/2)
    while min_i <= max_i:
        if t == S[i]:
            return i
            break
        elif t < S[i]:
            max_i = i - 1
        else:
            min_i = i + 1
        i = int((min_i + max_i)/2)
    return None

c = 0
for t in T:
    if binary_search(t) != None:
        c += 1
print(c)



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

int main()
{
	int h,w;
	cin >> h >> w;
	int m;
	cin >> m;
	vector<pair<int,int>> vp(m);
	for(auto &i:vp)cin >> i.first >> i.second;
	for(auto &i:vp)i.first--, i.second--;


	vector<vector<int>> G(h);
	vector<int>yoko(w);
	for(auto &i:vp)yoko[i.second]++;
	multiset<int> mst;
	for(int i = 0;i<w;i++)mst.insert(yoko[i]);
	ll ans =0;
	for(auto &i:vp)
	{
		G[i.first].push_back(i.second);
	}
	for(int i = 0;i<h;i++)
	{
		multiset<int> onmst;
		for(int j = 0;j<G[i].size();j++)
		{
			onmst.insert(yoko[G[i][j]]);
			mst.erase(mst.find(yoko[G[i][j]]));
		}
		ll yokosum = G[i].size();
		if(mst.size())ans = max(*mst.rbegin()+yokosum,ans);
		if(onmst.size())ans = max(*onmst.rbegin()+yokosum-1,ans);
		for(int j = 0;j<G[i].size();j++)
		{
			mst.insert(yoko[G[i][j]]);
		}

	}


	cout<<ans<<endl;
}


Measured memory_bytes: 43164
#include<iostream>
#include<string>
#include<stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<algorithm>
#include<vector>
using namespace std;

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

Measured memory_bytes: 256
import numpy as np
N = int(input())
V = np.array(list(map(int,input().split())))	#1 2 3 4 5 ... n  li=[1,2,3,4,5,...,n]
C = np.array(list(map(int,input().split())))	#1 2 3 4 5 ... n  li=[1,2,3,4,5,...,n]
diff = V - C
sum = 0
for i in range(N):
    if diff[i] > 0:
        sum += diff[i]
print(sum)


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

const int maxzeni = 10000;

int dp[102][10001];
int pp[102];
int reals[102];

int money[102][10001];

void update2(int &a,int b,int &c,int d){
    if(a < b){
        a = b;
        c = d;
    }
    else if(a == b){
        if(c > d || c < 0) c = d;
    }
}

void update(int i,int zeni,int c,int real){
    int val = dp[i][zeni];
    //cout << "i:"<<i << "zeni:"<<zeni << "reals:"<< real <<endl;
    update2(dp[i+1][zeni],val,money[i+1][zeni],money[i][zeni]);

    if(zeni - c >= 500){
        update2(dp[i+1][zeni - c - 500],val+1,money[i+1][zeni - c - 500],money[i][zeni]+real);
    }

    if(1000 - c >= 500 && (1000 - c - 500+ zeni) <= maxzeni){
        update2(dp[i+1][1000 - c - 500 + zeni],val+1,money[i+1][1000 - c - 500+zeni],money[i][zeni]+real);
    }

    else{
        if(1000 + zeni - c >= 500 && 1000 + zeni - c <= maxzeni){
            update2(dp[i+1][1000 + zeni - c - 500],val+1,money[i+1][1000 + zeni - c - 500],money[i][zeni]+real);
        }
        else{
            update2(dp[i+1][1000 + zeni - c],val,money[i+1][1000 + zeni - c],money[i][zeni]+real);
        }
    }

}

int main()
{
    int p;
    while(scanf("%d",&p)&&p){
        memset(dp,-1,sizeof(dp));
        memset(money,-1,sizeof(money));
        _for(i,0,p) {
            scanf("%d",&pp[i]);
            reals[i] = pp[i];
            pp[i] %= 1000;
            if(pp[i] == 0) pp[i] = 1000;
        }

        dp[0][0] = 0;
        money[0][0] = 0;

        _for(i,0,p){
            _for(j,0,maxzeni){
                if(dp[i][j] >= 0){
                    update(i,j,pp[i],reals[i]);
                }
            }
        }

        int maxcoin = 0;
        int min_cost = 0;
        _for(j,0,maxzeni){
            if(dp[p][j] >= maxcoin){
                //cout << j <<" "<< money[p][j] <<endl;
                if(dp[p][j] > maxcoin){
                    maxcoin = dp[p][j];
                    min_cost = money[p][j];
                }
                else{
                    min_cost = min(min_cost,money[p][j]);
                }
            }
        }
        cout << maxcoin <<" "<<min_cost << endl;

    }
    return 0;
}


Measured memory_bytes: 11108
def gcd(x, y)
  if(y == 0)
    return x
  else
    return gcd(y, x%y)
  end
end

while data = gets
  a, b = data.chomp.split
  a, b = a.to_i, b.to_i
  g = gcd(a, b)
  l = (a*b)/g
  print g, " ", l, "\n"
end



Measured memory_bytes: 6836
#include <iostream>
using namespace std;
int n;
long long a[100000],b[100000];
long long ans,m;
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    for(int i=n-1;i>=0;i--){
        a[i]+=ans;
        ans+=(b[i]-(a[i]%b[i]))%b[i];
    }
    cout<<ans;
    return 0;
}

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

int main(){
	char input[8];
	int minNum, maxNum;
	int num;

	cin >> num;
	for(int i=0; i < num; i++){
		cin >> input;
		sort(input, input+8);
		minNum = atoi(input);
		sort(input, input+8 , greater<int>());
		maxNum = atoi(input);
		cout << maxNum - minNum << endl;
	}
}

Measured memory_bytes: 1192
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.print(s.charAt(0));
        System.out.print(s.length() - 2);
        System.out.print(s.charAt(s.length()-1));     
	}
}


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

int main()
{
    long long n, i, count=0, z;
    cin>>n;
    vector <long long> x;

    for(i=1; i<=n; i++)
    {
        z = to_string(i).length();
        if(z%2!=0)
        {
            count++;
        }
    }

    cout<<count;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int k, ans;
int main(){
	scanf("%d", &k);
	rep(i,k) rep(j,k){
		int t = gcd(i+1,j+1);
		rep(l,k) ans += gcd(t,l+1);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<lint> p(a), q(b), r(c);
    for (int i = 0; i < a; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < b; ++i) {
        cin >> q[i];
    }
    for (int i = 0; i < c; ++i) {
        cin >> r[i];
    }
    sort(p.begin(), p.end(), greater<>());
    sort(q.begin(), q.end(), greater<>());
    sort(r.begin(), r.end(), greater<>());
    deque<lint> rg;
    for (int i = 0; i < x; ++i) {
        rg.push_back(p[i]);
    }
    for (int i = 0; i < y; ++i) {
        rg.push_back(q[i]);
    }
    for (int i = 0; i < c; ++i) {
        rg.push_back(r[i]);
    }
    sort(rg.begin(), rg.end(), greater<>());
    lint ret = 0;
    for (int i = 0; i < x + y; ++i) {
        ret += rg[i];
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 4864
#include <iostream>
using namespace std;
int a, b, c, k, m, s=1;
int main() {
	cin>>a>>b>>c>>k;
	while(k--) s *= 2;
	m = max(a,max(b,c));
	cout<<s*m + a+b+c-m;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(float,input().split()))

dp = [[0 for j in range(i+1)] for i in range(N+1)]
dp[0][0] = 1

for i in range(N) :
    for j in range(i+1) :
        dp[i+1][j+1] += dp[i][j] * P[i]
        dp[i+1][j] += dp[i][j] * (1 - P[i])

ans = 0
for i in range(N+1) :
    if i > N/2 :
        ans += dp[N][i]
print(ans)


Measured memory_bytes: 150664
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n;
	cin >> n;
	cout << (n + 1) * n / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
static const ll MOD = 1e9+7;

ll modfac(ll a, ll b){
    ll ans = 0;
    for(int i = 0; i < b; i++){
        ans += a;
        a %= MOD;
    } //cout << ans << endl;
    return ans;
}


int main(){
    ll N; cin >> N;
    ll ans = 1;
    int C[1005]; for(int i = 0; i <= N; i++) C[i] = 0;
    for(int n = 2; n <= N; n++){
        bool flag = true;
        int num = n;
        //cout << num << " ";
        for(int i = 2; i * i <= n; i++){
            if(num == 1) break;
            while(num % i == 0){
                flag = false;
                //cout << n << " " << i << endl;
                num /= i;
                C[i]++;
                //cout << "y" << endl;
            }
            //cout << 1 << endl;

        }
        //cout << num << endl;
        
        if(flag) C[num]++;
        else C[num]++;
    }
    for(int i = 2; i <= N; i++){
        if(C[i] != 0){
            ans = modfac(ans, C[i]+1);
            ans %= MOD;
        }
    }
    //for(int i = 0; i <= N; i++) cout << C[i] << endl;
        
    cout << ans << endl;
}

Measured memory_bytes: 256
O = list(input())
E = list(input())
flag = 0
if len(O) != len(E) :
    flag += 1
answer = ""
if flag == 0 :
    for i in range(len(O)) :
        answer += O[i]
        answer += E[i]
else :
    for i in range(len(E)) :
        answer += O[i]
        answer += E[i]
    answer += O[-1]
print(answer)


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

int minimum(int min[],int k,int n,int arr[],int i)
{
    int range;
    vector<int> a;
    if(i+k>n-1)
    {
        range=n-1;
    }
    else
    {

        range=i+k;
    }
    for(int j=range;j>i;j--)
    {
        a.push_back(abs(arr[j]-arr[i])+min[j]);
    }
    return *min_element(a.begin(),a.end());
}
int findmin(int n,int k,int arr[])
{
    int min[n];

    min[n-1]=0;
    min[n-2]=abs(arr[n-1]-arr[n-2]);

    for(int i=n-3;i>=0;i--)
    {
        min[i]=minimum(min,k,n,arr,i);
    }
    return min[0];
}
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    {
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
    }
    int ans;
    ans=findmin(n,k,arr);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
  int n;
  while(cin >> n , n){
    char dic[256];
    fill(dic , dic + 256 , 0);
    for(int i = 0; i < n; i++){
      char c;
      cin >> c;
      cin >> dic[c];
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++){
      char c;
      cin >> c;
      if(dic[c] == 0){
        cout << c;
      } else {
        cout << dic[c];
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
#define MAX 1000001
#define MAXN 200001
#define mod 1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,sum=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    sum=sum-a[n-1];
    if(a[n-1]<sum){
            cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
#define endl "\n"
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define mem(a,b) memset((a),(b),sizeof (a))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF long long(1e18)
#define MOD 1000000007


void solve(){
	int k,n;
	cin>>k>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	vector<int> dis;
	dis.push_back(k-arr[n-1]+arr[0]);
	for(int i=1;i<n;i++){
		dis.push_back(arr[i]-arr[i-1]);
	}	
	sort(dis.begin(),dis.end());
	int sum=0;
	for(int i=0;i<dis.size()-1;i++){
		sum+=dis[i];
	}
	cout<<sum<<endl;
}

int32_t main(){
    int t=1;
    while(t--)
        solve();
    return 0;
}




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

using namespace std;

int N;
int DataInfo[3];
set<int> CommonDivi;

int getGcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return getGcd(b, a%b);
}

void solve(int gcd) {
	int limit;
	set<int>::iterator pos;

	limit = gcd / 2;
	for (int i = 2; i < limit; ++i) {
		if (gcd%i == 0) {
			CommonDivi.insert(i);
			CommonDivi.insert(gcd / i);
		}
	}

	for (pos = CommonDivi.begin(); pos != CommonDivi.end(); ++pos) {
		cout << *pos << endl;
	}
}

int main() {
	int gcd;

	CommonDivi.insert(1);
	cin >> N >> gcd;
	for (int i = 1; i < N; ++i) {
		cin >> DataInfo[i];
		gcd = getGcd(gcd, DataInfo[i]);
	}
	//cout << "="<<gcd << endl;
	CommonDivi.insert(gcd);
	solve(gcd);

	return 0;
}


Measured memory_bytes: 3124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int W = cin.nextInt();
		int H = cin.nextInt();
		int N = cin.nextInt();
		int migi = W, hidari = 0, ue = H, shita = 0;
		for (int i = 0; i < N; i++)
		{
			int x = cin.nextInt();
			int y = cin.nextInt();
			int a = cin.nextInt();
			if (a == 1)
			{
				hidari = Math.Max(hidari, x);
			}
			else if (a == 2)
			{
				migi = Math.Min(migi, x);
			}
			else if (a == 3)
			{
				shita = Math.Max(shita, y);
			}
			else if (a == 4)
			{
				ue = Math.Min(ue, y);
			}
		}
		Console.WriteLine(Math.Max((migi - hidari), 0) * Math.Max((ue - shita), 0));
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 2776
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll N;
    scanf("%lld", &N);
    vector<ll> A(N);
    for (ll i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }

    sort(A.begin(), A.end());

    ll except = 0;
    ll mod2 = 0;
    ll j = 0;
    for (ll i = 0; i < N; i++)
    {
        j++;

        if (i == N - 1 || A[i] != A[i + 1])
        {
            if (j > 0 && j % 2 == 0)
            {
                mod2++;
            }
            if (j > 2)
            {
                except += (j - 1) / 2;
            }

            j = 0;
        }
    }
    except += mod2 / 2;
    if (mod2 % 2 == 1)
        except++;
    printf("%lld", N - except * 2);
}


Measured memory_bytes: 1024
num=list(map(int,input().split()))
num_set=[]

while num[0]!=0 or num[0]!=0:
    num[0]=[i for i in range(1,num[0]+1)]
    num_set.append(num)
    num=list(map(int,input().split()))

for i in range(len(num_set)):
    n=num_set[i][0]
    x=num_set[i][1]
    x_count=0
    for j in range(len(n)-2):
        for k in range(j+1,len(n)-1):
            for l in range(k+1,len(n)):
                wa=n[j]+n[k]+n[l]
                if wa==x:
                    x_count=x_count+1
    print(x_count)
    



Measured memory_bytes: 5600
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



int main() {
	string s, t;
	cin >> s >> t;
	bool ok = true;
	map<char, char> ma, ima;
	rep(i, s.size()) {
		char S = s[i], T = t[i];
		if (ma.count(S)) if (ma[S] != T) ok = false;
		if (ima.count(T)) if (ima[T] != S) ok = false;
		ma[S] = T; ima[T] = S;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;
int n, cnt1, cnt2;
int main(){
cin >> n;

int ai;

for(int i = 1; i <= n; ++i) {
    cin >> ai;  
    if(ai % 2 == 0) {cnt1++;}
    else {cnt2++;}
}

if(cnt2 % 2 != 0) {cout << "NO";}
else {cout << "YES";}

return 0;
}



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

int main()
{
    int N; cin >> N;
    vector<int> d(N);
    int sum = 0;

    for(int i = 0; i < N; i++) {
        cin >> d[i];
        sum += d[i];
    }

    int ans = 0;
    for(int i = 0; i < N; i++)
        ans += (sum-d[i])*d[i];
    ans /= 2;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2 << '\n';
		return 0; 
	}
	ll a2 = a, b2 = b;
	ll ans1 = a2 - 1;
	b2 -= a2 - 1;
	a2 = 1;
	++ans1;
	--b2;
	ans1 += (b2 - a2) / 2;
	
	
	a2 = a, b2 = b;
	ll ans2 = n - b2;
	a2 += n - b2;
	b2 = n;
	++ans2;
	++a2;
	ans2 += (b2 - a2) / 2;
	cout << min(ans1, ans2) << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if (a<=8 && b<=8) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    if(n%2==1){
        cout << b[n/2]-a[n/2]+1 << endl;
    }
    else{
        cout << b[n/2]+b[(n/2)-1]-a[n/2]-a[(n/2)-1]+1 << endl;
    }
return 0;
}


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

int main(){
    int k,x;
    cin >> k >> x;
    // [k-1] ..k[x] k[x] k[x] k[x]
    // k pattern  
    //vector<int> list;
    rep2(i,(x-k+1),(x+k)){
        cout << i << " ";
    }
    cout << endl;
//    sort(list.begin(),list.end());


}

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

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; }

int main() {
    int n, m;
    cin >> n >> m;
    mint ans = 1;
    for (int i = 1; i <= n; i++) {
        ans *= i;
    }
    for (int i = 1; i <= m; i++) {
        ans *= i;
    }
    if ((n + m) % 2 == 0)
        ans *= 2;

    if (abs(n - m) >= 2)
        ans = 0;

    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;

int main() {
  int N,K;
  string s;
  cin>>N>>K>>s;
  vector<int64_t>one;
  vector<int64_t>zero;
  if(s[0]=='0'){one.push_back(0);}
  for(int i=0;i<N;i++){
    if(s[i]=='1'){
      int cnto=1;
      while(i+1<N&&s[i+1]=='1'){cnto++;i++;}
      one.push_back(cnto);
    }
    if(s[i]=='0'){
      int cntz=1;
      while(i+1<N&&s[i+1]=='0'){cntz++;i++;}
      zero.push_back(cntz);
    }
  }
  if(s[N-1]=='0'){one.push_back(0);}
  
//  for(int i=0;i<one.size();i++){
//    cout<<one[i]<<" ";
//  }cout<<"aa"<<endl;
// for(int i=0;i<zero.size();i++){
//   cout<<zero[i]<<" ";
//  }cout<<"bb"<<endl;
  
  int a=one.size(),b=zero.size();
  for(int i=0;i<(int)one.size();i++){
    if(i>0){one[i]+=one[i-1];}
  }

  for(int i=0;i<(int)zero.size();i++){
    if(i>0){zero[i]+=zero[i-1];}
  }

  int MAX=0;
 // cout<<a<<" "<<b<<endl;
  for(int i=0;i<(int)one.size();i++){
    int r=0;
    if(K>=zero.size()){
      r=one[a-1];
      if(b-1>=0){r+=zero[b-1];}
    }//間に挟むのでi+K
    else if(i==0&&i+K<=a-1){r=one[i+K]+zero[i+K-1];}
    else if(i>0&&i+K<=a-1){r=one[i+K]-one[i-1]+zero[i+K-1]-zero[i-1];}
    //cout<<r<<endl;
    chmax(MAX,r);
  }
  cout<<MAX<<endl;
  return 0;
}


Measured memory_bytes: 4424
#include <iostream>
#include <cstring>

using namespace std;

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

  if(n[0] == '7' || n[1] == '7' || n[2] == '7') {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

  


Measured memory_bytes: 3640
n = input()

num = int(n[-1])
if num == 2 or num == 4 or num == 5 or num == 7 or num == 9:
    print('hon')
elif num == 0 or num == 1 or num == 6 or num == 8:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9040
import java.util.Scanner;

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

        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            int sum = 0;
            int[] A = new int[N + 2];
            A[0] = A[N + 1] = 0;
            for (int i = 0; i < N; i++) {
                A[i + 1] = sc.nextInt();
                sum += Math.abs(A[i + 1] - A[i]);
            }
            sum += Math.abs(A[N + 1] - A[N]);

            for (int i = 0; i < N; i++) {
                int ans = sum - Math.abs(A[i + 1] - A[i]) - Math.abs(A[i + 2] - A[i + 1]) + Math.abs(A[i] - A[i + 2]);
                System.out.println(ans);
            }
        }
    }
}


Measured memory_bytes: 64092
#include <bits/stdc++.h>
#define MOD 1000000007
#define MX INT_MAX
using namespace std;
#define int long long

int32_t main()
{
    int x, a;
    cin >> x >> a;

    if (x < a)
        cout<< 0 << endl;
    else
    {
        cout << 10 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
ans = 0
for x in range(1000) :
    X = list(str(x).zfill(3))
    i = 0
    j = 0
    if X[0] in S[:N-2] :
        i = S.index(X[0])
    else :
        continue
    if X[1] in S[i+1:N-1] :
        j = S[i+1:N-1].index(X[1])+i+1
    else :
        continue
    if X[2] in S[j+1:N] :
        ans += 1
                        
print(ans)


Measured memory_bytes: 9340
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;
stack<int> que;
     signed main(){
int n,m,ans=0,j,j0;
cin>>n;

for(int i=2;i*i<=n;i++){
if(n%i)continue;
  que.push(i);while((n/que.top())%que.top()==0){m=que.top();que.push(m*m);}
     m=n;
  while(!que.empty()){
     if(m%que.top()==0){
       
        m/=que.top();
       
     }
      que.pop();
  }
  if(n!=m&&(m-1)%i==0)ans++;
  if(i%(n/i)==1)ans++;
}

n--;
int ans2=1,l=2,p,n0=n;
for(int i=2;i*i<=n0;i++){
   if(n%i)continue;
   p=0;
    que.push(i);while((n/que.top())%que.top()==0){m=que.top();que.push(m*m);}
 
    while(!que.empty()){
       p<<=1;
     if(n%que.top()==0){
       n/=que.top();
       
     p++;
       
     }
      que.pop();
  }
  ans2*=(p+1);
}
if(n!=1)ans2*=2;
cout<<ans+ans2<<endl;
//cerr<<ans<<' '<<ans2;
      
      }

        


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().strip())
c = collections.Counter(prime_factorize(n))
ans = 0
for elem in c.items():
    count = 1
    value = elem[1]
    while True:
        value -= count
        count += 1
        ans += 1
        if value < count:
            break
print(ans)


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 5e5 + 100;

struct IDX{
	int P;
	vector<pi> val;
	IDX(int n = 10) {
		for(P=1; P<n; P<<=1);
		val = vector<pi>(2*P, pi(0, 0));
	}
	void update(int v, pi k) {
		val[v+=P] = k;
		while(v>>=1) val[v] = max(val[v*2], val[v*2+1]);
	}
	pi getMax(int a, int b) {
		pi res = pi(-1, 0);
		for(a+=P, b+=P; a<=b; a>>=1, b>>=1) {
			if(a%2==1) res = max(res, val[a++]);
			if(b%2==0) res = max(res, val[b--]);
		}
		return res;
	}
};

int N, K, Nr[MAX_N];
int Ans[MAX_N];
IDX idx;
int main() {
	cin >> N >> K;
	idx = IDX(N);
	for(int i=0; i<N; i++) scanf("%d", &Nr[i]);
	for(int i=0; i<N; i++) idx.update(i, pi(Nr[i], i));
	vector<bool> vis(N, false);
	priority_queue<int> Q;
	for(int i=0; i<N; i++) {
		int v, ix; tie(v, ix) = idx.getMax(max(0, i-K+1), min(N-1, i+K-1));
		if(ix == i) Q.emplace(i), vis[i] = true;
	}
	int cnt = 0;
	while(!Q.empty()) {
		int v = Q.top(); Q.pop();
		Ans[v] = N - cnt;
		cnt++;
		idx.update(v, pi(-1, v));
		Nr[v] = -1;
		int g = v/K;
		for(int k=max(0, g-1); k<=min((N-1)/K, g+1); k++) {
			int w, wix; tie(w, wix) = idx.getMax(k*K, min(N-1, (k+1)*K));
			if(vis[wix]) continue;
			int same; tie(ignore, same) = idx.getMax(max(0, wix-K+1), min(N-1, wix+K-1));
			if(same == wix) Q.emplace(wix), vis[wix] = true;
		}
	}
	for(int i=0; i<N; i++) printf("%d\n", Ans[i]);
	return 0;
}


Measured memory_bytes: 17876
N,K=map(int,input().split())
alist=[0]+list(map(int,input().split()))
#print(alist)

tlist=[]
pos=1
pos_set=set()
while True:
  tlist.append(pos)
  if pos in pos_set:
    break
  pos_set.add(pos)
  pos=alist[pos]
  
dup_pos2=len(tlist)-1
dup_pos1=-1
for i in range(len(tlist)):
  if tlist[i]==tlist[-1]:
    dup_pos1=i
    break
    
#print(tlist)
cycle=dup_pos2-dup_pos1
#print(dup_pos1,dup_pos2,cycle)
if K<len(tlist):
  print(tlist[K])
else:
  print(tlist[(K-dup_pos1)%cycle+dup_pos1])

Measured memory_bytes: 126104
sx, sy, tx, ty=map(int, input().split())
result=[]
result.append("D")
for i in range(tx-sx+1):
    result.append("R")
for i in range(ty-sy+1):
    result.append("U")
result.append("L")
result.append("U")
for i in range(tx-sx+1):
    result.append("L")
for i in range(ty-sy+1):
    result.append("D")
result.append("R")

for i in range(tx-sx):
    result.append("R")
for i in range(ty-sy):
    result.append("U")

for i in range(tx-sx):
    result.append("L")
for i in range(ty-sy):
    result.append("D")
print("".join(result))

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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    ll sum=0;
    rep(i,10000*b) {
        sum+=a;
        if (sum%b==c) {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


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

int main() {
    ll X, Y; cin >> X >> Y;
    ll cnt = 1;
    while (X * 2 <= Y) {
        X *= 2;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871;
const int N = 13;
lli dp[N][11];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
void calcDp() {
	for(int i = 0; i < 10; i++)
		dp[1][i] = 1;
	
	for(int i = 2; i < N; i++) {
		for(int j = 1; j < 10; j++)
			dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + dp[i-1][j+1];
		dp[i][0] = dp[i-1][1] + dp[i-1][0];
	}
}
int getLen(int kk) {
	int i;
	int sum = 0;
	for(i = 1; i < N; i++) {
		for(int j = 1; j < 10; j++) {
			sum += dp[i][j];
			if(sum >= kk) break;
		}
		if(sum >= kk) break;
	}
	return i;
}
lli buildNumber(int kk, int len) {
	lli ans = 0;
	int sum = 0;
	for(int i = 1; i < len; i++)
		for(int j = 1; j < 10; j++)
			sum += dp[i][j];
	
	for(int j = 1; j < 10; j++) {
		sum += dp[len][j];
		if(sum >= kk) { 
			ans *= 10;
			ans = j;
			kk -= sum - dp[len][j];
			break;
		}
	}
	for(int i = len-1; i >= 1; i--) {
		sum = 0;
		for(int j = max(ans % 10 - 1, 0LL); j <= min(ans % 10 + 1, 9LL); j++) {
			sum += dp[i][j];
			if(sum >= kk) {
				ans *= 10;
				ans += j;
				kk -= sum - dp[i][j];
				break;
			}
		}
	}
	return ans;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	calcDp();
	int kk;
	cin >> kk;
	if(kk < 10) {
		cout << kk << "\n";
		return 0;
	}
	cout << buildNumber(kk, getLen(kk)) << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

const int MOD = 1e9+7;

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::set<int> states_s;
	for(int i=1;i*i<=n;i++) {
		states_s.emplace(i);
		states_s.emplace(n/i);
	}
	std::vector<int> states;
	states.assign(all(states_s));
	int state_count = states.size();
	std::vector<int> a;
	std::vector<int> b;
	a.reserve(state_count);
	b.reserve(state_count);
	for(int i=0;i<state_count;i++) a[i] = states[i];
	for(int i=1;i<k;i++) {
		int last = 0;
		for(int j=0;j<state_count;j++) {
			b[j] = (states[j]-last)*a[std::lower_bound(all(states),(n/states[j]))-states.begin()]%MOD;
			if(j!=0) b[j] = (b[j]+b[j-1])%MOD;
			last = states[j];
		}
		std::swap(a,b);
	}
	print(a[state_count-1]);
	return 0;
}


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

using namespace std;

int main()
{
    int n,x;
    cin >>n>>x;
    vector<int> l(n);
    for(int i=0;i<n;i++)
    {
        cin >> l[i]; 
    }

    int sum =0; 
    int count =1; 
    for(int i=0;i<n;i++)
    {
        sum +=l[i];
        if(sum>x)
        {
            break; 
        }
        else
        {
            count++; 
        }
    }
    cout<<count<<endl; 
    return 0; 
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  string n;
  cin >> n;

  if(n[0]=='9' || n[1]=='9'){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using arr = vector<ll>;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
constexpr int MAX = 110000;
long fac[MAX], inv[MAX], finv[MAX];
void init()
{
    fac[0] = inv[0] = finv[0] = 1;
    fac[1] = inv[1] = finv[1] = 1;
    for (int i = 2; i < MAX; ++i)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 区別できるnこの中からkこ選ぶときの組み合わせの総数
long C(int n, int k)
{
    if (n < 0 || k < 0 || n < k)
        return 0;
    return (fac[n] * finv[n - k] % MOD) * finv[k] % MOD;
}
// 区別できるnこの中から重複を許してkこ選ぶときの組み合わせの総数
long H(int n, int k)
{
    return C(n + k - 1, k);
}

ll n, m;

int main()
{
  cin >> n >> m;
  init();
  ll ans = 1;
  for(ll i = 2; i * i <= m; ++i) {
    ll cnt = 0;
    while (m % i == 0) {
      m /= i;
      ++cnt;
    }
    ans = ans * H(n, cnt) % MOD;
  }
  if (m != 1) {
    ans = ans * n % MOD;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int K;
    cin >> K;
    string S;
    cin >> S;
    if(S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) + "..." << endl;
    }

}

Measured memory_bytes: 3660
while True:
    n, m, h, k = map(int, input().split())
    if not n:
        break
    points = [int(input()) for _ in range(n)]
    bars = [tuple(map(int, input().split())) for _ in range(m)]
    bars_h = [set() for _ in range(h)]
    for ba, bh in bars:
        bars_h[bh].add(ba - 1)
    swap = list(range(n))
    history = set()

    for i in range(h - 1, 0, -1):
        for ba in bars_h[i]:
            l, r = swap[ba:ba + 2]
            history.add((l, r) if l < r else (r, l))
            swap[ba:ba + 2] = r, l
    swap_dict = {v: i for i, v in enumerate(swap)}
    min_score_d = 0
    for l, r in history:
        li, ri = swap_dict[l], swap_dict[r]
        if li > ri:
            l, r, li, ri = r, l, ri, li
        if li < k and k <= ri:
            min_score_d = min(min_score_d, points[r] - points[l])

    print(sum(points[x] for x in swap[:k]) + min_score_d)

Measured memory_bytes: 32052
#include<bits/stdc++.h>
using namespace std;
int main(){

int N,K;
cin>>N>>K;
vector<int> vec(N);
int count=0;

for(int i=0;i<N;i++){
cin>>vec.at(i);
  if(vec.at(i)>=K) count++;
}




cout<<count<<endl;
  
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int read();
int n, k;
char s[10004], res[10004], c = 'z';
int l[10004], len, mx, vis;

void cpy(int p) {
    for (int i = 1; i <= n; ++i) res[i] = s[p + i - 1];
}

void check(int p) {
    if (!vis) cpy(p), vis = 1;
    for (int i = 1; i <= n; ++i) {
        if (res[i] < s[p + i - 1]) return;
        if (res[i] > s[p + i - 1]) return cpy(p);
    }
}

int main() {
    scanf("%d%d%s", &n, &k, s + 1);
    for (int i = 1; i <= n; ++i) c = min(c, s[(n << 1) + 1 - i] = s[i]);
    if (k >= 15) {
        for (int i = 1; i <= n; ++i) putchar(c);
        return 0;
    }
    if (k == 1) {
        for (int i = 1; i <= n + 1; ++i) check(i);
        for (int i = 1; i <= n; ++i) putchar(res[i]);
        return 0;
    }
    for (int i = 1; i <= n + n; ++i)
        (s[i] == c) ? mx = max(mx, l[i] = l[i - 1] + 1) : 0;

    if ((len = mx << k - 1) >= n) {
        for (int i = 1; i <= n; ++i) putchar(c);
        return 0;
    }
    for (int i = 1; i <= n + mx; ++i)
        if (l[i] == mx) check(i - l[i] + 1);
    for (int i = 1; i <= len; ++i) putchar(c);
    for (int i = len + 1; i <= n; ++i) putchar(res[i - len + mx]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int calc_gcd(int a, int b){
  int r = a%b;
  while(r>0){
	a=b;
	b=r;
	r = a%b;
  }
  return b;
}

int gcd(int a, int b){
  if(a>b){
	return calc_gcd(a,b);
  } else {
	return calc_gcd(b,a);
  }
}

int main(){
  int a,b,g;
  while(scanf("%d %d",&a,&b)!=EOF){
	g=gcd(a, b);
	printf("%d %ld\n", g, (long)a*b/g);
  }
  return 0;
}

Measured memory_bytes: 596
while True:
    x , y , z = map(int,input().split())
    if x == y == z == -1 :
        break
    
    if x == -1:
        print("F")
        
    elif y == -1:
        print("F")
    
    elif z >= 50 :
#        if x + y < 50 & x + y >=30:
        if x + y >=30:
            print("C")

    else :
        if x + y >= 80:
            print("A")
        elif x + y >= 65:
            print("B")
        elif x + y >= 50:
            print("C")
        elif x + y >= 30:
            print("D")
        elif x + y < 30:
            print("F")


Measured memory_bytes: 5596
package main

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

func main() {
	N := nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	L := make([]int, N)
	R := make([]int, N)
	L[0] = A[0]
	R[N-1] = A[N-1]
	for i := 0; i < N-1; i++ {
		L[i+1] = gcd(L[i], A[i+1])
		R[N-1-i-1] = gcd(R[N-1-i], A[N-1-i-1])
	}

	var max int
	for i := 0; i < N; i++ {
		var g int
		if i == 0 {
			g = R[i+1]
		} else if i == N-1 {
			g = L[i-1]
		} else {
			g = gcd(L[i-1], R[i+1])
		}

		if g > max {
			max = g
		}
	}

	fmt.Println(max)
}

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}

	return a
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 4736
#include<cstdio>
using namespace std;
int ap_impar[100001],ap_ap_impar[100001],ap_par[100001],ap_ap_par[100001];
int main()
{
    //freopen("f.in","r",stdin);
    //freopen("f.out","w",stdout);
    int n,i,x,max_impar1=0,max_par1=0,max_impar2=0,max_par2=0,poz_impar,poz_par;
    scanf("%d",&n);
    for(i=1;i<=n;++i)
    {
        scanf("%d",&x);
        if(i%2)
        {
            ap_ap_impar[ap_impar[x]]--;
            ap_impar[x]++;
            ap_ap_impar[ap_impar[x]]++;
            if(max_impar1<ap_impar[x])
            {
                max_impar1=ap_impar[x];
                poz_impar=x;
            }
            else
            {
                if(ap_impar[x]<max_impar1&&ap_impar[x]>max_impar2)
                    max_impar2=ap_impar[x];
            }
        }
        else
        {
            ap_ap_par[ap_par[x]]--;
            ap_par[x]++;
            ap_ap_par[ap_par[x]]++;
            if(max_par1<ap_par[x])
            {
                max_par1=ap_par[x];
                poz_par=x;
            }
            else
            {
                if(ap_par[x]<max_par1&&ap_par[x]>max_par2)
                    max_par2=ap_par[x];
            }
        }
    }
    if(ap_ap_impar[max_impar1]>1||ap_ap_par[max_par1]>1||poz_impar!=poz_par)
        printf("%d\n",n-max_impar1-max_par1);
    else
    {
        int val=max_impar1+max_par2;
        if(val<max_impar2+max_par1)
            val=max_impar2+max_par1;
        printf("%d\n",n-val);
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	int b[30];
	for (int i = 0; i < 30; ++i) {
		b[i] = 100;
	}
	string S[51];
	for (int i = 0; i < n; ++i) {
		cin >> S[i];
		int a[30] = { 0 };
		for (int j = 0; j < S[i].size();++j) {
			int x = S[i][j] - 'a';
			a[x]++;
		}
		for (int j = 0; j < 26; ++j) {
			b[j] = min(b[j], a[j]);
		}
	}
	for (char i = 'a'; i <= 'z'; ++i) {
		for (int j = 0; j < b[i - 'a']; ++j) {
			cout << i;
		}
	}
	cout << endl;
	return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

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

	if (a < b) cout << "<" << endl;
	if (a > b) cout << ">" << endl;
	if (a == b) cout << "=" << endl;
}

Measured memory_bytes: 256