akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 330000
using namespace std;
inline char gc(){
	static char now[1<<16],*T,*S;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0;char ch=gc();
	while(ch<'0'||ch>'9') ch=gc();
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=gc();}
	return x;
}
struct node{
	int l,r;
}line[N];
inline bool cmp(node a,node b){return a.l<b.l;}
struct node1{
	int left,right,v;
}tree[N*20];
int num,n,m,root[N];
inline void insert1(int &x,int l,int r,int p){
	tree[++num]=tree[x];x=num;tree[x].v++;if (l==r) return;
	int mid=l+r>>1;if (p<=mid) insert1(tree[x].left,l,mid,p);else insert1(tree[x].right,mid+1,r,p);
}
inline int query(int rt1,int rt2,int l,int r,int l1,int r1){
	if (l1<=l&&r1>=r) return tree[rt2].v-tree[rt1].v;
	int mid=l+r>>1;int tmp=0;if (l1<=mid) tmp+=query(tree[rt1].left,tree[rt2].left,l,mid,l1,r1);
	if (r1>mid) tmp+=query(tree[rt1].right,tree[rt2].right,mid+1,r,l1,r1);return tmp;
}
int main(){
	//freopen("arc.in","r",stdin);
	n=read();m=read();
	for (int i=1;i<=n;++i) line[i].l=read(),line[i].r=read();
	sort(line+1,line+n+1,cmp);int tot=0;printf("%d\n",n);
	for (int i=1;i<=m;++i){root[i]=root[i-1];//printf("%d ",tree[root[i]].v);
	while(line[tot+1].l==i) insert1(root[i],1,m,line[tot+1].r),++tot;}//printf("%d\n",tree[root[i]].v);}
	for (int len=2;len<=m;++len){
		int j=len,tmp=0,now=m%len;now=m-now;
		for (;j<=m;j+=len) tmp+=query(root[j-len],root[j-1],1,m,j-len+1,j-1);
		if(now<m) tmp+=query(root[now],root[m],1,m,now+1,m);//printf("%d\n",tmp);
		printf("%d\n",n-tmp);
	}
	return 0;
}

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

