akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC057D
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static public void Main(string[] args)
        {
            var N = Console_.NextInt();
            var A = Console_.NextInt();
            var B = Console_.NextInt();

            var aryV = new long[N];
            for (int i = 0; i < N; ++i)
            {
                aryV[i] = Console_.NextLong();
            }
            Array.Sort(aryV);
            aryV = aryV.Reverse().ToArray();

            var maxAve = 0.0d;
            for (int i = 0; i < A; ++i)
            {
                maxAve += aryV[i] / (double)A;
            }

            var ctable = new long[N + 1, N + 1];
            for (int i = 0; i <= N; ++i)
            {
                for (int j = 0; j <= i; ++j)
                {
                    if (j == 0 || j == i)
                    {
                        ctable[i, j] = 1;
                    }
                    else
                    {
                        ctable[i, j] = ctable[i - 1, j - 1] + ctable[i - 1, j];
                    }
                }
            }

            var x = 0;
            var y = 0;
            for (int i = 0; i < N; ++i)
            {
                if (aryV[A - 1] == aryV[i])
                {
                    ++x;
                    if (i < A)
                    {
                        ++y;
                    }
                }
            }
            var sumCount = 0L;
            if (A == y)
            {
                for (int i = A; i <= B; ++i)
                {
                    sumCount += ctable[x, i];
                }
            }
            else
            {
                sumCount = ctable[x, y];
            }

            Console.WriteLine(maxAve);
            Console.WriteLine(sumCount);
        }
    }
}


Measured memory_bytes: 13620
program main
      implicit none
      integer(4) :: n, i
      integer(8) :: cnt

      read *, n

      cnt = 0
      do i= 1, n
        if (( mod(i,3) /= 0 ) .and. ( mod(i,5) /= 0 )) then
          cnt = cnt + i
        end if
      end do
      print *, cnt

end program main


Measured memory_bytes: 2796
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	x := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
	}

	var ans int

	for i := 0; i < n; i++ {
		ans += int(math.Min(float64(2*(x[i])), float64(2*math.Abs(float64(x[i]-k)))))
	}
	fmt.Println(int(ans))
}


Measured memory_bytes: 1844
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

int main() {
    int n;
    cin >> n;
    int maior = 0;
    int tot = 0;
    for (int i = 0; i <= n - 1; i++) {
        int a;
        cin >> a;
        if (a >= maior) {
            maior = a;
            tot++;
        }
    }
    cout << tot << '\n';
    return 0;
}

Measured memory_bytes: 3612
# レベルiバーガーの層数は 2^(i+2) - 3
def layers(i):
    return 2 ** (i + 2) - 3

# レベルiバーガーのパティ数は 2^(i+1) - 1
def patties(i):
    return 2 ** (i + 1) - 1

def solve(n, x):
    layers = 2 ** (n + 1) - 3  # レベルn-1バーガーの層の数
    patties = 2 ** n - 1    # レベルn-1バーガーのパティの数
    if x == 0:
        ans = 0
    elif x < layers + 1:
        ans = solve(n - 1, x - 1)
    elif x == layers + 1:
        ans = patties
    elif x == layers + 2:
        ans = patties + 1
    elif x < 2 * layers + 2:
        ans = patties + 1 + solve(n - 1, x - layers - 2)
    else:
        ans = 2 * patties + 1
    return ans

N, X = [int(x) for x in input().split()]
print(solve(N, X))


Measured memory_bytes: 3064
S = gets.chomp.split('')
Q = gets.to_i

t1 = false
Q.times do
  q = gets.split
  if q[0] == "1"
    t1 = !t1
    next
  end

  if q[1] == "1"
    if t1
      S.push(q[2])
    else
      S.unshift(q[2])
    end
  else
    if t1
      S.unshift(q[2])
    else
      S.push(q[2])
    end
  end
end

if t1
  puts S.reverse.join
else
  puts S.join
end

Measured memory_bytes: 30844
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}



