akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[1005],b[1005],posa[1000005],posb[1000005],mod=1e9+7,ans=1,fx=0,fy=0;
struct bit_2d{int a[1005][1005];int lowbit(int x){return x&(-x);}void add(int x,int y,int z){int i,j;for (i=x;i<=n;i+=lowbit(i)){for (j=y;j<=m;j+=lowbit(j)){a[i][j]+=z;}}}int query(int x,int y){int i,j;int s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}int query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
bit_2d c;
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=m;i++) scanf("%d",&b[i]);
	sort(a+1,a+n+1,greater<int>());sort(b+1,b+m+1,greater<int>());
	for (i=1;i<=n;i++) if (posa[a[i]]) {puts("0");return 0;} else posa[a[i]]=i;
	for (i=1;i<=m;i++) if (posb[b[i]]) {puts("0");return 0;} else posb[b[i]]=i; 
	if (!posa[n*m]||!posb[n*m]) {puts("0");return 0;}
	for (i=n*m;i>=1;i--)
	{
		if (posa[i]&&posb[i])
		{
			c.add(posa[i],posb[i],1);
			fx=posa[i];fy=posb[i];
		}
		else if (posa[i])
		{
			int s=fy;
			if (s<1) {puts("0");return 0;}
			ans=1ll*ans*s%mod;
			c.add(posa[i],fy,1);
			fx=posa[i];
		}
		else if (posb[i])
		{
			int s=fx;
			if (s<1) {puts("0");return 0;}
			ans=1ll*ans*s%mod;
			c.add(fx,posb[i],1);
			fy=posb[i];
		}
		else
		{
			int s=(fx*fy)-c.query(fx,fy);
			if (s<1) {puts("0");return 0;}
			ans=1ll*ans*s%mod;
			c.add(fx,fy,1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6400
<?php
fscanf(STDIN, '%s', $s);
$n = strlen($s);
$min = 1000;
for ($i = 0; $i < $n - 2; $i++) {
    $x = abs((int) substr($s, $i, 3) - 753);
    $min = min($x, $min);
}
echo $min;

Measured memory_bytes: 4604
n = gets.to_i
c = gets.chomp.split

def bubble_sort(c, n)
  0.upto(n-1) do |i|
    (n-1).downto(i+1) do |j|
      if c[j][1].to_i < c[j-1][1].to_i
        c[j],c[j-1] = c[j-1],c[j]
      end
    end
  end
  return c
end

def selection_sort(c, n)
  cnt = 0
  0.upto(n-1) do |i|
    minj = i
    i.upto(n-1) do |j|
      if c[j][1].to_i < c[minj][1].to_i
        minj = j
      end
    end
    c[i], c[minj] = c[minj], c[i]
  end
  return c
end

#Rubyの変数は参照渡しになるのでdupして渡す
b = bubble_sort(c.dup, n)
s = selection_sort(c.dup, n)

#バブルソートは数字が同じとき交換を行わないので常にStable
puts b.join(" "), "Stable"

#バブルソートのソート結果と比較して結果が異なればNot stable
puts s.join(" "), (b == s) ? "Stable" : "Not stable"


Measured memory_bytes: 6876
while True:
    s=raw_input()
    if s=="0":break
    s+="".join([raw_input() for i in range(2)])
    L=[(i,i+1,i+2) for i in range(0,9,3)]+[(i,i+3,i+6) for i in range(3)]+[(0,4\
,8),(2,4,6)]
    for i,j,k in L:
        if s[i]==s[j]==s[k]!="+":
            print "b" if s[i]=="b" else "w"
            break
    else:
        print "NA"

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, k;
	cin >> n >> k;
	vector<vector<int>> a(k);
	rep(i, k){
		int d;
		cin >> d;
		vi A(d);
		rep(j, d) cin >> A[j];
		a[i] = A;
	}

	vi sunuke(n, 0);
	rep(i, k){
		for(auto t : a[i]){
			sunuke[t-1]++;
		}
	}
	int ans = 0;
	rep(i, n){
		if(sunuke[i] == 0) ans++;
	}

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

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,n)       for(int i=0; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int fast_pow(long long base, long long n, long long M)
{
    if (n == 0)
        return 1;
    if (n == 1)
        return base;
    long long halfn = fast_pow(base, n / 2, M);
    if (n % 2 == 0)
        return ( halfn * halfn ) % M;
    else
        return ( ( ( halfn * halfn ) % M ) * base ) % M;
}
int findMMI_fermat(int n, int M)
{
    return fast_pow(n, M - 2, M);
}
int32_t main()
{
    zeus();

    int n; cin >> n;

    int a[n], b[n];

    forn(i, n) {
        cin >> a[i] >> b[i];
    }

    sort(a, a + n);
    sort(b, b + n);


    if (n % 2 == 1) {
        int meda = a[n / 2];
        int medb = b[n / 2];
        cout << medb - meda + 1 << endl;
    }
    else {
        int meda = ((a[n / 2] + a[n / 2 - 1]) / 2.0) ;
        int medb = ((b[n / 2] + b[n / 2 - 1]) / 2.0) ;
        int ans = (medb - meda) * 2 + 1;
        if (a[n / 2] % 2 != a[n / 2 - 1] % 2) {
            ans--;
        }
        if (b[n / 2] % 2 != b[n / 2 - 1] % 2) {
            ans++;
        }
        cout << ans << endl;
    }



}





Measured memory_bytes: 6688
/*
      author : Nishikawa
      created: 10.08.2020 13:04:16
*/

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


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

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[205];
int main(){
	int n, ans = 0;
	scanf("%d", &n);
	for(int i=0;i<2*n;i++) scanf("%d", &a[i]);
	sort(a, a+2*n);
	for(int i=0;i<2*n;i+=2) ans += a[i];
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  cout<<s.substr(0,4)<<" "<<s.substr(4)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

string s;

void input(){
    cin >> s;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    s[3] ='8';
    cout << s << endl;
  	return 0;
}

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define y1 dhwjdshg

using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    vector<pair<int, int> > a(n), b(n);
    rep(i, 0, n)
        cin >> a[i].fi >> a[i].se;
    rep(i, 0, n)
        cin >> b[i].fi >> b[i].se;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    bool used[n]; fill(used, used + n, false);
    int ans = 0;
    rep(i, 0, n)
    {
        int id = -1;
        rep(j, 0, n)
            if (!used[j] && a[j].fi < b[i].fi && a[j].se < b[i].se)
            {
                if (id == -1 || a[j].se > a[id].se)
                    id = j;
            }
        if (id != -1)
        {
            used[id] = true;
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
	int length[11] = {0};
	int v1, v2;
	while( ~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &length[1], &length[2], &length[3], &length[4], &length[5], &length[6], &length[7], &length[8], &length[9], &length[10], &v1, &v2) ){
		for(int i=1; i<=10; i++) length[i] += length[i-1];
		double t = (double)length[10] / (v1+v2);
		for(int i=0; i<=10; i++){
			if( t*v1 <= length[i] ){
				cout << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define MP make_pair
#define ull unsigned long long int
#define F first
#define S second
#define put insert
#define pb push_back
#define rsortV(arr) sort(arr.begin(),arr.end(),greater<int>())
#define sortV(arr) sort(arr.begin(),arr.end())
#define sortA(arr,n) sort(arr,arr+n)
#define rsortA(arr,n) sort(arr,arr+n,greater<int>())
#define arrInput(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define rev(arr) reverse(arr.begin(), arr.end())
#define all(x) (x).begin(), (x).end()
ll MOD = 1e9+7;
int main() {
    fastio
    // int t;
    // cin>>t;
    // while(t--) {
    ll n;
    cin>>n;
    ll sum = 0;
    ll prevHeight = 0;
    while(n--) {
        ll x;
        cin>>x;
        if(x < prevHeight) {
            sum += prevHeight-x;
        } else {
            prevHeight = x;
        }
    }
    cout<<sum;
    // }
    return 0;
}


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

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if (a > b){
    rep(i,a) cout << b;
  }
  else{
    rep(i,b) cout << a;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 200000;

vector<int> graph[MAX_N];
vector<int> used(MAX_N, 0);

pair<int, ll> dfs(int node, ll dist) {
    used[node] = 1;
    pair<int, ll> ret = {node, dist};
    for(int next_node: graph[node]) {
        if(used[next_node]) continue;
        pair<int, ll> q = dfs(next_node, dist+1);
        if(ret.second < q.second) {
            ret = q;
        }
    }
    return ret;
}

ll calc_diameter() {
    pair<int, ll> u = dfs(0, 0);
    used = vector<int>(MAX_N, 0);
    return dfs(u.first, 0).second;
}


int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, a, b;
    cin >> n;

    for(int i=0;i<n-1;++i) {
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    if(calc_diameter() % 3 != 1) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }

}


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

using ll = long long;
using ull = unsigned long long;

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

    int n;
    cin >> n;

    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;

        if ((x & 1) && (i & 1)) ++cnt;
    }

    cout << cnt << "\n";

    return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin>>a[i];

	multiset<int> buriunti;
	int ans = 0;
	rep(i,n){
		auto itr = buriunti.lower_bound(a[i]);
		if(itr==buriunti.begin()){
			buriunti.insert(a[i]);
			continue;
		}
		--itr;
		buriunti.erase(itr);
		buriunti.insert(a[i]);
	}
	cout <<buriunti.size() << endl;
}


Measured memory_bytes: 8236
#include <iomanip>
#include <iostream>
#include <iterator>
#include <sstream>
#include <vector>

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

    int n;
    while (std::cin >> n && n > 0) {
        std::cin.ignore();

        std::vector<int> vec;
        std::string s;
        for (int i = 0; i < n; i++) {
            std::getline(std::cin, s);

            std::stringstream ss(s);
            std::copy(std::istream_iterator<int>(ss), {},
                      std::back_inserter(vec));
        }

        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < n; j++) {
                std::cout << std::right << std::setw(5) << vec[n * i + j];
                sum += vec[n * i + j];
            }
            std::cout << std::right << std::setw(5) << sum << std::endl;
        }
        int total = 0;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < n; j++) { sum += vec[n * j + i]; }
            std::cout << std::right << std::setw(5) << sum;
            total += sum;
        }
        std::cout << std::right << std::setw(5) << total << std::endl;
    }
}

Measured memory_bytes: 3020
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        X, A, B = map(lambda x: int(x), line.split(" ", 3))
        if B <= A:
            print("delicious")
        elif (B - A) <= X:
            print("safe")
        else:
            print("dangerous")

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2568
#include<stdio.h>
int main(){
  int W, H, x, y, r;
  scanf("%d %d %d %d %d\n", &W, &H, &x, &y, &r);
  printf((0<=x-r && x+r<=W && 0<=y-r && y+r<=H) ? "Yes\n" : "No\n");
  return 0;
}


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

#define ll long long
#define mk make_pair
#define pb push_back


using namespace std;


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

   int a, b, c; cin >> a >> b >> c;
   if(a+b+c >= 22) cout << "bust";
   else cout << "win";
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int a[200010];
	int mx=-1,mx2=-1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>=mx){
		mx2=mx;
		mx=a[i];
		}
		else if(a[i]>=mx2)mx2=a[i];
		
			}
	for(int i=0;i<n;i++)
	{
		if(a[i]==mx)cout<<mx2<<endl;
		else cout<<mx<<endl;
	}
	return 0; 
 } 

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        10000005
#define mod         998244353  
#define pi          3.1415926535897932384626433
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k,x;
    map<ll,ll> mp1;
    cin>>n;
    for(i=1;i<=100;i++){
        for(j=1;j<=100;j++){
            for(k=1;k<=100;k++){
                x=i*i+j*j+k*k+i*j+j*k+k*i;
                if(x<=n){
                    mp1[x]++;
                }
            }
        }
    }
    for(i=1;i<=n;i++){
        cout<<mp1[i]<<endl;
    }
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> S(N), A(N);

    long long x;
    for(int i = 0; i < N; ++i)
    {
        cin >> x;
        S[i] = 2 * x;
    }

    long long sum = 0;
    for(int i = 0; i < N; ++i) sum += S[i];
    sum = sum / 2;

    long long oddsum = 0;
    for(int i = 0; i < N; i+=2) oddsum += S[i];

    A[0] = oddsum - sum;
    for(int i = 1; i < N; ++i)
        A[i] = S[i - 1] - A[i - 1];

    for(int i = 0; i < N; ++i)
        cout << A[i] << ' ';
    cout << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

