akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
 
void init();
void solve();
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
 
#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
 
#define MOD 1000000007
 
signed main()
{
	init();
	solve();
}

string s;

void init()
{
  cin >> s;
}
 
void solve()
{
  string ans = "CODEFESTIVAL2016";
  int res = 0;
  rep(i, 16) res += ans[i] != s[i];
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int H,N;
cin>>H>>N;
int a=0;
int b;
for(int i=0;i<N;i++){
cin>>b;
a+=b;}
if(a>=H){
cout<<"Yes"<<endl;}
else
cout<<"No"<<endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    ll ans = 22222222222;
    for(int i = 0; i < n-k+1; i++){
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<vector>
#include<string>
#include<algorithm>
#include<bitset>
typedef long long ll;
 
#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define MOD 1000000007;
using namespace std;
ll n;
string s;
int main(){
    cin>>n>>s;
    ll r=0,g=0,b=0;
    rep(i,0,n){
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
    }
    ll ans=r*g*b;//条件1を満たす会の個数
    rep(i,0,n){
        rep(j,0,n){
            ll i2=i+j;
            ll i3=i+2*j;
            if(i2>=n||i3>=n)break;
            if(s[i]!=s[i2]&&s[i]!=s[i3]&&s[i2]!=s[i3]){
                ans--;
            }
        }
    }
    puts(ans);
}

Measured memory_bytes: 3648
import sys
import collections
input=sys.stdin.readline


H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input().strip())


def f(sx, sy):
    q = collections.deque()
    q.append((sx, sy))
    dist = [[float("inf") for w in range(W)] for h in range(H)]
    dist[sx][sy] = 0
    dx = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    while q:
        h, w = q.popleft()
        d = dist[h][w]
        for x, y in dx:
            h2 = h + y
            w2 = w + x
            if h2 >= 0 and h2 < H and w2 >= 0 and w2 < W:
                if S[h2][w2] == "." and dist[h2][w2] == float("inf"):
                    dist[h2][w2] = d+1
                    q.append((h2, w2))
    ma = 0
    for d in dist:
        for i in d:
            if i != float("inf"):
                ma = max(ma, i)
    return ma


def main():
    ans = 0
    for y in range(H):
        for x in range(W):
            if S[y][x] == ".":
                ans = max(ans, (f(y, x)))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;


int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<std::vector<uint32>> G(n);
	std::vector<uint32> degree(n, 0);
	uint32 tempa, tempb;
	for (uint32 i = 1;i < n;++i) {
		std::cin >> tempa >> tempb;
		++degree[tempa];
		++degree[tempb];
		G[tempa].push_back(tempb);
		G[tempb].push_back(tempa);
	}
	uint32 root = n;
	for (uint32 i = 0;i < n;++i) {
		if (degree[i] > 2) root = i;
	}
	if (root == n) {
		std::cout << "1\n";
		return 0;
	}
	std::vector<uint32> c(n, 0);
	std::function<void(uint32, uint32)> dfs=[&](uint32 node, uint32 prev) {
		uint32 count1 = 0, count2 = 0, count3 = 0;
		for (uint32 i = 0;i < G[node].size();++i) {
			if (G[node][i] == prev) continue;
			dfs(G[node][i], node);
			if (c[G[node][i]] == 0) ++count2;
			count3 += c[G[node][i]];
			++count1;
		}
		c[node] = count2 ? count3 + count2 - 1 : count3;
	};
	dfs(root, n);
	std::cout << c[root] << "\n";
	return 0;
}

Measured memory_bytes: 12672
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N,K;
  cin >> N >> K;
  int ans = 0;
  while(N>0){
    N /= K;
    ans++;
  }
  cout <<  ans << endl;

}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var cmp= new bool[1000000];
            cmp[0] = true;
            var X = Sarray()[0];
            for(var i=0;i<=X;++i )
            {
                if(cmp[i])
                {
                    for (var j = 0; j <= 5; ++j)
                        cmp[i + 100 + j] = true;
                }
            }
            if (cmp[X])
                WriteLine(1);
            else
                WriteLine(0);

            //Out.Flush();
        }
    }
}

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

using ll = long long int;

int solve(){
    ll q, cnt = 0;
    cin >> q;
    for(int i=0;i<q;i++){
        ll p, n;
        char c;
        cin >> p >> c >> n;
        if(c == '(') cnt += n;
        else cnt -= n;
        cout << (cnt==0 ? "Yes" : "No") << endl;
    }
    return 0;
}

int main(){
    solve();
    return 0;
}


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

int main() {

    int x, a, b;
    int aa, bb;

    cin >> x >> a >> b;

    aa = x - a; if (aa < 0) aa = aa * (-1);
    bb = x - b; if (bb < 0) bb = bb * (-1);
    
    if (aa < bb ) cout << "A" <<endl;
    else cout << "B" <<endl;

    return 0;
}

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

