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

int main() {
    int w,h,k;
    cin >> h >> w >> k;

    vector<string> m(h);
    for (int i = 0; i < h; ++i) {
        cin >> m[i];
    }

    int ans = 0;
    for (int i = 0; i < (1 << h); ++i) {
        for (int j = 0; j < (1 << w); ++j) {
            int cnt = 0;
            for (int y = 0; y < h; ++y) {
                if (((i >> y) & 1) == 0) {
                    for (int x = 0; x < w; ++x) {
                        if (((j >> x) & 1) == 0) {
                            if (m[y][x] == '#') {
                                cnt++;
                            }
                        }
                    }
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    int N;
    int[] a;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        N = sc.nextInt();
        a = new int[N];
        for (int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
    }
    
    //解答処理
    int solve() {
        double sum = 0;;
        for (int i=0; i<N; i++){
            sum += a[i];
        }
        double avr = sum / N;   //平均
        double min = Integer.MAX_VALUE;
        double dif = 0;    //差
        int answer = 0;
        
        for (int i=0; i<N; i++){
            dif = Math.abs(a[i]-avr);
            if (min > dif){
                min =  dif;
                answer = i;
            }
        }
        
        return answer;
    }
    
    //出力
    void show(int answer) {
        System.out.println(answer);
    }
}


Measured memory_bytes: 35980
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    const int MAX_N = 200010;
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    bool hash1[MAX_N] = {false};
    bool hashn[MAX_N] = {false};
    REP(i, m){
        int a, b;
        cin >> a >> b;
        if(a == 1){
            hash1[b] = true;
        }
        if(b == n){
            hashn[a] = true;
        }
    }

    FOR(i, 1, n){
        if(hash1[i] && hashn[i]){
            cout << "POSSIBLE" << "\n";
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << "\n";


    return 0;
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;

    // 処理
    string temp = "";
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B') {
            if (!temp.empty()) {
                temp.pop_back();
            }
        } else {
            temp.push_back(s[i]);
        }
    }

    // 出力
    string ans = temp;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    a,b,n = rl()
    if n >= b:
        ans = (a * (b - 1)) // b - a * ((b - 1) // b)
    else:
        ans = a * n // b

    print (ans)






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 65160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド
		Scanner sc = new Scanner(System.in);

		for(int i = 0;;i++) {
		int m = sc.nextInt();
		int f = sc.nextInt();
		int a = sc.nextInt();
		if(m==-1&&f==-1&&a==-1)
			break;
                if(m==-1||f==-1)
                        System.out.println("F");
		else if((m+f)>=80)
			System.out.println("A");
		else if((m + f)>=65)
			System.out.println("B");
		else if((m+f) >=50)
			System.out.println("C");
		else if((m+f)>=30&&a>=50)
			System.out.println("C");
		else if((m+f)>=30)
			System.out.println("D");
		else
			System.out.println("F");
		}
	}
}



Measured memory_bytes: 26260
import sys
input = sys.stdin.readline


h, w = map(int, input().split())
A = []

for i in range(h):
    line = list(map(int, input().split()))
    A.append(line)

for i in range(h):
    line = list(map(int, input().split()))
    for j, num in enumerate(line):
        A[i][j] = abs(A[i][j] - num)

const = 64000
bitset = 1 << const
DP = [0]*w
DP[0] = bitset >> A[0][0]


def slide_down(y, x):
    bit = DP[x]
    delta = A[y+1][x]
    new1 = bit << delta
    new2 = bit >> delta
    DP[x] = new1 | new2


def slide_right(y, x):
    bit = DP[x]
    delta = A[y][x+1]
    new1 = bit << delta
    new2 = bit >> delta
    DP[x+1] |= new1 | new2


for y in range(h):
    for x in range(w):
        if x < w-1:
            slide_right(y, x)
        if y < h-1:
            slide_down(y, x)

ans = DP[w-1]
for i in range(81):
    if (ans >> const+i) & 1 or (ans >> const-i) & 1:
        print(i)
        exit()


Measured memory_bytes: 4212
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(M)]

A = [[False for _ in range(N)] for _ in range(N)]
for a,b in AB:
    A[a-1][b-1] = True
    A[b-1][a-1] = True

# 頂点を巡る順番を順列で生成する
from itertools import permutations
Ps = permutations([i for i in range(1,N)])

ans = 0
for P in Ps:
    flg = True
    x,y = 0,0
    for p in P:
        y = p
        # 経路がなければ
        if not A[x][y]:
            flg = False
            break
        x = p
    if flg:
        ans += 1

print(ans)

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int N;
int x[100], y[100], h[100];


int main(){
	cin >> N;
	int tx, ty, th;
	for(int i = 0; i < N; i++){
		cin >> x[i] >> y[i] >> h[i];
		if(h[i] > 0){
			tx = x[i];
			ty = y[i];
			th = h[i];
		}
	}

	int ans = -1;
	int ansx, ansy;
	for(int cx = 0; cx <= 100; cx++){
		if(ans != -1) break;
		for(int cy = 0; cy <= 100; cy++){
			if(ans != -1) break;
			ans = th + abs(cx - tx) + abs(cy - ty);
			for(int i = 0; i < N; i++){
				int check = max(ans - abs(cx-x[i]) - abs(cy-y[i]), 0);
				if(check != h[i]){
					ans = -1;
					break;
				}
			}
			if(ans != -1){
				ansx = cx, ansy = cy;
				break;
			}
		}
	}

	cout << ansx << " " << ansy << " " << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include<stdio.h>
#include<utility>
#include<algorithm>

int main() {
	int W, H, x, y, r;
	int d = 0;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);//////////////////////
	
	if (x >= r) {
		if (y>=r)
		{
			if (x + r <= W) {
				if (y + r <= H) {
					d = 1;
					printf("Yes\n");
				}
			}
		}
	}
	if (d == 0) {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2692
#include<cstdio>
int main()
{
    int N,fsum=0;
    scanf("%d",&N);
    int a=N;
    while(a)
    {
        fsum+=a%10;
        a/=10;
    }
    if(N%fsum==0)
    {
        printf("Yes");
    }
    else
    printf("No");


}


Measured memory_bytes: 128
n = int(input())


def digit_sum(num):
    ret = 0
    s = str(num)
    for e in s:
        ret += int(e)

    return ret


ans = float("inf")
for a in range(1, n):
    b = n - a
    ds = digit_sum(a) + digit_sum(b)
    ans = min(ans, ds)

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

double dist(double gx,double gy, P p) {
  return sqrt((gx-p.first)*(gx-p.first)+(gy-p.second)*(gy-p.second));
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x,y;cin>>n;
  double gx=0.0,gy=0.0,r=0.0,r_=0.0,c=0.5;
  vector<P> points(n);
  rep(i,n) {cin>>x>>y;gx+=x;gy+=y;points[i]=P(x,y);}
  gx/=n,gy/=n;
  P far;
  rep(i,1e6) {
    r=0.0;
    for(P p:points) {
      r_=dist(gx,gy,p);
      if(r<r_) {r=r_;far=p;} 
    }
    gx+=c*(far.first-gx);
    gy+=c*(far.second-gy);
    c*=0.999;
  }
  for(P p:points) r=max(r,dist(gx,gy,p));
  printf("%.10f\n",r);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    string s;
    cin >> s;
    ll ans = 0,b=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='B')b++;
        else{
            ans+=b;
        
        }
    }
    cout <<ans<<endl;
}
    



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int ans = 0;
		boolean flag = true;
		
		while(true) {
			for (int i = 0; i < n; i++) {
				if (a[i] % 2 == 0) {
					a[i] /= 2;
				} else {
					flag = false;
				}
			}
			
			if (flag) ans++;
			else break;
		}
		
		System.out.println(ans);
		sc.close();
	}
}

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