int main() {
  ll n;
  cin>>n;
  ll l[n+1];
  l[0] = 2, l[1] = 1;
  fr(i,2,n+1) l[i] = l[i-1]+l[i-2];
  cout<<l[n];
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int c[1400][1400] = {}, dp[1400][1400] = {}, mv[3][2] = {{-1, -1}, {-1, 0}, {0, -1}};
int main()
{
    int h, w;
    scanf("%d %d", &h, &w);
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            scanf("%d", &c[i][j]);
        }
    }
    for (int i = 0; i < h; ++i)
    {
        dp[i][0] = !c[i][0];
    }
    for (int i = 0; i < w; ++i)
    {
        dp[0][i] = !c[0][i];
    }
    for (int i = 1; i < h; ++i)
    {
        for (int j = 1, mi = 100000000; j < w; ++j, mi = 100000000)
        {
            if(!c[i][j])
            {
                for (int k = 0; k < 3; ++k)
                {
                    mi = min(mi, dp[i + mv[k][0]][j + mv[k][1]]);
                }
                dp[i][j] = mi + 1;
            }
        }
    }
    printf("%.0lf\n", pow(*max_element(dp[0], dp[h - 1] + w), 2));
}



Measured memory_bytes: 16516
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    int N; cin >> N;
    int min, max, ans;
    vector<int> A;

    for (int i = 0; i < N; i++) {
        int tmp; cin >> tmp;
        A.push_back(tmp);
    }

    ans = 100*100*101;
    min = *min_element(A.begin(), A.end());
    max = *max_element(A.begin(), A.end());

    for (int j=min-1;j<=max+1;j++) {
        int tmp_ans = 0;
        for (int i=0;i<N;i++) {
            tmp_ans+=((j-A[i])*(j-A[i]));
        }
        if(ans>tmp_ans) ans=tmp_ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        aa: [usize;n]
    }
    let mut v = vec![0;100000];
    for a in aa {
        v[a] += 1;
    }
    let mut max = 0;
    for i in 1..v.len()-1 {
        max = std::cmp::max(max, v[i-1] + v[i] + v[i+1]);
    }
    println!("{}", max);
}