void fnInput(vector<int> &a_rviTarget, vector<int> &a_rviSearch)
{
  int iTargetCnt;
  cin >> iTargetCnt;

  a_rviTarget.resize(iTargetCnt);
  for (int i = 0; i < iTargetCnt; i++)
    cin >> a_rviTarget[i];

  int iSearchCnt;
  cin >> iSearchCnt;

  a_rviSearch.resize(iSearchCnt);
  for (int i = 0; i < iSearchCnt; i++)
    cin >> a_rviSearch[i];
}

void fnBinarySearch(const vector<int> &a_cnrviTarget, const vector<int> &a_cnrviSearch, int &a_riFound)
{
  for (int i = 0; i < a_cnrviSearch.size(); i++)
  {
    int iLow  = 0;
    int iHigh = a_cnrviTarget.size();
    while (iLow < iHigh)
    {
      int iMid = (iLow + iHigh) / 2;
      if (a_cnrviSearch[i] == a_cnrviTarget[iMid])
      {
        a_riFound++;
        break;
      }
      else if (a_cnrviSearch[i] < a_cnrviTarget[iMid])
        iHigh = iMid;
      else
        iLow  = iMid + 1;
    }
  }
}

void fnResultOut(int a_iFound)
{
  cout << a_iFound << endl;
}

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

  vector<int> viTarget, viSearch;
  int iFound = 0;

  fnInput(viTarget, viSearch);
  fnBinarySearch(viTarget, viSearch, iFound);
  fnResultOut(iFound);

  return 0;
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    //int c=0;
    while(t--) {
       string s;
       ll n,i,j;
       cin>>s;
       n=s.length();
       if(s[n-1]=='s')
        s+="es";
       else
        s+='s';
       cout<<s;
    }

}


Measured memory_bytes: 3544
n = int(input())
xy = [[int(item) for item in input().split()] for _ in range(n)]
xy.sort()
pq = []
for x1, y1 in xy:
    for x2, y2 in xy:
        p = x1 - x2
        q = y1 - y2
        if p >= 0 and (p != 0 or q !=0):
            pq.append([p, q])
ans = n
for p, q in pq:
    val = n
    possible = {} 
    for x, y in xy:
        possible[str(x+p) + "_" + str(y+q)] = 1
    for x, y in xy:
        if str(x) + "_" + str(y) in possible:
            val -= 1
    ans = min(ans, val)
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+7;
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
map<int,int>mp;
int p[N],k[N],s[N][N];
int get_bit(int x,int i){return (x>>i)&1;}