int main()
{
    // Input
    int n;
    cin >> n;
    vector<int> heap(n + 1);
    for (int i = 0; i < n; ++i) {
        int key;
        cin >> key;
        heap[i + 1] = key;
    }

    // Output
    for (int i = 1; i <= n; ++i) {
        cout << "node " << i << ": key = " << heap[i] << ", ";
        if (i > 1) {
            cout << "parent key = " << heap[i / 2] << ", ";
        }
        if (i * 2 <= n) {
            cout << "left key = " << heap[i * 2] << ", ";
        }
        if (i * 2 + 1 <= n) {
            cout << "right key = " << heap[i * 2 + 1] << ", ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3008
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 800005;

int ehead[maxn],ecnt=1,deg[maxn];
struct edge {
	int u,v,next;
}edg[maxn];
void add(int u,int v) {
	edg[++ecnt]=(edge){u,v,ehead[u]};
	ehead[u]=ecnt;deg[u]++;
	edg[++ecnt]=(edge){v,u,ehead[v]};
	ehead[v]=ecnt;deg[v]++;
}
int n,a[maxn],b[maxn],w[maxn],vis[maxn],ra,rb;

void Euler(int u)
{
	for (int &j=ehead[u];j;j=edg[j].next)
	if (!vis[j>>1]) {
		vis[j>>1]=true;
		int v=edg[j].v;Euler(v);
		if (u==v+n) w[v]=-1;
		if (v==u+n) w[u]=1;
	}
}
int main()
{
	#ifdef Amberframe
		freopen("agc018f.in","r",stdin);
		freopen("agc018f.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) scanf("%d",&b[i]);
	for (int i=1;i<=n;i++) if (a[i]!=-1) add(i,a[i]);else ra=i;
	for (int i=1;i<=n;i++) if (b[i]!=-1) add(i+n,b[i]+n);else rb=i+n;
	add(0,ra);add(0,rb);
	for (int i=1;i<=n;i++)
		if ((deg[i]&1)!=(deg[i+n]&1)) {puts("IMPOSSIBLE");return 0;}
	puts("POSSIBLE");
	for (int i=1;i<=n;i++) if (deg[i]&1) add(i,i+n);
	Euler(0);for (int i=1;i<=n;i++) printf("%d ",w[i]);
	return 0;
}

Measured memory_bytes: 31488
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    private static final int MOD = (int) 1e9 + 7;
    int N,M;
    int[] a;
    private void solve() {
        N = nextInt();
        M = nextInt();
        a = new int[M];
        for(int i = 0;i < M;i++) {
            a[i] = nextInt();
        }

        boolean[] ng = new boolean[N + 1];
        for(int i = 0;i < M;i++) {
            ng[a[i]] = true;
        }

        long[] dp = new long[N + 1];
        dp[0] = 1;
        for(int i = 0;i < N;i++) {
            if (ng[i]) continue;
            if (!ng[i + 1]){
                dp[i + 1] += dp[i];
                dp[i + 1] %= MOD;
            }
            if (i + 2 <= N && !ng[i + 2]) {
                dp[i + 2] += dp[i];
                dp[i + 2] %= MOD;
            }
        }

        out.println(dp[N]);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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


int main() {

	int N;
	string S;
	int K;

	cin >> N;
	cin >> S;
	cin >> K;


	int key = S.at(K - 1);


	for (int i = 0; i < N; i++) {
	
		if (S.at(i) != key) {
			S.at(i) = '*';
		}
	}

	cout << S << endl;
	
}

Measured memory_bytes: 256
N = int(input())
d = dict(zip([i for i in range(1, N+1)], [[] for _ in range(N)]))
 
for i in range(N-1):
  u, v, w = map(int, input().split())
  d[u].append([v, w])
  d[v].append([u, w])
  
colors = [0 for i in range(N)]
l = [[1, 1]]
while l:
  node, parent = l.pop()
  edges = d[node]
  for v, w in edges:
    if v == parent:
      continue
    colors[v-1] = (colors[node-1]+w)%2
    l.append([v, node])
    
for c in colors:
  if c==1:
    print(0)
  else:
    print(1)

Measured memory_bytes: 53528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	if (n == 2){
		cout << 1 << endl;
		return 0;
	}
	set <ll> factor;
	for (int z=2;z<=sqrt(n);z++){
		if (n % z == 0){
			factor.insert(z);
			factor.insert(n/z);
		}
	}
	set <ll> ans;
	ans.insert(n);
	ans.insert(n-1);
	for (ll i : factor){
		ll t = n;
		while (t % i == 0){
			t /= i;
		}
		if (t%i == 1) ans.insert(i);
	}
	n--;
	for (int z=2;z<=sqrt(n);z++){
		if (n % z == 0){
			ans.insert(z);
			ans.insert(n/z);
		}
	}
	cout << ans.size() << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x1,x2,x3,x4,x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if(x1==0){cout<<1<<endl;}
  if(x2==0){cout<<2<<endl;}
  if(x3==0){cout<<3<<endl;}
  if(x4==0){cout<<4<<endl;}
  if(x5==0){cout<<5<<endl;}
}

Measured memory_bytes: 3584
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = int64_t;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
 int n;
 cin>>n;
 vector<int>a(n);
 int cnt=1;
 int flag=0;
 cin>>a.at(0);
 rep(i,n-1){
   cin>>a.at(i+1);
   if(flag==0){
     if(a.at(i+1)>a.at(i)){
       flag=1;
     }
     if(a.at(i+1)<a.at(i)){
       flag=-1;
     }
   }
   if(flag==1){
     if(a.at(i+1)<a.at(i)){
       cnt+=1;
       flag=0;
     }
   }
   if(flag==-1){
     if(a.at(i+1)>a.at(i)){
       cnt+=1;
       flag=0;
     }
   }
   
 }

 cout<<cnt<<endl;
}




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

int main()
{
    int N,K,S;
    cin>>N>>K>>S;
    for(int j=0; j<K; j++) cout<<S<<" ";
    for(int j=0; j<N-K; j++) 
        if(S==1e9) cout<<S-1<<" ";
        else cout<<S+1<<" ";
    return 0;
}


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

int main(void){
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
    int ans=0;
    if (N<=K) ans=N*X;
    else ans=K*X+(N-K)*Y;
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    int edge = sqrt((x1 - x2) ^ 2 + (y1 - y2) ^ 2);
    static const double pi = 3.141592653589793;
    x3 = round(x2 + (x2 - x1) * cos(pi / 2) - (y2 - y1) * sin(pi / 2));
    y3 = round(y2 + (x2 - x1) * sin(pi / 2) + (y2 - y1) * cos(pi / 2));
    x4 = round(x3 + (x3 - x2) * cos(pi / 2) - (y3 - y2) * sin(pi / 2));
    y4 = round(y3 + (x3 - x2) * sin(pi / 2) + (y3 - y2) * cos(pi / 2));
    printf("%d %d %d %d", x3, y3, x4, y4);
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(n):
    for j in range(a[i]):
        s.append(i+1)
for i in range(h):
    x = []
    for j in range(w):
        x.append(s[w*i+j])
    if i % 2 == 0:
        print(*x)
    else:
        print(*x[::-1])

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

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


	return 0;
}

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

const int Maxn = 2005;
const int Inf = 1000000007;

int n, K;
vector <int> neigh[Maxn];
int L[Maxn], cnt[Maxn];
int dp[Maxn][Maxn];
int res = Inf;

void Traverse(int v, int p)
{
    dp[v][0] = 0;
    L[v] = 0;
    cnt[v] = 1;
    for (int i = 0; i < neigh[v].size(); i++) {
        int u = neigh[v][i];
        if (u == p) continue;
        Traverse(u, v);
        for (int j = L[v]; j >= 0; j--) {
            int my = dp[v][j]; dp[v][j] = Inf;
            for (int k = 0; k <= L[u]; k++) if (j + k <= K)
                dp[v][max(j, k)] = min(dp[v][max(j, k)], my + dp[u][k]);
        }
        L[v] = max(L[v], L[u]);
        cnt[v] += cnt[u];
    }
    for (int i = 0; i <= L[v] && i <= K; i++)
        res = min(res, dp[v][i] + n - cnt[v]);
    L[v]++;
    for (int i = L[v]; i > 0; i--)
        dp[v][i] = dp[v][i - 1];
    dp[v][0]++;
}

int main()
{
    scanf("%d %d", &n, &K);
    for (int i = 0; i < n - 1; i++) {
        int a, b; scanf("%d %d", &a, &b);
        neigh[a].push_back(b);
        neigh[b].push_back(a);
    }
    fill((int*)dp, (int*)dp + Maxn * Maxn, Inf);
    Traverse(1, 0);
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 16256
#include<cstdio>
int main(){
  char s[11];
  int n;
  char march[] = {'M', 'A', 'R', 'C', 'H'};
  long int d[5] = {0, 0, 0, 0, 0};
  int p[5] = {0, 1, 2, 3, 4};
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%s", s);
    for(int j = 0; j < 5; j++)
      if(s[0] == march[j]) d[j]++;
  }
  //printf("%d %d %d %d %d\n", d[0], d[1], d[2], d[3], d[4]);
  long int sum = 0;
  for(int i = 0; i < 3; i++){
      for(int j = i+1; j < 4; j++){
          for(int k = j+1; k < 5; k++){
            sum += d[i] * d[j] * d[k];
          }
      }
  }
  /*do{
    sum += d[p[0]] * d[p[1]] * d[p[2]];
  } while(std::next_permutation(p, p+4));
  */
  printf("%ld\n", sum);
  return 0;
}


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

int N, T, c[1004], t[1004], ans;
int main(){
	scanf("%d %d", &N, &T);
	ans = 1e9;
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &c[i], &t[i]);
		if (t[i] <= T) {
			ans = min(ans, c[i]);
		}
	}
	if (ans > 100000) {
		printf("TLE\n");
		return 0;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << std::fixed << std::setprecision(10);

	string s;
	cin >> s;
	int q;
	cin >> q;

	string front, back;

	int flag = 1;
	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;
		if (t == 1) {
			flag *= -1;
			continue;
		}
		int f;
		string c;
		cin >> f >> c;
		if (f == 1) {
			if (flag == 1)front += c;
			else back += c;
		}
		else {
			if (flag == -1)front += c;
			else back += c;
		}
	}

	if (flag == 1) {
		reverse(front.begin(), front.end());
		s = front + s + back;
	}
	else {
		reverse(s.begin(), s.end());
		reverse(back.begin(), back.end());
		s = back + s + front;
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 1200
let inline scan () = System.Console.ReadLine()
let inline split (s: string) = s.Split(' ')

let xs = scan () |> split |> Array.map int

let (m, app) =
  match xs |> Array.map (fun x -> x % 2) |> Array.sum with
    | 0 -> (1, 0)
    | 1 -> (0, 1)
    | 2 -> (1, 1)
    | 3 -> (0, 0)

let xs' = [
    for x in xs do
      if x % 2 = m then
        yield x + 1
      else
        yield x
  ]

let max = List.max xs'
printfn "%i" <|
  (xs' |> Seq.map (fun x -> (max - x) / 2) |> Seq.sum) + app 


Measured memory_bytes: 14172
cards = list()
suit = ['S', 'H', 'C', 'D']
n = int(input())
for i in range(n):
    s,r = input().split()
    r = int(r)
    if s == "S": cards.append(0 + r)
    elif s == "H": cards.append(13 + r)
    elif s == "C": cards.append(26 + r)
    elif s == "D": cards.append(39 + r)
for i in range(1,53):
    if not (i in cards):
        print(suit[(i-1)//13], (i-1)%13+1)



Measured memory_bytes: 5608
n = int(input())
restaurant = []
for i in range(n):
  s, p = input().split()
  d = str(100 - int(p))
  restaurant.append((s + '0' * (13 - len(s) - len(d)) + d, i+1))
restaurant.sort()
for rest in restaurant:
  print(rest[1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,res=0,fb=0,la=0,wa=0;cin>>n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin>>s[i];
    }
    for (int i = 0; i < n; i++) {
        int len=s[i].length();
        if(s[i][0]=='B')fb++;
        if(s[i][len-1]=='A')la++;
        if(s[i][0]=='B' and s[i][len-1]=='A')wa++;
        for (int j = 1; j < len; j++) {
            if(s[i][j]=='B' and s[i][j-1]=='A')res++;
        }
    }
    if(fb==wa and la==wa and wa!=0) res+=wa-1;
    else res+=min(fb,la);
    cout<<res<<endl;
}


Measured memory_bytes: 768
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
ans = [[0]*3 for _ in range(n)]

ans[0][0] = abc[0][0]
ans[0][1] = abc[0][1]
ans[0][2] = abc[0][2]

for i in range(1, n):
    ans[i][0] = max(ans[i-1][1], ans[i-1][2]) + abc[i][0]
    ans[i][1] = max(ans[i-1][0], ans[i-1][2]) + abc[i][1]
    ans[i][2] = max(ans[i-1][0], ans[i-1][1]) + abc[i][2]

print(max(ans[-1]))

Measured memory_bytes: 47384
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

auto inc(set<int> &st,set<int>::iterator it){
	if(it == st.end()) return it;
	else return ++it;
}

auto dec(set<int> &st,set<int>::iterator it){
	if(it == st.begin()) return it;
	else return --it;
}

int n,p[100010],ans = 0;

int val(set<int> &st,set<int>::iterator it){
	if(it == st.end()) return n;
	else return *it;
}

signed main(){
	vector<P> vec;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> p[i];
		vec.pb(P(p[i],i));
	}
	sort(all(vec),greater<P>());
	set<int> st;
	st.insert(-1);
	for(int i = 0;i < n;i++){
		int ind = vec[i].second;
		if(i){
			auto ip1 = st.lower_bound(ind),ip2 = inc(st,ip1),im1 = dec(st,ip1),im2 = dec(st,im1);
			//cout << val(st,im2) << " " << val(st,im1) << " " << val(st,ip1) << " " << val(st,ip2) << " " << endl;
			ans += vec[i].first * ((val(st,ip2) - val(st,ip1)) * (ind - val(st,im1)) + (val(st,ip1) - ind) * (val(st,im1) - val(st,im2)));
		}
		st.insert(ind);
	}
	cout << ans << endl;
}

Measured memory_bytes: 7280
#include <stdio.h>
int main(void)
{
    long long int n,m;
    scanf("%lld %lld",&n,&m);
    if(n==1 && m==1)
    {
        printf("1");
        return 0;
    }
    long long int ans;
    if(n==1 || m==1)
    {
        ans=n+m-3;
        printf("%lld",ans);
    }
    else
    {
        ans=(n-2)*(m-2);
        printf("%lld",ans);
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  1000000007;

     signed main(){
         int n,m;
         cin>>n>>m;
         pair<int,int> p[m];int a,b;
         for(int i=0;i<m;i++){
              cin>>a>>b;p[i]=make_pair(b,a);
         }
         sort(p,p+m);
         int q=p[0].first,ans=1;
         for(int i=0;i<m;i++){
              if(p[i].second>=q){
                   ans++;
                   q=p[i].first;
              }
         }
         cout<<ans<<endl;



      }

        


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main() {
	vector<int> factorial = {1, 2, 6, 24, 120, 720, 5040};
	int N;
	cin >> N;
	vector<int> P(N), Q(N);
	for (int i = 0; i < N; i++) {
		cin >> P.at(i);
	}
	for (int i = 0; i < N; i++) {
		cin >> Q.at(i);
	}

	int p = 0, cnt1 = 0, cnt2 = 0;
	while (p < N - 1) {
		int tmp = P.at(p);
		if (p == N - 2) {
			if (tmp == 1) cnt1++;
			else cnt1 += 2;
		}
		if (tmp != 1 && p != N - 2) {
			cnt1 += factorial.at(N - 2 - p) * (tmp - 1);
		}
		for (int i = p + 1; i < N; i++) {
			if (P.at(i) > tmp) P.at(i) -= 1;
		}
		p++;
	}

	p = 0;
	while (p < N - 1) {
		int tmp = Q.at(p);
		if (p == N - 2) {
			if (tmp == 1) cnt2++;
			else cnt2 += 2;
		}
		if (tmp != 1 && p != N - 2) {
			cnt2 += factorial.at(N - 2 - p) * (tmp - 1);
		}
		for (int i = p + 1; i < N; i++) {
			if (Q.at(i) > tmp) Q.at(i) -= 1;
		}
		p++;
	}

	cout << abs(cnt1 - cnt2) << endl;
}

Measured memory_bytes: 256
import numpy as np

def set_list(es):
    return len(list(set(es))) == 1

n = int(input())
a = [int(i) for i in input().split()]

if(len(a)==2):
    print((a[0]+a[1])/2)    
elif(len(a)!=2 and set_list(a)):
    print(a[0])
else:
    for i in range(1,n):
        idx = np.argmin(a)
        num1 = a.pop(idx)
        idx = np.argmin(a)
        num2 = a.pop(idx)
        a.append((num1+num2)/2)
    print(a[0])

Measured memory_bytes: 12504
#include <stdio.h>
#include <stdlib.h>
int main(){
    int N;
    scanf("%d", &N);
    char *a = (char*)malloc(N*sizeof(char));
    scanf("%s", a);
    long int ans = 0;
    for(int i = 0; i <= 10; i++){
        for(int j = 0; j <= 10; j++){
            for(int k = 0; k <= 10; k++){
                int u = 0;
                for(int l = 0; l < N; l++){
                    if(u == 0 && a[l] - '0' == i) {
                        u++;
                        continue;
                    }
                    if(u == 1 && a[l] - '0' == j) {
                        u++;
                        continue;
                    }
                    if(u == 2 && a[l] - '0' == k) {
                        u++;
                        break;
                    }
                }
                if(u == 3) ans++;
            }
        }
    }
    printf("%ld\n", ans);
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}

signed main()
{
    
    
	speed
	int n,m;cin>>n>>m;
	int ac=0,penalty=0;
	vector<bool> solved(n+1,0);
	vector<int> tmp(n+1,0);
	for (int i = 0; i < m; ++i)
	{
		int problem;
		string verdict;cin>>problem>>verdict;
		if(solved[problem]){continue;}
		else
		{
			if(verdict=="AC"){++ac;solved[problem]=1;penalty+=tmp[problem];}
			else{++tmp[problem];}
		}
	}
	cout<<ac<<" "<<penalty<<"\n";
}

Measured memory_bytes: 1024
import math
n = int(input())

def order(a,b):
    return max(len(str(int(a))),len(str(int(b))))
    
ans = [] 


for i in range(1,int(math.ceil(math.sqrt(n)))+1):
    if n % i == 0:
        ans.append(order(n/i,i))

if len(ans) == 0:
    print(1)
else:
    print(min(ans))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    char str;
    while(1){
        if(str == '\n') break;
        scanf("%c",&str);
        if(isalpha(str)){
            if(islower(str)) printf("%c", toupper(str));
            else printf("%c",tolower(str));
        }
        else printf("%c",str);
    }
    return 0;
    
}


Measured memory_bytes: 3136
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <unordered_map>

#define BIG 1000000007

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    int o = max(a * 2 - 1,max(a + b,b * 2 - 1));
    cout << o;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
    int n, i, sum=0, memo;
    scanf("%d",&n);

    char title[n][101], title_memo[101];
    int time[n];

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

    scanf("%s",title_memo);

    for(i=0;i<n;i++){
        if(strcmp(title_memo,title[i])==0){
            memo = i;
            break;
        }
    }

    for(i=memo+1;i<n;i++){
        sum += time[i];
    }

    printf("%d",sum);

    return 0;
}

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C; cin >> A >> B >> C;
    swap(A, B);
    swap(A, C);
    cout << A << ' ' << B << ' ' << C  << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 999999999999

int main(){
  int N,max=0,cnt=0; cin>>N;
  ll H[100000];
  rep(i,N){
    cin>>H[i];
  }
  rep(i,N-1){
    if(H[i]>=H[i+1]) cnt++;
    else if(cnt<=max&&H[i]<H[i+1]) cnt=0;
    else{
      max=cnt; cnt=0;
    }
  }
  if(max<cnt) max=cnt;
  cout<<max<<endl;
return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> E(N);
  for (int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  vector<int> p(N, -1);
  vector<vector<int>> c(N);
  queue<int> q;
  q.push(0);
  while (!q.empty()){
    int v = q.front();
    q.pop();
    for (int w : E[v]){
      if (w != p[v]){
        p[w] = v;
        c[v].push_back(w);
        q.push(w);
      }
    }
  }
  vector<int> A(N, 0);
  for (int i = 0; i < Q; i++){
    int p, x;
    cin >> p >> x;
    p--;
    A[p] += x;
  }
  queue<int> q2;
  q2.push(0);
  while (!q2.empty()){
    int v = q2.front();
    q2.pop();
    for (int w : c[v]){
      A[w] += A[v];
      q2.push(w);
    }
  }
  for (int i = 0; i < N; i++){
    cout << A[i];
    if (i < N - 1){
      cout << ' ';
    }
  }
  cout << endl;
}

Measured memory_bytes: 25856
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

//#define DEBUG_MODE


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

	vector<vector<int>> conn(N+1, vector<int>(0));
	REP(i, M) {
		ll A, B;
		cin >> A >> B;
		conn[A].push_back(B);
		conn[B].push_back(A);
	}

#ifdef DEBUG_MODE
	FOR(i, 1, N+1) {
		cout << i << ": ";
		REP(j, conn[i].size()) {
			cout << conn[i][j] << " ";
		}
		cout << endl;
	}
#endif

	vector<int> ans(N+1, 0);
	queue<int> search_list;

	REP(i, conn[1].size()) {
		search_list.push(conn[1][i]);
		ans[conn[1][i]] = 1;
	}

	while (!search_list.empty()) {
		int n = search_list.front();
		search_list.pop();

		REP(i, conn[n].size()) {
			int m = conn[n][i];
			if (ans[m] != 0) continue;
			search_list.push(m);
			ans[m] = n;
		}

#ifdef DEBUG_MODE
		cout << "search for " << n << endl;
		FOR(i, 2, N+1) {
			cout << i << ": " << ans[i] << endl;
		}
#endif
	}

	cout << "Yes" << endl;
	FOR(i, 2, N+1) cout << ans[i] << endl;

	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

bool ok[128];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	cin >> skipws;

	int n, k; read(n, k);
	rep(i, '0', '9' + 1) ok[i] = 1;
	rep(i, 0, k) {
		char c; read(c);
		ok[c] = 0;
	}

	for (int i = n;; i++) {
		string s = to_string(i);
		bool thisok = true;
		for (char c : s) if (!ok[c]) thisok = false;
		if (thisok) {
			die(i);
		}
	}
}


Measured memory_bytes: 256
var
	X:Longint;
	p,ans:real;
begin
	read(X,p);
	p:=p/100;
	if X mod 2=0 then ans:=X/2/p else ans:=p*(X-1)/2/p+(1-p)*(X+1)/2/p+1;
	writeln(ans:0:9);
end.


Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int N,i,flag;
  int ans = 0;
  scanf("%d",&N);
  int V[N];
  int C[N];
  for(i=0;i<N;i++){
  scanf("%d",&V[i]);
  }
  for(i=0;i<N;i++){
  scanf("%d",&C[i]);
  }
  for(i=0;i<N;i++){
    flag = V[i]-C[i];
    if(flag>=0){
      ans += flag;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
 
    if(b-a==c-b){
    System.out.println("YES");  
    }else{
    System.out.println("NO");    
    }
}
}

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

int main() {
  int FLOORS = 3;
  int ROOMS = 10;
  int first_b[FLOORS][ROOMS];
  int second_b[FLOORS][ROOMS];
  int third_b[FLOORS][ROOMS];
  int fourth_b[FLOORS][ROOMS];

  for (int i = 0; i < FLOORS; i++) {
    for (int j = 0; j < ROOMS; j++) {
      first_b[i][j] = 0;
      second_b[i][j] = 0;
      third_b[i][j] = 0;
      fourth_b[i][j] = 0;
    }
  }

  int n, b, f, r, v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    if (b == 1 ) {
      first_b[f-1][r-1] += v;
    } else if (b == 2) {
      second_b[f-1][r-1] += v;
    } else if (b == 3) {
      third_b[f-1][r-1] += v;
    } else if (b == 4) {
      fourth_b[f-1][r-1] += v;
    }
  }


  for (int i = 0; i < FLOORS; i++) {
    for (int j = 0; j < ROOMS; j++) {
      cout << " " << first_b[i][j];
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (int i = 0; i < FLOORS; i++) {
    for (int j = 0; j < ROOMS; j++) {
      cout << " " << second_b[i][j];
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (int i = 0; i < FLOORS; i++) {
    for (int j = 0; j < ROOMS; j++) {
      cout << " " << third_b[i][j];
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (int i = 0; i < FLOORS; i++) {
    for (int j = 0; j < ROOMS; j++) {
      cout << " " << fourth_b[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1168
N, M = gets.split.map!(&:to_i)
A = []
M.times do
	A << gets.to_i
end
ans = Array.new(N + 2, 0)
M.times do |m|
	ans[A[m]] = -1
end
ans[N] = 1
i = N - 1
while i > -1
	if ans[i] == -1
		ans[i] = 0
	else
		ans[i] = ans[i + 1] + ans[i + 2]
	end
	i -= 1
end
puts ans[0] % 1_000_000_007

Measured memory_bytes: 433020
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long a[]=new long[n];
		for(int i=0;i<n;i++) a[i]=sc.nextLong()-i;
		Arrays.sort(a); long sum=0;
		for(int i=1;i<=n;i++)sum+=Math.abs(a[i-1]-a[(n/2)]);
		System.out.println(sum);
	}
}


Measured memory_bytes: 87432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int min = 1000000001;
  int temp;
  
  
  for(int i = 0 ; i < N ; i++){
     cin >> temp;
     for(int j = 0 ; ; j++){
       if((temp % 2) == 1){
         if(min > j){
           min = j;
         }
         break;
       }
       temp >>= 1;
     }
  }
  
  cout << min << endl;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 16:43:46 2019
//
package main

import (
	"fmt"
	"sort"
)

func max(slice ...int) int {
	sort.Ints(slice)
	return slice[len(slice)-1]
}

type pair struct {
	begin, end int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	return p[i].begin < p[j].begin
}

func main() {
	var N, C int
	fmt.Scan(&N, &C)

	m := map[int]pairs{}
	for i := 0; i < N; i++ {
		var p pair
		var c int
		fmt.Scan(&p.begin, &p.end, &c)
		if _, ok := m[c]; ok {
			m[c] = append(m[c], p)
		} else {
			m[c] = pairs{p}
		}
	}

	for c, v := range m {
		arr := pairs{}
		sort.Sort(v)
		for i := 0; i < len(v); i++ {
			if len(arr) == 0 || arr[len(arr)-1].end != v[i].begin {
				arr = append(arr, v[i])
			} else {
				arr[len(arr)-1].end = v[i].end
			}
		}
		m[c] = arr
	}

	arr := make([]int, 10e5+1)
	for _, v := range m {
		for _, p := range v {
			arr[p.begin-1]++
			arr[p.end]--
		}
	}

	for i := range arr {
		if i+1 < len(arr) {
			arr[i+1] += arr[i]
		}
	}

	fmt.Println(max(arr...))
}


Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200500;
map < int, int > pref;
map < int , int > tmp;
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    long long sum = 0, ans = 0;
    pref[0] = 1;
    tmp[0] = 0;
    for(int i = 1 ; i <= n ;++i){
        if(tmp.find(i - k) != tmp.end())
            pref[tmp[i - k]]--;
        int x;
        cin >> x; sum += x; sum %= k;
        ans += pref[(sum - i%k + k) % k];
        //cout << i << ' ' << (sum - i%k + k) % k << ' ' << pref[(sum - i%k + k) % k] << '\n';
        pref[(sum - i%k + k) % k]++;
        tmp[i] = (sum - i%k + k) % k;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 19072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		if(S.charAt(2)==S.charAt(3) &&
			S.charAt(4)==S.charAt(5) ) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 23764
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void solve();
int main(void) {
  std::cout << std::fixed << std::setprecision(15);
  solve();
	return 0;
}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

void solve(){
  ll N; cin >> N ;
  cout << 3*N*N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int x, y;
    cin >> x;
    cin >> y;
    if(x == y) {
        cout << x * 2;
    }
    else {
        x = max(x, y);
        cout << x + (x - 1);
    }
    return 0;
}



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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

ll  n, k;
vector<ll> vs;
vector<ll> ps;
vector<ll> ms;
ll pp;
ll mm;
ll pCount;
ll mCount;

struct BSearch {
	ll solve1(ll left, ll right, ll k) {
		while (right - left > 1) {
			ll middle = left + right;
			middle /= 2;
			ll uSum = 0;
			ll lSum = 0;
			rep(i, mm) {
				ll c = vs[i];
				auto u = upper_bound(vs.end() - pp, vs.end(), middle / c);
				//kより小さい
				uSum += vs.end() - u;
				auto l = lower_bound(vs.end() - pp, vs.end(), middle / c);
				//k以上
				lSum += l - (vs.end() - pp);
			}
			if (uSum > k) {
				right = middle;
			}
			else if (lSum > mCount - k) {
				left = middle;
			}
			else return middle;
		}
		return right;
	}
	ll solve2(ll left, ll right, ll k) {
		while (right - left > 1) {
			ll middle = left + right;
			middle /= 2;
			ll uSum = 0;
			ll lSum = 0;
			for (int i = 0; i < mm;i++) {
				ll c = ms[i];
				//kより大きい
				auto u = upper_bound(ms.begin() +  i , ms.end(), middle / c);
				uSum += ms.end() - u;
				//以上
				auto l = lower_bound(ms.begin() + i, ms.end(), middle / c);
				lSum += l - (ms.begin() + i);
			}
			for (int i = 0; i < pp; i++) {
				ll c = ps[i];
				//kより大きい
				auto u = upper_bound(ps.begin() + i, ps.end(), middle / c);
				uSum += ps.end() - u;
				//以上
				auto l = lower_bound(ps.begin() + i, ps.end(), middle / c);
				lSum += l - (ps.begin() + i);
			}
			if (uSum > k) {
				right = middle;
			}
			else if (lSum > pCount - k) {
				left = middle;
			}
			else return middle;
		}
		return right;
	}
};


int main(void)
{
	ll n,k;
	cin >> n >> k;
	int d = 0;
	while (n > 0) {
		d++;
		n /= k;
	}
	cout << d << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;


bool is_triangle(int l1, int l2, int l3){
    return (l1 < (l2 + l3)) && (l2 < (l1 + l3)) && (l3 < (l1 + l2));
}

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

    vector<int> L(N);

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

    int cnt = 0;
    for (int i = 0; i < N - 2; i++){
        for (int j = i + 1; j < N - 1; j++){
            for (int k = j + 1; k < N; k++){
                if (is_triangle(L[i], L[j], L[k])){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 888
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

class UnionFind
{
private:
  vector<int> par, sizes;

public:
  UnionFind(int n = 200010) : par(n), sizes(n, 1)
  {
    rep(i, n) par[i] = i;
  }

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

  void unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (sizes[x] < sizes[y])
      swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y)
  {
    return root(x) == root(y);
  }

  int size(int x)
  {
    return sizes[root(x)];
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  UnionFind uf;
  int n, m;
  cin >> n >> m;
  rep(i, m)
  {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    uf.unite(x, y);
  }
  set<int> st;
  rep(i, n)
  {
    st.insert(uf.root(i));
  }
  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 6528
m,i,j,k,c[],p,d;main(n){for(;scanf("%d%d",&n,&m),n;printf("%d\n",j>m?k:j)){for(k=3;k--;)for(scanf("%d",&i);i--;c[j]=k)scanf("%d",&j);for(j=i=0;i++<n;p=c[i]*2+p&3)j+=pow(3,n-i)*abs(p-c[i]);j=fmin(j,pow(3,n)+~j);}}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
 int N, A, B;
 cin >> N >> A >> B;

 int ans = min(A * N, B);
 print(ans);
 
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int arr[10341];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&arr[i]);
    sort(arr,arr+n);
    int ans=0;
    arr[n-1]/=2;
    for(int i=0;i<n;i++) ans+=arr[i];
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n;
	cin>>n;
	vector<P> v(n);
	rep(i, n){
		cin>>v[i].fst;
		v[i].snd = i;
	}
	sort(all(v));
	ll res = 0;
	rep(i, n) if((v[i].snd+i)%2) res++;
	cout<<res/2<<endl;
	return 0;
}


Measured memory_bytes: 1792
/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define trv(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
template<class T>inl bool ylmin(T &a,T b){return a<b?0:(a=b,1);}
template<class T>inl bool ylmax(T &a,T b){return a>b?0:(a=b,1);}
template<class T>inl T abs(T x){return x<0?-x:x;}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
const int MAXN = 2010;
struct Edge{
	int to,next;
}e[MAXN<<1];
char s[MAXN];
int n,u,v,cnt,head[MAXN];
ll ans=1e18,dp[MAXN],sum[MAXN],tot[MAXN],Max[MAXN],pos[MAXN],dep[MAXN];
inl void add(int u,int v){
	e[++cnt]=(Edge){v,head[u]},head[u]=cnt;
}
inl void dfs(int u,int fa){
	tot[u]=s[u]=='1';
	trv(i,u){
		int v=e[i].to;
		if(fa==v) continue;
		dfs(v,u);
		tot[u]+=tot[v];
		sum[u]+=sum[v]+tot[v];
		if(ylmax(Max[u],sum[v]+tot[v])) pos[u]=v;
	}
	if(Max[u]>sum[u]-Max[u]) dp[u]=min(sum[u]/2,sum[u]-Max[u]+dp[pos[u]]); 
	else dp[u]=sum[u]/2;
}
int main(){
	scanf("%d%s",&n,s+1);
	rep(i,2,n) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	rep(root,1,n){
		rep(i,1,n) sum[i]=0,Max[i]=0,tot[i]=0,dp[i]=0;
		dfs(root,root);
		if(dp[root]*2==sum[root]) ylmin(ans,dp[root]);
	} 
	printf("%lld\n",ans==1e18?-1:ans);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    System.out.println(Hoge.isProductPositive(a, b));
  }
}

class Hoge {

  static String isProductPositive(int a, int b) {
    return a * b % 2 == 0 ? "Even" : "Odd";
  }
}

Measured memory_bytes: 21716