akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main() {
	int h, w; cin >> h >> w;
	int cnt = 0;
	Loop(i, h) {
		Loop(j, w) {
			char c; cin >> c;
			if (c == '#') cnt++;
		}
	}
	if (cnt == h + w - 1) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();

        Queue<Long> queue = new PriorityQueue<>();
        for (int i = 1; i < 11; i++) {
            List<Integer> list = new ArrayList<>();
            dfs(i, list, queue);
        }
        for (int i = 0; i < k - 1; i++) {
            queue.poll();
        }
        System.out.println(queue.poll());
    }

    static void dfs(int l, List<Integer> list, Queue<Long> queue) {
        if (list.size() == l) {
            queue.add(convertListToNumber(list));
            return;
        }
        for (int i = 0; i < 10; i++) {
            if (i == 0 && list.size() == 0) {
            } else {
                list.add(i);
                if (isLunLun(list)) {
                    dfs(l, list, queue);
                }
                list.remove(list.size() - 1);
            }
        }
    }

    static boolean isLunLun(List<Integer> list) {
        if (list.size() == 1) {
            return true;
        }
        for (int i = 0; i < list.size() - 1; i++) {
            if (Math.abs(list.get(i) - list.get(i + 1)) > 1) {
                return false;
            }
        }
        return true;
    }

    static long convertListToNumber(List<Integer> list) {
        long num = 0;
        for (int i = 0; i < list.size(); i++) {
            num += list.get(i) * Math.pow(10, list.size() - 1 - i);
        }
        return num;
    }

}

Measured memory_bytes: 47864
#include <stdio.h>

int main() {
	int A, B;
	scanf("%d %d", &A,&B);
	
	if (A == 1 && B == 2){
		printf("3\n");
	}else if (A == 1 && B == 3){
		printf("2\n");
	}else if (A == 2 && B == 1){
		printf("3\n");
	}else if (A == 2 && B == 3){
		printf("1\n");
	}else if (A == 3 && B == 1){
		printf("2\n");
	}else if (A == 3 && B == 2){
		printf("1\n");
	}
	
	return 0;
}

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

int main () {
	int N;
  	cin >> N;
  	vector<string> shi(N);
  	vector<int> tensu(N);
  	map<string, int> kazu;
  	
  	for (int i = 0; i < N; i++) {
      string s;
      int p;
      cin >> s >> p;
      shi[i] = s;
      tensu[i] = p;
      kazu[s] += 1;
    }
    for (auto item : kazu) {
      auto key = item.first;
      auto value = item.second;
      map<int, int> ids;
      priority_queue<int> queue;
      for (int i = 0; i < N; i++) {
      	if (shi[i] == key) {
          	int t = tensu[i];
        	ids[t] = i;
          	queue.push(t);
        }
      }
      while (queue.size() > 0) {
      	int top = queue.top();
        queue.pop();
        cout << ids[top] + 1 << endl;
      }
    }
}

Measured memory_bytes: 3524
#include <iostream>

using namespace std;

int main(){
	int house[4][3][10] = {};
	int n, b, r, f, v;
	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> b >> r >> f >> v;
		house[b-1][r-1][f-1] += v;
	}

	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				if(i != 0 && j == 0 && k == 0){
					for(int l = 0; l < 20; l++) cout << "#";
					cout << endl;
				}
				cout << " " << house[i][j][k];
			}
			cout << endl;
		}
	}

	return 0;
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	std::string S;
	std::cin >> S;

	cout << (S == "ABC" ? "ARC" : "ABC") << endl;

	return 0;
}


Measured memory_bytes: 3644
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
count = 0
for d1, d2 in D:
    if d1 == d2:
        count += 1
        if count >= 3:
            print('Yes')
            quit()
    else:
        count = 0

print('No')

Measured memory_bytes: 9184
n=int(input())
a=list(map(int,input().split()))
import collections
data=collections.Counter(a)
ans_2=[]
ans_4=[]
for i,j in data.items():
    if 4<=j:
        ans_4.append(i)
    if 2<=j<=3:
        ans_2.append(i)
ans_2.sort()
ans_2.reverse()
ans_4.sort()
ans_4.reverse()
max_4=max_2=mix_24=0
if len(ans_4)!=0:
    max_4=ans_4[0]*ans_4[0]