int main()
{

     int n,m;
     cin>>n>>m;
     for(int i=1;i<=m;i++) {
         scanf("%d",&k[i]);
         for (int j = 1; j <=k[i];j++)
             scanf("%d",&s[i][j]);
     }
     for(int i=1;i<=m;i++)cin>>p[i];
     int sum=0;
     for(int i=0;i<pow(2,n);i++)
     {
         int f=1;
         for(int r=1;r<=m;r++) {
             int ans=0;
            for(int l=1;l<=k[r];l++)
                if (get_bit(i,s[r][l]-1))
                    ans++;
                if(ans%2!=p[r])
                {
                    f=0;
                    break;
                }
        }
         if(f==1)
             sum++;
     }
     cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>

using namespace std;

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

	int N;
	cin >> N;

	map<int, int> count_info;

	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;

		count_info[a]++;
	}

	long long result = 0;
	for (pair<int, int> e : count_info)
	{
		if (e.first < e.second)
		{
			result += e.second - e.first;
		}
		else if (e.first > e.second)
		{
			result += e.second;
		}
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 4736
var n:longint;
    max,x,min:int64;
    a:array[0..150000]of longint;
    i:longint;
begin
  read(n);
  for i:=1 to n do
  read(a[i]);
  if a[n]<>2 then
  begin
    writeln(-1);
    exit;
  end;
  a[0]:=1;
  max:=2;
  min:=2;
  for i:=n-1 downto 1 do
  begin
    x:=max*2-1;
    if max+a[i+1]-1<x then x:=max+a[i+1]-1;
    x:=x div a[i];
    if (x=0) then
    begin
      writeln(-1);
      exit;
    end else max:=x*a[i];
    x:=min div a[i];
    if min mod a[i]=0 then min:=x*a[i] else min:=(x+1)*a[i];
    if min>max then
    begin
      writeln(-1);
      exit;
    end;
  end;
  writeln(min,' ',max+a[1]-1);
end.
//or(((max+a[i+1]-1) div a[i])-((max-1) div a[i])=0)

Measured memory_bytes: 512
function Main(input) {
  var a = parseInt(input.split(" ")[0]);
  var b = parseInt(input.split(" ")[1]);
  var c = parseInt(input.split(" ")[2]);
  console.log(b+c-Math.min(a, b+c));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 3e2 + 10;

int n;
ll ar[N];
ll sumxor;

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

    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> ar[i];
        if (i > 2) sumxor ^= ar[i];
    }
    ll a = ar[1], b = ar[2];
    if (sumxor > a + b){
        cout << -1 << el;
        return 0;
    }
    ll anb = (a + b - sumxor) / 2LL; // supposedly the new a & b
    ll na = anb, nb = anb; // new a, new b
    if (na > a){
        cout << -1 << el;
        return 0;
    }
    for (ll i=50;i>=0;i--){
        ll bit = (1LL << i);
        if (sumxor & bit){
            if (na + bit < a) na += bit;
            else nb += bit;
        }
    }
    if (na == 0 || (na ^ nb) != sumxor || na + nb != a + b) cout << -1 << el;
    else cout << a - na << el;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-8
#define equal(a,b) (fabs(a-b) < EPS)
#define lt(a,b) (a-b < -EPS)
#define le(a,b) (lt(a,b) || equal(a,b))
#define MAX_N 86401
#define MAX_L 1000000
#define END 86400
 
struct P{
  double s,t,u;
  P(){}
  P(double s,double t,double u) : s(s),t(t),u(u) {}
  bool operator < (const P &p)const{
    return s < p.s;
  }
};

int main(){
  int N;
  double L;
  P p[MAX_N];
  while(cin >> N >> L,N){
    for(int i = 0 ; i < N ; i++){
      cin >> p[i].s >> p[i].t >> p[i].u;
    }
    sort(p,p+N);
    double l = 0, r = MAX_L;
    for(int i = 0 ; i < 150 ; i++){
      double mid = (l + r) / 2.0;
      bool ok = true;
      double rem[2]; rem[0] = L;
      for(int j = 0 ; j < 2 ; j++){
        double prev = 0;
        for(int k = 0 ; k < N ; k++){
          rem[j] = min(L,rem[j]+mid*(p[k].s-prev));
          double d = p[k].t-p[k].s;
          rem[j] = min(L,rem[j]+d*(mid-p[k].u));
          if(le(rem[j],0)){ ok = false; break; }
          prev = p[k].t;
        }
        rem[j] = min(L,rem[j]+mid*(END-prev));
        if(j == 0){ rem[1] = rem[0]; }
        else if(lt(rem[1],rem[0])){
          ok = false;
        }
        if(!ok){ break; }
      }
      if(ok){ r = mid; }else{ l = mid; }
    }
    printf("%.8f\n",r);
  }
  return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <cstdio>
using namespace std;
typedef unsigned long long ll;

ll n, x, s, mn=2e18, a[200005];
int main() {
	ll i, j, k;
	scanf("%lld%lld", &n, &x);
	for(i=1; i<=n; i++) scanf("%lld", &a[i]), a[i] += a[i-1];
	for(int i=1;i<=n;i++){
		k = 2;
		s = (n+i)*x;
		int id = n;
		while(id>0){
			s += (2*k+1)*(a[id]-a[max(id-i,0)]);
			if(id!=n) k++;
			id -= i;
		}
		mn = min(mn, s);
	}
	printf("%lld", mn);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
using namespace std;

int main()
{
    int n;
	double x[1000] = {0};
	double y[1000] = {0};

    cin >> n;
	for ( int i = 0; i < n; i++ )
	{
		cin >> x[i];
	}
		for ( int i = 0; i < n; i++ )
	{
		cin >> y[i];
	}

	double m[1000] = {0};
	double p1 = 0, p2 = 0, p3 = 0, p4 =0, t2 = 0, t3 = 0;
	for ( int i = 0; i < n; i++ )
	{
	m[i] = fabs(x[i]-y[i]);
    p1 += m[i];
	t2 += m[i]*m[i];
	t3 += m[i]*m[i]*m[i];
	}
	p2 = sqrt(t2);
	p3 = pow( t3, 1.0/3 );
	p4 = m[1];
	for ( int i = 0; i < n; i++ )
	{
		m[i] = fabs(x[i]-y[i]);
		if ( p4 < m[i])
		{
			p4 = m[i];
		}
	}
		
    cout << fixed << setprecision(6) << p1 << "\n" ;
	cout << fixed << setprecision(6) << p2 << "\n" ;
	cout << fixed << setprecision(6) << p3 << "\n" ;
	cout << fixed << setprecision(6) << p4 << endl;

	return 0;
}


Measured memory_bytes: 3516
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	cout << fixed << setprecision(6) << a * b / 3.305785 << endl;
	return 0;
}

Measured memory_bytes: 1236
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    int a, b, c;

    cin >> a >> b >> c;

    if (a == b and b == c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m,x,y,z;
	scanf("%d%d%d",&n,&m,&k);
	if(k==1)
	{
		for(i=0;i<m;i++)
		{
			printf("%d ",1);
		}
		for(i=m;i<n;i++)
		{
			printf("%d ",2);
		}
		return 0;
	}
	if(m==n)
	{
		for(i=0;i<n;i++)
		{
			printf("%d ",k);
		}
		return 0;
	}
	x=k+1;
	if(k==1e9)
	{
		x=1;
	}
	y=0;
	for(i=0;i<m+1;i++)
	{
		printf("%d ",y?k/2:k-k/2);
		y=y^1;
	}
	for(i=m+1;i<n;i++)
	{
		printf("%d ",x);
	}
}


Measured memory_bytes: 1280
#include<stdio.h>
main(){
  int a[1000000]={0},i,j,n,cnt;
  while(scanf("%d",&n)!=EOF){
    for(i=0;i<=n;i++)a[i]=0;
    cnt=0;
    for(i=2;i<=n;i++){
      if(a[i]==0){
    cnt++;
    for(j=1;i*j<=n;j++){
      a[i*j]=1;
    }      
      }
    }
 
 
    printf("%d\n",cnt);
  }
  return 0;
}


Measured memory_bytes: 5704
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int a, b;
	cin >> a >> b;
    int ans = ceil((double)(b-1)/(a-1));
	cout << ans << endl;
	return 0;
}


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

int main() {
	int N, K; cin >> N; cin >> K;
	vector<pair<long, long>> V(N);
	vector<long> X(N);
	vector<long> Y(N);
	for (int i = 0; i < N; i++) {
		long x, y; cin >> x; cin >> y;
		X[i] = x; Y[i] = y;
		V[i] = make_pair(x, y);
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	long ans = 4000000000000000000;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int l = k + 1; l < N; l++) {
					long x1 = X[i];
					long x2 = X[j];
					long y1 = Y[k];
					long y2 = Y[l];
					int cnt = 0;
					for (int n = 0; n < N; n++) {
						if (x1 <= V[n].first and V[n].first <= x2 and y1 <= V[n].second and V[n].second <= y2) {
							cnt += 1;
						}
					}
					if (cnt >= K) {
						ans = min(ans, (x2 - x1) * (y2 - y1));
					}
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int main(){
	int a=read(),b=read(),c=read(),minn=0x3f3f3f3f;
	minn=min(minn,abs(a-b)+abs(a-c));
	minn=min(minn,abs(a-b)+abs(b-c));
	minn=min(minn,abs(c-b)+abs(a-c));
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
typedef long long LL;

LL N, A, B, C, D;

int main()
{
	scanf("%lld %lld %lld %lld %lld", &N, &A, &B, &C, &D);
	bool check = false;
	for(int i = 2; i <= N - 1; i++){
		LL R1 = A - C * (i - 1), L1 = A - D * (i - 1);
		LL R2 = B - C * (N - i), L2 = B - D * (N - i);
		bool ok = true;
		if(L1 > R2 || L2 > R1) ok = false;
		if(ok) check = true;
		if(check) break;
	}
	if(check) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
D, G = map(int, input().split())
P = [0]
C = [0]
ans = 0
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
    ans += p

for i in range(1<<D):
    point = 0
    count = 0
    for j in range(D, 0, -1):
        if i>>j-1&1:
            point += j * 100 * P[j] + C[j]
            count += P[j]
    for k in range(D, 0, -1):
        if not i>>k-1&1 and P[k] > 1:
            for _ in range(P[k]-1):
                if point < G:
                    point += k * 100
                    count += 1
                else:
                    break
            if point >= G:
                ans = min(ans, count)
            break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

ll gcd(ll a, ll b) {
    if(a % b == 0) return b;
    else return gcd(b, a % b);
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];

    int ans = 0;
    REP(i, n) ans += a[i] - 1;
    cout << ans << endl;
    
    return 0;
}


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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  vector<int> sn(N), c(N);
  for (int i = 0; i < N; ++i) {
    sn[i] = (S[i] == 'W') ? -1 : 1;
    c[i] = -1;
  }
  c[0] = 0;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (sn[i] != c[i]) ++ans;
  }
  int now = ans;
  for (int i = 1; i < N; ++i) {
    if (sn[i] == c[i]) ++now;
    ++c[i];
    ++c[i - 1];
    if (sn[i - 1] == c[i - 1]) --now;
    ans = min(ans, now);
  }
  cout << ans - 1 << endl;
  return 0;
}


Measured memory_bytes: 3076
# ARC061C - たくさんの数式 / Many Formulas (ABC045C)
from itertools import product


def main():
    s = input()
    ans = 0
    ops = tuple(product(("", "+"), repeat=len(s) - 1))
    for op in ops:
        e = ""
        for i in range(len(s) - 1):
            e += s[i] + op[i]
        e += s[-1]
        ans += eval(e)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace ABC020
{
    class MainClass
    {
        public static void Main(string[] args){
            new MainClass().solve();
        }

        Scanner cin;

        string O, E;

        void solve(){
            cin = new Scanner();

            O = cin.next();
            E = cin.next();

            int nO=0, nE=0;
            string ans = "";
            for (int i = 0; i < O.Length + E.Length;i++){
                if(i%2==0){
                    ans += O[nO++];
                }else{
                    ans += E[nE++];
                }
            }

            Console.WriteLine(ans);
        }

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

Measured memory_bytes: 11092
N,A,B=map(int,input().split())
S=input()
a=b=0
for s in S:
    if s=="a" and a+b<A+B:
        a+=1
        print("Yes")
    elif s=="b" and a+b<A+B and b<B:
        b+=1
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9292
// Code for D - Replacing
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

  map<ll, ll> m;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }

  ll Q;
  cin >> Q;
  vector<ll> B(Q), C(Q);
  REP(i, Q) {
    cin >> B[i] >> C[i];
  }

  ll total = 0;
  REP(i, N) {
    total += A[i];
    m[A[i]] += 1;
  }


  REP(i, Q) {
    total += (C[i] - B[i]) * m[B[i]];
    m[C[i]] += m[B[i]];
    m[B[i]] = 0;
    cout << total << endl;
  }

  return 0;
}


Measured memory_bytes: 11428
#include <bits/stdc++.h>
using namespace std;
template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (
        T&& t
      ) noexcept
      : T(forward<T>(t))
      {
      }
    template<typename... Args>
    constexpr decltype(auto)
    operator()(
        Args&&... args
      ) const
      {
        return T::operator()(*this, forward<Args>(args)...);
      }
};
template<typename T>
static inline constexpr decltype(auto) fix (T&& t) noexcept {
  return fixed_point<T>{forward<T>(t)};
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> grh(n);
  for (int i = 0; i < n - 1; i++) {
    int s, t;
    cin >> s >> t;
    grh[--s].push_back(--t);
    grh[t].push_back(s);
  }
  vector<int> c(n), d(n);
  for (int i = 0; i < n; i++) cin >> c[i];
  sort(c.begin(), c.end(), greater<int>());
  auto it = c.begin();
  fix ([&](auto dfs, int crr, int prt) -> void {
    d[crr] = *it; it++;
    for (auto const& nxt : grh[crr]) if (nxt != prt) {
      dfs(nxt, crr);
    }
  })(0, 0);
  long long ret = accumulate(c.begin(), c.end(), 0LL) - c[0];
  cout << ret << endl;
  copy(d.begin(), d.end(), ostream_iterator<int>(cout, " "));
  return 0;
}

Measured memory_bytes: 1408
import math;

def swap(a,b):
    return (b,a)

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

xm = [1,0,-1,0]
ym = [0,1,0,-1]

def bfs(y,x):
    if (y==gy and x==gx):
        return
    for i in range(4):
        for j in range(4):
            if (c[y+ym[i]][x+xm[j]]=='#'):
                continue
            if (aom[y+ym[i]][x+xm[j]]!=-1):
                continue
            aom[y+ym[i]][x+xm[j]] = aom[y][x] + 1

def main():
    n = int(input())
    a = [x for x in map(int,input().split())]
    x = 0
    for i in a:
        x += 1 / i
    ans = 1 / x
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
//Meri hr baat bs yaad hai tumhari , mera apna koi kissa nhi!!
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
#define fat 998244353 
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);
using namespace std;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
int main()

