akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
max_a = max(a)
del a[-1]
target = int(1e9+1)
for aa in a:
    if abs(max_a - target*2) >= abs(max_a - aa*2):
        target = aa
print(max_a, target)


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

void print_line(int width, bool start_dot)
{
  for (int i = 0; i < width; i++)
  {
    cout << (start_dot ? '.' : '#');
    start_dot = !start_dot;
  }
  cout << endl;
}

void print_chessboard(int height, int width)
{
  for (int i = 0; i < height; i++)
  {
    print_line(width, i % 2);
  }
  cout << endl;
}

int main()
{
  int height, width;

  while (true)
  {
    cin >> height >> width;
    if (height == 0 && width == 0)
    {
      break;
    }
    print_chessboard(height, width);
  }
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
const ll MOD=1000000007;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    char c;
    cin>>N;
    cin>>c;
    int sub=N;
    char x;
    for(int i=0;i<N-1;i++){
        cin>>x;
        if(c==x)sub--;
        c=x;
    }
    cout<<sub<<endl;
}

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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double h = 360 / 12 * H + 30.0 / 60 * M;
  double m = 360 / 60 * M;
  double d = abs(h - m);
  d = min(d, 360 - d);
  double r = d * M_PI / 180;
  double ans = sqrt(A * A + B * B - 2 * A * B * cos(r));
  cout << fixed << setprecision(9) << ans << "\n";
}

Measured memory_bytes: 4056
N = int(input())
s = [1 if s=='o' else 0 for s in input()]

# 1:sheep, 0:wolf
def check(a,b):
  answer = [None]*N
  answer[0]=a
  answer[-1]=b
  for i in range(0,N-2):
    answer[i+1] = answer[i-1]^answer[i]^s[i]
  #print(answer)
  if answer[N-3]^answer[N-2]^s[N-2]==answer[N-1] and answer[N-2]^answer[N-1]^s[N-1]==answer[0]:
    return answer
  else:
    return False
  
for a,b in [(0,0),(1,0),(0,1),(1,1)]:
  x = check(a,b)
  if x:
    print(''.join(['S' if a==1 else 'W' for a in x]))
    break
else:
  print(-1)
    

Measured memory_bytes: 5644
N=int(input())
S=input()

flag=0

if N%2==0:
    for i in range(int(N/2)):
        if S[i]!=S[i+int(N/2)]:
            flag+=1

    if flag==0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<ll>> graph;

int main() {
  ll n, m;
  cin >> n >> m;
  vll h(n);
  rep(i,n) cin >> h[i];
  graph g(n);
  rep(i,m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll ans = 0;
  rep(i,n) {
    ll m = g[i].size();
    bool ok = true;
    rep(j,m) if(h[i]<=h[g[i][j]]) ok = false;
    if(ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9856
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
abc=[list(map(int,input().split())) for i in range(n-1)]
q,k=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(q)]

itta=[0]*(n+1)
dic=defaultdict(list)
for a,b,c in abc:
    dic[a].append((b,c))
    dic[b].append((a,c))

d=deque([(k,0)])
while d:
    now=d.popleft()
    if itta[now[0]]!=0:
        continue
    itta[now[0]]=now[1]
    for i,j in dic[now[0]]:
        d.append((i,j+now[1]))
# print(itta)
itta[k]=0
for x,y in xy:
    print(itta[x]+itta[y])

Measured memory_bytes: 131160
#include <iostream>
using namespace std;
int main(void){
  int a,b,c,d;
  a = b = c = d = 0;
  int p;
  for(int i=0;i<6;i++){
    cin >> p;
    if(p == 1) a++;
    if(p == 2) b++;
    if(p == 3) c++;
    if(p == 4) d++;
  }
  
  if(a == 3 || b == 3 || c == 3 || d == 3) cout << "NO" << endl;
  else cout << "YES" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1; 
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a;

}

Measured memory_bytes: 3568
S = input()
N = len(S)

ans = [0] * N

r, l = 0, 0
for i in range(N):
    if S[i] == 'R' and l != 0:
        ans[i-l-1] = r//2 + r % 2 + l//2
        ans[i-l]   =  r//2 + l//2 + l % 2
        r, l = 1, 0
    elif S[i] == 'R':
        r += 1
    elif S[i] == 'L':
        l += 1
ans[N-l-1] = r//2 + r % 2 + l//2
ans[N-l]   =  r//2 + l//2 + l % 2

print(*ans)


Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  string S;
  cin >> S;
  int add=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='o')  add++;
  }
  cout << 700+100*add << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;
 
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; }
    return true;
}
 
