akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> s(n+1);
  int m;
  for(int i = 0; i < n; i++){
    cin >> m;
    s.at(i+1) = s.at(i) + m+1;
  }
  
  int ans = 0;
  int tmp = 0;
  for(int i = 0; i + k <= n; i++){
    tmp = s.at(i+k) - s.at(i);
    if(ans < tmp) ans = tmp;
  }
  cout<<fixed<<setprecision(10);
  cout << ans / 2.0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
int main(void){
    // Your code here!
    string S;
    char bf;
    cin >> S;
    bf = S[1];
    for(int i = 0; i < 3; i++)
    {
        if(S[i]==bf)
        {
            cout << "Bad" << endl;
            exit(0);
        }
        bf=S[i+2];
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
import math
while True:
    n = int(input())
    if n == 0:
        break
    else:
        ans = 0
        point = list(map(int,input().split(' ')))
        sum_point = sum(point)
        ave = float(sum_point / n)
        for i in point:
            ans += (i-ave)**2
        ans = ans / n
        print(math.sqrt(ans))



Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
string s;

int main(void){
    
    scanf("%d", &N);
    cin >> s;
    
    int ans = 0;
    for(int i = 1; i < N; ++i){
        map<char, int> a, b;
        for(int j = 0; j < i; ++j) ++a[s[j]]; 
        for(int j = i; j < N; ++j) ++b[s[j]];
        int cnt = 0;
        for(auto m : a) if(b.find(m.first) != b.end()) ++cnt;
        ans = max(ans, cnt);
     }
     printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
int main()
{
	ll mx, my;
	scanf("%lld%lld", &mx, &my);
	vector<pii>vec;
	for (int i = 0; i < mx; i++)
	{
		ll z;
		scanf("%lld", &z);
		vec.push_back(make_pair(z, 0));
	}
	for (int i = 0; i < my; i++)
	{
		ll z;
		scanf("%lld", &z);
		vec.push_back(make_pair(z, 1));
	}
	sort(vec.begin(), vec.end());
	ll ans = 0;
	ll nx = mx + 1, ny = my + 1;
	for (int i = 0; i < vec.size(); i++)
	{
		if (vec[i].second == 0)
		{
			ans += ny*vec[i].first;
			nx--;
		}
		else
		{
			ans += nx*vec[i].first;
			ny--;
		}
	}
	printf("%lld\n", ans);
}

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

int main(){
	int a,b,num,next=1,count=0;
	cin>>a>>b;
	if(a+b>=10){
    	cout<<"error";
    }else{
    	cout<<a+b;
    }
}

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


using namespace std;

int n,vis[101][101];
struct point{int x,y;};
point grid[101][101];

int dfs(int x,int y,int fg){

	vis[y][x]=fg;
	point nx=grid[y][x];
	int res=vis[nx.y][nx.x];
	
	if(vis[nx.y][nx.x]==0)res=dfs(nx.x,nx.y,fg);
	vis[y][x]=res;
	
	return res;
}

int main(void){

	point p;
	
	while(cin >> n,n){
		fill(vis[0],vis[101],0);
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin >> p.x >> p.y;
				grid[i][j]=p;
			}
		}
		
		int cnt=1;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(!vis[i][j]){
					cnt++;
					int tmp=dfs(j,i,cnt);
					if(tmp!=cnt)cnt--;	
				}
			}
		}

		cout << cnt-1 << endl;
	}

return 0;
}

Measured memory_bytes: 1284
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

const int num=1000000007;
ll n;
vector<int> a(1001);

int count(int m)
{
  int k=2;
  while(m>1)
  {
    if(m%k==0)
    {
      a.at(k)++;
      m/=k;
    }
    else if(m%k!=0) k++;
  }
  return 0;
}

