akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
static inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
using ll = long long;
using ld = long double;

int main()
{
    fast_io();

    int k, n;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += p[i];
    }
    cout << sum;
}


Measured memory_bytes: 3160
N, M = [int(i) for i in input().split()]
v = ['x' for n in range(N)]
e = False
for m in range(M):
    s, c = [int(i) for i in input().split()]
    if e:
        continue
    if v[s-1] != 'x' and v[s-1]!=str(c):
        e = True
    else:
        v[s-1] = str(c)

if e:
    print(-1)
    exit()

r = []
fd = N != 1
for d in v:
    if d == 'x':
        if fd:
            r.append('1')
        else:
            r.append('0')
    else:
        r.append(d)
    fd = False

rv = int("".join(r))

if len(str(rv))!=N:
    print(-1)
else:
    print("".join(r))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000
 
using namespace std;
 
int main()
{
	double r;
	double p=3.141592653589793238462643383279;
	cin>>r;
	printf("%.9lf %.9lf\n",r*r*p,2*r*p);
	return 0;
}


Measured memory_bytes: 3192
n = gets.to_i
h = gets.split.map &:to_i
a = Array.new(n,0)

for i in 1...n
  if h[i-1] >= h[i]
    a[i] = a[i-1] + 1
  else
    a[i] = 0
  end
end
p a.max

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    vb used(26, false);
    cin >> st;
    rep(i, st.size()) {
        used[st[i] - 'a'] = true;
    }

    rep(i, used.size()) {
        if (!used[i]) {
            cout << st << (char)(i + 'a') << endl;
            return 0;
        }
    }

    for (int i = st.size()-1; i >= 0; i--) {
        used[st[i]-'a'] = false;
        for (int j = st[i]+1; j <= 'z'; j++) {
            if (!used[j - 'a']) {
                for (int k = 0; k < i; k++) {
                    cout << st[k];
                }
                cout << (char)(j) << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;



    return 0;
}





Measured memory_bytes: 764
#include<stdio.h>
int main()
{
    char n[6];
    for(int i=0;i<6;i++)
    {
        scanf("%c",&n[i]);
    }

    if(n[2]==n[3]&&n[4]==n[5])
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main(){
  int a, b;
  string s;
  stack<int> S;

  for (int i=0; cin >> s; i++){
    if (s[0] == '+') {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a+b);
    } else if (s[0] == '-') {
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a-b);
    } else if (s[0] == '*') {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a*b);
    } else {
      S.push(atoi(s.c_str()));
    }
  }

  cout << S.top() << endl;

  return 0;
}



Measured memory_bytes: 3196
from collections import deque

H, W = map(int,input().split())

mymap = []
for h in range(H):
    mylist = list(input())
    mymap += [mylist]
#print(myAC)
#print(myWA)
#print(mymap)

d = [ [0 for w in range(W)] for h in range(H) ]
dx = [1,0,-1,0]
dy = [0,1,0,-1]
INF = -999

def bfs(a, b):
    mymax = 0
    #探索結果を示す配列dについて，すべての地点をINFで初期化
    for h in range(H):
        for w  in range(W):
            d[h][w] = INF
    #スタート地点の処理（ここでは x = 0, y = 0 の地点がスタート地点）
    #print(d)
    que = deque([[a,b]])
    d[a][b] = 0
    #queが空になるまで処理を行う
    while que:
        y, x = que.popleft() #左側から取り出す
        #4方向の探索
        for i in range(4):
            ny = y + dy[i]
            nx = x + dx[i]
            
            if 0 <= ny and ny < H and 0 <= nx and nx < W and mymap[ny][nx] != '#' and d[ny][nx] == INF:
                que.append([ny,nx])
                d[ny][nx] = d[y][x] + 1
                if d[ny][nx] > mymax:
                    mymax = d[ny][nx]
    #print(d)
    return mymax

mymax = 0
for h in range(H):
    for w in range(W):
        if mymap[h][w] != '#':
            mine = bfs(h, w)
            #print(mine)
            if mymax < mine:
                mymax = mine

print(mymax)

Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[20],b[20],aa,bb;
    for(int i=0;i<10;i++)cin>>a[i];
    for(int i=0;i<10;i++)cin>>b[i];
    sort(a,a+10);
    reverse(a,a+10);
    sort(b,b+10);
    reverse(b,b+10);
    cout<<a[0]+a[1]+a[2]<<" ";
    cout<<b[0]+b[1]+b[2]<<endl;
    return 0;
}

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

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

    if(K % 2 == 0) {
        cout << (K / 2) * (K / 2);
    }else {
        cout << (1 + (K - 1) / 2)* (K - 1) / 2;
    }
   return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    A,B,C = LI()
    K = NI()

    for _ in range(K):
        if A >= B:
            B *= 2
        elif B >= C:
            C *= 2

    if A < B < C:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 68828
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    int tot = 0;
    for (int i = 0; i < 5; ++i) {
        int x;
        cin >> x;
        tot += x;
    }
    cout << 15 - tot;
    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