int main() {
	ll X;
  	cin >> X;
  	ll money =100;
  	int year=0;
  	while(money < X){
    	money = money*1.01;
      	year++;
    }
  	cout << year << endl;
}

Measured memory_bytes: 3680
groups :: [[Int]]
groups = [ [1, 3, 5, 7, 8, 10, 12]
         , [4, 6, 9, 11]
         , [2]
         ]

main :: IO ()
main = do
  [x, y] <- mapM readIO . words =<< getLine
  if any (\g -> elem x g && elem y g) groups
    then putStrLn "Yes"
    else putStrLn "No"


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll INF = 100100100100;
/*
dp[i][w]
i番目までの品物で重さの総和がw以下となるような
選び方の価値の最大値
*/
int main(){
    int n,WL;
    cin >> n >> WL;
    vector<ll> w(n+1),v(n+1);  //.first = weight, .second = value
    rep(i,n) cin >> w[i+1] >> v[i+1];
    vector<vector<ll>> dp(n+1,vector<ll>(WL+1));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=WL;j++){
            dp[i][j] = dp[i-1][j];
            if(j-w[i]>=0)
                dp[i][j] = max(dp[i][j],   //use
                    dp[i-1][j-w[i]]+v[i] );
        }
    }
    cout << dp[n][WL] << endl;

    return 0;
}

Measured memory_bytes: 80256
#include <cstdio>
#include <cstdlib>

#define siz 10000000

char buf[siz], *bit = buf;

inline int nextInt(void) {
	register int ret = 0;
	register int neg = false;

	for (; *bit < '0'; ++bit)
		if (*bit == '-')neg ^= true;

	for (; *bit >= '0'; ++bit)
		ret = ret * 10 + *bit - '0';

	return neg ? -ret : ret;
}

int n, m;

int pre[100005];

inline int ask(int p) {
	int ret = 0;
	for (; p; p -= p&-p)
		ret += pre[p];
	return ret;
}

inline void add(int p, int k) {
	for (; p <= n; p += p&-p)
		pre[p] += k;
}

signed main(void) {
	fread(buf, 1, siz, stdin);

	n = nextInt();
	m = nextInt();

	for (int i = 1; i <= m; ++i) {
		int c = nextInt();
		if (c)	// get(i)
			printf("%d\n", ask(nextInt()));
		else	// add(s, t, x)
		{
			int x = nextInt();
			int y = nextInt();
			int k = nextInt();
			add(x, k); add(y + 1, -k);
		}
	}

	//system("pause");
}

Measured memory_bytes: 4284
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BSimilarArrays {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vi A(n);
        in >> A;
        int odd = 1, res = 1;
        trav(x, A) {
            x %= 2;
            res *= 3;
            odd *= 1 + (not x);
        }
        res -= odd;
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BSimilarArrays solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int S;
	cin >> S;
	int s = S % 60;
	S -= s;
	S /= 60;
	int m = S % 60;
	int h = S / 60;
	cout << h << ":" << m << ":" << s << "\n";
}



Measured memory_bytes: 3076
h,w,d=map(int,input().split())
a=[]
l=[[] for i in range(h*w+1)]
for i in range(h):
    p=[int(j) for j in input().split()]
    a.append(p)
    for j in range(w):
        l[int(p[j])].append(i)
        l[int(p[j])].append(j)
