akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
const int md=1000000007;
inline void add(int &a,int b){
	a+=b;
	if (a>=md) a-=md;
}
int ned1[22],ned2[22];
int dp[2][22][1048999]; //dp[i][j][state] i-th line j-th layer state
int main(void){
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	for (int i=1;i<=q;++i){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		--v;
		ned1[u]|=(1<<v);
		ned2[u]|=(w<<v);
	}
	--n;
	dp[0][n][0]=1;
	for (int i=1;i<=m;++i){
		int cur=i&1,lst=cur^1;
		memset(dp[cur],0,sizeof(dp[cur]));
		memcpy(dp[cur][0],dp[lst][n],sizeof(dp[cur][0]));
		for (int j=0;j<n;++j){
			for (int k=0;k<(1<<n);++k){
				if (k&(1<<j)){
					add(dp[cur][j+1][k],dp[cur][j][k]);
				}
				else{
					add(dp[cur][j+1][k],dp[cur][j][k]);
					register int nxk=k^(k&((1<<j)-1));
					if (nxk){
						nxk^=(nxk&(-nxk));
						nxk=nxk|(k&((1<<j)-1));
					}
					else{
						nxk=k;
					}
					nxk|=(1<<j);
					add(dp[cur][j+1][nxk],dp[cur][j][k]);
				}
			}
		}
		for (int k=0;k<(1<<n);++k){
			if ((k&ned1[i])!=ned2[i]) dp[cur][n][k]=0;
		}
	}
	int res=0;
	for (int k=0;k<(1<<n);++k){
		add(res,dp[m&1][n][k]);
	}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 180480
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = sorted(a)[n-1]
a_max2 = sorted(a)[n-2]
for i in range(n):
    if a[i] == a_max:
        print(a_max2)
    else:
        print(a_max)

Measured memory_bytes: 68512
#!/usr/bin/env python
import re

def main():
    S = input()
    regex = r"[ATCG]*"
    matches = re.findall(regex, S)

    ans = 0
    for match in matches:
        if len(match) > ans:
            ans = len(match)
    return ans

if __name__ == '__main__':
    print(main())

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+7;
vector<int> dp(lim,0);


int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);

    for(int i=3;i<=n;i++){
        int x = INT_MAX;
        for(int j=i-1;j>=max(1,i-k);--j){
            x=min(x,dp[j]+abs(h[i]-h[j]));
        }
        dp[i]=x;
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        mut n: usize,
    }

    let mut ans = vec![];

    while n > 0 {
        n -= 1;
        ans.push(b'a' + (n % 26) as u8);
        n /= 26;
    }
    ans.reverse();

    println!("{}", std::str::from_utf8(&ans).unwrap());
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

vector<P> prime_factorize(ll n) {
    vector<P> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    ll n, p;
    cin >> n >> p;
    vector<P> factorize;
    factorize = prime_factorize(p);

    ll ans = 1;
    REP(i, factorize.size()) {
        if(factorize[i].second >= n) {
            REP(j, factorize[i].second / n) {
                ans *= factorize[i].first;
            }
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 25

typedef struct{
  int l,r,par;
} node;

node N[MAX];

void init(int);
void Preorder(int);
void Inorder(int);
void Postorder(int);

int main(){
  int n,i,id,l,r;
  int p;
  
  scanf("%d" ,&n); 
  init(n);  

  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&r);

    if(l != -1){
      N[id].l = l;
      N[l].par = id;
    }
    if(r != -1){
      N[id].r = r;
      N[r].par = id;
    }
  }

  for(i = 0 ; i < n ; i++){
    if(N[i].par == -1){
      p = i;
      break;
    }
  }
 
  puts("Preorder");
  Preorder(p);
  puts("");

  puts("Inorder");
  Inorder(p);
  puts("");

  puts("Postorder");
  Postorder(p);
  puts("");

  return 0;
}

void init(int n){
  int i;

  for(i = 0 ; i < n ; i++){
    N[i].par = N[i].l = N[i].r = -1;
  }
}

void Preorder(int p){
  if(p != -1){
    printf(" %d" ,p);
    Preorder(N[p].l);
    Preorder(N[p].r);
  }
}

void Inorder(int p){
  if(p != -1){
    Inorder(N[p].l);
    printf(" %d" ,p);
    Inorder(N[p].r);
  }
}

void Postorder(int p){
  if(p != -1){
    Postorder(N[p].l);
    Postorder(N[p].r);
    printf(" %d" ,p);
  }
}


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

#define fi first
#define se second
#define ll long long

const int N = 2020;

using namespace std;

long double F(ll a, ll b)
{
        return (long double)100 * b / (a + b);
}

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

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        ll a, b, c, d, e, f;
        cin >> a >> b >> c >> d >> e >> f;
        long double res = -1;
        ll A, B;
        a *= 100;
        b *= 100;
        for(ll i = 0; i <= f; i += a){
                for(ll j = 0; i + j <= f; j += b){
                        ll t1 = i + j;
                        for(ll h = 0; h + t1 <= f; h += c){
                                for(ll k = 0; k + h + t1 <= f; k += d){
                                        ll t2 = k + h;
                                        if(e * (t1 / 100) < t2){
                                                continue;
                                        }
                                        if(F(t1, t2) > res + 1e-16){
                                                res = F(t1, t2);
                                                A = t1;
                                                B = t2;
                                        }
                                }
                        }
                }
        }
        cout << A + B << " " << B << "\n";
}