//standard
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define abs(a) ((a)>(0)?(a):-(a))

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//Prototype
void bubbleSort(long int* N, int len);
void Swap(int long *a,long int *b);


int main() {
    int n,m;
    long int x[1000];
    long int y[1000];
    long int z[1000];

    long tameru[8][1000];
    long ans = 0;

    //input
    scanf("%d",&n);
    scanf("%d",&m);

    for(int i = 0; i < n; i++){
        scanf("%ld %ld %ld",&x[i],&y[i],&z[i]);
        tameru[0][i] = x[i] + y[i] + z[i];
        tameru[1][i] = x[i] + y[i] - z[i];
        tameru[2][i] = x[i] - y[i] + z[i];
        tameru[3][i] = x[i] - y[i] - z[i];
        tameru[4][i] = -x[i] + y[i] + z[i];
        tameru[5][i] = -x[i] + y[i] - z[i];
        tameru[6][i] = -x[i] - y[i] + z[i];
        tameru[7][i] = -x[i] - y[i] - z[i];
    }

    //calculation
    for(int i = 0; i < 8; i++){
        bubbleSort(tameru[i], n);
        long count = 0;
        for (int j = n-1; j >= n - m; j--) {
            count += tameru[i][j];
        }
        ans = max(ans, count);
    }

    printf("\n%ld\n",ans);
    return 0;
}


//BubbleSort
void bubbleSort(long int* N, int len){
    int i,j;

    for(i=0; i<len; i++){
        for(j=len-1; j>i; j--){
            if(N[j] < N[j-1]){
                Swap(&N[j],&N[j-1]);
            }
        }
    }
}

