akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 35

int dp[SIZE][1<<16];

void calc(int n){
  int c;
  int in;
  int a[SIZE] = {} ,b[SIZE] = {};
  
  scanf("%d",&c);

  for(int i=0;i<n;i++){

    for(int j=0;j<16;j++){
      scanf("%d",&in);
      a[i] = a[i]*2 + in;
    }

  }

  for(int i=0;i<c;i++){

    for(int j=0;j<16;j++){
      scanf("%d",&in);
      b[i] = b[i]*2 + in;
    }

  }
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<(1<<16);j++){
      dp[i][j] = -INF;
    }
  }

  dp[0][0] = 0;

  for(int i=0;i<n;i++){
    for(int j=0;j<(1<<16);j++){
      if(dp[i][j] == -INF) continue;
      
      int now = j | a[i];
      
      for(int k=0;k<c;k++){
        int p = __builtin_popcount(now & b[k]);
        
        dp[i+1][now & (~(now & b[k]))] =
          max(dp[i+1][now & (~(now & b[k]))],dp[i][j] + p);        
      }

      dp[i+1][now] = max(dp[i][j],dp[i+1][now]);
    }
  }

  int ans = 0;

  for(int i=0;i<(1<<16);i++){
    ans = max(ans,dp[n][i]);
  }

  printf("%d\n",ans);
}
  

int main(){
  int n;

  while(scanf("%d",&n)!=EOF){
    if(n==0) break;
    calc(n);
  }
  
  return 0;
}

Measured memory_bytes: 9380
object Main{
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val h0 = sc.nextInt()
    val w0 = sc.nextInt()
    val h = sc.nextInt()
    val w = sc.nextInt()
    println((h0-h) * (w0-w))
  }
}

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

typedef long long INT;

int main(){
    INT N;
    INT M;
    std::cin >> N >> M;

    INT l,i=0,a[N];
    while(std::cin >> l){
        a[i]=l;
        i++;
        if(i>=N)break;
    }

    std::sort(a,a+N,std::greater<INT>());

    long double sum = 0;
    for(INT i = 0;i<N;i++){
        sum +=a[i];
    }

    long double bd = (long double)sum*(1/(4*(long double)M));
    

    bool ok = true;

    for(INT i = 0;i<M;i++){
        if(a[i]<bd)ok=false;
    }

    if(ok)std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	int a,b,x;
	cin>>x>>a>>b;
	x-=a;
	cout<<x%b<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
D=list(map(int,input().split()))
T=[[] for _ in range(max(D)+1)]
for i in range(n):
    T[D[i]].append(i+1)
if T[0]!=[1]:
    print(0)
    exit()
a=1
for j in range(1,len(T)):
    if T[j]==[]:
        print(0)
        exit()
    else:
        a*=len(T[j-1])**len(T[j])
        a%=998244353
print(a)

Measured memory_bytes: 21888
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;
const int inf = 1e9 + 7;

int main() {
	int n;
	double t,a;
	cin>>n>>t>>a;
	double x[n];
	int ans=0;
	double ret=inf;
	rep(i,n){
		cin>>x[i];
		x[i]=t-0.006*x[i];
		if(ret>abs(x[i]-a)){
			ans=i+1;
			ret=abs(x[i]-a);
		}
	}
	cout<<ans<<endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n,m;
  cin >> n >> m;
  vector<ll>a(m),b(m),c(m,0);
  rep(i,m){
    cin >> a[i] >> b[i];
    rep(j,b[i]){
      ll d;
      cin >> d;
      c[i]+= 1<<(d-1);
    }
  }
  vector<vector<ll>>dp(m+1,vector<ll>(1<<n,1e18));
  dp[0][0]=0;
  rep(i,m){
    rep(j,1<<n){
      dp[i+1][j]=dp[i][j];
    }
    rep(j,1<<n){
      dp[i+1][j|c[i]]=min(dp[i+1][j|c[i]],dp[i][j]+a[i]);
    }
  }
  if(dp[m][(1<<n)-1]==1e18) cout << -1 << endl;
  else cout << dp[m][(1<<n)-1] << endl;

}


Measured memory_bytes: 32384
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

x,k,d = map(int, input().split())

x = abs(x)

if x == 0:
    if k % 2 == 0:
        print(0)
        exit()
    else:
        print(abs(d))
        exit()

bai = x//d

if bai >= k:
    print(x-k*d)
    exit()
else:
    x -= bai*d
    if (k-bai)%2==0:
        print(x)
        exit()
    else:
        print(abs(x-d))




Measured memory_bytes: 9156
import java.util.Scanner;

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



		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		
		System.out.println(n*n);
		
		
		
		
		
	}

	

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 22996
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using ll = long long;
using namespace std;
char g[900][900];
int vis[900][900];
int H, W, K;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> H >> W >> K;
  int x0, y0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> g[i][j];
      if (g[i][j] == 'S') {
        x0 = i;
        y0 = j;
      }
    }
  }

  vis[x0][y0] = 1;

  vector<pair<int, int>> pos;

  pos.push_back({x0, y0});
  vector<pair<int, int>> apos;

  auto checkAdd = [&apos](const int x, const int y, vector<pair<int, int>> &npos) {
    if (x < 0 || x >= H || y < 0 || y >= W) return;
    if (vis[x][y] || g[x][y] == '#') return;
    vis[x][y] = 1;

    npos.push_back({x, y});
    apos.push_back({x, y});
  };
  int ct = 0;
  apos.push_back({x0, y0});
  while (ct < K && pos.size()) {
    vector<pair<int, int>> npos;
    for (auto &p : pos) {
      apos.push_back(p);
      int x = p.first;
      int y = p.second;
      checkAdd(x + 1, y, npos);
      checkAdd(x - 1, y, npos);
      checkAdd(x, y + 1, npos);
      checkAdd(x, y - 1, npos);
    }

    swap(pos, npos);
    ct++;
  }
  int ret = 800 * 800 + 1000;
  for (auto &p : apos) {
    int x = p.first;
    int y = p.second;
    int mstep = min({x, y, H - x - 1, W - y - 1});
    ret = min(ret, (mstep + K - 1) / K + 1);
  }

  cout << ret << endl;
}