Measured memory_bytes: 3604
//abc134_a.cpp
//Sat Jul 20 20:59:16 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	cout << 3*n*n << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    ll ans = 0;

    ans += (N/(A+B))*A;
    ans+= min(A,N%(A+B));

    cout<<ans;
    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N, M;
VL p;

//通常
struct UnionFind {
    V par, rank;
    UnionFind(int size) { init(size); }
    void init(int size) {
        REP(i, size) {
            par.push_back(i);
            rank.push_back(0);
        }
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            swap(x, y);
        } else {
            if(rank[x] == rank[y]) rank[x]++;
        }
        par[y] = x;
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

int main() {
    cin >> N >> M;
    REP(i, N) p.emplace_back(IN());
    auto uf = UnionFind(N);
    REP(i, M) {
        CINT(x, y);
        uf.unite(p[x - 1] - 1, p[y - 1] - 1);
    }
    ll ans = 0;
    REP(i, N) if(uf.same(i, p[i] - 1)) ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 2292
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

vector<bool> Eratosthenes(int n) {
    vector<bool> prime(n, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!prime[i]) continue;
        for (int j = 2; i * j <= n; j++) {
            prime[i * j] = false;
        }
    }
    return prime;
}

int main() {
    const int MAX = 100000;
    int Q; cin >> Q;
    vector<bool> prime = Eratosthenes(MAX + 1);

    int cnt = 0;
    vector<int> cnt2017(MAX + 1, 0);
    REP(i, 0, MAX + 1) {
        if (!prime[i] || i % 2 == 0) {
            cnt2017[i] = cnt;
            continue;
        }
        if (prime[(i + 1) / 2]) {
            cnt2017[i] = ++cnt;
        } else {
            cnt2017[i] = cnt;
        }
    }
    
    REP(i, 0, Q) {
        int l, r; cin >> l >> r;
        cout << cnt2017[r] - cnt2017[l - 1] << endl;
    }
    return 0;
}

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

void fnMaxHeapifyUp(vector<int>& rvnPrtyHeap, int nx)
{
  int nParnt = nx / 2;
  int nLrge = nx;

  if (nParnt > 0  &&
      rvnPrtyHeap[nParnt] < rvnPrtyHeap[nLrge])
  {
    swap(rvnPrtyHeap[nParnt], rvnPrtyHeap[nLrge]);
    fnMaxHeapifyUp(rvnPrtyHeap, nParnt);
  }
}

void fnMaxHeapifyDown(vector<int>& rvnPrtyHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLrge = nx;

  if (nLeft < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nLeft])  
    nLrge = nLeft;
  if (nRigt < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nRigt])
    nLrge = nRigt;

  if (nx != nLrge)
  {
    swap(rvnPrtyHeap[nx], rvnPrtyHeap[nLrge]);
    fnMaxHeapifyDown(rvnPrtyHeap, nLrge);
  }
}