cost=[0 for i in range(h*w+1)]
for i in range(1,h*w+1-d):
    cost[i+d]=cost[i]+abs(l[i+d][0]-l[i][0])+abs(l[i][1]-l[i+d][1])
q=int(input())
lr=[]
for i in range(q):
    lr=[int(j) for j in input().split()]
    print(cost[lr[1]]-cost[lr[0]])

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  set<string> s;
  rep(i,n){
    string x;
    cin>>x;
    s.emplace(x);
  }
  cout<<(size(s))<<endl;

}

Measured memory_bytes: 19180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(ALL(a));
  ll m = a[n / 2];
  ll ans = 0;
  REP(i, n) { ans += abs(a[i] - m); }
  cout << ans << "\n";
}

Measured memory_bytes: 1792
using System;
using System.Linq;
 
namespace AtCoder {
    class Program {
        static void Main() {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] b = new int[n];
            for (int i = 0; i < n - 1; i++) {
                b[a[i] - 1]++;
            }
            Console.WriteLine(string.Join("\n", b));
        }
    }
}

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

public class Main {
    public static void main(String... args) {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        int N = 0;
        String S = "";
        int K = 0;
        try {
            N = Integer.parseInt(bufferedReader.readLine());
            S = bufferedReader.readLine();
            K = Integer.parseInt(bufferedReader.readLine());
        } catch (IOException e){
            e.printStackTrace();
            return;
        }

        char c = S.charAt(K-1);
        System.out.println(S.replaceAll("[^" + c + "]", "*"));
    }
}


Measured memory_bytes: 22356
import sys
input=sys.stdin.readline
import heapq
def dijkstra(s,graph,n):
    dist=[float("inf") for i in range(n+1)]
    dist[s]=0
    pq=[]
    heapq.heapify(pq)
    heapq.heappush(pq,(0,s))
    while pq:
        mini_dis,node=heapq.heappop(pq)
        if dist[node]<mini_dis: continue
        for w,point in graph[node]:
            if dist[point]<w:continue
            newlen=dist[node]+w
            if newlen<dist[point]:
                heapq.heappush(pq,(newlen,point))
                dist[point]=newlen
    return dist
N,M,S,T=map(int,input().split())
graph_yen=[[] for i in range(N+1)]
graph_snuke=[[] for i in range(N+1)]
for _ in range(M):
    u,v,a,b=map(int,input().split())
    graph_yen[u].append((a,v))
    graph_yen[v].append((a,u))
    graph_snuke[u].append((b,v))
    graph_snuke[v].append((b,u))
    
yen=dijkstra(S,graph_yen,N)
snuke=dijkstra(T,graph_snuke,N)
minimum_case=[10**15 for i in range(N+1)]
for i in range(N):
    minimum_case[1+i]-=(yen[i+1]+snuke[i+1])
for i in range(N-1,-1,-1):
    minimum_case[i]=max(minimum_case[i],minimum_case[i+1])
for i in range(1,N+1):
    print(minimum_case[i])


Measured memory_bytes: 122108
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] number = new int[n];
		int max = 0, min = 0;
		long sum = 0;
		for(int i = 0; i < n; i++){
			number[i] = scan.nextInt();
			if(i == 0){
				max = number[0];
				min = number[0];
			}
			if(max < number[i]){
				max = number[i];
			}
			if(min > number[i]){
				min = number[i];
			}
			sum+= number[i];
		}
		System.out.printf("%d %d %d\n", min, max, sum);
	}
}