if 2<=len(ans_2):
    max_2=ans_2[0]*ans_2[1]
if len(ans_4)!=0 and len(ans_2)!=0:
    mix_24=ans_2[0]*ans_4[0]
print(max(max_2,max_4,mix_24))
    
    


Measured memory_bytes: 18444
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  200005

ll n,k,x;
vi v;
bool check(ll x)
{
    ll it=upper_bound(all(v),x)-v.begin();
    ll ans=0;
    rep(i,it,n)
    {
        ans+=(v[i])/x;
    }
    return (ans<=k);
}
void solve()
{
    cin>>n>>k;
    rep(i,0,n)
    {
        cin>>x;
        v.pb(x);
    }
    sort(all(v));
    ll l=1,r=hell,m;
    ll ans=hell;
    while(l<=r)
    {
        m=(l+r)>>1;
        if(check(m))
        {
            ans=min(ans,m);
            r=m-1;
        }
        else
        {
            l=m+1;
        }
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5272
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: i64,
        B: i64,
    }
    let mut ans = "Draw";
    let A = (A+11)%13;
    let B = (B+11)%13;
    if A>B{
        ans = "Alice";
    }else if A<B{
        ans = "Bob";
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	vector<int>flag(100100, 0);
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (a <= 100000) {
			flag[a]++;
		}
	}
	int ans = 0;
	int count = 0;
	for (int i = 1; i <= 100000; ++i) {
		if (flag[i] < i) {
			ans += flag[i];
		}
		else {
			ans += (flag[i] - i);
		}
		count += flag[i];
		if (count == N) {
			break;
		}
	}
	cout << ans + (N - count) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int X;
    cin >> X;
    vector<bool> po(1000);
    po[1] = 1;
    for(int i=2; i<=31; ++i){
        int n=i;
        while(n<1000){
            n*=i;
            po[n] = 1;
        }
    }
    for(int i=X; i>0; --i){
        if(po[i]){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int factorial(int n);
int factorial(int n)
{
    if(n==1)
    {
        return 1;
    }
    else
    {
        return n*factorial(n-1);
    }

}

bool is_prime(ll n) {
    // Assumes that n is a positive natural number
    // We know 1 is not a prime number
    if (n == 1) {
        return false;
    }

    ll i = 2;
    // This will loop from 2 to int(sqrt(x))
    while (i*i <= n) {
        // Check if i divides x without leaving a remainder
        if (n % i == 0) {
            // This means that n has a factor in between 2 and sqrt(n)
            // So it is not a prime number
            return false;
        }
        i += 1;
    }
    // If we did not find any factor in the above loop,
    // then n is a prime number
    return true;
}
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
typedef unsigned long long  ull;

int check(int x,vector <int> a,int n)
{  int county=0;
  map <int,int> mapa;
    for(int i=0;i<n;i++)
    {
        mapa.insert(pair<int,int>(a[i],0));
    }
    for(int i=0;i<n;i++)
    {
        mapa[a[i]]++;
    }
   // cout<<mapa[1]<<mapa[2]<<mapa[3]<<mapa[4]<<mapa[5]<<endl;
    for(int i=0;i<a.size();i++)
    {   mapa[a[i]]--;
        if(mapa[abs(a[i]-x)]>0)
        {
            county++;


            mapa[abs(a[i]-x)]--;
        }


    }
    return county;
}



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

long long  x,k,d;
cin>>x>>k>>d;
long long cha=x;
if(cha>0)
{ ll z;
    if(x/d<=k)
    {
        ll u=x/d;
         z=k-(x/d);
        x=x-u*d;

    }
    else
    {  z=0;
        x=x-k*d;
    }


  /*while(z>0)
  {
      if(county%2==0)
      {
          x=x-d;
          county++;
      }
      else
      {
          x=x+d;
          county++;
      }


      z--;
  }*/
  if(z>0)
  {
    if(z%2!=0)
    {
        x=x-d;
    }
  }

}
else if(cha==0)
{
   if(k%2!=0)
    {
        x=x-d;
    }


}
else if(cha<0)
{  ll z;
    if(abs(x)/d<=k)
    {
        ll u=abs(x)/d;
        z=k-(abs(x)/d);
        x=x+u*d;
    }
    else
    {
        x=x+k*d;
        z=0;
    }
ll county=0;

 /* while(z>0)
  {
      if(county%2==0)
      {
          x=x+d;
          county++;
      }
      else
      {
          x=x-d;
          county++;
      }


      z--;
  }*/
  if(z>0)
  {
        if(z%2!=0)
    {
        x=x+d;
    }
  }



}
cout<<abs(x)<<endl;
}


Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new ABC110().doIt();
	}
	class ABC110{
		void doIt(){
			String str1 = sc.next();
			String str2 = sc.next();
			System.out.println(check(str1,str2));
		}
		String check(String str1,String str2) {
			char ctr1[] = str1.toCharArray();
			char ctr2[] = str2.toCharArray();
			int length = str1.length();
			int alf[] = new int[128];
			int alf2[] = new int[128];
			int cnt1 = 1;
			int cnt2 = 1;
			for(int i = 0;i < length;i++) {
				if(alf[ctr1[i]] == 0) {
					alf[ctr1[i]] = cnt1;
					ctr1[i] = (char)cnt1;
					cnt1++;
				}else ctr1[i] = (char)alf[ctr1[i]];
				
				if(alf2[ctr2[i]] == 0) {
					alf2[ctr2[i]] = cnt2;
					ctr2[i] = (char)cnt2;
					cnt2++;
				}else ctr2[i] = (char)alf2[ctr2[i]];
				if(ctr1[i] != ctr2[i])return "No";
			}
			return "Yes";
		}
	}
}