void fnPriorityQueue(vector<int>& rvnPrtyHeap)
{
  rvnPrtyHeap.push_back(-1);
  string sCmd;
  while (cin >> sCmd && sCmd != "end")
  {
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      rvnPrtyHeap.push_back(nNo);
      int nx = rvnPrtyHeap.size() - 1;
      fnMaxHeapifyUp(rvnPrtyHeap, nx);
    }
    else if (sCmd[0] == 'e')
    {
      cout << rvnPrtyHeap[1] << endl;
      rvnPrtyHeap[1] = rvnPrtyHeap.back();
      rvnPrtyHeap.pop_back();
      if (rvnPrtyHeap.size() > 1)
        fnMaxHeapifyDown(rvnPrtyHeap, 1);
    }
    else;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPrtyHeap; 

  fnPriorityQueue(vnPrtyHeap);
  return 0;
}

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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
    while(b){
        a %= b;
        swap(a, b);
    }
    return a;
}

ll lcm(ll a, ll b){
    ll d = gcd(a, b);
    return a / d * b;
}

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

    ll ans = 1;
    for (int i = 0; i < n; ++i) {
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010,mod=998244353;
const char str[2][10]={"First","Second"};
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,a[maxn]; 
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int main(){
	n=read();
	FOR(i,1,n) a[i]=read();
	int t=0;
	while(true){
		int cnt1=0,cnte=0;
		FOR(i,1,n){
			if(a[i]==1) cnt1++;
			if(a[i]%2==0) cnte++;
		}
		if(cnte!=n-1 || cnt1==1){puts(cnte%2?str[t]:str[t^1]);break;}
		FOR(i,1,n) if(a[i]%2!=0){a[i]--;break;}
		int g=0;
		FOR(i,1,n) g=gcd(g,a[i]);
		FOR(i,1,n) a[i]/=g;
		t^=1;
	}
}
// coming soon 2020.5.11

Measured memory_bytes: 640
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
A.sort()
B.sort()
sa = set(A)
sb = set(B)
if len(sa)!=N or len(sb)!=M:
    print(0)
    exit()
MOD = 10**9+7

ans = 1
w = h = 0
for v in range(N*M,0,-1):
    if v in sa and v in sb:
        w += 1
        h += 1
    elif v in sa:
        ans *= w
        ans %= MOD
        h += 1
    elif v in sb:
        ans *= h
        ans %= MOD
        w += 1
    else:
        free = w*h - (N*M - v)
        if free <= 0:
            print(0)
            exit()
        ans *= free
        ans %= MOD
print(ans)

Measured memory_bytes: 9172
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M;
std::vector<ll> G[610];

double f( ll block ) {
  std::vector<double> dp( N );
  
  repd( i, N-1 ) {
    double sum = 0;
    double ma = 0;
    ll num = 0;

    for( auto u : G[i] ) {
      sum += dp[u];
      chmax( ma, dp[u] );
      ++num;
    }

    if( i == block && num > 1 ) {
      sum -= ma;
      --num;
    }

    dp[i] = sum / num + 1;
  }

  return dp[0];
}

int main() {
  std::cin >> N >> M;

  rep( i, M ) {
    ll s, t;
    std::cin >> s >> t;
    --s; --t;

    G[s].emplace_back( t );
  }

  double ans = 1e18;

  rep( i, N-1 ) {
    chmin( ans, f(i) );
  }

  printf( "%.12f\n", ans );

  return 0;
}

Measured memory_bytes: 5820
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scanner = new Scanner(System.in);
		
		String inputS = scanner.nextLine();

		scanner.close();
		
		String[] split = inputS.split(" ");
		Integer inA = Integer.parseInt(split[0]);
		Integer inB = Integer.parseInt(split[1]);
		Integer inC = Integer.parseInt(split[2]);
		
		int result = 0;
		for(int c = 0; c < 20; c++) {
			int time = c + 1;
			
			if(time > inC) {
				break;
			}

			if(time % inA == 0) {
				result += inB;
			}
			
			
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

int main() {
    LL a[3];
    R(a[0],a[1],a[2]);
    sort(a,a+3);
    if ( a[0]%2==1 && a[1]%2==1 && a[2]%2==1 ) W(a[0]*a[1]);
    else W(0);
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s == "AAA" || s == "BBB"){
    cout << "No";
  }
  else{
    cout << "Yes";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define F(i,a,b) for(int i=a;i<=b;++i)
const int maxn=2e5+5;
int n,a[maxn],pw1[maxn],pw2[maxn],f[maxn],sum1=0,sum2=0,tot=0;
char s[maxn];
int pct(int x){return x==0?x:pct(x>>1)+(x&1);}
void run(int p)
{
	a[p]^=1;
	int x=0,pc=0;
	if(a[p]) pc=tot+1;
	else pc=tot-1;
	if(!pc){
		a[p]^=1;
		f[p]=0;return;
	}
	if(pc==tot-1) x=(sum1+tot-1-pw1[p])%(tot-1);
	else x=(sum2+pw2[p])%(tot+1);
	++f[p];
	while(x){
		pc=pct(x);
		x%=pc;
		++f[p];
	}
	a[p]^=1;
}
int main()
{
	//freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
	scanf("%d",&n);
	scanf("%s",s+1);
	F(i,1,n)
		if(s[i]=='1') a[i]=1,++tot;
	LL all=0;
	for(int i=n;i;--i) all+=a[i]*(1LL<<(n-i));
	int tmp=1;
	if(tot>1){
		F(i,1,n) sum1=(2*sum1+a[i])%(tot-1);
		for(int i=n;i;--i) pw1[i]=tmp,tmp=tmp*2%(tot-1);
	}
	if(tot<n){
		tmp=1;
		F(i,1,n) 
		    sum2=(2*sum2+a[i])%(tot+1);
		for(int i=n;i;--i) pw2[i]=tmp,tmp=tmp*2%(tot+1);
	}
	F(i,1,n) run(i);
	F(i,1,n) printf("%d\n",f[i]);
	return 0;
}

Measured memory_bytes: 7076
import java.util.Scanner;

public class Main {
	public static void main(String[] a) {
		final int max = 10;
		Scanner scn = new Scanner(System.in);
		try {
			while (true) {
				int n = scn.nextInt();
				long ans = 0;
				for (int w = 0; w < max; w++) {
					if (n - w > (max - 1) * 3)
						continue;
					if (n - w < 0)
						break;
					for (int x = w; x < max; x++) {
						if (n - w - x > (max - 1) * 2)
							continue;
						if (n - w - x < 0)
							break;
						for (int y = x; y < max; y++) {
							if (n - w - x - y > (max - 1))
								continue;
							if (n - w - x - y < y)
								break;
							int z = n - w - x - y;
							if (w == x && x == y && y == z) {
								ans += 1;
							} else {
								if ((w == x && x == y) || (x == y && y == z)) {
									ans += 4;
								} else {
									if (w == x && y == z) {
										ans += 6;
									} else {
										if ((w == x) || (x == y) || (y == z)) {
											ans += 12;
										} else {
											ans += 24;
										}
									}
								}
							}
						}
					}
				}
				System.out.println(ans);
			}
		} catch (Exception e) {

}
	}

}

Measured memory_bytes: 26012
import itertools
import math

n = int(input())
l =[]
for i in range(n):
    x,y = map(int,input().split())
    l.append((x,y))
d = [[0]*n for i in range(n)]
for i in range(n-1):
    for j in range(n):
        xy = math.sqrt((l[i][0]-l[j][0])**2 + (l[i][1]-l[j][1])**2)
        d[i][j] = xy
        d[j][i] = xy
t = (i for i in range(n))
p = list(itertools.permutations(t))
sum = 0
nn = math.factorial(n)
for i in p:
    for j in range(n-1):
        sum += d[i[j]][i[j+1]]
ans = sum / nn
print(ans)


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

using namespace std;

int main(){

   int n;
   cin>>n;
   vector<double>dp(n+1);
   dp[0]=1;
   for(int c=0;c<n;c++){
    double temp;
    cin>>temp; 
    for(int i=c+1;i>=0;i--){
        dp[i]=(i==0?0:dp[i-1]*temp)+(1-temp)*dp[i];

    }
   }
   double answer =0;
   for(int i=0;i<=n;i++){
        int t= n-i;
        if(i>t){
            answer+=dp[i];
        }
   }
   cout<<fixed<<setprecision(12)<<answer;
    return 0;
}


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

int main(){
	int n, m, a, b;
	cin >> n >> m >> a >> b;
	for (int i = 1; i <= b; ++ i){
		for (int j = 1; j <= a; ++ j)
			putchar('1');
		for (int j = a + 1; j <= m; ++ j)
			putchar('0');
		putchar('\n');
	}
	for (int i = b + 1; i <= n; ++ i){
		for (int j = 1; j <= a; ++ j)
			putchar('0');
		for (int j = a + 1; j <= m; ++ j)
			putchar('1');
		putchar('\n');
	}
} 

Measured memory_bytes: 1280
import java.util.Scanner;
     
    public class Main { //クラス名はMain
        public static void main(String[] args) {
            //コード
          Scanner sc = new Scanner(System.in);
    	  String n = sc.nextLine();
          String[] strArray = n.split(" ");
          int K_width = Integer.parseInt(strArray[0]);   //窓
          int karten =  Integer.parseInt(strArray[1]);  //カーテン
          int result = 0;
          
          result = K_width - (karten * 2);
          
          if (result <= 0){
         	  result = 0;
          }
          System.out.println(result);
    }
    }

Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
 
char *flag;
int head,rear;
int *que;
int factorial[10];
 
int cal_factorial(int n) {
  if(n == 0) return 1;
  return cal_factorial(n-1)*n;
}
 
int stotag(char *s) {
  int a= 0;
  int i;
  for(i = 0; i < 9; i++) {
    int t,j;
    t = 0;
    for(j = 0; j < i; j++) {
      if(s[j] < s[i]) t++;
    }
    a+= factorial[8-i]*(s[i]-'0'-t);
  }
  return a;
}
 
char *tagtos(int tag) {
  int i;
  char *s;
  s = (char*)malloc(sizeof(char)*10);
  for(i = 0; i < 9; i++) {
    s[i] = tag%factorial[9-i]/factorial[8-i] + '0';
  }
  s[9] = '\0';
  for(i = 7; i >= 0; i--) {
    int j;
    for(j = 8; j > i; j--) {
      if(s[i] <= s[j]) s[j]++;
    }
  }
  return s;
}
 
 
char *move_up(char s[], int x) {
  if(x < 3) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x-3];
  s_new[x-3] = s[x];
  return s_new;
}
 
char *move_left(char s[], int x) {
  if(x%3 == 0) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x-1];
  s_new[x-1] = s[x];
  return s_new;
}
 
char *move_right(char s[], int x) {
  if(x%3 == 2) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x+1];
  s_new[x+1] = s[x];
  return s_new;
}
 
