akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
using namespace std;

static const int all = 52;

int main(void) {
    bool cards[all];
    char inputSute;
    int N, inputCard;
    cin >> N;

    for(int i=0; i<all; i++) {
        cards[i] = true;
    }

    while(N-- > 0) {
        cin >> inputSute >> inputCard;
        switch(inputSute) {
            case 'S': inputCard += 0; break;
            case 'H': inputCard += 13; break;
            case 'C': inputCard += 26; break;
            case 'D': inputCard += 39; break;
        }
        cards[inputCard-1] = false;
    }

    for(int i=0; i < all; i++) {
        if(cards[i]) {
            switch(i / 13) {
                case 0: cout << "S "; break;
                case 1: cout << "H "; break;
                case 2: cout << "C "; break;
                case 3: cout << "D "; break;
            }
            cout << (i % 13) + 1 << endl;
        }
    }

    return 0;
}

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

int main()
{
        char a[10000],b[10000];
        int len1,len2,d,e,k=0,i,s[1000];
        gets(a);
        gets(b);
        len1=strlen(a);
        len2=strlen(b);
        if(len1>len2)
                printf("GREATER\n");
        else if(len1<len2)
                printf("LESS\n");
        else if(len1==len2)
        {
            for(i=0;i<len1;i++)
            {
                  d=a[i]-'0';
                  e=b[i]-'0';
                  if(d>e)
                  {
                      printf("GREATER\n");
                      break;
                  }
                  else if(d<e)
                  {
                          printf("LESS\n");
                           break;
                  }
                  else if(d==e)
                  {
                          s[k]=i;
                          k++;
                  }
            }
            //printf("%d\n",k);
            if(k==len1)
                printf("EQUAL\n");
        }

        return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, K, ans;
  cin >> N;
  
  if(N % 1000 == 0){
    ans = 0;
  }
  else{
    K = N / 1000;
    ans = (K + 1) * 1000 - N;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=0;cin>>N;
  REP(i,N){
    ll a;cin>>a;
    if(i%2==0&&a%2==1)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;

int main() {
	int a,b,c;cin>>a>>b>>c;
  rep(i,100){
    int j = 100 - i;
    if(a%j==0 && b%j==0){
      c --;
      if(c==0){
      cout << j;
      return 0;
      }
      
    }
  }
}

Measured memory_bytes: 256
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) const {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

int N;
vector<Int> A, B, C;

void input() {
  cin >> N;
  Int x;
  rep(N) {
    cin >> x; A.push_back(x);
  }
  rep(N) {
    cin >> x; B.push_back(x);
  }
  rep(N) {
    cin >> x; C.push_back(x);
  }
}

void solve() {
  sort(span_all(A)); // O(NlogN)
  sort(span_all(B));
  sort(span_all(C));

  Int count = 0;
  for (auto b: B) { // O(N)
    Int a = upper_bound(span_all(A), b-1) - A.begin(); // O(logN)
    Int c = C.end() - lower_bound(span_all(C), b+1); // O(logN)
    count += a * c;
  }

  cout << count << endl;
}

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


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=702;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=-INF;
static int t=120000;
class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int evaluate(){
    int sum=0;
    vector<int> l(ntype+1,0);
    for(int day=1;day<=D;++day){
        int type=ans[day];
        sum+=contest[type].s[day];
        l[type]=day;
        for(int t=1;t<=ntype;++t){
            sum-=contest[t].c*(day-l[t]);
        }
    }
    return sum;   
}

void Output(){
    for(int d=1;d<=D;++d) cout<<ans[d]<<endl;
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int temp=ans[p];
    ans[p]=rand()%ntype+1;
    int temp_score=evaluate();
    if(max_score<temp_score) max_score=temp_score;
    else ans[p]=temp;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int temp_score=evaluate();
    if(max_score<temp_score) max_score=temp_score;
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void solve(int times){
    max_score=evaluate();
    for(int i=0;i<times;++i){
        swap();
        change();
    }
}

int main(){
    srand(seed);
    Input();
    Greedy();
    solve(t);
    for(int i=0;i<2000;++i) swap();
    Output();
}


Measured memory_bytes: 3664
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
// #ifndef RAHUL
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif

 
long long x,t;

cin>>x>>t;

std::vector<long long> v(x);
for (int i = 0; i < x; ++i)
{
	/* code */
	cin>>v[i];
}

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


long long min1=10101010000000;

for (int i = 0; i < x-t+1; ++i)
{
	/* code */
	 min1=min(min1,v[i+t-1]-v[i]);
}

cout<<min1<<endl;

return 0;	
}

Measured memory_bytes: 4028
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let e=tnn(n+1)
  let p=tnn(n),ans=0
  for(let i=0;i<n;i++){
    if(p[i]>e[i]){
      ans+=e[i]
      if(p[i]-e[i]>e[i+1]){
        ans+=e[i+1]
        e[i+1]=0
      }else{
        ans+=p[i]-e[i]
        e[i+1]-=p[i]-e[i]
      }
    }else{
      ans+=p[i]
    }
  }
  to(ans)
}
main()


Measured memory_bytes: 37988
X = int(input())

def is_prime(x):
  if x < 2: return False
  if x == 2 or x == 3 or x == 5: return True
  if x%2==0 or x%3==0 or x%5==0: return False

  prime = 7
  step = 4
  while prime <= int(p**0.5)+1:
    if x % prime == 0: return False
    prime += step
    step = 6-step

  return True

p = X
while True:
  if is_prime(p):
    print(p)
    exit()
  else:
    p += 1

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int ans=0;
    for(int i=0;i<4;i++){
        char a;cin>>a;
        if(a=='+')ans++;
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
lli mp[1000001];
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	
	cin.tie(NULL);
	lli i,k,m=0,n,j,f;
	cin>>n;
	lli a[n];
	memset(mp,0,sizeof(mp));
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	for(i=0;i<n;i++)
	{
		k=a[i];
		f=0;
		for(j=2;j*j<=k;j++)
		{
			if(k%j==0)
			{ 
			if(mp[j]>0||mp[k/j]>0)
			{
				f=1;
				break;
			}
			}
		}
		if(f==0)
		{
			if(mp[k]==1)
			{
				if(k==1)
				m++;
				else
				{
					if(mp[1]==0)
					m++;
				}
			}
		}
	}

	cout<<m;

	return 0;
}

Measured memory_bytes: 12920
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,a[60],b[60],ans[60]={};
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		ans[a[i]]++;
		ans[b[i]]++;
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;
int N;
LL A[MAX];

map<LL, int> cnt;

int main(void) {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    sort(A, A + N);
    reverse(A, A + N);
    int ans = 0;
    REP(i, N) {
        if (cnt.count(A[i]) == 0) continue;
        int now_cnt = cnt[A[i]];
        if (now_cnt > 0) {
            RREP(j, 31) {
                LL foo = (1 << j) - A[i];
                if (foo <= A[i]) break;
                if ((A[i] == foo && now_cnt > 1) || (A[i] != foo && cnt.count(foo) && cnt[foo] > 0)) {
                    if (now_cnt == 1) cnt.erase(A[i]);
                    else cnt[A[i]]--;
                    if (cnt[foo] == 1) cnt.erase(foo);
                    else cnt[foo]--;
                    ans++;
                    break;
                }
            }
        }
    }
    FORE(e, cnt) {
        while (__builtin_popcountll(e.first + e.first) == 1 && e.second > 1) {
            ans++;
            e.second -= 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int ab = Integer.parseInt(str[0]);
    int bc = Integer.parseInt(str[1]);
    int ca = Integer.parseInt(str[2]);
    if(ab>=bc && ab>=ca)
      System.out.println(bc*ca/2);
    else if(bc>=ab && bc>=ca)
      System.out.println(ab*ca/2);
    else if(ca>=ab && ca>=bc)
      System.out.println(ab*bc/2);
  }
}

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

int main() {
  string S;
  cin >> S;
     
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(S == "Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
using System;

namespace AtC154
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] A = new long[N];
            string[] Astr = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++) A[i] = long.Parse(Astr[i]);

            Array.Sort(A);
            for(int i = 1; i < N; i++)
            {
                if(A[i] == A[i - 1])
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            Console.WriteLine("YES");
        }
    }
}


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

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

int dp[114514];

int main(){
	int n,k;
	cin>>n>>k;
	vector<int>h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];	
	}
	for(int i=0;i<114514;i++){
		dp[i]=1000000000;
	}
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<=k;j++){
			if(i-j>=0)dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);	
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;	
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=2e5+11,INF=~0u>>2;
struct node{
	int x,l,r;
	bool operator<(const node&b)const{return x>b.x;}
};
priority_queue<node> Q;
int n,d[2][N][25],a[2][N],pos[N];
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
void RMQ_init(int f){
	for(int i=1;i<=n;++i) d[f][i][0]=a[f][i];
	for(int j=1;(1<<j)<=n;++j) 
	   for(int i=1;(i+(1<<j)-1)<=n;++i)
	      d[f][i][j]=min(d[f][i][j-1],d[f][i+(1<<(j-1))][j-1]);
}
int RMQ(int l,int r,int f){
	int k=0;
	while((1<<(k+1))<=r-l+1) k++;
	return min(d[f][l][k],d[f][r-(1<<k)+1][k]);
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();
	for(int i=1;i<=n;++i){
		int tmp=read();
		a[i&1][i]=tmp;
		a[(i&1)^1][i]=INF;
		pos[tmp]=i;
		
	}
	RMQ_init(0);RMQ_init(1);
	Q.push((node){RMQ(1,n,1),1,n});
	while(!Q.empty()){
		node x=Q.top();Q.pop();
		int v1=x.x,v2=RMQ(pos[x.x]+1,x.r,(pos[x.x]&1)^1);
		printf("%d %d ",v1,v2);
		v1=pos[v1];v2=pos[v2];
		if(x.l!=v1) Q.push((node){RMQ(x.l,v1-1,x.l&1),x.l,v1-1});
		if(v1+1!=v2) Q.push((node){RMQ(v1+1,v2-1,(v1+1)&1),v1+1,v2-1});
		if(v2!=x.r) Q.push((node){RMQ(v2+1,x.r,(v2+1)&1),v2+1,x.r});
	}
	return 0;
}

