akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int main()
{
	int		i, ans = 0;
	char	S[100] = {0};
	
	scanf("%s", &S);

	for (i=0; i<15; i++) {
		if (S[i]!='x') ans++;
	}
	if (ans>=8) printf("YES\n");
	else printf("NO\n");

	if (DEBUG) printf("%s\n",S);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    cin>>b>>a;

    for(int i=1;i<=n;i++){
        cin>>A[i];
        A[i]*=3;
    }

    k = (b-a)*500;

    for(int i=1;i<=n;i++){
        if(abs(A[i]-k)<mn){
            mn = abs(A[i]-k);
            idx = i;
        }
    }

    cout<<idx<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	ll ans = 0LL;
	cin >> n;
	Vi l(n);
	cin >> l;
	auto ter = l.begin();
	sort(all(l));
	for (auto i = l.begin(); i != l.end(); i++) {
		for (auto j = i + 1; j != l.end(); j++) {
			//clog << "min " << *i + *j << endl;
			ter = upper_bound(j, l.end(), *i + *j - 1);
			ter--;
			ans += max(0, (int)distance(j, ter));
		//	clog << *i << " " << *j << " " << *(ter) << " ;" << ans << endl;
		}
	}
	cout << ans << endl;
}

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

long long n,m,k;
long long a[200010],b[200010];
long long suma[200010],sumb[200010];

int main(){
	
	cin>>n>>m>>k;
	suma[0] = sumb[0] = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		suma[i] = suma[i-1]+a[i];
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		sumb[i] = sumb[i-1]+b[i];
	}

	long long ans = 0;
	long long now_a=n , now_b=0;
	while(k < suma[now_a])now_a--;

	while(0 <= now_a){
		while(sumb[now_b+1]+suma[now_a] <= k && now_b<m)now_b++;
		ans = max(ans,now_a+now_b);
		now_a--;
	}

	cout<<ans<<endl;
}

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

int a[3][101];
int p[201][3];