int main() {

	int N;
	cin >> N;

	map<ll, ll> X1;
	map<ll, ll> X2;

	for (int i = 0; i < N; i++) {
		ll tmp;
		cin >> tmp;

		//要素の検索
		map<ll, ll>::iterator ite;
		ite = X1.find(tmp+i+1);
		if (ite != X1.end()) {
			//値の取得
			ll value = ite->second;
			//要素の削除
			X1.erase(tmp+i+1);
			//要素の代入
			X1.insert(make_pair(tmp+i+1, value + 1));
		}
		else {
			X1.insert(make_pair(tmp + i+1, 1));
		}

		ite = X2.find(-tmp + i+1);
		if (ite != X2.end()) {
			//値の取得
			ll value = ite->second;
			//要素の削除
			X2.erase(-tmp + i + 1);
			//要素の代入
			X2.insert(make_pair(-tmp + i + 1, value + 1));
		}
		else {
			X2.insert(make_pair(-tmp + i + 1, 1));
		}
	}

	ll ans = 0;
	//要素の全探索
	for (map<ll, ll>::iterator ite = X1.begin(); ite != X1.end(); ite++) {
		//値の取得
		ll X1_val = ite->first;
		ll X1_num = ite->second;
		//値の存在確認
		ll X2_num = 0;
		if (X2.count(X1_val) != 0) {
			//値の取得
			X2_num = X2[X1_val];
		}
		ans += X1_num * X2_num;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 26696
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
 
int main() {
  int Tc; cin >> Tc;
  int H, M;
	char c;
   
  while(Tc --) {
    //scanf("%d:%d", &H, &M);
     cin >> H >> c >> M;
    double h = H*30.0 + M/2.0, m = M*6;
     
    int ang = abs(h - m);
    if(ang > 180) ang = 360 - ang;
    if(0 <= ang && ang < 30) {
      cout << "alert" << endl;
    }
    else if(90 <= ang && ang <= 180) {
      cout << "safe" << endl;
    }
    else cout << "warning" << endl;
  }
   
  return 0;
}

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

const int maxl=3e5+10;

int n,m,ans,cas,k;
int a[maxl],b[maxl];
char s[maxl];
bool in[maxl]; 

inline void prework()
{
	scanf("%s",s+1);
	n=strlen(s+1);
} 

inline void mainwork()
{
	for(int i=1;i<=n;i++)
	if(s[i]=='?')
		s[i]='D';
}

inline void print()
{
	for(int i=1;i<=n;i++)
		printf("%c",s[i]);
}

int main()
{
	int t=1;
	//scanf("%d",&t);
	for(cas=1;cas<=t;cas++)
	{
		prework();
		mainwork();
		print();
	}
	return 0;
}

Measured memory_bytes: 3968
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	VS str = { "light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy" };

	double w;
	while (cin >> w) {

		int ans = -1;
		if (w <= 48.00)ans = 0;
		else if (w <= 51.00)ans = 1;
		else if (w <= 54.00)ans = 2;
		else if (w <= 57.00)ans = 3;
		else if (w <= 60.00)ans = 4;
		else if (w <= 64.00)ans = 5;
		else if (w <= 69.00)ans = 6;
		else if (w <= 75.00)ans = 7;
		else if (w <= 81.00)ans = 8;
		else if (w <= 91.00)ans = 9;
		else ans = 10;

		Cout(str[ans]);
	}
}


Measured memory_bytes: 3180
input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i

product = a * b

small = a < b ? a : b
bigest_common = 1
(2..small).each do |num|
    bigest_common = num if a % num == 0 && b % num == 0
end

puts product / bigest_common

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

using namespace std;

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 

int main() {
    int n, x, y;

    scanf("%d", &n);

    int flag = 0, f2 = 0;
    while (n--) {
        scanf("%d %d", &x, &y);

        if (x == y)
            ++flag;
        else
            flag = 0;

        if (flag == 3) {
            puts("Yes");
            f2 = 1;
            flag = -1000;
            continue;
        }
    }

    if (!f2)
        puts("No");

    return 0;
}

Measured memory_bytes: 3656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int ten = n / 10;
            int one = n % 10;

            out.println(ten == 9 || one == 9 ? "Yes" : "No");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

int a[502];
int pref[502];
int main(){
	int n, x;
	cin >> n >> x;
	int l = 1  + x -1;
	int r= n + x -1;
	int i =1;
	while(l<=r)
		a[i++]=l++;

	for(i=1;i<=n;i++) pref[i]=pref[i-1] + a[i];

	int orig = pref[n];
	int ans = pref[n]-pref[1];
	for(i=1;i<=n;i++) {
		int tans =pref[n]-a[i];
		if(abs(orig-tans) < abs(orig - ans))
			ans = tans;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    auto N = readln.chomp.map!(i => (i - '0').to!int).retro.array;
    N ~= 0;

    auto L = N.length.to!int;

    auto dp = new int[][](L + 1, 2);
    fillAll(dp, inf);
    dp[0][0] = 0;

    foreach (i ; 0 .. L) {
        foreach (j ; 0 .. 2) {
            foreach (d ; 0 .. 10) {
                int x = N[i] + j;
                if (d < x) {
                    chmin(dp[i + 1][1], dp[i][j] + d + 10 + d - x);
                }
                else {
                    chmin(dp[i + 1][0], dp[i][j] + d + d - x);
                }
            }
        }
    }

    auto ans = dp[L][0];
    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 49960
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Abcdef
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //Input int array
            int[] inputArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            (int h, int w, int k) = (inputArray[0], inputArray[1], inputArray[2]);

            char[,] c = new char[h, w];
            for (int i = 0; i < h; i++)
            {
                var ss = Console.ReadLine().AsSpan();
                for (int j = 0; j < w; j++)
                {
                    c[i, j] = ss[j];
                }
            }

            List <bool[]> boolPatterns = new List<bool[]>();
            var boolArray = new bool[h+w];
            GetBoolPermutation(boolArray, 0);

            var results = new List<int>();
            foreach (var pattern in boolPatterns)
            {
                bool[] hbool = new bool[h];
                Array.Copy(pattern, hbool, h);

                bool[] wbool = new bool[w];
                Array.Copy(pattern, h,wbool,0,w);

                char[,] cc = new char[h,w];
                Array.Copy(c, cc, c.Length);

                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        if (hbool[i] || wbool[j]) 
                        {
                            cc[i, j] = '.';
                        }
                    }
                }

                int result = 0;
                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        if (cc[i, j] == '#') result++; 
                    }
                }
                results.Add(result);
            }

            Console.WriteLine(results.Where(item => item == k).Count()); 

            Console.Out.Flush();

            void GetBoolPermutation(bool[] bools, int first)
            {
                if (first == bools.Length) 
                {
                    boolPatterns.Add(bools.ToArray());
                    return;
                }

                bools[first] = true;
                GetBoolPermutation(bools, first + 1);
                bools[first] = false;
                GetBoolPermutation(bools, first + 1);
            }
        }
    }
}