char *move_down(char s[], int x) {
  if(x > 5) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x+3];
  s_new[x+3] = s[x];
  return s_new;
}
 
int create(char s[], int t) {
  if(strcmp(s,"123456780") == 0) return t;
  int tag = stotag(s);
  if(flag[tag]) return 0;
  flag[tag] = t;
  que[rear] = tag;
  rear++;
  return 0;
}
 
int check_x(char *s) {
  int i = 0;
  while(s[i] != '0') i++;
  return i;
}
 
int cal() {
  char *s_right,*s_left,*s_up,*s_down;
  int k,b;
 
  b= que[head];
  char *s = tagtos(b);
  int x = check_x(s);
   
  if((s_right = move_right(s, x)) != NULL) {
    if((k = create(s_right,flag[b]+1))) return k;
    free(s_right);
  }
  if((s_left = move_left(s, x)) != NULL) {
     if((k = create(s_left,flag[b]+1))) return k;
     free(s_left);
  }
  if ((s_up = move_up(s, x)) != NULL) {
    if((k = create(s_up,flag[b]+1))) return k;
    free(s_up);
  }
  if((s_down = move_down(s, x)) != NULL) {
    if((k = create(s_down,flag[b]+1))) return k;
    free(s_down);
  }
  free(s);
  head++;
  return 0;
}
   
 
int solve(char s0[]) {
  int k;
  if((k = create(s0,1))) return k;
   
  while(!(k = cal())) {
    if(head == rear) break;
  }
  return k;
}
 