Measured memory_bytes: 6396
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 500010
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define int long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, ans = 1, cnt;
const int mod = 1e9 + 7;
int t[SIZE], a[SIZE];
string s;

signed main() {
	io(); cin >> n >> s;
	rep(i, 2, n) ans = ans * i % mod;
	rep(i, 0, (s.length() - 1)) {
		if (s[i] == 'B' && !(cnt & 1)) ++cnt;
		else if (s[i] == 'B' && (cnt & 1)) ans = ans * cnt-- % mod;
		else if (s[i] == 'W' && (cnt & 1)) ++cnt;
		else ans = ans * cnt-- % mod;
	}
	cout << (cnt ? 0 : ans);
}

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


/** 
 * Knapsack in O(N*W). Here the dimesion of W is very high so we use dp in 
 * dimension of values
 */
const ll INF = 1e18L + 5;
int main(){
    ll n; cin>>n;
    ll w; cin>>w;
    vector<int> weight(n); vector<int> value(n);
    for(ll item=0; item<n; ++item){
        cin>>weight[item]>>value[item];
    }
    int sum_value =0;
    for(int x: value){
        sum_value += x;
    }
    vector<ll> dp(sum_value+1, INF);
    dp[0] =0;
    // dp[i] - The total minimum weight of items of given value equal to i
    for(ll item=0; item<n; ++item){
        for(int value_already = sum_value - value[item]; value_already>=0; --value_already){
            dp[value_already+value[item]] = min(dp[value_already+value[item]], dp[value_already] + weight[item] );
        }
    }
    ll ans = -INF;
    for(ll i=0; i<=sum_value ;++i){
        if(dp[i]<=w)
            ans = max(i, ans);
    }
    cout<<ans;
    return 0;
}

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

