akhauriyash/Code-Regression huggingface dataset:
S = str(input())
Q = int(input())

qs = [list(map(str, input().split())) for _ in range(Q)]

x, y = S, ""
for ls in qs:
    if ls[0] == "1":
        x, y = y, x
    else:
        if ls[1] == "1":
            y += ls[2]
        else:
            x += ls[2]
            
y = ''.join(list(reversed(y)))
print(y+x)

Measured memory_bytes: 41136
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define reppe(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define repm(i, a, b) for (int i = (int)(a); i > (int)(b); --i)
#define repme(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)

typedef long long ll;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    return GCD(b, a % b);
}

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    bool b = true;
    while (true) {
        if (b)
            C -= B;
        else
            A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        } else if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        b = !b;
    }
}


Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

p1 = 0
p2 = 0
ng = 0
for i in range(n):
    if b[i]>=a[i]:
        p1 += (b[i]-a[i])//2
        p2 += (b[i]-a[i])%2
    else:
        ng += a[i]-b[i]

if p1>=ng:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 4596
#include <stdio.h>

int main()
{
	int P, Q, R;
	scanf("%d %d %d", &P, &Q, &R);
	
	if(P==Q&&P==R&&P==R)
{
	printf("No");
}
	else if(P==Q||P==R||Q==R)
{
	printf("Yes");
}
	else if(P!=Q&&P!=R&&Q!=R)
{
	printf("No");
}
	return 0;
}

Measured memory_bytes: 3204
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

#define pb(a) push_back(a)

using namespace std;

int main(){
  int max_w, n;
  int count = 1;

  while(true){
    scanf("%d", &max_w);
    if(max_w == 0){
      break;
    }

    scanf("%d", &n);
    vector<int> v, w;
    for(int i = 0; i < n; ++i){
      int t1, t2;
      scanf("%d,%d", &t1, &t2);
      v.pb(t1); w.pb(t2);
    }

    int dp[1011][1011] = {};
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < max_w + 1; ++j){
        if(j - w[i] >= 0){
          dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }else{
          dp[i + 1][j] = dp[i][j];
        }

      }
    }

    int ans = 0, index = -1;
    for(int i = 0; i < 1001; ++i){
      if(ans < dp[n][i]){
        ans = dp[n][i];
        index = i;
      }
    }
    printf("Case %d:\n%d\n%d\n", count, ans, index);
    count++;
  }
  return 0;
}




Measured memory_bytes: 7104
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pb push_back
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  if (N >= 10) {
    cout << K << "\n";
  }
  else {
    cout << K + 100 * (10 - N) << "\n";
  }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;


