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

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

    int n, m;
    cin >> n >> m;
    vector<long long> X(m);
    for(int i = 0; i < m; i++){
        cin >> X[i];
    }

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

    vector<long long> A(m, 0);

    for(int i = 1; i < m; i++){
        A[i] = X[i] - X[i - 1];
    }

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

    long long ans = 0;
    for(int i = 0; i < m - n + 1; i++){
        ans += A[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        if (X >= 30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

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


int main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	
	int res = 0;
	
	for(int i = 0; i < n;i++){
		if(i<k) res+=x;
		else res+=y;
	}
	
	cout<<res;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,k,s;
	cin >> n >> k >> s;

	REP(i,n){
		if(i<k) cout << s << " ";
		else if(s<1e9) cout << 1000000000 << " ";
		else cout << 1000000000-1 << " ";
		
	}
	return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++){
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    int n = N / 2;
    cout << d.at(n) - d.at(n-1) << endl; 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    set<string> st;
    vector<string> ss; 
    rep(i, 0, n){
        rep(j, i, n){
            string tmp = s.substr(i, j - i + 1);
            if(ss.size() >= k){
                string now = ss[k - 1];
                if(now < tmp){
                    break;
                }
            }
            if(st.count(tmp)) continue;
            ss.push_back(tmp);
            st.insert(tmp);
            sort(all(ss));
            if(ss.size() > k) ss.pop_back();
        }
    }
    cout << ss[k - 1] << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> as(N);
  F0R(i, N) {
    cin >> as[i].first >> as[i].second;
  }
  sort(rrng(as), [](const pair<int, int>& l, const pair<int, int>& r) {
    return l.first < r.first;
  });
  i64 r = 0;
  while (M) {
    int a = min(M, as.back().second);
    M -= a;
    r += (i64)a * as.back().first;
    as.resize(as.size() - 1);
  }
  cout << r;
}
#endif


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(1){
        C-=B;
        if(C<=0){
            cout << "Yes" <<endl;
            break;
        }A-=D;
        if(A<=0){
            cout << "No" <<endl;
            break;
        }
        
    }
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long LL;
const int MAxn = 2e5 + 5;
const int MA_N = 5e3 + 5;

int vis[MAxn] = {0};

int main(){
	int n, m;
	cin >> n >> m;
	if(n >= m) cout << n - m << endl;
	else cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [int(v) for v in input().split()]
c = [0,abs(h[0]-h[1])]

for i in range(1,n-1):
  cost1 = c[i-1] + abs(h[i-1] - h[i+1])
  cost2 = c[i] + abs(h[i]-h[i+1])
  c.append(min(cost1,cost2))

print(c[-1])

Measured memory_bytes: 13780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<P,vector<P>,greater<P>> v;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v.push(make_pair(a,b));
    }
    priority_queue <int> b;
    ll ans=0;
    rep(i,m+1){
        while(!v.empty()){
            auto f = v.top();
            if(f.first<=i){
                b.push(f.second);
                v.pop();
            }
            else break;
        }
        if(!b.empty()){
            int now = b.top();b.pop();
            ans += now;
        }
    }
    cout << ans << endl;
    return 0;
}

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

inline bool is_number(char a) {
  return '0' <= a && a <= '9';
}

int main() {
  int A, B;
  cin >> A >> B;
  A--;
  B--;
  string S;  
  cin >> S;
  for(int i = 0; i < S.size(); ++i) {
    if(i <= A || A + 1 < i) {
      if(!is_number(S[i])) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if(S[i] != '-') {
        cout << "No" << endl;
        return 0;
      } 
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
program prob6
    implicit none
    integer :: N
    integer, allocatable :: a(:)
    integer :: i, j
    integer :: ans, tmp
    read(*,*) N
    allocate(a(N))
    
    read(*,*) a
    
    ans = 4000005
    do i = -100, 100
        tmp = 0
        do j = 1, N
            tmp = tmp + (a(j) - i) * (a(j) - i)
        end do
        ans = min(tmp, ans)
    end do
    write(*,*) ans
    
    deallocate(a)
 
    stop
contains
end program prob6

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

using namespace std;

const int N = 1e5;

int n, t, w[100], v[100];
long long dp[N + 1], ans;

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

	cin >> n >> t;
	for (int i = 0; i < n; ++i)
		scanf("%d%d", w + i, v + i);

	for (int i = 0; i < n; ++i)
		for (int weight_taken = t - w[i]; weight_taken >= 0; --weight_taken)
			dp[weight_taken + w[i]] = max(dp[weight_taken + w[i]], dp[weight_taken] + v[i]);
	
	for (int i = 0; i <= t; ++i)
		ans = max(ans, dp[i]);

	cout << ans << endl;
}


Measured memory_bytes: 4444
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	double cost;
	if(a<=5)
		cost=0;
	else if(a>=6&&a<=12)
		cost=b*0.5;
	else if(a>=13)
		cost=b;
	cout<<cost<<endl;
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp
q = gets.to_i
queries = q.times.map { gets.split }

s1 = ''
s2 = s
reversed = false

queries.each do |t, f, c|
  if t.to_i == 1
    reversed = !reversed
    next
  end

  if (f.to_i == 1 && reversed) || (f.to_i == 2 && !reversed)
    s2 << c
  else
    s1 << c
  end
end

if reversed
  puts s2.reverse! << s1
else
  puts s1.reverse! << s2
end


Measured memory_bytes: 43132
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;


void dfs(int v,vector<bool> &seen, int &res) 
{
	bool end = true;
	for (int i = 0; i < seen.size(); i++)
	{
		if (!seen[i] && i != v)
		{
			end = false;
		}
	}
	if (end)
	{
		res++;
		return;
	}

	seen[v] = true;
	for (auto nv : G[v])
	{
		if (seen[nv])
		{
			continue;
		}
		dfs(nv, seen, res);
	}
		seen[v] = false;
	


}


int main()
{
	int N, M; cin >> N >> M;
	G.assign(N, vector<int>());
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<bool> seen(N, false);
	int res = 0;
	dfs(0, seen, res);
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, m, count = 0;
	int s[100000], t[50000];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}

	int value, left, right, temp;
	for (int i = 0; i < m; i++) {
		value = t[i];
		left = 0;
		right = n;
		while (1) {
			temp = (left + right) / 2;

			if (s[temp] == value) {
				count++;
				break;
			}
			else if (s[temp] < value) {
				left = temp + 1;
			}
			else {
				right = temp - 1;
			}

			if (right > n || left < 0 || left > right) {
				break;
			}
		}
	}
	cout << count << endl;

	return 0;
}

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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

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

   int N,A,B;
   cin>>N>>A>>B;

   if(N*A<B)cout<<N*A;
   else cout<<B;

   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 10000

int prime(int);

int main()
{
  int A[N], i, p, number, count=0;
  scanf("%d", &number);
  for( i=0 ; i<number ; i++ ){
    scanf("%d", &A[i]);
    p = prime(A[i]);
    if( p==1 ) count++;
  }

  printf("%d\n", count);
  return 0;
}
int prime(int a)
{
  int i;
  if( a==2 ) return 1;
  if( a<2 || a%2==0 ) return 0;
  i = 3;
  while( i<=sqrt(a) ){
    if( a%i==0 ) return 0;
    i = i+2;
  }
  return 1;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
#define ll long long int
#define inf 3e18+1
#define all(v) (v).begin(),(v).end() 
#define N 200005
#define F first 
#define S second 
using namespace std;
ll mod=1e9+7;
// ll parent[N];  
// ll size[N]; 
// ll find(ll i){
//     if(parent[i]!=i) {
//         parent[i]=find(parent[i]);
//     }
//     return parent[i];
// }
// void Union(ll x,ll y){
//     ll a=find(x);
//     ll b=find(y);
//     if(a==b) return;
//     parent[a]=parent[b];
// }
int main()
{
    // added the two lines below 
    ios_base::sync_with_stdio (false); 
    cin.tie(NULL);
    cout.tie(0);    
  
    ll test=1;//cin>>test;
    while(test--){
        ll n,m;
        cin>>n>>m;
        char a[n][m];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                cin>>a[i][j];
            }
        }
        ll dp[n][m];
        memset(dp,0,sizeof(dp));
        for(int i=0;i<m;i++){
            if(a[0][i]=='#') break;
            dp[0][i]=1;
        }
        for(int i=0;i<n;i++){
            if(a[i][0]=='#') break;
            dp[i][0]=1;
        }
        for(int i=1;i<n;i++){
            for(int j=1;j<m;j++){
                if(a[i][j]!='#'){
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
                }
            }
        }
        cout<<dp[n-1][m-1];



        
    }
    return 0;
    
}




Measured memory_bytes: 12344
n = int(input())
d_list = list(map(int,input().split()))
d_list.sort()
n_half = n//2
left = d_list[n_half-1]+1
right = d_list[n_half]
dum = right-left
if dum < 0:
    print(0)
else:
    print(dum+1)

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

#define mod 1'000'000'007
typedef long long ll;

template <typename T>
void deb(initializer_list<T> l)
{
    for (auto &e : l)
        cout << e << ' ';
    cout << '\n';
}

int solve(string s)
{
    int cnt = 0;
    for (int i = 1; i < s.length(); ++i)
    {
        if (s[i] == s[i - 1])
        {
            s[i] = s[i - 1] == '0' ? '1' : '0';
            ++cnt;
        }
    }
    return cnt;
}

void solve()
{
    string s;
    cin >> s;
    string t = s;
    t[0] = s[0] == '0' ? '1' : '0';
    cout << min(solve(s), 1 + solve(t)) << '\n';
}

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

    int t { 1 };
//    cin >> t;
    while (t--)
        solve();

    return 0;
}


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll n, a, b; cin >> n >> a >> b;
  if (a > b) swap(a, b);
  if ((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;
  }else {
    ll m = min(a - 1, n - b);
    cout << m + 1 + (b - a - 1) / 2 << endl;
  }

  return 0;
}