//general function
void Swap(long int *a, long int *b) {
    long int tmp = *a;
    *a = *b;
    *b = tmp;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const int INF = 100100100;

int main() {
    int n,m; cin >> n >> m;
    string s; cin >> s;
    int dp[n+1]; rep(i,n+1) dp[i] = INF;
    dp[0] = 0;
    int check = 0;
    int last[n+1]; rep(i,n+1) last[i] = -1;
    rep(i,n) {
        if (s[i] == '1') continue;
        for (int j = max(check, i)+1; (j <= m+i && j <= n); j++) {
            check = max(check, j);
            if (s[j] == '1') continue;
            if (dp[j] > dp[i]+1) {
                dp[j] = dp[i]+1;
                last[j] = i;
            }
        }
    }
    if (dp[n] == INF) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    int now = n;
    while (now != -1) {
        ans.push_back(now);
        now = last[now];
    }
    reverse(all(ans));
    rep(i,sz(ans)-1) {
        printf("%d ", ans[i+1] - ans[i]);
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 4764
#include <stdio.h>
#include <string.h>

void addstr( char *str1, char *str2 ) {

    char temp[1000];
    int max, i;
    
    if ( strlen( str1 ) > strlen( str2 ) ) { max = strlen( str1 ); } else { max = strlen( str2 ); }
    
    memset( temp, '\0', 1000 );
    strcpy( &temp[max-strlen(str1)+1], str1 );
    i = 0;
    while ( temp[i] == '\0' ) {
         temp[i] = '0';
         i++;
    }
    strcpy( str1, temp );
    
    memset( temp, '\0', 1000 );
    strcpy( &temp[max-strlen(str2)+1], str2 );
    i = 0;
    while ( temp[i] == '\0' ) {
         temp[i] = '0';
         i++;
    }
    strcpy( str2, temp );
    
    for ( i = max; i >= 0; i-- ) {

        str1[i] += str2[i] - '0';

        if ( str1[i] > '9' ) {

            str1[i] -= 10;
            str1[i-1] += 1;

        }

    }

    if ( str1[0] == '0' ) {

        memset( temp, '\0', 1000 );
        strcpy( temp, &str1[1] );
        memset( str1, '\0', 1000 );
        strcpy( str1, temp );

    }

}

int main( void ) {

    char a[1000], b[1000];
    int n;
    
    scanf( "%d", &n );
    
    while ( n-- != 0 ){
        
        scanf( "%s", a );
        scanf( "%s", b );
        
        addstr( a, b );
        
        if ( strlen( a ) <= 80 ) {

            printf( "%s\n", a );

        } else {

            printf( "overflow\n" );

        }

    }
    
    return 0;

}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long K, long long C, std::string S){
    vector<pair<int, int>> ldp(N, {0, -1e6}), rdp(N, {0, 1e6});
    rep(i,0,N) {
        if (S[i] == 'o') {
            ldp[i] = {i>0 ? ldp[i-1].first + 1 : 1, i};
            rep(j,i+1, min(i+1+C, N)) ldp[j] = ldp[i];
            i += C;
        } else if (i > 0) {
            ldp[i] = ldp[i-1];
        }
    }
    rrep(i,0,N) {
        if (S[i] == 'o') {
            rdp[i] = {i<N-1 ? rdp[i+1].first + 1 : 1, i};
            rep(j,max(i-C,0LL), i) rdp[j] = rdp[i];
            i -= C;
        } else if (i < N-1) {
            rdp[i] = rdp[i+1];
        }
    }
    vector<int> answer;
    rep(i,0,N) {
        if (S[i] == 'x') continue;
        int sum = 0, nextLeft = -1e6, nextRight = 1e6;
        if (i>0) {
            sum += ldp[i-1].first;
            nextLeft = ldp[i-1].second;
        }
        if (i<N-1) {
            sum += rdp[i+1].first;
            nextRight = rdp[i+1].second;
        }
        if (nextRight - nextLeft <= C) sum--;
        if (sum < K) answer.push_back(i+1);
    }
    if (answer.empty()) cout << endl;
    rep(i,0,answer.size()) cout << answer[i] << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long C;
    scanf("%lld",&C);
    std::string S;
    std::cin >> S;
    solve(N, K, C, S);
    return 0;
}


Measured memory_bytes: 5880
import scala.io.StdIn.{readInt, readLine};

object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val arr = readLine.split(" ").map(_.toInt);
        build(n, arr);
        println(" " + arr.mkString(" "));
    }
    
    def build(length: Int, arr: Array[Int]): Unit = {
        def go(curr: Int): Unit = {
            if (curr < length) {
                go(curr * 2 + 1);
                go(curr * 2 + 2);
                heapify(length, arr, curr);
            }
        }
        go(0);
    }
    
    def heapify(length: Int, arr: Array[Int], idx: Int): Unit = {
        val left = idx * 2 + 1;
        val right = idx * 2 + 2;
        if (right < length) {
            val m = max(arr, idx, left, right);
            if (idx != m) {
                swap(arr, idx, m);
                heapify(length, arr, m);
            }
        } else if (left < length) {
            if (arr(left) > arr(idx)) swap(arr, left, idx);
        } else {
            // nop
        }
    }
    
    def max(arr: Array[Int], k1: Int, k2: Int, k3: Int): Int = {
        val v1 = arr(k1); val v2 = arr(k2); val v3 = arr(k3);
        if (v1 > v2) {
            if (v1 > v3) k1 else k3;
        } else {
            if (v2 > v3) k2 else k3;
        }
    }
    
    def swap(arr: Array[Int], a: Int, b: Int): Unit = {
        val tmp = arr(a);
        arr(a) = arr(b);
        arr(b) = tmp;
    }
}


Measured memory_bytes: 188740
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[][] A = new int[N][];
		for(int i=0;i<N;i++){
			A[i] = new int[M];
			for(int j=0;j<M;j++) A[i][j] = (int) (S[i][j] - '0');
		}
		
		var blk = new Acc2();
		blk.Init(A);
		
		int[][] H = new int[N][];
		for(int i=0;i<N;i++){
			H[i] = new int[M];
			for(int j=0;j<M-1;j++){
				if(S[i][j] == '1' && S[i][j+1] == '1') H[i][j] = 1;
			}
		}
		
		var hor = new Acc2();
		hor.Init(H);
		
		int[][] V = new int[N][];
		for(int i=0;i<N;i++){
			V[i] = new int[M];
		}
		for(int i=0;i<N-1;i++){
			for(int j=0;j<M;j++){
				if(S[i][j] == '1' && S[i+1][j] == '1') V[i][j] = 1;
			}
		}
		
		var ver = new Acc2();
		ver.Init(V);
		
		int[] Ans = new int[Q];
		for(int i=0;i<Q;i++){
			int x1 = Query[i][0] - 1;
			int y1 = Query[i][1] - 1;
			int x2 = Query[i][2] - 1;
			int y2 = Query[i][3] - 1;
			int bb = blk.cal(y1, x1, y2+1, x2+1);
			if(bb == 0){
				Ans[i] = 0;
				continue;
			}
			int hh = hor.cal(y1, x1, y2, x2+1);
			int vv = ver.cal(y1, x1, y2+1, x2);
			//Console.WriteLine("bb{0} hh{1} vv{2}",bb,hh,vv);
			Ans[i] = bb - hh - vv;
		}
		Console.WriteLine(String.Join("\n",Ans));
		
	}
	int N,M;
	int Q;
	String[] S;
	int[][] Query;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1]; Q = d[2];
		S = new String[N];
		for(int i=0;i<N;i++) S[i] = rs();
		Query = new int[Q][];
		for(int i=0;i<Q;i++) Query[i] = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class Acc2{
	
	int H,W;
	int[][] acc;
	
	public void Init(int[][] M){
		H = M.Length;
		W = M[0].Length;
		acc = new int[H+1][];
		for(int i=0;i<=H;i++){
			acc[i] = new int[W+1];
			if(i == 0) continue;
			for(int j=1;j<=W;j++){
				acc[i][j] = M[i-1][j-1];
			}
		}
		
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				acc[i][j] += acc[i][j-1];
			}
		}
		for(int j=1;j<=W;j++){
			for(int i=1;i<=H;i++){
				acc[i][j] += acc[i-1][j];
			}
		}
	}

	public int cal(int x1,int y1,int x2,int y2){
		//return num of land [x1,x2)*[y1,y2); left-inclusive / right-noninclusive;
		if(x2<x1||y2<y1)return 0;
		return acc[y2][x2]-acc[y2][x1]-acc[y1][x2]+acc[y1][x1];
	}

}