Measured memory_bytes: 30272
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    float arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    if(n==1)
        cout<<arr[0]<<endl;
    else
    {
    sort(arr,arr+n);
    float sum=(arr[0]+arr[1])/2;
    for(int i=2;i<n;i++)
    {
        sum= (sum+arr[i])/2;
    }
    cout<<sum<<endl;
    }
}



Measured memory_bytes: 256
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int 	N = sc.nextInt(),
				M = sc.nextInt(),
				count[] = new int[N],
				ans1 = 0,
				ans2 = 0;
		
		boolean f[] = new boolean[N];
		Arrays.fill(f, true);
		
		for (int i = 0; i < M; i++) {
			int QN = sc.nextInt()-1;
			String result = sc.next();
			if (f[QN]) {
				if (result.equals("WA")) {
					count[QN]++;
				} 
				if (result.equals("AC")) {
					ans1 += count[QN];
					ans2++;
					f[QN] = false;
				}
			}
		}
		System.out.println(ans2 + " " + ans1);
	}
}

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

int main(){
  int N,A,count,x=10000000;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A;
    count=0;
    while(A%2==0){
      A/=2;
      count++;
    }
    if(count<x)
      x=count;
  }
  cout<<x<<endl;
}
  

Measured memory_bytes: 256
import heapq
X, Y, Z, K = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

h1 = []
for a in A:
  for b in B:
    heapq.heappush(h1, -a - b)

h2 = []
for _ in range(min(K, X * Y)):
  ab = -heapq.heappop(h1)
  for c in C:
    heapq.heappush(h2, -ab - c)

for _ in range(K):
  print -heapq.heappop(h2)

Measured memory_bytes: 152164
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

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

    vector<ll>a(n, 0);
    REP(i, n) cin >> a[i];

    sort(ALL(a));

    int maxct = 0;
    int end = 0;
    int ct = 0;

    REP(start, n){
        while (end < a.size() && a[end] < a[start]+3){
            end++;
            ct++;
        }
        if (ct > maxct) maxct = ct;
        if (end == a.size()-1) break;
        ct--;
    }
    cout << maxct << endl;

}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    static int[] m;

    static void swapWithRight(int i) {
        int s = m[i + 1];
        m[i + 1] = m[i];
        m[i] = s;
    }

    static void swapWithLeft(int i) {
        int s = m[i - 1];
        m[i - 1] = m[i];
        m[i] = s;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        m = new int[n];
        for (int i = 0; i < n; ++i) m[i] = in.nextInt();
        int res = 0;
        for (int i = 0; i < n; ++i) {
            if (i == 0 && m[i] == i + 1) {
                swapWithRight(i);
                ++res;
            } else if (i == n - 1 && m[i] == i + 1) {
                swapWithLeft(i);
                ++res;
            } else if (m[i] == i + 1) {
                if (m[i + 1] == i + 2) {
                    swapWithRight(i);
                } else if (m[i - 1] > m[i]) {
                    swapWithRight(i);
                } else {
                    swapWithLeft(i);
                }
                ++res;
            }
        }
        System.out.println(res);
    }
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	string S; cin >> S;
	vector<int> A(N+1,0);
	repp(i,0,N){
		A[i+1] = A[i];
		if(S[i]=='#') ++A[i+1];
	}
	int ans = N;
	repp(i,0,N+1){
		ans = min(ans,A[i]+N-i-A[N]+A[i]);
	}
	cout << ans << endl;
	return 0;
}


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