Measured memory_bytes: 21224
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

using ull = unsigned long long;
using ll = long long;

// code
// ------------------------------------------------
int main() {

  ll h,w;
  cin >> h >> w;

  vector<string> s(h);

  rep(i,h) cin >> s[i];

  bool ans = true;

  rep(i,h)
  rep(j,w)
  {
    if(s[i][j] == '#')
    {
      bool ue = true;
      bool shita = true;
      bool migi = true;
      bool hidari = true;

      // ue
      if(0 < i)
      {
        if(s[i - 1][j] == '.') ue = false;
      }

      // shita
      if( i < h - 1)
      {
        if(s[i + 1][j] == '.') shita = false;
      }

      // hidari
      if( 0 < j)
      {
        if(s[i][j - 1] == '.') hidari = false;
      }

      // migi
      if( j < h - 1 )
      {
        if(s[i][j + 1] == '.') migi = false;
      }

      if(ue == false && shita == false && migi == false && hidari == false )
      {
        ans = false;
        break;
      }
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include <unistd.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define istream ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define uint unsigned int
#define mod 1000000007
#define vec vector<int>
#define twod vector<vector<int>>
#define mp make_pair
#define pbc push_back
#define all(a) a.begin(),a.end()
#define debug1(x)                cout<<#x<<"="<<x<<endl;
#define debug2(x,y)              cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z)            cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define debugarray(arr,j,n)      for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";};

int32_t main()
{
     int n,w;
     scanf("%lld%lld",&n,&w);
     vec wts;
     vec vals;
     int sumval = 0;
     for(int i=0;i<n;i++){
          int t1,t2;
          scanf("%lld%lld",&t1,&t2);
          wts.pbc(t1);
          vals.pbc(t2);
          sumval+=vals[i];
     }
     vec knapsack(sumval+1,INT_MAX);
     knapsack[0]=0;
     for(int i=0;i<n;i++){
          int val = vals[i];
          for(int j=sumval-val;j >= 0;j--){
               knapsack[j+val] = min(knapsack[j]+wts[i],knapsack[j+val]);

          }
     }
     int ans = 0;
     for(int i=0;i<=sumval;i++){
          if(knapsack[i]<=w)
               ans = max(ans, i);
     }
     cout<<ans;
     return 0;
}


Measured memory_bytes: 4072
#!/usr/bin/env python
# coding: utf-8

# In[21]:


N = int(input())
A = list(map(int, input().split()))


# In[22]:


A_s = sorted(enumerate(A), key=lambda x: x[1], reverse=False)
# print(A_s)
odr = [str(idx+1) for idx,x in A_s]
print(" ".join(odr))


# In[ ]:






Measured memory_bytes: 25824
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    string s;
    cin >> s;
    int N = s.size();
    for (int i = 0; i < N; i += 2) {
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 512
arr = (0...5).map { gets.to_i }
@min_amari = 10
@min_amari_v = nil
arr.each do |num|
  amari = num % 10 
  if amari > 0 && @min_amari > amari
    @min_amari = amari
    @min_amari_v = num
  end
end

sum = 0
non_last = true
arr.each do |v|
  if (v == @min_amari_v) && non_last
    sum += v
    non_last = false
  elsif v % 10 == 0
    sum += v
  else
    sum += (v + 10 - (v % 10))
  end
end

puts sum


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

void sieve(int x)
{
    int n=1000000;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]==true && p>=x){
            cout<<p<<"\n";
            break;
       }
}

int main()
{
    fastio;
    int n;
    cin>>n;
    sieve(n);
    return 0;
}


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

int main() {
    long long n,k;
    cin >> n >> k;
    if(n % k == 0) {
        cout << "0";
    } else {
        n = n % k;
        if(abs(n-k) < n)
            cout << abs(n-k);
        else
            cout << n;
    }
}

Measured memory_bytes: 256
#include<stdio.h>




int main(){
	int N,K;
	int S[100];
	int B;
	int count;
	int h=1;

	int i,j;

	scanf("%d %d",&N,&K);

	while((N!=0)&&(K!=0)){
		h=1;
		for(i=0;i<K;i++){
			scanf("%d",&S[i]);
		}

		for(i=0;i<N;i++){
			for(j=0;j<K;j++){
				scanf("%d",&B);
				S[j]=S[j]-B;
				if(S[j]<0){
					h=0;
				}
			}
		}


		if(h==1){
			printf("Yes\n");
		}else{
			printf("No\n");
		}


		scanf("%d %d",&N,&K);
	}

	return 0;

}

Measured memory_bytes: 732
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	string s;
	cin>>s;
	cout<<s.substr(0,4)<<" "<<s.substr(4,s.size()-4)<<endl;
}

Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
 
sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

MOD = 10 ** 9 + 7
N, K = map(int, input().split())
count = Counter()
for i in reversed(range(1, K + 1)):
    c = pow(K // i, N, MOD)
    j = 2
    while i * j <= K:
        c -= count[i * j]
        j += 1
    count[i] = c
print(sum(i * j for i, j in count.items()) % MOD)


Measured memory_bytes: 85288
/**
 * AOJ #1109: Fermat's Last Theorem (ICPC Domestic 2000)
 */

#include <stdio.h>

#define CUBE(x) ((x)*(x)*(x))

/**
 * Compute z^3 - max{ x^3+y^3 | x>0, y>0, x^3+y^3 <= z^3 }.
 */
int fermat(int z)
{
  int x, y, max = 0;
  for (x = 1; x < z; x++) {
    for (y = x; CUBE(x) + CUBE(y) <= CUBE(z); y++) {
      if (max < CUBE(x) + CUBE(y)) {
          max = CUBE(x) + CUBE(y);
      }
    }
  }
  return CUBE(z) - max;
}

int main()
{
  int z;
  for (;;) {
    scanf("%d", &z);
    if (z == 0) break;
    printf("%d\n", fermat(z));
  }
  return 0;
}

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

int main(){
    int N;cin>>N;
    set<string> A;
    string s,t;
    for(int i=0;i<N;i++){
        cin>>s>>t;
        if(s=="insert")A.insert(t);
        else{
            if(A.count(t))cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 32608
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a + b <= b + c && a + b <= a + c) {

			System.out.println(a + b);

		} else if (a + c <= a + b && a + c <= b + c) {

			System.out.println(a + c);

		} else if (b + c <= a + c && b + c <= a + b) {

			System.out.println(b + c);

		}

	}
}


Measured memory_bytes: 21588
str = $stdin.read.downcase.scan(/[a-z]/)

  # a~zのハッシュ作成
  alp = {}
  ("a".."z").each do | a |
    alp[a] = 0
  end
  
  # a~zのハッシュに標準入力の文字数を加算
  str.each do | a |
    alp[a] += 1
  end

  # 出力
  alp.each do |key,value|
    puts "#{key} : #{value}"
  end


Measured memory_bytes: 6860
from collections import deque

n = int(input())
Adj_dict = {x:[] for x in range(1, n+1)}
for _ in range(n-1):
    u, v, w = map(int, input().split())
    Adj_dict[u].append([v,w])
    Adj_dict[v].append([u,w])

dq = deque()
dq.append(1)
Visited = [-1 for _ in range(n+1)]
Visited[1] = 0

while dq:
    now = dq.popleft()
    Adjs = Adj_dict[now]
    for adj in Adjs:
        if Visited[adj[0]] != -1:
            continue
        else:
            dq.append(adj[0])
            Visited[adj[0]] = Visited[now] + adj[1]

for i in range(1,n+1):
    print(Visited[i]%2)


Measured memory_bytes: 57864
def Get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def Get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def Get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def Get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end

n=gets.to_i
a=Get_i()

ava1=(a.inject(:+).to_f/n.to_f).ceil
ava2=(a.inject(:+).to_f/n.to_f).floor
ans1=a.map{|x| (x-ava1)**2}.inject(:+)
ans2=a.map{|x| (x-ava2)**2}.inject(:+) 
puts ans1<ans2 ? ans1 : ans2

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
 int n;
  cin >>n;
  
  vector<string> s(n);
  
  for(int i=0;i<n;i++) cin >> s[i];
  
  bool res=true;
   for(int i=1;i<n;i++){
     if(s[i-1][s[i-1].length()-1]!=s[i][0]) res=false;
   }
  
   for(int i=1;i<n;i++){
     for(int j=0;j<i;j++){
       if(s[i]==s[j]) res=false;
     }
   }
  
  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

string S;
int N;
ll k;

int dp1[2010][2010];
int f1(int l, int r){
	int& d = dp1[l][r];
	if(d != -1) return d;
	if(l > r) return d = 0;
	if(l == r) return d = 1;
	if(l + 1 == r && S[l] == S[r]) return d = 2;

	d = 1e9;
	d = min(d, f1(l + 1, r) + 2);
	d = min(d, f1(l, r - 1) + 2);
	if(S[l] == S[r]) d = min(d, f1(l + 1, r - 1) + 2);
	return d;
}

ll dp2[2010][2010];
ll f2(int l, int r, int rem){
	ll& d = dp2[l][r];
	if(rem < f1(l, r)) return 0;
	if(d != -1) return d;
	if(l >= r) return d = 1;
	if(l + 1 == r && S[l] == S[r]) return d = 1;

	d = 0;
	for(char i = 'a'; i <= 'z'; i++){
		int nl = l, nr = r;
		if(S[l] == i) nl++;
		if(S[r] == i) nr--;
		d += f2(nl, nr, rem - 2);
		d = min(d, k + 1);
	}
	return d;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(cin >> S >> k){
		N = S.size();
		memset(dp1, -1, sizeof dp1);
		memset(dp2, -1, sizeof dp2);
		int minlen = f1(0, N - 1);

		if(minlen == 1){
			if(k == 1) cout << S << endl;
			else cout << "NONE" << endl;
			continue;
		}
		string ans;
		int l = 0, r = N - 1;
		bool ok = true;
		for(int i = 0; i < minlen / 2; i++){
			char nxt = 0;
			int L = 0, R = 0;
			ll sum = 0;
			for(char c = 'a'; c <= 'z'; c++){
				int nl = l, nr = r;
				if(S[l] == c) nl++;
				if(S[r] == c) nr--;
				ll res = f2(nl, nr, minlen - 2 * (i + 1));
				if(sum + res < k){
					sum += res;
				}
				else{
					nxt = c;
					L = nl, R = nr;
					break;
				}
			}
			if(nxt){
				k -= sum;
				ans += nxt;
				l = L, r = R;
			}
			else{
				ok = false;
				break;
			}
		}

		if(!ok){
			cout << "NONE" << endl;
		}
		else{
			string rev = ans;
			reverse(rev.begin(), rev.end());
			if(minlen % 2){
				ans = ans + S[l] + rev;
			}
			else{
				ans += rev;
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 50708
H,W,K = map(int, input().split())
mod = 10**9+7

horz_pattern = 0
horz_pattern_fromleft = [0] * W
horz_pattern_fromright = [0] * W
for i in range(2**(W-1)):
  horz = bin(i+2**(W-1))[3:]
  ok = 1
  for j in range(W-2):
    if int(horz[j]) * int(horz[j+1]) == 1:
      ok = 0
      break
  if ok:
    horz_pattern += 1
    for bar in range(W-1):
      if horz[bar] == "1":
        horz_pattern_fromleft[bar+1] += 1
        horz_pattern_fromright[bar] += 1

dp = [[0 for w in range(W+2)] for h in range(H+1)]
dp[0][1] = 1
for h in range(1,H+1):
  for w in range(1,W+1):
    fromleft = horz_pattern_fromleft[w-1]
    fromright = horz_pattern_fromright[w-1]
    no_move = horz_pattern - fromleft - fromright
    dp[h][w] = (dp[h-1][w] * no_move
    		  + dp[h-1][w-1] * fromleft
      		  + dp[h-1][w+1] * fromright) % mod
print(dp[H][K])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for (int i=0;i<M;i++) {
    cin >> A.at(i);
  }
  
  int k=M;
  for (int i=0;i<M;i++) {
    if (X < A.at(i)) {
      k=i;
      break;
    }
  }
  
  cout << min(k, M-k) << endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define PB push_back
#define MP make_pair
#define F first
#define S second

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


int main(){
	int d,g;
	cin >>d>>g;
	int y,x,ans=10000;
	vector<int>pp(d),p(d),c(d);
	REP(i,d) cin >>pp[i]>>c[i];
	REP(bit,1<<d){
		p=pp,x=0,y=0;
		REP(i,d){
			if(bit&(1<<i)){
				y+=p[i]*(i+1)*100+c[i];
				x+=p[i];
				p[i]=0;
			}
		}
		if(y<g){
			REPD(i,d){
				while(p[i]!=0){
					y+=(i+1)*100;
					p[i]--;
					x++;
					if(p[i]==0)y+=p[i]*(i+1)*100+c[i];
					if(y>=g)goto label;
				}
			}
		}
		label:
		chmin(ans,x);
	}
	cout<< ans<<endl;
}


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

int main(){
    int n,m;
    cin>>n;
    set <int> a;
    for (int i=0;i<n;i++){
        cin>>m;
        a.emplace(m);
    }
    if (a.size()!=n) cout<<"NO";
    else cout<<"YES";
}


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

int main()
{
	int N;
	long long K;
	cin >> N >> K;
	vector<long long> A( N );
	for( int i = 0; i < N; i++ )  {
		cin >> A[i];
	}

	const long long MOD = 1000000000 + 7;
	long long ans1 = 0;
	for( int i = 0; i < N; i++ ) {
		for( int j = i + 1; j < N; j++ ) {
			if( A[i] > A[j] ) ans1++;
		}
	}
	long long ans2 = 0;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			if( A[i] > A[j] ) ans2++;
		}
	}
	auto power = [&]( long long x, long long n )
	{
		long long res = 1;
		while( n > 0 ) {
			if( n % 2 ) res = res * x % MOD;
			x = x * x % MOD;
			n /= 2;
		}
		return res;
	};
	long long ans = ans1 * K % MOD + ans2 * K % MOD * (K - 1) % MOD * power( 2, MOD - 2 );
	ans %= MOD;

	cout << ans << endl;
}


Measured memory_bytes: 3628
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int H, W; string s[55];
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> s[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') cout << '#';
			else {
				int cnt = 0;
				for (int k = -1; k <= 1; k++) {
					for (int l = -1; l <= 1; l++) {
						int tx = i + k, ty = j + l;
						if (0 <= tx && tx < H && 0 <= ty && ty < W && s[tx][ty] == '#') {
							cnt++;
						}
					}
				}
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
lst = [0, abs(h[1]-h[0])]
for i in range(2, n):
    lst.append(min(lst[i-1]+abs(h[i]-h[i-1]), lst[i-2]+abs(h[i]-h[i-2])))
print(lst[-1])

Measured memory_bytes: 13980
#include <stdio.h>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

int main() {
    string s, t;
    int i;
    vector <int> table[26];
    cin >> s >> t;
    
    for (i=0;i<s.size();i++){
        table[s[i] - 'a'].push_back(i + 1);
    }

    ll ans = 0, pre=0;
    for (i=0;i<t.size();i++){
        ll idx = t[i] - 'a';
        if (table[idx].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        auto p = *upper_bound(table[idx].begin(), table[idx].end(), pre);
        if (p == *table[idx].end()){
            p = *table[idx].begin();
            ans += s.size();
        }
        ans += p - pre;
        pre = p;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1216
def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string
s=input()
n=len(s)
ans=0
for i in range(2**(n-1)):
  t=base10toN(i,2)
  r=[]
  for j in range(n-1-len(t)):
    r.append('0')
  for j in range(len(t)):
    r.append(t[j])
  k=[]
  k.append(s[0])
  for j in range(n-1):
    if r[j]=='0':
      k.append(s[j+1])
    else:
      ans+=int(''.join(k))
      k=[]
      k.append(s[j+1])
  ans+=int(''.join(k))
print(ans)

Measured memory_bytes: 73936
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
  char s[100];
  int x;
  int list[100];
  int tail=0;
  while(scanf("%s",s)!=EOF) {
    if(s[0]=='+'){
      list[tail-2]+=list[tail-1];
      tail--;
    }
    else if(s[0]=='-') {
      list[tail-2]-=list[tail-1];
      tail--;
    }
    else if (s[0]=='*') {
      list[tail-2]*=list[tail-1];
      tail--;
    }
    else {
      x=atoi(s);
      list[tail]=x;
      tail++;
    }
  }
    
  printf("%d\n",list[0]);

  return 0;
}

/* 実行結果
[17D8103002C@ISE1Ac jissen]$ ./ALDS1_3_A
1 2 +
3

[17D8103002C@ISE1Ac jissen]$ ./ALDS1_3_A
1 2 + 3 4 - *
-3
*/



Measured memory_bytes: 2092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin>>n;
    ll a[n],b[n];
    vector<pair<ll,int>> c;
    rep(i,n){
        cin>>a[i]>>b[i];
        c.push_back({a[i]+b[i],i});
    }
    
    sort(all(c));
    reverse(all(c));

    ll suma=0,sumb=0;
    rep(i,n){
        int x=c[i].second;
        if(i%2==0) suma+=a[x];
        else sumb+=b[x];
    }
    
    cout<<suma-sumb<<endl;
}



Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] h = new int[n];
    int cnt = n;
    
    for(int i=0; i<n; i++) {
      h[i] = Integer.parseInt(str[i]);
     }
    for(int i=1; i<n; i++) {
      int tmp_cnt = 0;
      for(int j=0; j<i; j++) {
        if(h[i]<h[j])
          tmp_cnt += 1;
      }
      if(tmp_cnt>0){
        cnt -= 1;
      }
    }
    
    System.out.println(cnt);
  }
}

Measured memory_bytes: 21204
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

int main()
{
    int k;
    cin >> k ;

    int n_e = k/2;
    int n_o = k - n_e;

    p(n_e*n_o)
}

Measured memory_bytes: 256
N = int(input())
AB=[]
for _ in range(N):
	A,B=map(int, input().split())
	AB.append([B,A])
AB.sort(reverse=True)
cur = AB[0][0]
for ab in AB:
	a = ab[1]
	b = ab[0]
	cur = min(cur, b)
	cur -= a
if(cur >= 0):
	print("Yes")
else:
	print("No")

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;



int main() {
    int n, k; cin >> n >> k;
    int a[n];
    int max_a = 0;
    rep(i, n){
        cin >> a[i];
        max_a = max(max_a, a[i]);
    }
    int gcd_a = __gcd(a[0], a[1]);
    rep(i, n){
        gcd_a = __gcd(gcd_a, a[i]);
    }
    if (
        max_a < k || k % gcd_a != 0
        ){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        cout << "POSSIBLE" << endl;
    }



}



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

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(decimal.Parse).ToArray();
            Console.WriteLine(Math.Floor(ab[0] * ab[1]));
        }
    }
}


Measured memory_bytes: 28312
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[100010];
    rep(i,0,N) cin >> a[i];
    set<ll> st;
    rep(i,0,N) st.insert(a[i]);
    print(st.size());
    

}


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

