akhauriyash/Code-Regression huggingface dataset:
#define first f
#define second s
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#include <bits/stdc++.h>
#define pii pair<string,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn=1e5+5;
const int MOD=998244353;
const double PI=acos(-1);
const double e=2.718281828459;


int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int num=0;
    while(n){
        n/=k;
        num++;
    }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 256
'use strict';
const main = input => {
  const n = parseInt(input[0]);
  let s = input[1];
  let ans = 0;
  for(let i=0; i<s.length-2; i++) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      ans++;
    }
  }
  console.log(ans);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 21064
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
ll N;
ll A[200001];
ll sum[200001];
ll ans;

bool ok(ll x){//
	ll d1,d2,mid,lb,ub;
	rep(st,N){// [st,st+N)??§?????????
		ub=st+N;
		lb=st;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			if( sum[mid]-(st-1<0?0:sum[st-1]) >=x ) ub=mid;
			else lb=mid;
		}
		if(ub>=st+N-2) continue;
		d1=ub+1;
		ub=st+N;
		lb=d1;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			if( sum[mid]-sum[d1-1] >=x ) ub=mid;
			else lb=mid;
		}
		if(ub>=st+N-1) continue;
		d2=ub+1;
		if(sum[st+N-1]-sum[d2-1]>=x) return 1;
	}
	return 0;
}


int main()
{
	cin>>N;
	rep(i,N) cin>>A[i];
	rep(i,N) A[i+N]=A[i];
	A[2*N]=0;
	sum[0]=A[0];
	rep1(i,2*N) sum[i]=A[i]+sum[i-1];
	ll ub=1e17,lb=0;
	while(ub-lb>1){
		ll mid=(ub+lb)/2;
		if(ok(mid)) lb=mid;
		else ub=mid;
	}
	cout<<lb<<endl;
}

Measured memory_bytes: 6200
k = int(input())

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])


Measured memory_bytes: 2940
#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 999999999
#define llong long long

using namespace std;

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

	int c1=0;
	int c2=0;
	int N=s.size();
	for(int i=0;i<N;i++){
		if(i%2==0){
			if(s[i]=='0'){
				c2++;
			}else if(s[i]=='1'){
				c1++;
			}
		}else{
			if(s[i]=='0'){
				c1++;
			}else if(s[i]=='1'){
				c2++;
			}
		}
	}
	int min;
	if(c1>c2){min=c2;
	}else{min=c1;}
	cout<<min<<endl;



	return 0;

}


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


int main() {
    
    int a, b, c;
    cin >> a >> b >> c;
    
    bool fl = true;

    for (int i = min(a, b); i <= max(a, b); ++i) {
        if (i == c) {
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";
    
    return 0;
}


Measured memory_bytes: 256
d=[0]*1e5;d[1]=p=1;n=2..gets.to_i;n.map{|i|p*=i};n.map{|i|c=0;(p/=i;c+=1)while p%i<1;75.downto(0){|k|c.times{|j|d[k.*j+2]+=d[k]}}};p d[75]

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> G(N);
  vector<vector<int>> Ginv(N);
  vector<int> is_child(N);

  vector<int> h(N);

  int a, b;
  for(int i = 0; i < N-1+M; i++){
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    h[b]++;
    Ginv[b].push_back(a);
    is_child[b] = 1;
  }

  int root = 0;
  for(int i = 0; i < N; i++){
    if(is_child[i] == 0){
      root = i;
    }
  }

  vector<int> parent(N);

  stack<int> st;
  st.push(root);

  vector<int> topo;
  while(st.size()){

    int v = st.top(); st.pop();
    topo.push_back(v);

    for(auto& nv : G[v]){
      h[nv]--;
      if(h[nv] == 0) st.push(nv);
    }
  }

  vector<int> topo_order(N);
  for(int i = 0; i < N; i++){
    topo_order[topo[i]] = i;
  }
  
  for(int i = 0; i < N; i++){
    // 自分にはいってくる中で、一番トポロジカル順序が遅い（大きいやつ）
    int tmp = -1;
    for(auto nv : Ginv[i]){
      if(chmax(tmp, topo_order[nv])) parent[i] = nv+1;
    }
  }

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

  return 0;
}


Measured memory_bytes: 13820
#include<stdio.h>

int main(void) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  int d = c - (a - b);
  
  if (d <= 0) printf("0");

  else {
    printf("%d", d);
  }
  
  return 0;
}

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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