int a[12][12];
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j]; 
    }

    int ans = INF;
    rep(s,1<<n){
        int cost = 0;
        vector<int> d(m);
        rep(i,n){
            if(s>>i&1) {
                cost += c[i];
                rep(j,m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j,m) if(d[j] < x) ok = false;
        if(ok) ans = min(ans,cost);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;


    cout << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

#define MAX 101000
int V,K;
vector<int> G[MAX];
vector<int> out_deg,depth,in_deg;

void dfs(int cur,int pre,int d) {
  assert( depth[cur] == 0 );
  depth[cur] = d;
  rep(i,(int)G[cur].size()) {
    int nex = G[cur][i];
    if( pre == nex ) continue;
    dfs(nex,cur,d+1);
  }
}

typedef pair<int,int> ii;
int main(){
  if( 0 ) {
    V = 100000;
    K = 100000;
    cout << V << " " << K << endl;
    rep(i,V) {
      cout << i << endl;
    }
    return 0;
  }
  cin >> V >> K;
  out_deg = vector<int>(V+1,0);
  in_deg = vector<int>(V+1,0);
  depth = vector<int>(V+1,0);
  rep(i,V) {
    int a;
    cin >> a;
    if( a == 0 ) continue;
    G[i+1].push_back(a);
    ++out_deg[i+1];
    ++in_deg[a];
  }
  rep(i,V+1) depth[i] = INT_MAX;
  deque<ii> deq;
  REP(i,1,V+1) {
    if( in_deg[i] == 0 )  {
      deq.push_back(ii(i,0));
      depth[i] = 0;
    }
  }

  while( !deq.empty() ) {
    ii v = deq.front(); deq.pop_front();
    int cur = v.first;
    int d   = v.second;
    rep(i,(int)G[cur].size()) {
      int nex = G[cur][i];
      if( depth[nex] > d + 1 ) {
	depth[nex] = d + 1;
	deq.push_back(ii(nex,d+1));
      }
    }
  }
  
  int cnt = 0;
  REP(i,1,V+1) {
    //cout << i << "-th : " << depth[i] << " in = " << in_deg[i] << ", out = " << out_deg[i];
    if( depth[i] < K || in_deg[i] == 0 || out_deg[i] == 0 ) {
      ++cnt;
      //cout << " +1";
    }
    //cout << endl;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 10260
#include <iostream>
#include <string>
#include <set>
using namespace std;
int tonum(int x,int y,int z){
     return x+y*500+z*500*500;
}

int main(){
     int N,H;
     while(cin>>N>>H,N||H){
	  string t;
	  int a,b;
	  set<int> ans;
	  for(int l=0;l<H;l++){
	       cin>>t>>a>>b;
	       --a;--b;
	       if(t=="xy"){
		    for(int i=0;i<N;i++){
			 ans.insert(tonum(a,b,i)) ;
		    }
	       }else if(t=="xz"){
		    for(int i=0;i<N;i++){
			 ans.insert(tonum(a,i,b));
		    }
	       }else if("yz"==t){
		    for(int i=0;i<N;i++){
			 ans.insert(tonum(i,a,b));
		    }
	       }
	  }
	  /*int sum=0;
	  for(int i=0;i<N;i++){
	       for(int j=0;j<N;j++){
		    for(int k=0;k<N;k++){
			 if(!map[i][j][k])++sum;
			 //cout<<map[i][j][k];
		    }
		    //cout<<endl;
	       }
	       //cout<<endl<<endl;
	       }*/
	  cout<<N*N*N-ans.size()<<endl;
     }
     return 0;
}

Measured memory_bytes: 1984
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;
ll n, k, x,i, j, dp[200005];
set<ll>s;
vector<ll>v;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);
    cin>>n>>k;
    for(i=1;i<=n;i++)
        {
            cin>>x;
           v.pb(x);
        }
        for(i=1;i<=k;i++)
            {for(auto x:v){
            if(i>=x && !dp[i-x])
        {
            dp[i]=true;
        }
            }
            }
       // for(i=1;i<=k;i++) cout<<dp[i]<<" ";

    if(dp[k]) cout<<"First";
    else
        cout<<"Second";

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[100001],d=0,f=0,g=0,h,j,i;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&s[i]);
		if(s[i]%4==0) d++;
		if(s[i]%2==1) f++;
		if(s[i]%2==0) g++;
	}
	if(d==0){
		if(f>=1) printf("No\n");
		else if(g==a) printf("Yes\n");
	}
	else{
		if(d>=f) printf("Yes\n");
		else if(d+1==f&&d+f==a) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int W,H,N;
  cin>>W>>H>>N;
  int x,y,a;
  int x_min=0;
  int x_max=W;
  int y_min=0;
  int y_max=H;
  vector<vector<int>> v(N,vector<int>(3));
  for(int i=0;i<N;i++){
    cin>>x>>y>>a;
    switch(a){
      case 1:
        x_min=max(x,x_min);
        break;
      case 2:
        x_max=min(x,x_max);
        break;
      case 3:
        y_min=max(y,y_min);
        break;
      case 4:
        y_max=min(y,y_max);
        break;
      }
  }
  if(x_max < x_min || y_max < y_min){
    cout<<0<<endl;
  }else{
    cout<<(x_max-x_min)*(y_max-y_min)<<endl;
  }
}


Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: r,c,k,i,x,y,in,v1,v2
    integer(int64), allocatable:: mass(:,:)
    integer(int64), allocatable:: dp(:,:,:)

    read*, r,c,k
    allocate(mass(r,c), source=0_8)
    allocate(dp(0:3,0:r,0:c),source=0_8)

    do i=1,k
        block; integer(int64):: x,y,v
            read*, y,x,v
            mass(y,x) = v
        end block
    end do

    do y=1,r
        do x=1,c
            dp(0,y,x) = maxval(dp(:,y-1,x))
            if (mass(y,x)>0) dp(1,y,x) = maxval(dp(:,y-1,x)) + mass(y,x)
            do in=1,3
                v1 = dp(in,y,x-1)
                v2 = 0
                if (mass(y,x) > 0)v2 = dp(in-1,y,x-1)+mass(y,x)
                dp(in,y,x) = max(dp(in,y,x),v1,v2)
            end do
        end do
    end do
    print'(i0)', maxval(dp(:,r,c))

end program main

Measured memory_bytes: 354560
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n,m,k;
	cin>>n>>m>>k;

	string ans = "No";
	rep(i,n+1)rep(j,m+1){
		int odd = i*m + j*n - 2*i*j;
		if (odd == k){
			ans = "Yes";
		}
	}
	cout<<ans<<endl;

	return 0;
}

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

int main() {
  int N, A;
  cin >> N >> A;
  
  int only1 = N % 500;
  
  if (only1 <= A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())
x -= 1 # 1-indexed に注意
y -= 1
def dist(a, b):
    return min(b - a, abs(b - y) + abs(a - x) + 1)
ans = [0] * n
for i in range(n):
    for j in range(i + 1, n):
        ans[dist(i, j)] += 1
for i in range(1, n):
    print(ans[i])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 2e5+5,mod = 1e9+7;
it add(int x,int y){ return x+y>=mod?x+y-mod:x+y; }
it mul(int x,int y){ return 1ll*x*y%mod; }
il inc(int &x,int y){ x=add(x,y); }
int n,k,ans,sum[N];
it Calc(int x){
	int L=sum[x-1],R=sum[n];
	if(x<=n) inc(R,mod-sum[n-x]);
	return add(R+1,mod-L);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(k);
	for(ri i=1;i<=n;++i) sum[i]=add(sum[i-1],i);
	for(ri i=k;i<=n+1;++i) inc(ans,Calc(i));
	print(ans);
	return 0;
}

Measured memory_bytes: 4412
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDaydream solver = new CDaydream();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDaydream {
        public static final String[] STRINGS = {"esare", "resare", "maerd", "remaerd"};

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = new StringBuilder(in.next()).reverse().toString();
            int i = 0;
            outer:
            while (i < s.length()) {
                for (String k : STRINGS) {
                    if (s.startsWith(k, i)) {
                        i += k.length();
                        continue outer;
                    }
                }
                out.println("NO");
                return;
            }
            out.println("YES");
        }

    }
}



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