{
    ll t;
    cin>>t;
    if(t%2==0 || t%5==0)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    set<ll> s;
    ll rem = 7;
    ll cnt= 1;
    bool flag = false;
    while(true)
    {   
        if(rem%t==0)
        {
            break;
        }
        else 
        {
            rem = rem%t;
        }
        rem = rem*10+7;
        if(s.count(rem)==0)s.insert(rem);
        else
        {
            flag = 1;
            break;
        }
        cnt++;
    }
    if(!flag) cout<<cnt<<endl;
    else cout<<"-1"<<endl;
}

Measured memory_bytes: 50460
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

class Node{
public:
	int location;
	int p,l,r;
	Node(){}
};

class Point{
public:
	int id,x,y;
	Point(){}
	Point(int id,int x,int y):id(id),x(x),y(y){}
	bool operator <(const Point &p)const{
		return id<p.id;
	}

	void print(){
		printf("%d\n",id);
	}
};

static const int MAX=1000000;
static const int NIL=-1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){
	return p1.x<p2.x;
}

bool lessY(const Point &p1,const Point &p2){
	return p1.y<p2.y;
}

int makeKDTree(int l,int r,int depth){
	if(l>=r)return NIL;
	int mid=(l+r)/2;
	int t=np++;
	if(depth%2==0){
		sort(P+l,P+r,lessX);
	}else{
		sort(P+l,P+r,lessY);
	}
	T[t].location=mid;
	T[t].l=makeKDTree(l,mid,depth+1);
	T[t].r=makeKDTree(mid+1,r,depth+1);
	return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
	int x=P[T[v].location].x;
	int y=P[T[v].location].y;
	if(sx<=x && x<=tx && sy<=y && y<=ty){
		ans.push_back(P[T[v].location]);
	}
	if(depth%2==0){
		if(T[v].l!=NIL){
			if(sx<=x)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[v].r!=NIL){
			if(x<=tx)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
		}
	}else{
		if(T[v].l!=NIL){
			if(sy<=y)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[v].r!=NIL){
			if(y<=ty)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
		}
	}
}