Measured memory_bytes: 29200
#include<bits/stdc++.h>
using namespace std;
int main(){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        while(1){
                c -= b;
                if(c <= 0){
                        cout << "Yes" << endl;
                        break;
                }
                a -= d;
                if(a <= 0){
                        cout << "No" << endl;
                        break;
                }
        }
}


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

int main(){
	ll N,M;
	cin >> N >> M;
	vector<ll> A(N+M-1),B(N+M-1),G[N],in_cnt(N,0);
	vector<bool> is_root(N,true);

	for(int i=0;i<N+M-1;i++){
		cin >> A[i] >> B[i];
		A[i]--,B[i]--;
		G[A[i]].push_back(B[i]);
		is_root[B[i]] = false;
		in_cnt[B[i]]++;
	}

	int root;
	for(int i=0;i<N-1;i++){
		if(is_root[i]) root = i;
	}

	vector<ll> pa(N,-1);
	queue<ll> q;
	q.push(root);

	while(q.size()){
		ll from = q.front();
		q.pop();
		for(auto to:G[from]){
			pa[to] = from;
			in_cnt[to]--;
			if(in_cnt[to] == 0){
				q.push(to);
			}
		}
	}

	pa[root] = -1;
	for(auto x:pa){
		cout << x+1 << "\n";
	}

}


Measured memory_bytes: 9472
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)	cin>>a[i];
	sort(a,a+n,greater<int>());
	int sum=0;
	for(int i=k;i<n;i++)
	{
		sum+=a[i];
	}
	cout<<sum<<endl;

}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}



Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int m,f,r,t;
	for(;;)
	{
		scanf("%d%d%d",&m,&f,&r);
		t=m+f;
		if(m+f+r==-3)return 0;
		if(m==-1||f==-1)puts("F");
		else if(t>=80)puts("A");
		else if(t>=65)puts("B");
		else if(t>=50||r>=50)puts("C");
		else if(t>=30)puts("D");
		else puts("F");
	}
	return 0;
}



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

typedef pair<int, int> P;

int N, K;
vector<int> G[2000];
int U[2000], C[2000], R[2000];
bool B[2000];

int dfs(int s, int p, int r) {
  U[s] = p, R[s] = r;
  int c = 1;
  for (int t : G[s]) {
    if (t == p) continue;
    c += dfs(t, s, r+1);
  }
  C[s] = c-1;
  return c;
}

int dfs2(int s, int p, int d) {
  int c = !B[s] && d > K;
  for (int t : G[s]) {
    if (t == p) continue;
    c += dfs2(t, s, d+1);
  }
  return c;
}

int f(int x) {
  return C[x] + (U[x]==x ? 0 : dfs2(U[x], x, 1));
}