template <int B> // (1 << B) >= MAX_LEN
struct lowest_common_ancestor {
    vector<vector<int>> graph;
    int N, root;
    int parent[B][1 << B], depth[1 << B];

    lowest_common_ancestor() {}
    void init(int _root) {
        root = _root;

        N = graph.size();

        // set ancestors
        set_parent(root, -1, 0);
        for (int b = 1; b < B; ++b) {
            for (int i = 0; i < N; ++i) {
                if (parent[b-1][i] == -1) {
                    parent[b][i] = -1;
                } else {
                    parent[b][i] = parent[b-1][parent[b-1][i]];
                }
            }
        }
    }

    int query(int u, int v) {
        if (depth[u] > depth[v]) {
            int t = u; u = v; v = t;
        }

        for (int i = 0; i < B; ++i) {
            if ((((depth[v] - depth[u]) >> i) & 1) != 0) {
                v = parent[i][v];
            }
        } // depth[u] == depth[v]

        if (u == v) return u;

        for (int b = B-1; b >= 0; --b) {
            if (parent[b][u] != parent[b][v]) {
                u = parent[b][u];
                v = parent[b][v];
            }
        }

        return parent[0][u];
    }

private:
    void set_parent(int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        for (const int& e : graph[v]) {
            if (e != p) {
                set_parent(e, v, d+1);
            }
        }
    }
};

int N;
vector<vector<int>> g;
lowest_common_ancestor<17> lca;

int main() {
    cin >> N; lca.graph.resize(N);
    for (int j = 0; j < N; ++j) {
        int k; cin >> k;
        for (int x = 0; x < k; ++x) {
            int c; cin >> c;
            lca.graph[j].push_back(c);
        }
    }

    lca.init(0);

    int Q; cin >> Q;
    for (int j = 0; j < Q; ++j) {
        int u, v;
        cin >> u >> v;
        cout << lca.query(u, v) << endl;
    }
    return 0;
}

Measured memory_bytes: 18272
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int L;
	cin >> L;
	L--;
	if (L == 1)
	{
		puts("2 2");
		puts("1 2 0");
		puts("1 2 1");
		exit(0);
	}
	int n;
	vector<tuple<int, int, int>> ans;
	for (n = 0; (1 << n) <= L; n++)
	{
		ans.emplace_back(n + 1, n, 0);
		ans.emplace_back(n + 1, n, (1 << n));
	}
	n--;
	ans.pop_back();
	ans.pop_back();
	int cur = 0;
	for (int i = n; i >= 0; i--)
	{
		if (L >> i & 1)
		{
			if(cur) ans.emplace_back(n, i, cur);
			cur |= 1 << i;
		}
	}
	ans.emplace_back(n, 0, L);
	printf("%d %d\n", n + 1, (int)ans.size());
	for (auto& p : ans)
	{
		int x, y, w;
		tie(x, y, w) = p;
		x = n + 1 - x;
		y = n + 1 - y;
		printf("%d %d %d\n", x, y, w);
	}

	return 0;
}

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

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

  char s[4]={'A', 'C', 'G', 'T'};
  vector<int> n;

  int ans=0;
  for(int i = 0; i < S.size(); i++){
    if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
      ans++;
      n.push_back(ans);
    }else{
      ans =0;
      n.push_back(ans);
    }
  }

  int res = 0;
  for(int i = 0; i< n.size(); i++){
    res=max(n[i], res);
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  char A;
  cin >> A;
  if(A>='A'&&'Z'>=A){
    cout << "A" << endl;
  }else{
    cout << "a" << endl;
  }
}