int main(void){
	int x,y;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d %d",&x,&y);
		P[i]=Point(i,x,y);
		T[i].l=T[i].r=T[i].p=NIL;
	}
	np=0;
	int root=makeKDTree(0,N,0);

	int q;
	scanf("%d",&q);
	int sx,tx,sy,ty;
	vector<Point> ans;
	for(int i=0;i<q;i++){
		scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(),ans.end());
		for(int j=0;j<ans.size();j++){
			ans[j].print();
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 17416
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int r;
cin>>r;
double pi = 3.14;
cout<<(double)2*pi*r;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  vector<bool> dp1(10001,false);
  vector<bool> dp2(10001,false);
  dp1[0] = true;
  dp2[0] = true;

  for (int i=0;i < n;i++){
    rep(k,10001) dp2[k]=false;
    dp2[0]=true;
    for (int j =0;j < 10001;j++){
      if (dp1[j]) {
        dp2[j+v[i]] = true;
        dp2[j] = true;
      }
    }
    swap(dp1,dp2);
  } 
  int ans=0;
  for(int i=0;i < 10001;i++){
    if (dp1[i] && i%10 != 0) ans=max(ans,i);
    //if (dp1[i]) printf("dp1[%d]\n",i);
  }
  cout << ans << endl;
  
  

  return 0; 
}