Measured memory_bytes: 3652
import sys

# import bisect
# map(int, sys.stdin.read().split())
from collections import Counter



def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = []
    for i in range(N):
        s =list(input())
        s.sort()
        s = "".join(s)
        S.append(s)

    C  = Counter(S)
    ans =0
    for key,value in C.items():
        ans +=value*(value-1)/2

    print(int(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 98680
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n;
const int inf = 1000000009;
int a[110];

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n;
    Forn(i, n) a[i] = inf;
    Forn(i, n-1)
    {
        int x;
        cin >> x;
        a[i] = min(a[i], x);
        a[i+1] = min(a[i+1], x);
    }
    int ans = 0;
    Forn(i, n) ans += a[i];
    cout << ans << endl;
}


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

using namespace std;

bool check(const vector<int>& a){
    const int N = a.size();
    int m = *min_element(a.begin(), a.end());
    int M = *max_element(a.begin(), a.end());
    if(M - m > 1) return false;
    if(M == m){
        return M == N-1 || 2*M <= N;
    }
    auto c = count_if(a.begin(), a.end(), [&](int t){ return t == m; });
    return c <= m && c + 2 * (M-c) <= N;
}

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(auto& t : a) cin >> t;
    cout << (check(a) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 768
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main ()
{
    int N,M;
    cin >> N >> M;
    vector<int> X;
    vector<int> W;
    int temp;
    int Length;
    int output=0;
    for(int i=0;i<M;i++){
        cin >> temp;
        X.push_back(temp);
    }
    sort(X.begin(),X.end());
    for(int i=0;i<M-1;i++){
        W.push_back(X.at(i+1)-X.at(i));
    }
    sort(W.begin(),W.end());
    Length=X.back()-X.front();
    output=Length;
    if(N>=M){
        output=0;
    }else{
        output=Length;
        for(int i=0;i<N-1;i++){
            output-=W.at(M-2-i);    
        }
    }
    
    cout << output << endl;
    return 0;
}



Measured memory_bytes: 1400
#include <stdio.h>

int solve(int A[], int array_size, int index, int sum)
{
    if(index == array_size){
        if(sum == 0) return 1;
        else return 0;
    }
    else if(sum == 0) return 1;
    else if(sum < 0) return 0;
    else return
        solve(A, array_size, index+1, sum-A[index]) 
        || solve(A, array_size, index+1, sum); 
}

int main(){
    int n,q;
    scanf("%d", &n);
    int A[25];
    for(int i=0; i<n; i++){
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for(int i=0; i<q; i++){
        int m;
        scanf("%d", &m);
        int result = solve(A, n, 0, m);
        if(result == 1) printf("yes\n");
        else printf("no\n");
    }
}



Measured memory_bytes: 2104
#include <stdio.h>

int main(){
  int i,n;
  int fib[45];
  scanf("%d", &n);
  for(i=0; i<=n; i++){
    if(i <= 1) fib[i] = 1;
    else fib[i] = fib[i-1] + fib[i-2];
  }
  printf("%d\n", fib[n]);
  return 0;
}



Measured memory_bytes: 2112
<?php
fscanf(STDIN, "%d %d",$n,$k);
$v = fgets(STDIN);
$array = explode(' ',$v);

//初期化
$lval = array();
$ans = 0;

//0スタートのために両端に0追加
array_push($array, 0);
array_unshift($array, 0);

#左0個からスタート
for ($l=0;$l<=$k;$l++){
	#右から取る配列の初期化
	$rval = array();
	#左から$l番目を取得
	$lval[] = $array[$l];
	#右0個からスタート
	for ($r=0;$r+$l<=$k;$r++){
		//試行回数が宝石の数を超えた段階でbreak
		if ($l+$r>$n){
			break;
		}
		#右からr番目を取得
		$rval[] = $array[$n-$r+1];
		
		#宝石の価値の和
		$sumval = array_merge($lval,$rval);
		$sum = array_sum($sumval);
		#宝石ソート
		sort($sumval);
		
		#負の宝石を詰めなおす
		for ($i=0;$i < min($k-$l-$r,$l+$r);$i++){
			if ($sumval[$i]<0){
				$sum -= $sumval[$i];
			}
		}
		#最大値
		$ans = max($ans,$sum);
	}
}
echo $ans;


Measured memory_bytes: 3576
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<vector>
#include<map>

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

using namespace std;
typedef long long ll;

int main(void)
{
	string s;
	cin >> s;
	int count1, count2;
	int deg;
	int num=0;
	vector<char> ans;
	rep(i, s.size()) {
		if (s[i] == 'A') {
			if (num == 0) {
				count1 = i;
				num++;
			}
		}

		if (s[i] == 'Z') {
				count2 = i+1;
		}

	}
	deg = count2 - count1;
	cout << deg;
	
	cout << endl;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s;
	cin>>s;
	rep(i,3){
		if(s[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	cout<<"No"<<endl;
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL N, M;
    cin >> N >> M;
    if(N == 1 || M == 1) {
        if(N == 1 && M == 1) cout << 1 << endl;
        else cout << max(N, M) - 2 << endl;

    } else {
        cout << (N - 2) * (M - 2) << endl;

    }
    return 0;
}



Measured memory_bytes: 256
n,k = map(int, input().split())
L = [list(map(int, input().split())) for i in range(2*k)]
A = []
for i in range(k):
  A = A + L[2*i + 1]
ans = 0
for i in range(n):
  if i+1 not in A:
    ans += 1
    
print(ans)


Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n, m;
  cin >> n >> m;
  int b[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int a; cin >> a;
      b[i][j] = a;
    }
  }
  int c[m];
  for (int i = 0; i < m; i++) {
    int a; cin >> a;
    c[i] = a;
  }

  for (int i = 0; i < n; i++) { 
    int ans = 0;
    for (int j = 0; j < m; j++) {
      ans += b[i][j] * c[j];
    }
    cout << ans << endl;
  }
}


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

int main()
{
	int min = 1000000, max =-1000000, n, tmp, i;
	long sum = 0;
	
	cin >> n;

	
	for(i = 0; i < n; i++){
		cin >> tmp;

		if(tmp < min){
			min = tmp;
		}
		if(tmp > max){
			max = tmp;
		}
		sum += tmp;
	}
	cout << min << " " << max << " " << sum << endl;
		
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 5005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n; char ar[N]; ll dp[N][N];
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	cin>>ar;

	ll mx=0;
	for(i=n-1;i>=0;i--){
		for(j=i+1;j<n;j++){
			if(ar[i]==ar[j]){
				dp[i][j]=dp[i+1][j+1]+1;
				mx=max(mx,min(dp[i][j],j-i));
			}
		}
	}
	cout<<mx;
	return 0;
}

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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("b.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    double a[100];

    cin >> n;

    rep(i, n)
    {
        cin >> a[i];
    }

    double ans = 0;
    rep(i, n)
    {
        ans += 1 / a[i];
    }
    cout << 1.0 / ans;

    return 0;
}


Measured memory_bytes: 256
while True:
    n, m = map(int, input().split())
    if n == 0: break
    r = int(input())
    records = []
    for i in range(r):
        records.append(list(map(int, input().split())))
    q = int(input())
    queries = []
    for i in range(q):
        queries.append(list(map(int, input().split())))
    #print(records,queries)
    for q in queries:
        st = q[2]
        rs = list(filter(lambda x: x[2] == st, records))
        pcs = [[0,0] for i in range(n)]
        ls = []
        for r in rs:
            pcs[r[1]-1][r[3]] = r[0]
            if r[3] == 0:
                ls.append(pcs[r[1]-1])
                pcs[r[1]-1] = [0,0]
        if not ls: 
            print(0)
            continue
        ls.sort(key=lambda x:x[1])
        uses = []
        start, end = ls[0][1], ls[0][0]
        for v in ls[1:]:
            if v[0] < end: # subset
                continue
            elif v[1] <= end:
                end = v[0]
            elif v[1] > end:
                uses.append((start,end))
                start, end = v[1], v[0]
        uses.append((start,end))
        ans = 0
        for u in uses:
            for i in range(u[0], u[1]):
                if i >= q[0] and i < q[1]:
                    ans += 1
        print(ans)

Measured memory_bytes: 6956
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

// (y, x)
using P = pair<int, int>;

int h, w;
vector<string> g;

vector<vector<int>> bfs(P s) {
    vector<vector<int>> d(h, vector<int>(w, INF));
    d[s.first][s.second] = 0;
    queue<P> que;
    que.push(s);
    while(que.size()) {
        P now = que.front();
        que.pop();
        if(d[now.first][now.second] == INF) {
            continue;
        }
        for(int i = 0; i < 4; i++) {
            int ni = now.first + dy[i];
            int nj = now.second + dx[i];
            if(0 <= ni && ni < h && 0 <= nj && nj < w && g[ni][nj] != '#') {
                if(d[ni][nj] > d[now.first][now.second] + 1) {
                    d[ni][nj] = d[now.first][now.second] + 1;
                    que.push(P(ni, nj));
                }
            }
        }
    }
    return d;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    g.resize(h);
    for(int i = 0; i < h; i++) {
        cin >> g[i];
    }
    int ans = -INF;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(g[i][j] == '.') {
                auto d = bfs(P(i, j));
                int res = -INF;
                for(int ii = 0; ii < h; ii++) {
                    for(int jj = 0; jj < w; jj++) {
                        if(d[ii][jj] == INF) {
                            continue;
                        }
                        chmax(res, d[ii][jj]);
                    }
                }
                chmax(ans, res);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val d = Array(N) { sc.next().toInt() }.sorted().toTypedArray()
        pw.println(d[N / 2] - d[N / 2 - 1])
    }
}


Measured memory_bytes: 56512
import sys
input = sys.stdin.readline

n = int(input())
l = []
m1 = 0
m2 = 0
for i in range(n):
    num = int(input())
    l.append(num)
    if num > m1:
        m1 = num
    elif num > m2:
        m2 = num

for i in range(n):
    if l[i] != m1:
        print(m1)
    else:
        print(m2)


Measured memory_bytes: 12512
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int sum = 0;
int h[100];
int N;

vector<pair<int, int>> find(int left, int right) {
    vector<pair<int, int>> v;
    int l, r; l = r = 0;
    bool set_left = false;
    for(int i = left; i <= right; i++) {
        // 左をきめる
        if(!set_left) {
            if(h[i] != 0) {
                set_left = true;
                l = i;
            }
        // 右を決める
        } else {
            if(i == right || h[i] == 0) {
                set_left = false;
                r = i;
            }
        }
        if(l < r) {
            v.push_back(make_pair(l, r));
            // cout << l << ", " << r << endl;
        }
    }

    return v;
}

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

    queue<pair<int, int>> que;
    que.push(make_pair(0, N));

    while(que.size()) {
        auto p = que.front(); que.pop();
        int left = p.first;
        int right = p.second;

        // 島をみつける
        auto v = find(left, right);
        // cout << "found " << v.size() << " number;" << endl;

        while(v.size() > 0) {
        // あれば各島に対して
            // cout << v[0].first << ", " << v[0].second << endl;
            // queに島の座標を追加
            auto pair = v.back(); v.pop_back();
            que.push(pair);
            // 最小の数をsumにadd
            // cout << pair.first << ", " << pair.second << endl;
            int m = *min_element(h+pair.first, h+pair.second);
            // cout << "min: " << m << endl;

            sum += m;
            // 島の大きさを最小の数でへらす
            for(int i = pair.first; i < pair.second; i++) { h[i] -= m; }
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
import itertools
n,m=list(map(int,input().split()))
L=[list(map(int,input().split()))[1:] for i in range(m)]
P=list(map(int,input().split()))
cnt=0

for i in range(1<<n):
  k=1
  for p,ll in zip(P,L):
    k*=(sum([int(bin(i)[2:].zfill(n)[l-1]) for l in ll])%2==p)
  cnt+=k
print(cnt)

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

int main() {
    int n;
    int num[105];
    for(int i=0;i<101;i++)num[i]=0;
    cin >> n;

    for(int i=0;i<n;i++){
        int d;
        cin >> d;
        num[d]++;
    }
    int ans = 0;
    for(int i=0;i<101;i++)if(num[i]>0)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;

    if(S.compare("Sunny") == 0){
        cout << "Cloudy" << endl;
    }
    else if(S.compare("Cloudy") == 0){
        cout << "Rainy" << endl;
    }
    else{
        cout << "Sunny" << endl;
    }
    
    return 0;
}

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

using namespace std;

int n,k;

int findTrackMax(int stackWeight[]){
	int max = 0;
	for(int i = 0; i < k; i++){
		if(max < stackWeight[i]){
			max = stackWeight[i];
		}
	}
	return max;
}

bool pileW(int w[],int p){

	int trial[k],index_w=0,index_track=0,tmp=0;

	for(int i = 0; i < k; i++){
		trial[i] = 0;
	}

	while(true){
		if(tmp + w[index_w] <= p){
			tmp += w[index_w++];
		}else{
			trial[index_track++] += tmp;
			tmp = 0;
		}

		if(index_track == k-1){
			for(int i = index_w; i < n; i++){
				trial[index_track] += w[i];
			}
			return (trial[index_track] <= p);
		}else if(index_w == n-1){
			return (w[index_w] <= p);
		}
	}
}

int main(){

	scanf("%d %d",&n,&k);
	int w[n],guessPMax[k];

	for(int i = 0; i < n; i++){
		scanf("%d",&w[i]);
	}
	for(int i = 0; i < k; i++){
		guessPMax[i] = 0;
	}

	if(k == 1){
		int onetrack;
		for(int i = 0; i < n; i++){
			onetrack += w[i];
		}
		printf("%d\n",onetrack);
	}else{

		int p_trial_number;
		if(n >= k){
			if(n%2 == 0 && k%2 == 0){
				p_trial_number = n/k;
			}else{
				p_trial_number = n/k + 1;
			}
		}else{
			p_trial_number = 1;
		}

		int k_trial = 0,n_trial = 0;
		while(true){
			for(int i = 0; (i < p_trial_number && n_trial < n-1);i++){
				guessPMax[k_trial] += w[n_trial++];
			}
			k_trial++;
			if(k_trial == k-1){
				for(int i = n_trial;i < n;i++){
					guessPMax[k_trial] += w[i];
				}
				break;
			}else if(n_trial == n-1){
				guessPMax[k-1] += w[n_trial];
				break;
			}
		}

		int right = findTrackMax(guessPMax),left = n/k,m;

		if(right - left == 1){
			if(pileW(w,left)){
				right = left;
			}
		}else{
			while(right - left > 1){
				m = (left + right)/2;
				if(pileW(w,m)){
					right = m;
				}else{
					left = m;
				}
			}
		}
		printf("%d\n",right);
	}
}

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


int main(){
    int N;
    cin >> N;
    map<int, int> p;
    int num;
    for (int i = 0; i < N; i++)
    {
        cin >> num;
        p[num]++;
    }
    int ans=0;
    for(auto x:p) {
        if(x.second % 2) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());
            var x = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var sum = 0;
            for (int i = 0; i < n; i++)
            {
                var val = Math.Min(Math.Abs(x[i] - k), Math.Abs(k - x[i]));
                sum += Math.Min(val, x[i]);
            }
            Console.WriteLine(sum * 2);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 1 << 30;

signed main() {
    int N;
    cin >> N;
    string left, right;
    {
        string S;
        cin >> S;
        left = S.substr(0, N);
        right = S.substr(N, N);
    }
    map<pair<string, string>, ll> count;
    for (int i = 0; i < (1 << N); i++) {
        string red, blue;
        // generate
        for (int j = 0; j < N; j++) {
            if ((i >> j)&1) red += left[j];
            else blue += left[j];
        }
        count[{red, blue}]++;
    }
    ll ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        string red, blue;
        // generate
        for (int j = 0; j < N; j++) {
            if ((i >> j)&1) red += right[j];
            else blue += right[j];
        }
        reverse(blue.begin(), blue.end());
        reverse(red.begin(), red.end());
        ans += count[{blue, red}];
    }
    cout << ans << endl;
}



Measured memory_bytes: 87040
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define ll long long
using namespace std;
const int N=5e3+10;
const ll mod=1e9+7;
int n,len;
ll dp[N][N];
char ss[N];
inline int mx(int a,int b){return a>b ? a : b;}
inline ll powe(ll aa,ll tt){
	ll ans=1;
	for(ll i=tt;i;i>>=1, aa=aa*aa%mod) if(i&1) (ans*=aa)%=mod;
	return ans;
}
int main()
{
//	freopen("Unhappy Hacking.in","r",stdin);
	scanf("%d%s",&n,ss);
	len=strlen(ss);
	dp[0][0]=1;
	for(RG int i=0;i<=n;i++)
	 for(RG int j=0;j<=i;j++)
	 {
		(dp[i+1][j+1]+=2*dp[i][j])%=mod;
		(dp[i+1][mx(0,j-1)]+=dp[i][j])%=mod;
	 }
	printf("%lld",dp[n][len]*powe(powe(2,len),mod-2)%mod);
	return 0;
}

Measured memory_bytes: 194304
#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 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll d = c - a - b;
  if(d > 0 && 4 * a * b < d * d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

const int INF = 1e9;
vector<int> p(8), a(8);

template <typename T> string tostr(const T& t) {
    ostringstream os; os<<t; return os.str();
}

void shift(vector<int>& a) {
    int sz = a.size();
    for (int i = sz - 1; i > 0; i--)
        swap(a[i], a[i - 1]);
}

int main() {
    for (int i = 0; i < 8; i++) {
        if (i % 2) a[i] = 1;
        else if (i <= 2) a[i] = 4;
        else a[i] = 2;
    }

    while (scanf("%d", &p[0]) != EOF) {
        for (int i = 1; i < 8; i++)
            scanf("%d", &p[i]);
        
        int min = INF;
        vector<int> ans(8);
        for (int i = 0; i < 8; i++) {
            shift(a);

            int sum = 0;
            for (int j = 0; j < 8; j++) {
                sum += max(p[j] - a[j], 0);
            }

            if (sum < min) ans = a, min = sum;
            else if (sum == min) {
                string ss = "", sa = "";
                for (int k = 0; k < 8; k++) {
                    ss += tostr(a[k]);
                    sa += tostr(ans[k]);
                }
                if (ss < sa) ans = a, min = sum;
            }
        }

        for (int i = 0; i < 8; i++) {
            if (i) cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3184
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

input_s = int(input())

h = int(input_s//3600)
m = int((input_s%3600)/60)
s = int(input_s%60)

print(h, ":", m, ":", s, sep="")





Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
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;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  vector<int> seat(N+1, -1);
  // 0: Male, 1: Female
  cout <<0 <<endl;
  fflush(stdout);
  string s; cin >>s;
  if (s == "Vacant") return 0;
  seat[0] = s == "Male" ? 0 : 1;
  seat[N] = s == "Male" ? 0 : 1;
  int ai = 0, bi = N;
  for (int qq=1; qq<20; qq++){
    int ci = (ai+bi)/2;
    cout <<ci <<endl;
    fflush(stdout);
    cin >>s;
    if (s == "Vacant") return 0;
    seat[ci] = s == "Male" ? 0 : 1;
    if ((seat[ai]^seat[ci]) != abs((ai-ci)%2)){
      bi = ci;
    }else{
      ai = ci;
    }
  }
}


Measured memory_bytes: 1236
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	x := getNextInt(scanner)
	y := getNextInt(scanner)

	turtle := x

	for bird := 0; bird < x+1; bird++ {
		if 4 * turtle + 2 * bird == y {
			fmt.Println("Yes")
			return
		}
		turtle--
	}
	fmt.Println("No")
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int H,W;
  cin>>H>>W;
  vector<string> s(H);
  rep(i,H) cin>>s[i];
  vector<vector<int>> dp(H,vector<int>(W,INFint));
  if (s[0][0] == '#') dp[0][0] = 1;
  else dp[0][0] = 0;
  for(int i(0);i<H;i++){
    for (int j(0);j<W;j++){
      if (i == 0 && j == 0) continue;
      if (i == 0){
        if (s[i][j] == '#' && s[i][j-1] == '.'){
          dp[i][j] = dp[i][j-1]+1;
        }else{
          dp[i][j] = dp[i][j-1];
        }
      }else if (j == 0){
        if (s[i][j] == '#' && s[i-1][j] == '.'){
          dp[i][j] = dp[i-1][j]+1;
        }else{
          dp[i][j] = dp[i-1][j];
        }
      }else{
        char c = s[i][j],ci = s[i-1][j],cj = s[i][j-1];
        if (c == '#'){
          if (ci == '.' && cj == '.'){
            dp[i][j] = min(dp[i-1][j],dp[i][j-1]) + 1;
          }else if(ci == '.' && cj == '#'){
            dp[i][j] = min(dp[i-1][j]+1,dp[i][j-1]);
          }else if(ci == '#' && cj == '.'){
            dp[i][j] = min(dp[i-1][j],dp[i][j-1]+1);
          }else{
            dp[i][j] = min(dp[i-1][j],dp[i][j-1]);
          }
        }else{
          dp[i][j] = min(dp[i-1][j],dp[i][j-1]);
        }
      }
    }
  }
  // rep(i,H){
  //   rep(j,W){
  //     cout << dp[i][j];
  //   }
  //   cout << endl;
  // }
  cout << dp[H-1][W-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int d = b - a;
	int tmp = 0;
	REPS(i, d) {
		tmp += i;
	}
	PRINTD(tmp - b);
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader r = new FastReader();
        String s = r.next();

        int i, j;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A')
                break;
        }

        for (j = s.length() - 1; j >= 0; j--) {
            if (s.charAt(j) == 'Z')
                break;
        }

        System.out.println(j - i + 1);
    }
}

Measured memory_bytes: 25340
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        char a[]=sc.next().toCharArray();
        char b[]=sc.next().toCharArray();
        int po[]=new int [129];
        int po2[]=new int [129];
        boolean bb=true;
        for(int i=0;i<a.length;i++)
            if(po[a[i]]==po2[b[i]]){
                po[a[i]]=i;
                po2[b[i]]=i;
            }
            else {
                bb=false;
                break;
            }
        System.out.println(bb?"Yes":"No");
    }
}


Measured memory_bytes: 28720