Measured memory_bytes: 3616
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Thu Apr 26 21:15:23 2018
//
package main

import (
	"fmt"
)

var S string

func main() {
	fmt.Scan(&S)

	exists := make([]bool, 26)
	if len(S) == 26 {
		for index := 25; index >= 0; index-- {
			last := S[index]
			for c := last + 1; c <= 'z'; c++ {
				used := false
				for j := index; j >= 0; j-- {
					if c == S[j] {
						used = true
					}
				}
				if !used {
					fmt.Println(S[:index] + string(c))
					return
				}
			}
		}
		fmt.Println(-1)
	} else {
		for i := range S {
			exists[S[i]-'a'] = true
		}
		fmt.Print(S)
		for i, e := range exists {
			if !e {
				fmt.Println(string('a' + i))
				return
			}
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn=100017;
const ll mod=1000000007;

ll dp[maxn];
int main()
{
    ll n,m;
    cin>>n>>m;
    memset(dp,0,sizeof(dp));
    dp[1]=1;
    dp[2]=0;
    dp[0]=1;
    ll x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        dp[x]=-1;
    }
    for(int i=2;i<=n;i++)
    {
        if(dp[i]>=0&&dp[i-1]>0)
            dp[i]=(dp[i]+dp[i-1])%mod;
        if(dp[i]>=0&&dp[i-2]>0)
            dp[i]=(dp[i]+dp[i-2])%mod;
    }
    cout<<dp[n]%mod;
    return 0;
}
/*

*/


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod=1e9+7;
// Not for Rating """"""""""I'm in Love with Experience :)""""""""""""""""""
void solve()
{
    // ll N;cin>>N;
    // ll p=7;
    // if(N%2==0){cout<<"-1";return;}
    // while(p<=)
    ll N;cin>>N;
    string str;cin>>str;
    ll a=0;
    //bool flag=false;
    ll i=0,j=N-1;
    for(;i<j;)
    {
        //cout<<str[i]<<str[j];
        if(str[i]=='W' and str[j]=='R'){i++;j--;a++;}
        else if(str[i]=='R')i++;
        else if(str[j]=='W')j--;
        //cout<<a<<'\n';
    }
    cout<<a<<'\n';
}
int main(void)
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int T=1;while(T--){solve();}return 0;
}/*Solved By:- RITIK AGARWAL*/

Measured memory_bytes: 3716
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,q,tmp;
  cin >> n >> k >> q;
  ll a[q],b[n];
  fill(b,b+n,0);
  for(int i=0;i<q;i++){
    cin >> a[i];
    a[i]--;
    b[a[i]]++;
  }
  for(int i=0;i<n;i++){
    tmp = q-b[i];
    if(k-tmp<=0){
      cout <<"No\n";
    }else{
      cout <<"Yes\n";
    }
  }
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
//long long vis[10000001],prim[10000001];
long long nn,mm;
long long ans=1;

using namespace std;
/*
void prime()
{
	long long m=0;
	for(long long i=2;i<=n;i++)
	{
		if(vis[i]==0)
		{
			vis[i]=i;
			prim[++m]=i;
		}
		for(long long j=1;j<=m;j++)
		{
			if(prim[j]>vis[i]||prim[j]>n/i)
			break;
			vis[i*prim[j]]=prim[j];
		}
		
	}
}*/
long long a[1000001][2];
long long tot;
inline void prim()
{
	long long sq=sqrt(mm)+1,cnt;
	for(long long i=2;i<=sq;i++)
	if(mm%i==0)
	{
		tot++;
		cnt=0;
		a[tot][1]=i;
		while(mm%i==0)
		{
			cnt++;
			mm/=i;
		}
		a[tot][0]=cnt;
	}
}
long long kuai(long long kk,long long pp)
{
	long long anss=1,tmp=kk;
	for(long long i=pp;i;i>>=1)
	{
		if(i&1ll)
		{
			anss=anss*tmp;
		}
		tmp=tmp*tmp;
	}
	return anss;
}
/*
void did(long long mm)
{
	for(long long i=1;i<=1000001;i++)
	{
		long long bs=0;
		while(mm%prim[i]==0)
		{
			mm=mm/prim[i];
			bs++; 
		}
		long long ph=bs/nn;
		ans=ans*kuai(prim[i],ph);
		if(mm==1||prim[i+1]==0)
		{
			break;
		}
	}
}
*/
signed main()
{
	cin>>nn>>mm;
//	prime();
//	did(mm);
	if(nn==1)
	{
		cout<<mm<<endl;
		return 0;
	}
	a[++tot][1]=1;a[tot][0]=nn;
	prim();
	for(long long i=tot;i>=1;i--)
	if(a[i][0]>=nn)
	{
		long long tmp=a[i][0]/nn;
		ans*=kuai(a[i][1],tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main{
    static long [][] memo;
    static long [] pow = new long[33];
    static ArrayList <Integer> [] graph;
    static Integer [] d;
    static int [] dist;
    static boolean[][] visited;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        long MOD = 1000000007;
        //int t = sc.nextInt();
        int t = 1;
        while(t -- > 0)
        {
            int A = sc.nextInt();
            int B = sc.nextInt();
            int C = sc.nextInt();
            int D = sc.nextInt();
            //int k = sc.nextInt();
            int n = (C + B - 1) / B;
            int m = (A + D - 1) / D;
            if(n <= m)
            out.println("Yes");
            else
                out.println("No");
        }
        out.close();
    }
    public static void bfs(int source, int i, int g)
    {
        if(visited[i][g]) return;
        visited[i][g] = true;
        if(g == 0) graph[source].add(i);

        if(dist[i] <= g) bfs(source, i - 1, g - dist[i]);
        if(dist[i + 1] <= g) bfs(source, i + 1, g - dist[i + 1]);
    }
    public static long solve(long n){
        for(int i = 1; i < 33; i ++)
            if(n % pow[i] == 0)
                return n / pow[i];
        return -1;
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}


Measured memory_bytes: 32716
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int k; int X;
  cin >> k >> X;
  if (k*500 >= X) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Math;
using static System.Console;
using System.Collections.Generic;

partial class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(ReadLine());
        var k = int.Parse(ReadLine());
        var v = ReadLine()
            .Split(' ')
            .Select(x => int.Parse(x))
            .Select(x => Min(x, Abs(x - k)))
            .Select(x => x * 2)
            .Sum();
        WriteLine(v);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100+10;
double arr[maxn], total;

int main(){
    int N;

    cin >> N;

    total = 0;

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

    total = total + (1/(arr[i]));
    }

    cout << (1/total) << endl;
    
    
    }

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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

int main() {
  string s;
  cin >> s;
  cout << count(ALL(s),'1') << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
std::map <std::string,int> mp;
std::string s;
long long ans=0;
int main(){
	int n; std::cin>>n;
	while (std::cin >> s, std::sort (s.begin(),s.end()), n--){ ans+=mp[s]++; }
	std::cout<<ans;
}


Measured memory_bytes: 11136
N, K = map(int, input().split())
P = 0
for i in range(min(N,K-1)):
    tmp=1.0/float(N)
    now=i+1
    while now < K:
        now *= 2
        tmp /= 2
    P += tmp
if N > K-1:
    P += 1./float(N)*float(N-K+1)
print(P)

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


int gcd(int a, int b) {
    if (b==0) return a;
   	else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}


int main(){
	ll A,B,C,K;
	cin>>A>>B>>C>>K;
	ll MAX=pow(10,18);
	
	if(abs(A-B)>MAX){
		cout<<"Unfair"<<endl;
	}
	else if(K%2==0){
         cout<<A-B<<endl;
    }
    else cout<<B-A<<endl;
	
	return 0;
}
	

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 1000


int main(void){
	int n;
	scanf("%d",&n);
	double p[n];
	double q[n+1];
    double c[n+1][n+1];
	double d[n+1];
	for(int i=0 ; i<n ; i++)    scanf("%lf",&p[i]);
	for(int i=0 ; i<n+1 ; i++)   scanf("%lf",&q[i]);

	c[0][0]=q[0];
	d[0]=p[0]+q[0];
	
	for(int i=1 ; i<n+1 ; i++){
		c[i][i]=q[i];
		c[i-1][i]=p[i-1]+(q[i-1]+q[i])*2;
		d[i]=d[i-1]+p[i]+q[i];
	}

	double s,t;
	for(int i=1 ; i<n ; i++){
		for(int j=0 ; j<n-i ; j++) {
			s = c[j][j] + c[j+1][i+j+1];
			for (int k=j ; k<i+j ; k++) {
				t = c[j][k+1] + c[k+2][i+j+1];
				if (s>t)    s=t;
			}
			c[j][i+j+1] = s + d[i+j] - d[j-1] + q[i+j+1];
		}
	}
	printf("%lf\n", c[0][n]);
	return 0;
}



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


int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.rbegin(), a.rend());

  int t = n - 1;
  ll ans = 0;
  rep(i,n){
    int lim = 2;
    if (i == 0) lim = 1;
    rep(j,lim){
      if (t > 0){
        ans += a.at(i);
        t--;
      }
    }
  }

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

// int main(){
  //   int n;
  //   cin >> n;
  //
  //   vi a(n);
  //   rep(i,n) cin >> a.at(i);
  //   sort(a.begin(), a.end());
  //   reverse(a.begin(), a.end());
  //
  //   int cnt = 0;
  //   ll ans = 0;
  //   cnt++;
  //   ans += a.at(0);
  //   cnt++;
  //   REP(i,1,n){
    //     if (cnt == n) break;
    //     ans += a.at(i);
    //     cnt++;
    //     if (cnt == n) break;
    //     ans += a.at(i);
    //     cnt++;
    //     if (cnt == n) break;
    //   }
    //   cout << ans << endl;
    //   return 0;
    // }


Measured memory_bytes: 4052
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10, mod = 1e9 + 7;

ll pwr(ll x, ll e);

int main() {
	fast_cin();
	ll h, w, t;
	cin >> h >> w >> t;
	ll l = (h / __gcd(h, w)) * w;
	ll g = __gcd(t, l);
	ll gw = __gcd(g, w);
	ll gh = __gcd(g, h);
	ll ans = pwr(2, h / gh) + pwr(2, w / gw) + pwr(2, __gcd(w / gw, h / gh)) + mod - 3;
	ans = pwr(ans % mod, gh * gw);
	cout << ans << endl;
}

ll pwr(ll x, ll e) {
	ll res = 1;
	while (e) {
		if (e & 1) {
			res = (res * x) % mod;
		}
		e /= 2;
		x = (x * x) % mod;
	}
	return res;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from copy import deepcopy

def sieve(n):
    prime = []
    limit = n ** 0.5
    data = [i + 1 for i in range(1,n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e%p != 0]


def main():
    primes = sieve(1000005)
    n = int(input())
    div = set()
    for i in range(2,int(n ** 0.5) + 1):
        if n%i == 0:
            div.add(i)
            div.add(n//i)
    
    ans = 0
    for d in div:
        k = deepcopy(n)
        while k%d == 0:
            k //= d
        if k%d == 1:
            ans += 1
    
    m2 = n - 1
    cnt = 1
    for p in primes:
        tmp = 1
        while  m2%p == 0:
            m2 //= p
            tmp += 1
        cnt *= tmp           
    
    if m2 != 1:
        cnt *= 2
    
    print(ans + cnt)

if __name__ =='__main__':
    main()  

Measured memory_bytes: 47056
// SeeAlso: https://atcoder.jp/contests/dp/tasks/dp_a

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int n;
int h[MAX];


int main (){ 

    cin >> n;
    memset(h, 0, sizeof(h));
    rep(i, n) {
        cin >> h[i];
    }
    
    ll dp[n+5];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    rep(i, n) {
        FOR(j,i+1,i+3) {
            if(dp[j] >= 0) {
                dp[j] = min(dp[j], dp[i]+abs(h[j]-h[i]));
            } else {
                dp[j] = dp[i]+abs(h[j]-h[i]);
            }
        }
    }

    print(dp[n-1]);
    return 0;
}   

Measured memory_bytes: 1408
ans = 0

n = int(raw_input())
blue = []
for i in range(0, n):
	blue.append(raw_input())

m = int(raw_input())
red = []
for i in range(0, m):
	red.append(raw_input())

while blue != []:
	countblue = 0
	countred = 0
	blueword = blue[0]
	while blueword in blue:
		countblue = countblue + 1
		blue.remove(blueword)
	while blueword in red:
		countred = countred + 1
		red.remove(blueword)
	if countblue - countred > ans:
		ans = countblue - countred

print ans


Measured memory_bytes: 2568
n,k=map(int,input().split())
if k % 2 != 0:
  print((n // k) ** 3)
else:
  if n % k >= k // 2:
    print((n // k) ** 3 + (n // k + 1) ** 3)
  else:
    print((n // k) ** 3 + (n // k) ** 3)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0;
  cin >>a>>b>>c;
  a=a*b;
  if(a>c) cout <<c<<'\n';
  else cout <<a<<'\n';
  return (0);
}


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

using namespace std;
static const int INF = 1000000000;
static int table[2][4001][2001];
static int dp[2001][2001];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	const int m = 2 * n;
	vector<int> color(m);
	vector<int> value(m);
	for(int i = 0; i < m; ++i){
		string s;
		int x;
		cin >> s >> x;
		color[i] = (s[0] == 'W' ? 0 : 1);
		value[i] = x - 1;
	}
	vector<int> inv[2] = { vector<int>(n), vector<int>(n) };
	for(int i = 0; i < m; ++i){
		inv[color[i]][value[i]] = i;
	}

	for(int c = 0; c < 2; ++c){
		for(int j = 0; j <= n; ++j){ table[c][0][j] = 0; }
		for(int i = 1; i <= m; ++i){
			for(int j = 0; j <= n; ++j){
				table[c][i][j] = table[c][i - 1][j];
			}
			if(color[i - 1] == c){
				for(int j = value[i - 1] + 1; j <= n; ++j){
					++table[c][i][j];
				}
			}
		}
	}
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= n; ++j){ dp[i][j] = INF; }
	}
	dp[0][0] = 0;
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= n; ++j){
			if(i < n){
				const int p = inv[0][i];
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + p - table[0][p][i] - table[1][p][j]);
			}
			if(j < n){
				const int p = inv[1][j];
				dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + p - table[0][p][i] - table[1][p][j]);
			}
		}
	}
	cout << dp[n][n] << endl;
	return 0;
}



Measured memory_bytes: 78464
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  GS(s);
  for (string prm : {"SS", "SW", "WS", "WW"}) {
    string ans = prm;
    for (int i = 1; i < N - 1; ++i) {
      if (s[i] == 'o' ^ ans[i] == 'W') {
        ans += ans[i - 1];
      } else {
        ans += ans[i - 1] == 'S' ? 'W' : 'S';
      }
    }
    if ((ans[0] == 'W') ^ (s[0] == 'o') ^ (ans[1] != ans[N - 1])) {
      if ((ans[N - 1] == 'W') ^ (s[N - 1] == 'o') ^ (ans[0] != ans[N - 2])) {
        print(ans);
        return 0;
      }
    }
  }
  print(-1);
  return 0;
}

Measured memory_bytes: 776
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
n, m = map(int, input().split())
Hs = list(map(int, input().split()))
spots = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    if (Hs[a - 1] >= Hs[b - 1]):
        spots[b-1] += 1
    if (Hs[a - 1] <= Hs[b - 1]):
        spots[a-1] += 1
ans = 0
for spot in spots:
    if(spot == 0):
        ans += 1
print(ans)


Measured memory_bytes: 20120
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

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

	int n;
	cin >> n;

	vector<int> vals(n);
	for (int i = 0; i < n; ++i) cin >> vals[i];
	sort(vals.begin(), vals.end());
	int h = n/2;
	cout << vals[h] - vals[h-1] << '\n';
}


Measured memory_bytes: 640
n = int(input())
h = list(map(int,input().split()))

ans = 1
done = 0
h[0] = h[0] - 1

for i in range(1,n):
    if h[i] > h[i-1]:
        h[i] = h[i]-1

    if h[i-1] > h[i]:
        ans = 0
        done = 1
    if done:
        break

#for i in range(1,n):
 #   print(h[i])

if(ans):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 63984
'use strict';
(function(stdin) {
  //declare function
  function square(array) {
    var h = array[0];
    var w = array[1];
    var outLine = [];
    for (var i = 0; i < w; i++) {
      outLine.push('#');
    }
    outLine = outLine.join('');
    var inLine = [];
    for (var j = 0; j < w - 2; j++) {
      inLine.push('.');
    }
    inLine.push('#');
    inLine.unshift('#');
    inLine = inLine.join('');
    var result = [];
    for (var k = 0; k < h - 2; k++) {
      result.push(inLine);
    }
    result.push(outLine);
    result.unshift(outLine);
    return result.join('\n');
  }

  //declare variable
  var inputs = stdin.toString().trim().split('\n');
  var line = inputs.slice(0, inputs.indexOf('0 0'));
  line = line.map(function(v) {
    return v.split(' ').map(Number);
  });
  //main
  var all = line.map(square).join('\n\n');
  //display
  console.log(all + '\n');
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 15532
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

int main()
{
	FASTIO

	ll n;
	cin >> n;
	ll ans = 0;
	for(ll i = 1; i < n; i ++)
	{
		ans += (n - 1) / i;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3684
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 1e5 + 5;

vector <int> g[N];
int n, m;
int par[N];

void solve() {
  memset(par, -1, sizeof par);
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  queue <int> q;
  q.push(1);
  while(not q.empty()) {
    int u = q.front();
    q.pop();
    for(auto v : g[u]) {
      if(par[v] == -1) {
        par[v] = u;
        q.push(v);
      }
    }
  }
  for(int i = 2; i <= n; i++) {
    if(par[i] == -1) {
      print("No");
      return;
    }
  }
  print("Yes");
  for(int i = 2; i <= n; i++) cout << par[i] << '\n';
}

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

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int F(int v) {
	int ret=0;
	while(v) {
		ret+=v%10;
		v/=10;
	}
	return ret;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x;
	if(x%F(x)) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

//flagを用いたソート
int bubblesort(int a[],int n){
    int sw=0;
    bool flag=1;
    for(int i=0;flag;i++){
        flag=0;
        for(int j=n-1;j>=i+1;j--){
            if(a[j]<a[j-1]){
                //隣接要素を交換する
                swap(a[j],a[j-1]);
                flag=1;
                sw++;
            }
        }
    }
    return sw;
}

int main(){
    int a[100],n,sw;
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    sw=bubblesort(a,n);
    for(int i=0;i<n;i++){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << sw << endl;
    return 0;
}



Measured memory_bytes: 3084
import Control.Monad
import Control.Applicative
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.Maybe


main :: IO ()
main = do
  n <- read <$> getLine
  as <- VU.map (subtract 1)
      . VU.unfoldrN n (BSL.readInt . BSL.dropWhile (<'!')) <$> BSL.getContents
  print $ fromMaybe (-1)
        $ VU.elemIndex 1 $ VU.iterateN (n+1) (as VU.!) 0


Measured memory_bytes: 2428
/*
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
*/
#include<bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define db double
#define ull unsigned long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
const int M = 200003;
const double pi = acos(-1.0);
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int pos[maxn],a[maxn],cnt[maxn];
ll G[maxn];
int r[maxn<<2];
void init()
{
    int g = 2;
    G[0] = 1;
    pos[1] = 0;
    rep(i,1,M-1){
        G[i] = (G[i-1] * g) % M;
        pos[G[i]] = i;
    }
}
struct cpx
{
    double x,y;
    cpx(double xx=0,double yy=0) {x=xx,y=yy;}
    cpx operator + (cpx b) {return cpx(x+b.x,y+b.y);}
    cpx operator - (cpx b) {return cpx(x-b.x,y-b.y);}
    cpx operator * (cpx b) {return cpx(x*b.x-y*b.y,x*b.y+y*b.x);}
}A[maxn<<2],B[maxn<<2];
void FFT(cpx *a,int lim,int type)
{
    rep(i,0,lim) if(i<r[i]) swap(a[i],a[r[i]]);
    for(int mid=1;mid<lim;mid<<=1){
        cpx wn(cos(pi/mid),type*sin(pi/mid));
        for(int R=mid<<1,j=0;j<lim;j+=R){
            cpx w(1,0);
            for(int k=0;k<mid;k++,w=w*wn){
                cpx x = a[j+k],y = w*a[j+k+mid];
                a[j+k] = x+y;
                a[j+k+mid] = x-y;
            }
        }
    }
    if(type==-1){
        rep(i,0,lim) a[i].x /= lim;
    }
}

int main()
{
    fastio(); init();
    int n; cin>>n;
    rep(i,1,n) {
        cin>>a[i];
        if(a[i]>0) cnt[pos[a[i]]]++;
    }
    rep(i,0,M-1){
        A[i].x = B[i].x = cnt[i];
    }
    int lim = 1,l = 0;
    while(lim<=2*M) lim<<=1,l++;
    rep(i,1,lim-1) r[i] = (r[i>>1]>>1) | ((i&1)<<(l-1));
    FFT(A,lim,1);FFT(B,lim,1);
    rep(i,0,lim) A[i] = A[i]*B[i];
    FFT(A,lim,-1);

    ll ans = 0;
    rep(i,0,lim){
        ans += llround(A[i].x) * G[i%(M-1)];
    }
    rep(i,0,M-1) ans -= 1LL * cnt[i] * (G[i] * G[i] % M);
    cout<<ans/2<<endl;
    return 0;
}


Measured memory_bytes: 34912
import itertools

S = input()
N = len(S)
#print(S)

ans = 0
for v in itertools.product([1,0],repeat=N-1):
    start = 0
    for i in range(N-1):
        if v[i] == 1:
            stop = i+1
            ans += int(S[start:stop])
            start = stop
    ans += int(S[start:N])

print(ans)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int s[200050];
int main()
{
    int n,l=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&s[i]);
    int cnt=1;
    for(int i=0;i<n;i++){
        if(s[i]==cnt)
            cnt++;
    }
    if(cnt!=1)
        printf("%d\n",n-cnt+1);
    else puts("-1");
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

const int MAXN = 3005;

char s[MAXN], t[MAXN], ans[MAXN];

int f[MAXN][MAXN];
std::pair<int, int> pre[MAXN][MAXN];

int main() {
    scanf("%s %s", s + 1, t + 1);

    int ns = std::strlen(s + 1), nt = std::strlen(t + 1);

    for (int i = 1; i <= ns; i++) for (int j = 1; j <= nt; j++) {
        if (f[i - 1][j] > f[i][j - 1]) {
            f[i][j] = f[i - 1][j];
            pre[i][j] = std::make_pair(i - 1, j);
        } else {
            f[i][j] = f[i][j - 1];
            pre[i][j] = std::make_pair(i, j - 1);
        }
        if (s[i] == t[j] && f[i - 1][j - 1] + 1 > f[i][j]) {
            f[i][j] = f[i - 1][j - 1] + 1;
            pre[i][j] = std::make_pair(i - 1, j - 1);
        }
    }

    int p = f[ns][nt];
    for (auto i = std::make_pair(ns, nt); i.first || i.second; i = pre[i.first][i.second]) {
        auto j = pre[i.first][i.second];
        if (f[i.first][i.second] == f[j.first][j.second] + 1) ans[--p] = s[i.first];
    }
    printf("%s\n", ans);
    
    return 0;
}

Measured memory_bytes: 105984