using ll=long long;
vector<ll> l(0,0),p(0,0);

ll cal(ll x, ll n) {
    if(n == 0)
        return (x>0 ? 1 : 0);
    else if(x <= 1+l.at(n-1))
        return cal(x-1, n-1);
    else
        return p.at(n-1) + 1 + cal(x-2-l.at(n-1), n-1);
}

int main() {
    ll N,i,X;
    cin >> N >> X;

    l.resize(N+1);
    p.resize(N+1);
    l.at(0)=1, p.at(0)=1;
    
    for(i=1; i<N+1; i++) {
        l.at(i) = l.at(i-1)*2 + 3;
        p.at(i) = p.at(i-1)*2 + 1;
    }

    cout << cal(X,N) << endl;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cerr << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;
#define DBG(x) cerr << x << endl;

/*
	http://abc069.contest.atcoder.jp/tasks/arc080_b
*/
int h, w, n;
VI color;


void solve()
{
	VVI ans(h, VI(w));

	int delta = 0, cnt = color[1];
	for(int i = 0, j = 0, col = 1; i < h && col <= n; i += (j == w || j < 0))
	{	
		if(j == w)
		   j = w - 1, delta = 1;
		else if(j < 0)
		   j = 0, delta = 0;

		if(delta == 0)
		{
			for(; j < w && cnt > 0; ++j, --cnt)
				ans[i][j] = col;
		}
		else
		{
			for(; j >= 0 && cnt > 0; --j, --cnt)
				ans[i][j] = col;
		}

		
		if(cnt == 0) {
			++col;
			cnt = color[col];
		}
	}
	
	for(auto v : ans) {
		for(auto i : v)
			cout << i << " ";
		cout << endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> h >> w >> n;

	color.resize(n + 1);
	REPC(i, 1, n) cin >> color[i];

	solve();
	
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int n;
V<double>p,q;
double e[510][510],w[510][510];int root[510][510];

void Optimal_BST(){
    for(int i=1;i<=n+1;i++){
        e[i][i-1]=q[i-1];
        w[i][i-1]=q[i-1];
    }
    for(int l=1;l<=n;l++){
        for(int i=1;i<=n-l+1;i++){
            int j=i+l-1;
            e[i][j]=INF;
            w[i][j]=w[i][j-1]+p[j]+q[j];
            for(int r=i;r<=j;r++){
                double t=e[i][r-1]+e[r+1][j]+w[i][j];
                if(t<e[i][j]){
                    e[i][j]=t;
                    root[i][j]=r;
                }
            }
        }
    }
}
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    cin>>n;
    p.resize(n+1);q.resize(n+1);
    for(int i=1;i<=n;i++)cin>>p[i];
    for(int i=0;i<=n;i++)cin>>q[i];
    Optimal_BST();
    printf("%.12lf\n",e[1][n]);
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------















































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

int n, r[101]; char c[3];

int main()
{
	while (true)
	{
		scanf("%d", &n);

		if (n == 0) break;

		memset(r, 0, sizeof(r));

		for (int i = 0; i < n; i++)
		{
			scanf("%s", &c);

			switch (c[1])
			{
				case 'u': r[i + 1] = r[i] + 1; break;
				case 'd': r[i + 1] = r[i] - 1; break;
			}
		}

		int ret = 0;

		for (int i = 2; i <= n; i++)
		{
			if (r[i - 2] == 0 && r[i] == 2) ret++;
			if (r[i - 2] == 2 && r[i] == 0) ret++;
		}

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

	return 0;
}

Measured memory_bytes: 2668
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int d = sc.nextInt();
        int n = sc.nextInt();

        int ans = 0;

        for (int i = 0; i < n; i++) {
            ans += Math.pow(100, d);
            if (ans % Math.pow(100, d+1) == 0) {
                ans += Math.pow(100, d);
            }
            //System.out.println(ans);
        }
        //System.out.println("----");
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <math.h>

using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)
#define ll long long

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void Main() {
    int r, D, x2000; cin >> r >> D >> x2000;

    int x = x2000;
    rep(i, 10) {
        x = std::max(r*x - D, 0);
        cout << x << endl;
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    return 0;
}


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


int powL(int a,int b,int m){
    
    int res = 1;
    
    for(int i = 0; i < b; i++){
        res *= a;
        res = res % m;
    }
    
    return res;
}

int main(void){
    // Here your code !
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    
    for(int i= 0; i < n; i++) cin >> a[i];
    
    b = a;
    
    sort(b.begin(),b.end());
    
    const int mod = pow(10,9) + 7;
    
    bool f = true;
    
    if(n%2){
        
        for(int i = 0; i < n; i++){
            if(((i+1) / 2) * 2 != b[i] ) f = false;
        }
        
        if(f)
        cout << powL(2,n/2,mod) << endl;
        else
        cout << 0 << endl;
    }else{
        
        for(int i = 0; i < n; i++){
            if((i / 2) * 2 + 1 != b[i] ) f = false;
        }
        
        if(f)
        cout << powL(2,n/2,mod) << endl;
        else
        cout << 0 << endl;
    }
    
    
    
}


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

using namespace std;

typedef long long LL;

#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;
typedef vector<V> VV;

int f(int k,int s){
    if(k+k<s)return 0;
    int ed=min(k-(s-k),k)+1;//X is K
    int bg=max(k-s,0)+1;//X is 0
    int res=(bg+ed)*(ed-bg+1)/2+max(0,(k+1)*(k-s));
    return res;
}
int main(){
    int K,S;
    cin>>K>>S;
    cout<<f(K,max(S-K,0))-f(K,S+1)<<endl;
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    int ans = 0;
    for (int i = 1; i < n - 1; ++i) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[] for _ in range(n)]

for i in range(n):
  a[i] = list(map(int, input().split()))
  
b = [0 for _ in range(m)]
for i in range(m):
  b[i] = int(input())
  
for i in range(n):
    d = 0
    
    for j in range(m):
      d += a[i][j]*b[j]
        
    print(d)


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

main() {
  ll N, K; cin >> N >> K;
  vector<P> ab(N); for (int i = 0; i < N; i++) cin >> ab[i].first >> ab[i].second;
  sort(begin(ab), end(ab));

  ll ans = -1, sum = 0;
  for (int i = 0; i < N; i++) if (sum < K) sum += ab[++ans].second;
  cout << ab[ans].first << endl;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

x=I()
if x<1200:
    print("ABC")
else:
    print("ARC")

Measured memory_bytes: 3316
from collections import Counter
import sys
input = sys.stdin.buffer.readline

def main():
    n = int(input())
    m = float(n)
    a = Counter(map(int, input().split()))
    dp = [[[.0] * (n+1) for _ in range(n+1)] for _ in range(n+1)]
    for k in range(a[3]+1):
        for j in range(a[2]+a[3]-k+1):
            for i in range(n-j-k+1):
                if i + j + k == 0:
                    continue
                tmp = m
                if i > 0:
                    tmp += i * dp[i-1][j][k]
                if j > 0:
                    tmp += j * dp[i+1][j-1][k]
                if k > 0:
                    tmp += k * dp[i][j+1][k-1]
                dp[i][j][k] = tmp / (i+j+k)
    print(dp[a[1]][a[2]][a[3]])

if __name__ == '__main__':
    main()


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

int main(){
  int a,b;
  cin>>a>>b;
  if(a>0){
    cout<<"Positive"<<endl;
  }else if(a==0||b==0){
    cout<<"Zero"<<endl;
  }else if(a<0&&b>0){
    cout<<"Zero"<<endl;
  }else{
    if((b-a)%2==1){
      cout<<"Positive"<<endl;
    }else{
      cout<<"Negative"<<endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	string s;
	cin >> s;
	int i=0;
	if(s[0]=='0'&&s[1]!='0' || s[0]=='1'&&s[1]>='0'&&s[1]<='2')
		i|=1;
	if(s[2]=='0'&&s[3]!='0' || s[2]=='1'&&s[3]>='0'&&s[3]<='2')
		i|=1<<1;
	if(i==0)
		cout << "NA" << endl;
	else if(i==1)
		cout << "MMYY" << endl;
	else if(i==2)
		cout << "YYMM" << endl;
	else
		cout << "AMBIGUOUS" << endl;
	return 0;
}

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

int main(void)
{

  int c[9];

  for (int i = 0; i < 9; i++) {
    scanf("%d", &c[i]);
  }

  int min = 1000;
  for (int i = 0; i < 3; i++) {
    if (min > c[i]) {
      min = c[i];
    }
    
  }

  int b[3];

  for (int i = 0; i < 3; i++) {
    b[i] = c[i] - min;
  }

  int min2=1000;
  int min3=1000;

  for (int i = 0; i < 3; i++) {
    if (min2 > c[3+i]) {
      min2 = c[i+3];
    }
    if (min3 > c[6+i]) {
      min3 = c[i+6];
    }
  }
  for (int i = 0; i < 3; i++) {
  }

  bool flag = true;

  for (int i = 0; i < 3; i++) {
    if (c[3+i] - min2 != b[i] ) {
       flag = false;
    }
    if (c[6+i] - min3 != b[i] ) {
       flag = false;
    }

  }
  

  if (flag == true) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
n = int(input())
dic = {}
ans = 0
for i in range(n):
	tmp = list(input())
	sorted_str = "".join(sorted(tmp))
	if not(sorted_str in dic):
		dic[sorted_str] = 0
	else:
		dic[sorted_str] += 1
		ans += dic[sorted_str]

print(ans)


Measured memory_bytes: 17808
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {
  ll N, M; cin >> N >> M;
  vvi V(100001);
  for (ll i = 0; i < N; i++) {
    ll a, b; cin >> a >> b;
    V[a].push_back(b);
  }

  ll ans = 0;

  priority_queue<ll> pq;
  for (ll i = M - 1; i >= 0; i--) {
    for (auto j: V[M - i]) {
      pq.push(j);
    }
    if (pq.size()) {
      ans += pq.top();
      pq.pop();
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 5632
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<pair<int,int>> A(N);
    for(int i = 0; i < N; i++) cin >> A[i].fi >> A[i].se;
    sort(all(A));
    ll sum = 0;
    for(int i = 0; i < N; i++){
        sum += A[i].se;
        if(K <= sum){
            cout << A[i].fi << endl;
            return 0;
        }
    }
}

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


from math import sqrt

def divisor(num):
    max_num = int(sqrt(num))
    divisor_list = []
    for i in range(1, max_num + 1):
        if num % i == 0:
            divisor_list.append(i)
            divisor_list.append(num//i)
    sorted_divisor_list = sorted(divisor_list)
    return sorted_divisor_list

def main():
    l = divisor(n)
    n_i = l[len(l)//2 - 1]
    n_j = l[len(l)//2]
    dist = n_i - 1 + n_j - 1
    print(dist)

main()

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

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

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

    string s;
    cin >> s;

    int l = 0, cnt = 0, ans = 0;
    for (int r = 0; r < n; r++){
        
        if (s[r] == '0'){
            if (cnt == k){
                cnt -= 1;
                while(s[l] == '1')
                    l += 1;
                while(s[l] == '0')
                    l += 1;
            }
            cnt += 1;
            while(r < n && s[r] == '0')
                r += 1;
            r -= 1;
        }
        
        ans = max(ans, r - l + 1);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<vector>

using namespace std;

int main(){
    int nums;
    cin >> nums;
    unsigned long long res;
    unsigned long long B = 1000000000000000000;
    
    vector<unsigned long long> v;
    for(int i = 0; i < nums; ++i){
        unsigned long long in;
        cin >> in;
        v.push_back(in);
        if(in == 0){
            cout << 0 << endl;
            return 0;
        }
        if(in > B){
            cout << -1 << endl;
            return 0;
        }
    }
    res = v[0];
    
    for(int i = 1; i < nums; ++i){
        unsigned long long tmp, t;
        // cin >> tmp;
        t = res;
        tmp = v[i];
        res *= tmp;

        // if(res == 0) break;
        // cout << res  << " " <<  t << " " << tmp << endl;
        if(res > B || res < t || res < tmp) {
            cout << -1 << endl;
            return 0;
        }
    }
    printf("%llu\n", res);
}

Measured memory_bytes: 4316
n,a=map(int,input().split())
*x,=map(int,input().split())
dp=[[[None]*(n*50+1) for i in range(n+1)] for _ in range(n+1)]

for i in range(n+1):
    for j in range(n+1):
        for k in range(n*50+1):
            if i==0 and j==0 and k==0:
                dp[i][j][k]=1
            elif i and k<x[i-1]:
                dp[i][j][k]=dp[i-1][j][k]
            elif i and j and k>=x[i-1]:
                dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]]
            else:
                dp[i][j][k]=0

print(sum(dp[n][i][i*a] for i in range(1,n+1)))

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


class UnionFindNode(object):
    """
    Union-Find構造
    ノードのグループ併合や、所属グループ判定を高速に処理する
    """

    def __init__(self, group_id, parent=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.size_ = 1
        self.rank_ = 1

    def __str__(self):
        template = "UnionFindNode(group_id: {}, \n\tparent: {}, size: {}, rank: {})"
        return template.format(self.group_id_, self.parent_, self.size_,
                               self.rank_)

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        root = self.root()
        return root.group_id_

    def rank(self):
        root = self.root()
        return root.rank_

    def get_size(self):
        root = self.root()
        return root.size_

    def unite(self, unite_node):
        root = self.root()
        unite_root = unite_node.root()

        if root.group_id_ != unite_root.group_id_:
            if root.rank() > unite_root.rank():
                unite_root.parent_ = root
                root.rank_ = max(root.rank_, unite_root.rank_ + 1)
                root.size_ += unite_root.size_

            else:
                root.parent_ = unite_root
                unite_root.rank_ = max(root.rank_ + 1, unite_root.rank_)
                unite_root.size_ += root.size_


N, M = map(int, input().split())

node_array = [UnionFindNode(i) for i in range(N)]

for i in range(M):
    x, y, z = map(int, input().split())
    node_array[(x - 1)].unite(node_array[(y - 1)])

parent = set()

for node in node_array:
    parent.add(node.find())

print(len(parent))


Measured memory_bytes: 64160
import math
N = int(input())
T,A = map(int,input().split())
ans = 0
a = ''
c = 0
for i in input().split():
    c += 1
    x = T - int(i) * 0.006
    b = abs(A-x)
    if a == '' or a > b:
        ans = c
        a = b
print(ans)

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

int main(void){
  int fld[110][110], xlen[110][110], ylen[110][110];
  int w, h, d, t, ans;
  
  cin >> h >> w >> d;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      char c; cin >> c;
      fld[j][i] = (c=='#'?1:0);
    }
  }
  ans = 0;
  for (int i=0; i<h; i++){
    t = 0;
    for (int j=0; j<w; j++){
      if (fld[j][i]) t = 0;
      else t++;
      xlen[j][i] = t;
      if (xlen[j][i]>=d) ans++;
    }
  }
  for (int i=0; i<w; i++){
    t = 0;
    for (int j=0; j<h; j++){
      if (fld[i][j]) t = 0;
      else t++;
      ylen[i][j] = t;
      if (ylen[i][j]>=d) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3140
# -*-coding: utf-8 -*-

import sys

def main():
    input = sys.stdin.readline
    n, k = map(int, input().split())
    S = [tuple(map(int, input().split())) for _ in range(n)]
    S.sort(key=lambda x: -x[1])
    y_1, y_0 = [0], [0]
    st = set()

    for t, d in S:
        if t in st:
            #累積報酬和のリスト
            y_0.append(y_0[-1]+d)
        else:
            st.add(t)
            y_1.append(y_1[-1]+d)
    

    max_sum = -1

    for i in range(1,k+1):
        if k-i >= len(y_0):
            continue
        if i >= len(y_1):
            break
        max_sum = max(max_sum, y_0[k-i]+y_1[i]+i**2)
    
    print(max_sum)
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 32876
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	d := 0
	for n > 0 {
		n /= k
		d++
	}
	fmt.Fprintln(writer, d)
}


Measured memory_bytes: 640
import bisect

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

count = 0

L_i.sort()
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        count += bisect.bisect_left(L_i,L_i[i] + L_i[j]) - j - 1
        
print(count)


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    string s;
    cin >> s;
    char flg[256] = {};
    for(int i = 0; i < s.size(); i++){
        flg[s[i]] = 1;
    }
    for(char c = 'a'; c <= 'z'; c++){
        if(flg[c]==0){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  string str;
  while(cin >> str && str != "0000"){
    if(str == "1111" || 
       str == "2222" || 
       str == "3333" || 
       str == "4444" || 
       str == "5555" || 
       str == "6666" || 
       str == "7777" || 
       str == "8888" || 
       str == "9999") cout << "NA" << endl;
    else if(str == "6174") cout << 0 << endl;
    else{
      for(int n=1;;n++){
        int L=0,S=0,LS,a,b;
        bool f[4];
        fill(f,f+4,false);

        for(int i=1;i<=1000;i*=10){
          a = b = -1;
          for(int j=0;j<4;j++){
            if(f[j]) continue;
            else if(a < str[j] - '0'){
              a = str[j] - '0';
              b = j;
            }
          }
          f[b] = true;
          L += 1000 / i * a;
          S += i * a;
        }
        LS = L - S;

        if(LS == 6174){
          cout << n << endl;
          break;
        }

        for(int i=3;i>=0;i--){
          str[i] = LS % 10 + '0';
          LS /= 10;
        }
      }
    }
  }
}

Measured memory_bytes: 1192
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next()); // 整数
        int k = Integer.parseInt(sc.next()); // 基数
        ArrayList<Integer> list = new ArrayList<>();
        while (n >= 1) {
            list.add(n % k);
            n /= k;
        }
        System.out.println(list.size());
        sc.close();
    }
}


Measured memory_bytes: 35580
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int A, B, M;
	cin >> A >> B >> M;

	vector<int> a( A ), b( B );
	for( auto& v: a ) { cin >> v; }
	for( auto& v: b ) { cin >> v; }

	int v = *min_element( a.begin(), a.end() ) + *min_element( b.begin(), b.end() );
	int w = INT_MAX;
	for( int i = 0; i < M; ++i ) {
		int x, y, c;
		cin >> x >> y >> c;
		w = min( w, a[x-1] + b[y-1] - c );
	}

	cout << min( v, w ) << endl;
	return 0;
}


Measured memory_bytes: 1024
def main():
	n,m = map(int,input().split())
	# a = list(map(int,input().split()))
	# l = [str(input()) for i in range(n)]
	
	if n < 10:
		print(100*(10-n) + m)
	else:
		print(m)
	

		
		
	
	
 
if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

void solve() {
  vector<int> a, b;
  REP(i, 9) {int x; scanf("%d", &x); a.push_back(x); }
  REP(i, 9) {int x; scanf("%d", &x); b.push_back(x); }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  int awin = 0;
  int bwin = 0;
  int drow = 0;
  do {
      int scoreA = 0;
      REP(i, 9) {
          if (a[i] > b[i]) scoreA += a[i] + b[i];
          else scoreA -= a[i] + b[i];
      }
      if (scoreA > 0) awin++;
      if (scoreA < 0) bwin++;
      if (scoreA == 0) drow++;
  } while (next_permutation(b.begin(), b.end()));
  int all = awin + bwin + drow;
  printf("%.5f %.5f\n", (double) (awin) / (all), (double) (bwin) / (all));
}

int main() {
  int T; cin >> T;
  for (;T--;) solve();
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n,a[20000];
int ans=0;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        while(a[i]%2==0){
            a[i]/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int f(int a,int b)
{
	if(a<b)
	swap(a,b);
	if(a==b)
	return a;
	int m;
	while(b)
	{
		m=a%b;
		a=b;
		b=m;
	}
	return a;
}
int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		cout<<f(a,b)<<" "<<a/f(a,b)*b<<endl;
	}
}

Measured memory_bytes: 3060
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (abs(b - a) + w*t <= v*t) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3648