int main() {
	int n; cin >> n;
	rep(i, n) {
		rep(j, 3)cin >> p[i][j];
		a[0][p[i][0]]++; a[1][p[i][1]]++; a[2][p[i][2]]++;
	}
	rep(i, n) {
		int cnt = 0;
		rep(j, 3) {
			if (a[j][p[i][j]] == 1)cnt += p[i][j];
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
n = int(input())
k = (2*n+0.25)**(1/2)+1/2
if k-int(k) == 0:
    print("Yes")
    k = int(k)
    print(k)
    bset = [[] for i in range(k)]
    now = 1
    for i in range(k-1):
        for j in range(i+1,k):
            bset[i].append(now)
            bset[j].append(now)
            now += 1
    length = len(bset[0])
    for i in bset:
        print(length," ".join(list(map(str,i))))
else:
    print("No")

Measured memory_bytes: 9076
#include<iostream>
#include<complex>
#include<complex>
#include<cmath>
using namespace std;

typedef complex<double> P;

const double eps = 1e-10;

//
//0:a include b
//1:intersected
//2:same
//3:far away
// r1 >= r2
int is_intersected_circle(P a,P b,double r1,double r2){
  double d = abs(a-b);
  if (d<eps && abs(r1-r2)<eps)return 2;
  if  (d+r2 < r1)return 0;//(fabs(r1-r2)<d if dont care a(b) include another
  if (d > r1+r2)return 3;

  
  return 1;
}

main(){
  int op[2][4]={{2,1,100,0},
  {-2,1,100,0},};
  P a,b;
  double r1,r2;
  int te;
  cin>>te;
  while(te--){
    cin>>a.real()>>a.imag()>>r1>>
      b.real()>>b.imag()>>r2;

    if (r1 >= r2)
      cout << op[0][is_intersected_circle(a,b,r1,r2)]<<endl;
    else
      cout << op[1][is_intersected_circle(b,a,r2,r1)]<<endl;
  }
  
}

Measured memory_bytes: 0
import java.util.*;

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

      int N=sc.nextInt();

      int n=N+1;

      int[] a = new int[n];

      for(int i=1;i<n;i++){
        a[i]=sc.nextInt();
      }

      int[] ans = new int[n];

      int sum1=0;

      for(int i=n-1;i>=1;i--){
      //////////////////////////////////////////////////////
/*        if(n/2<=i){
          ans[i] = a[i];
        }
        else{
        */
          for(int j=2*i;j<n;j+=i){ //there is 2*i, and 2*i<=N<n
            sum1 = sum1 + ans[j];
          }
          //////////////////////////////////////////
          if(sum1%2==a[i]){
            ans[i] = 0;
          }
          else{
            ans[i] = 1;
          }
          /////////////////////////////////////////
        //}
        sum1=0;
      /////////////////////////////////////////////////////
      }

    ////////////////////////////////////////
      int m=0;
      for(int i=1;i<n;i++){
        m = m + ans[i];
      }

      System.out.println(m);

      for(int i=1;i<n;i++){
        if(ans[i]==1){
          System.out.print(i+" ");
        }
      }
    /////////////////////////////////////////

    }
}


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

int main() {
  while(1) {
    int total;
    cin >> total;
    if(total == 0) break;

    for(int i = 0; i < 9; i++) {
      int price;
      cin >> price;
      total -= price;
    }
    cout << total << endl;
  }
  return 0;
}


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

#include <algorithm>
#include <vector>
#include <cstdio>
#include <random>
#include <functional>


int main() {
    std::string m;
    cin >> m;
 
          reverse(m.begin(), m.end());
  
  string d[4] = {"dream",  "dreamer",  "erase",  "eraser"};
  for(int i =0; i<4; i++) reverse(d[i].begin(), d[i].end());
  
  bool YN;
  
  
  for(int i=0; i<m.size();){
    YN = false;
    for(int t=0; t<4; t++){
    if(m.substr(i, d[t].size()) == d[t]){
      i += d[t].size();
      YN = true;
    }
    }
    if(!YN){
      break;
    }
  }
                
    if(YN){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  
  return 0;
}

Measured memory_bytes: 512
import Control.Applicative ((<$>))

main :: IO ()
main = solve <$> map read <$> words <$> getLine >>= mapM_ print

solve :: [Int] -> [Int]
solve [a, b, k]
  | a - b + 2 * k - 2 >= 0 = [a .. b]
  | otherwise = [a .. a+k-1] ++ [b-k+1 .. b]


Measured memory_bytes: 764
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        long[] diff = new long[n-1];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
            sum += a[i];
        }
        long s = 0;
        for (int i = 0; i < n-1; i++) {
            s += a[i];
            sum -= a[i];
//            System.out.println(sum + " " + s);
            diff[i] = Math.abs(sum - (s));
        }
        Arrays.sort(diff);
        System.out.println(diff[0]);
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 85700
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}
//string add(string s,int n){ string res; int c=n,x; for(int i=s.size()-1;i>=0;i--)   { x=s[i]-'0'+c;res+=(x%10+'0'); c=x/10; }    while(c)    { res+=(c%10+'0'); c=c/10;} reverse(res.begin(),res.end()); return res;}