Measured memory_bytes: 43512
#include<iostream>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

void insertionSort(short a[], short n)
{
	for(short i = 1; i < n; i++){
		short v = a[i];
		short j = i -1;
		while(j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		REP(i,n-1) cout << a[i] << ' ';
		cout << a[n-1];
		cout << endl;
	}
	return;
}

int main(void)
{
	short n;
	short a[100];
	cin >> n;
	REP(i,n) cin >> a[i];

	REP(i,n-1) cout << a[i] << ' ';
	cout << a[n-1];
	cout << endl;
	insertionSort(a,n);

        return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main( void ) {
  int i, j, k, n;
  int a, b, c, d;
  int p[ 300 ]; // parts
  int t[ 1000 ][ 3 ], r; // test

  while( 1 ) {
    scanf( "%d%d%d", &a, &b, &c );
    if( !a && !b && !c ) break;
    d = a + b + c;

    scanf( "%d", &n );

    for( i = 0; i < d; i++ )
      p[ i ] = 2; // not clear

    for( i = 0; i < n; i++ ) {
      scanf( "%d%d%d%d",
          &t[ i ][ 0 ],
          &t[ i ][ 1 ],
          &t[ i ][ 2 ], &r );
      if( r ) {
        p[ t[ i ][ 0 ] - 1 ] = 1;
        p[ t[ i ][ 1 ] - 1 ] = 1;
        p[ t[ i ][ 2 ] - 1 ] = 1;
      }
    }

    for( i = 0; i < d; i++ )
      if( p[ i ] == 1 )
        for( j = 0; j < n; j++ )
          for( k = 0; k < 3; k++ )
            if( t[ j ][ k ] == i + 1 )
              t[ j ][ k ] = 0;

    for( j = 0; j < n; j++ ) {
      if( t[ j ][ 0 ] && !t[ j ][ 1 ] && !t[ j ][ 2 ] )
        p[ t[ j ][ 0 ] - 1 ] = 0;
      else if( !t[ j ][ 0 ] && t[ j ][ 1 ] && !t[ j ][ 2 ] )
        p[ t[ j ][ 1 ] - 1 ] = 0;
      else if( !t[ j ][ 0 ] && !t[ j ][ 1 ] && t[ j ][ 2 ] )
        p[ t[ j ][ 2 ] - 1 ] = 0;
    }

    for( i = 0; i < d; i++ )
      printf( "%d\n", p[ i ] );
  }

  return ( 0 );
}

Measured memory_bytes: 0
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();
    let k = s.len();

    if s.chars().filter(|x| *x == 'o').count() + 15 - k >= 8{
        println!("YES");
    }else{
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include<cstdio>
int main(){
    int a,b,vs=0;
    double ns=0,is=0;
    while(scanf("%d, %d\n",&a,&b)!=-1){
        is++;
        vs+=a*b;
        ns+=b;
    }
    printf("%d\n%d\n",vs,(int)((ns/is)+0.5));
}

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

#define int long long
#define MOD 1000000007


#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
using namespace std;

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }
 
//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;
vector<int>A;

int euclid( int a, int b )
{
    int temp;

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

    if( a < b ) { temp = a; a = b; b = temp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return euclid( b, a % b );
}

signed main(){
 
    cin>>N;
   A.resize(N);
   rep(i,N){
       cin>>A[i];
   }

    int L[N+1],R[N+1];
    L[0]=0;
    R[N]=0;

    rep(i,N){
        L[i+1]=euclid(L[i],A[i]);
    }

    for(int i=N-1;i>=0;i--){
        R[i]=euclid(R[i+1],A[i]);
    }

    int m=0;

    rep(i,N){

        m=max(m,euclid(L[i],R[i+1]));

    }

    cout<<m<<endl;

    return 0;
 
}


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

int main(){
    int n; cin>>n;
    vector<int> a(n);

    int mx = 0,ind;

    for(int i=0; i<n; i++){
        cin>>a[i];
        if(abs(a[i])>=abs(mx)){
            mx = a[i];
            ind = i;
        }
    }

    ind++;

    vector<pair<int,int>> pairs;

    for(int i=1; i<=n; i++){
        pairs.push_back(make_pair(ind,i));
    }

   if(mx >= 0){
        for(int i=1; i<n; i++){
            pairs.push_back(make_pair(i,i+1));
        }
    }

    else{
        for(int i=n; i>1; i--){
            pairs.push_back(make_pair(i,i-1));
        }
    }

    cout<<pairs.size()<<endl;

    for(int i=0; i<pairs.size(); i++){
        cout<<pairs[i].first<<" "<<pairs[i].second<<endl;
    }

    return 0;      
}

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

int main(){
  int n;cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin >> a.at(i);
  int ans=100000000;
  for(int i=-100;i<=100;++i){
    int sum=0;
    for(int j=0;j<n;++j){
      sum+=pow(a.at(j)-i,2);
    }
    ans=min(ans,sum);
  }
  cout << ans << endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  // 前計算
  int r[10][2];  // 計算用
  memset(r, 0, sizeof(r));
  r[0][0] = 1;
  for (int i = 0; i < 9; i++) {
    r[i + 1][1] += r[i][0];  // 後ろ空いてて、引いた
    r[i + 1][0] += r[i][1];  // 後ろ引いてて、引かない
    r[i + 1][0] += r[i][0];  // 後ろ空いてて、引かない
  }
  vector<int> kumi(10);  // 長さがiの時の正しくできる組み合わせの数
  for (int i = 0; i < 10; i++) kumi[i] = r[i][0] + r[i][1];

  // 入力
  int h, w, k;
  cin >> h >> w >> k;

  ll dp[h + 1][w];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;

  for (int y = 0; y + 1 <= h; y++) {
    for (int s = 0; s < w; s++) {
      // cout << y << "," << s << "=" << dp[y][s] << endl;
      ll add;
      if (s - 1 >= 0) {
        add = dp[y][s] * kumi[max(0, s - 2)] % MOD * kumi[max(0, w - 1 - (s + 1))] % MOD;
        dp[y + 1][s - 1] += add;  // 左に
        dp[y + 1][s - 1] %= MOD;
      }
      if (s + 1 <= w - 1) {
        add = dp[y][s] * kumi[max(0, s - 1)] % MOD * kumi[max(0, w - 1 - (s + 2))] % MOD;
        dp[y + 1][s + 1] += add;  // 右に
        dp[y + 1][s + 1] %= MOD;
      }
      add = dp[y][s] * kumi[max(0, s - 1)] % MOD * kumi[max(0, w - 1 - (s + 1))] % MOD;
      dp[y + 1][s] += add;
      dp[y + 1][s] %= MOD;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int main() {
    ll N; cin >> N;
    if(N==1){
        cout << 1 << endl;
        return 0;
    }

    map<ll, ll> m;
    for (int i = 2; i <= N; i++)
    {
        int icpy = i;
        for (int j = 2; j <= round(sqrt(N)); j++)
        {
            while(icpy%j==0){
                icpy /= j;
                m[j]++;
            } 
        }
        if(icpy!=1) m[icpy]++;
    }
    ll ans = 1;
    for(auto i: m){
        ans = ans * (i.second + 1) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}

int main() {
    fastik();
    ll n,m;cin>>n>>m;
    vll l(m),r(m);
    ll mx = -1,mn=ll(2e9);
    forn(i,m){
        cin >> l[i] >> r[i];
        mx = max(mx,l[i]);
        mn = min(mn,r[i]);
    }

    if(mx > mn ){
        cout << 0;
    }else{
        cout << mn - mx + 1;
    }


}


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

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

Measured memory_bytes: 256
using System;public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);
        int sum = 0;
        
        string[] input2 = Console.ReadLine().Split(' ');//型変換
        int[] num = new int[N];
        for(int x = 0;x < N;x++){
            num[x] = int.Parse(input2[x]);
        }
        
        for(int i = 0;i < N - 1;i++){//ソート
        int temp = num[0];
            for(int j = i + 1; j < N;j++){
                if(num[i] < num[j]){
                    temp = num[i];
                    num[i] = num[j];
                    num[j] = temp;
                }
            }
        }
        for(int z = 0;z < K;z++){
           sum = sum + num[z];
        }
        Console.WriteLine($"{sum}");
    }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    if (n < 10) {
        cout << "Yes\n";
        return 0;
    } 
    bool flag = false;
    for (int i = 2; i < 10; i++) {
        if (n % i == 0) {
            if (n / i < 10) {
                flag = true;
                break;
            }
        }
    }
    if (flag) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
def even(n: int) -> bool:
    return n % 2 == 0


A, B, C = map(int, input().split())

if (A == B == C) and (even(A) and even(B) and even(C)):
    print(-1)
    exit(0)

ret = 0
while even(A) and even(B) and even(C):
    a, b, c = A, B, C
    ret += 1
    A = (b + c) / 2
    B = (a + c) / 2
    C = (a + b) / 2
    # print(A, B, C)

print(ret)

Measured memory_bytes: 3064
K = int(input())
from collections import deque
que = deque()
for i in range(1,10):
  que.append(i)
  
while K > 0:
  a = que.popleft()
  b = a % 10
  if b == 0:
    que.append(a*10 + b)
    que.append(a*10 + b+1)
  elif b == 9:
    que.append(a*10 + b-1)
    que.append(a*10 + b)
  else:
    que.append(a*10 + b-1)
    que.append(a*10 + b)
    que.append(a*10 + b+1)
  K -= 1
print(a)

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<M; i++) cin >> B[i];
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    A.push_back(-1);
    B.push_back(-1);

    int apt = 0, bpt = 0, mx = N*M;
    int64_t ans = 1;
    int freept = 0;
    while(apt<N || bpt<M){
        if(A[apt] == mx && B[bpt] == mx){
            freept += apt+bpt;
            apt++;
            bpt++;
        }else if(A[apt] == mx){
            apt++;
            mul(ans, bpt);
            freept += bpt-1;
        }else if(B[bpt] == mx){
            bpt++;
            mul(ans, apt);
            freept += apt-1;
        }else{
            if(freept > 0){
                mul(ans, freept);
                freept--;
            }else{
                cout << 0 << endl;
                return 0;
            }
        }
        mx--;
    }

    while(mx>0){
        mul(ans, mx);
        mx--;
    }

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

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


using namespace std;

int main() {

	string s;
	int size = 0;
	
	cin >> s;
	
	size = s.size();
	
	int def = 0;
	
	for (int i = 0; i < size; i++) {
		if(s.at(i) =='x') def++;
	}
	
	if (15 - def > 7){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
	return 0;
}


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

int main(){
  bool map[52][52];
  int w,h;

  while(cin >> w >> h && w>0 && h>0){
    for(int i=0;i<52;i++){
      for(int j=0;j<52;j++)
        map[i][j]=false;
    }

    int land=0;

    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
        int c;
        cin >> c;
        if(c==1){
          map[i][j]=true;
          land++;
        }
      }
    }

    int visited=0,cnt=0;
    queue<int> cur;
    int d[8]={-w-3,-w-2,-w-1,-1,1,w+1,w+2,w+3};

    while(visited<land){
      cnt++;
      for(int i=0;i<(w+2)*(h+2);i++){
        if(map[i/(w+2)][i%(w+2)]){
          map[i/(w+2)][i%(w+2)]=false;
          visited++;
          cur.push(i);
          break;
        }
      }
      while(!cur.empty()){
        for(int i=0;i<8;i++){
          if(map[(cur.front()+d[i])/(w+2)][(cur.front()+d[i])%(w+2)]){
            map[(cur.front()+d[i])/(w+2)][(cur.front()+d[i])%(w+2)]=false;
            visited++;
            cur.push(cur.front()+d[i]);
          }
        }
        cur.pop();
      }
    }

    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 3136
package main

import (
	"fmt"
	"sort"
)

func main()  {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
		a[i] = -1*a[i]
	}
	dp := make([]int, n)

	for i := range dp {
		dp[i] = 10e15
	}

	for _, aa := range a {
		// dp を広義増加部分列にするため a+1 に対して lower_bound
		i := sort.SearchInts(dp, aa+1)
		dp[i] = aa
	}

	res := sort.SearchInts(dp, 10e15)

	fmt.Println(res)
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define sqrt(d) pow((long double) (d), 0.50)
 
const ll INF = 2e9;
const ll large_P = 1e9 + 7;
 
 
// ユークリッドの互除法を用いて再帰関数を書けばよい。
ll my_gcd(int & a, int & b) {
    if (b == 0) return a;
    int temp = a % b;
    return my_gcd(b, temp);
}
 
 
 
int main() {
    int K;
    cin >> K;
 
    ll res = 0;
    vector<vector<int>> gcd_memo(203, vector<int>(203, -1));
    int temp = 0;
    int temp2 = 0;
 
    for(int i=1; i<=K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                if (gcd_memo.at(i).at(j) != -1) {
                    temp = gcd_memo.at(i).at(j);
                }
                else {
                    temp = my_gcd(i, j);
                    gcd_memo.at(i).at(j) = temp;
                    gcd_memo.at(j).at(i) = temp;
                }
 
                if (gcd_memo.at(temp).at(k) != -1) {
                    temp2 = gcd_memo.at(temp).at(k);
                }
                else {
                    temp2 = my_gcd(temp, k);
                    gcd_memo.at(temp).at(k) = temp2;
                    gcd_memo.at(k).at(temp) = temp2;
                }
                
                res += temp2;
            }
        }
    }
 
    cout << res << endl;
 
}

Measured memory_bytes: 3804
N = int(input())

i=1
now=26
before = 0
while True:
    if N <= now:
        break
    i += 1
    before = now
    now += 26**i
    
#print(i)
M = N-before
alphabet = "abcdefghijklmnopqrstuvwxyz"
ans=""
for j in range(i):
    dig = int((M-1)//26**(i-j-1))
    #print(M, dig)
    ans = ans + alphabet[dig]
    M -= dig*26**(i-j-1)
    
print(ans)

Measured memory_bytes: 9188
n=int(input())
lis=[]
dic={}
lis2=[]
lis3=[]
b=0
for i in range(n):
    lis.append(input())
for i in lis:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1
for i in dic.keys():
    lis2.append(dic[i])
lis2=sorted(lis2)
a=lis2[-1]
for i in dic.keys():
    if dic[i]==a:
        lis3.append(i)
lis3=sorted(lis3)
for i in lis3:
    print(i)

Measured memory_bytes: 36108
#include <iostream>
using namespace std;
 
int main() {
    int num = 0;
    cin >> num;
    
    int shou = 0;
    shou = num;
    
    int amari = 0;
    int sum = 0;
    
    while (shou > 0) {
        amari = shou % 10;
        shou = shou / 10;
        sum += amari;
    }
    
    if (num % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e3 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int x;
int y;
int d[N];
int cnt[N];
int used[N][N];
vector<int> g[N];
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n >> x >> y;
    for(int i = 1; i < n; i ++){
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= n; j ++){
            d[j] = n;
        }
        queue<int> q;
        q.push(i);
        d[i] = 0;
        while(!q.empty()){
            int v = q.front(); q.pop();
            for(auto to: g[v]){
                if(d[to] == n){
                    d[to] = d[v] + 1;
                    if(used[i][to] == 0){
                        cnt[d[to]] ++;
                        used[i][to] = used[to][i] = 1;
                    }
                    q.push(to);
                }
            }
        }
    }
    for(int i = 1; i < n; i ++){
        cout << cnt[i] << "\n";
    }
}


Measured memory_bytes: 16128
n,m,c = map(int, input().split())
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    d = 0
    for j in range(m):
        d = d + a[j]*b[j]
    if d+c > 0:
        ans = ans + 1
print(ans)

Measured memory_bytes: 62240
//import java.util.Arrays;
//import java.util.Scanner;
//import java.util.ArrayList;
//import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	String o = sc.next();
    	String e = sc.next();
    	StringBuilder ans = new StringBuilder();
    	for(int i=0;i<o.length();i++) {
    		ans.append(o.substring(i,i+1));
    		if(i != e.length()) {
    			ans.append(e.substring(i,i+1));
    		}
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define L long long
using namespace std;
int n,m,x[410][410],a[100010],b[100010],p;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	  scanf("%d%d",&a[i],&b[i]);
	for(i=1;i<=n;i++)
	  {
	   x[i][i]=1;
	   for(j=m;j>0;j--)
	     if(x[i][a[j]])
	       if(x[i][b[j]])
	         x[i][0]=1;
	       else
	         x[i][b[j]]=1;
	     else
	       if(x[i][b[j]])
	         x[i][a[j]]=1;
	  }
	for(i=1;i<=n;i++)
	  for(j=i+1;j<=n;j++)
	    if(!x[i][0] && !x[j][0])
	      {
		   for(k=1;k<=n;k++)
		     if(x[i][k] && x[j][k])
		       break;
		   if(k>n)
		     p++;
		  }
	printf("%d\n",p);
	return 0;
}


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

int main (){
    int x_1, y_1, x_2, y_2;
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    int x = x_2;
    int y = y_2;
    int dx = x_2 - x_1;
    int dy = y_2 - y_1;
    for (int i = 0; i < 2; i++) {
        swap(dx, dy);
        dx = -dx;
        x += dx;
        y += dy;
        cout << x << " " << y << " ";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ull i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();

  ll n;cin>>n;
  vector<ll>a(n+1),b(n);
  loop(i,0,n+1)cin>>a[i];
  loop(i,0,n)cin>>b[i];
  ll ans = 0;
  for(int i = n-1;i>=0;i--)
  {
    ll def = min(a[i+1],b[i]);
    a[i+1]-=def;
    b[i]-=def;
    ans+=def;
    ll def2 = min(a[i],b[i]);
    a[i]-=def2;
    b[i]-=def2;
    ans+=def2;
  }
  cout<<ans<<endl;

  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll H,W;
  cin>>H>>W;

  // | | |
  ll min1=H*(W/3);
  ll max1=H*((W+2)/3);
  ll ans1=max1-min1;

  // -
  // -
  // -
  ll min2=W*(H/3);
  ll max2=W*((H+2)/3);
  ll ans2=max2-min2;

  //|-
  ll ans3=INF;
  for(ll w=1;w<W;w++){
    ll left=w*H;
    ll up=(W-w)*(H/2);
    ll down=(W-w)*((H+1)/2);
    ans3=min(ans3,max({left,up,down})-min({left,up,down}));
  }

  //-
  //|
  ll ans4=INF;
  for(ll h=1;h<H;h++){
    ll up=h*W;
    ll left=(H-h)*(W/2);
    ll right=(H-h)*((W+1)/2);
    ans4=min(ans4,max({up,left,right})-min({up,left,right}));
  }

  cout<<min({ans1,ans2,ans3,ans4})<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	string s,t;
	cin>>s>>t;
	ll a=s.size();
	ll b=t.size();
	if(a<b)
	{
		cout<<"UNRESTORABLE";
		return;
	}
	string ans(a,'z');
	// cout<<ans;
	ll c=0,f=0;
	for(ll i=0;i<a-b+1;i++)
	{
		c=0;
		for(ll j=i;j<i+b;j++)
			if(s[j]!=t[j-i] && s[j]!='?')
			{
				c=1;
				break;
			}
		if(c==0)
		{
			string ans1=s;
			for(ll j=i;j<i+b;j++) 
				ans1[j]=t[j-i];
			
			
			for(ll j=0;j<a;j++)
				if(ans1[j]=='?')
					ans1[j]='a';
				
			ans=min(ans,ans1);
			f=1;
		}
	}
	if(f==0)
		cout<<"UNRESTORABLE";
	else
		cout<<ans;
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

#define KI_MAX (1 << 18) /* 262144 */

typedef struct ki_t {
	int ki[KI_MAX * 2 - 1], all[KI_MAX * 2 - 1];
} ki_t;

int tnh(int a, int b) { /* 小さくない方 */
	return a >= b ? a : b;
}

void add_i(ki_t* ki, int idx, int qmin, int qmax, int smin, int smax, int v) {
	if (qmax <= smin || smax <= qmin) { /* セグメントがクエリから完全に外れている */
		/* nop */
	} else if (qmin <= smin && smax <= qmax) { /* セグメントがクエリに完全に含まれる */
		ki->all[idx] = tnh(ki->all[idx], v);
	} else {
		int smid = smin + (smax - smin) / 2;
		int lidx = idx * 2 + 1, ridx = idx * 2 + 2;
		ki->all[lidx] = tnh(ki->all[lidx], ki->all[idx]);
		ki->all[ridx] = tnh(ki->all[ridx], ki->all[idx]);
		ki->all[idx] = 0;
		add_i(ki, lidx, qmin, qmax, smin, smid, v);
		add_i(ki, ridx, qmin, qmax, smid, smax, v);
		ki->ki[idx] = tnh(tnh(ki->ki[lidx], ki->all[lidx]), tnh(ki->ki[ridx], ki->all[ridx]));
	}
}

void add(ki_t* ki, int min, int max, int v) {
	if (ki != NULL && min < max) add_i(ki, 0, min, max, 0, KI_MAX, v);
}

int get_i(ki_t* ki, int idx, int qmin, int qmax, int smin, int smax) {
	if (qmax <= smin || smax <= qmin) { /* セグメントがクエリから完全に外れている */
		return 0;
	} else if (qmin <= smin && smax <= qmax) { /* セグメントがクエリに完全に含まれる */
		return tnh(ki->ki[idx], ki->all[idx]);
	} else {
		int smid = smin + (smax - smin) / 2;
		int lidx = idx * 2 + 1, ridx = idx * 2 + 2;
		int left = get_i(ki, lidx, qmin, qmax, smin, smid);
		int right = get_i(ki, ridx, qmin, qmax, smid, smax);
		return tnh(tnh(left, right), ki->all[idx]);
	}
}

int get(ki_t* ki, int min, int max) {
	return ki != NULL && min < max ? get_i(ki, 0, min, max, 0, KI_MAX) : 0;
}

int N, K, C;
char S[271828];

ki_t k1, k2, k3;

#define INFU 222222

int main(void) {
	int i;
	if (scanf("%d%d%d", &N, &K, &C) != 3) return 1;
	if (scanf("%271827s", S) != 1) return 1;

	/* クールダウン含めそこまでで何日 */
	for (i = 0; i < N; i++) {
		int cur = get(&k1, i, i + 1);
		if (S[i] != 'x') add(&k1, i + C + 1, INFU, cur + 1);
	}
	/* そこから何日 */
	for (i = N - 1; i >= 0; i--) {
		int a = get(&k2, i + 1, INFU);
		int b = S[i] != 'x' ? get(&k2, i + C + 1, INFU) + 1 : 0;
		add(&k2, i, i + 1, tnh(a, b));
	}

	for (i = 0; i <= N + C; i++) add(&k3, i, i + 1, get(&k1, i, i + 1) + get(&k2, i, i + 1));

#if 0
	for (i = 0; i < N; i++) {
		printf("  %c", S[i]);
	}
	puts("");
	for (i = 0; i <= N + C; i++) {
		printf("%3d", get(&k1, i, i + 1));
	}
	puts("");
	for (i = 0; i < N; i++) {
		printf("%3d", get(&k2, i, i + 1));
	}
	puts("");
#endif
	if (C == 0) {
		int count = 0;
		for (i = 0; i < N; i++) {
			if (S[i] == 'o') count++;
		}
		if (count == K) {
			for (i = 0; i < N; i++) {
				if (S[i] == 'o') printf("%d\n", i + 1);
			}
		}
	} else {
		for (i = 0; i < N; i++) {
			if (S[i] == 'o' && get(&k3, i + 1, i + C + 1) < K) printf("%d\n", i + 1);
		}
	}

	return 0;
}

/*

働く→C日後以降のoへ
働かない→明日以降のoへ

「そこを外したとき、何日働けるか」

クールダウン含めそこまでで何日
そこから何日

*/


Measured memory_bytes: 12544
def check(i, N, M, V, P, A):
    K = N - V
    tot = sum(A[(P-1):i]) - A[i]*(i-(P-1))
    if K*M >= tot and (A[P-1]-A[i])<=M:
        return True
    else:
        return False

N, M, V, P = map(int,input().split())
A = [int(i) for i in input().split()]
A.sort(reverse=True)

start = P
end = N-1
if check(end, N, M, V, P, A):
    print(N)
elif not check(start, N, M, V, P, A):
    print(P)
else:
    while True:
        if (end - start) == 1:
            break
        new = (start + end)//2
        flag = check(new, N, M, V, P, A)
        if flag:
            start = new
        else:
            end = new
    print(start+1)
        

Measured memory_bytes: 14996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXI 100000
#define MAXIV 1000000000
int main()
{
    ll n;
    cin>>n;
    ll x[MAXI],l[MAXI];
    vector<pair<ll,ll>> rob(n);
    for(ll i=0;i<n;i++)
	{
        cin>>x[i]>>l[i];
        rob.at(i).second=x[i]-l[i];
        rob.at(i).first=x[i]+l[i];
    }
    sort(rob.begin(),rob.end());
    ll ans=0; ll t=-MAXIV;
    for(ll i=0;i<n;i++)
	{
        if(t<=rob.at(i).second)
		{
            ans++;
            t=rob.at(i).first;
        }
    }
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int t,x,y;
		cin>>t>>x>>y;
		t-=x+y;
		if(t<0||t%2)
			return!(cout<<"No\n");
	}
	return!(cout<<"Yes\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std; 
 int main() {
    int arr[5];    
    int k;
    vector<int> arr2;
    for (int i = 0; i < 5; i++) {
        cin >> arr[i];
    }
    cin >> k;
    for (int i = 1; i <= 4; i++) {
        arr2.push_back(abs(arr[i]-arr[0]));
    }
    for (int i = 2; i <= 4; i++) {
        arr2.push_back(abs(arr[i]-arr[1]));
    }
    for (int i = 3; i <= 4; i++) {
        arr2.push_back(abs(arr[i]-arr[2]));
    }
    arr2.push_back(abs(arr[4]-arr[3]));
    for (int i = 0; i < 10; i++) {
        if (arr2[i] > k) {
            cout << ":(";
            return 0;
        }
    }
    cout << "Yay!";
 }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int answer = 1000000;
  for (int i = 0;i < n;i++){
    int a;
    cin >> a;
    int score = 0;
    while(a % 2 == 0){
      a /= 2;
      score++;
    }

    if (answer > score){
      answer = score;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
/* ex4_2
  bonbonc */

#include<stdio.h>
#include<math.h>
int main(void){
	int length_hours,length_minutes,hours,minutes;
	double theta_hours,theta_minutes;
	scanf("%d%d%d%d",&length_hours,&length_minutes,&hours,&minutes);
	
	theta_hours = (double)((hours+(double)minutes/60)*(M_PI/6));/*時針の回転角（ラジアン）*/
	theta_minutes = (double)(minutes*(M_PI/30));/*分針の回転角（ラジアン）*/
	
	printf("%.20lf\n",sqrt(pow((double)length_hours,2.0)+pow((double)length_minutes,2.0)-(double)(2*length_hours*length_minutes*cos(theta_hours-theta_minutes))));
	/*余弦定理で時針と分針の先の距離を計算して出力。*/
	return 0;
}

Measured memory_bytes: 2584
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,k;
cin>>n>>k;
vector<ll>cnt(n+1,0);
for(ll i=0;i<k;i++)
{
    ll a;
    cin>>a;
    for(ll j=0;j<a;j++)
    {
        ll b;
        cin>>b;
        cnt[b]++;
    }
}
ll ans=0;
for(ll i=1;i<=n;i++)
{
    if(cnt[i]==0)
    {
        ans++;
    }
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3652