Measured memory_bytes: 147788
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  REP(i, N) cin >> s[i];
  sort(All(s));
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if(s[i]!=s[i+1]){
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	int dist = abs(a - b);
	int sa = v - w;
	YORN(sa * t >= dist);
	return 0;
}

Measured memory_bytes: 3664
A,B,H,M=map(int,input().split())
import math
fun=60*H+M
SA=5.5 * fun
syuu=SA//360
sa=SA-syuu*360
rad=math.pi * sa /180
C=(A**2 +B**2 -2*A*B* math.cos(rad))**(1/2)
print(C)

Measured memory_bytes: 9500
import sys
input = sys.stdin.readline
s=input().strip()
flg=True
for i in range(len(s)):
    if i%2==0:
        if s[i]=="L":
            flg=False
    else:
        if s[i]=="R":
            flg=False
if flg:
    print("Yes")
else:
    print("No")


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

bool isPalindromic(int n) {
    if (n % 2 == 0) return false;
    int counter = 0;
    rep(i, n+1) {
        if (n % (i+1) == 0) counter++;
    }
    return counter == 8;
}

int main() {
    int N;
    cin >> N;
    int counter = 0;
    rep(i, N) {
        if (isPalindromic(i+1)) counter++;
    }
    cout << counter << endl;
}


Measured memory_bytes: 256
N,M,X,Y = map(int,input().split())
x = sorted(list(map(int,input().split())))
y = sorted(list(map(int,input().split())))

war = True
for i in range(X+1,Y+1):
    if x[-1] < i and y[0] >= i:
        war = False
        break
print('War' if war else 'No War')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long a, b, c, k;

	std::cin >> a >> b >> c >> k;

	if (k % 2 == 0) {
		std::cout << a - b << std::endl;
	}
	else {
		std::cout << b - a << std::endl;
	}

	return 0;
}

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

int main(){
    vec x,y;
    int N;cin>>N;
    int a[60];
    int M=-1,m=1,i_M=0,i_m=0;
    for(int i=1;i<=N;i++){
        cin>>a[i];
        if(a[i]>=0){
            if(a[i]>M){
                M=a[i];
                i_M=i;
            }
        }
        else{
            if(a[i]<m){
                m=a[i];
                i_m=i;
            }
        }
    }
    
    if(M==-1){
        int i=N-1;
        while(i>=1){
            if(a[i]>a[i+1]){
                a[i]+=a[i+1];
                x.push_back(i+1);
                y.push_back(i);
            }
            i--;
        }
    }
    else if(m==1){
        for(int i=1;i<N;i++){
            if(a[i]>a[i+1]){
                a[i+1]+=a[i];
                x.push_back(i);
                y.push_back(i+1);
            }
        }
    }
    else if(M>=-m){
        for(int i=1;i<=N;i++){
            if(a[i]<0){
                a[i]+=M;
                x.push_back(i_M);
                y.push_back(i);
            }
        }
        for(int i=1;i<N;i++){
            if(a[i]>a[i+1]){
                a[i+1]+=a[i];
                x.push_back(i);
                y.push_back(i+1);
            }
        }
    }
    else{
        for(int i=1;i<=N;i++){
            if(a[i]>0){
                a[i]+=m;
                x.push_back(i_m);
                y.push_back(i);
            }
        }
        int i=N-1;
        while(i>=1){
            if(a[i]>a[i+1]){
                a[i]+=a[i+1];
                x.push_back(i+1);
                y.push_back(i);
            }
            i--;
        }
    }

    cout<<x.size()<<endl;
    for(int i=0;i<x.size();i++)
        cout<<x[i]<<" "<<y[i]<<endl;
    return 0;  
}

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