typedef long long ll;

int main() {
    int H, W;
    cin >> H >> W;
    string a;
    vector<int> c(26, 0), d(4, 0);
    rep(i, H) {
        cin >> a;
        rep(j, W) {
            c[a[j] - 'a']++;
        }
    }
    rep(i, 26) {
        d[c[i] % 4]++;
    }
    if (H % 2) {
        if (W % 2) {
            if (d[1] + d[3] == 1 && d[2] + d[3] <= (H + W - 1) / 2) cout << "Yes\n";
            else cout << "No\n";
        } else {
            if (d[1] + d[3] == 0 && d[2] <= W / 2) cout << "Yes\n";
            else cout << "No\n";
        }
    } else {
        if (W % 2) {
            if (d[1] + d[3] == 0 && d[2] <= H / 2) cout << "Yes\n";
            else cout << "No\n";
        } else {
            if (d[0] == 26) cout << "Yes\n";
            else cout << "No\n";
        }
    }
}

Measured memory_bytes: 256
A, B = map(int, input().split())
ans = 0
for i in range(A, B+1):
    s = []
    for _ in [0]*5:
        s.append(i % 10)
        i //= 10
    if s[0] == s[4] and s[1] == s[3]:
        ans += 1
print(ans)

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

int main(){
	int X,Y;
	cin >> X >> Y;

	bool f=false;
	for(int i=0; i<=100; i++){
		for(int j=0; j<=100; j++){
			if(2*i+4*j == Y && i+j==X)f=true;
		}
	}

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

}


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