int main()
{
    FAST();
    string s;
   cin>>s;
   int cnt=0,mx=0;
   for(int i=0;i<s.size();i++)
   {
       if(s[i]=='R')cnt++;
       else
       {
           mx=max(mx,cnt);
           cnt=0;
       }
   }
   cout<<max(mx,cnt)<<endl;

}




Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int ans = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++)
  {
    if (s.substr(i, 3) == "ABC")
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def check(N, Y):
  for i in reversed(range(N+1)):
    if i > N:
      continue
    j = 0
    while (i*10000)+(j*5000) <= Y:
      if i+j > N:
        break
      k = N - (i+j)
      if (i*10000)+(j*5000)+(k*1000) == Y:
        return str(i) + ' ' + str(j) + ' ' + str(k)
      j += 1
  return '-1 -1 -1'

N, Y = map(int, input().split())
print(check(N, Y))

Measured memory_bytes: 3064
N = str(input())
length = len(N)
#temp = list(N)
ans = 0
for i in range(2**(length-1)):
  temp = ""
  for j in range(length-1):
    if (i>>j)&1 == 1:
      temp += N[j]+"+"
    else:
      temp += N[j]
  temp += N[-1]
  kotae = eval(temp)
  ans += kotae
print(ans)



Measured memory_bytes: 8984
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define MAX LONG_MAX
long aray[4000000];
int n,p=2;

int right(int k){
  return 2*k+2;
}
int left(int k){
  return 2*k+1;
}
int parent(int k){
  return (k-1)/2;
}
long query(int a,int b,int k,int l,int r){
  long res;
  if(r<=a || b<=l)res = MAX;
  else if(a<=l && r<=b){
      res = aray[k];
  }
  else {
      res = min(query(a,b,left(k),l,(l+r)/2),query(a,b,right(k),(l+r)/2,r));
  }
  return res;   
}
long findmin(int a,int b){
    return query(a,b,0,0,p);
}
void update(int k,long x){
  k = k+p-1;
  aray[k] =x;
  while(k>0){
    k=parent(k);
    aray[k]=min(aray[left(k)],aray[right(k)]);
  }
}

int main(){
  int l,i=0,j;
  long tmp;
  cin>>n>>l;
  while(n>pow(p,i))i++;
  p= pow(p,i);
  for(i=0;i<p*2+1;i++)aray[i]=MAX;
  for(i=0;i<n;i++){
      cin>>tmp;
      update(i,tmp);
  }
  for(i=0;i<n-l+1;i++){

    cout<<findmin(i,i+l);
    if(i!=n-l)cout<<" ";
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 19660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,n;
    cin>>N>>n;
    for(int i=0,ai,bi;i<n;i++){
        cin>>ai>>bi;
        if(ai>(N+1)/2)ai=N-ai+1;
        if(bi>(N+1)/2)bi=N-bi+1;
        if(ai%3==1&&bi-ai>=0&&N-bi>=3*(ai/3)||bi%3==1&&ai-bi>=0&&N-ai>=3*(ai/3))cout<<"1\n";
        else if(ai%3==2&&bi-ai>=0&&N-bi>=3*(ai/3)-1||bi%3==2&&ai-bi>=0&&N-ai>=3*(ai/3)-1)cout<<"2\n";
        else cout<<"3\n";
    }
}

Measured memory_bytes: 1120
#include <iostream>
#include <vector>

using namespace std;

void insertionSort(int *A, int N) {
    for (int i = 1; i <= N-1; i++) {
        int v = A[i];
        int j = i-1;
        
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        } 
        
        A[j+1] = v;
        
        for (int k = 0; k < N-1; k++) {
            cout << A[k] << " ";
        }
        
        cout << A[N-1] <<  endl;
    }
}

int main(int argc, char** argv) {
    int N = 0;
    int Array[1000] = {0};
    
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> Array[i];
    }
    
    for (int j = 0; j < N-1; j++) {
        cout << Array[j] <<" ";
    }
    
    cout << Array[N-1] << endl;
    
    insertionSort(Array, N);
    
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[200000],k,cnt[200005],s;
vector<ll>v;
int32_t main(){
CODE_START;
cin>>n;
cin>>k;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    if(cnt[a[i]]==0){
      s++;
    }
    cnt[a[i]]++;
}
if(s<=k){
   rc(0);
}
for(ll i=0;i<=200000;i++)
{
    if(cnt[i]!=0){
        v.pb(cnt[i]);
    }
}
sort(v.begin(),v.end());
ll ans=0;
for(ll i=0;i<s-k;i++)
    ans=ans+v[i];
cout<<ans;
}


Measured memory_bytes: 5492
N=int(input())
h=input().split()
h.append(-1)
index=0
count=0
all_zeros=True
for i in h:
    if i!='0':
        all_zeros=False
        break

if all_zeros:
    print('0')
    exit(0)

while True:
    flag=True
    while flag:
        for i in range(index,len(h)):
            h[i]=int(h[i])
            if not h[i]-1<0:
                h[i]-=1
            elif h[index]==0:
                flag=False
                if index==i:
                    pass
                else:
                    count+=1
                break
            else:
                count += 1
                break

        #print(h)
        #print(count)
        #print('\n')
    counter=True
    while counter:
        index+=1
        if not h[index]==0:
            counter=False

    if h[index]==-1:
        print(count)
        exit(0)

Measured memory_bytes: 40944
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 ll N;
  ll K;
  cin >>N>>K;
  vector<ll> vec(N);
  rep(i,N) {
    cin >>vec.at(i);
  }
  
  
  if(N<=K) {
    cout<<0<< endl;
  }
  
  else {
sort(all(vec));
    ll sum=0;
    rep(j,N-K) {
    sum+=vec.at(j);
  }
    cout<<sum<<endl;
  }
  
  
  
}
  
  