int main() {
  cin >> N >> K;
  for (int i=0; i<N-1; i++) {
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b), G[b].push_back(a);
  }


  vector<int> g;
  for (int i=0; i<N; i++) g.push_back(i);
  random_shuffle(g.begin()+1, g.end());

  int s = N - 1;
  int sn = min((int)g.size(), 30);
  for (int z=0; z<sn; z++) {
    int k = g[z];
    dfs(k, k, 0);
    vector<P> a;
    for (int i=0; i<N; i++) {
      B[i] = false;
      a.push_back(P(R[i], i));
    }
    sort(a.begin(), a.end(), greater<P>());
    int b = 0;
    for (P p : a) {
      int v = p.second;
      s = min(s, f(v) + b);
      b++;
      B[v] = true;
    }
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

fn main() {
    let (h, w): (usize, usize) = (read(), read());
    let mut a: Vec<Vec<i64>> = (0..h)
        .map(|_| (0..w).map(|_| read::<i64>()).collect())
        .collect();

    let mut ans: Vec<(usize, usize, usize, usize)> = Vec::new();

    let d = [(0, 1), (1, 0)];
    for i in 0..h {
        for j in 0..w {
            for k in 0..2 {
                let (ny, nx) = (i + d[k].0, j + d[k].1);
                if nx >= w || ny >= h {
                    continue;
                }
                if a[i][j] % 2 == 1 {
                    a[ny][nx] += 1;
                    a[i][j] -= 1;
                    ans.push((i, j, ny, nx));
                    break;
                }
            }
        }
    }
    println!("{}", ans.len());
    for i in &ans {
        println!("{} {} {} {}", i.0 + 1, i.1 + 1, i.2 + 1, i.3 + 1);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 13304
#include <stdio.h>

int main() {
	int a, b;
	int k;
	
	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	
		
	for (int i = a; i <= b; i++) {	
		
		int c;
		c = a%k;
		
		if(c != 0 && a <= b) {
			a++;
			continue;
		}
		if(c == 0 && a <= b) {
			printf("OK\n");
			return 0;
			
		}
	}
	printf("NG\n");
	return 0;
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}


    vector<int> gcd_len_1(n);
    vector<int> gcd_len_2(n);
    gcd_len_1[0] = a[0]; gcd_len_2[n-1] = a[n-1];

    rep1(i, n-1) gcd_len_1[i] = gcd(a[i], gcd_len_1[i-1]);
    rep1(i, n-1) gcd_len_2[n-1-i] = gcd(a[n-1-i], gcd_len_2[n-i]);

    // show(gcd_len_1);
    // show(gcd_len_2);

    int ans = 0;
    rep(i, n) {
        int tmpgcd;
        if (i == 0) {
            tmpgcd = gcd_len_2[1];
        } else if (i == n-1) {
            tmpgcd = gcd_len_1[n-2];
        } else {
            tmpgcd = gcd(gcd_len_1[i-1], gcd_len_2[i+1]);
        }
        //cout << tmpgcd << endl; 
        ans = max(ans, tmpgcd);
    }
    cout << ans << endl;
}


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

int main(){
	
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	
	if (0 <= x - r&&W >= x + r){ 
		
		if (0 <= y-r&&H >= y + r){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}

	}
	else{
		cout << "No" << endl;
	}

	return 0;
}




Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
int ctoi(char c);
using namespace std;

int main(){
	string s;
	long long int k;
	long long int sum=0;
	cin >> s >> k;

	if (s.size() == 1) {
		cout << s[0] << endl;
		return 0;
	} else if (s.size() > k && s[k-1] == '1') {
		cout << 1 << endl;
		return 0;
	}

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define vv vector<lli>
#define vp vector<pair<lli,lli>>
#define vpp vector<pair<lli,pair<lli,lli>>>
#define lims(w) (w).begin(),(w).end()
#define rlims(w) (w).rbegin(),(w).rend()
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(lli i=a;i<b;i++)
#define ff first
#define ss second
#define sz(a) (lli)(a.size())
lli inf = (1e18 + 2);
lli asc[1000003] = {0};
lli prlim = 78499;
lli asc2[1000003] = {0};

int main()
{
	lli n;
	cin>>n;
	lli a[n+1];
	vv v;
	lli gcd = 0;
	bool sety = false;
	bool pairy = true;

	f(i,0,n)
	{
		cin>>a[i];
		gcd = __gcd(gcd, a[i]);
		asc[a[i]]++;
	}

	sety = (gcd == 1);

	f(i,2,1000001)
	{
		if(asc[i] > 0)
			v.pb(i);

		if(asc[i] > 1)
		{
			if(sety)
				cout<<"setwise coprime"<<endl;
			else
				cout<<"not coprime"<<endl;
			return 0;	
		}
	}

	lli els = n;

	if(asc[1] > 1)
	{
		els -= (asc[1] - 1);
	}

	if(asc[1] > 0)
		v.pb(1);

	if(els > prlim)
	{
		if(sety)
			cout<<"setwise coprime"<<endl;
		else
			cout<<"not coprime"<<endl;
		return 0;
	}

	lli val;

	f(z,0,sz(v))
	{
		if(!pairy)
			break;
		val = v[z];

		if(val == 1)
			continue;

		if(asc2[2] > 0 && val % 2 == 0)
		{
			pairy = false;
			break;
		}

		while(val % 2 == 0)
		{
			asc2[2] = 1;
			val /= 2;
		}

		for(lli i = 3; i*i <= val; i = i + 2)
		{
			if(val % i == 0)
			{
				if(asc2[i] > 0)
				{
					pairy = false;
					break;
				}

				while (val % i == 0)
				{
					asc2[i] = 1;
					val /= i;
				}
			}
		}

		if(val > 2)
		{
			if(asc2[val] > 0)
				pairy = false;
			else
				asc2[val] = 1;
		}
	}

	if(pairy)
		cout<<"pairwise coprime"<<endl;
	else if(sety)
		cout<<"setwise coprime"<<endl;
	else
		cout<<"not coprime"<<endl;

	return 0;
}


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

long long lcm(long long x, long long y){
  long long xx=x,yy=y,temp;
  while(yy!=0){
    xx%=yy;
    temp=yy;
    yy=xx;
    xx=temp;
  }
  return x/xx*y;
}

int main(){
  int N; cin >> N;
  long long result=1,T;
  for(int i=0; i<N; i++){
    cin >> T;
    result=lcm(result,T);
  }
  cout << fixed << setprecision(0) << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define REP(v, n) FOR(v, 0, n)
using namespace std;

int main(){
	int t, n, s, f, sum;
	
	while(cin >> t, t){
		cin >> n;
		sum = 0;
		REP(i, n){
			cin >> s >> f;
			sum += (f - s);
		}
		if(sum >= t) cout << "OK" << endl;
		else cout << t - sum << endl;
	}
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> A(N);
  int A_total=0;
  for (int i=0; i<N; i++){
    cin >> A.at(i);
    A_total += A.at(i);
  } 

  int choise=0;
  for(int i=0; i<N; i++){
    if(4*M*A.at(i) >= A_total) choise++; 
  }

  if(choise>=M) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {

    ll N;
    cin >> N;

    int F[100][14];
    int P[100][15];


    for(int i = 0; i < N; ++i)
    {
        for(int j = 0; j < 10; ++j)
        {
            cin >> F[i][j];
        }
    }

    for(int i = 0; i < N; ++i)
    {
        for(int j = 0; j < 11; ++j)
        {
            cin >> P[i][j];
        }
    }

    int res = -(1 << 30);
        
    //2^10通り(シフト10個 出る/出ない)
    for(int b = 1; b < (1 << 10); ++b)
    {
        int cc = 0;
        for(int i = 0; i < N; ++i)
        {
            int c = 0;
            for(int j = 0; j < 10; ++j)
            {
                //joisinoが出勤かつ F[i][j]が出勤
                if(((b >> j) & 1) && F[i][j])
                {
                    ++c;
                }
            }
            cc += P[i][c];
        }
        res = max(res,cc);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
d={}
L="abcdefghijklmnopqrstuvwxyz.?! "
p=0
for i in range(30): d[(i/5)*10+i%5+11]=L[i]
for s in sys.stdin:
  s=s[:-1]
  s=[s[i:i+2] for i in range(0,len(s),2)]
  try: A=[d[e] for e in map(int,s)]
  except: A=["NA"]
  print "".join(A)

Measured memory_bytes: 4220
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<assert.h>
#define rep(i,N) for(long long i=0;i<(long long)N;i++)
int N,x,y,pos,tri0,tri1,tri2,pw3[13]={1},A[1000001],salsa[531441];
char T[200001],sw[1000001];
void OUT(long long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
char* replace(char* s,const char* before,const char* after)
{
  assert(s!=(char*)NULL);assert(before!=(char*)NULL);assert(after!=(char*)NULL);
  const size_t szb=strlen(before),sza=strlen(after);
  char* pt=s;
  if(szb==0)return s;
  for(;;)
  {
    pt=strstr(pt,before);if(pt==(char*)NULL)break;const char* remain=pt+szb;
    memmove(pt+sza,remain,strlen(remain)+1);
    memcpy(pt,after,sza);
    pt+=sza;
  }
  return s;
}
signed main(void)
{
  x=scanf("%d %s",&N,T+1);
  replace(T+1,"SS","");if(T[0]=='\n')return 0;
  rep(i,N)pw3[i+1]=3*pw3[i];
  tri0=pw3[N],tri1=pw3[N/2],tri2=pw3[N-N/2];
  rep(i,tri0)salsa[i]=salsa[i/3]*3+(3-i%3)%3;
  rep(i,tri1)
  {
    x=i,pos=0;
    rep(j,strlen(T+1))
    {
      if(T[j+1]=='S'){x=salsa[x];if(sw[pos]=='s')pos--;else sw[++pos]='s';}
      if(T[j+1]=='R'){x++;if(x==tri1)sw[++pos]='r',x=0;}
    }
    rep(j,tri2)
    {
      y=j;
      rep(k,pos){if(sw[k+1]=='s')y=salsa[y];else if(sw[k+1]=='r'){if((++y)==tri2)y=0;}}
      A[i+j*tri1]=y*tri1+x;
    }
  }
  rep(i,tri0)OUT(A[i]),putchar(' ');
}

Measured memory_bytes: 8208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define ill long long
#define rep(i, a, b) for(ill i = (ill)(a); i < (ill)(b); i++)
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(a >= b) cout << "delicious\n";
  else if(a+x >= b) cout << "safe\n";
  else cout << "dangerous\n";
}


Measured memory_bytes: 3568
from collections import defaultdict


def mod_inv(a, m):
    return pow(a, m-2, m)


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)
    ans = fact[a] * ifact[b] * ifact[a-b]
    return ans


MOD = 10**9+7
n, k = map(int, input().split())
k = min(k, n-1)

fact = defaultdict(int)
fact[0] = 1
for i in range(1, n+1):
    fact[i] = fact[i-1] * i
    fact[i] %= MOD

ifact = defaultdict(int)
ifact[n] = mod_inv(fact[n], MOD)
for i in reversed(range(1, n + 1)):
    ifact[i-1] = ifact[i] * i
    ifact[i-1] %= MOD

ans = 0
for i in range(k+1):
    ans += combination(n, i) * combination((n-i-1)+i, i)
    ans %= MOD

print(ans % MOD)


Measured memory_bytes: 63972
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: print('Yes' if b else 'No')
YESNO=lambda b: print('YES' if b else 'NO')

def main():
    N,W=map(int,input().split())
    v,w=[0]*N,[0]*N
    for i in range(N):
        v[i],w[i]=map(int,input().split())
    dp=[[0]*2*10**5 for _ in range(N+1)]
    for i in range(N):
        for weight in range(W+1):
            dp[i+1][weight]=max(dp[i+1][weight],dp[i][weight])
            if weight-w[i]>=0:
                dp[i+1][weight]=max(dp[i+1][weight],dp[i][weight-w[i]]+v[i])
    print(dp[N][W])

if __name__ == '__main__':
    main()



Measured memory_bytes: 175448
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  while(R n && n) {
    int x[n];
    rep(i,n) R x[i];
    double ans=MAX;
    int z[3];
    rep(s,16) {
      rep(a,16) {
        rep(c,16) {
          vector<int> y(n+1);
          y[0]=s;
          int o[256];
          mem(o);
          REP(i,1,n+1) {
            y[i]=(a*y[i-1]+c)%256;
            o[(y[i]+x[i-1])%256]++;
          }
          double h=0;
          rep(i,256) if(o[i]) h+=-o[i]*(log(o[i])-log(n));
          if(h+1e-10<ans) {
            ans=h;
            z[0]=s;
            z[1]=a;
            z[2]=c;
          }
        }
      }
    }
    PR(z,3);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 1244
def main(n,a):
  a=sorted([a[i]-i for i in range(n)])
  m0=a[n//2]
  m1=a[n//2-1]
  ans0,ans1=0,0
  for i in range(n):
    ans0+=abs(a[i]-m0)
    ans1+=abs(a[i]-m1)
  print(min(ans0,ans1))
if __name__=='__main__':
  import sys
  input = sys.stdin.readline
  n=int(input())
  a=list(map(int,input().split()))
  main(n,a)


Measured memory_bytes: 25168
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,ans,a,n;
	cin>>N;
	ans=N;
	for(int i=0;i<=N;i++){
		a=0;
		n=i;
		while(n!=0){
			a=a+n%6;
			n=n/6;
		}
		n=N-i;
		while(n!=0){
			a=a+n%9;
			n=n/9;
		}
		if(ans>a) ans=a;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=list(map(int,input().split()))
S=map(str,s)
print(' '.join(S))
for i in range(1,n):
  tmp=s[i]
  j=i-1
  while j>=0 and tmp < s[j]:
    s[j+1]=s[j]
    j -= 1
  s[j+1]=tmp
  S=map(str,s)
  print(' '.join(S))


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

vector<pll> factorize(ll num)
{
	vector<pll> v; 
	for (ll i = 2; i * i <= num; ++i)
	{
		if (num % i != 0) continue;
		ll c{0};
		while (num % i == 0) {++c; num /= i;}
		v.push_back(pll(i, c));
	}

	if (num != 1) v.push_back(pll(num, 1));
	return v;
}

int main(int argc, char **argv)
{
	ll N, P; cin >> N >> P;

	vector<pll> vf{factorize(P)};

	ll res{1};
	for (auto &e : vf)
	{
		for(ll i = 0; i < e.second/N; ++i) res *= e.first;
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val y = sc.nextLong()
    println(problem085c(n, y))
}

fun problem085c(n: Int, y: Long): String {
    for (i in 0..n) {
        if (i == n && i * 10000L == y) return "$i 0 0"
        for (j in 0..n) {
            if (i + j > n) break
            for (k in 0..n) {
                if (i + j + k > n) break
                if (i + j + k == n && i * 10000L + j * 5000L + 1000L * k == y) {
                    return "$i $j $k"
                }
            }
        }
    }
    return "-1 -1 -1"
}

Measured memory_bytes: 31520
N = int(input())
NAME = 'abcdefghijklmnopqrstuvwxyz'
D = 26
name = ''

while N > 0:
  i = N % D
  name = NAME[i-1] + name
  N = int((N - i) / D)
  if i == 0:
    N -= 1
  
print(name)

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <numeric>
#include <functional>
#include <stack>
#include <queue>
#include <deque>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define INF 1e9
#define MOD 1e9+7
#define ll long long

using namespace std;
int main(void){
    int k,s,ans=0;
    cin>>k>>s;
    rep(i,0,k+1){
        rep(j,0,k+1){
            int z=s-i-j;  
            if(0<=z && z<=k)ans++;
        }
    }
    cout<<ans<<endl;
}


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

int main()
{
  ll h;
  cin >> h;
  ll w;
  cin >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (w%2) {
    cout << h*(w-1)/2 + (h+1)/2 << endl;
  } else {
    cout << h*w/2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if((a*b)%2==0) printf("Even\n");
	else printf("Odd\n");
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python

def main():
    k, n = map(int, input().split())
    a = list(map(int, input().split()))

    a.append(k + a[0])
    b = [a[i + 1] - a[i] for i in range(n)]

    print(k - max(b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 26420
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
char s1[SIZE],s2[SIZE];

int main()
{
	scanf("%s",&s1);
	scanf("%s",&s2);
	int n = strlen(s1);
	map<char,char> T,S;
	bool ans = true;
	for(int i=0;i<n;i++){
		if(T.find(s1[i]) == T.end()){ //new
			T.insert(make_pair(s1[i],s2[i]));
		}else{ //used
			if(T[s1[i]] != s2[i])ans = false;
		}
		if(S.find(s2[i]) == S.end()){ //new
			S.insert(make_pair(s2[i],s1[i]));
		}else{ //used
			if(S[s2[i]] != s1[i])ans = false;
		}
	}
	if(ans)puts("Yes");
	else puts("No");

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int a, b;
    cin >> a >> b;
    if (a < b)
    {
        cout << "a < b" << endl;
    }
    else if (a > b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3096
import sys
input = sys.stdin.readline
W, H, N = map(int, input().split())
table = [set() for _ in range(H + 1)]
qs = []
for _ in range(N):
  x, y = map(int, input().split())
  table[y - 1].add(x - 1)
  if x >= y: qs.append((x - 1, y - 1))
u, v = 0, 0
while u < W and (v < H):
  u += 1
  v += not (u in table[v + 1])
t = []
for i in range(len(qs)):
  if qs[i][1] <= v: t.append(qs[i])
qs = t
def check(x, y):
  u, v = 0, 0
  while u <= x:
    if (u + 1) in table[v]: return True
    u += 1
    if v < y: v += not (u in table[v + 1])
  return False

qs.sort(key = lambda x: x[0])
ng = -1
ok = len(qs)
while ok - ng > 1:
  m = (ok + ng) // 2
  if check(qs[m][0], qs[m][1]): ok = m
  else: ng = m
#print(ok, ng, qs)
#print(table)
if ok == len(qs): print(W)
else:
  x, y = qs[ok]
  u, v = 0, 0
  res = 0
  stop = 0
  while True:
    if (u + 1) in table[v]:
      stop += 1
    else:
      u += 1
      stop = 0
    res += 1
    if stop > 1: break
    if v >= y or (u in table[v + 1]) or (stop > 0): stop += 1
    else:
      v += 1
      stop = 0
    if stop > 1: break
  print(res)


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

int main(){
    ll n;
    int k;
    cin >> n >> k;
    vector<int> a = vector<int>();
    int i = 1;
    while (n != 0){
        int r = n % k;
        //cout << "r = " << r << endl;
        a.push_back(r);
        n -= r;
        n /= k;
        i++;
    }
    cout << a.size() << endl;
    //reverse(a.begin(),a.end());
    //string nk(a.size(), '0');
    //rep(j, a.size()) nk[j] = (char)(a[j] + '0');

    //cout << nk << endl;
    return 0;
}

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


public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line1 = br.readLine().split(" ");
    int numOfCards = Integer.parseInt(line1[0]);
    int numOfHints = Integer.parseInt(line1[1]);
    
    UnionFind tree = new UnionFind(numOfCards);
    
    int x;
    int y;
    
    for(int i=0; i<numOfHints; i++){
      String[] hint = br.readLine().split(" ");
      x = Integer.parseInt(hint[0])-1;
      y = Integer.parseInt(hint[1])-1;
      
      if(!tree.whetherSameRoot(x, y)){
        tree.uniteNode(x, y);
      }
    }
    System.out.println(tree.getNumOfRoot());
  }
}

class UnionFind{
  int[] par;
  UnionFind(int numNode){
    par = new int[numNode];
    for(int i=0; i<numNode; i++){
      par[i] = i;
    }
  }
  
  int getRoot(int nodeIndex){
    if(par[nodeIndex] == nodeIndex){
      return nodeIndex;
    }else{
      return par[nodeIndex] = getRoot(par[nodeIndex]);
    }
  }
  
  void uniteNode(int nodeA, int nodeB){
    if(!whetherSameRoot(nodeA, nodeB)){
      par[getRoot(nodeA)] = getRoot(nodeB);
    }
  }
  
  boolean whetherSameRoot(int nodeA, int nodeB){
    return getRoot(nodeA) == getRoot(nodeB);
  }
  
  int getNumOfRoot(){
    int result = 0;
    for(int i=0; i<par.length; i++){
      if(par[i] == i){
        result++;
      }
    }
    return result;
  }
}

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

int main(void) {
  int N;
  cin >> N;
  int a,b,c;
  a = N % 10;
  b = (N / 10) % 10;
  c = N / 100;
  if(a == 7 || b == 7 || c == 7) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

const int MAX_N = 60;

int main(int argc, char const *argv[])
{
    int n;
    double sum = 0, v[MAX_N];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v, v+n);
    sum = (v[0] + v[1]) /2;
    for (int i = 2; i < n; ++i) {
        sum = (sum + v[i]) / 2;
    }
    printf("%.16lf\n", (double)(sum));
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def get_all_members(self):
        pare_d = {}
        for i in range(self.n):
            parent = self.find(i)
            pare_d.setdefault(parent,[])
            pare_d[parent].append(i)
        return list(pare_d.values())

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



def main():
    n,m = map(int, input().split())
    al = list(map(int, input().split()))    
    uf = UnionFind(n)
    for _ in range(m):
        x,y = map(int, input().split())
        uf.union(x,y)

    first_mins = []
    other_vals = []
    
    all_members = uf.get_all_members()
    if len(all_members) == 1:
        print(0)
        exit()

    for members in all_members:
        vs = []
        for m in members:
            vs.append(al[m])
        vs.sort()
        first_mins.append(vs[0])
        for i,v in enumerate(vs):
            if i > 0:
                other_vals.append(v)

    # print(first_mins)
    ans = 0
    ans += sum(first_mins)
    rem = len(all_members)-2
    if len(other_vals) < rem:
        print('Impossible')
        exit()
    other_vals.sort()
    ans += sum(other_vals[:rem])
    print(ans)



if __name__ == "__main__":
    main()

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

int main(){
  int N, M, k;
  cin >> N >> M;
  vector<vector<int>> s(M, vector<int>());
  vector<int> p(M);
  
  for (int i = 0; i < M; i++) {
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> s.at(i).at(j);
      s.at(i).at(j)--;
    }
  }
  
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool ok = true;
    for (int i = 0; i < M; i++) {
      int switch_count = 0;
      for (int sw : s.at(i)) {
        if (bit & (1 << sw)){
          switch_count++;
        }
      }
      if ((switch_count % 2) != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define SQ(a) (a)*(a)you
#define f first
#define s second
#define int long long
#define PB push_back
#define MP make_pair
#define db long double
#define all(a) a.begin(), a.end()
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define cases int testcases;cin>>testcases; while(testcases--)
#define mod 1000000007 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
      

    return (a.first<b.first); 
} 

int32_t main()
{
IOS



          int ans=0;

        string s;
        cin>>s;
        for(int i=0;i<s.length();i++)
        {
          if(s[i]=='0')
          {
            ans++;
          }
        }
        int ans2=s.length()-ans;
        cout<<2*min(ans,ans2);

    return 0;
    }
 

  

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  string s;cin>>s;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'o')cnt++;
  }
  cnt += 15-s.size();

  if(cnt >=8)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256