akhauriyash/Code-Regression huggingface dataset:
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;

long long nCm(long long n, long long m) {
	long long ans = 1;
	for (long long i = 1; i <= m; i++) {
		ans = ans * n / i;
		n--;
	}
	return ans;
}

int main() {
	vector<vector<int>>v(3, vector<int>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> v[i][j];
		}
	}
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (v[j][k] == n) {
					v[j][k] = 0;
				}
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		int check = 0;
		for (int j = 0; j < 3; j++) {
			check += v[i][j];
		}
		if (check == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	for (int i = 0; i < 3; i++) {
		int check = 0;
		for (int j = 0; j < 3; j++) {
			check += v[j][i];
		}
		if (check == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (v[0][0] + v[1][1] + v[2][2] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (v[0][2] + v[1][1] + v[2][0] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}


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

# In[30]:


abc = list(map(int, input().split()))


# In[32]:


abc_s = sorted(abc)
ones = abc_s[2] - abc_s[1]
twos = -(-(abc_s[2] - (abc_s[0]+ones))//2) + (abc_s[2] - (abc_s[0]+ones))%2
print(ones+twos)


# In[ ]:






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

int main(){
     long int A, B, C;
     long int ans;
     cin >> A >> B >> C;
     if(A+B>=C-1){
             ans=B+C;
     }else{
             ans=B+(A+B+1);
     }
     cout << ans << endl;
     return 0;
}


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

namespace _071_BombsChain
{
	class Program
	{
		const char Bomb = '1';
		const char Nothing = '0';

		const int Width = 8;
		const int Height = 8;

		static void Main ( string[] args )
		{
			int dataCount = int.Parse (Console.ReadLine ());

			char[][] map = new char[Height][];
			StringBuilder output = new StringBuilder (80 * dataCount);

			for (int i = 1; i <= dataCount; i++)
			{
				//input
				//delete space
				string space = Console.ReadLine ();
				space = space.Trim ();

				for (int lp = 0; lp < Height; lp++)
				{
					map[lp] = Console.ReadLine ().ToCharArray ();
				}

				int x = int.Parse (Console.ReadLine ());
				int y = int.Parse (Console.ReadLine ());

				//process
				Queue<Vector> bombPoint = new Queue<Vector> (10);
				bombPoint.Enqueue (new Vector (x - 1, y - 1));

				do
				{
					Vector item = bombPoint.Dequeue ();

					//bomb delete
					map[item.Y][item.X] = Nothing;

					//search bomb
					//top
					for (int top = item.Y - 1; top > item.Y - 1 - 3; top--)
					{
						if (0 <= top)
						{
							if (map[top][item.X] == Bomb)
							{
								bombPoint.Enqueue (new Vector (item.X, top));
							}
						}
						else
						{
							break;
						}
					}

					//left
					for (int left = item.X - 1; left > item.X - 1 - 3; left--)
					{
						if (0 <= left)
						{
							if (map[item.Y][left] == Bomb)
							{
								bombPoint.Enqueue (new Vector (left, item.Y));
							}
						}
						else
						{
							break;
						}
					}

					//right
					for (int right = item.X + 1; right < item.X + 1 + 3; right++)
					{
						if (right < Width)
						{
							if (map[item.Y][right] == Bomb)
							{
								bombPoint.Enqueue (new Vector (right, item.Y));
							}
						}
						else
						{
							break;
						}
					}

					//buttom
					for (int buttom = item.Y + 1; buttom < item.Y + 1 + 3; buttom++)
					{
						if (buttom < Height)
						{
							if (map[buttom][item.X] == Bomb)
							{
								bombPoint.Enqueue (new Vector (item.X, buttom));
							}
						}
						else
						{
							break;
						}
					}

				} while (bombPoint.Count != 0);


				output.Append ("Data " + i + ":");
				output.AppendLine ();

				for (int lp = 0; lp < Width; lp++)
				{
					output.Append (map[lp]);
					output.AppendLine ();
				}
			}

			//output
			Console.Write (output);
		}
	}

	class Vector
	{
		public Vector ( int x, int y )
		{
			this.X = x;
			this.Y = y;
		}

		public int X { private set; get; }
		public int Y { private set; get; }
	}
}

Measured memory_bytes: 10124
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;
	set<string> s;

	rep(i, N) {
		string S;
		cin >> S;
		s.insert(S);
	}

	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 19256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    string n;
    cin >> n;
    if(n=="A") cout << "T" << endl;
    if(n=="T") cout << "A" << endl;
    if(n=="C") cout << "G" << endl;
    if(n=="G") cout << "C" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int size = (n + 1) / 2;
        int[] array = new int[size];

        for (int i = 0; i < n; i++) {
            array[sc.nextInt() / 2]++;
        }

        if (n % 2 == 1 && array[0] != 1) {
            System.out.println(0);
            return;
        } else if (n % 2 == 0 && array[0] != 2) {
            System.out.println(0);
            return;
        }

        for (int i = 1; i < size; i++) {
            if (array[i] != 2) {
                System.out.println(0);
                return;
            }
        }

        int kaijo = n % 2 == 0 ? size : size - 1;

        System.out.println(pow(2, kaijo, 1000000007));
    }

    //return a^b mod M O(logB)
    private static long pow(long a, long b, int M) {
        long ret = 1;
        long tmp = a;
        while (b > 0) {
            if ((b & 1) == 1) ret = (ret * tmp) % M;
            tmp = (tmp * tmp) % M;
            b = b >> 1;
        }
        return ret;
    }
}

Measured memory_bytes: 48752
#include<stdio.h>

#define MAX 100

int main(){
	int n,i;
  char a[MAX],b[MAX];
  char answer[MAX*2];
  if(scanf("%d",&n)!=1) return -1;
  if(!scanf("%s%s",a,b)) return 1;
  for(i=0;i<n;i++){
    printf("%c%c",a[i],b[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while (true) {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        }

    }
}


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

int main()
{
	int N;
	cin >> N;
	vector<int64_t> a(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	int count = 0;
	for (int i = 0; i < N; ++i)
	{
		while (true)
		{
			if (a[i] % 2 != 0)
			{
				break;
			}

			++count;
			a[i] /= 2;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  const int P = 1000000007;
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> dp(k + 1, 0);
  dp[0] = 1;
  while (n--) {
    int a;
    scanf("%d", &a);
    for (int i = 1; i <= k; ++i)
      if ((dp[i] += dp[i - 1]) >= P)
        dp[i] -= P;
    for (int i = k; i > a; --i)
      if ((dp[i] -= dp[i - a - 1]) < 0)
        dp[i] += P;
  }
  printf("%d\n", dp[k]);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

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

#define INF  (int)1e9
#define LINF (long long)1e18

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

using Edge   = vector<vector<pair<int, int>>>; // src   -> dst, weight
using Vertex = vector<pair<int, bool>>;        // index -> cost, visited

int graph_bfs(const int&  start,
              const int&  goal,
              const Edge& edge,
              Vertex&     vertex) {
    queue<int> queue;
    queue.push(start);

    while(!queue.empty()) {
        auto src = queue.front();
        queue.pop();

        REP(i, edge[src].size()) {
            auto dst = edge[src][i].first;

            if(vertex[src].first + 1 < vertex[dst].first) {
                vertex[dst].first = vertex[src].first + 1;
                queue.push(dst);
            }
        }
    }

    return vertex[goal].first;
}

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

    int N, M;
    std::cin >> N >> M;

    Edge   edge(N * 3);
    Vertex vertex(N * 3, make_pair(INF, false));

    REP(i, M) {
        int l, r;
        std::cin >> l >> r;
        edge[(l - 1) * 3 + 0].emplace_back((r - 1) * 3 + 1, 0);
        edge[(l - 1) * 3 + 1].emplace_back((r - 1) * 3 + 2, 0);
        edge[(l - 1) * 3 + 2].emplace_back((r - 1) * 3 + 0, 0);
    }

    int S, T;
    std::cin >> S >> T;

    auto start = (S - 1) * 3;
    auto goal  = (T - 1) * 3;

    vertex[start].first = 0;
    auto min_move_cost = graph_bfs(start, goal, edge, vertex);
    if(min_move_cost == INF) {
        std::cout << -1 << std::endl;
    }
    else {
        std::cout << min_move_cost / 3 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 19072
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n, d;
	cin >> n >> d;

	int w = 2 * d + 1;
	cout << (n + w - 1) / w << endl;




	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int S, W; cin >> S >> W;
  auto ans = W >= S;
  cout << (ans ? "unsafe" : "safe") << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 3648
S = int(input())

simo = S%100
kami = S//100

if( 1 <= kami <= 12 and 1 <= simo <= 12 ):
  print('AMBIGUOUS')
elif( 1 <= kami <= 12 and not(1 <= simo <= 12) ):
  print('MMYY')
elif( not(1 <= kami <= 12) and 1 <= simo <= 12 ):
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;




int main() {
	int n;

	cin >> n;

	int candidate[] = {
		111,222,333,444,555,666,777,888,999
	};

	for (int i = 0; i < 9; i++) {
		if (candidate[i] >= n) {
			cout << candidate[i] << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    string s; cin >> s;
    int n = s.size();
    ll k; cin >> k;
    ll ans = 0;
    ll cnt = 0;
    bool t = true;
    rep(i,n){
        if (s[0] != s[i]){
            t = false;
            break;
        }
    }
    if (t){
        cout << n * k / 2 << endl;
        return 0;
    }
    char le = s[0];
    char ri = s[n-1];
    if (le == ri){
        int l = 0; int r = 0;
        rep(i,n){
            if (s[i] == le) l++;
            else break;
        }
        rep(i,n){
            if (s[n-1-i] == ri) r++;
            else break;
        }
        char c = '!';
        repp(i,n-r,l){
            if (s[i] != c) c = s[i];
            else {
                c = '!';
                cnt++;
            }
        }
        ans = cnt * k;
        ans += l / 2;
        ans += r / 2;
        ans += (r + l) / 2 * (k-1);
    }
    else {
        char c = '!';
        rep(i,n){
            if (s[i] != c) c = s[i];
            else {
                c = '!';
                cnt++;
            }
        }
        ans = cnt * k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a = [0 for _ in range(5)]

idx = 0
tmp = 9
for i in range(5):
    a[i] = int(input())
    if a[i] % 10 == 0:
        continue
    elif a[i] % 10 < tmp:
        idx = i
        tmp = a[i] % 10
        

ans = 0
for i in range(5):
    if a[i] % 10 == 0 or i==idx:
        ans += a[i]
    else:
        tmp = (a[i] // 10 + 1) * 10
        ans += tmp

print(ans)


Measured memory_bytes: 3064
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int l = 0;
    for(int i = 1; i < b - a; i++){
        l += i;
    }
    cout << l - a << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int n,m,c[200200];

int main()
{
  scanf ("%d %d",&n,&m);
  int s=0,p=0;
  while (m--){
int x; char S[10]; scanf ("%d %s",&x,S);
    if (S[0] == 'A'){
if (c[x] >= 0){
s++; p += c[x];
  c[x] = -1;
}
    }
    else{
if (c[x] >= 0) c[x]++;
    }
  }
  printf ("%d %d\n",s,p);
return 0;
}


Measured memory_bytes: 3552
//
// Union-Find tree (with rank)
//
// verified:
//   AOJ Course DSL_1_A Set - Disjoint Set: Union Find Tree
//     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp
//

// root(x): root node of x
// size(x): the size of the group of x


#include <iostream>
#include <vector>
#include <map>
using namespace std;

struct UnionFind {
    vector<int> par, rank;
    
    UnionFind(int n) : par(n , -1), rank(n, 0) { }
    void init(int n) { par.assign(n, -1), rank.assign(n, 0); }
    
    int root(int x) {
        if (par[x] == -1) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};


/* debug */
ostream& operator << (ostream& s, UnionFind uf) {
    map<int, vector<int> > res;
    for (int i = 0; i < uf.par.size(); ++i) {
        int r = uf.root(i);
        res[r].push_back(i);
    }
    for (map<int, vector<int> >::iterator it = res.begin(); it != res.end(); ++it) {
        s << endl;
        for (int j = 0; j < (int)it->second.size(); ++j) {
            s << it->second[j] << ", ";
        }
    }
    return s << endl;
}



int main() {
    int N, Q; cin >> N >> Q;
    UnionFind uf(N);
    for (int q = 0; q < Q; ++q) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) uf.merge(x, y);
        else {
            if (uf.issame(x, y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
        //cout << uf << endl;
    }
}


Measured memory_bytes: 3176
N = int(input())
x = {}
y = {}
h = {}
for i in range(N):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    x0, y0, h0 = x[i], y[i], h[i]
for cx in range(101):
  for cy in range(101):
    H = h0 + abs(cx - x0) + abs(cy - y0)
    for i in range(N):
      if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
        break
    else:
      print(cx, cy, H)
      break
    continue
  else:
    continue
  break

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

class Combination {
    vector<ll> factorial;
    vector<ll> fact_inverse;
    vector<ll> inverse;
    int mod;

    void init(int size) {
        factorial[0] = 1;
        factorial[1] = 1;
        fact_inverse[0] = 1;
        fact_inverse[1] = 1;
        inverse[1] = 1;

        for (int i = 2; i < size; i++) {
            factorial[i] = factorial[i - 1] * i % mod;
            inverse[i] = mod - inverse[mod % i] * (mod / i) % mod;
            fact_inverse[i] = fact_inverse[i - 1] * inverse[i] % mod;
        }
    }

    public:
        Combination(int size, int m) {
           factorial = vector<ll>(size);
           fact_inverse = vector<ll>(size);
           inverse = vector<ll>(size);
           mod = m;
           init(size);
        }
    
        ll calc(int n, int k) {
            if (n < k) {
                return 0;
            }
            if (n < 0 || k < 0) {
                return 0;
            }
            return factorial[n] * (fact_inverse[k] * fact_inverse[n - k] % mod) % mod;
        }
};

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    int u = h - a;
    int r = w - b;

    Combination c = Combination(h + w, MOD);
    
    ll ans = 0;
    REP(i, r) {
        ans += c.calc(u - 1 + i + b, u - 1) * c.calc(a - 1 + w - b - 1 - i, a - 1);
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
#define MOD 1000000007

#include <iostream>
using namespace std;

long pow(long a, long b) {
	if (b == 0) return 1;
	long c = pow(a, b / 2);
	if (b % 2) c = a * c % MOD * c % MOD;
	else c = c * c % MOD;
	return c;
}

long mod(long a) {
	a %= MOD;
	if (a < 0) a += MOD;
	return a;
}

int main() {
	long n, a, b;
	cin >> n >> a >> b;
	long c = 1, d = 1, e = 1, f = 1;
	for (long i = 0, j = n; i < a; i++, j--) c = c * j % MOD;
	for (long i = 0, j = n; i < b; i++, j--) d = d * j % MOD;
	for (long i = 1; i <= a; i++) e = e * i % MOD;
	for (long i = 1; i <= b; i++) f = f * i % MOD;
	long g = c * pow(e, MOD - 2) % MOD;
	long h = d * pow(f, MOD - 2) % MOD;
	cout << mod(mod(mod(pow(2, n) - g) - h) - 1);
}

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

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

  vector<int> X(M);
  for (int i = 0; i < M; i++) {
    cin >> X.at(i);
  }

  sort(X.begin(), X.end());

  vector<int> Y(M - 1);
  for (int i = 0; i < M - 1; i++) {
    Y.at(i) = X.at(i + 1) - X.at(i);
  }

  sort(Y.begin(), Y.end());
  reverse(Y.begin(), Y.end());

  int sum = 0;
  for (int i = 0; i < M - 1; i++) {
    if (N > 1) {
      N--;
    } else {
      sum += Y.at(i);
    }
  }

  cout << sum << endl;
}


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

const int INF = 1001001001;

vector<int> to[2505];
vector<int> rto[2505];
bool rf1[2505];
bool rtn[2505];
bool ok[2505];

void dfs(int v){
    if(rf1[v]) return;
    rf1[v] = true;
    for(int u : to[v]) dfs(u);
}

void rdfs(int v){
    if(rtn[v]) return;
    rtn[v] = true;
    for(int u : rto[v]) rdfs(u);
}

int main(){
    int n, m, p;
    cin >> n >> m >> p;
    vector<tuple<int,int,int>> es;
    rep(i,m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        c -= p;
        c = -c;
        es.emplace_back(a,b,c);
        to[a].push_back(b);
        rto[b].push_back(a);
    }
    dfs(0);
    rdfs(n-1);
    rep(i,n) ok[i] = rf1[i] & rtn[i];
    vector<int> d(n, INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while(upd){
        upd = false;
        rep(i,m){
            int a, b, c;
            tie(a,b,c) = es[i];
            if(!ok[a]) continue;
            if(!ok[b]) continue;
            int newD = d[a] + c;
            if(newD < d[b]){
                upd = true;
                d[b] = newD;
            }
        }
        step++;
        if(step > n){
            cout << -1 << endl;
            return 0;
        }
    }
    int ans = -d[n-1];
    ans = max(ans, 0);
    cout << ans << endl;
}

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

const int N = 2e5, M = 1e9 + 7;
int fact[N+1], ans[N], dp[N], sz[N], n;
vi g[N];

int add(int a, int b){ return a+b < M ? a+b : a+b-M; }
int sub(int a, int b){ return a-b >= 0 ? a-b : a-b+M; }
int mul(int a, int b){ return int(ll(a)*b % M); }
int pot(int b, int e){ // O(log e)
	if(!e) return 1;
	int q = pot(b,e/2); q = mul(q, q);
	return (e & 1 ? mul(b, q) : q);
}
int inv(int x){ return pot(x, M-2); } // Change M-2 for Phi(M)-1 if M isn't prime
int divide(int a, int b) { return mul(a, inv(b)); }

int dfs(int u=0, int p=-1) {
    int &x = dp[u] = 1, y = 1;
    for (int v : g[u]) if (v != p) {
        sz[u] += dfs(v, u);
        x = mul(x, dp[v]);
        y = mul(y, fact[sz[v]]);
    }
    x = mul(divide(x, y), fact[sz[u]-1]);
    return sz[u];
}

void reroot(int u=0, int p=-1) {
    if (u != 0) {
        int x = mul(ans[p], mul(fact[sz[u]], fact[n-sz[u]-1]));
        int y = mul(fact[sz[u]-1], fact[n-sz[u]]);
        ans[u] = divide(x, y);
    }
    for (int v : g[u]) if (v != p) reroot(v, u);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    fact[0] = 1;
    forsn(i, 1, N+1) fact[i] = mul(i, fact[i-1]);

    cin >> n;
    forn(i, n-1) {
        int x,y; cin >> x >> y, x--, y--;
        g[x].pb(y), g[y].pb(x);
    }
    forn(i, n) sz[i] = 1;
    dfs(), ans[0] = dp[0], reroot();
    forn(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 17012
S = input()
L = []
for i in range(4):
  if S[i] not in L:
    L.append(S[i])
flag = False
if len(L) == 2:
  t = 0
  for i in range(2):
    if S.count(L[i]) == 2:
      t += 1
  if t == 2:
    flag = True
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 100000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}



int main()
{
    string str;
    cin>>str;
    if(str=="ABC" ) cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}



















Measured memory_bytes: 3616
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=1000000+10,mo=1000000007;
int f[maxn*2],g[maxn*2];
int i,j,k,l,t,n,m,ans;
int main(){
    scanf("%d",&n);
    f[1]=1;
    fo(i,1,n){
        if (i>=3) (f[i]+=g[i-3])%=mo;
        (f[i]+=f[i-1])%=mo;
        g[i]=(g[i-1]+f[i])%mo;
    }
    fo(i,1,n-1) (ans+=(ll)f[i]*(n-1)%mo*(n-1)%mo)%=mo;
    fo(i,1,n-1) (ans+=(ll)f[i]*min(i+1,n-1)%mo)%=mo;
    (ans+=(ll)f[n]*n%mo)%=mo;
    (ans+=mo)%=mo;
    printf("%d\n",ans);
}

Measured memory_bytes: 10368
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int INF = 2000000000;
        int[] h = new int[N];
        long[] dp = new long[N + 1];
        for(int i=0;i<N;i++) {
            h[i] = sc.nextInt();
            dp[i] = INF;
        }
        dp[1] = 0;
        long reg;
        for(int i=2;i<N+1;i++){
            reg = INF;
            for(int j=1;j<Math.min(i, K+1);j++){
                reg = Math.min(reg, dp[i - j] + Math.abs(h[i - 1] - h[i - j - 1]));
            }
            dp[i] = reg;
        }
        System.out.println(dp[N]);
    }
}


Measured memory_bytes: 62084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll x = (n/(a+b));
    cout << x * a + min(a, n - x * (a+b)) << endl;
    return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS

#define FOR(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;



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

	int h, w;
	cin >> h >> w;
	REP(i, h) {
		REP(j, w) {
			string s;
			cin >> s;
			if ("snuke" == s) {
				printf("%c%d\n", 'A' + j, i + 1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  int A[N];
  rep(i,N) cin >> A[i];

  bool approved = true;
  rep(i,N){
    if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0){
      approved = false;
    }
  }
  if (approved) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int main() {
	int a[5], w, b[5], t[5], c, d, e, f, i, j, n;
	for (i = 0; i < 4; i++) {
		scanf("%d %d", &a[i], &t[i]);
	}
	for (i = 0; i < 4; i++) {
		if (a[i] == 1) {
			b[i] = t[i] * 6000;
		}
		if (a[i] == 2) {
			b[i] = t[i] * 4000;
		}
		if (a[i] == 3) {
			b[i] = t[i] * 3000;
		}
		if (a[i] == 4) {
			b[i] = t[i] * 2000;
		}
	}
	for (i = 0; i < 4; i++) {
		printf("%d\n", b[i]);
	}
}

Measured memory_bytes: 3148
N = gets.to_i
T = []
N.times do
  T << gets.to_i
end

def gcd(a, b)
  return a if b == 0
  gcd(b, a % b)
end

ans = 1
T.each do |t|
  m = gcd(ans, t)
  ans *= (t / m)
end

puts ans

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

vector<int> v,v2;
int A[200200];

int main(){
	int n,m,a,b;
	cin >> n >> m;
	
	for(int i=0;i<m;i++){
		cin >> a >> b;
		if(a==1) v.push_back(b);
		if(b==n) v.push_back(a);
	}
	
	
	for(int i=0;i<v.size();i++){
		A[v[i]]++;
	}
	
	for(int i=0;i<200200;i++){
		if(A[i]==2){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) int((x).size())

const int N=1e6+5,M=1e3+7,mod=1e9+7;

int dx[]={0,1,-1,0},
    dy[]={1,0,0,-1};
              

int a[N],b[N],n,m,k,tc,ans,d,x,y;

char s[N];

vector<pair<int,int> > g[N];

bool check(int mask){
    for(int i=1;i<=n;i++){
        if ( ! (mask & (1<<(i-1))) )
            continue;
        for(auto x:g[i]){
            if (!x.second){
                if (mask & (1 << (x.first-1)))
                    return false;
            }
            else{
                if (! (mask & (1 << (x.first-1))))
                    return false;
            }
        }

    }
    return true;
}

int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&m);
        while(m--){
            scanf("%d%d",&x,&y);
            g[i].push_back({x,y});
        }
    }
    for(int i=0;i< (1<<n) ;i++){
        if (check(i))
            ans=max(ans,__builtin_popcount(i));
    }
    printf("%d\n",ans);
}



Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define isA(x) ((x) < 0)
#define isB(x) ((x) >= 0)

typedef std::bitset <3001> bitset;
const int N = 6054;

int n;
int a[N], b[N], s[N];
char buf[N];
bitset f[N], mask;

inline int abs(int x) {return x ^ x >> 31;}
inline char get(int x) {return 98 + (x >> 31);}

char * parse(const bitset &B, char *ret) {
	for (int i = 0; i < 2 * n; ++i) if (B.test(abs(s[i]))) *ret++ = get(s[i]);
	return *ret = 0, ret;
}

inline void up(bitset &A, const bitset &B) {
	static char bufA[N], bufB[N];
	if (parse(A, bufA), parse(B, bufB), strcmp(bufA, bufB) < 0) A = B;
}

int main() {
	int i, j = 0, k = 0, r;
	scanf("%d%s", &n, buf);
	for (i = 0; i < 2 * n; ++i) s[i] = (buf[i] & 1 ? (a[j] = i, ~j++) : (b[k] = i, k++));
	f[n - 1].set(n - 1), mask.set(n - 1);
	for (i = n - 2; i >= 0; --i) {
		if (a[i] < b[i])
			r = *std::min_element(s + a[i], s + b[i]),
			assert(isA(r)), f[i] = f[-r], f[i].set(i);
		else {
			for (r = 0, j = b[i]; j < 2 * n; ++j) {
				if (isB(s[j])) f[i].set(s[j]), ++r;
				else if (~s[j] >= i) --r;
				if (!r) break;
			}
			f[i] |= f[abs(s[++j])];
		}
		up(f[i], f[i + 1]), mask.set(i);
	}
	return parse(*f, buf), puts(buf), 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main() {
  int n;cin>>n;vector<ll> a(100000);rep(i,n)cin>>a[i];
  sort(a.begin(), a.end(), greater<ll>());
  ll v1 = INF, v2 = INF;
  rep(i,n-1){
    if(a[i] == a[i+1] && v1 == INF){
      v1 = a[i];i++;
    }else if(a[i] == a[i+1] && v2 == INF){
      v2 = a[i];
    }
  }
  if(v2 == INF){
    cout << 0 << endl;
  }else{
    cout << v1 * v2 << endl;
  }
}


Measured memory_bytes: 1024
//E - Dist Max
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

#define LL long long
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(int i=A;i<=B;i++)
#define BOR(i,A,B) for(int i=A;i>=B;i--)
#define INF 0x3f3f3f3f
using namespace std;
const int MaxN=2e5+10;

int X[MaxN],Y[MaxN],Total,Ans;
int u,v;

inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}

int main() {
    // File();
    scanf("%d",&Total);
    FOR(i,1,Total) {
        scanf("%d %d",&u,&v);
        X[i]=u+v;
        Y[i]=u-v;
    }
    sort(X+1,X+Total+1);
    sort(Y+1,Y+Total+1);
    Ans=max(Ans,max(X[Total]-X[1],Y[Total]-Y[1]));
    cout<<Ans;
    // fclose(stdin);
    // fclose(stdout);
    //system("pause");
    return 0;
}

Measured memory_bytes: 5248
// Problem : B - Digits
// Contest : AtCoder Beginner Contest 156
// URL : https://atcoder.jp/contests/abc156/tasks/abc156_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
#define range(i, s, t)  for (int (i) = s; (i) <= (int)t; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
int main() {
	int n = qread(), m = qread();
	int cnt = 0;
	while (n) {
		n /= m;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    return a
  return gcd(b, a % b)

X = [0] * (n + 1)
Y = [0] * (n + 1)

for i in range(n):
  X[i+1] = gcd(X[i], A[i])
  Y[n-1-i] = gcd(Y[n-i], A[n-1-i])

gcds = []

for i in range(n):
  gcds.append(gcd(X[i], Y[i+1]))

print(max(gcds))


Measured memory_bytes: 14436
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
const ll mod=998244353;
int main()
{
	char s[100];
	cin>>s;
	int len=strlen(s);
	for(int i=0;i<len/2;i++)
	{
		if(s[i]==s[len-1-i])
		continue;
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=0;i<len/4;i++)
	{
		if(s[i]==s[len/2-1-i])
		continue;
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=len/2+1;i<len/2+1+len/4;i++)
	{
		if(s[i]==s[len+len/2-i])
		continue;
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-19 07:29:10
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

int dp[20][2];

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

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

  dp[0][0] = 0;
  dp[0][1] = -1e9;

  for (int i = 0; i < n; ++i) {
    int d = s[i] - '0';
    dp[i + 1][0] = dp[i][0] + d;
    dp[i + 1][1] = max(dp[i][0] + d - 1, dp[i][1] + 9);
  }

  cout << max(dp[n][0], dp[n][1]) << endl;

  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	s := readString()
	n := len(s)

	k := 1
	pre := 0
	r := make(map[int]int)
	r[0]++
	for i := n - 1; i >= 0; i-- {
		a, _ := strconv.Atoi(s[i : i+1])
		pre = (k*a + pre) % 2019
		k = k * 10 % 2019
		r[pre]++
	}

	ans := 0
	for _, v := range r {
		ans += v * (v - 1) / 2
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

int main() {
  int x, y;
  vector<vector<int> > a(3001, vector<int>(2));
  int count = 0;
  while (true) {
    cin >> x >> y;
    if (x == 0 && y == 0)
      break;
    else if (x <= y)
      a.at(count).at(0) = x, a.at(count).at(1) = y;
    else if (x > y)
      a.at(count).at(0) = y, a.at(count).at(1) = x;
    count++;
  }

  for (int i = 0; i < count; i++) {
    cout << a.at(i).at(0) << " " << a.at(i).at(1) << endl;
  }
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
vector<int>vt;
set<int>st;
map<int,int>mp;
unordered_map<string,int> umap; 
const long long MAX = 1e5;
const long long INF = 1e9;
const double pi = acos(-1);




int main() {

 int a;
 cin>>a;
string s;
cin>>s;
int l=s.length();
if(l<=a)
{
    cout<<s<<endl;
}
else if(l>a)
{
    for(int i=0;i<a;i++)
        cout<<s[i];

    cout<<"..."<<endl;
}


}

Measured memory_bytes: 3628