akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}
 
//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);
 
//.data
bool HasBit(ll x, int b) {
    return (x >> b) & 1;
}
 
class XorSet {
public:
    static constexpr int kMaxBit = 60;
 
    XorSet() : basis(kMaxBit, 0) {
    }
 
    void Insert(ll val) {
        if (size == 0) {
            return;
        }
        for (int b = 0; b < kMaxBit; ++b) {
            if (HasBit(val, b)) {
                if (basis[b] == 0) {
                    basis[b] = val;
                    ++size;
                    return;
                }
                val ^= basis[b];
            }
        }
    }
 
    int Size() const { return size; }
 
    bool Contains(ll val) {
        if (size == 0) {
            return false;
        }
        for (int b = 0; b < kMaxBit; ++b) {
            if (HasBit(val, b)) {
                if (basis[b] == 0) {
                    return false;
                }
                val ^= basis[b];
            }
        }
        return true;
    }
  
    void Init() { ++size; }

private:
    vector<ll> basis;
    int size = 0;
};
 
//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
 
    int test_cases;
    cin >> test_cases;
    while (test_cases--) {
        int n;
        cin >> n;
        vector<ll> arr(n);
        loop(n) {
            cin >> arr[i];
        }
        string s;
        cin >> s;
        if (s.back() == '1') {
            cout << 1 << endl;
            continue;
        }
        vector<XorSet> dp(n + 1);
        dp[n].Init();
        for (int i = n - 1; i >= 0; --i) {
            if (s[i] == '0') {
                dp[i] = dp[i + 1];
                dp[i].Insert(arr[i]);
            } else {
                if (dp[i + 1].Contains(arr[i])) {
                    dp[i] = dp[i + 1];
                }
            }
        }
        cout << !dp[0].Size() << endl;
    }
 
#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

int main(){
	int w, a, b;
	cin >> w >> a >> b;
	int ans=0;
	if(b>a+w) ans=b-a-w;
	if(b+w<a) ans=a-b-w;
	cout << ans << endl;
}


Measured memory_bytes: 3608
import math

N, D = list(map(int, input().split()))
X = [[0] * D for i in range(N)]
for n in range(N):
    X[n] = list(map(int, input().split()))

counter = 0
for n1 in range(N):
    for n2 in range(n1 + 1, N, 1):
        sum = 0
        for d in range(D):
            sum += (X[n1][d] - X[n2][d]) * (X[n1][d] - X[n2][d])
        sum = math.sqrt(sum)
        if sum == int(sum):
            counter += 1
print(counter)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) { return a < b ? a : b;}

int main(){
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);

  for(i = 1; i <= n ; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1; tail = n + 1;
 
 while(head != tail){
   u = dequeue();
   c = min(q,u.t);
   u.t -= c;
   elaps += c;
   if(u.t > 0) enqueue(u);
   else{
     printf("%s %d\n",u.name,elaps);
   }
 }

 return 0;
}



Measured memory_bytes: 12812
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, P;
  cin>>N>>P;
  string S;
  cin>>S;
  vector<ll> arr(S.size()+1);
  arr[0] = 0;
  ll num = 1;
  if(P==2) {
    ll ans = 0;
    for(ll i=0;i<S.size();++i) {
      if((S[i]-'0')%2==0) ans += i+1;
    }
    cout<<ans<<endl;
    return 0;
  }
  if(P==5) {
    ll ans = 0;
    for(ll i=0;i<S.size();++i) {
      if(S[i]=='0' || S[i]=='5') ans += i+1;
    }
    cout<<ans<<endl;
    return 0;
  }
  for(ll i=0;i<N;++i) {
    arr[i+1] = (arr[i]+num*(S[N-1-i]-'0'))%P;
    //arr[i+1] = (arr[i+1]+P)%P;
    num *= 10;
    num %= P;
  }
  /**
  for(ll i=0;i<=N;++i) cout<<arr[i]<<" ";
  cout<<endl;
  **/
  map<ll, ll> amap;
  vector<ll> arr1;
  for(ll i=0;i<=N;++i) {
    if(amap[arr[i]]==0) arr1.push_back(arr[i]);
    amap[arr[i]]++;
  }
  ll ans = 0;
  for(ll i=0;i<arr1.size();++i) {
    ans += amap[arr1[i]]*(amap[arr1[i]]-1)/2;
  }
  cout<<ans<<endl;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n;