int main()
{
 
  int i,d;
  char a[10];
  for(i = 0; i < 10; i++) factorial[i] = cal_factorial(i);
  flag = (char*)malloc(sizeof(char)*factorial[9]);
  memset(flag , 0, factorial[9]);
  que = (int*)malloc(sizeof(int)*factorial[9]);
  head = 0;
  rear = 0;
  for (i = 0; i < 9; i++) {
    scanf("%d", &d);
    a[i] = d+'0';
  }
  a[9] = '\0';
  printf("%d\n",solve(a)-1);
   
  return 0;
}


Measured memory_bytes: 2872
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=(n)-1;i>j-1;i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

struct friendfind{
    
    vector<lli> par;
    
    friendfind(lli n){
        lli i;
        rep(i,0,n){
            par.push_back(i);
        }
    }
    
    lli root(lli x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=root(par[x]);
        }
    }
    
    void unit(lli a, lli b){
        lli ax=root(a);
        lli bx=root(b);
        if(ax!=bx){
            par[ax]=bx;
        }
    }
    
    void answer(){
        lli i,a=0;
        map<lli,lli> mp;
        rep(i,0,par.size()){
            mp[root(i)]++;
        }
        for(auto itr=mp.begin();itr!=mp.end();itr++){
            a=max(a,itr->second);
        }
        cout<<a<<endl;
    }
    
};