int n;
bool ch = 0;

int main() {
  cin >> n;
  for (int i = 0; i < 3; ++i) {
    if (n % 10 == 7) ch = 1;
    n /= 10;
  }
  if (ch)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
N = int(input())


hash = {}
end = int(N ** (1/2))
for i in range(2, end + 1):
    while N % i == 0:
        if i in hash:
            hash[i] += 1
        else:
            hash[i] = 1
        N = N // i
if N != 1:
        if N in hash:
            hash[N] += 1
        else:
            hash[N] = 1

if len(hash.keys()) == 0 and N != 1:
    print(1)
    exit()


count = 0
trans = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]

res = 0
for i in hash.values():
    for j in range(len(trans)):
        if i > trans[j]:
            continue
        elif i == trans[j]:
            res += (j + 1)
            break
        else:
            res += j
            break



print(res)

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

int main(){
  int n,k;
  cin >> n >> k;
  int num = 1;
  rep(i,n){
    if(2*num >= num+k) num += k;
    if(2*num < num+k)  num *= 2;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    int a;
    int b;
    int i;
    int j;
    int count = 0;
    scanf("%d %d", &a, &b);

    if (a <= 12 && b <= 31)
    {
        if (b >= a)
        {
            printf("%d", a);
        }
        else
        {
            printf("%d", a - 1);
        }
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll gcd(ll a,ll b){
    if(b == 0)
        return a;
    return gcd(b,a % b);
}
int main(){
    ll a,b;
    while(scanf("%lld%lld",&a,&b) != EOF){
        printf("%lld %lld\n",gcd(a,b),a * b / gcd(a,b));
    }
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  priority_queue<pair<int,int>> que;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
    que.push(make_pair(a,i));
  }

  ll ret = 0;
  set<int> s;
  while(!que.empty()){
    pair<int,int> p = que.top(); que.pop();
    int x = p.first;
    int idx = p.second;
    s.insert(idx);
    auto pos = s.find(idx);
    int rhs = N;
    int rhs2 = N;
    int lhs = -1;
    int lhs2 = -1;
    {
      auto it = pos;
      it++;
      if(it != s.end()){
        rhs = *it;
        it++;
        if(it != s.end()) rhs2 = *it;
      }
    }
    {
      auto it = pos;
      if(it != s.begin()){
        it--;
        lhs = *it;
        if(it != s.begin()){
          it--;
          lhs2 = *it;
        }
      }
    }

    int l1 = idx-lhs, l2 = lhs-lhs2, r1 = rhs-idx, r2 = rhs2-rhs;
    //cout << l2 << " " << l1 << " " << r1 << " " << r2 << endl;
    ret += (ll)x * (l2 * r1 + l1 * r2);
  }

  
  cout << ret << endl;
  
  
  return 0;
}


Measured memory_bytes: 6128
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        String t=sc.next();
        //-97
        int[] x=new int[26];
        int c=0;
        HashSet<Character> S=new HashSet<>();
        HashSet<Character> T=new HashSet<>();
        for (int i = 0; i < s.length(); i++) {
            char p=s.charAt(i);
            S.add(p);
            char q=t.charAt(i);
            T.add(q);
            if(x[(int)(p-97)]==0){
                x[(int)(p-97)]=(int)q;
            }else{
                if(x[(int)(p-97)]!=(int)q){
                    out.println("No");
                    exit(0);
                }
            }
        }
        if(S.size()!=T.size()){
            out.println("No");
        }else{
            out.println("Yes");
        }
    }
    //階乗
static long fact(long a){
    long b=1;
    for (long i = 1; i <= a; i++) {
        b*=i;
    }
    return b;
}
//最大公約数
static int gcd (int a, int b) {
    int temp;
    while((temp = a%b)!=0) {
        a = b;
        b = temp;
    }
    return b;
}
//※最小公倍数はa*b/gcd(a,b)である
//二項係数
static long combi (long a, long b) {
    b=min(a-b,b);
    return permu(a,b)/fact(b);
}
//順列
static long permu(long a,long b){
    long temp=1;
    for (long i =a ; i > a-b; i--) {
        temp*=i;
    }
    return temp;
}
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string t = "";
    vector<string> ts;
    ts.push_back("");
    while(!ts.empty())
    {
        vector<string> cs;
        cs.push_back("dream");
        cs.push_back("dreamer");
        cs.push_back("erase");
        cs.push_back("eraser");
        vector<string> tcs;
        for(int i=0; i<ts.size(); i++)
        {
            for(int j=0; j<cs.size(); j++)
            {
                tcs.push_back(ts.at(i) + cs.at(j));
            }
        }
        for(int i=0; i<tcs.size();)
        {
            if(tcs.at(i).length() > s.length()) tcs.erase(tcs.begin()+i);
            else if(tcs.at(i) != s.substr(0, tcs.at(i).size())) tcs.erase(tcs.begin()+i);
            else if(tcs.at(i) == s)
            {
                t = s;
                break;
            }
            else i++;
        }
        ts = tcs;
        if(t==s) break;
    }
    if(t==s) cout << "YES\n";
    else cout <<"NO\n";
    return 0;
}