Measured memory_bytes: 256
using System;
 
public class ABC156_B {
    private static void Main(string[] args) {
        var inputs = Console.ReadLine().Trim().Split();
        var n = int.Parse(inputs[0]);
        var k = int.Parse(inputs[1]);
 
      	var answer = Math.Floor(Math.Log(n, k) + 1);
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		if(a >= 3200) {
			System.out.println(s);
		} else if(a < 3200) {
			System.out.println("red");
		}
	}
}


Measured memory_bytes: 23124
import numpy as np

N, K = map(int, input().split())

x = np.array([1 for i in range(N)])
for i in range(0, K*2):
	if i % 2 == 0:
		d = int(input())
	else:
		member = np.array(list(map(int, input().split())))
		for j in range(d):
			x[member-1] = 0

print(np.sum(x == 1))



Measured memory_bytes: 27312
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;


int main()
{
    std::ios_base::sync_with_stdio(0);	
    cin.tie(0);
    cout.tie(0);
    
    ll n,k;
    cin>>n>>k;
    
    ll arr[n];
    
    for(ll i=0;i<n;i++)cin>>arr[i];
    
    ld ard[n];
    
    for(ll i=0;i<n;i++)
    {
		ard[i] = ((arr[i]*(arr[i]+1))/2)/(arr[i]+0.0L);
		//cout<<ard[i]<<endl;
	}
	
	ld ans = 0,cur = 0;
	for(ll i=0;i<k;i++)
	{
		cur+=ard[i];
		ans+=ard[i];
	}
   
    for(ll i=k;i<n;i++)
    {
		cur+=ard[i]-ard[i-k];
		//cout<<cur<<" "<<ans<<endl;
		if((cur-ans)>(1e-6))ans = cur;
	}
	
	cout<<fixed<<setprecision(9)<<ans;
    
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int A = b - (a + W);
		int B = a - (b + W);

		if (b <= (a + W) && (a + W) - b <= 2 * W) {

			System.out.println("0");

		} else if (b > (a + W)) {

			if (A >= B) {

				System.out.println(A);

			} else if (A < B) {

				System.out.println(B);

			}

		} else if (a > (b + W)) {

			if (A >= B) {

				System.out.println(A);

			} else if (A < B) {

				System.out.println(B);
			}

		}
	}
}


Measured memory_bytes: 21844
n,m=map(int,input().split())
h=list(map(int,input().split()))
flag=[True for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1] >= h[b-1]:
    flag[b-1] = False 
  if h[b-1] >= h[a-1]:
    flag[a-1] = False 
print(flag.count(True))

Measured memory_bytes: 19736
li_a = list(input())
li_b = list(input())
li_c = list(input())