int main()
{
  cin>>n;
  for(int i=n;i>1;i--) count(i);

  ll ans=1;
  rep(i,n+1)
  {
    ans*=(a.at(i)+1);
    ans%=num;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
import math
h,w=map(int,input().split())
x=h
y=w

ans=x*y

for i in range(1,x):
    x1=i
    
    x2=(x-x1)//2
    x3=x-x1-x2
    s1=x1*y
    s2=x2*y
    s3=x3*y
    a_yoko=max(s1,s2,s3)-min(s1,s2,s3)
    
    y2=y//2
    y3=y-y2
    x2=x-x1
    x3=x2
    y1=y
    
    s1=x1*y1
    s2=x2*y2
    s3=x3*y3
    a_tate=max(s1,s2,s3)-min(s1,s2,s3)
    
    ans=min(a_yoko,a_tate,ans)

x=w
y=h
 
for i in range(1,x):
    x1=i
    
    x2=(x-x1)//2
    x3=x-x1-x2
    s1=x1*y
    s2=x2*y
    s3=x3*y
    a_yoko=max(s1,s2,s3)-min(s1,s2,s3)
    
    y2=y//2
    y3=y-y2
    x2=x-x1
    x3=x2
    y1=y
    
    s1=x1*y1
    s2=x2*y2
    s3=x3*y3
    a_tate=max(s1,s2,s3)-min(s1,s2,s3)
    
    ans=min(a_yoko,a_tate,ans)
    
print(ans)    

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

int main(void) {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  const double pi = 3.14159265358979;

  double radh = (h + m / 60.) / 6. * pi;
  double radm = m * pi / 30.;
  double dist = sqrt(a * a + b * b - 2 * a * b * cos(abs(radh - radm)));

  cout << setprecision(10) << dist << endl;
  return 0;
}

Measured memory_bytes: 4212
#include<stdio.h>
#include<stdlib.h> //function atoi reader
#include<string.h>
#define N 2
int main(){
  int x[98],i = 0,j = 0,n[100],sum;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
	n[i - 2] = n[i - 2] + n[i - 1];
	i--;
	

    } else if ( s[0] == '-' ){
	n[i - 2] = n[i - 2] - n[i - 1];
	i--;

    } else if ( s[0] == '*' ){
	n[i - 2] = n[i - 2] * n[i - 1];
	i--;
	

    } else {
      n[i] = atoi(s);
	i++;

    }
  }

printf("%d\n",n[0]);
  return 0;
}

Measured memory_bytes: 548
ps=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
n=int(input())
factor=[0]*len(ps)
for i in range(2,n+1):
    for j in range(len(ps)):
        p=ps[j]
        while True: 
            if i%p==0:
                i//=p
                factor[j]+=1
            else:
                break
res=0
if factor[0]>=74:
    res+=1
for i in range(len(ps)):
    for j in range(i+1,len(ps)):
        if factor[i]>=2 and factor[j]>=24:
            res+=1
        if factor[i]>=4 and factor[j]>=14:
            res+=1
        if factor[i]>=14 and factor[j]>=4:
            res+=1
        if factor[i]>=24 and factor[j]>=2:
            res+=1
for i in range(len(ps)):
    for j in range(i+1,len(ps)):
        for k in range(j+1,len(ps)):
            if factor[i]>=2 and factor[j]>=4 and factor[k]>=4:
                res+=1
            if factor[i]>=4 and factor[j]>=2 and factor[k]>=4:
                res+=1
            if factor[i]>=4 and factor[j]>=4 and factor[k]>=2:
                res+=1
print(res)