Measured memory_bytes: 41120
// Born Sinner
// old but im not that old
// fuck all you hoes get a grip
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
        long nextLong(){
            return Long.parseLong(next());
        }
        double nextDouble(){
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            } catch (Exception e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static int modPower(int x, int y, int mod){
        int res = 1;
        x %= mod;
        if(x==0) return 0;
        while(y>0){
            if(y%2==1){
                res = (res*x)%mod;
            }
            y = y>>1;
            x = (x*x)%mod;
        }
        return res;
    }
    static class pair<T1, T2>{
        T1 first;
        T2 second;
        pair(T1 first, T2 second){
            this.first = first;
            this.second = second;
        }
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        FastReader in = new FastReader();
        int n = in.nextInt();
        double d = in.nextDouble();
        int ans = 0;
        for(int i = 0; i < n; i++){
            double x = in.nextDouble(), y = in.nextDouble();
            if((Math.sqrt((x*x)+(y*y))) <= d) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 56692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        int ans = 0;
        while (n > 0) {
            n /= k;
            ans++;
        }
        out.println(ans);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	double n; cin >> n;
	cout << (n / 2) * (1 + n) << "\n";

	return 0;
}

Measured memory_bytes: 256
# 2019/08/04
# AtCoder Beginner Contest 136 - B

# Input
n = int(input())

# Calc
ans = 0
for i in range(1, n+1):
    if i < 10 or (i > 99 and i < 1000) or (i > 9999 and i < 100000):
        ans = ans + 1

# Output
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans = 0;
    int n = S.length();
    rep(i, n / 2) {
        if(S[i] != S[n - i - 1]) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath> 
#define ll long long

ll MOD=1e9+7;
ll a[100005];
using namespace std;

int main(){
	ll n;
	cin>>n;
	
	ll flag=1;//flag 
	ll ans=1;
	
	if(n%2==0){ // even number 
	
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;//a[7]++
			
			// give data x error 
			if(x>=n || x%2==0 || a[x]>2){ 
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			
			//The correct situation 
			if(a[x]==1)
				ans=ans*2%MOD; // a * b %c == a%c * b%c 
		}
	} 
	
	else{ //odd 
	
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;
			
			// give data x error 
			if(x>=n || x%2==1 || a[0]>1 ||a[x]>2){
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			
			//The correct situation
			if(x!=0 && a[x]==1)
				ans=ans*2%MOD;
		}
	}
	
	if(flag)
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll r1;
    cin>>r1;
  ld r=r1;
    cout<<fixed<<setprecision(12)<<(2*3.14159265358979323846*r);



    return 0;
}


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

typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
  ll n, d;
  cin >> n >> d;

  vector<ll> x(n), y(n);
  rep(i, n) cin >> x.at(i) >> y.at(i);

  ll dd = d * d;
  int ans = 0;
  rep(i, n) {
    ll xx = x.at(i) * x.at(i);
    ll yy = y.at(i) * y.at(i);
    ll dis = xx + yy;
    if (dis <= dd) {
      ans++;
    }
  }

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

Measured memory_bytes: 6408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VI Z_algorithm(string s){
    int n = s.length();
    VI a(n);
    a[0] = n;
    for (int i = 1, j = 0; i < n;){
        while (i + j < n && s[j] == s[i + j]) j++;
        a[i] = j;
        if (j == 0){
            i++;
            continue;
        }
        int k = 1;
        while (i + k < n && k + a[k] < j) a[i + k] = a[k], k++;
        i += k;
        j -= k;
    }
    return a;
}

VI calc(string s){
    int n = s.length();
    VI ret(n, 1);
    VI z = Z_algorithm(s);
    FOR(x,1,n-1){
        int i = x;
        while (i < n){
            if (z[i] < x) break;
            i += x;
            ret[i - 1] = 0;
        }
    }
    return ret;
}

int main() {
    string s;
    cin >> s;
    int n = s.length();

    if (s == string(n, s[0])){
        cout << n << endl << 1 << endl;
        return 0;
    }

    VI z = Z_algorithm(s);

    bool found = false;
    FOR(i,1,n-1){
        if (n % i) continue;
        if (z[i] == n - i) found = true;
    }

    if (!found){
        cout << 1 << endl << 1 << endl;
        return 0;
    }

    VI c1 = calc(s);
    reverse(ALL(s));
    VI c2 = calc(s);
    reverse(ALL(c2));

    // REP(i,n) cout << c1[i];
    // cout << endl;
    // REP(i,n) cout << c2[i];
    // cout << endl;

    int ans = 0;
    REP(i,n-1){
        if (c1[i] && c2[i + 1]) ans++;
    }
    cout << 2 << endl << ans << endl;

    return 0;
}


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

# In[29]:


Sdash = input()
T = input()


# In[30]:


length_S = len(Sdash)
length_T = len(T)
if length_S >= length_T:
    for i in range(length_S-length_T+1):
        for j in range(length_T):
            if Sdash[j+length_S-length_T-i] != T[j] and Sdash[j+length_S-length_T-i] != "?":
                break
        else:
            ans = Sdash[:length_S-length_T-i]+T+Sdash[length_S-i:]
            ans = [x if x != "?" else "a" for x in ans]
            print("".join(ans))
            break
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")


# In[ ]:






Measured memory_bytes: 9076
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;

struct restaurant{
	int n;
	string name;
	int point;
};

bool mycompare(struct restaurant lhs,struct restaurant rhs){
	if( lhs.name == rhs.name){
		return lhs.point > rhs.point;
	}
	return lhs.name < rhs.name;
}

int main()
{
	vector<struct restaurant> ansList;
	int n;
	cin>>n;
	for(int i =0; i < n; i++){
		struct restaurant temp;
		cin>>temp.name>>temp.point;
		temp.n = i+1;
		ansList.push_back(temp);
	}
	sort(ansList.begin(),ansList.end(),mycompare);
	for(int i = 0; i < ansList.size(); i++){
		cout<<ansList[i].n<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
    vector<int>dp(51,0LL),dp2(51,0LL);
    int n,x; cin >> n >> x;
    rep(i,51){
        if(i == 0){
            dp[0] = dp2[0] = 1LL;
        } else {
            dp[i] = dp[i-1] + dp[i-1] + 3;
            dp2[i] = dp2[i-1] + dp2[i-1] + 1;
        }
    }
    function<int(int,int)>cal = [&](int i,int x) -> int{
        if(i == 0 or  x == 0) return x != 0;;
        return (x >= dp[i-1] + 2 ? dp2[i-1] + 1 + cal(i-1,x-dp[i-1]-2) : cal(i-1,x-1));
    };
    cout << cal(n,x) << endl;
}



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

int main()
{
    int c[3][3];
    for( int i = 0; i < 3; ++i )
        for( int j = 0; j < 3; ++j )
            cin >> c[i][j];


    int a[3] = { 0 }, b[3] = { 0 };
    for( int i = 0; i <= 100; ++i ){
        a[0] = i;
        b[0] = c[0][0] - a[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0];

        for( int j = 0; j <= 100; ++j ){
            a[1] = j;
            if( a[1]+b[0] == c[1][0] && a[1]+b[1] == c[1][1] && a[1]+b[2] == c[1][2] ) ;
            else continue;

            for( int k = 0; k <= 100; ++k ){
                a[2] = k;
                if( a[2]+b[0] == c[2][0] && a[2]+b[1] == c[2][1] && a[2]+b[2] == c[2][2] ){
                    cout << "Yes" << endl;

                    //cout << a[0] << " " << a[1] << " " << a[2] << endl;
                    //cout << b[0] << " " << b[1] << " " << b[2] << endl;
                    return 0;
                } else continue;
            }
        }
    }


    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
long long  N;
cin >> N;

//N=m*k+k=k*(m+1):k<mがお気に入りの整数の条件
/*long  answer=0;
for(long  m=2;m<N;m++){
    for(long  k=1;k<m;k++)
    if(N==k*(m+1))
    answer+=m;
}*/

vector<long long>d;



long long Q=sqrt(N);
if(N>2){
for(long long i=1;i<=Q;i++){
     if(N%i==0&& N/i>i+1){
        d.push_back(N/i);
    }

   
}

/*for(int  itr=0;itr<d.size();++itr){
cout << d[itr]<<endl;
}*/
long long  answer=0;
for(int  itr=0;itr<d.size();++itr){
    if(d[itr]>2)
    answer+=d[itr]-1;
}

cout <<answer<<endl;
}
else
{
    cout<<"0"<<endl;
}


  return 0;
}
//2499686339916


Measured memory_bytes: 256
//Dictionary
#include<iostream>
#include<string>
#include<cstdio>
#include<map>
using namespace std;

int main(void){
    map<string, bool> D;
    int n;
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
        char com[10];
        char word[13];
        scanf("%s %s", com, word);
        if(com[0] == 'i'){
            D[string(word)] = true;
        }else{
            if(D[string(word)] == true)  printf("yes\n");
            else printf("no\n");    
        }
    }
    return 0;
}

Measured memory_bytes: 45492
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

void inputVectorString(vector<string> * p, long long a){
    rep(i, a){
        string input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const long long MOD = 10*10*10*10*10*10*10*10*10+7;

int main(int argc, const char * argv[]) {
    const double PI=3.14159265358979323846;
    // source code
    long long N = inputValueLongLong();
    long long M = inputValueLongLong();
    ll H[N],A[M],B[M];
    ll hantei[N];
    ll counter = 0;
    for(ll i=0;i<N;i++){
        H[i] = inputValueLongLong();
        hantei[i] = 0;
    }
    for(ll i=0;i<M;i++){
        A[i] = inputValueLongLong()-1;
        B[i] = inputValueLongLong()-1;
        if(H[A[i]] > H[B[i]]){
            hantei[B[i]] = 1;
        }else if(H[A[i]] < H[B[i]]){
            hantei[A[i]] = 1;
        }else{
            hantei[A[i]] = 1;
            hantei[B[i]] = 1;
        }
    }

    for(ll i=0;i<N;i++){
        if(hantei[i]==0){
            counter++;
        }

    }


    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    cin >> S >> T;
    cout << (T.substr(0,S.size())==S? "Yes\n":"No\n");
}

Measured memory_bytes: 3652
#15:38
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
a = a[:k]
b = list(map(int,input().split()))
b.sort(reverse = True)
b = b[:k]
c = list(map(int,input().split()))
c.sort(reverse = True)
c = c[:k]
ab = []
for l in a:
  for m in b:
    ab.append(l+m)
ab.sort(reverse = True)
ab = ab[:k]
abc = []
for n in ab:
  for o in c:
    abc.append(n+o)
abc.sort(reverse = True)
abc = abc[:k]
for p in abc:
  print(p)

Measured memory_bytes: 152152
def solve():
    num_lines = int(raw_input())

    s = set()
    for i in xrange(num_lines):
        command, target = raw_input().split(" ")

        if command[0] == "i":# insert
            s.add(target)
            continue

        if target in s:
            print "yes"
        else:
            print "no"


if __name__ == "__main__":
    solve()

Measured memory_bytes: 27636
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

int main()
{
    using namespace std;
    
    int n, d;
    cin >> n >> d;
    auto x = vector<vector<int>>(n, vector<int>(d,0));
    
    for(int i=0; i<n; i++)
        for(int j=0; j<d; j++)
            cin >> x[i][j];
    
    int c=0;

    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            long int sum = 0;
            for(int k=0; k<d; k++){
                int t = x[j][k] - x[i][k];
                sum += t*t;
            }
            double dist = sqrt(sum);
            if(ceil(dist) == floor(dist)){
               c++;
            }
        }
    }
    cout << c << endl;

    return 0;
}


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

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

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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 998244353LL;

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

double L(int x,int y){
  return sqrt(x*x+y*y);
}

int main() {
  int N;
  cin>>N;
  vector<int> X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];
  vector<int> v(N);
  rep(i,N) v[i] = i;
  double ans = 0;
  do{
    rep(i,N-1){
      ans += L(X[v[i+1]]-X[v[i]],Y[v[i+1]]-Y[v[i]]);
    }
  }while(next_permutation(v.begin(),v.end()));
  ll p = 1;
  rep(i,N) p *= i+1;
  ans = ans / p;
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
}

Measured memory_bytes: 3860
N = int(input())
H = list(map(int, input().split()))
MAX = 10**9
dp = [MAX]*N
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
    dp1 = dp[i-1]+abs(H[i]-H[i-1])
    dp2 = dp[i-2]+abs(H[i]-H[i-2])
    dp[i] = min(dp1, dp2)
print(dp[-1])

Measured memory_bytes: 13924
#include<stdio.h>
int main(){
  long long int t,a,b,ans;
  scanf("%lld %lld",&a,&b);
  if(a > b){
    t = a;
    a = b;
    b = t;
  }
  if(a == 1){
    if(b == 1){
      ans = 1;
    }else{
      ans = b - 2;
    }
  }else{
    ans = (a - 2) * (b - 2);
  }
  printf("%lld\n",ans);
  return 0;
}

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

using namespace std;

int a[5][5];
bool bingo[5][5];

int main() {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }
  int n;
  cin >> n;
  while (n--) {
    int b;
    cin >> b;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (a[i][j] == b) {
          bingo[i][j] = true;
        }
      }
    }
  }

  bool ans = false;
  for (int i = 0; i < 3; i++) {
    bool ok = true;
    for (int j = 0; j < 3; j++) {
      if (!bingo[i][j]) {
        ok = false;
      }
    }
    ans |= ok;
  }
  for (int i = 0; i < 3; i++) {
    bool ok = true;
    for (int j = 0; j < 3; j++) {
      if (!bingo[j][i]) {
        ok = false;
      }
    }
    ans |= ok;
  }
  ans |= bingo[0][0] && bingo[1][1] && bingo[2][2];
  ans |= bingo[0][2] && bingo[1][1] && bingo[2][0];

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

  return 0;
}