int main() {
  int N , K , i ,a  ;
  cin >> N >> K ;
  i = 0;
  a = 1;
  while(i < N){
    i++ ;
    if ( a < K ){
      a *= 2 ;
    }
    else {
      a += K ;
    }
  }
  cout << a << endl;
}
  
      
  
  
 

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

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e15)

using namespace std;

int N;

signed main()
{
    cin >> N;


    int a4 = 0;
    int a2 = 0;
    REP(i,N)
    {
        int a;
        cin >> a;

        if (a%4 == 0)
        {
            a4++;
        }
        else if (a%2 == 0)
        {
            a2++;
        }
    }

    int ans = 0;
    if (a4 > 0) ans += 2*a4+1;
    if (a2 > 0) ans += a2/2*2;

    if (ans >= N)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M), C(M);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    for(int i = 0; i < M; ++i){
        cin >> B[i] >> C[i];
    }
    vector<P> BC(M);      // (C, B)
    for(int i = 0; i < M; ++i){
        BC[i] = P(C[i], B[i]);
    }
    sort(A.begin(), A.end());                   // 昇順ソート
    sort(BC.begin(), BC.end(), greater<P>());   // 降順ソート
    
    vector<int> D(N);
    int now = 0;
    for(int i = 0; i < M; ++i){
        int value = BC[i].first;
        int cnt = BC[i].second;
        while(cnt > 0 && now < N){
            D[now++] = value;
            cnt--;
        }
        
        if(now == N)        break;
    }
    
    for(int i = 0; i < N; ++i){
        if(A[i] >= D[i])        break;
        
        A[i] = D[i];
    }

    ll ans = 0;
    for(int i = 0; i < N; ++i){
        ans += A[i];
    }
    cout << ans << endl;
}

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  
  for(int i = a; i <= b; i++){
    if(i%k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}




Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string s, t;
    cin >> s >> t;
    ll ns = (ll)s.size(), nt = (ll)t.size();

    vector<vector<ll>> idx(26);
    rep(i, 0, ns) idx[s[i] - 'a'].push_back(i);
    rep(i, 0, ns) idx[s[i] - 'a'].push_back(ns+i);
    
    ll ans = 0, p = 0;
    rep(i, 0, nt) {
        ll c = t[i] - 'a';
        if(idx[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(idx[c].begin(), idx[c].end(), p) + 1;
        if (p >= ns) {
            p -= ns;
            ans += ns;
        }
    }
    ans += p;
    cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    unsigned long A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    unsigned long X[N];
    long long xn = A[N-1];
    for (int i = 0; i < N - 1; i++) {
        if (i % 2 == 0) {
            xn = xn - A[i];
        } else {
            xn = xn + A[i];
        }
    }
    X[N-1] = xn / 2;
    for (int i = N-2; i > -1; i--) {
        X[i] = A[i] - X[i+1];
    }
    /* 
    for (int i = 0; i < N; i++) {
        cout << 2 * X[i] << endl;
    }*/
    string s = "";
    for (int i = 0; i < N - 1; i++) {
        string s2 = to_string(2 * X[i]);
        s += s2;
        s += " ";
    }
    string s2 = to_string(2 * X[N-1]);
    s += s2;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 4096
let t = cin.triple
let a = Double(t.0)
let b = Double(t.1)
let n = t.2

// debugPrint("a: \(a), b: \(b), n: \(n)")

// (1...n).map { Double($0) }.forEach { x in 
//     let res = Int(a*x/b) - Int(a)*Int(x/b)
//     debugPrint("x: \(x) -> [ax/b]: \(Int(a*x/b)), a[x/b]: \(Int(a)*Int(x/b)), diff: \(res)")
//     mmax = max(mmax, res)
// }

let x = Double(min(n, Int(b)-1))
print("\(Int(a*x/b) - Int(a)*Int(x/b))")

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var int: Int { Int(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    // 12 23 34
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    // AtCoder
    static var str: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { str.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { str.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in int } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}


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

main() {
    int A,B,T; cin >> A >> B >> T;
    cout << B*(T/A) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int card[4][13];
  int n,i,j;
  for(j=1;j<=13;j++){
    for(i=1;i<=4;i++){
      card[i-1][j-1]=0; //card?????????????????¨???0???
    }
  }
  scanf("%d",&n);
  int k; //k???????????\????????????
  char mark;
  for(k=1;k<=n;k++){
    scanf("%*c%c %d",&mark,&j); //?????????????????£???????????¨???????????????%*c?????????????????¨?????????????????¨?????????????????????
    if(mark=='S'){
      card[0][j-1]=1; //i=1
    }else if(mark=='H'){
      card[1][j-1]=1; //i=2
    }else if(mark=='C'){
      card[2][j-1]=1; //i=3
    }else if(mark=='D'){
      card[3][j-1]=1; //i=4
    }
  }
  for(i=1 ; i<=4 ; i++){
    for(j=1 ; j<=13 ; j++){
      if(card[i-1][j-1]==0){{
          if(i==1){
            printf("S %d\n",j);
          }else if(i==2){
            printf("H %d\n",j);
          }else if(i==3){
            printf("C %d\n",j);
          }else if(i==4){
            printf("D %d\n",j);
          }
        }
      }
    }
  }
  //  printf("\n");
  return 0;
}

Measured memory_bytes: 596
s = input()
t = input()

stri = []
for i in range(len(s)-len(t)+1):
    j = i+ len(t)
    stri.append(s[i:j])
maxcount = 0
for i in range(len(stri)):
    count = 0
    for j in range(len(t)):
        if(stri[i][j] ==t[j]):
            count+= 1
    maxcount = max(maxcount,count) 
print(len(t)-maxcount)

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

inline void era(vector<bool> &prime, int num);

using namespace std;

int main(void){
  int num;

  while(cin >> num){
    vector<bool> prime((num+1), true);
    prime[0] = false;
    prime[1] = false;
    era(prime, num);
    cout << count(prime.begin(), prime.end(), true) << endl;
  }
  return 0;
}

void era(vector<bool> &prime, int num){
  int N = 2;
  while (N <= num){
    int count = 2;
    while ((count*N) <= num){
      prime[count*N] = false;
      ++count;
    }
    ++N;
  }
}

Measured memory_bytes: 1316
#include <iostream>


int main()
{
	long long int number;
	std::cin >> number;

	long long int happy = 0;

	int div500 = number / 500;
	happy += div500 * 1000;
	number -= div500 * 500;

	int div5 = number / 5;
	happy += div5 * 5;
	
	std::cout << happy;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    final int A=sc.nextInt();
    final int B=sc.nextInt();
    int[] result={A+B,A-B,A*B};
    Arrays.sort(result);
    System.out.println(result[2]);
  }
}

Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N,K; cin>>N>>K;
  int cnt = 0;
  for(int i=0; i<N; i += 2) {
    cnt++;
  }
  string ans = cnt >= K ? "YES" : "NO";
  cout << ans << endl;
}


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

using namespace std;

#define MOD 1000000007

long long ans(long long N, long long M)
{
  if(M == 1)
    return N % MOD;

  if(M % 2)
  {
     //return N % MOD * ans(N, M-1) % MOD;
    return N % MOD * (ans(N, (M-1)/2)%MOD * ans(N, (M-1)/2)%MOD) % MOD;
    //const long long a = ans(N, (M-1)/2)%MOD;
    //return N%MOD * a * a % MOD;
       
  }
  else 
  {
      const long long a = ans(N, M/2);
      return a*a%MOD;
  }
    
}

int main()
{

  long long N, M;
  cin >> N >> M;

  cout << ans(N, M) << endl;
  
  return 0;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	string s;
	cin>>s;
	s[5]=' ';
	s[13]=' ';
	cout<<s<<endl;
	return 0;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  if(n * a < b){
    cout << n * a << endl;
  }else{
    cout << b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <cstring>
#include <iostream>
#include <set>
using int_t = long long int;
using std::cin;
using std::cout;
using std::endl;

const int_t LARGE = 1e4 + 10;

bool check(const int_t* A, int_t n, int_t p) {
    static int_t B[LARGE + 1];
    const int_t phi = p - 1;
    for (int_t i = 0; i <= n; i++)
        B[i % phi] = (B[i % phi] % p + (A[i] % p + p) % p + 2 * p) % p;
    bool ok = true;
    for (int_t i = 0; i < phi; i++) {
        ok = ok && ((B[i] % p + p) % p == 0);
        B[i] = 0;
    }
    return ok;
}
int_t gcd(int_t a, int_t b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int main() {
    static bool isPrime[LARGE + 1];
    memset(isPrime, 1, sizeof(isPrime));
    for (int_t i = 2; i <= LARGE; i++) {
        if (isPrime[i]) {
            for (int_t j = i * i; j <= LARGE; j += i) isPrime[j] = false;
        }
    }
    // for (int_t i = 2; i <= LARGE; i++) {
    //     bool has = false;
    //     for (int_t j = i - 1; j >= 2; j--) {
    //         if (i % j == 0 && isPrime[i]) assert(false);
    //         if (i % j == 0) has = true;
    //     }
    //     if (has == 0)
    //         if (isPrime[i] == 0) assert(false);
    // }
    std::set<int_t> result;
    static int_t A[LARGE + 1];
    int_t n;
    scanf("%lld", &n);
    int_t prev = 0;
    for (int_t i = n; i >= 0; i--) {
        scanf("%lld", &A[i]);
        prev = gcd(prev, std::abs(A[i]));
    }
#ifdef DEBUG
    cout << "gcd  = " << prev << endl;
#endif
    for (int_t i = 2; i * i <= prev; i++) {
        if (prev % i == 0) {
            result.insert(i);
            while (prev % i == 0) prev /= i;
        }
    }
    if (prev > 1) result.insert(prev);
    for (int_t i = 2; i <= n; i++)
        if (isPrime[i] && A[0] % i == 0 && check(A, n, i)) {
            result.insert(i);
#ifdef DEBUG
            cout << "got " << i << endl;
#endif
        }

    // for (int_t i  = 0; i <= n; i++)

    for (int_t x : result) {
        printf("%lld\n", x);
        assert(x >= 2);
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod = 1000000007;

ll sum(ll l, ll r){
  return (l+r)*(r-l+1)/2;
}

int main()
{
  int N,K;
  cin >> N >> K;
  ll ans = 0;
  for(ll i=K; i<=N+1;i++){
    ll L = sum(0,i-1);
    ll R = sum(N-i+1,N);
    ans = (ans + R - L + 1) % mod;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

const ll MAX = 1000000;
ll fac[MAX], finv[MAX], inv[MAX];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll n = (-x + 2 * y) / 3;
    ll m = (2 * x - y) / 3;
    if (n < 0 || m < 0) {
        cout << 0 << endl;
        return 0;
    }
    cominit();
    cout << com(n + m, n) << endl;
    return 0;
}


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

using namespace std;
using   ll=long long;

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

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve() 
{
	int a,  b, c ,d;
	
	cin >> a >> b >> c >> d;
	
	int tot = b/c - (a-1)/c;
	
	tot += b/d - (a-1)/d;
	
	int tm = lcm(c ,d);
	
	tot = tot - (b/tm - (a-1)/tm);
	
	cout << (b-a+1)-tot;
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3632
import math

N=int(input())
a=list(map(int, input().split()))
H=math.floor(N / 2)
B=a[:]

for i in range(H-1,-1,-1):
    s = 0
    j = i
    j+=(i+1)
    while j < N:
        s+=B[j]
        j+=(i+1)
    m = s % 2
    B[i] = a[i] ^ m

ans = [i + 1 for i, x in enumerate(B) if x == 1]
l = len(ans)
print(l)
if (l > 0):
    print(*ans)


Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 	int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for(int i=0;i<=N;i++){
        if(i % R != 0) continue;
        for(int j=0;j<=N;j++){
            if(j % G != 0) continue;
            int rest = N - i - j;
            if(rest < 0) continue;
            if(rest % B != 0) continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A, B = list(map(int, input().split(' ')))
maxKouyaku = fractions.gcd(A, B)
#print(maxKouyaku)
#print(*factorization(maxKouyaku))
if maxKouyaku == 1:
    print(1)
else:
    print(len(factorization(maxKouyaku)) + 1)

Measured memory_bytes: 5048
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int start, end, num;
    int count = 0;
    cin >> start >> end >> num;
    for(int i=start; i<=end; i++){
        if(i%num == 0){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int popcount(int n){//O(log N)
  int res = 0;
  while(n){
    res += n%2;
    n >>= 1;
  }
  return res;
}
int main(){
  cin.tie(0);ios::sync_with_stdio(0);
  int n,i,j,h;cin >> n;
  string x;cin >> x;
  bool X[n];
  for(i=0;i<n;i++) X[n-i-1] = x[i]=='1';
  int c[n+1] = {};//c[i] == iを操作するのに必要な回数
  for(i=0;i<=n;i++){
    j = i;h = 0;
    for(h=0;j!=0;h++) j %= popcount(j);
    c[i] = h;
  }
  int onecount = count(X,X+n,1),pc = onecount+1,mc = onecount-1;
  int plus = 0,minus = 0,ps[n+1],ms[n+1];ps[0] = ms[0] = 1;
  for(i=0;i<n;i++){
    if(X[i] == 1){
      plus = (plus+ps[i])%pc;
    }
    ps[i+1] = (ps[i]*2)%pc;
  }
  if(mc != 0){
    for(i=0;i<n;i++){
      if(X[i] == 1){
        minus = (minus+ms[i])%mc;
      }
      ms[i+1] = (ms[i]*2)%mc;
    }
  }
  int fnum,ans;
  for(i=n-1;i>=0;i--){
    if(mc == 0 && X[i] == 1){
      printf("0\n");continue;
    }
    if(X[i] == 0){
      fnum = (plus+ps[i])%pc;
      ans = c[fnum];
    }
    else{
      fnum = (minus-ms[i]+mc)%mc;
      ans = c[fnum];
    }
    printf("%d\n",ans+1);
  }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using P = pair<ll,ll>;

const ll MX=1e18;

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        if(a[i]==0){
            cout <<0<<endl;
            return 0;
        }
    }
    ll ans=1;
    for (int i = 0; i < n; ++i) {
        if(MX/ans<a[i]||ans*a[i]>MX){
            cout <<-1<<endl;
            return 0;
        }
        ans*=a[i];
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 4056
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int x[n];
    for (int i=0; i<n; i++) {
        cin >> x[i];
    }
    for (int i=n-1; i>=0; i--) {
        cout << x[i];
        if (i!=0) {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
n=int(input())
a=list(map(int,input().split()))
ans=0
for x in range(n):
    for y in range(x+1,n):
        for z in range(y+1,n):
            if a[x]!=a[y] and a[y]!=a[z] and a[z]!=a[x] and a[x]+a[y]>a[z] and a[y]+a[z]>a[x] and a[z]+a[x]>a[y]:
                ans+=1
print(ans)

Measured memory_bytes: 9200
import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    ArrayList<Integer>[] graph;
    HashSet<Integer> cycle;
    int[] prev;
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n<10) return n;
        long ans = 9;
        for(int i=10;i<=n;i++){
            ans += singleNumber(i);
        }
        return ans;
    }
    long singleNumber(int x){
        // num of pairs that with one value being x
        if(x%10==0) return 0;
        String s = Integer.toString(x);
        int len = s.length();
        int head = s.charAt(0)-'0', tail = s.charAt(len-1)-'0';
        // it's guaranteed that tail != 0
        long ans = 0;
        if(head==tail) ans += 1; // for size = 1 case. E.g. 22->2
        int size = 2;
        while(size<=len){
            if(size<len){
                ans += power(10,size-2);
            } else{
                // size == len. needs careful
                if(tail>head) ans += 0;
                else if(tail < head){
                    ans += power(10,size-2);
                } else{
                    // head == tail
                    String mid = s.substring(1,len-1);
                    if(mid.length()==0) ans += 1;
                    else ans += 1+Integer.parseInt(mid);
                }
            }
            size += 1;
        }
        ans *= 2; // change order
        // finally check repeat
        if(head==tail) ans -= 1;
        return ans;
    }
    int power(int base, int q){ // no bigger than 1e6
        int ans = 1;
        while(q>0){
            if(q%2==1) ans *= base;
            base *= base;
            q /= 2;
        }
        return ans;
    }
}



Measured memory_bytes: 36104
a,b = map(int,input().split())
a,b = sorted([a,b])

def gcd(x,y):
    x,y = sorted([x,y])
    for i in range(1,x+1):
        if x%i==0 and y%i==0:
            answer = i
    return answer

tmp_a = a//gcd(a,b)
tmp_b = b//gcd(a,b)

lcm = gcd(a,b)*tmp_a*tmp_b
print(lcm)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
  // 整数の入力
  ll N, X, Y;
  map<ll, ll> counts;
  cin >> N >> X >> Y;
  X--;Y--;
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      ll d = min(min((ll)abs(j - i),abs(X-j) + abs(Y- i) + 1), abs(X-i) + abs(Y- j) + 1);
      counts[d]++;
    }
  }

  for(int i = 1;i< N;i++){
    cout << counts[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main (void){
	int x,y;
	cin>>x>>y;
	string ans;
	for(int i=0;i<=x;i++){
		if(i*2+(x-i)*4==y){
			ans="Yes";
			break;
		}
		else ans="No";
	}
    
	cout<<ans<<endl;

}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  long long N, K;
  int ans = 0;
  string s;

  cin >> N >> K;

  vector<int> a;
  long long n = N;
  while(n > 0){
    a.push_back(n%K);
    n = n/K;
  }
  cout << a.size() << endl;
}


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

bool check(int x, int y, vector<string> s, int k) {
	for (int i = 0; i < 6; i++) {
		if (x & (1<<i)) {
			for (char& c : s[i]) {
				c = '.';
			}
		}
	}
	for (int j = 0; j < 6; j++) {
		if (y & (1<<j)) {
			for (int i = 0; i < s.size(); i++) {
				s[i][j] = '.';
			}
		}
	}
	for (int i = 0; i < s.size(); i++) {
		for (char c : s[i]) {
			if (c == '#') {
				--k;
			}
		}
	}
	return k == 0;
}

int main() {
	int m, n, k;
	cin >> m >> n >> k;
	vector<string> s(m);
	for (int i = 0; i < m; i++) {
		cin >> s[i];
	}
	int res = 0;
	for (int i = 0; i < (1<<m); i++) {
		for (int j = 0; j < (1<<n); j++) {
			if (check(i, j, s, k)) {
				res++;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3632
#include <iostream>
static const int INFNTY = 1e9 + 1;
using namespace std;

int main(){
  int n, k;

  cin >> n >> k;
  int h[n];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  int dp[n];
  for (int i = 0; i < n; i++) {
    dp[i] = INFNTY;
  }
  int j;
  int cost;
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) {
    for (int j = 1; (j <= i) && (j <= k); j++) {
      cost = dp[i - j] + abs(h[i] - h[i - j]);
      if (cost < dp[i]){
        dp[i] = cost;
      }
    }
    cout << endl;
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1152
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        
        int[] a = new int[M];
        for(int i=0; i<M; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        int ans_1 = 0;
        for(int i=X+1; i<=N; i++){
            for(int j=0; j<M; j++){
                if(a[j] == i){
                    ans_1++;
                    break;
                }
            }
        }
        
        int ans_2 = 0;
        for(int i=X-1; i>=0; i--){
            for(int j=0; j<M; j++){
                if(a[j] == i){
                    ans_2++;
                    break;
                }
            }
        }
        
        System.out.println(Math.min(ans_1, ans_2));
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
using namespace std;

using i64 = long long;

i64 invmod(i64 a, i64 b, i64 NUM) {
	i64 n2 = NUM - 2;
	i64 ans = a;
	i64 b2 = b;
	while(n2 != 0) {
		if(n2 % 2 == 1) {
			ans *= b2;
			ans %= NUM;
		}
		b2 = b2 * b2;
		b2 %= NUM;
		n2 /= 2;
	}
	return ans;
}

int main(int argc, char *argv[]) {
	i64 X, Y;
	cin >> X >> Y;
	i64 b1 = 2 * Y - X;
	i64 a1 = 2 * X - Y;
	if(b1 % 3 != 0 || a1 % 3 != 0 || b1 < 0 || a1 < 0) {
		cout << 0 << endl;
	}
	else {
		i64 b = b1 / 3, a = a1 / 3;
		i64 ans = 1;
		i64 N = a + b;
		i64 NUM = 1000000007LL;
		for(int i=1;i<=b;++i) {
			ans *= (N - i + 1);
			ans %= NUM;
			ans = invmod(ans, i, NUM);
			ans %= NUM;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
/**
 *    author:   K.R.Surrya  
 *    created:  30/04/2020 11:23:23
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

void solve() { 
    int k;
    cin >> k;
    queue<long long> q;
    for(int i=1;i<=9;++i) q.push(i);
    int count=0;
    long long ret=-1;
    while(q.size() > 0) {
        int sz=q.size();
        while(sz--) {
            long long rem=q.front();q.pop();
            string curr=to_string(rem);
            ++count;
            // error(count,rem);cerr << '\n';
            if(count==k) {
                ret=rem;
                assert(ret!=-1);
                cout << ret << '\n';
                return ;
            }

            int last=curr[curr.size()-1]-'0'; //3 option rises from this point;
            if(last-1>=0) {
                int temp=last-1;
                char ch='0'+temp;
                // curr[curr.size()-1]=ch;
                curr.append(string(1,ch));
                long long temp2=stoll(curr);
                curr.pop_back();
                q.push(temp2);
            }
            curr.append(string(1,'0'+last));
            q.push(stoll(curr));
            curr.pop_back();
            if(last+1<=9) {
                int temp=last+1;
                char ch='0'+temp;
                // curr[curr.size()-1]=ch;
                curr.append(string(1,ch));
                long long temp2=stoll(curr);
                curr.pop_back();
                q.push(temp2);
            }
        }
    }
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


     auto start = chrono::high_resolution_clock::now();
     solve();
     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

int n;

string s;

bitset<26> vis;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> s;
	n = s.size();

	for(auto it:s)
	{
		vis[it-'a'] = 1;
	}

	if(vis.count()<26)
	{
		for(int i = 0; i < 26; ++i)
		{
			if(!vis[i])
			{
				s += char('a'+i);
				cout << s << endl;
				return 0;
			}
		}
	}

	for(int i = n-1; i >= 0; --i)
	{
		bool ok = 0;

		for(int j = i+1; j < n; ++j)
		{
			if(s[j]>s[i])
				ok = 1;
		}

		if(ok)
		{
			char best = 'z'+1;
			int ind = -1;

			for(int j = i+1; j < n; ++j)
			{
				if(s[j]>s[i] && best>s[j])
				{
					best = s[j];
					ind = j;
				}
			}

			for(int j = 0; j < i; ++j)
			{
				cout << s[j];
			}

			cout << s[ind];

			return 0;
		}
	}

	cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> v;
  rep(i,n){
    int temp=0;
    int pos=i;
    while(pos<n && s[i]==s[pos]){
      pos++;
      temp++;
    }
    v.push_back(temp);
    i=pos-1;
  }
  ll ans=0;
  rep(i,v.size()){
    ans+=v[i]-1;
  }
  int m=v.size();
  if(k>=m/2){
    cout << n-1 << endl;
    return 0;
  }
  ans+=2*k;
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        a-=k;
        cout<<a<<" "<<b<<endl;
    }
    else{
        k-=a;
        a=0;
        b=b-k;
        cout<<a<<" "<<max(a,b)<<endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

string s;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>s;
    ll ans = INF;
    rep(i,s.size()-1){
        if(s[i]!=s[i+1]){
            chmin(ans,(ll)max(i+1,(ll)s.size()-i-1));
        }
    }
    chmin(ans,(ll)s.size());
    print(ans);
    return 0;
}

Measured memory_bytes: 512