Measured memory_bytes: 2300
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
    fast;
    int n;
    cin >> n;
    int h[n+1];
    for(int i = 1; i<=n ; i++ ){
    	cin >> h[i];
	}
	int dp[n+1];
	dp[0] = 0;
	dp[1] = 0;
	for(int i = 2 ; i<=n ; i++ ){
		if(i<=2)
		dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
		else
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n];
}





Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    
    ll r = v - w;
    
    if (r <= 0) {
        cout << "NO" << endl;
        return 0;
    }
    
    ll need = (abs(a - b) + r - 1) / r;
    if (need <= t) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3616
ref_num = list(input())

for i in range(2**3): # 2**len(ref_num)
    fomula = ref_num[0]
    for j in range(3):
        if i >> j & 1:
            fomula += "+" + ref_num[j+1]
        else:
            fomula += "-" + ref_num[j+1]
    if eval(fomula) == 7:
        print(fomula+"=7")
        break
    

Measured memory_bytes: 3060
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int x, y, z;
  std::cin >> x >> y >> z;
  bool ans = x+y+z >=22;
  std::cout << (ans ? "bust" : "win") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
	int s[34]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<s[k-1]<<endl;
}
 

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 200*1000+10;
ll sum, t[maxn];
int n, a[maxn];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		t[a[i]]++;
	}
	for (int i = 0; i < maxn; i++)
		sum += t[i] * (t[i] - 1) / 2;
	for (int i = 0; i < n; i++)
		cout << sum - t[a[i]] + 1 << endl;
	return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,m,s[6],c[6];
  cin>>n>>m;
  for(int i=0;i<m;i++)cin>>s[i]>>c[i];


  int l,r;
  if(n==1){
    l=0;r=9;
  }
  else if(n==2){
    l=10;r=99;
  }
  else{
    l=100;r=999;
  }

  for(int i=l;i<=r;i++){
    bool check=true;
    string str=to_string(i);
    for(int j=0;j<m;j++){
      if(str[s[j]-1]-'0'!=c[j])check=false;
    }
    if(check){
      cout<<i;
      return 0;
    }
  }

  cout<<"-1";
  return 0;
}


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

    long long a,b,c,d,e,f,g;
    cin>>a;
    long long j=1;
    map<long long,long long>mp;

   for(long long i=0;i<a;i++ )
   {
      cin>>b;
      mp[b]=j;
      j++;
   }
   for(auto it=mp.begin();it!=mp.end();it++)
    cout<<it->second<<" ";




}



Measured memory_bytes: 7040
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, m;
    cin >> n >> m;

    cout << (n*(n-1)/2) + (m*(m-1)/2) << endl;

}

Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()
	k := nextInt()

	a := make([]int, n+1)
	b := make([]int, m+1)
	for i := 1; i <= n; i++ {
		a[i] = a[i-1] + nextInt()
	}
	for i := 1; i <= m; i++ {
		b[i] = b[i-1] + nextInt()
	}

	ans := 0
	for i := 0; i <= n; i++ {
		if k < a[i] {
			continue
		}
		x := sort.SearchInts(b, k-a[i]+1)
		ans = max(ans, i+x-1)
	}
	fmt.Println(ans)
}

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

var sc = bufio.NewScanner(os.Stdin)

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


Measured memory_bytes: 8268
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n ,i;
  cin>>n;
  string s;
  cin>>s;
  int l=s.length();
  for(i=0;i<l;i++)
  {
    s[i]=(char)(65+(s[i]-65+n)%26);
  }
  cout<<s;
  return 0;
}
  

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task "photo"

using namespace std;
typedef long long ll;