tmp = "a"

while True:
    if tmp == "a":
        if len(li_a) == 0:
            print("A")
            break
        tmp = li_a[0]
        del li_a[0]
    elif tmp == "b":
        if len(li_b) == 0:
            print("B")
            break
        tmp = li_b[0]
        del li_b[0]
    else:
        if len(li_c) == 0:
            print("C")
            break
        tmp = li_c[0]
        del li_c[0]


    

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;




namespace contest
{

    class contest
    {


        static void Main(string[] args)
        {


            //int n = int.Parse(Console.ReadLine());
            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();


            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string t = Console.ReadLine();


            int length = s.Length+t.Length;

            int mx = 0;
            for(int i =0; i<s.Length; i++)
            {
                string tmp = s.Substring(s.Length-1-i);
                if(t.IndexOf(tmp)==0)
                {
                    mx = Math.Max(mx,tmp.Length);
                }

            }
            length -= mx;

            if (length < n) length = n;
            //if (s.CompareTo(t) == 0) length = s.Length;
            Console.WriteLine(length);


           // Console.Read();


        }

        


    }


}


Measured memory_bytes: 3160
N,X,Y=map(int,input().split())
X-=1
Y-=1
l=[0]*(N-1)
for i in range(N-1):
    for j in range(i+1,N):
        l[min(j-i,abs(X-i)+abs(Y-j)+1)-1]+=1
print(*l,sep="\n")

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

template <typename T>
vector<T> _divisor(T a) {
    vector<T> res;
    for (T i = 2; i * i <= a; i++) {
        if (a % i == 0) {
            res.push_back(i);
            if (i != 1 && i * i != a)
                res.push_back(a / i);
        }
    }
    return res;
}

bool _is_prime(long long int a) {
    if (a < 2)
        return false;
    else if (a == 2)
        return true;
    if (a % 2 == 0)
        return false;
    for (long long int i = 3; i * i <= a; i += 2) {
        if (a % i == 0)
            return false;
    }
    return true;
}