void setup()
{
    //cinでファイルから読込
    ifstream in("./input.txt");
    cin.rdbuf(in.rdbuf());

    //cinの高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main()
{
    int K, X;
    cin >> K;
    cin >> X;

    for (int i = X - K + 1; i < X + K - 1; i++)
    {
        cout << i << " ";
    }
    cout << X + K - 1;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<endl
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e];
using namespace std;

int main()
{
    fastio;
    int n, m;
    cin>>n>>m;
    
    int a[n];
    read(a, n);
    
    LL sum = 0, cnt=0;
    sum = accumulate(a, a+n, sum);
    
    for(int i=0; i<n; i++){
        if(a[i] >= (float)sum/(4*m))
            cnt++;
        if(cnt == m)
            break;
    }
    
    if(cnt>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,l,r;
	cin>>n;
	int a[100005] = {0};
	for(int i = 0; i < n; i++){
		cin>>l>>r;
		a[l]++;
		a[r+1]--;
	}
	int ans = 0;
	for(int i = 1; i <= 100000; i++){
		a[i] += a[i-1];
		if(a[i] > 0){
			ans++;
		}
	}
	cout<<ans<<endl;
}



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

const char i = 'I', v = 'V', x = 'X', l = 'L', c = 'C', d = 'D', m = 'M';

int number(char s)
{
     switch (s) {
     case i: return 1;
     case v: return 5;
     case x: return 10;
     case l: return 50;
     case c: return 100;
     case d: return 500;
     case m: return 1000;
     }
}

int main()
{
     string str;
     while (cin >> str) {
          int i = 0;
          int ans = 0;
          while (i < str.size()) {
               int tmp = 0;
               char s = str[i];
               while (s == str[i] && i < str.size()) {
                    tmp += number(s);
                    i++;
               }
               if (number(s) < number(str[i])) ans -= tmp;
               else ans += tmp;
          }
          cout << ans << endl;
     }

     return 0;
}

Measured memory_bytes: 1180
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N = ri()

l = []
for i in range(1,6):
  l.append(9**i)
for i in range(7):
  l.append(6**i)
l.sort(reverse=True)

cache = {n:1 for n in l}
def f(n):
  if n in cache:
    return cache[n]
  ret = 100000
  for i in l:
    if i <= n:
      ret = min(ret, f(n-i)+1)
  cache[n] = ret
  return ret
print(f(N))

Measured memory_bytes: 15688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

const int max = 1000000010;
/*bool isPrime[max];

void init(){
	//rep(i, max)isPrime[i] = true;
	isPrime[0] = isPrime[1] = true;

	REP(i, 2, max){
		if (!isPrime[i]){
			for (int j = i * 2; j < max; j += i)isPrime[j] = true;
		}
	}
}*/

int main(){
	//init();

	int n;
	std::cin >> n;

	std::cout << n << ":";
	//if (!isPrime[n])std::cout << " " << n;
	//else{
		int cp = n;
		for (int i = 2; i * i <= cp; ++i){
			while (n % i == 0)n /= i, std::cout << " " << i;
		}
	//}
		if (n != 1)std::cout << " " << n;
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 1168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20190309_02 {
    class Program {
        static void Main(string[] args) {
            var line0 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var n = line0[0];
            var m = line0[1];
            var c = line0[2];
            var b = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var ans = 0;
            for (int i = 0; i < n; i++) {
                var sum = 0;
                var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                for (int j = 0; j < m; j++) {
                    sum += a[j] * b[j];
                }
                if (sum > -c) {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

#define MOD 1000000007
typedef unsigned long long ull;

int main() {
    int a,b;
    cin >> a >> b;

    // 全探索
    for (int i = 1; i <= 1000; i++) {
        int hachi = floor(i * 0.08);
        int juu = floor(i * 0.1);

        if (hachi == a && juu == b) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
}


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

int n, cnt[205];

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			++cnt[gcd(i, j)];
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			ans += cnt[j] * gcd(i, j);
	cout << ans;
	return 0;
} 


Measured memory_bytes: 3636
a,b,c,d = map(int,input().split())
if d >= max(a,c) - min(a,c):
     print("Yes")
     exit()
if d >= max(a,b) - min(a,b):
    if d >= max(b,c) - min(b,c):
        print("Yes")
        exit()
print("No")



Measured memory_bytes: 2940
n, a, b = [int(_) for _ in raw_input().split()]
h = [int(raw_input()) for _ in xrange(n)]

d = a - b


def c(n):
    m = 0
    for hi in h:
        m += max(0, -((b * n - hi) // d))
    return m <= n


lb = 0
ub = -(-max(h) // b) + 1
while lb < ub:
    mid = (lb + ub) // 2
    if c(mid):
        ub = mid
    else:
        lb = mid + 1

print lb


Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=9;i++){
      if(i==1){
          if(100<=n&&n<=111){
          cout<<111<<endl;
        }
      }
      else{
           if((i-1)*111+1<=n&&n<=111*i){
          cout<<111*i<<endl;
        }

      }
      
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    int n, m;
    cin >> n >> m ;
    int ans = n * (n - 1) / 2  + m * (m - 1) / 2;
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
fn main() {
    let mut nums: Vec<i32> = Vec::new();

    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let num: i32 = s.trim().parse().unwrap();
        if num == 0 {
            break;
        }
        nums.push(num);
    }

    for i in 0..nums.len() {
        println!("Case {}: {}", i + 1, nums[i]);
    }
}



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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const int mod = 1e9+7;
// int 1e9+7 double 1e-12 long long 1e18

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  ll N;
  cin >> N;
  ll f = 0;
  ll n = N;
  for (int i = 8; i >= 0; --i){
    f += n / (int)pow(10, i);
    n = n % (int)pow(10, i);
  }
  if (N % f == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

int main(){
    
    int N;
    cin >> N;
    
    long long D;
    map<long long,int>mp;
    for(int i = 0; i < N; i++){
        cin >> D;
        mp[D]++;
    }
    
    int M;
    cin >> M;
    
    long long T;
    for(int i = 0; i < M; i++){
        cin >> T;
        if(mp[T]==0){
            cout << "NO"<<endl;
            return 0;
        }else{
            mp[T]--;
        }
    }
    
    cout << "YES"<<endl;
    return 0;
    
}

    
    



Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
vector<vector<ll>> graph;
vector<ll> ans;
map<P, ll> number;
void dfs(ll cur, ll parent, ll cpc) {
    int color = 1;
    REP(i, graph[cur].size()) {
        if (parent != graph[cur][i]) {
            if (cpc == color) {
                color++;
            }
            ans[number[{cur, graph[cur][i]}]] = color;
            dfs(graph[cur][i], cur, color);
            color++;
        }
    }
}
int main() {
    string s;
    ll n;
    cin >> n;
    int d;
    s = to_string(n);
    d = s.size();
    if (d == 1) {
        cout << n << endl;
        return 0;
    }
    ll sum = 0;
    ll cnt[10][10] = {0};
    ll now = d;
    rep(k, 2, d) {
        rep(i, 1, 10) {
            rep(j, 1, 10) { cnt[i][j] += power(10, (k - 2)); }
        }
    }
    rep(j, 1, 10) { cnt[j][j]++; }
    REP(l, d - 1) {
        rep(i, 0, s[l] - '0') {
            if (l > 0) {
                rep(j, 1, 10) { cnt[s[0] - '0'][j] += power(10, (d - l - 2)); }
                continue;
            }
            rep(j, 1, 10) { cnt[i][j] += power(10, (d - l - 2)); }
        }
    }
    rep(i, 1, s[d - 1] - '0' + 1) { cnt[s[0] - '0'][i]++; }
    rep(i, 1, 10) {
        rep(j, 1, 10) { sum += cnt[i][j] * cnt[j][i]; }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, ans=0;
	cin >> a >> b;
	for(int i=a;i<=b;i++){
		if(i/10000 == i%10){
			if(i/1000%10 == i%100/10){ \
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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

min_abs = INF
ans = 0
for i in range(1, N):
    S_left = sum(W[:i])
    S_right = sum(W[i:])
    sa = abs(S_left - S_right)
    if min_abs > sa:
        min_abs = sa
        ans = i

print(min_abs)


Measured memory_bytes: 3572
n,k = list(map(int,input().split()))
a = [0]*n
for i in range(n):
    a[i] = int(input())

a.sort()
ans = 9999999999999999999
for i in range(len(a)-(k-1)):
    x = a[i+k-1] - a[i]
    ans = min(ans,x)
print(ans)

Measured memory_bytes: 7472
#include<iostream>
#include <bits/stdc++.h> 
using namespace std;
int main(){
  string s;
  int countA=0 , countB=0;
  cin>>s;
  for(int i=0;i<3;i++){
   	 if(s[i] == 'A') countA++;
    else countB++;
  }
  if(countA==0 || countB==0)
    cout<<"No";
  else
    cout<<"Yes";
}

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

int n;
vector<int> v;
long long cnt[300010];

int main()
{
    int i;
    scanf("%d", &n);
    for(int i=1; i<=n; ++i){
        int x;
        scanf("%d", &x);
        v.push_back(x);
        cnt[x] += 1;
    }
    long long ans = 0;
    for(int i=1; i<=n; ++i) ans += (cnt[i]*(cnt[i]-1))/2;
    for(auto x : v){
        int t = cnt[x];
        printf("%lld\n", ans - t*(t-1)/2 + (t-1)*(t-2)/2);
    }
}

Measured memory_bytes: 4084
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  int A, B;
  cin >> A >> B;
  if (A > B) {
    int tmp = A;
    A = B;
    B = tmp;
  }
  int K = (B - A)/2 + A;
  if ((B - A) % 2 == 1) {
    cout << "IMPOSSIBLE\n";
  } else {
    cout << K << '\n';
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

s = readline()
n = len(s)
answer = 0
for i in range(n):
    for j in range(i, n):
        t = s[i:j + 1]
        if set(t) <= set('ACGT'):
            answer = max(answer, j - i + 1)
print(answer)

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    while(N>0) {
        N /= K;
        ans++;
    }

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

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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; ++i) cin >> v[i];
    sort(begin(v), end(v));

    double res = (v[0] + v[1]) / 2.0;
    for(int i=2; i<N; ++i) {
        res = (res + v[i]) / 2.0;
    }
    cout << fixed << setprecision(6) << res << endl;
}

Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main()
{
    int a[100][100]={0};
    int b[100] ={0};
    int ans[100] = {0};

    int n,m;

    cin >>n >> m;

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }

    for(int i=0;i<m;i++){
        cin >> b[i];
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            ans[i] += a[i][j]*b[j];
        }
    }

    for(int i=0; i<n;i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}



Measured memory_bytes: 3128
N = int(input())
S = N
if N % 2 == 0:
    S += 1
ans = []    
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if i + j == S:
            continue
        ans += [(i, j)]
print(len(ans))
for i, j in ans:
    print(i, j)

Measured memory_bytes: 74284
#include<bits/stdc++.h>   //取り敢えず書く
using namespace std;      //取り敢えず書く
int main(){               //取り敢えず書く
 /* コード */    int x;
 cin>>x;
 x=x*x*x;
 cout<<x<<endl;//今までやったようにコードを書く
}


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

int main ()
{
	string inputData;
    cin >> inputData;

    string tmp = "";

    for(int i = 0; i < inputData.size(); i++){
        if(inputData[i] != 'B'){
            tmp = tmp + inputData[i];
        }else{
            if(tmp.size() > 0){
                // 文字列の最後を削除する
                tmp.pop_back();
            }
        }
    }
    cout << tmp << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,k,n,b,d,p,q,ct,x;
    vector<ll>v;
    map<ll,ll>mp;
    cin>>n;
    p=0;
    ct=0;
    for(ll i=0;i<n-1;i++)
    {
       cin>>x;
       mp[x]++;
    }
    for(ll i=1;i<=n;i++)
    {
    cout<<mp[i]<<endl;
    }
}



Measured memory_bytes: 16128
s[50],j,p,q;
main(i){for(;p=atoi(gets(s));printf("%d\n",i)){
for(i=0;i<p;s[i++]=strlen(gets(s+i)));
for(i=j=0;j<7;)for(p=i++,j=q=1;q>0;)for(q=0x886860>>j++*4&15;q>1;q-=s[p++]);
}}

Measured memory_bytes: 532
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

int N, M;
int f[200005], sons[200005];
int ans = 0;

inline int find(int x)
{
	if(f[x] != x)
		return f[x] = find(f[x]);
	return x;
}

inline void merge(int x, int y)
{
	int fx = find(x), fy = find(y);
	if(fx == fy)
		return;
	f[fy] = fx;
	sons[fx] += sons[fy];
}

int main()
{
	scanf("%d%d", &N, &M);
	for(int i = 1;i <= N;++i)
		f[i] = i, sons[i] = 1;
	for(int i = 1;i <= M;++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		merge(u, v);
	}
	for(int i = 1;i <= N;++i)
	{
		int ff = find(i);
		if(ff != i)
			continue;
		ans = max(ans, sons[i]);
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
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; }

struct Edge
{
	int to, id;
};

vector<vector<Edge>> adj_list;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1)
{
	int k = 1;
	rep(i, sz(adj_list[v]))
	{
		int u = adj_list[v][i].to;
		int eid = adj_list[v][i].id;
		if (u == p)continue;
		if (k == c)k++;
		ans[eid] = k; k++;
		dfs(u, ans[eid], v);
	}
}

int main()
{
	int n; cin >> n;
	adj_list.resize(n);
	ans.resize(n - 1);
	rep(i, n - 1)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		adj_list[a].push_back(Edge{ b,i });
		adj_list[b].push_back(Edge{ a,i });
	}
	int k = 0, i_ma = 0;
	rep(i, n)if (chmax(k, sz(adj_list[i])))i_ma = i;
	dfs(i_ma);

	co(k);
	rep(i, n - 1)co(ans[i]);
	return 0;
}


Measured memory_bytes: 8320
import sys
sys.setrecursionlimit(3000)

n = int(input())
X = []
for _ in range(n):
    x = list(map(int, input().split()))
    if x[1] != 0:
        X.append(x[2:])
    else:
        X.append([])

df = [[0, 0] for _ in range(n)]
t = 0
def search(i = 0):
    global t
    if df[i][0] == 0:
        t += 1
        df[i][0] = t
    for x in X[i]:
        if df[x - 1][0] == 0:
            search(x - 1)
    if df[i][1] == 0:
        t += 1
        df[i][1] = t

for i in range(n):
    search(i)

for i, x in enumerate(df):
    print('{} {} {}'.format(i + 1, x[0], x[1]))


Measured memory_bytes: 5636
/*
 *  author : Atul Anand   
 *  created on : Thu Apr 02 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int P = in.nextInt();
        int Q = in.nextInt();
        int R = in.nextInt();
        println(Math.min(P + Q, Math.min(Q + R, R + P)));   
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 21332