const int maxn = 2e5 + 5;

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".in", "r")){
        freopen(Task".in", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    ll n, a, b; cin >> n >> a >> b;
    ll dist = abs(a - b);
    if (dist % 2 == 0) return cout << dist / 2, 0;
    if (a > b) swap(a, b);
    ll res = b - 1;
    res = min(res, a + max(1ll, b - a) / 2);
    res = min(res, n - b + 1 + (n - min(n, a + n - b + 1)) / 2);
    cout << res << '\n';
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		char[] s=ir.next().toCharArray();
		out.println(Character.toString(s[0])+Integer.toString(s.length-2)+Character.toString(s[s.length-1]));
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res-1;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 22996
fun main(args: Array<String>) {
    readInputLine()
    val list = readInputLine().split(" ").map { it.toInt() }

    for (a in list) {
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                println("DENIED")
                return
            }
        }
    }

    println("APPROVED")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 38076
n = int(input())
a = list(map(int,input().split()))

a.sort(reverse = True)

ans = 0
ans += a[0]
i = 1
j = 1
while i < n-1 :
    if i+2 <= n-1 :
        ans += 2*a[j]
        j += 1
        i += 2
    else :
        ans += a[j]
        j += 1
        i += 1

print(ans)


Measured memory_bytes: 31484
HW = input().split()

H = int(HW[0])
W = int(HW[1])

tmp1 = ("." * W) + ".."
s = [list(tmp1)]
for i in range(H):
    tmp2 = "." + input() + "."
    s.append(list(tmp2))
s.append(list(tmp1))

checker = 1
for i in range(1, H+1):
    for j in range(1, W+1):
        if s[i][j] == "#":
            if s[i][j-1] == "." and s[i-1][j] == "." and s[i][j+1] == "." and s[i+1][j] == ".":
                checker = 0
                break
    if checker == 0:
        break

if checker == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
var
	s,t,a,u:String;
	i,x,y:Longint;
begin
	readln(a);
	i:=1;
	while a[i]<>' 'do inc(i);
	s:=copy(a,1,i-1);
	t:=copy(a,i+1,length(a)-i);
	readln(x,y);
	readln(u);
	if s=u then dec(x)else dec(y);
	writeln(x,' ',y);
end.


Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;



int main()
{   IOS;
cout.precision(30);
    ll n,D;
    cin >> n >> D;
    if(n%((2*D)+1)==0)
        cout << n/(2*D+1);
    else
        cout << n/(2*D+1) +1;



    return 0;
}


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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n, k;
    cin >> n >> k;
    cout << (3*n + k)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int S;
    int h, m, s;

    scanf("%d", &S);

    h = S / 3600;
    m = (S - h * 3600 ) / 60;
    s = (S - (h * 3600 + m * 60)) / 1;

    printf("%d:%d:%d\n", h, m, s);
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
long long maxl(long long a,long long b){
	return a>b?a:b;
}
int main(){
	int n;
	cin>>n;
	long long x=1,y=1;
	for(int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		x=maxl((x-1)/a,(y-1)/b)*a+a;
		y=maxl((x-1)/a,(y-1)/b)*b+b;
	} 
	cout<<x+y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <complex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll C,D,E,F,G,H,K,L,M,N,P,R,W,Y,Z;
vector<ll> V(10),U(10);

int func1(vector<ll> Q){
  ll A=0,B=0;
  rep(i,N){
    if(Q[i]!=V[i]){
      A=1;
    }
    if(Q[i]!=U[i]){
      B=1;
    }
  }
  if(A==0){
    return 1;
  }
  return 0;
}

int func2(vector<ll> Q){
  ll A=0,B=0;
  rep(i,N){
    if(Q[i]!=V[i]){
      A=1;
    }
    if(Q[i]!=U[i]){
      B=1;
    }
  }
  if(B==0){
    return 2;
  }
  return 0;
}

int main(){
  cin >> N;
  vector<ll> x(N);
  rep(i,N){
    cin >> V[i];
  }
  rep(i,N){
    cin >> U[i];
    x[i]=i+1;
  }
  sort(ALL(x));
  do{ 
    C++;
    ll T = func1(x),A = func2(x);

    if(T==1){
      D=C;
    }
    if(A==2){
      E=C;
    }
  }while (next_permutation(x.begin(), x.end()));
  cout << abs(D-E) << endl;
}

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

using namespace std;

int n;
string s;
map<pair<string, string>, long long> mm;
long long ans;
string s1, s2;

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


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    string s;
    cin >> s;
    vector<int> x;
    for(auto c: s)
        x.push_back(c-'0');
    int n = x.size();

    for(int bit=(1<<(n-1))-1;bit>=0;bit--){
        stringstream ss;
        int now = x[0];
        ss << x[0];
        FOR(i, 0, n-1){
            if((bit>>i)&1){
                now += x[i+1];
                ss << '+';
            }
            else{
                now -= x[i+1];
                ss << '-';
            }
            ss << x[i+1];
        }
        if(now == 7){
            cout << ss.str() << "=7" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextString() string {
	sc.Scan()
	return sc.Text()
}
func countSlimes(s string) (count int) {
	old := '0'
	for _, ss := range s {
		if old != ss {
			count++
			old = ss
		}
	}
	return
}

func main() {
	nextInt()
	s := nextString()
	count := countSlimes(s)
	fmt.Println(count)
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;int h[n];
    for(int i=0;i<n;i++)
    cin>>h[i];
    int dp[n];
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        //cout<<"ram\n";
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++){
           // cout<<(dp[i-j]+abs(h[i-j]-h[i]))<<"\n";
           if(i<j)
           break;
        dp[i]=min(dp[i],(dp[i-j]+abs(h[i-j]-h[i])));
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  ll n, k; cin >> n >> k;
  V a(n); cin >> a;

  VV ind(int(2e5)+1, V());
  rep(i, n) ind[a[i]].push_back(i);

  V x;
  Vll y;
  x.push_back(0);
  y.push_back(0);

  while (1) {
    int x1 = x.back();
    int i = lower_bound(all(ind[a[x1]]), x1+1) - ind[a[x1]].begin();

    ll y1 = y.back();
    if (i == ind[a[x1]].size()) {
      i = 0;
      y1 += n;
    }
    int x2 = ind[a[x1]][i] + 1;
    y1 += x2 - x1;
    x2 %= n;

    x.push_back(x2);
    y.push_back(y1);

    if (x.back() == 0) break;
  }

  k *= n;
  k %= y.back();

  int i = lower_bound(all(y), k+1) - y.begin() - 1;
  k -= y[i];
  int c = x[i];

  V v;
  set<int> S;

  rep(j, k) {
    int &b = a[(j+c)%n];
    if (S.find(b) == S.end()) {
      S.insert(b);
      v.push_back(b);
    }
    else {
      while (v.back() != b) {
        S.erase(v.back());
        v.pop_back();
      }
      S.erase(v.back());
      v.pop_back();
    }
  }

  cout << v << "\n";
  return 0;
}


Measured memory_bytes: 25704
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    int sq = sqrt(n);
    for (int i = sq; i >= 1; i--) {
        if (n % i == 0) {
            cout << i + n/i - 2 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int res=110000,n;
char s[100005];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int F=1;F<=n;++F){
		int nos=0,p=0;
		for(int i=1;i<=n;++i){
			if(s[i]!=s[F])++p;
			else nos=max(nos,p),p=0;
		}nos=max(nos,p);
		res=min(res,nos);
	}cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)
#define scan1(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define scan2(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define assign1(a,n,x) for(int i=0;i<n;i++)a[i]=x;
#define assign2(a,m,n,x) for(int i=0;i<m;i++){ for(int j=0;j<n;j++){a[i][j]=x;}}
#define max3(a,b,c) max(a,max(b,c));
#define min3(a,b,c) min(a,max(b,c));
#define int long long
#define bn "\n"

long long power_mod(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int binarySearch(int arr[], int l, int r, int x) 
{ 
    while (l <= r) { 
        int m = l + (r - l) / 2; 
        // Check if x is present at mid 
        if (arr[m] == x) 
            return m; 

        // If x greater, ignore left half 
        if (arr[m] < x) 
            l = m + 1; 
  
        // If x is smaller, ignore right half 
        else
            r = m - 1; 
    } 
  
    // if we reach here, then element was 
    // not present 
    return -1; 
} 

int32_t main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        int k;
        cin>>k;
        int t=0;
        for(int a=1;a<=k;a++)
            for(int b=1;b<=k;b++)
                for(int c=1;c<=k;c++){
                    int d=__gcd(a,b);
                    t+=__gcd(c,d);
                }
                    
        cout<<t;
    }
    return 0;
}

Measured memory_bytes: 3664
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
fn main() {
    input!(n: usize);
    input!(mut a: [usize; n]);
    a.sort();
    let mut ans = 0;
    for i in 1..n {
        ans += a[n - 1 - i / 2];
        //println!("{}", a[n - 1 - i / 2]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 6188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,k;
	cin>>n>>k;
	cout << min(n%k,k-n%k);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256