int main(){
    lli n,m,a,b;
    lli i,j;
    cin>>n>>m;
    friendfind bro(n);
    rep(i,0,m){
        cin>>a>>b;
        bro.unit(a-1,b-1);
    }
    bro.answer();
}


Measured memory_bytes: 17136
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
//Proof:
//Complexity:
ll power(ll a, ll b){
    ll res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int main(){
    SPEED;
    ll h;
    cin>>h;
    ll cnt=0,i=1,j=0;
    while(h!=0){
        h/=2;
        cnt+=i;
        i*=2;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int read(int *a)
{
    int h,w;
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0)
        return 0;
    a[0] = h;   a[1] = w;
    return 1;
}

void printChess(int *a)
{
    int i, j;
    char sym[] = {'#', '.'};

    for(i=0;i<a[0];i++) {
        for(j=0;j<a[1];j++) {
            printf("%c", sym[(i%2+j%2) % 2]);
        }
        putchar('\n');
    }
}

int main(void)
{
    int i, idx = 0;
    int data[100][2];

    while(read(data[idx++]) != 0);

    for(i=0;i<idx-1;i++) {
        printChess(data[i]);
        putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 576
#include <stdio.h>
#define MAX_NUM 100

void swap(int* one, int* another){
    int buf;
    buf = *one;
    *one = *another;
    *another = buf;    
}

int main(void){
    int num[MAX_NUM];
    int N;
    int i, j;
    int sumEven = 0;
    int sumOdd = 0;
    int maxarg;
    scanf("%d",&N);
    for (i = 0; i < N; i++){
        scanf("%d",&num[i]);
    }

    for (i = 0; i < N; i++){
        maxarg = i;
        for (j = i; j < N; j++){
            if(num[maxarg] <= num[j]){
                maxarg = j;
            }
        }
        //printf("%d %d\n",i,maxarg);
        swap(&num[i], &num[maxarg]);
    }

    for (i = 0; i < N; i++){
        //printf("%d",num[i]);
        if (i % 2 == 0){
            sumEven += num[i];
        } else {
            sumOdd += num[i];
        }
    }
    printf("%d",sumEven - sumOdd);
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int h[100010];
    for (int i=0;i<n;i++) cin >> h[i];
    
    int i = n-1;
    while (i >= 1){
        if (h[i] < h[i-1]){
            h[i-1] -= 1;
        }
        if (h[i] < h[i-1]) break;
        i--;
    }
    if (i != 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string t,p;cin>>t>>p;
  int nowi=0;
  vector<int> use_front(0);
  vector<int> use_back(0);
  int i;
  rep(i,t.size())
  {
    if(t[i]==p[nowi])
    {
      use_front.emplace_back(i);
      nowi++;
    }
    if(nowi>=p.size())break;
  }
  nowi=p.size()-1;
  for(i=t.size()-1;i>=0;i--)
  {
    if(t[i]==p[nowi])
    {
      use_back.emplace_back(i);
      nowi--;
    }
    if(nowi<0)break;
  }
  if(use_front.size()<p.size()||use_back.size()<p.size())
  {
    cout<<"no"<<endl;
  }
  else
  {
    reverse(all(use_back));
    if(use_back==use_front)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  
}



Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
int c[N]={0};
typedef struct cities{
    int num;
    long long year;
    int t;
    int st;
}city;
city b[N];
bool cmp1(cities s1,cities s2){
    if(s1.num == s2.num){
        return (s1.year<s2.year)?true:false;
    }
	else{
        return (s1.num<s2.num)?true:false;
    }
}
bool cmp2(cities s1,cities s2){
    return (s1.t<s2.t)?true:false;
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=m;i++){
    	scanf("%d %d",&b[i].num,&b[i].year);
        b[i].t = i;
    }
    sort(b+1,b+m+1,cmp1);
    for(int i = 1;i<=m;i++){
        b[i].st = c[b[i].num];
        c[b[i].num]++;
    }
    sort(b+1,b+m+1,cmp2);
    for(int i =1;i<=m;i++){
        printf("%06d%06d\n",b[i].num,b[i].st+1);
    }
    return 0;
}

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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end(),greater<int>());
	int Alice = 0;
	int Bob = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			Alice += a[i];
		}
		else {
			Bob += a[i];
		}
	}
	cout<<Alice-Bob;
	return 0;
}

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

int main() {
  int D, G;
  cin >> D >> G;

  vector<int> p(D + 1), c(D + 1);
  rep1(i, D) {
    int a, b;
    cin >> a >> b;
    p.at(i) = a;
    c.at(i) = b;
  }

  int ans = 10000;

  for (int i = 0; i < (1 << D); i++) {
    bitset<11> bs(i);
    bs <<= 1;
    int sum = 0, count = 0;

    // コンプしたものを足す
    for (int j = D; j > 0; j--) {
      if (bs.test(j)) {
        sum += p.at(j) * j * 100 + c.at(j);
        count += p.at(j);
      }
    }

    if (count > ans) continue;
    if (sum >= G) {
      ans = count;
      continue;
    }

    // コンプしてないものを足す
    for (int j = D; j > 0; j--) {
      if (bs.test(j)) continue;  // コンプ済み

      rep(k, p.at(j) - 1) {
        if (sum >= G) break;
        sum += j * 100;
        count += 1;
      }

      if (count >= ans) break;
      if (sum >= G) {
        ans = count;
        break;
      }
    }
  }

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


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = ''
if len(s) == 3:
    ans = s[::-1]
else:
    ans = s
print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a>b)swap(a,b);
	if(a<=c&&c<=b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
import collections
n, k = map(int, input().split())
W = collections.deque()
for i in range(n):
    W.append(int(input()))
left = max(math.ceil(sum(W) / k), max(W))
right = sum(W)
center = (left + right) // 2
# print('------')
while left < right:
    i = 1
    track = 0
    # print(center)
    for w in W:
        # if center == 26:
        #     print('track: ' + str(track))
        track += w
        if track > center:
            track = w
            i += 1
            if i > k:
                left = center + 1
                break
    else:
        right = center
    center = (left + right) // 2
print(center)


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


void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

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

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int h,w,k;
  scanf("%d%d%d",&h,&w,&k);

  for(int i=0;i<=h;i++){
    for(int j=0;j<=w;j++){

      int now=(w*i)+(h*j)-2*i*j;

      if(now==k){
        printf("Yes\n");

        return 0;
      }

    }
  }

  printf("No\n");

  return 0;
}

Measured memory_bytes: 1632
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    bool ok = true;
    int count = 1;
    int ans = 0;
    while (ok) {
        if (n / count == 0) {
            ok = false;
            break;
        }
        else {
            ans++;
        }
        count = count * k;
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
int main() {
    int n; scanf("%d", &n);
    int s = 0;
    for(int i = 1; i<= n; i++)
    {
        if(i%2!=0)
            s++;
    }
    printf("%0.15lf", (double)s / (double)n);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000021
using namespace std;
int w,h;
int par[N],Rank[N];
char mp[1001][1001];

void init(){
  for(int i=0;i<N;i++) par[i]=i,Rank[i]=0;
}

int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(Rank[x]<Rank[y])par[x]=y;
  else par[y]=x,Rank[x]+=(Rank[x]==Rank[y]);
}

bool same(int x,int y){return find(x)==find(y);}
int Pos(int x,int y){return w*y+x;}

int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
void umeru(){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      for(int k=0;k<4;k++){
	int ni=i+dy[k],nj=j+dx[k];
	if(mp[i][j]=='#')continue;
	if(ni<0||nj<0||ni>=h||nj>=w||mp[ni][nj]=='#')continue;
	unite(Pos(j,i),Pos(nj,ni));
      }
}

void umeru2(int x,int y){
  for(int i=0;i<4;i++){
    int ny=y+dy[i],nx=x+dx[i];
    if(ny<0||nx<0||ny>=h||nx>=w||mp[ny][nx]=='#')continue;
    unite(Pos(x,y),Pos(nx,ny));
  }
}

int main(){
  init();
  cin>>w>>h;
  int t;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
      if(mp[i][j]=='t')t=Pos(j,i);
    }
  umeru();
 
  int n,ans=-1;
  if(same(0,t)) ans=0;
  cin>>n;
  for(int i=1,a,b;i<=n;i++){
    cin>>a>>b;
    umeru2(a,b);
    mp[b][a]='.';
    if(same(0,t)&&ans==-1)ans=i;
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 11888
import java.util.Scanner;

class Main {

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

        double r = scan.nextDouble();
        double x;
        double y;

        x = r * r * Math.PI;
        y = 2 * r * Math.PI;

        System.out.printf("%f %f\n", x, y);
    }
}


Measured memory_bytes: 28112
#include <bits/stdc++.h>
#include<iostream>
#include<functional>
using namespace std;
#define for_n for(long i=0 ; i<n ; i++)
int main()
{
    map<string,long> m;
    long n,max=0;
    cin>>n;
    string s;
    for_n
    {
        cin>>s;
        m[s]++;
        if(m[s]>max)
        {
            max=m[s];
        }
    }
    for(auto &el1:m)
    {
        if(el1.second==max)
        {
            cout<<el1.first<<endl;
        }
    }

    return 0;
}


























Measured memory_bytes: 25216
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int n;
  cin>>n;
  cout<<n*n*n;
	return 0;
}


Measured memory_bytes: 256
a,b,m = map(int,input().split())

r = tuple(map(int,input().split()))
d = tuple(map(int,input().split()))

ans = min(r)+min(d)

for i in range(m):
    x,y,c = map(int,input().split())
    ans = min(ans,r[x-1]+d[y-1]-c)
    
print(ans)

Measured memory_bytes: 24844
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n=int(input())
    XYH=[tuple(map(int,input().split())) for i in range(n)]
    XYH.sort(key=itemgetter(2),reverse=True)
    for cy in range(101):
        for cx in range(101):
            hc=XYH[0][2]+abs(cx-XYH[0][0])+abs(cy-XYH[0][1])
            for x,y,h in XYH:
                if h!=max(0,hc-abs(x-cx)-abs(y-cy)):
                    break
            else:
                print(cx,cy,hc)
                sys.exit()

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, M = sc.nextInt()
    val A = Array.fill(M)(sc.nextInt()).toSet

    // dp(i) := i段目にたどり着くための移動方法が何通りか？
    // 最終的にdp(N) を求める
    var dpi_a = BigInt(1)
    var dpi_b = BigInt(0)

    if (A.contains(1))
      dpi_b = BigInt(0)
    else
      dpi_b = dpi_a

    (1 until N) foreach { i =>
      if (A.contains(i+1)) {
        // 壊れているので0通り
        dpi_a = dpi_b
        dpi_b = BigInt(0)
      } else { // 壊れていないので, 一個前と二個前のをたす
        val temp = dpi_b
        dpi_b = dpi_a + dpi_b
        dpi_a = temp
      }
    }
    println(dpi_b % 1000000007)
  }

}


Measured memory_bytes: 114176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[11],b[11],c[11],A,B,C;
    cin>>a>>b>>c;
    A = toupper(a[0]);
    B = toupper(b[0]);
    C = toupper(c[0]);
    cout<<A<<B<<C<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

#define dbg(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T>& a) {
  for (int i = 0; i < (int)a.size(); ++i)
    os << a[i] << " \n"[i == (int)a.size() - 1];
  return os;
}

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ll n, d;
  cin >> n >> d;
  ll x, y;
  ll ans = 0;
  rep(i, 0, n) {
    cin >> x >> y;
    ll a = x * x + y * y;
    if (a <= d * d) ++ans;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  if(a <= 0 && 0 <= b) {
    printf("Zero\n");
    return 0;
  }
  if(a > 0) {
    printf("Positive\n");
    return 0;
  }
  bool neg = false;
  if(a < 0 && abs(a)%2) {
    neg = !neg;
  }
  if(b < 0 && abs(b)%2 == 0) {
    neg = !neg;
  }
  if(neg) {
    printf("Negative\n");
  }
  else {
    printf("Positive\n");
  }
}


Measured memory_bytes: 256