Measured memory_bytes: 256
/*input
10 10
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s, w; cin >> s >> w;
    cout << (w >= s ? "unsafe" : "safe");

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define INF 1LL<<55
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll x[200005];
ll sum[200005];
ll X;


int main(void){
	scanf("%d%lld",&n,&X);
	for(int i=0;i<n;i++){
		scanf("%lld",&x[i]);
		sum[i+1]+=sum[i];
		sum[i+1]+=x[i];
	}
	ll ans=INF;
	for(int i=1;i<=n;i++){
		ll val=0;
		int rest=i*2;
		int j=n;
		ll c=5;
		while(j>0){
			int tgt=j-rest;
			if(tgt<0)tgt=0;
			val+=(sum[j]-sum[tgt])*c;
			if(val+(ll)i*X>=ans)break;
			rest=0;
			if(rest==0){
				rest=i;
				c+=2;
			}
			j=tgt;
		}
		ans=min(ans,val+(ll)i*X);
	}
	printf("%lld\n",ans+(ll)n*X);
	return 0;
} 

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  ll Q;
  cin >> Q;
  vector<ll> l(Q);
  vector<ll> r(Q);
  for (ll i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
  }

  ll MAX = 100001;
  vector<bool> isprime(MAX, true);
  isprime[0] = false;
  isprime[1] = false;
  for (ll i = 2; i <= MAX; i++) {
    if (!isprime[i]) continue;

    for (ll j = i * 2; j <= MAX; j += i) {
      isprime[j] = false;
    }
  }

  vector<ll> a(MAX, 0);
  for (ll i = 0; i < MAX; i++) {
    if (isprime[i] && isprime[(i + 1) / 2]) {
      a[i] = 1;
    }
  }

  // [0, i)
  // a[0] ~ a[i] までの総和
  vector<ll> sum(MAX + 1, 0);
  sum[0] = 0;
  for (ll i = 0; i < MAX; i++) {
    sum[i + 1] = sum[i] + a[i];
  }

  for (ll i = 0; i < Q; i++) {
    cout << sum[r[i] + 1] - sum[l[i]] << endl;
  }

  return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for(int i=0; i<(int)(n); i++)
#define forne(i, a, b) for(int i=a; i<=(int)(b); i++)

#define gottagofast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
using namespace std;

#define MAX (int)(2e5)

int tabela[MAX];
vi v;

int dp(int idx) {
  if(idx == 0)
    return 0;

  if(tabela[idx] != -1)
    return tabela[idx];

  int v2 = MAX;
  int v1 = abs(v[idx] - v[idx-1]) + dp(idx-1);
  if(idx-2 >= 0)
    v2 = abs(v[idx] - v[idx-2]) + dp(idx-2);

  return tabela[idx] = min(v1, v2);
}

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

  memset(tabela, -1, sizeof(tabela));

  v.assign(n, 0);
  forn(i, n)
    cin >> v[i];

  cout << dp(n-1) << endl;

  return 0;
}


Measured memory_bytes: 6144
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N, T;
  cin >> N >> T;
  int ans = INF;
  for(int i=0; i<N; i++){
    int c, t;
    cin >> c >> t;
    if(t <= T){
      ans = min(ans, c);
    }
  }
  if(ans == INF){
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }

}

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

using namespace std;

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

	int a,b,c,k;
	cin >> a >> b >> c >> k;
	while(a >= b){
		k--;
		b <<= 1;
	}
	while(b >= c){
		k--;
		c <<= 1;
	}
	cout << (k < 0 ? "No\n" : "Yes\n");

	return 0;
}

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



void solve(long long N, long long L, std::vector<std::string> S){

    sort(S.begin(),S.end());
    for(auto elm : S){
        cout << elm;
    }
    cout << endl;

}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, L, std::move(S));
    return 0;
}


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

using namespace std;

int bitCount(int t){
    int res = 0;
    for(int i=t;i;i&=i-1) ++res;
    return res;
}

template<typename T>
class SegTree {
public:
    explicit SegTree(int n, T def) : N(calcN_(n)), def(def), mVal(2*calcN_(n)-1, def) {}
    void update(int idx, T value){
        int i = N + idx - 1;
        update_(mVal[i], value);
        while(i > 0){
            i = (i-1)/2;
            mVal[i] = operate(mVal[2*i+1], mVal[2*i+2]);
        }
    }
    T get(int l, int r){
        return getImpl_(l, r, 0, 0, N);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    T getImpl_(int l, int r, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return def;
        if(l <= rangeL && rangeR <= r) return mVal[idx];
        int rangeM = (rangeL+rangeR)/2;
        T a = getImpl_(l, r, 2*idx+1, rangeL, rangeM);
        T b = getImpl_(l, r, 2*idx+2, rangeM, rangeR);
        return operate(a, b);
    }
    void update_(T& data, T val) { data = val; }
    T operate(T a, T b) { return a|b; }
    const int N;
    const T def;
    vector<T> mVal; 
};

int main(){
    int N;
    while(cin >> N){
        string S; cin >> S;
        SegTree<unsigned int> seg(N, 0);
        for(int i=0;i<N;i++) seg.update(i, 1UL << (S[i]-'a'));
        int Q; cin >> Q;
        for(int i=0;i<Q;i++){
            int q; cin >> q;
            if(q == 1){
                int p; char c;
                cin >> p >> c;
                seg.update(p-1, (1UL << (c-'a')));
            } else {
                int l, r;
                cin >> l >> r;
                cout << bitCount(seg.get(l-1, r)) << endl;
            }
        }
    }
}


Measured memory_bytes: 4996