int main(){
    int a, b; cin>>a>>b;
    if((a*b) % 2 == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

int main()
{
	long int n;
	long long int k;
	long long int a[100000];
	cin>>n>>k;
	long long int maxa=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		maxa=(maxa>a[i]?maxa:a[i]);
	}
	long long int counter=0;
	long long int poo=1;
	long long int b[1000];
	int maxe=0;
	long long int ki[100];
	for(int i=0;maxa>=poo||k>=poo;i++)
	{
		int count=0;
		for(int j=0;j<n;j++)
		{
			if((a[j]-(a[j]/(poo*2))*poo*2)/poo){count++;}else{}
		}
		b[i]=count;
		if((k-(k/(poo*2))*poo*2)/poo){ki[i]=1;}else{}
		poo=poo*2;
		maxe=i;//bit配列の要素数
	}
	int eval=0;
	for(int i=maxe;i>=0;i--)
	{
		poo=poo/2;
		if(eval==1){
			if(n<=2*b[i]){
				counter+=poo*b[i];}
			else{counter+=(n-b[i])*poo;}
		}else if(ki[i]==1){
				if(n<=2*b[i]){
				counter+=poo*b[i];eval=1;}
			else{counter+=(n-b[i])*poo;}
		}else {counter+=poo*b[i];}
	}
	cout<<counter;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#define ll long long
#define REP(i, n) for(int i=0; i<n; i++)
using namespace std;

int main() {
    string S; cin >> S;
    int n[4]; REP(i,4) n[i] = (S.at(i)-'0');
    char ops[3];

    REP(bit, 1<<3) {
        int sum = n[0];
        REP(i, 3) {
            if (bit & (1<<i)) {
                sum += S.at(i+1) - '0';
                ops[i] = '+';
            } else {
                sum -= S.at(i+1) - '0';
                ops[i] = '-';
            }
        }

        if (sum == 7) {
            REP(i, 3) cout << n[i] << ops[i];
            cout << n[3] << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
'use strict';
(function(stdin) {
  //declare function
  function sum(a, b) {
    return a + b;
  }

  function fillArray(array, n) {
    for (var i = 0, len = array.length; i < len; i++) {
      array[i] = n;
    }
    return array;
  }

  function makeRow(matrix, n) {
    var row = fillArray(Array(matrix.length), 0);
    return row.map(function(v, i) {
      return matrix[i][n];
    });
  }

  function reverseMatrix(matrix) {
    var newMatrix = fillArray(Array(matrix[0].length));
    return newMatrix.map(function(v, i) {
      return makeRow(matrix, i);
    });
  }

  function mulMatrix(matrixX, matrixY) {
    var reverseY = reverseMatrix(matrixY);
    return matrixX.map(function(x) {
      return reverseY.map(function(y) {
        return y.map(function(z, j) {
          return z * x[j];
        }).reduce(sum);
      });
    });
  }

  function toStr(matrix) {
    return matrix.map(function(v) {
      return v.join(' ');
    }).join('\n');
  }
  //declare variable
  var inputs = stdin.toString().trim().split('\n').map(function(v) {
    return v.split(' ').map(Number);
  });
  var size = inputs.shift();
  var matrixA = inputs.splice(0, size[0]);
  var matrixB = inputs.splice(0, size[1]);
  //main

  //display
  console.log(toStr(mulMatrix(matrixA, matrixB)));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21812
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define all(x) x.begin(),x.end()
#define mod 1000000007

ll expo(ll a,ll b){ll r=1;a=a%mod;while(b){if(b%2)r=(r*a)%mod;a=(a*a)%mod;b=b/2;}
return r;}
struct greaterr
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};



/*vector<bool> sieve(10000007,true);

void help(){
     sieve[0] = false;
     sieve[1] = false;

     for(int i=2;i*i<=10000000;++i){
        if(sieve[i]){
            for(int j=i*i;j<=10000000;j+=i)
                sieve[j] = false;

        }
     }

}


ll exp(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
*/
int main() {
   fastIO

     int n;
     cin>>n;

     int arr[n];

     for(int i=0;i<n;++i)
        cin>>arr[i];

     sort(arr,arr+n);

     long double sum = 0;

     sum = (arr[0]+arr[1])/2.0 ;


     for(int i=2;i<n;++i)
     {
         sum =  (sum+arr[i])/2.0;
     }

     cout<<setprecision(6)<<fixed<<sum;


	return 0;
}


Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline

n = int(input())
query = []
for i in range(n):
    x, l = map(int, input().split())
    query.append([x+l, x-l])

# 貪欲
heapq.heapify(query)

finish, start = heapq.heappop(query)
time = finish
count = 1
while len(query) > 0:
    finish, start = heapq.heappop(query)
    if start >= time:
        time = finish
        count += 1
    else:
        continue
print(count)


Measured memory_bytes: 70620
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, cut, a[200008], aa[200008], ia[200008];

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){cin >> a[i];}
	for(ll i = 2; i <= n; i++){a[i] += a[i-1];}
	
	cut = 1;
	for(ll i = 2; i <= n-2; i++){
		while(1){
			if(abs(a[i]-2*a[cut]) < abs(a[i]-2*a[cut+1])){aa[i] = cut; break;}
			else{cut++;}
		}
	}
	
	cut = n-1;
	for(ll i = n-2; i >= 2; i--){
		while(1){
			if(abs(a[n]-2*a[cut]+a[i]) < abs(a[n]-2*a[cut-1]+a[i])){ia[i] = cut; break;}
			else{cut--;}
		}
	}
	
	ll ans = a[n];
	for(ll j = 2; j <= n-2; j++){
		ll maxmax = max(max(a[aa[j]], a[j]-a[aa[j]]), max(a[ia[j]]-a[j], a[n]-a[ia[j]]));
		ll minmin = min(min(a[aa[j]], a[j]-a[aa[j]]), min(a[ia[j]]-a[j], a[n]-a[ia[j]]));
		ans = min(maxmax-minmin, ans);
		//cout << aa[j] << " " << j << " " << ia[j] << endl; 
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
n=int(input())
t=list(map(int,input().split()))
tmp=sum(t)
m=int(input())
px=[list(map(int,input().split())) for i in range(m)]
for i in range(m):
  ans=tmp+px[i][1]
  ans-=t[px[i][0]-1]
  print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <utility>
#include <ctime>
#include <cassert>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii > vii;
typedef vector<pair<int, pair<int, int> > > viii;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<vii> vvii;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define MEM(a,b) memset(a,(b),sizeof(a))
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(a) a.begin(),a.end()
#define loop(x,a,b) for(int (x) = (a);(x)<(b);(x)++)
#define rep(x,n)   for(int (x)=0;(x)<(n);(x)++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ain(a,n) int ((a)[(n)]); for(int i=0; i<(n); i++) cin>>((a)[i])  
#define md 1000000007
#define MAXN 200005

int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s1,s2;
    cin>>s1>>s2;
    int n = s1.length();
    string ans = "Yes";
    map<char,char> dic, rdic;
    rep(i,n)
    {
    	rdic[s2[i]] = s1[i];
    	dic[s1[i]] = s2[i];
    }
    rep(i,n)
    	if (s2[i] != dic[s1[i]] or s1[i] != rdic[s2[i]])
    		ans = "No";
    cout<<ans;

    return 0;
}


Measured memory_bytes: 916
<?php

$A = array();
fscanf(STDIN, "%d", $n);
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d", $a);
    array_push($A, $a);
}
sort($A);
$count = 1;
for ($i = 0; $i < $n; $i++) {
    $a=array_pop($A);
    if ($a - (int) ($i / 4) > 0) {
        $count+=$a - (int) ($i / 4);
    } else {
        break;
    }
}

echo $count . "\n";
?>

Measured memory_bytes: 6660
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}

int main(){
	//freopen("in.txt","r",stdin);
	ll s;cin>>s;	
	int inv=1000000000;
	int t=s%inv;
	int x=(inv-t)%inv;
	int y=(s+x)/inv;
	cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");
let input = "";
process.stdin.on("data", function(chunk) {input += chunk;});
process.stdin.on("end", function() {main(input.split("\n"));});

function allocNode(key) {
	const p = {};
	p.key = key;
	p.left = null;
	p.right = null;
	return p;
}

function insert(p,c) {
	if (p === null) return c;
	if (c.key < p.key) {
		p.left = insert(p.left,c);
	}	else {
		p.right = insert(p.right,c);
	}
	return p;
}

function find(p,key) {
	if (p !== null && p.key !== key) {
		if (key < p.key) p = find(p.left,key);
		else p = find(p.right,key);
	}
	return p;
}

function inset(p,ary) {
	if (p === null) return;
	inset(p.left,ary);
	ary.push(p.key);
	inset(p.right,ary);
}

function preset(p,ary) {
	if (p === null) return;
	ary.push(p.key);
	preset(p.left,ary);
	preset(p.right,ary);
}

function dump(p,setfunc) {
	const ary = [];
	setfunc(p,ary);
	console.log(ary.map(x => ` ${x}`).join(""));
}

function main(lines){
	const n = Number(lines[0]);
	let p, key, line, root = null;

	for (let i = 0; i < n; i++) {
		line = lines[i+1].split(" ");
		switch(line[0][0]) {
		case "i":
			key = Number(line[1]);
			p = allocNode(key);
			root = insert(root,p);
			break;
		case "p":
			dump(root,inset);
			dump(root,preset);
			break;
		case "f":
			key = Number(line[1]);
			if (find(root,key) !== null) console.log("yes");
			else console.log("no");
			break;
		}
	}
}



Measured memory_bytes: 215108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num;
  cin >> num;
  vector<int> houses(num);
  int avarage;
  int minX = 100;
  int maxX = 0;
  
  int ans = INT_MAX;
  
  for(int i=0; i < num; i++) {
    int current;
    cin >> current;
    minX = min(minX, current);
    maxX = max(maxX, current);
    houses.at(i) = current;
  }
  for(int i = minX; i <= maxX; i++) {
    int tempAns = 0;
   for(int j = 0; j < num; j++) {
     int foo = houses.at(j) - i;
     tempAns += foo * foo;
   }
    ans = min(ans, tempAns);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    std::cout<<std::fixed<<std::setprecision(10);
   int n,k,x,y;
   cin>>n>>k>>x>>y;
   ld ans =((ld)n*(ld)k)/2;
   cout<<ans<<" ";

   if(n==2*x&&k==2*y)cout<<1<<endl;
   else cout<<0<<endl;


}


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

int main() {
	int N, H, W;
	cin >> N >> H >> W;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		if ((x >= H) && (y >= W)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

bool isPrime(long long X){
  if(X==2){
    return true;
  }
  else if(X%2 == 0){
    return false;
  }

  for (int k = 3; k < sqrt(X); k=k+2) {
    if(X%k==0){
      return false;
    }
  }
  return true;
}

int main(){
  long long X;

  cin >> X;

  long long i= X;
  while(true){
    if(isPrime(i)){
      cout << i << endl;
      break;
    }
    i++;
  }

  return 0;
}


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

int N;
vector<int> vec;

int main(int argc, char **argv)
{
	cin >> N;
	vec.resize(N);

	for (int i = 0; i < N; ++i)
		cin >> vec[i];

	sort(vec.begin(), vec.end(), greater<int>());

	int before = -1;
	for (auto it = vec.begin(); it != vec.end();)
	{
		if (before == *it)
		{
			it = vec.erase(it);
		}
		else
		{
			before = *it;
			++it;
		}
	}
	std::cout << vec.size() << std::endl;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
lnt W,H,n;
lnt X1[1000],X2[1000];
lnt Y1[1000],Y2[1000];
queue<P> q;
lnt compress(lnt w,lnt *x1,lnt *x2){
	vector<lnt> xs;
	xs.push_back(0);
	xs.push_back(w-1);
	for(lnt i=0;i<n;i++){
		for(lnt d=-1;d<=1;d++){
			if(0<=x1[i]+d&&x1[i]+d<w) xs.push_back(x1[i]+d);
			if(0<=x2[i]+d&&x2[i]+d<w) xs.push_back(x2[i]+d);
		}
	}
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	for(lnt i=0;i<n;i++){
		x1[i]=lower_bound(xs.begin(),xs.end(),x1[i])-xs.begin();
		x2[i]=lower_bound(xs.begin(),xs.end(),x2[i])-xs.begin();
	}
	return xs.size();
}

bool ita[6100][6100];

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

void bfs(lnt i,lnt j){
	if(ita[i][j]) return;
	ita[i][j]=1;
	for(lnt d=0;d<4;d++){
		lnt nx=i+dx[d],ny=j+dy[d];
		if(0<=nx&&nx<W&&0<=ny&&ny<H) q.push(P(nx,ny));
	}
}

int main()
{while(1){
	memset(ita,0,sizeof(ita));
	scanf("%lld%lld",&W,&H);
	if(!W&&!H) return 0;
	scanf("%lld",&n);
	for(lnt i=0;i<n;i++){
		scanf("%lld%lld%lld%lld",&X1[i],&Y1[i],&X2[i],&Y2[i]);
		X2[i]--;
		Y2[i]--;
	}
	W = compress(W,X1,X2);
	H = compress(H,Y1,Y2);
	for(lnt i=0;i<n;i++){
		for(lnt x=X1[i];x<=X2[i];x++){
			for(lnt y=Y1[i];y<=Y2[i];y++){
				ita[x][y]=1;
			}
		}
	}
	lnt ans=0;
	for(lnt i=0;i<W;i++){
		for(lnt j=0;j<H;j++){
			if(ita[i][j]) continue;
			ans++;
			q.push(P(i,j));
			while(!q.empty()){
				P p=q.front();
				q.pop();
				bfs(p.first,p.second);
			}
		}
	}
	cout<<ans<<endl;
}}

Measured memory_bytes: 39600
#include<stdio.h>
#include<math.h>

long long solve(long long n,long long k){
  long long r,t;

  if(k == 0) return n;

  r = n % k;

  if(r - k > 0) t = r - k;

  else t = k - r;

  if(r > t) return t;

  else return r;
}

int main(){
  long long n,k;

  scanf("%lld %lld", &n, &k);

  printf("%lld", solve(n,k));

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long x[n], y[n], h[n];
  for(int i = 0; i < n; i++)
    cin >> x[i] >> y[i] >> h[i];
  for(int cx = 0; cx <= 100; cx++){
    for(int cy = 0; cy <= 100; cy++){
      long long H = 0;
      for(int i = 0; i < n; i++){
        if(h[i] == 0) continue;
        H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
      }
      if(H == 0) continue;
      bool flag = true;
      for(int i = 0; i < n; i++){
        long long th = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0LL);
        if(h[i] != th){
          flag = false;
          break;
        }
      }
      if(!flag) continue;
      cout << cx << " " << cy << " " << H << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
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 n = Integer.parseInt(str[0]);
    int a = Integer.parseInt(str[1]);
    int b = Integer.parseInt(str[2]);
    System.out.println(Math.min(a*n,b));
  }
}

Measured memory_bytes: 32744
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

vector<long long> fact(100001,1);
void factorial(int N){
    for(int i=1; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

map<long long, long long> inv_fact;
long long inv_factorial(long long x){
    if (inv_fact.count(x)){
        return inv_fact[x];
    }
    long long p=MOD-2;
    long long ret=1;
    long long tmp=x;
    while(p>0){
        if(p%2==1)ret=ret*tmp%MOD;
        tmp=tmp*tmp%MOD;
        p/=2;
    }
    inv_fact[x]=ret;
    return ret;
}

long long comb(int a, int b){
    if(a<b){
        return 0;
    }else if(min(a,b)<0){
        return 0;
    }
    long long ret=fact[a]*inv_factorial(fact[a-b])%MOD;
    return ret*inv_factorial(fact[b])%MOD;
}

int main(){
    int n;
    cin >> n;
    vector<int> vec(n+1,0);
    vector<int> already(n+1,-1);
    int diff=0;

    factorial(100001);

    for(int i=0; i<=n; i++){
        cin >> vec[i];
        if(already[vec[i]]>=0){
            diff=abs(already[vec[i]]-i);
        }
        already[vec[i]]=i;
    }

    //cout << diff << endl;
    long long ans=0;
    for(int i=1; i<=n+1; i++){
        cout << (MOD+(comb(n+1, i)-comb(n-diff, i-1))%MOD)%MOD << endl;;
    }
}

Measured memory_bytes: 9088
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int[] bingo = new int[9];
      
        for(int i = 0; i < 9; i++){
          bingo[i] = sc.nextInt();
        }
      
        while(sc.hasNext()){
          int next = sc.nextInt();
          for(int i = 0; i < 9; i++){
            if(bingo[i] == next){
              bingo[i] = 0;
            }
          }
        }
       
        String ans = "No";
        if(bingo[0] == bingo[1] && bingo[1] == bingo[2]){
          ans = "Yes";
        }else if(bingo[3] == bingo[4] && bingo[4] == bingo[5]){
          ans = "Yes";
        }else if(bingo[6] == bingo[7] && bingo[7] == bingo[8]){
          ans = "Yes";
        }else if(bingo[0] == bingo[3] && bingo[3] == bingo[6]){
          ans = "Yes";
        }else if(bingo[1] == bingo[4] && bingo[4] == bingo[7]){
          ans = "Yes";
        }else if(bingo[2] == bingo[5] && bingo[5] == bingo[8]){
          ans = "Yes";
        }else if(bingo[0] == bingo[4] && bingo[4] == bingo[8]){
          ans = "Yes";
        }else if(bingo[2] == bingo[4] && bingo[4] == bingo[6]){
          ans = "Yes";
        }
        
        System.out.println(ans);
	}

}

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

int main(){
    long n,k;
    cin>>n>>k;

    long surplus=n%k;

    if(n>=k){
        cout<<min(surplus,k-surplus)<<endl;
    }else{
        if(n*2>=k){
            cout<<k-n<<endl;
        }else{
            cout<<n<<endl;
        }
    }
}

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

int	main(void)
{
	int x, n;
	cin >> x >> n;
	vector<bool> can_use(220, true);
	int p;
	for (int i = 0; i < n; i++)
	{
		cin >> p;
		can_use[p + 110] = false;
	}
	int ans = -1;
	int diff = 1e9;
	for (int i = 0; i < 220; i++)
	{
		if (!can_use[i]) continue ;
		if (abs(x - (i - 110)) < diff)
		{
			ans = i - 110;
			diff = abs(x - (i - 110));
		}
	}
	cout << ans << endl;
	return (0);
}


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

int main()
{
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N + 10, 0));
  for (int i = 0; i < N; i++) cin >> A.at(0).at(i);
  for (int i = 0; i < N; i++) cin >> A.at(1).at(i);
  
  int max = 0; 
  for (int i = 0; i < N; i++)
  {
    int candies = 0;
    
    for (int j = 0; j <= i; j++) candies += A.at(0).at(j);
    for (int j = i; j < N; j++) candies += A.at(1).at(j);
    
    if (max < candies) max = candies;
  }
  
  cout << max << endl;
}

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

using namespace std;

int main(){
 int n;
  cin >> n;
  
  int l=10000;
  int u=-1;
  int a[n];
  
  for(int i=0;i<n;i++) {
    cin >> a[i];
   l=min(l,a[i]);
   u=max(u,a[i]);
  }

  cout << u-l << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	string S, T;
	cin >> S;
	cin >> T;

	int ans = 0;
	rep(i, 3) {
		if (S[i] == T[i]) {
			ans ++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i, a, b, c;
	int min;

	scanf("%d %d %d", &a, &b, &c);
	min = a + b;
	if (min > a + c) {
		min = a + c;
	}
	if (min > b + c) {
		min = b + c;
	}
	printf("%d\n", min);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

bool isPalindrome(string s) {
  int n = s.length();
  rep(i, n / 2) {
    if (s[i] != s[n - i - 1]) {
      return false;
    }
  }
  return true;
}

int main() {
  string s;
  cin>>s;
  if (!isPalindrome(s)) {
      cout << "No";
      return 0;
  }
  
  string a = s.substr(0, s.length() / 2);
  if (!isPalindrome(a)) {
    cout << "No";
    return 0;
  }

  string b = s.substr(s.length() / 2 + 1, s.length() / 2);
  if (!isPalindrome(b)) {
    cout << "No";
    return 0;
  }
  cout << "Yes";
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

std::string S;
bool solve(int p) {
    if(p==S.size()) return true;
	if(S.substr(p,5)=="dream"   && solve(p+5)) return true;
	if(S.substr(p,5)=="erase"   && solve(p+5)) return true;
	if(S.substr(p,6)=="eraser"  && solve(p+6)) return true;
    if(S.substr(p,7)=="dreamer" && solve(p+7)) return true;
    return false;
}

int main() {
    std::cin >> S;
    std::cout << (solve(0) ? "YES" : "NO") << std::endl;
}

Measured memory_bytes: 2560
S=input()
ans=0
for i in range(len(S)):
    cnt=0
    while True:
        if  i>=len(S):
            break
        elif S[i] not in ["A","C","G","T"]:
            break
        else:
            cnt+=1
            i+=1    
    if cnt>ans:
        ans=cnt
print(ans)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    w,a,b = map(int, input().split())

    if ((a+w)<b) or ((b+w)<a):
        print(min(abs(a+w-b), abs(b+w-a)))
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65452
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(std::vector<long long> M, std::vector<long long> D){
    ll ret=0;
    if(M[0]!=M[1]&&D[0]!=D[1]){
        ret=1;
    }
    cout << ret << "\n";
}

int main(){
    std::vector<long long> M(2);
    std::vector<long long> D(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&M[i]);
        scanf("%lld",&D[i]);
    }
    solve(std::move(M), std::move(D));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

vec kmp_table(string &Pattern) {
    ll i = 2, j = 0;
    vec T(Pattern.size(), -1);
    T[1] = 0;

    while (i < (ll)Pattern.size()) {
        if (Pattern[i-1] == Pattern[j]) {
            T[i] = j+1;
            i++;
            j++;
        } else if (j > 0) {
            j = T[j];
        } else {
            T[i] = 0;
            i++;
        }
    }

    return T;
}

vec kmp_search (string &Text, string &Pattern, vec &kmptable) {
    vec ret;
    ll m = 0, i = 0;
    while (m+i < (ll)Text.size()) {
        if (Pattern[i] == Text[m+i]) {
            i++;
            if (i == (ll)Pattern.size()) {
                ret.push_back(m);
                i--;
                m = m+i-kmptable[i];
                if (i > 0) i = kmptable[i];
            }
        } else {
            m = m+i-kmptable[i];
            if (i > 0) i = kmptable[i];
        }
    } 
    return ret;
}

mat graph;
vec d;
ll dfs (ll v, ll start) {
    if (d[v] != -1) return d[v];
    if (graph[v].size() == 0) {
        d[v] = 0;
        return 0;
    }
    if (graph[v][0] == start) {
        cout << -1 << "\n";
        exit(0);
    }
    d[v] = dfs(graph[v][0], start) + 1;
    return d[v];
}

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

    string s, t;
    cin >> s >> t;
    while (s.size() <= t.size()) {
        s += s;
    }
    ll n = s.size();
    s += s;

    // cout << s << "\n";
    // cout << t << "\n";

    vec T = kmp_table(t);
    vec result = kmp_search(s, t, T);
    graph.assign(n, vec());
    for (ll e : result) {
        if (e < n) graph[e].push_back((e+t.size())%n);
    }

    d.assign(n, -1);

    Rep (i, n) {
        if (d[i] == -1) dfs(i, i);
    }

    ll ans = 0;
    Rep (i, n) chmax(ans, d[i]);
    cout << ans << "\n";

}


Measured memory_bytes: 98000
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var monsters = readInts()
    var heroes = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    var ans = 0
    for i in 0..<n{
        ans             += min(heroes[i], monsters[i])
        heroes[i]       -= min(heroes[i], monsters[i])
        monsters[i]     -= min(heroes[i], monsters[i])
        ans             += min(heroes[i], monsters[i + 1])
        monsters[i + 1] -= min(heroes[i], monsters[i + 1])
    }
    print(ans)
}
main()


Measured memory_bytes: 22340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a[26];
  string s, ans="Yes";
    for(int i=0; i<26; i++) a[i] = 0;
    cin >> s;
      for(int i=0; i<s.size();i++) a[s[i]-'a'] += 1;

      for(int i=0; i<26; i++)
        if(a[i]%2==1) ans="No";

      cout << ans << endl;
}

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

int main(void){
    int N,a[101];

    scanf("%d",&N);

    int i;
    for(i=0;i<N-1;i++){
        scanf("%d ",&a[i]);
    }
        scanf("%d",&a[N-1]);

    double sum=0;

    for(i=0;i<N;i++)sum += 1/(double)a[i];

    sum = 1/sum;

    printf("%lf\n",sum);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

	public class Main {

		static long mod = 1000000007;

		static long powmod(long x, long y) {
			long res=1;
			for(long i=0; i<y; i++) {
				res=res*x%mod;
			}
			return res;
		}

		public static void main(String[] args) {
			// AtCoder_C
			Scanner sc = new Scanner(System.in);
			long ans = 0;

			int N = sc.nextInt();
    	    // Scannerクラスのインスタンスをクローズ
    		sc.close();

			ans = powmod(10,N) - powmod(9,N) - powmod(9,N) + powmod(8,N);
			ans%=mod;
			ans=(ans+mod)%mod;

    		System.out.println(ans);
    	}
    }

Measured memory_bytes: 35704
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;


int H,W;
int moji[29];
char jj;
int ff;
int f1,f2,f4;

int main(){
	cin >> H >> W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> jj;
			moji[jj-'a']++;
		}
	}
	if(H%2==0 && W%2==0){
		for(int i=0;i<26;i++){
			if(moji[i]>0&&moji[i]%4==0){
				ff += moji[i]/4;
			}
		}
		if(4*ff == H*W){
			printf("Yes\n");
			return 0;
		}
		else{
			printf("No\n");
			return 0;
		}
	}
	if(H%2==1 && W%2==1){
		for(int i=0;i<26;i++){
			if(moji[i]%2==1){
				f1 ++;
				f4 += moji[i]/4;
				f2 += moji[i]/2-2*(moji[i]/4);
			}
			else{
				f4 += moji[i]/4;
				f2 += moji[i]/2-2*(moji[i]/4);
			}
//			printf("%d %d %d\n",f1,f2,f4);
		}
			if(f1 !=1){
				printf("No\n");
				return 0;
			}
			if(f2 <= (H/2+W/2)){
				printf("Yes\n");
				return 0;
			}
			else{
				printf("No\n");
				return 0;
			}

	}
	if(H%2==1 && W%2==0){
		for(int i=0;i<26;i++){
//			printf("moji[%d]=%d\n",i,moji[i]);
			if(moji[i]%2==1){
				f1 ++;
				f4 += moji[i]/4;
				f2 += moji[i]/2-2*(moji[i]/4);
			}
			else{
				f4 += moji[i]/4;
				f2 += moji[i]/2-2*(moji[i]/4);
			}
//			printf("%d %d %d\n",f1,f2,f4);
		}
		if(f1 >0){
			printf("No\n");
			return 0;
		}
		if(f2 <= W/2){
			printf("Yes\n");
			return 0;
		}
		else{
			printf("No\n");
			return 0;
		}
	}
	if(H%2==0 && W%2==1){
		for(int i=0;i<26;i++){
			if(moji[i]%2==1){
				f1 ++;
				f4 += moji[i]/4;
				f2 += moji[i]/2-2*(moji[i]/4);
			}
			else{
				f4 += moji[i]/4;
				f2 += moji[i]/2-2*(moji[i]/4);
			}
//			printf("%d %d %d\n",f1,f2,f4);
		}
			if(f1 >0){
				printf("No\n");
				return 0;
			}
			if(f2 <= H/2){
				printf("Yes\n");
				return 0;
			}
			else{
				printf("No\n");
				return 0;
			}

	}
}







		



















		



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

using namespace std;

int main() {
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    long int n;
    cin >> n;
    long int ans=1;
    while((ans*ans)<=n){
        ans++;
    }
    ans--;
    cout << ans*ans;
    
    return 0;
}

Measured memory_bytes: 256
def main():

    X11 = int(input())
    X12 = int(input())
    X22 = int(input())
    X13 = 0
    while True:
        v = X11 + X12 + X13 # 1st row
        X31 = v - X13 - X22 # diag 2
        X21 = v - X11 - X31 # 1st col
        X23 = v - X21 - X22 # 2nd row
        X33 = v - X13 - X23 # 3rd col
        X32 = v - X12 - X22 # 2nd col

        if X31 + X32 + X33 == v and X11 + X22 + X33 == v: # 3rd row, diag 1
            print(" ".join(map(str, [X11, X12, X13])))
            print(" ".join(map(str, [X21, X22, X23])))
            print(" ".join(map(str, [X31, X32, X33])))
            break
        X13 += 1

if __name__ == '__main__':
    main()

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

int h,w,c;
int map[8][8];
int ans,cnt;

void dfs(int y,int x,int now, int color){
  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};
  int sx,sy;

  map[y][x] = color;
  cnt++;

  for(int i=0;i<4;i++){
    sx = x + dx[i];
    sy = y + dy[i];
    if(sx < 0 || sx >= w || sy < 0 || sy >= h)continue;
    if(map[sy][sx] == now)dfs(sy,sx,now,color);
  }
}

void rec(int time){
  int tmp[8][8];

  if(time==4){
    if(map[0][0] != c)dfs(0,0,map[0][0],c);
    cnt = 0;
    dfs(0,0,c,0);
    ans = max(ans,cnt);
  }else{

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)tmp[i][j] = map[i][j];
    }
    
    for(int i=1;i<=6;i++){
      if(i!=map[0][0]){
	dfs(0,0,map[0][0],i);
	rec(time+1);
	for(int j=0;j<h;j++){
	  for(int k=0;k<w;k++)map[j][k] = tmp[j][k];
	}
      }
    }
  }
}

int main(){
  while(1){
    cin >> h >> w >> c;
    if(!h && !w && !c)break;

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

    ans = 0;
    rec(0);

    cout << ans << endl;
  }
}

Measured memory_bytes: 872
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
long bignum = 1_000_000_007;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto c = new long[](0);
    foreach (_; 0 .. 3)
    {
        auto tmp = aryread();
        c ~= tmp;
    }
    bool check = true;
    long b1, b2, b3, a2, a3;
    b1 = c[0];
    b2 = c[1];
    b3 = c[2];
    if(!((c[3] - b1) == (c[4] - b2) && (c[3] - b1) == (c[5] - b3)))
        check = false;
    if(!((c[6] - b1) == (c[7] - b2) && (c[6] - b1) == (c[8] - b3)))
        check = false;

    if(check)
        writeln("Yes");
    else
        writeln("No");
}

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

F = []
for i in range(N):
    F.append(list(map(int, input().split(' '))))

P = []
for i in range(N):
    P.append(list(map(int, input().split(' '))))

max_ = -1000000000

for i in range(1, 2 ** 10):
    pattern = [int((i >> _i) % 2 == 1) for _i in range(10)]
    
    score = 0
    for n in range(N):
        same_num = 0
        for j in range(10):
            if pattern[j] == 0:
                continue
            if F[n][j] == 1:
                same_num += 1
        score += P[n][same_num]
    if score > max_:
        max_ = score
print(max_)
       

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

int main() {
  int N;
  cin >> N;
  vector<string>blue(N);
  for(int i=0;i<N;i++) {
    cin >> blue.at(i);
  }
  int M;
  cin >> M;
  vector<string>red(M);
  for(int i=0;i<M;i++) {
    cin >> red.at(i);
  }
  
  int answer =0;
  
  for(int i=0;i<N;i++) {
    int x=0;
    for(int j=0;j<N;j++) {
      if(blue.at(i)==blue.at(j)) {
        x++;
      }
    }
    for(int j=0;j<M;j++) {
      if(blue.at(i)==red.at(j)) {
        x--;
      }
    }
    if(answer<x) {
      answer = x;
    }
  }
  cout << answer << endl;
}

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

int main()
{
  int n;
  scanf("%d",&n);
  int a[n],i,sum1=0,sum=0,min=32000;
  
  for(i=0;i<n;++i)
  { scanf("%d",&a[i]);
    sum+=a[i];
  }
  
  for(i=0;i<n-1;++i)
  {
    sum1+=a[i];
    if(min>abs((sum-sum1)-sum1))
      { min=abs((sum-sum1)-sum1);
        
      }
  }
  
  printf("%d",min);
}


Measured memory_bytes: 128
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let x: u32 = buf.trim().parse().unwrap();

    let mut max = 1;
    for i in 2..x {
        let mut val = 1;
        let mut power = 0;
        loop {
            val = val * i;
            if val > x {
                if val/i > max && power > 1 {
                    max = val/i;
                }
                break;
            }
            power += 1;
        }
    }

    println!("{}", max)
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int x = 100 * a + 10 * b + c;
	if (x % 4 == 0) cout << "YES"<<endl;
	else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string w;
	cin >> w;
	for (char i = 'a'; i <= 'z'; ++i) {
		if (count(all(w), i) % 2 != 0) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

using namespace std;

//最大公約数 gcd
double gcd(double a, double b){
	while (a != b){
		a > b ? a -= b : b -= a;
	}
	if (a == b) return a;
}

//最小公倍数 lcm
double lcm(double a, double b){
	return a*b/gcd(a, b);
}

int main(){
	int a, b;
	while (cin >> a >> b){
		printf("%.0f %.0f\n", gcd(a, b), lcm(a, b));
	}
	return 0;
}

Measured memory_bytes: 1188