Measured memory_bytes: 2084
import numpy as np
a,b,c=map(int,input().split())
l=[a,b,c]
arr=np.array(l)
m=max(arr)
t=m-arr
#print(t)
s=sum(t)
if s%2==0:
  ans=s//2
else:
  ans=(s+3)//2
print(ans)

Measured memory_bytes: 12488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k,x;
int main()
{
   cin>>k>>x;
   for(ll i=x-k+1;i<=x+k-1;i++)
   if(i!=x+k-1)
    cout<<i<<" ";
   else
    cout<<i;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<string> v(3);
int cnt = 0;

void game(int target) {
  if (v[target].empty()) {
    cout << char(target + 'A') << endl;
    return;
  }
  int old = target;
  target = v[target][0] - 'a';
  if (!v[target].empty()) {
    v[old].erase(0, 1);
  }
  game(target);
}

int main() {
  cin >> v[0] >> v[1] >> v[2];
  game(0);
  getchar();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcount __builtin_popcount
#define mp make_pair
#define pb push_back
#define ins insert
#define sc second
#define fr first
#define endl "\n"
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)

int n, v[N], dp[N];

void solve(){
    cin >> n;
    forn(i,0,n)cin >> v[i];
    dp[n-1]=0;dp[n]=MOD;
    for(int i=n-2;i>=0;i--){
        dp[i] = min(abs(v[i]-v[i+1])+dp[i+1], abs(v[i]-v[i+2])+dp[i+2]);
    }
    cout << dp[0] << endl;
}
int main(){_
    solve();
    /*
    int t; cin >> t;
    while(t--){
        solve();
    }
    */
}


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

struct prog
{
	int s,t,c;
};

bool cmp(prog a,prog b)
{
	if(a.c!=b.c)return a.c<b.c;
	return a.s <= b.s;
}

int main()
{
	int n,c;
	cin >> n >> c;
	vector<prog> p(n);
	vector<int> imos(200010);
	rep(i,n)
	{
		cin >> p[i].s >> p[i].t >> p[i].c;
	}
	sort(ALL(p),cmp);
	rep(i,n-1)
	{
		if(p[i].c==p[i+1].c&&(p[i].t==p[i+1].s||p[i].t==p[i+1].s+1))
		{
			p[i].t = p[i+1].t;
			p[i+1].t = 200008;
			p[i+1].s = 200008;
		}
	}
	int aa = p[n-1].c;
	rep(i,n)
	{
		imos[p[i].s]++;
		imos[p[i].t+1]--;
	}
	rep(i,150005)
	{
		imos[i+1] += imos[i];
	}
	int ans = 0;
	rep(i,150007)
	{
		ans = max(imos[i],ans);
	}
	cout<<min(c,ans)<<endl;
	return 0;
}

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

using namespace std;

int main(int argc, char const* argv[])
{
  int n, ans=0;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  int tmpmax = h[0];
  for (int i = 0; i < n; i++) {
    if( i == 0 ) ans++;
    else{
        if( tmpmax <= h[i]){
            ans++;
            tmpmax = h[i];
        }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

double A[100005];

int main() {

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

	double h;
	int n;
	cin >> h >> n;
	for (int i = 0; i < n; ++i) {
		cin >> A[i];
	}
	sort(A, A + n);
	for (int i = n - 1; i >= 0; --i) {
		h -= A[i];
		if (h <= 0) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 1024
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=3007;
const ll mod=1000*1000*1000+7;

int n;
char wcz[nax];

ll dp[nax][nax];

void dod(ll &a, ll b)
{
	a=(a+b)%mod;
}

int main()
{
	scanf("%d%s", &n, wcz+1);
	dp[1][1]=1;
	for (int i=2; i<=n; i++)
	{
		if (wcz[i-1]=='<')
		{
			ll s=0;
			for (int j=1; j<=i; j++)
			{
				dp[i][j]=s;
				s=(s+dp[i-1][j])%mod;
			}
		}
		else
		{
			ll s=0;
			for (int j=i; j; j--)
			{
				dp[i][j]=s;
				s=(s+dp[i-1][j-1])%mod;
			}
		}
	}
	
	ll wyn=0;
	for (int i=1; i<=n; i++)
		wyn+=dp[n][i];
	printf("%lld\n", wyn%mod);
	return 0;
}


Measured memory_bytes: 69120
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int n, a[100001], cnt;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}
int main(){
	cin >> n;
	a[0] = 0;
	lp(n) {
		cin >> a[i+1];
	}
	sort(a, a + n + 1);
	lp(n) {
		if (a[i] == a[i + 1]) {
			cnt--;
			a[i + 1] = 0;
		}
		else cnt++;
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ms(x) memset(x,0,sizeof(x));
#define forn(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
#define sc(x) scanf("%d",&x)
#define bug(x) cerr<<#x<<":"<<(x)<<endl
using namespace std;
typedef long long ll;
const int M = 1000000;
vector<int> g[1000];
int cal(vector<int> & a,vector<int> & b){
    ll sum=0;
    int n=a.size()-1;
    forn(i,0,n){
        sum+=(a[i]-b[i])*(a[i]-b[i]);
    }
    ll s=sqrt(sum);
    if(s*s==sum) return 1;
    return 0;
}
int main(){
    int u;
    int n,d;
    cin>>n>>d;
    forn(i,1,n) 
        forn(j,1,d){
            cin>>u;
            g[i].push_back(u);
        }
    int ans=0;
    forn(i,1,n)
        forn(j,i+1,n){
            if(cal(g[i],g[j])) ++ans;
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::collections::HashMap;
use std::io::Read;

fn count_chars(s: &str) -> [usize;26]{
    let mut cnt = [0usize; 26];
    for c in s.to_string().chars() {
        cnt[c as usize - 'a' as usize] += 1
    }
    cnt
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf);
    let mut iter = buf.split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let strs: Vec<[usize;26]> = (0..n)
        .into_iter()
        .map(|_| {count_chars(iter.next().unwrap())})
        .collect();
    let mut cnt:HashMap<[usize;26], usize> = HashMap::new();

    for s in strs{
        let etry = cnt.entry(s).or_insert(0 as usize);
        *etry += 1;
    }
    let mut ans = 0 as usize;
    
    for x in cnt.values(){
        ans += x * (x - 1) / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 68716
#include <stdio.h>

int main(void){
    int A,B;
    scanf("%d %d", &A, &B);
    int x[3];
    x[0] = A+B;
    x[1] = A-B;
    x[2] = A*B;
    int Max=x[0];
    for(int i=0; i<3; i++){
        if(Max<x[i])
            Max = x[i];
    }
    printf("%d\n", Max);
    return 0;
}

Measured memory_bytes: 128
/* SPARROW 2019 */
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long

#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)

#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x,y) insert({x,y})
#define sv(a) sort(a.begin(),a.end())
#define zero(arr,a) memset(arr,a,sizeof arr)
#define mx 100005

int fx[]={0,1,1,1,0,-1,-1,-1};
int fy[]={1,1,0,-1,-1,-1,0,1};
int pre[mx],suf[mx];

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

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);
    //freopen("1015.txt","w",stdout);
    int n;
    sci(n);

    vector<int>data(n);

    for(int i=0;i<n;i++) sci(data[i]);
    pre[0]=data[0];
    for(int i=1;i<n;i++){
        pre[i]=gcd(data[i],pre[i-1]);
    }

    suf[n-1]=data[n-1];

    for(int i=n-2;i>=0;i--){
        suf[i]=gcd(data[i],suf[i+1]);
    }

    int res=0;
    res=max(suf[1],pre[n-2]);

    for(int i=1;i<n-1;i++){
        int tmp=gcd(pre[i-1],suf[i+1]);
        res=max(res,tmp);
    }

    pfi(res);pn;
    return 0;
}



Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}



signed main(void) {
    int k; cin >> k;
    vvint v(10, vint(0));
    rep(i, 9) v[0].push_back(i + 1);
    rep(i, 9) {
        rfor(x, v[i]) {
            int d = x % 10;
            if(d != 0) v[i + 1].push_back(x * 10 + d - 1);
            v[i + 1].push_back(x * 10 + d);
            if(d != 9) v[i + 1].push_back(x * 10 + d + 1);
        }
    }
    vint ans;
    rfor(x, v) {
        rfor(y, x) ans.push_back(y);
    }
    sort(all(ans));
    print(ans[k - 1]);

    return 0;
}


Measured memory_bytes: 4084
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int MAXN=220000;
const ll INF=1E18;
int n, m, a[MAXN];
struct Edge
{
	int to, val;
	Edge(int v, int w): to(v), val(w) {}
};
vector<Edge> g[MAXN];
struct DSU
{
	int f[MAXN];
	void init()
	{
		for (int i=1; i<=n; i++) f[i]=i;
	}
	int getf(int x)
	{
		if (x==f[x]) return x;
		return f[x]=getf(f[x]);
	}
	bool merge(int u, int v)
	{
		int x=getf(u), y=getf(v);
		if (x==y) return 0;
		f[x]=y; return 1;
	}
} dsu;
typedef pair<ll, int> pli;
pli dp1[MAXN], dp2[MAXN], p[MAXN];
void dfs1(int u, int f)
{
	for (Edge e:g[u])
	{
		int v=e.to;
		if (v!=f)
		{
			dfs1(v, u);
			dp1[u]=min(dp1[u], make_pair(dp1[v].first+e.val, dp1[v].second));
		}
	}
	for (Edge e:g[u])
	{
		int v=e.to;
		if (v!=f)
		{
			dp2[u]=min(dp2[u], dsu.f[dp1[v].second]!=dsu.f[dp1[u].second]?
			make_pair(dp1[v].first+e.val, dp1[v].second):
			make_pair(dp2[v].first+e.val, dp2[v].second));
		}
	}
}
void dfs2(int u, int f)
{
	for (Edge e:g[u])
	{
		int v=e.to;
		if (v!=f)
		{
			dp1[v]=min(dp1[v], make_pair(dp1[u].first+e.val, dp1[u].second));
			dp2[v]=min(dp2[v], dsu.f[dp1[u].second]!=dsu.f[dp1[v].second]?
			make_pair(dp1[u].first+e.val, dp1[u].second):
			make_pair(dp2[u].first+e.val, dp2[u].second));
			dfs2(v, u);
		}
	}
}
int main()
{
//	freopen("AT3611.in", "r", stdin);
//	freopen("AT3611.out", "w", stdout);
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	for (int i=1; i<n; i++)
	{
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		g[u].push_back(Edge(v, w));
		g[v].push_back(Edge(u, w));
	}
	dsu.init();
	int cnt=0; ll ans=0;
	while (cnt<n-1)
	{
		for (int i=1; i<=n; i++)
		{
			dp1[i]=make_pair(a[i], i);
			dp2[i]=make_pair(INF, 0);
		}
		dfs1(1, 0); dfs2(1, 0);
		for (int i=1; i<=n; i++)
		{
			p[i]=dsu.f[dp1[i].second]!=dsu.f[i]?dp1[i]:dp2[i];
			p[i].first+=a[i];
		}
		for (int i=1; i<=n; i++) p[dsu.f[i]]=min(p[dsu.f[i]], p[i]);
		for (int i=1; i<=n; i++)
		{
			pli t=p[dsu.getf(i)];
			if (t.first<INF&&dsu.merge(i, t.second)) cnt++, ans+=t.first;
		}
		for (int i=1; i<=n; i++) dsu.getf(i);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 45440
def main():
    N, W = map(int, input().split())
    DP = [-1]*(W+1)
    DP[0] = 0
    for i in range(N):
        v, w = map(int, input().split())
        for j in range(w, W+1):
            if DP[j-w] == -1:
                continue
            else:
                DP[j] = max(DP[j], DP[j-w] + v)
    
    ans = 0
    for k in range(W+1):
        ans = max(ans, DP[k])
    #print(DP)
    print(ans)


if __name__ == "__main__":
    main()



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> num(N);
  rep(i,N) cin >> num.at(i);
  int ans=0;
  rep(i,N-2) {if((num.at(i)<num.at(i+1)&&num.at(i+1)<num.at(i+2))||(num.at(i)>num.at(i+1)&&num.at(i+1)>num.at(i+2))) ans++;}
  cout << ans << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, X, Y;
int ans[2010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> X >> Y;
	X--; Y--;

	rep(i, 0, N) rep(j, i + 1, N) {
		int k = inf;

		// not use X -> Y
		chmin(k, j - i);

		// use X -> Y
		chmin(k, abs(X - i) + abs(Y - j) + 1);

		ans[k]++;
	}

	rep(k, 1, N) cout << ans[k] << endl;
}







Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') cnt++;
	}
	cout << cnt << endl;
 	return 0;
}

Measured memory_bytes: 3532