int main()
{
    cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++){
            string str;
        cin >> str;
        s.insert(str);
    }
    cout << s.size() << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  N--;

  int C[N], S[N], F[N];
  for (int i = 0; i < N; i++) {
    cin >> C[i] >> S[i] >> F[i];
  }

  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = i; j < N; j++) {
      if (sum < S[j]) {
        sum = S[j];
      }
      if (sum % F[j]) {
        sum += F[j] - (sum % F[j]);
      }
      sum += C[j];
    }
    cout << sum << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void) {
  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1!=m2) {
    cout << "1" << endl;
  }else {
    cout << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,i,a[100];
	
	scanf("%d", &n);
	for(i = 0; i < n; i++){
	    scanf("%d", &a[i]);
	}
	
	for(i = n - 1; i >= 0; i--){
	    if(i != n - 1){
		printf(" ");
		}
		printf("%d", a[i]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  string s;
  cin >> n >> s;
  vector<int> e(n), w(n);
  rep(i, 0, n) {
    if (s[i] == 'E') {
      if (i)
        e[i] = e[i - 1] + 1;
      else
        e[i] = 1;
    } else
      e[i] = e[i - 1];
  }

  repr(i, 0, n) {
    if (s[i] == 'W') {
      if (i < n - 1)
        w[i] = w[i + 1] + 1;
      else
        w[i] = 1;
    } else
      w[i] = w[i + 1];
  }

  int ans = 1e9 + 7;
  rep(i, 0, n) { chmin(ans, (e[n - 1] - e[i]) + (w[0] - w[i])); }

  cout << ans << endl;
}


Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb(x) { push_back(x); }
 
 
void solve()
{
	char a;
	
	cin>>a;
	if(a>=65 && a<=90) 
		cout<<"A"<<endl;
	else
		cout<<"a"<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

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

int main()
{
    int N;
    cin >> N;
    int t[N + 1] = {};
    int x[N + 1] = {};
    int y[N + 1] = {};
    string ans = "Yes";
    for (int i = 1; i <= N; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
        int distance = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        if (distance > (t[i] - t[i - 1]) || abs(distance - (t[i] - t[i - 1])) % 2 == 1)
        {
            ans = "No";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<cstdio>

template<typename t>
t max(t *a)
{
   t max=0;
   for(int i=0;a[i]!=0;i++){
     if(a[i]>max) max=a[i];
  }
  return max;
}

template<typename t>
t sum(t *a)
{
  t ans=0;
  for(int i=0;a[i]!=0;i++){
    ans +=a[i];
  }
  return ans;
}

int main()
{
  int n;
  int p[11]={0};

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

  int answer = sum(p)-max(p)/2;
  std::cout<<answer<<std::endl;


}


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

int arr[500001];

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

	string s;
	int n;

	cin >> s;

	n = s.length();

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

	bool flag = false;
	int len = 0;

	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='>')
		{
			if(flag==false)
			{
				len = 1;
				flag = true;
			}
			else
			{
				len++;
			}
			arr[i] = len;
		}
		else
		{
			if(flag==true)
			{
				flag = false;
			}
		}
	}

	long long int res = 0;
	int now = 0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='<')
		{
			now++;
			res += now;
		}
		else
		{
			if(now >= arr[i])
			{
				now = arr[i];
			}
			else
			{
				res += abs(now-arr[i]);
				now = arr[i];
			}
			now--;
			res += now;
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 2844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int N;
   vector<double> x;
   vector<string> u;
   cin >> N;
   for(int i=0; i < N; i++){
      double x_tmp;
      string u_tmp;
      cin >> x_tmp >> u_tmp;
      x.push_back(x_tmp);
      u.push_back(u_tmp);
   }

   double sum_jpy = 0;
   double sum_btc = 0;
   for(int i=0; i < N; i++){
      if(u[i] == "JPY"){
         sum_jpy += x[i];
      }
      else if(u[i] == "BTC"){
         sum_btc += x[i] * 380000;
      }
   }
   cout << sum_jpy + sum_btc << endl;




   return 0;
}

Measured memory_bytes: 888
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Scanner{
  string[] s;
  int i;
 
  char[] cs = new char[] { ' ' };
 
  public Scanner(){
    s = new string[0];
    i = 0;
  }
 
  public string next(){
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    if (s.Length == 0) return next();
    i = 0;
    return s[i++];
  }
 
  public int nextInt(){
    return int.Parse(next());
  }
  public int[] ArrayInt(int N, int add = 0){
    int[] Array = new int[N];
    for (int i = 0; i < N; i++){
      Array[i] = nextInt() + add;
    }
    return Array;
  }
 
  public long nextLong(){
    return long.Parse(next());
  }
 
  public long[] ArrayLong(int N, long add = 0){
    long[] Array = new long[N];
    for (int i = 0; i < N; i++){
      Array[i] = nextLong() + add;
    }
    return Array;
  }
 
  public double nextDouble(){
    return double.Parse(next());
  }

  public double[] ArrayDouble(int N, double add = 0){
    double[] Array = new double[N];
    for (int i = 0; i < N; i++){
      Array[i] = nextDouble() + add;
    }
    return Array;
  }
}

public class procon {
  public procon(){}
  
  Scanner cin;
  public static int Main(){
    new procon().calc();
    return 0;
  }
  
  void calc(){
    cin=new Scanner();
    int N=cin.nextInt();
    int K=cin.nextInt();
    
    bool[] D=new bool[10];
    for(int i=0; i<10; ++i) D[i]=true;
    for(int i=0; i<K; ++i){
      int d=cin.nextInt();
      D[d]=false;
    }
    
    int ans=N;
    while(true){
      bool can=true;
      int tmp=ans;
      while(tmp>0){
        can&=D[tmp%10];
        tmp/=10;
      }
      if(can){
        Console.WriteLine(ans);
        break;
      }
      else{
        ++ans;
      }
    }
  }
}



















Measured memory_bytes: 11092
n, k = gets.chomp.split
ds = gets.chomp.split.map(&:to_i)
memo = [true] * 10
for d in ds
  memo[d] = false
end

n = n.to_i
while true
  s = n.to_s
  ok = true
  s.chars.each{|c|
    idx = c.to_i
    if not memo[idx]
      ok = false
    end
  }
  if ok
    puts s
    break
  end
  n += 1
end


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5;
int n,m,a[N+5];
int main()
{
    cin>>n;
    for (int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    ll ans1=0;
    int minus2=(n-1)/2;
    int plus2=(n-2)/2;
    int plus1=n%2 ? 2 : 1;
    int minus1=2-plus1;
    for (int i=0;i<n;i++)
    {
        if (minus2)
        {
            minus2--;
            ans1-=2*a[i];
        }
        else if (minus1)
        {
            minus1--;
            ans1-=a[i];
        }
        else if (plus1)
        {
            plus1--;
            ans1+=a[i];
        }
        else ans1+=2*a[i];
    }
    ll ans2=0;
    minus2=(n-2)/2;
    plus2=(n-1)/2;
    plus1=n%2 ? 0 : 1;
    minus1=2-plus1;
    for (int i=0;i<n;i++)
    {
        if (minus2)
        {
            minus2--;
            ans2-=2*a[i];
        }
        else if (minus1)
        {
            minus1--;
            ans2-=a[i];
        }
        else if (plus1)
        {
            plus1--;
            ans2+=a[i];
        }
        else ans2+=2*a[i];
    }
    cout<<max(ans1,ans2);
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n, ans = 0; cin >> n;
    char color, pre_color = '0';
    for (int i = 0; i < n; i++)
    {
        cin >> color;
        if (pre_color != color)
            ans++;
        pre_color = color;
    }
    cout << ans << endl;
}

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

int main(){
  int n,i,j;
  cin>>n;
  int h[n];
  for(i=0;i<n;i++)cin>>h[i];
  int cnt=n;
  for(i=1;i<n;i++){
    for(j=0;j<i;j++){
      if(h[i]<h[j]){
        cnt--;
        break;
      }
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 256
# 2019/07/14

from collections import Counter


class unionfind():
    def __init__(self,n):
        self.par=list(range(n+1))
        self.rank=[0]*(n+1)
    def find(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def is_same(self,x,y):
        return self.find(x)==self.find(y)
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1


n,k,l=map(int,input().split())

uf1=unionfind(n)
uf2=unionfind(n)

for i in range(k):
    p,q=map(int,input().split())
    uf1.unite(p,q)

for i in range(l):
    r,s=map(int,input().split())
    uf2.unite(r,s)

res=[]

for i in range(n+1):
    tmp=(uf1.find(i),uf2.find(i))
    res.append(tmp)
c=Counter(res)
ans=[]
for i in range(n+1):
    ans.append(c[res[i]])
print(*ans[1:])


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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i=0; i<=a; i++) {
    for(int j=0; j<=b; j++) {
      for(int k=0; k<=c; k++) {
        int temp = 500*i + 100*j + 50*k;
        if(temp == x) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1e18 : 1e9;
const int MOD = 1000000007;
const long double EPS = 1e-8;

int main() {
	int n;
	while(cin >> n, n) {
		map <pair <int, int>, bool> mp;
		rep (i, n) {
			int x, y;
			cin >> x >> y;
			mp[make_pair(x, y)] = true;
		}
		int m;
		cin >> m;
		pair <int, int> now = {10, 10};
		set <pair <int, int>> st;
		if (mp.find({10, 10}) != mp.end()) st.insert({10, 10});
		rep (i, m) {
			char d;
			int l;
			cin >> d >> l;
			rep (j, l) {
				if (d == 'N') now.second += 1;
				if (d == 'S') now.second -= 1;
				if (d == 'W') now.first -= 1;
				if (d == 'E') now.first += 1;
				if (mp.find(now) != mp.end()) st.insert(now);
			}
		}
		cout << (st.size() == n ? "Yes" : "No") << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
'use strict';
(function(stdin) {
  var lines = stdin.toString().split('\n')[0];
  var result = (function(data) {
    var p1 = { x : data[0],y : data[1] };
    var p2 = { x : data[2],y : data[3] };

    return Math.sqrt(
      Math.pow(p1.x - p2.x,2) 
      + Math.pow(p1.y - p2.y,2));

  }(
    lines.split(' ').map(parseFloat)
  ));

  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,i,ans,L,max,sum;
    ans=0;
    max=0;
    sum=0;
    cin >> N ;
    for(i=0;i<N;i++){
        cin >> L;
        sum+=L;
        if(max<L) max=L;
    }
    ans=sum-max;
    if (max<ans)
    cout << "Yes" <<endl;
    else cout << "No" << endl;
}

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

int main(int argc, char const* argv[]){
    int w,h,n;cin>>w>>h>>n;
    vector<int> x(n),y(n),a(n);
    for (int i = 0; i < n; i++) {
        cin>>x[i]>>y[i]>>a[i];
    }

    int xi=0,xj=w,yi=0,yj=h;
    for (int i = 0; i < n; i++) {
        if(a[i] == 1 && xi<x[i]){
            xi = x[i];
        }else if (a[i] == 2 && xj>x[i]) {
            xj = x[i];
        }else if (a[i] == 3 && yi<y[i]){
            yi = y[i];
        }else if (a[i] == 4 && yj>y[i]){
            yj = y[i];
        }
    }
    if(xj<xi || yj<yi || w < xj-xi || h < yj-yi)cout<<"0"<<endl;
    else cout << (xj-xi) * (yj-yi) << endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i = (n); i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(1e6+5);

void pre() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int a,b,c,k;  cin>>a>>b>>c>>k;

  int cnt = 0;
  while(a >= b)  {
    cnt++;
    b *= 2;
  }
  while(b >= c) {
    cnt++;
    c *= 2;
  }
  if(cnt > k) cout<<"No";
  else  cout<<"Yes";

}

int main() {
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  pre();
  int t = 1;
  //cin>>t;
  rep(i,t)  {
    //cout<<"Case #"<<(i+1)<<": ";
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3652
def is_prime(num):
    limit = int(num ** 0.5) + 1
    for i in range(2, limit):
        if num % i == 0:
            return False
    return True


n = int(input())
ans = [2, 7, 17]

for num in range(27, 55555, 10):
    if is_prime(num):
        ans.append(num)

    if len(ans) == n:
        break

print(' '.join(map(str, ans)))


Measured memory_bytes: 3060
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF = 1e9;
#define MOD = 1e9+7;
#define INF64 = 1e18;


using namespace std;

int main() {

	SINT32 N = 0;
	cin >> N;
	SINT32 ANS = 1;
	
	rep(i,2,N) {
		SINT32 j = 2;
		while (pow(i,j) <= N) {
			ANS = MAX(ANS,pow(i,j));
			j++;
		}
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 384
n = int(input())
alist = list(map(int, input().split(" ")))
q = int(input())

master = [0 for i in range(100001)]
total = sum(alist)

for a in alist:
  master[a] += 1
for i in range(q):
  b,c = map(int, input().split(" "))
  d = master[b]
  master[b] = 0
  master[c] += d
  total -= b*d
  total += c*d
  print(total)

Measured memory_bytes: 21032
N = int(input())
R = int(input())

max = 0
maxcounter = 0
j = 1

for i in range(N):
  # counter = 0
  # while j > 1:
  if j * 2 <= j + R:
    j = j * 2
    # counter += 1
  else:
    j = j + R
 
print(j)

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " ";cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 2e5 + 3;
int cnt[N];
int n, m, K;
char grid[15][1005];
int mat[15][1005];

int help(vi &v, int mask)
{
	int j = 1, x = v.size();
	int sum[x];
	mset(sum, 0);
	int start = 1;
	int f = 1;
	int cnt = 0;
	while ( j <= m )
	{
		int prev = 0;
		int temp = 1;
		loop(k, 0, x)
		{
			sum[k] += (mat[v[k]][j] - mat[prev][j]);
			if (sum[k] > K) temp = 0;
			prev = v[k];
		}

		if (temp) j++;
		else
		{
			if (start == j)
			{
				f = 0;
				break;
			}
			else start = j;
			cnt++;
			mset(sum, 0);
		}
	}


	if (f) return cnt;
	else return -1;


}


void solve()
{
	cin >> n >> m >> K;
	loop(i, 1, n + 1)
	{
		loop(j, 1, m + 1) cin >> grid[i][j];
	}

	loop(j, 1, m + 1)
	{
		loop(i, 1, n + 1)
		{
			if (grid[i][j] == '1')
				mat[i][j] = mat[i - 1][j] + 1;
			else mat[i][j] = mat[i - 1][j];
		}
	}
	int ans = INT_MAX;
	loop(mask, 0, (1 << n))
	{

		vi v;
		loop(j, 0, n - 1)
		{
			if ( mask & (1 << j) ) v.pb(j + 1);

		}
		v.pb(n);
		int a1 = help(v, mask) ;
		if (a1 >= 0) ans = min(ans, a1 + __builtin_popcount(mask));


	}
	cout << ans << endl;
	return;


}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	//cout << setprecision(9) << fixed;
	clock_t z = clock();
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Measured memory_bytes: 384
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
// header
ll n,k;
vector<ll> a;
map<ll,ll> mp;
void input(){
    cin>>n;
    scan(n,a);
}
void src(){
    mp[0]++;
    ll sum=0;
    rep(i,n){
        sum+=a[i];
        mp[sum]++;
    }
    ll ans=0;
    for(auto m:mp){
        ans+=m.second*(m.second-1)/2;
    }
    cout<<ans;
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
   // ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 14336
import           System.IO
import           Text.Printf
import           Data.List
import           Control.Monad

sosuExe :: [Int] -> [Int]
sosuExe (x : tail) = x : (sosuExe $ filter (\n -> mod n x /= 0) tail)

sosus = sosuExe [2 ..]

yakus :: Int -> [Int]
yakus 1 = []
yakus n = x : next
 where
  x = case filter (\a -> mod n a == 0) $ filter (\a -> n >= a) sosus of
    []      -> n
    (w : _) -> w
  next = if x == n then [] else yakus $ div n x

rmi :: Eq a => Int -> [a] -> [a]
rmi n xs = let (h, t) = splitAt n xs in h ++ tail t

interL :: Eq a => [a] -> [a] -> [a]
interL [] _        = []
interL _  []       = []
interL ls (r : rs) = case elemIndex r ls of
  Just x  -> ls !! x : interL (rmi x ls) rs
  Nothing -> interL ls rs

diffL :: Eq a => [a] -> [a] -> [a]
diffL [] _        = []
diffL ls []       = ls
diffL ls (r : rs) = case elemIndex r ls of
  Just x  -> diffL (rmi x ls) rs
  Nothing -> ls

main = do
  (l : r : _) <- fmap (map (yakus . read) . words) getLine
  let res = interL l r
  putStrLn $ printf "%d %d"
                    (product res)
                    (product $ (diffL l res) ++ (diffL r res) ++ res)
  eof <- isEOF
  unless eof $ main



Measured memory_bytes: 5176
(N, M), *ABs = readlines.map{_1.split.map(&:to_i)}

@p = Array.new(N + 1, -1)

def root(x)
  @p[x] < 0 ? x : @p[x] = root(@p[x])
end

def unite(x, y)
  x, y = root(x), root(y)
  if x != y
    x, y = y, x if @p[y] < @p[x]
    @p[x] += @p[y]
    @p[y] = x
  end
end

ABs.each{unite(_1, _2)}
puts -@p.drop(1).min

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


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    ll ans;
    ans = n*(n-1)/2;
    cout<< ans <<endl;
    return 0;
}


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

#define fastIO                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define here cout << "here\n" // debug
#define int long long int
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sl(x) cin >> x
#define pfl(x) printf("%lld\n", x)
#define pf printf //debug
#define mod 1000000007
#define modu(x) x % 1000000007
#define isEqualf(a, b) (abs(a - b) < 1e-9) // comapre 2 float nums
#define inputVec(v, n)        \
  for (int i = 0; i < n; i++) \
  {                           \
    int d;                    \
    sl(d);                    \
    v[i] = d;                 \
  }
#define loop(i, n) for (; i < n; i++)

int32_t main()
{
  fastIO;

  double ans;
  double sum = 0;
  int n, a;
  sl(n);
  int i = 0;
  loop(i, n)
  {
    sl(a);
    sum = sum + (1.0 / a);
  }
  ans = 1 / sum;
  printf("%lf\n", ans);
  return 0;
}

Measured memory_bytes: 256
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

   ll n;
   cin>>n;

   ll x=n/1000;
   x=(x+1)*1000;

   ll s=abs(n-x);

   if (s==1000)
    cout<<0;
   else
    cout<<s;

return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 100005;
int vis[MAXN], cnt[5], clr[MAXN], n, m, flag;
vector<int> A[MAXN], B[MAXN];

void dfs(int u, int c) {
	vis[u] = 1, clr[u] = c, ++cnt[c], ++cnt[3];
	for (int v : A[u]) {
		++cnt[4];
		int d = (c + 1) % 3;
		if (vis[v] && clr[v] != d) flag = 1;
		else if (!vis[v]) dfs(v, d);
	}
	for (int v : B[u]) {
		int d = (c + 2) % 3;
		if (vis[v] && clr[v] != d) flag = 1;
		else if (!vis[v]) dfs(v, d);
	}
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int u, v; scanf("%d%d", &u, &v);
		A[u].push_back(v);
		B[v].push_back(u);
	}
	LL res = 0;
	for (int i = 1; i <= n; i++) if (!vis[i]) {
		flag = 0;
		memset(cnt, 0, sizeof(cnt));
		dfs(i, 0);
		int c = 0;
		for (int i = 0; i < 3; i++) c += !cnt[i];
		if (flag) res += (LL)cnt[3] * cnt[3];
		else if (c) res += cnt[4];
		else res += (LL)cnt[0] * cnt[1] + (LL)cnt[1] * cnt[2] + (LL)cnt[0] * cnt[2];
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 16640
using System;
using System.Text;

namespace Simultaneous_Equation
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();


            while (true)
            {
                string str = Console.ReadLine();
                if (str == null)
                {
                    break;
                }
                double[] input = Array.ConvertAll(str.Split(' '), double.Parse);
                input[1] = input[1] / input[0];
                input[2] = input[2] / input[0];

                input[4] = input[4] - input[3] * input[1];
                input[5] = input[5] - input[3] * input[2];

                input[5] = input[5] / input[4];
                input[2] = input[2] - input[5] * input[1];
                sb.AppendLine(string.Format("{0:f3} {1:f3}", input[2], input[5]));
            }
            sb.Remove(sb.Length - 1, 1);
            Console.WriteLine(sb);




        }
    }
}



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

int main(){
    int x;
    cin >> x;
    cout << (x/500)*1000 + ((x%500)/5)*5 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void B();

int main()
{
	B();
	fflush(stdout);
	return 0;
}

static void B()
{
	int N;
	get(N);
	int ai, ans = 0;
	for (int i = 1; i <= N; i++) {
		get(ai);

		if (i % 2 && ai % 2) ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3688
#include<stdio.h>

int main(void)


{


int a,b,d,r;


double f=0;


scanf("%d",&a);


scanf("%d",&b);


d=a/b;


r=a%b;


f=(double)a/(double)b;


printf("%d %d %lf\n",d,r,f);


return 0;


}

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

using namespace std;

const int N = 1<<18;
int a[N];
array<int,2> v[N];
void upd(int i,int u)
{
	if (u<0||v[i][0] == u || v[i][1] == u)
		return;
	if (v[i][0] == -1)
		v[i][0] = u;
	else if (v[i][1] == -1) {
		v[i][1] = u;
		if(a[v[i][1]] > a[v[i][0]])
			swap(v[i][0], v[i][1]);
	}
	else if(a[u] > a[v[i][0]])
		v[i][1] = v[i][0], v[i][0] = u;
	else if(a[u] > a[v[i][1]]) 
		v[i][1] = u;
}
int main()
{
	int n, ans=0;
	cin >> n;
	fill_n(v, 1<<n,array<int,2>{-1, -1});
	for(int i=0;i<(1<<n);i++) {
		cin >> a[i];
		upd(i,i);
		if (i) {
			ans = max(ans, a[v[i][0]] + a[v[i][1]]);
			cout << ans << '\n';
		}
		for (int j=1;j<(1<<n);j<<=1)
			if ((i|j) > i)
				for (int u : v[i])
					upd(i|j,u);
	}
}


Measured memory_bytes: 6144
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
// #include <fstream>//ifstream/ofstream
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>

#define PRIME_SHORT 10007
#define PRIME 1000000007

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;

int main(void) {
    int k, s;
    cin >> k >> s;
    ull total = 0UL;
    for (int x = 0; x <= min(k,s); ++x)
    {
        int sx = s - x;
        for (int y = 0; y <= min(k,sx); ++y)
        {
            if (sx - y <= k) ++total;
        }
    }

    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple


signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int x;
	cin >> x;
	cout << 3 * x * x << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int N=gi();
        int M=gi();
        int X=gi();
        int Y=gi();
        int[] xa = new int[N];
        int[] ya = new int[M];
        for (int i=0; i<N; i++) {
        	xa[i]=gi();
        }
        for (int i=0; i<M; i++) {
        	ya[i]=gi();
        }
        Arrays.parallelSort(xa);
        Arrays.parallelSort(ya);

        if (xa[xa.length-1]<ya[0] && xa[xa.length-1]<Y && ya[0]>X) {
           System.out.println("No War");
	    } else {
	    	System.out.println("War");
	    }
//        if (a>0) {
//        	System.out.println("Yes");
//        }else {
//        	System.out.println("No");
//        }
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35760
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int ans=1;
    while(pow(k,ans)<=n){
        ans++;
    }
    cout<<ans;
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	map<string, long long int> mp;
	for(int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}

	long long int ans = 0;
	for(auto& p : mp)
	{
		long long int k = p.second;
		ans += (long long int)(k * (k-1) / 2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
n, q = map(int, input().split())
s = list(input())
ls = len(s)
for i in range(0, ls):
    if (s[i] == "A"):
        if (i != ls-1)and(s[i + 1] == "C"):
            s[i] = "a"

anum = [0]
for i in range(1, ls):
    if (s[i - 1] == "a"):
        anum.append(anum[i - 1] + 1)
    else:
        anum.append(anum[i - 1])

for i in range(q):
    l, r = map(int, input().split())
    print(anum[r-1]-anum[l-1])


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

string S, p;
int ans;

int main() {
	cin >> S;
	string cur = "";
	for (int i = 0; i < S.length(); i++) {
		cur += S[i];
		if (p != cur) {
			p = cur;
			cur = "";
			ans++;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 640
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	s, t := scanString(sc), scanString(sc)
	matched := false
slip:
	for i := 0; i < len(s); i++ {
		for j := 0; j < len(s); j++ {
			if s[(i+j)%len(s)] != t[j%len(s)] {
				continue slip
			}
		}
		matched = true
	}
	if matched {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	return
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> P;

const ll MOD = 1e9+7;

template <ll MOD>
struct modint{
    ll x;
    modint() : x(0) {}
    modint(ll a): x((a % MOD + MOD) % MOD) {}
    
    

    bool operator!() const{return !x;}

    bool operator<(const modint &a) const{
        modint res(*this);
        return res.x < a.x;
    }
    
    bool operator>(const modint &a) const{
        modint res(*this);
        return res.x > a.x;
    }

    modint &operator+=(const modint &a){
        if((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    modint &operator-=(const modint &a){
        if((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    modint &operator*=(const modint &a){
        (x *= a.x) %= MOD;
        return *this;
    }

    modint &operator/=(const modint &a){
        *this *= a.inv();
        return *this;
    }

    modint &operator%=(const modint &a){
        x %= a.x;
        return *this;
    }

    modint operator-() const{ return modint(-x); }

    modint operator+(const modint &a) const{ return modint(*this) += a; }
    modint operator-(const modint &a) const{ return modint(*this) -= a; }
    modint operator*(const modint &a) const{ return modint(*this) *= a; }
    modint operator/(const modint &a) const{ return modint(*this) /= a; }
    modint operator%(const modint &a) const{ return modint(*this) %= a; }
    bool operator==(const modint &a) const{ return x == a.x; }
    bool operator!=(const modint &a) const{ return x != a.x; }


    modint pow(ll n) const{
        modint res(1), a(x);
        while(n > 0){
            if(n & 1) res *= a;
            a *= a;
            n /= 2;
        }
        return res;
    }

    modint inv() const{
        ll a = x,b = MOD,u = 1,v = 0;
        while(b){
            ll t = a/b;
            a -= t*b; swap(a,b);
            u -= t*v; swap(u,v);
        }
        u %= MOD;
        if(u < 0) u += MOD;
        return modint(u);
    }

    friend ostream &operator<<(ostream &os, const modint &m){
        return os << m.x;
    }

    friend istream &operator>>(istream &is, modint &m){
        ll t;
        is >> t;
        m = modint<MOD>(t);
        return (is);
    }
    
    static ll get_mod(){ return MOD; }
};
using mint = modint<MOD>;

  int main(){
    ll h,w,k;
    cin >> h >> w >> k;

    mint dp[h+1][w];
    
    rep(i,0,h+1) rep(j,0,w) dp[i][j] = 0;
    dp[0][0] = 1;
 

    rep(i,0,h){
      rep(j,0,w){
        rep(l,0,pow(2,w-1)){
          ll temp = l;
          bool flag = false;

          rep(m,0,w-2) if((temp >> m) & 1  && (temp >> m+1) & 1) flag = true;
          if(flag) continue;


          if(j > 0 && (temp >> j-1) & 1 ) dp[i+1][j-1] += dp[i][j];
          else if(j < w-1 && (temp >> j) & 1 ) dp[i+1][j+1] += dp[i][j];
          else dp[i+1][j] += dp[i][j];
        }
        
      }
    }

    cout << dp[h][k-1] << endl;
    
    

    return 0;
  }

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

  int i,j,k;
  int house[4][3][10];
  int n;
  int tou,kai,heya,num;


  for(i = 0; i < 4;i++){
    for(j = 0;j < 3;j++){
      for(k = 0;k < 10;k++){
	house[i][j][k] = 0;
	  }
    }
  }
  
  scanf("%d",&n);

  for(i = 0; i < n;i++){
    scanf("%d %d %d %d",&tou,&kai,&heya,&num);
    house[tou-1][kai-1][heya-1] += num;
  }

    for(i = 0; i < 4;i++){
    for(j = 0;j < 3;j++){
      for(k = 0;k < 10;k++){
	printf(" %d",house[i][j][k]);
	  }
      printf("\n");
    }
    if(i != 3){
      printf("####################\n");
    }
   
    }
    return 0;
}

Measured memory_bytes: 612
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	int x = stdin.nextInt();
	int y  = stdin.nextInt();
	if(x<y){
	    System.out.println("a < b");
	}
	else if(x>y){
	    System.out.println("a > b");
	}
	else {
	    System.out.println("a == b");
	};
    }
}

Measured memory_bytes: 25996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[101];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    int  v=a[i];
    int  j= i-1;
    while(j>=0&&a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    for(int k=0;k<n;k++){
      cout << a[k];
      if(k!=n-1)cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

class Main { 
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    int[] numbers = new int[N];
    for (int i = 0; i < N; i++) {
      numbers[i] = in.nextInt();
    }
    int count = selectionSort(numbers);
    trace(numbers);
    System.out.println(count);
  }
  
  public static int selectionSort(int[] array) {
    int count = 0;
    for (int i = 0; i < array.length; i++) {
      int mini = i;
      for (int j = i; j < array.length; j++) {
        if (array[j] < array[mini]) mini = j;
      }
      if (mini != i ) {
        swap(array, i, mini);
        count++;
      }
    }
    return count;
  }
  
  public static void swap(int[] array, int p, int q) {
    int temp = array[p];
    array[p] = array[q];
    array[q] = temp;
  }
  
  public static void trace(int[] array) {
    StringBuilder output = new StringBuilder();
    for (int i = 0; i < array.length; i++) {
      output.append(array[i]);
      if (i != array.length -1) output.append(" ");
    }
    System.out.println(output.toString());
  }
}

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

#define MAX_N 1000

int N, T, A, i;
int H[MAX_N];

double caltmp(int h) {
  return T - h*0.006;
}

int main() {
  scanf("%d", &N);
  scanf("%d %d", &T, &A);
  for (i = 0; i < N; i++) {
    scanf("%d", &H[i]);
  }
  double delt = fabs(A-caltmp(H[0]));
  int ans = 0;
  for (i = 1; i < N; i++) {
    if (fabs(A-caltmp(H[i])) < delt) {
      delt = fabs(A-caltmp(H[i]));
      ans = i;
    }
  }
  printf("%d", ans+1);
  return 0;
}


Measured memory_bytes: 256