int mod = 1000000007;

int main()
{
    string S;
    cin >> S;
    string ans;
    int now = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != 'B')
        {
            ans += S[i];
        }
        else
        {
            if (ans.size() != 0)
            {
                ans.erase(ans.size() - 1);
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
n = int(input())

l = [b,c,d,e]

ans = 'Yay!'

for i in range(len(l)):
    if ((l[i]- a) > n):
        ans = ':('
        break

print(ans)

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

int main()
{
	int N, K;
	std::cin >> N >> K;
	std::map<int, int> types;
	for(int i = 0; i < N; i++) {
		int a;
		std::cin >> a;
    auto checkTypes = types.find(a);
		if(checkTypes == types.end()) {
			types.insert(std::make_pair(a, 1));
		} else {
			checkTypes->second++;
		}
	}

	int answer = 0;
  std::vector<std::pair<int, int>> typesV(types.begin(), types.end());
  std::sort(typesV.begin(), typesV.end(), [](std::pair<int, int> a, std::pair<int, int> b){return a.second > b.second;});
  for(int i = 0; i < static_cast<int>(typesV.size()) - K; i++) {
    answer += (typesV.end() - i - 1)->second;
	}
	std::cout << answer << std::endl;
	return 0;
}


Measured memory_bytes: 11136
import sys
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
root=[-1]*(n+1)
def r(x):
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]
def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    root[x]+=root[y]
    root[y]=x
def size(x):
    x=r(x)
    return -root[x]
for i in range(m):
    x,y=map(int,input().split())

    unite(x,y)
ans=0
for i in range(n):
    ans=max(ans,size(i+1))
print(ans)



Measured memory_bytes: 96180
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int n;
int a[N], x[N][N], y[N][N];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		for (int j = 1; j <= a[i]; j++) {
			cin >> x[i][j] >> y[i][j];
		}
	}
	for (int mask = (1 << n) - 1; mask >= 0; mask--) {
		bitset<20> b(mask);
		int is_valid = 1;
		for (int i = 1; i <= n; i++) {
			if (b[n - i] == 1) {
				int flag = 1;
				for (int j = 1; j <= a[i]; j++) {
					if (b[n - x[i][j]] != y[i][j]) {
						flag = 0;
						break;
					}
				}
				if (!flag) {
					is_valid = 0;
					break;
				}
			}
		}
		if (is_valid) {
			cout << b.count();
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

// ranking
#define RANKSIZE 3
// source data
#define SRCSIZE 10

int compare(const void*, const void*);

int main(void)
{
    int source[SRCSIZE];
    int i;
    // get source data
    for(i=0; i < SRCSIZE; i++)
        scanf("%d", source+i);

    qsort(source, SRCSIZE, sizeof(int), compare);

    for(i = SRCSIZE - 1; SRCSIZE - 1 - RANKSIZE < i; i--)
        printf("%d\n", *(source+i));

    return 0;
}


int compare(const void* a, const void* b)
{
    return *(int*)a - *(int*)b;
}

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

long long n, k, ans=1;

int main() {
    cin >> n >> k;
    n = n - k;
    if (n < 0) ans =0;
    for (int i=k; i<n+k; i++) {
        ans = (ans * i) % 1000000007;
    }
    for (int i=2; i<n+1; i++) {
        int u = 1000000005;
        long long f[31];
        f[0] = i;
        for (int j=0; u>0; j++){
            if (u%2 == 1) ans = (ans * f[j])%1000000007;
            u/=2;
            f[j+1] = (f[j]*f[j])%1000000007;
        }
    }
    cout << ans << endl;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


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

	int n, x;
	cin >> n >> x;
	
	vi v(n);
	rep(i , n) cin >> v[i];
	
	int ans = 0;
	SORT(v);
	rep(i , n){
		if(v[i] <= x) {
			x -= v[i];
			++ans;
		} else {
			x = 0;
			break;
		}
	}
	if(x) ans = max(ans - 1, 0);
	dier(ans);

	return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************


int main(){

    ll N, M;
    cin >> N >> M;

    ll cnt = 0;
    REP(i, M){
        int tmp;
        cin >> tmp;
        cnt += tmp;
    }

    if (N >= cnt) {
        cout << N - cnt << endl;
    } else{
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <queue>

int main(){
   int K;
   std::cin >> K;

   const int n = 1000000;
   bool cache[n];
   for(int i=0; i<n; ++i)
      cache[i] = false;
   std::deque<std::pair<int,int> > dq;
   dq.push_front(std::make_pair(1,1));
   while(dq.size()){
      std::pair<int, int> cur = dq.front();
      dq.pop_front();
      if(cache[cur.first]) continue;
      cache[cur.first] = true;
      if(!cur.first){
	 std::cout << cur.second << std::endl;
	 return 0;
      }
      dq.push_front(std::make_pair(cur.first*10%K,cur.second));
      dq.push_back(std::make_pair((cur.first+1)%K,cur.second+1));
   }

   return -1;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(vector<vector<T>> x){cerr<<"\n{"; int f=x.size();for(int i=0;i<f;i++){cerr<<"("; int g=x[i].size(); for(auto j:x[i]){cerr<<j; (--g!=0)?cerr<<",":cerr<<"";}cerr<<")\n";}cerr<<"}";}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void __print(vector<bool> x){cerr<<"{";int f=x.size();for(auto i:x){cerr<<i;(--f !=0)?cerr<<",":cerr<<"";}cerr<<"}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
 
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define trace(x...)
#endif
 
template<typename... T>
void read(T&... args) {
    ((cin >> args), ...);
}
 
template<typename... T>
void writ(T&&... args) {
    ((cout << args << " "), ...);
}
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define INF (ll)1e18
#define IINF (int)1e9
#define EPS 1e-9

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    int ans=0;
    for(int i=1;i<n;i++){
        int x=n-i;
        int t=0;
        for(int j=1;j*j<=x;j++){
            if(j*j==x) t+=1;
            else if(x%j==0) t+=2;
        }
        ans+=t;
        //race(x,t);
    }
    cout<<ans<<endl;
    return 0;
}



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

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

int main(){
    int n;
    cin>>n;
    int a[(int)pow(10.0,5.0)];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int temp=*a;
    for(int i=0;i<n;i++){
        temp=gcd(temp,*(a+i));
    }
    cout << temp << endl;
    return 0;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
aa=['0']*n
for i in range(n):
    aa[a[i]-1]=str(i+1)
print(" ".join(aa))

'''
p,m=map(int,input().split())
s=bin(p)
s=s[2:]
n=len(s)


ans=pow(2,n) -1
if(m>=2):
    print(ans)
else:
    print(p)


m,n=map(int,input().split())
a=[False]*(n+1)
a[0]=True
for i in range(m):
    temp=list(map(int,input().split()))
    for kk in temp[1:]:
        a[kk]=True
ans=True
for nn in a:
    ans = nn and ans
if(ans):
    print("YES")
else:
    print("NO")



y,b,r = map(int,input().split())

if(r>b):
    if(b>y):
        print(int((3*y)+3))
    else:
        print(int(3*b))
else:
    if(b<y):
        print(int((3*y)-3))
    else:
        print()


  '''  




        

Measured memory_bytes: 15588
N = int(input())
h_list = list(map(int, input().split()))

min_num = -1
ans = True
for i in range(N - 1):
    h = h_list[i]
    h2 = h_list[i + 1]
    if h >= h2:
        h_list[i] -= 1
        h -= 1
        if h2 < min_num or h > h2:
            ans = False
    else:
        h_list[i+1] -= 1
        h2 -= 1
    min_num = max(h, h2)
    #print(min_num, ans, h, h2)
# if min(h_list) == 0 and max(h_list) == 1:
#     print("Yes")
#     exit()

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


Measured memory_bytes: 14252
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		char[] D = new char[K];
		for( int i=0; i<K; i++ ){
			String s = sc.next();
			D[i] = s.charAt(0);          
		}
		int count = 0;
		while( count==0 ){
			loop:for( int i=0; i<String.valueOf(N).length(); i++ ){
				String ss = String.valueOf(N);
				char ch = ss.charAt(i);
				for( int j=0; j<K; j++ ){
					if( ch==D[j] ){
						N++;
						break loop;
					}
				}
				if( i==String.valueOf(N).length()-1 ){
						count++;                  
                }                  
			}
		}
		System.out.println(N);
	}  
}


Measured memory_bytes: 28884
#include <iostream>
#include <string>
using namespace std;
int main(){
  int a, b;
  string s;
  cin >> a >> b >> s;
  
  bool ok = true;
  for(int i = 0; i < s.size(); ++i) {
    if(i == a){
      if(s[i] != '-') ok = false;
    }else{
      if(s[i] < '0' || s[i] > '9') ok = false;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >>b;
  int sum = 0;
  rep(i, 2) {
    if(a > b) {
      sum += a;
      a--;
    }
    else {
      sum += b;
      b--;
    }
  }
  
  cout << sum << endl;
}
      

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

int main(){
  while(1){
     string str,str1;
    int cnt,numer=0,denom=1;
    cin>>str;
    if(str=="#")break;
    for(int i=0;i<str.size();i++){
          if(str[i]=='n') str1+='n';
	        else if( str[i]=='w') str1+='w';
    }
    cnt=str1.size()-1;
    denom=pow(2,cnt);
         for(int i=0;i<cnt;i++){
	if(str1[i]=='n') numer-=(90*pow(2,i));
	else numer+=(90*pow(2,i));
      }
    if(str1[cnt]=='w') numer+=(90*pow(2,cnt));
    numer=abs(numer);
    for(int i=2;numer%i==0 && denom>1;i*=2) numer/=2,denom/=2;
    if(denom<=1) cout<<numer<<endl;
    else cout<<numer<<"/"<<denom<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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




int main(){
    long long X, y(100); std::cin >> X;
    int i(1);
    while(1){
        y = y + y/100;
        if(y >= X){
            std::cout << i << std::endl;
            return 0;
        }
        ++i;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, m;
	cin >> n >> m;
	ll sum = 0;
	rep(i, m)
	{
		int tmp;
		cin >> tmp;
		sum += tmp;
	}
	n -= sum;
	if (n < 0)
	{

		cout << -1 << endl;
	}
	else
	{
		cout << n << endl;
	}
	return 0;
}

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


int main(){
	string a,b;
	cin >> a >> b;
	if(a=="H"){
		if(b=="H"){
			cout << "H" << endl;
		}else{
			cout << "D" << endl;
		}
	}else{
		if(b=="H"){
			cout << "D" << endl;
		}else{
			cout << "H" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int result = 0;
		for (int i = 0; i < 2; i++) {
			if (a >= b) {
				result += a;
				a--;
			} else {
				result += b;
				b--;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>
ll power(ll a,ll b,ll mod){  ll ans=1;  while(b>0){
  if(b&1){ ans=(ans*a)%mod;} a=(a*a)%mod;  b=b/2; } return ans;}

int main(){
FIO  
 ll t;
  cin>>t;
  if(t>=30)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3648