constexpr long long mod = 1000000007;

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

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

    ll n;
    cin >> n;
    vll d = _divisor(n);

    d.emplace_back(n);

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

    vll e;
    rep(i, d.size()) {
        if (_is_prime(d[i])) {
            e.emplace_back(d[i]);
        }
    }

    set<ll> f;

    rep(i, e.size()) {
        ll t = e[i];
        rep(j, d.size()) {
            ll cnt = 0;
            ll s = d[j];

            bool bb = true;
            while (s != 1) {
                if (s % t != 0) {
                    bb = false;
                    break;
                } else {
                    cnt++;
                    s /= t;
                }
            }

            if (bb) {
                s = t;
                for (int k = 1; k <= cnt; k++) {
                    f.insert(s);
                    s *= t;
                }
            }
        }
    }

    ll t = n;
    ll cnt = 0;

    for (auto itr = f.begin(); itr != f.end(); itr++) {
        if (t % *itr == 0) {
            if (t > 1) {
                t /= *itr;

                cnt++;
            } else {
                break;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3656
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

p1 = p2 = p3 = 0
for p in P:
  if p <= A:
    p1 += 1
  elif p <= B:
    p2 += 1
  else:
    p3 += 1
print(min(p1, p2, p3))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int x;
	cin >> x ;
	int j1 =0,j,count;
	if(x == 1){
		cout << 1 <<endl;
	}
	else{
		for(int i = 2; i <= 31; i++){
			j = i;
			count =0;
			while(j<=x){
				count ++;
				j *= i;
			}
			if(count <=1){
			}
			else{
				j = j/i;
				j1 = max(j,j1);
		}

		}
		cout << j1 <<endl;
	}

	return 0;
}

Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  long n = readln.chomp.to!long;
  long[] A = readln.chomp.split.to!(long[]);
  long[long] h;
  long x = -1,
       y = -1;

  foreach (e; A) {
    if (e !in h) {
      h[e] = 1;
    } else {
      h[e]++;
    }
  }

  long[] keys = h.keys.sort!"a>b".array;

  foreach (k; keys) {
    if (x != -1 && y != -1) { break; }

    if (x == -1 && h[k] >= 2) {
      x = k;
      h[k] -= 2;
    }

    if (x != -1 && y == -1 && h[k] >= 2) {
      y = k;
      h[k] -= 2;
    } 
  }

  if (x == -1 || y == -1) {
    writeln(0);
    return;
  } else {
    writeln(x * y);
  }
}


Measured memory_bytes: 11188
N, A = map(int, input().split())
x = [int(i) for i in input().split()]
DP = [[[0] * (2501) for i in range(N+1)] for j in range(N+1)]
ans = 0
DP[0][0][0] = 1

for i in range(N):
  for j in range(N):
    for k in range(2501):
      if DP[i][j][k]:
        DP[i+1][j+1][k+x[i]] += DP[i][j][k]
        DP[i+1][j][k] += DP[i][j][k]
for i in range(N):
  ans += DP[N][i+1][(i+1)*A]
print(ans)

Measured memory_bytes: 91996
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

ll a,b,k;

int main()
{
    cin >> a >> b >> k;
    if (k<=a){cout << a-k << " " << b << endl;}
    else
    {
        k-=a;
        a=0;
        cout << a << " " << b-min(b,k) << endl;
    }
}


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

int c[1000006];
vector<int> V;
set<int> S;
multiset<int> T;

int N, A[200005];

int dp[200005];

int main(void) {
	cin >> N;
	int Am = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(A[i]);
		S.insert(A[i]);
		//T.insert(A[i]);
		Am = max(Am, A[i]);
	}

	//sort(V.begin(), V.end());

	

	for(auto y: V){
		if (c[y] >= 1) { c[y] = 2; }
		else if (c[y] >= 0) { c[y]++;
		for (long long int j = y*2; j <= Am; j+=y) {
			c[(int) j] = -1;
		}
		}
	}


	int ans = 0;

	for (int i = 1; i <= N; i++) {
		//if (T.count(A[i]) >= 2) { continue; }
		if (c[A[i]] == 1) { ans++; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 17056
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n;
    while(sf("%d",&n)==1)
    {
    	int ara[n+5];
    	int mx=0;
    	for(int i=0;i<n;i++)sf("%d",&ara[i]),mx=max(mx,ara[i]);

    	int freq[mx+5];
    	memset(freq,0,sizeof freq);
    	for(int i=0;i<n;i++)freq[ara[i]]++;

    	int ans=0,even=0;
    	for(int i=1;i<=mx;i++)
    	{
    		if(freq[i]!=0)
    		{
    			ans++;
    			if(freq[i]%2==0)even++;
    		}
    	}

    	if(even%2)ans--;
    	pf("%d\n",ans);
    }
    return 0;
}
 









 




























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

using namespace std;
typedef long long ll;


int n, w;
int a[100100][2];
ll dp[110][100100];

ll f(int idx, int curw)
{
    if (curw < 0) return -1e18;
    if (!curw) return 0;
    if (idx == n) return 0;
    ll &ret = dp[idx][curw];
    if (~ret) return ret;
    return ret = max(f(idx+1, curw), f(idx+1, curw-a[idx][0]) + a[idx][1]);
}
int main()
{
//    memset(dp, -1, sizeof dp);

    scanf("%d%d", &n, &w);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 2; ++j)
            scanf("%d", &a[i][j]);
    ll ans = 0 ;
    for (int i = n-1; i >= 0; --i)
    {
        dp[i][0] = 0;
        for (int j = 1; j <= w; ++j)
        {
            dp[i][j] = dp[i+1][j];
            if (j-a[i][0] >= 0)
                dp[i][j] = max(dp[i+1][j-a[i][0]] + a[i][1], dp[i][j]);
            ans = max(ans, dp[i][j]);
        }
    }

//    printf("%d\n", f(0, w));
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define sortV(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
// DSU
/*
const int maxn=100009;
int arr[maxn];
int sz[maxn];
void init(){rep(i,maxn){arr[i]=i;sz[i]=1;}}
int root(int a){while(a!=arr[a]){arr[a]=arr[arr[a]];a=arr[a];}return a;}
int check(int a,int b){if(root(a)==root(b))return 1;return 0;}
int un(int a,int b)
{
  int roota=root(a);int rootb=root(b);
  if(sz[roota]>=sz[rootb]){sz[roota]+=sz[rootb];arr[rootb]=roota;}
  else {sz[rootb]+=sz[roota];arr[roota]=rootb;}
}
*/
int32_t main()
{
   fastio
   int n;
   cin>>n;
   int a[n+1];
   repre(i,0,n)cin>>a[i];
   int b[n];
   rep(i,n)cin>>b[i];
   int ans=0;
   for(int i=0;i<n;i++)
   {
     if(a[i]+a[i+1]<=b[i])
     {
       ans+=a[i]+a[i+1];
       a[i+1]=0;
       a[i]=0;
       continue;
     }
     if(a[i]>=b[i] && b[i] && a[i])
     {
       ans+=b[i];
       a[i]=0;
       b[i]=0;
       continue;
     }
     if(a[i]<b[i] && b[i] && a[i])
     {
       ans+=a[i];
       b[i]-=a[i];
     }
     if(a[i+1]>=b[i] && a[i+1] && b[i])
     {
       ans+=b[i];
       a[i+1]=a[i+1]-b[i];
       b[i]=0;
       continue;
     }
     if(a[i+1]<b[i] && a[i+1] && b[i])
     {
       ans+=a[i+1];
       b[i]-=a[i+1];
     }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1792