akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cctype>
#include <climits>
#include <iomanip>
#include <limits>
#include <bitset>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = INT_MAX;
const ll linf = 1LL << 60;
#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(), greater<>()
#define SUM(a) accumulate((a).begin(), (a).end(), 0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
const double PI = 3.14159265359;
template <typename T>
int len(T tmp)
{
	int res = 0;
	while (tmp > 0)
	{
		res++;
		tmp /= 10;
	}
	return res;
}
template <typename T>
T gcd(T a, T b)
{
	T t;
	while (b != 0)
	{
		t = a % b;
		a = b;
		b = t;
	}
	return a;
}
template <typename T>
T recfact(T start, T n)
{
	T i;
	if (n <= 16)
	{
		T r = start;
		for (i = start + 1; i < start + n; i++)
			r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
template <typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
template <typename T>
T fct(T n)
{
	return recfact<T>(1, n);
}
template <typename T>
T ncm(T n, T m)
{
	if (n < m)
		return 0;
	T x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr)
{
	if (firstItr < 0 || secondItr > int(str.size() - 1))
		return str;
	while (firstItr < secondItr)
	{
		swap(str[firstItr], str[secondItr]);
		firstItr++;
		secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str)
{
	int itr = 0;
	std::string res;
	while (itr < int(str.size()))
	{
		char tmp = str[itr++];
		int length = 1;
		while (itr < int(str.size()) && str[itr] == tmp)
		{
			++itr;
			++length;
		}
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
typedef pair<string, string> pstr;
string split(string str, size_t first_itr, size_t second_itr)
{
	string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++)
	{
		tmp.push_back(str.at(i));
	}
	return tmp;
}

int main()
{
	string str;
	cin >> str;
	int n = str.size();
	int num[10];
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		num[i] = str[i] - '0';
	}
	for (int bit = 0; bit < (1 << (n - 1)); bit++)
	{
		ll tmp = num[0];
		ll tmp_sum = 0;
		for (int i = 0; i < n - 1; i++)
		{
			if (bit & (1 << i))
			{
				tmp_sum += tmp;
				tmp = num[i + 1];
			}
			else
			{
				tmp = tmp * 10 + num[i + 1];
			}
		}
		tmp_sum += tmp;
		ans += tmp_sum;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

const int INF = 1000000000;

int main() {FIN
    
    int i, e;
    string s;
    cin >> s;
    vi let('z' - 'a' + 1);
    for (i = 0; i < s.size(); i++)
		let[s[i] - 'a']++;
		
	e = 1;
	for (i = 0; i < let.size(); i++)
		e = (e & !(let[i] & 1));
		
	cout << (e ? "Yes" : "No") << "\n";
    
    return 0;
}


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

int main() {
  LL N;
  cin >> N;
  //vector<LL> a(N);
  unordered_map<LL, LL> m;
  for (int i=0; i<N; i++) {
    LL a;
    cin >> a;
    m[a]++;
  }
  
  bool flag = true;
  if (m.size() > 3) {
    flag = false;
  } else if (m.size() == 3) {
    LL t = 0;
    for (auto a : m) {
      t ^= a.first;
      if (a.second != N / 3) {
        flag = false;
      }
    }
    if (t != 0) {
      flag = false;
    }
  } else if (m.size() == 2) {
    for (auto a : m) {
      if (a.first == 0) {
        if (a.second != N / 3) {
          flag = false;
        }
      }
    }
  } else {
    for (auto a : m) {
      if (a.first != 0) flag = false;
    }
  }
  
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3620
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Stack;

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

        Scanner scan=new Scanner(System.in);
        int n=0;
        if(scan.hasNext())
            n=scan.nextInt();
        int[] arr=new int[n];
        for(int i=0;i<n;i++){
            if(scan.hasNext())
                arr[i]=scan.nextInt();
        }
        int[] dp=new int[n];
        dp[0]=0;
        dp[1]=Math.abs(arr[1]-arr[0]);
        for(int i=2;i<n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 54584
#include<bits/stdc++.h>
using namespace std;
int a,b;
int ans;
int main(){
	scanf("%d%d",&a,&b);
	for(int i=1;i<a;i++)
		ans+=i;
	for(int i=1;i<b;i++)
		ans+=i;	
	printf("%d",ans);
	
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int n,a[200010],b[200010];
bool check(int mid){
	for(int i=1;i<2*n;++i)b[i]=a[i]<=mid;
	for(int i=0;i+1<n;++i){
		if(b[n+i]==b[n+i+1])return b[n+i];
		if(b[n-i]==b[n-i-1])return b[n-i];
	}
	return b[1];
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=gi();
	for(int i=1;i<2*n;++i)a[i]=gi();
	int l=1,r=2*n-1,mid;
	while(l<r){
		mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll MOD2 = 998244353;
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()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int A, B; cin >> A >>B;
  //main
  
  
  // output
  if(A*B % 2){cout << "Yes" << endl;}
  else{cout << "No" << endl;}

  return 0;
}



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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int64_t ll;
typedef double dd;

void Solve(ll) {
  ll l;
  if (not(cin >> l)) return;
  vector<tuple<ll, ll, ll>> edges;
  const ll bits = 19;
  VEVE(b, 0, bits - 1) {
    edges.emplace_back(bits - b, bits - b + 1, 0);
    edges.emplace_back(bits - b, bits - b + 1, 1 << b);
  }
  VEVE(b, 0, bits) if (l >> b & 1) {
      l -= 1 << b;
      edges.emplace_back(1, bits - b + 1, l);
    }
  if (l > 0) {
    edges.emplace_back(1, 2, 0);
    edges.emplace_back(1, 2, 1 << 18);
  }
  cout << (bits + 1) << " " << SIZE(edges) << endl;
  RARA(e, edges) {
    cout << get<0>(e) << " " << get<1>(e) << " " << get<2>(e) << endl;
  }
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 11;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())

    flg = False
    for i in range(1, 10):
        if flg:
            break
        for j in range(1, 10):
            if i * j == N:
                print('Yes')
                flg = True
                break
    
    if not flg:
        print('No')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String nn = stdIn.next();
		int n = Integer.parseInt(nn); //n個の文字列
		char[][] s = new char[n][10];
		String[] moji = new String[n];

		for(int i = 0; i < n; i++) {
			s[i] = stdIn.next().toCharArray();
			Arrays.sort(s[i]);
		}

		for(int i = 0; i < n; i++) {
			moji[i] = String.valueOf(s[i]);
		}
		
		Arrays.sort(moji);

		long cnt = 0;
		long shikoi = 0;
		for(int i = 0; i < n-1; i++) {
			if(moji[i].equals(moji[i+1])) {
				shikoi++;
				cnt += shikoi;
			}else {
				shikoi = 0;
			}
		}
		System.out.println(cnt);

	}

}


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

int n,m,a[51][51],b[51],c[51];
bool used[51]={};

void dfs(int t){
  if(used[t]){
    return;
  }
  used[t]=true;
  for(int i=1;i<=n;++i){
    if(a[t][i]==1)dfs(i);
  }
}

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

  for(int i=0;i<m;++i){
    cin>>b[i]>>c[i];
    a[b[i]][c[i]]=a[c[i]][b[i]]=1;
  }

  int ans=0;
  for(int i=0;i<m;++i){

    for(int j=1;j<=n;++j)used[j]=false;
    a[b[i]][c[i]]=a[c[i]][b[i]]=0;

    dfs(1);

    for(int j=1;j<=n;++j){
        if(!used[j]){
            ans++;
            break;
        }
    }
    a[b[i]][c[i]]=a[c[i]][b[i]]=1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = int.Parse(Console.ReadLine());
		long ans = 0;
		for(var i=1;i<=N;i++){
			for(var j=1;j<=N;j++){
				long a1 = Gcd(i,j);
				for(var k=1;k<=N;k++){
					long a2 = Gcd(a1,k);
					ans += a2;
				}
			}
		}
		Console.WriteLine(ans);
	}

	public static long Gcd(long a, long b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
}

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

int main(void){
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(200001, 0); // 黒の数
  
  for(int i = 1; i <= n; i ++){
    if(s.at(i-1) == '#') a.at(i) = a.at(i-1) + 1;
    else a.at(i) = a.at(i-1);
  }
  
  vector<int> b(200001, 9999999);
  for(int i = 0; i <= n; i ++){
    int w = a.at(i); // 前半の黒の数
    int k = n-i - (a.at(n) - a.at(i)); // 後半の白の数
    
    b.at(i) = w+k;
  }
  
  cout << *min_element(b.begin(), b.end()) << endl;
  
  return 0;
}

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

void solve(void)
{
    int n;
    cin >> n;
    int a = n, x = 0;
    while (a > 0)
        x += a % 10, a /= 10;
    if (n % x == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  ll n ,k ,q;
  cin >>n >>k>>q;
  ll a[q];
  for(ll i=0;i<q;i++){
    cin>>a[i];
  }
  ll num[1000000];
  for(ll i =0 ;i<q;i++){
    num[a[i]] ++;
  }
  for(ll i =1; i <=n; i++){
    if(q-num[i]>=k){
      cout<<"No"<<endl;
    }
    else{
      cout <<"Yes"<<endl;
    }
  }

}

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

void solve(int n, string s, int up) {
  if (n == 0) {
    cout << s << endl;
    return;
  }

  rep(i, up) solve(n - 1, s + char('a' + i), up);
  solve(n - 1, s + char('a' + up), up + 1);
}

int main() {
  ll n;
  cin >> n;
  string s;
  solve(n, s, 0);
  return 0;
}


Measured memory_bytes: 3456
program KEYENCE_String
  implicit none
  character(100) :: s
  integer :: n, i
  read(*,*) s
  n = len_trim(s)
  do i = 1, 6
    if (s(1:i)//s(n-6+i:n) == "keyence") then
      write(*,'(a)') "YES"
      stop
    end if
  end do
  write(*,'(a)') "NO"
end program KEYENCE_String

Measured memory_bytes: 256
n = int(input())
arr = [input().split() for _ in range(n)]
for i in arr:
    i[1] = int(i[1])
ans = sorted(arr, key=lambda x: x[1])
list.sort(ans, key=lambda x: x[1] ,reverse=True)
list.sort(ans, key=lambda x: x[0])
for sorted_list in ans:
    for i, base in enumerate(arr, start = 1):
        if base == sorted_list:
            print(i)

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

int main(void) {
	int N, tmp, i,Alice = 0,Bob = 0;
	vector<int> a;
	scanf("%d", &N);
	rep(i, N) {
		scanf("%d", &tmp);
		a.push_back(tmp);
	}
	sort(a.rbegin(), a.rend());
	rep(i, N) {
		tmp = a.at(i);
		if ((i & 1) == 0) {
			Alice += tmp;
		}
		else {
			Bob += tmp;
		}
	}
	printf("%d\n", Alice - Bob);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <deque>
using namespace std;
typedef long long int ll;

constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}

struct perm{
private:
    int sz;
    vector<ll> p,invp;
public:
    perm(int n){
        sz=n+1;
        p.resize(sz),invp.resize(sz);
        p[0]=1;
        for(int i=1;i<=sz-1;i++){
            p[i]=p[i-1]*i%mod;
        }
        invp[sz-1]=mod_pow(p[sz-1],mod-2);
        for(int i=sz-2;i>=0;i--){
            invp[i]=invp[i+1]*(i+1)%mod;
        }
    }
    ll comb(ll x,ll y){
        if(x<y||y<0)return 0;
        return (p[x]*invp[x-y]%mod)*invp[y]%mod;
    }
};
perm p(1<<20);

const int N=200200;

vector<int> g[N];
int a[N],b[N];
int d[N];
int pre[N];

void dfs(int s,int p){
    d[s]=1;
    pre[s]=p;
    for(int t:g[s]){
        if(t==p)continue;
        dfs(t,s);
        d[s]+=d[t];
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i=1;i<n;i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    dfs(0,-1);
    ll res=0;
    ll inv=mod_pow(mod_pow(2,n-1),mod-2);
    ll po=mod_pow(2,n-1);
    for(int s=0;s<n;s++){
        if(g[s].size()==1)continue;
        ll sum=0;
        for(int t:g[s]){
            if(pre[s]==t){
                (sum+=mod_pow(2,n-d[s]))%=mod;
            }else{
                (sum+=mod_pow(2,d[t]))%=mod;
            }
        }
        (sum-=(g[s].size()-1))%=mod;
        sum=(po-sum)%mod;
        if(sum<0)sum+=mod;
        (res+=sum*inv%mod)%=mod;
    }
    printf("%lld\n",res*mod_pow(2,mod-2)%mod );
}


Measured memory_bytes: 39680
#include<iostream>
#include<vector>
using namespace std;
long long int INF=1e9+5;
int main()
{
    int n;
    cin>>n;
    int k;cin>>k;
    vector<long long int> arr(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    vector<long long int> dp(n+1,INF);
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;i-j>=1;j++)
        {
            if(j<=k)
            dp[i]=min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
            else
            {
                break;
            }
            
        }
        // cout<<dp[i]<<" ";
    }
    cout<<dp[n];
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
typedef long long int ll;
typedef pair<int, int> P;
 
const long long INF = 3e18 + 12;
const int inf = 1e9;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  if (a * b % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
 
  return 0;
}

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

const int segN = (1<<17);

struct segtree{
  int t[segN*2];
  void init(){
    for(int i=0;i<segN*2;i++){
      t[i]=1e9;
    }
  }
  
  int Get(int i){
    i+=(segN-1);
    int res=t[i];
    while(i){
      i=(i-1)/2;
      res=min(res,t[i]);
    }
  }
  
  void Update(int a,int b,int x,int k=0,int l=0,int r=segN){
    if(b<=l || r<=a)return;
    if(a<=l && r<=b){
      t[k]=min(t[k],x);
      return;
    }
    int m=(l+r)/2;
    Update(a,b,x,k*2+1,l,m);
    Update(a,b,x,k*2+2,m,r);
  }
};

segtree T;
int Rank[1000005];
int Tmp[1000005];
int kc,len;
 
bool compare_sa(int i,int j){
  return
    Rank[i]!=Rank[j]?
    Rank[i]<Rank[j]:
    (i+kc<=len?Rank[i+kc]:-1)<(j+kc<=len?Rank[j+kc]:-1);
}
 
void construct_sa(char* S,int *sa){
  len=strlen(S);
  for(int i=0;i<=len;i++){
    sa[i]=i;
    Rank[i]=i<len?S[i]:-1;
  }
  for(kc=1;kc<=len;kc*=2){
    sort(sa,sa+len+1,compare_sa);
    Tmp[sa[0]]=0;
    for(int i=1;i<=len;i++){
      Tmp[sa[i]]=Tmp[sa[i-1]]+compare_sa(sa[i-1],sa[i]);
    }
    for(int i=0;i<=len;i++)Rank[i]=Tmp[i];
  }
}
 


int n,m;
char str[1000005];
char t[1000005];
int sa[1000005];

int Search(char u[1000005]){
  int k=strlen(u);
  int l=0,r=n+1,m;
  
  while(l<r){
    m=(l+r)/2;
    if(strncmp(str+sa[m],u,k)<0)l=m+1;
    else r=m;
  }

  //   printf("%s %d\n",u,l);
  //   cout<< strncmp(str+sa[l], u,k) <<endl;
  
  return l;
}


string G[100005];

int main(){
  T.init();
  scanf("%s",str);
  n=strlen(str);
  construct_sa(str,sa);
  /*
  for(int p=0;p<=n;p++){
    cout<<sa[p]<<' ';
    for(int i=sa[p];i<n;i++)cout<<str[i];
    cout<<endl;
  }
  */
  scanf("%d",&m);

  set<int> st;
  for(int i=1;i<=n;i++)st.insert(i);
  
  typedef pair<int,int> P;
  vector<P> w,v;
  
  for(int i=0;i<m;i++){
    scanf("%s",t);
    int len=strlen(t);
    for(int j=0;j<len;j++)G[i].push_back( t[j] );
    w.push_back( P(len,i) );
  }
  sort(w.begin(),w.end());

  for(int i=0;i<m;i++){
    int id=w[i].second;
    int len=G[id].size();
    for(int j=0;j<len;j++)t[j]=G[id][j];
    t[len]='\0';
    int L=Search(t);
    t[len]='z'+1;
    t[len+1]='\0';
    int R=Search(t);
    while(1){
      set<int> :: iterator it;
      it=st.lower_bound(L);
      if(it==st.end() || *it >=R)break;
      
      v.push_back(P( sa[*it], sa[*it]+len-1) );
      //      cout<<L<<' '<<R<<endl;
      //      cout<<*it<<' '<< sa[*it] <<' '<< sa[*it]+len-1 <<endl;
      //      cout<<endl;
      st.erase(it);
    }
  }

  for(int i=0;i<(int)v.size();i++)swap(v[i].first,v[i].second);
  sort(v.begin(),v.end());
  for(int i=0;i<(int)v.size();i++)swap(v[i].first,v[i].second);
  
  int ans=0;
  int last=-1;
  for(int i=0;i<(int)v.size();i++){
    if( v[i].first<=last && last<=v[i].second)continue;
    last=v[i].second;
    ans++;
  }
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 12468
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n , ans , sum, cnt , a , k, m ,arr[mx5];
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>n>>m;
		fo(i,n) {
			cin>>arr[i];
			sum+=arr[i];
		}
		int k = (sum%(4*m) ? sum/(4*m) : (sum/(4*m))-1 );
		
		for(int i=n-1 ; i >=0 ; i--) {
			if(arr[i] > k) {
				cnt++;
			}
		}
		if( cnt < m) {
			cout<<"No";
		}	
		else {
			cout<<"Yes";
		}
		
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack 
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <list>
using namespace std;
int main(){
   int n;
   cin >> n;
   vector<long long> s(n);
   for(int i=0; i<n; i++){
       cin >> s[i];
   }
   int q;
   cin >> q;
   vector<long long> t(q);
   for(int i=0; i<q; i++){
       cin >> t[i];
   }
   int ans=0;
   for(int i=0; i<q; i++){
       long long x=t[i];
       for(int j=0; j<n; j++){
           if(x==s[j]){
               ans++;
               break;
           }
       }
   }
   cout << ans << endl;
}



Measured memory_bytes: 3156
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vi data(N); F0R(i, N) cin >> data[i];
    sort(all(data));
    F0R(i, N-1) {
        if (data[i] == data[i+1]) {
            cout << "NO" << endl; return 0;
        }
    }
    cout << "YES" << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string r; cin >> r;
  (r == s ? a : b)--;
  cout << a << ' ' << b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <istream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
//#include <unordered_map>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
//const LL LINF = INF * (LL) INF;
int n;
int p[100000];
int a[100000] , b[100000];
int main()
{
	scanf("%d" , &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d" , &p[i]);
		p[i]--;
	}
	//a[p[0]] = 1, b[p[0]] = 200000;
	for(int i = 0; i < n; i++)
	{
		a[i] = 20001 * i + 1;
		b[i] = 20001 * (n - 1 - i) + 1;
		//a[p[i]] = a[p[i - 1]] + 2;
		//b[p[i]] = b[p[i - 1]] - 1;
	}
	for(int i = 0; i < n; i++)
	{
		a[p[i]] += i;
	}
	for(int i = 0; i < n; i++)
	{
		printf("%d " , a[i]);
	}
	printf("\n");
	for(int i = 0; i < n; i++)
	{
		printf("%d " , b[i]);
	}
	printf("\n");
}




Measured memory_bytes: 896
#a問題
# x=int(input())
#
# if x>=30:
#     print("Yes")
# else:
#     print("No")

#b問題
n,d = (int(y) for y in input().split())
x=[]
count=0
for i in range(n):
    n, m = (int(y) for y in input().split())
    s=n**2+m**2
    # print(s)
    if s<=(d**2):
        count+=1
print(count)



Measured memory_bytes: 9172
/*
    Sharif Hasan - CSE, PUST
    Sep 01,2019 06:05 PM
    */
    #include<bits/stdc++.h>
    #define br cout<<"\n"
    #define FOR(i,n) for(i=0;i<n;i++)
    #define FROM(a,i,n) for(i=a;i<n;i++)
    #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
     
    using namespace std;
    int main()
    {
    long long n;
    cin>>n;
    --n;
    long long ans = (n*(n+1))/2;
    cout<<ans;
     
    return 0;
    }

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int cnt[100001] = { 0 };

int main()
{
	int N, a;
	int ans = 0;

	cin >> N;
	rep1(i, 1, N) {
		cin >> a;
		cnt[a]++;
	}
	rep1(i, 0, 100000 - 2) {
		ans = max(ans, cnt[i] + cnt[i + 1] + cnt[i + 2]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
program not_divisible
  implicit none
  integer :: n, a(200000) = 0, c(1000000) = 0, m = 0, i, j
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    c(a(i)) = c(a(i))+1
  end do
  select case(c(1))
  case(1)
    write(*,'(i0)') 1
    stop
  case(2:)
    write(*,'(i0)') 0
    stop
  end select
  do i = 1, n
    if (c(a(i)) > 1) cycle
    do j = 2, a(i)
      if (j*j > a(i)) exit
      if (mod(a(i),j) /= 0) cycle
      if (c(j) > 0 .or. c(a(i)/j) > 0) goto 100
    end do
    m = m+1
  100 end do
  write(*,'(i0)') m
end program not_divisible

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  vector<vector<int>>odd(100001,vector<int>(2));
  for(int i=0;i<n;i+=2) odd[a[i]][0]++;
  vector<vector<int>>even(100001,vector<int>(2));
  for(int i=1;i<n;i+=2) even[a[i]][0]++;
  for(int i=0;i<100001;i++){
    odd[i][1]=i;
    even[i][1]=i;
  }
  sort(odd.begin(),odd.end());
  sort(even.begin(),even.end());
  if(even[100000][1]!=odd[100000][1]) cout<<n-even[100000][0]-odd[100000][0]<<endl;
  else{
    if(even[99999][0]>odd[99999][0]) cout<<n-odd[100000][0]-even[99999][0]<<endl;
    else cout<<n-odd[99999][0]-even[100000][0]<<endl;
  }
}

Measured memory_bytes: 11520
# frozen_string_literal: true

_n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

min = (a.inject(:+) / (4 * m).to_f).ceil
if a.count { |x| x >= min } >= m
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
def main():  
  import sys
  input = sys.stdin.readline
  import numpy as np

  n,k = map(int,input().split())
  s = input()
  chk_0 = []
  chk_1 = []
  c0 = 0
  c1 = 0
  chk_0_append = chk_0.append
  chk_1_append = chk_1.append
  if s[0]=='0':
    c0 += 1
  else:
    c1 += 1
    chk_0_append(0)

  for i in range(n-1):
    if s[i]=='0' and s[i+1]=='0':
      c0 += 1
    if s[i]=='0' and s[i+1]=='1':
      chk_0_append(c0)
      c0 = 0
      c1 = 1
    if s[i]=='1' and s[i+1]=='0':
      chk_1_append(c1)
      c0 = 1
      c1 = 0
    if s[i]=='1' and s[i+1]=='1':
      c1 += 1

  if c0 != 0:
    chk_0_append(c0)
    chk_1_append(0)
  elif c1 != 0:
    chk_1_append(c1)
    chk_0_append(0)

  if len(chk_0) <= k:
    print(n)
    exit()

  chk_1 = tuple(chk_1)
  chk_0 = tuple(chk_0)
  ab = np.array([x+y for x,y in zip(chk_0,chk_1)])
  np.cumsum(ab,out=ab)
  ab = tuple(ab)
  #print(ab)
  ans = ab[k-1]
  for i in range(len(ab)-k):
    chk = ab[k+i]-ab[i]
    chk += chk_1[i]
    ans = max(ans,chk)
  print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 16368
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define inn ll arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
#define fora(i,n); for(ll i=0;i<n;i++)
#define forb(i,a,n); for(int i=a;i<n;i++)
#define mod 1000000007
#define endl "\n"
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
int main()
{
fastio
int h1,m1,h2,m2,k;
cin>>h1>>m1>>h2>>m2>>k;
int min1=h1*60+m1;

int min2=h2*60+m2;
if(min2<min1) min2+=24*60-(min1-min2);
//if(h2>=h1) {

    cout<<min2-min1-k;


//}
//else {
//    min2=24*60-(min1-min2);
//    cout<<min2-min1-k;
//
//
//}


return 0; }

Measured memory_bytes: 3652
#include<stdio.h>

int main(){
  int d[100], a[100][100], n, k, i, m, o, ans = 0, q = 0;

  scanf("%d %d", &n, &k);

  for(i = 0; i <= k; i++){
    scanf("%d", &d[i]);
    for(m = 0; m < d[i]; m++){
      scanf("%d", &a[i][m]);
    }
  }

  i = m = 0;

  for(o = 1; o <= n; o++){
    q = 0;
    for(i = 0; i < k; i++){
      for(m = 0; m < d[i]; m++){
        if(o == a[i][m])q = 1;
      }
    }
    if(q == 1)ans += 1;
  }

  printf("%d", n-ans);

  return 0;
}


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

int main() {
  int N,Z=0;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    Z=(a^Z);
    p.at(i)=a;
  }
  for(int i=0;i<N;i++){
    int A=(Z^p.at(i));
    cout<<A;
    if(i!=N-1){
      cout<<" ";
    }
    else{
      cout<<endl;
    }
  }
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
/*   -- AUTHOR -- 
  ---- cervotrex ---- 
*/
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(arr) arr.begin(),arr.end()
#define mod 1000000007
const ll INF = 1LL << 60;
const int MAX_N = 1000005;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order
// ordered_set <int> s  ;
// auto x=s.find_by_order(k);
// s.order_of_key(val);

vector<vector<int> > adj;
vector<bool> vis;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  // cin>>t;
  while(t--){
    ll l,r,d;
    cin>>l>>r>>d;
    ll ans=0;
    for(int i=l;i<=r;i++)
      if(i%d==0)
        ans++;
    cout<<ans<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(void){
  int n,m,k,i,j,l,counter;
  counter=0;
  while(scanf("%d",&n)!=1);
  while(scanf("%d",&m)!=1);
  int check[m];
  int count[m];
  for(i=0;i<m;i++){
    check[i]=i+1;
    count[i]=0;
  }
  for(i=0;i<n;i++){
    while(scanf("%d",&k)!=1);
    int array[k];
    for(j=0;j<k;j++){
      while(scanf("%d",&array[j])!=1);
    }
    for(j=0;j<m;j++){
      for(l=0;l<k;l++){
        if(check[j]==array[l])count[j]+=1;
      }
    }
  }
  for(i=0;i<m;i++){
    if(count[i]==n)counter++;
  }
  if(n==1){
    printf("%d\n",k);
  }else{
    printf("%d\n",counter);
  }
  return 0;
}


Measured memory_bytes: 128
// Aizu Vol-6 0630: Microwave
// 2017.9.4 bal4u@uu

#include <stdio.h>

int main()
{
	int a, b, c, d, e, ans;

	scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
	if      (a < 0 && b < 0) ans = c * (b-a);
	else if (a > 0 && b > 0) ans = e * (b-a);
	else                     ans = c * (-a) + d + e * b;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
 
int
main(int argc, char *argv[])
{
        int N;
        cin >> N;
        int v[N],c[N];
        for(int i=0;i<N;i++){
            cin >> v[i];
        }       
        for(int i=0;i<N;i++){
            cin >> c[i];
        }
        int sum=0;
        for(int i=0;i<N;i++){
            if(v[i]>c[i]){
                sum = sum + v[i] - c[i];
            }
        }

        cout << sum << endl;

        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=200005;
int n,l,a[N];
long long pre[N],suf[N],ans;
void solve(){
	for (int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];
	for (int i=n;i>=1;i--) suf[i]=suf[i+1]+l-a[i];
	for (int i=0;i<n;i++){
		int t=n-i;
		if (t&1) ans=std::max(ans,(pre[i+t/2]-pre[i]+suf[n-t/2+1])*2+a[n-t/2]);
		else ans=std::max(ans,(pre[i+t/2]-pre[i]+suf[n-t/2+1])*2-(l-a[n-t/2+1]));
	}
}
int main(){
	scanf("%d%d",&l,&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	solve();
	for (int i=1;i<=n;i++) a[i]=l-a[i];
	std::reverse(a+1,a+n+1);
	solve();
	printf("%lld\n",ans);
}

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

int main() {
  //入力と出力用の宣言
  string A;
  char s;
  
  //初期条件
  s='E';
  A="error";
    
  //入力部
  cin >> s;
  
  //判定部
  if(s=='a'||s=='i'||s=='u'||s=='e'||s=='o'){
  	A="vowel"; 
  }
  else{
    A="consonant";
  }
  
  //出力部
  cout << A << endl;

}


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

	}
	else if (b == c) {
		cout << a << endl;
		return 0;
	}
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<ll> p(1001,0);
    rep(i,n){
        int a=i+1;
        for(int j=2;j*j<=a;j++){
            while(a%j==0){
                a/=j;
                p[j]++;
            }
        }
        if(a!=1) p[a]++;
    }
    ll ans=1;
    rep(i,1001){
        if(p[i]>0) ans=(ans*(p[i]+1))%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
 
using namespace std;
 
int main(){
  int N;
  double v[110];
  double val = 0.0;
  
  cin >> N;
  for(int i = 0;i<N;i++)cin >>v[i];
  for(int i = 0;i<N;i++)val += 1.0/v[i];
  val = 1.0/val;
  printf("%f", val);
  
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val n = readInt
  val abs = 
  println(if(Range(0,n).map(_=>readLine.split(' ').map(_.toInt))
             .map(x=>(x(1),x(0)))
             .sorted
             .scanLeft((0,true))((acc,x)=>(acc._1+x._2, acc._1+x._2<=x._1))
             .foldLeft(true)(_&&_._2))
          "Yes" else "No")
}

Measured memory_bytes: 115592
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

bool G[4][4]={};

bool solve(){
    rep(i,3){
        int a,b;
        cin >>a >>b;
        --a;
        --b;
        G[a][b] = G[b][a] = true;
    }

    vector<int> v(4);
    rep(i,4) v[i] = i;
    do{
        bool ok = true;
        rep(i,3){
            int s = v[i], d = v[i+1];
            if(!G[s][d]) ok = false;
        }
        if(ok) return true;
    }while(next_permutation(all(v)));
    return false;
}

int main(){
    cout << (solve()?"YES":"NO") << endl;
    return 0;
}


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

int main(){
  int n;

  cin >> n;

  long *a = new long[n];

  for(int i=0;i<n;++i)cin >> a[i];

  long max=a[0],min=a[0],sum=0;

  for(int i=0;i<n;++i){
    if(max < a[i]){
      max = a[i];
    }

    if(min > a[i]){
      min = a[i];
    }

    sum += a[i];
  }

  cout << min << " " << max << " " << sum << endl;

  delete[] a;
}



Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  ll N, K; cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];
  
  vector<int> B(2*N);
  for(int i=0; i<2*N; i++)
    B[i] = A[i%N];
  
  vector<vector<int>> jump(300000);
  for(int i=0; i<2*N; i++)
    jump[B[i]].push_back(i);
  
  vector<int> next(N); // Aiからjumpしたときのindex
  for(int i=0; i<N; i++){
    auto it = upper_bound(jump[A[i]].begin(), jump[A[i]].end(), i);
    next[i] = (*it) + 1;
  }
  vector<int> start; // i個目Aをまたぐjumpにおける始点のindex
  int now, period;
  now = 0; period = 1;
  while(true){
    if(next[now] > N) {
      start.push_back(now);
      period++;
    }
    if(next[now]%N == 0) {
      start.push_back(now);
      break;
    }
    now = next[now]%N;
  }
  
  K %= period;
  
  for(int i=start[K-1]; i<N; i++){
    if(next[i] <= N) i = next[i] - 1;
    else cout << A[i] << " ";
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 18808
import sys
import string
lower_case = string.ascii_lowercase

alphabets = {}
for letter in lower_case:
     alphabets.setdefault(letter, 0)

string = []
for line in sys.stdin:
    string.append(line)

for line in string:
    for letter in line:
        lower_letter = letter.lower()
        try :
            alphabets[lower_letter] += 1
        except:
            pass

for k, v in alphabets.items():
    print('{} : {}'.format(k,v))
        


Measured memory_bytes: 6676
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }
    var max = 0
    var tmp = 0
    for (i in 0 until n-1){
        if (h[i] >= h[i+1]){
            tmp++
        }else{
            if (max < tmp)max = tmp
            tmp = 0
        }
    }
    if (max < tmp)max = tmp
    println(max)
}


Measured memory_bytes: 59616
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d ,n;
    cin >> d >> n;
    if(d == 0) 
    {
        if(n<=99) cout << n << endl;
        else cout << n+1 << endl;
    } 
    else if (d == 1) 
    {
        if(n<=99) cout << n*100 << endl;
        else cout << (n+1)*100 << endl;
    } 
    else 
    {
        if(n<=99) cout << n*10000 << endl;
        else cout << (n+1)*10000 << endl;
    }
    return 0;
}

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

int main(){
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int &x : v){
        cin >> x ;
    }
    sort(v.rbegin(),v.rend());
    int alice = 0 ;
    int bob = 0 ;
    for(int i=0;i<n;i++){
        if ( i % 2 == 0 ) alice += v[i];
        else bob += v[i] ;
    }
    cout << alice - bob << endl;
    return 0 ;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int n, a, ans = (int)1e9, c;
	cin >> n;
	REP(i, n) {
		c = 0;
		for (cin >> a; a % 2 == 0; a /= 2) c++;
		ans = min(ans, c);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string A, B, C;
        int X, Y;
            cin >> A >> B >> C;
            X = A.size() - 1;
            Y = B.size() - 1;
                if(A.at(X) == B.at(0) && B.at(Y) == C.at(0)){
                    cout << "YES";
                }else{
                    cout << "NO";
                }
    return 0;}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
h = []
for i in range(N):
    h1 = int(input())
    h.append(h1)
    
h.sort()
a = []
for i in range(N - (K - 1)):
    a.append(h[i+K-1] - h[i])
    
print(min(a))

Measured memory_bytes: 11288
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;
const int MOD = 9999973;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
//二項係数の計算をしたい時用

const int MAX = 5100000;

unsigned long long fac[MAX], finv[MAX], inv[MAX];
unsigned ll kaijyo(ll n){
    if(n == 0) return 1;
    return n * kaijyo(n - 1);
}

unsigned ll ansans(ll n, ll k){
    return kaijyo(n) / kaijyo(n - k) / kaijyo(k);
}
ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b){
    ll res=1;
    while(b>0){
        if(b&1) res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])*fact_inv[n-r];
}

//テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[8];
    memset(a, 0, sizeof(a));
    int n;
    cin >> n;
    int b[n];
    int except = 0;
    rep(i, n){
        int g;
        cin >> g;

        if(g < 3200) a[g / 400] ++;
        else except ++;
    }
    int ans_min = 0;
    rep(i, 8) if(a[i] > 0) ans_min ++;
    if(ans_min == 0) {
        ans_min = 1;
        except --;
    }
    cout << ans_min << " ";
    cout << ans_min + except << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M (1<<19)
using namespace std;
int n,m,in[M];
bool check() {
    multiset<int> s1, s2;

    s1.insert(in[1]);
    REP(i,2,n) s2.insert(in[i]);
    REP(tt,1,m) {
        vector<int> tmp;
        for (auto it=s1.rbegin(); it!=s1.rend(); it++) {
            int num = *it;
            auto it2 = s2.lower_bound(num);
            if (it2==s2.begin()) return false;

            it2--;
            tmp.push_back(*it2);
            s2.erase(it2);
        }
        for (int i:tmp) s1.insert(i);
    }
    return (int)s1.size()==n;
}
int main()
{
    while (~scanf("%d", &m)) {
        n = (1<<m);
        REP(i,1,n) scanf("%d", &in[i]);
        sort(in+1, in+n+1, greater<int> ());

        puts(check() ? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 14080
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();
    String T = sc.next();
    
    String oneS = S.substring(0,1);
    String twoS = S.substring(1,2);
    String threeS = S.substring(2,3);
    
    String oneT = T.substring(0,1);
    String twoT = T.substring(1,2);
    String threeT = T.substring(2,3);
    
    int count = 0;
    if (oneS.equals(oneT)) {
      count ++;
    }
    if (twoS.equals(twoT)) {
      count ++;
    }
    if (threeS.equals(threeT)) {
      count ++;
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
    public static void main(String[] args){
      	int count=0;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	int m = Integer.parseInt(sc.next());
      
      	//全通りを算出
      	int totalConbination=(n+m)*(n+m-1)/2;
      	
      	//奇数となる組み合わせ=偶数+奇数の組み合わせ
      	int oddConbination=n*m;
      
      	System.out.println(totalConbination-oddConbination);
      
      
    }

}

Measured memory_bytes: 23636
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string a;
int main()
{
	cin.tie(0);
	cout.tie(0);
	cin>>a;
	int len=a.size();
	for(int i=0;i<=len;i++)
	{
		if(a[i]=='C')
		{
			for(int j=i;j<=len;j++)
			{
				if(a[j]=='F')
				{
					printf("Yes");
					return 0;
				}
			}
			break;
		}
	}
	printf("No");
	return 0;
} 

Measured memory_bytes: 256
// g++ temp.cpp
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string>
#include <climits>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
const unsigned long long MOD = 100000000000000000;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 100000000
ll n;
ll a[MAX_N+1];
void solve(){
  ll ans=0;
  cin>>n;
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  for(ll i=0;i<n;i++){
//cout<<ans<<endl;
    if(a[i]%2==0){
      ans+=a[i]/2;
    } else {
      ans+=a[i]/2;
      if(i+1<n){
      if(a[i+1]>0){
        ans+=1;
        a[i+1]--;
        } 
      }
    }
  }
  cout<<ans<<endl;
  return ;
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 1024