Measured memory_bytes: 40176
<?php
list($n) = ints();
$m = 26;
$c = ints();
$last = array_fill(0, $m, 0);
for ($i = 1; $i <= $n; ++$i) $s[$i] = ints();
for ($i = 1; $i <= $n; ++$i) {
    list($t) = ints();
    --$t;
    $ans[$i] = ($ans[$i - 1] ?? 0) + $s[$i][$t];
    $last[$t] = $i;
    for ($j = 0; $j < $m; ++$j) {
        $ans[$i] -= $c[$j] * ($i - $last[$j]);
    }
}
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16628
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	cin >> n >> k;
	int d[k];
	int sunu[n] = {};
	rep(i, k) {
		cin >> d[i];
		int a[d[i]];
		rep(j, d[i]) {
			cin >> a[j];
			sunu[--a[j]]++;
		}
	}
	
	int ans = 0;
	rep(i, n) {
		if(!sunu[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    constexpr ll NINF = -(1LL<<60);
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    REP(i,N) {cin >> P[i]; P[i]--;}
    vector<ll> C(N);
    REP(i,N) cin >> C[i];
    // ループのグループ
    vector<int> loopg(N);
    int cntloopg = 1;
    // ループサイズ
    vector<int> loopsize(1);
    // ループグループごとの歩数別最大スコア
    vector<vector<ll>> loopmaxscore(1,vector<ll>(1));
    // ループグループごとの1周スコア
    vector<ll> loopscore(1);


    ll ans = NINF;
    REP(i,N) {
        if (loopg[i] == 0) {
            int pos = P[i];
            int loops = 0;
            ll score = 0;
            while(loopg[i] == 0) {
                score += C[pos];
                loopg[pos] = cntloopg;
                pos = P[pos];
                loops++;
            }
            loopsize.push_back(loops);
            loopscore.push_back(score);
            loopmaxscore.push_back(vector<ll>(loops+1,NINF));
            cntloopg++;
            // cerr << i+1 << " " << score << " " << loops << endl;
        }

        int pos = P[i];
        ll score = 0;
        REP(j,loopsize[loopg[i]]) {
            score += C[pos];
            pos = P[pos];
            loopmaxscore[loopg[i]][j] = max(loopmaxscore[loopg[i]][j],score);
            if (j != 0) loopmaxscore[loopg[i]][j] = max(loopmaxscore[loopg[i]][j],loopmaxscore[loopg[i]][j-1]);
        }
        int loopnum = K / loopsize[loopg[i]];
        int loopmod = K % loopsize[loopg[i]];
        ll tmp = 0;
        if (loopnum == 0) tmp = loopmaxscore[loopg[i]][loopmod-1];
        else {
            if (loopscore[loopg[i]] < 0) tmp = loopmaxscore[loopg[i]][loopsize[loopg[i]]-1];
            else {
                tmp = loopscore[loopg[i]] * (loopnum-1) + loopmaxscore[loopg[i]][loopsize[loopg[i]]-1];
                if (loopmod != 0) tmp = max(tmp,loopscore[loopg[i]] * loopnum + loopmaxscore[loopg[i]][loopmod-1]);
            }
        }
        ans = max(ans,tmp);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3768
'use strict'

function main(input) {
  input = input
    .trim()
    .split('\n')
    .map(v => v.split(' ').map(v => Number(v)))
  const N = input[0][0]
  const T = input[1]
  const M = input[2][0]
  const P = input.slice(3)

  // console.log(M, P)

  const total = T.reduce((a, b) => a + b)

  let ans = []
  for (let i = 0; i < M; i++) {
    const a = P[i][0]
    const b = P[i][1]

    ans.push(total - (T[P[i][0] - 1] - P[i][1]))
  }
  console.log(ans.join('\n'))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 21064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int[] divCount = new int[n + 1];
        for (int i = 1; i <= n; i += 2) {
            for (int j = 1; j <= i; j++) {
                if (i % j == 0) {
                    divCount[i]++;
                }
            }
        }

        int result = 0;
        for (int count : divCount) {
            if (count == 8) {
                result++;
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21204
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

int main()
{
  int i;
  string str;
  stack<int> sta;
  int a[20]={};

  cin>>str;
  rep(i,str.size()){
    if(str[i]=='B' && sta.size())
      sta.pop();
    else if(str[i]=='0')
      sta.push(0);
    else if(str[i]=='1')
      sta.push(1);
  }
  i=0;
  while(sta.size()){
    a[i]=sta.top();
    sta.pop();
    i++;
  }
  for(i--;i>=0;i--)
    cout<<a[i];
  cout<<endl;


}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<ll> prime_factorize(ll n) {
	vector<ll> l;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;

		while((n % i) == 0) { n /= i; }
		l.push_back(i);
	}

	if (n != 1) l.push_back(n);
	return l;
}

int main() {
	ll A, B;
	cin >> A >> B;
 
	ll d = gcd(A, B);
	
	vector<ll> p = prime_factorize(d);
	
	cout << (p.size() + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
orient = { ">": (1,0), "<": (-1,0), "^":(0,-1), "v":(0,1) }
while 1:
    H, W = map(int, raw_input().split())
    if H | W == 0: break
    passes = []
    route  = []
    for i in range(H):
        route.append([v for v in raw_input()])
    x, y = 0, 0
    passes.append((x, y))
    while 1:
        o = route[y][x]
        if o == ".":
            print x, y
            break
        (a, b) = orient[o]
        x, y = x + a, y + b
        t = map(lambda a : a==(x,y), passes)
        if any(t):
            print "LOOP"
            break
        passes.append((x, y))

Measured memory_bytes: 4344
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int main(){
  ll n;cin>>n;
  ll t,ans=1;
  rep(i,n){
    scanf("%lld",&t);
    ans=t*(ans/gcd(t,ans));
  }
  cout<<ans<<endl;    
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStillTBD solver = new AStillTBD();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStillTBD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String date = in.next();
            int mon = Integer.parseInt(date.substring(5, 7));
            int day = Integer.parseInt(date.substring(8));
            if (mon <= 4 && day <= 30)
                out.println("Heisei");
            else if (mon > 4)
                out.println("TBD");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 22612
implicit none
integer :: n
integer(8) :: k
integer(8) :: cnt(100000)
integer :: i,a,b

cnt(:) = 0

read *,n,k

do i = 1, n
   read *,a,b
   cnt(a) = cnt(a) + int(b,kind=8)
enddo

do i = 1, 100000
   k = k - cnt(i)
   if (k <= 0) then
      print '(i0)',i
      exit
   endif
enddo
end	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)

int main() {
    long long N;
    string S;
    cin >> N;
    cin >> S;

    long long ans = 0;
    rep(i, 1000) {
        string first = to_string(i / 100);
        string second = to_string(i % 100 / 10);
        string third = to_string(i % 10);

        vector<string> charvec{first, second, third};
        int matchCnt = 0;
        string next = charvec[matchCnt];
        rep(j, N) {
            if (S.substr(j, 1) == next) {
                matchCnt++;
                if (matchCnt == 3) {
                    ans++;
                    break;
                }
                next = charvec[matchCnt];
                continue;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    map<ll, ll> mp;
    for(int i = 0; i < N; i++){
        ll a; cin >>a;
        mp[a]++;
    }

    ll ans = 0;
    for(auto t: mp){
        if(t.first > t.second) ans += t.second;
        else ans+= (t.second - t.first);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
typedef pair< int , int > Pi;
  
/* 入力 */
int h, w, d, n; // h:縦 w:横 d:正方形の個数 n:Dマシン使用回数
char t[50][50]; // マップ
int r[10]; // r[i]:i番目の正方形の半径
int x[50], y[50], s[50]; // (x[i],y[i])に反応s[i]があった(小並感)
/* おわり */
  
int sx, sy; // Dの位置
bool go[50][50]; // いけたらtrue
bool used[50][50];
  
bool isin( int nx, int ny, int x, int y, int s){
  return ny >= y - s && ny <= y + s  && nx >= x - s  && nx <= x + s ;
}
bool isout( int nx, int ny, int x, int y, int s){
  return !isin( nx, ny, x, y, s);
}
  
void all_AND(){
  fill_n( *go, 50 * 50, true);
  for(int i = 0; i < n; i++){ //頑張ってＡＮＤやれば勝ちだろうけど
    if(s[i] == d){ //外にある
      for(int j = 0; j < h; j++){
        for(int k = 0; k < w; k++){
          if(isin( k, j, x[i], y[i], r[d - 1])) go[j][k] = false;
        }
      }
    }else if(s[i] == 0){ //中にある
      for(int j = 0; j < h; j++){
        for(int k = 0; k < w; k++){
          if(isout( k, j, x[i], y[i], r[0])) go[j][k] = false;
        }
      }
    }else{
      for(int j = 0; j < h; j++){
        for(int k = 0; k < w; k++){
          if(isout( k, j, x[i], y[i], r[s[i]])) go[j][k] = false;
          if(isin( k, j, x[i], y[i], r[s[i] - 1])) go[j][k] = false;
        }
      }
    }
  }
}
bool isover( int y, int x){
  return y < 0 || y >= h || x < 0 || x >= w;
}
void bfs(){
  fill_n( *used, 50 * 50, false);
  const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0, -1};
  queue< Pi > que;
  que.push( Pi( sy, sx));
  while(!que.empty()){
    Pi p = que.front();
    que.pop();
    if(used[p.first][p.second]++) continue;
    for(int i = 0; i < 4; i++){
      int ny = p.first + dy[i], nx = p.second + dx[i];
      if(!isover(ny,nx) && t[ny][nx] != '#') que.push( Pi( ny, nx));
    }
  }
  return;
}
  
int main(){
  cin >> h >> w >> d >> n;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> t[i][j];
      if(t[i][j] == 'D') sx = j, sy = i;
    }
  }
  for(int i = 0; i < d; i++){
    cin >> r[i];
  }
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i] >> s[i];
  }
  
  all_AND();
  int cnt = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(t[i][j] == '#') continue;
      cnt += go[i][j];
    }
  }
  if(cnt == 0) cout << "Broken\n";
  else{
    bfs();
    bool goflag = false;
    bool noflag = false;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        //   cout << go[i][j];
        if(t[i][j] != '#' && go[i][j]){
          if(used[i][j]) goflag = true;
          else noflag = true;
        }
      }
      //cout << endl;
    }
    if(goflag && noflag) cout << "Unknown" << endl;
    else if(goflag) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return(0);
}

Measured memory_bytes: 1228
from collections import Counter, defaultdict
from math import gcd
import bisect

N = int(input())
S = input()

char_to_indices = defaultdict(list)
for i, c in enumerate(S):
    char_to_indices[c].append(i)

total = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] == S[j]:
            continue
        for c in ('G', 'B', 'R'):
            if c not in (S[i], S[j]):
                search = c
                break
        indices = char_to_indices[search]
        idx = bisect.bisect_left(indices, j+1)
        if idx != len(indices):
            total += len(indices) - idx
        exact_idx = bisect.bisect_left(indices, j + (j - i))
        if exact_idx != len(indices) and indices[exact_idx] == (2 * j - i):
            total -= 1
print(total)




Measured memory_bytes: 72516
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i64 = read(&mut stdin_lock, &mut buf, b' ');
    let m: i64 = read(&mut stdin_lock, &mut buf, b'\n');

    let a = if n < m { n } else { m };
    let b = if n < m { m } else { n };
    let ans = if a == 1 && b == 1 {
        1
    } else if a == 1 {
        b - 2
    } else {
        (a - 2) * (b - 2)
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    ll n;
    cin>>n;
    ll a[n+2];
    ll b[n+1];
    b[0]=0;
    rep(i,n+1)cin>>a[i+1];
    rep(i,n)cin>>b[i+1];
    ll count=0;
    for(ll i=1;i<=n;i++)
    {
        if(a[i]<=b[i-1])
        {
            count+=a[i];
        }
        else if(a[i]<=b[i]+b[i-1])
        {
            count+=a[i];
            a[i]-=b[i-1];
            b[i]-=a[i];
        }
        else
        {
            count+=(b[i]+b[i-1]);
            b[i]=0;
        }
        
    }
    if(a[n+1]<=b[n])
    {
        count+=a[n+1];
    }
    else
    {
        count+=b[n];
    }

    cout<<count;
    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
int b[200001];
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n],i;
    for(i=0;i<n;i++){
        cin>>a[i];
        b[a[i]]++;
    }
    int c=0;
    sort(b,b+200001,greater<int>());
    for(int i=k;i<=n;i++){
        c+=b[i];
    }
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 1792
n=int(input())
x=list(map(int,input().split()))
s=sum(x)
mini=100000*10000
cand=s//n
sum=0
for i in x:
  sum+=((i-cand)**2)
mini=min(mini,sum)
cand+=1
sum=0
for i in x:
  sum+=((i-cand)**2)
mini=min(mini,sum)
cand-=2
sum=0
for i in x:
  sum+=((i-cand)**2)
mini=min(mini,sum)
print(mini)


Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
    long long int A[100100]={0};
        long long int maxmax[100100]={0};
int main(){
    long long int N;

    cin>>N;
    for(int i=0;i<=N;i++)cin>>A[i];
    if(N==0){
        if(A[0]==1)cout<<1<<endl;
        else cout<<-1<<endl;
        return 0;
    }

    for(int i=0;i<=N;i++){
        if(i==0){
            if(A[i]!=0){
                cout<<-1<<endl;
                return 0;
            }
            maxmax[i]=1;
        }
        else{

            if(maxmax[i-1]-A[i-1]<0){
                cout<<-1<<endl;
                return 0;
            }

            maxmax[i]=min((long long int)1000000000000000000,(maxmax[i-1]-A[i-1])*2);
        }
    }
    long long int ans[100100]={0};
    for(int i=N;0<=i;i--){
        if(i==N){
            if(A[i]>maxmax[i]){
                cout<<-1<<endl;
                return 0;
            }
            ans[i]=A[i];
        }
        else{
            ans[i]=min(ans[i+1]+A[i],maxmax[i]);
        }
    }
    long long int ansans=0;
    for(int i=0;i<=N;i++){

        if(i!=0){
            if((maxmax[i-1]-A[i-1])*2<ans[i]){
                ans[i]=(maxmax[i-1]-A[i-1])*2;
            }
        }

        ansans+=(long long int)ans[i];
    }
    cout<<ansans<<endl;
/*
    for(int i=0;i<=N;i++){
        printf("[%lld][%lld]\n",maxmax[i],ans[i]);
    }
*/


    return 0;
}


Measured memory_bytes: 5964
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] t = new int[n + 1];
		int[] x = new int[n + 1];
		int[] y = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			t[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		sc.close();

		for (int i = 1; i <= n; i++) {
			int d = Math.abs(x[i] - x[i - 1]) + Math.abs(y[i] - y[i - 1]);
			int dt = t[i] - t[i - 1];
			if (d > dt || (d - dt) % 2 != 0) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 92492
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mypow(ll a, ll b) {
    ll ret = 1;
    while (b--) {
        ret *= a;
    }
    return ret;
}

ll keta(ll a) {
    ll ret = 0;
    while (a) {
        ret++;
        a /= 10;
    }
    return ret;
}

int main() {
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while (x <= y) {
        x *= 2;
        ans++;
    }

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

Measured memory_bytes: 3596
from collections import deque
n,x = map(int, input().split())

if x == 1 or x == 2*n-1:
    print('No')
    exit()

if x == 2:
    ansl = []
    q = deque()
    for i in range(5,2*n):
        q.append(i)
    for i in range(0,2*n-1):
        if i == n-2: ansl.append(3)
        elif i == n-1: ansl.append(2)
        elif i == n: ansl.append(1)
        elif i == n+1: ansl.append(4)
        else: ansl.append(q.pop())
        

else:
    ansl = []
    q = deque()
    fix = [x-1,x,x+1,x-2]
    for i in range(1,2*n):
        if i not in fix:
            q.append(i)
    for i in range(0,2*n-1):
        if i == n-2: ansl.append(x-1)
        elif i == n-1: ansl.append(x)
        elif i == n: ansl.append(x+1)
        elif i == n+1: ansl.append(x-2)
        else: ansl.append(q.pop())

print('Yes')
print(*ansl)

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

int main(){
  int N;
  cin >> N;
  int max_ops = 100;
  for(int i=0;i<N;i++){
    int ai, count=0;
    cin >> ai;
    while(ai%2==0){
      count++;
      ai /= 2;
    }
    if(count < max_ops){
      max_ops = count;
    }
  }
  cout << max_ops << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants
#define INF 1e9

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin


// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin

  int a[5];

  rep(i,5) cin >> a[i];

  int k=in();

  rep(i,5){
    rep(j,i+1,5){
      dump(k,i,j,a[i],a[j],a[j]-a[i]);
      if(a[j]-a[i]>k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <random>
#include <complex>

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

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

    int l, r;
    cin >> l >> r;

    if (r - l + 1 >= 2019) { cout << 0 << '\n'; return 0; }

    LL ans = 2019;
    for (LL i = l; i < r; i++) {
        for (LL j = i + 1; j <= r; j++) {
            ans = min(ans, i * j % 2019);
        }
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		double[][] p=new double[4][2];
		double[] s=new double[2];
		int a,b,c;
		String t = "";
		String[] d = new String[8];
		while((t=bf.readLine())!=null){
			if(t.length()<=0)break;
			d=t.split(" ");
			for(int i=0;i<4;i++)for(int j=0;j<2;j++)p[i][j]=Double.parseDouble(d[i*2+j]);
			for(int i=0;i<3;i++){
				a=i;
				b=(a+1)%3;
				c=(b+1)%3;
				s[0]=(p[a][0]-p[b][0])*(p[c][1]-p[a][1])+(p[a][1]-p[b][1])*(p[a][0]-p[c][0]);
				s[1]=(p[a][0]-p[b][0])*(p[3][1]-p[a][1])+(p[a][1]-p[b][1])*(p[a][0]-p[3][0]);
				if(s[0]*s[1]<0.0){System.out.println("NO");break;}
				if(i==2)System.out.println("YES");
			}
		}
	}
}

Measured memory_bytes: 9820
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

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

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


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

    int i = 1;
    while (x > 0) {
        x -= i;
        i++;
    }
    cout << --i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ffor(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define rfor(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) ffor(i, 0, j, 1)
#define rrep(i, j) rfor(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
//#define f first
//#define s second
#define inf (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define trace1(x)                     cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)        cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
const double pi=acos(-1.0);
typedef pair<long long int,long long int> pii;
typedef long long ll;
typedef vector<long long int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<long long int,long long int> mpii;
typedef set<long long int> sei;
typedef multiset<long long int> msei;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n;
    ll a[n+1];
    for(i=1;i<=n;i++)
    cin>>a[i];
    ll dp[n+1]={0};
    for(i=2;i<=n;i++)
    {
        if(i==2)
        dp[i]=abs(a[1]-a[2]);
        else
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	map<string,bool>mp;
  int n;
  cin>>n;
  char old='@';
  rep(i,n){
    string s;
    cin>>s;
    if (mp[s] or (old!='@' and s[0]!=old)) {cout<<"No"<<endl;return 0;}
    mp[s]=true;
    old=s[s.size()-1];
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

using namespace std;

typedef struct{
    int x,y;
}Point;

int main()
{

    int w,h,x,y,r;
    Point p1,p2;

    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);

    p1.x=min(0,w);
    p1.y=min(0,h);
    p2.x=max(0,w);
    p2.y=max(0,h);

    bool flag=true;

    p1.x+=r;
    p1.y+=r;
    p2.x-=r;
    p2.y-=r;

    if(x>p2.x||x<p1.x||y>p2.y||y<p1.y)
    {
        flag=false;
    }

    if(flag)
    {
        printf("Yes\n");
    }else
    {
        printf("No\n");
    }

    return 0;
}



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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  vector<bool> vec(26);
  rep(i,n){
      vec[s[i]-'a']=true;

  }
  string ans="None";
  rep(i,26){
      if(vec[i]==false){
          ans='a'+i;
          break;
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3704
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 
bool second_greater(const pll& left, const pll& right) {
    return left.second > right.second;
}
#endif


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

    int N; cin >> N;
    vi V(N); REP(i, N) cin >> V[i];

    map<int, int> odd, even;
    REP(i, N) {
        if (i % 2 == 0) odd[V[i]]++;
        else even[V[i]]++;
    }

    vector<pii> oddH;
    for(auto p : odd) oddH.push_back(pii(p.first, p.second));
    vector<pii> evenH;
    for(auto p : even) evenH.push_back(pii(p.first, p.second));

    sort(oddH.begin(), oddH.end(), second_greater);
    sort(evenH.begin(), evenH.end(), second_greater);

    int ans = 0;
    if (odd.size() == 1 && even.size() == 1) {
        ans = V[0]==V[1] ? N / 2 : 0;
    } else {
        if (oddH[0].first != evenH[0].first) {
            ans = (N / 2 - oddH[0].second) + (N / 2 - evenH[0].second);
        } else {
            if (oddH[0].second + evenH[1].second >= oddH[1].second + evenH[0].second) {
                ans = (N / 2 - oddH[0].second) + (N / 2 - evenH[1].second);
            } else {
                ans = (N / 2 - oddH[1].second) + (N / 2 - evenH[0].second);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6524
#include<stdio.h>
int main(){
  int a[4][4];
  int i,j,k,check=0;
  for(i=0;i<3;i++)
    for(j=0;j<3;j++)
      scanf("%d",&a[i][j]);
  int n;
  scanf("%d",&n);
  int b[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
    for(j=0;j<3;j++)
      for(k=0;k<3;k++)
        if(b[i]==a[j][k])
          a[j][k]=0;
  }
  for(i=0;i<3;i++)
    if(((a[i][0]==a[i][1])&&(a[i][1]==a[i][2]))||((a[0][i]==a[1][i])&&(a[1][i]==a[2][i])))
      check=1;
  if(a[0][0]==a[1][1] && a[1][1]==a[2][2])
    check=1;
  if(a[0][2]==a[1][1] && a[1][1]==a[2][0])
    check=1;
  if(check==1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
  
  
  

Measured memory_bytes: 128
K=int(input())
A,B=map(int, input().split())

d_u=int(B/K)
r_u=B%K
d_l=int(A/K)
r_l=A%K

if (r_u*r_l == 0) or not(d_u == d_l):
  print("OK")
else:
  print("NG")

Measured memory_bytes: 9184
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007


int main() {
	LL n, k;
	cin >> n >> k;
	LL ret = 0;
	if (k == 0) {
		cout << n*n << endl;
		return 0;
	}
	FOR(b, k + 1, n+1) {
		LL r = (n+1) / b;
		ret += r * (b - k);
		ret += max(n - (b*r) - k +1, 0LL);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int N,M;
	scanf("%d%d",&N,&M);
	vector<int>target(M);
	for(int i=0;i<M;i++)scanf("%d",&target[i]),target[i]--;
	vector<int>points(N);
	for(int i=0;i<M;i++){
		int diff=0;
		for(int j=0;j<N;j++){
			int x;
			scanf("%d",&x);x--;
			if(x!=target[i])diff++;
			else points[j]++;
		}
		points[target[i]]+=diff;
	}
	for(int i=0;i<N;i++)printf("%d\n",points[i]);
}

Measured memory_bytes: 1032
ABCD = list(map(int,input()))

flag = False
for i in range(2**4):
    state = []
    for j in range(4):
        state.append((i >> j) & 1)
    
    ans = 0
    for i,s in enumerate(state):
        if s:
            ans += ABCD[i]
        else:
            ans -= ABCD[i]
    
    if ans == 7:
        ans = ""
        for i,s in enumerate(state):
            if s:
                ans += "+"
            else:
                ans += "-"
            ans += str(ABCD[i])
        if ans[0] == "+" or ans[:2] == "-0":
            ans = ans[1:]
        print(ans+"=7")
        exit()

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


int main() {
	char ch;
	cin >> ch;

	if (ch == 'a' || ch == 'i' || ch == 'u' || ch == 'e' || ch == 'o') cout << "vowel" << endl;
	else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(defun print-swap (a b)
  (when a
	(princ (car a))
	(print-swap b (cdr a))))

(labels ((read-list ()
					(concatenate 'list (read-line))))
  (let ((a (read-list)) (b (read-list)))
	(print-swap a b)))


Measured memory_bytes: 6076
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    mut a:String,
    b:String,
    c:String,
    }
    let a=a.chars().collect_vec();
    let b=b.chars().collect_vec();
    let c=c.chars().collect_vec();
    println!("{}{}{}",a[0],b[1],c[2])
}

Measured memory_bytes: 2092
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
const int maxn = 3030;
using vi = vector<int>;
int n, a[maxn];
vi g[maxn];
int dfs(int v, int p) {
	int ok = 0;
	for(auto &i : g[v]) {
		if(i == p) continue;
		if(!dfs(i, v)) ok |= a[v] > a[i];
	}
	return ok;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
	}
	for(int i = 1; i <= n; i++) {
		if(dfs(i, i)) cout << i << " ";
	}
}


Measured memory_bytes: 640