akhauriyash/Code-Regression huggingface dataset:
a, b, c, d = map(int, input().split())
ma = -10 ** 100
ma = max(ma, a * c)
ma = max(ma, a * d)
ma = max(ma, b * c)
ma = max(ma, b * d)
if a <= 0 <= b or c <= 0 <= d:
    ma = max(ma, 0)
print(ma)

Measured memory_bytes: 61612
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n);
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	min, max := n, 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		if a[i] < min {
			min = a[i]
		}
		if a[i] > max {
			max = a[i]
		}
	}
	
	if max - min == 0 {
		if max == n - 1 || 2 * max <= n {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else if max - min <= 1 {
		k := 0
		for i := 0; i < n; i++ {
			if a[i] == max - 1 {
				k++
			}
		}
		if max > k && 2 * (max - k) <= n - k {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		fmt.Println("No")
	}
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  int a, b; cin >> a >> b;
  if (a + b == 15) cout << '+';
  else if (a * b == 15) cout << '*';
  else cout << 'x';
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int w,h,x,y,r;
    
    int height;
    int width;
    
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    
    if(((x-r)>=0)&&((x+r)<=w))
    {
        if(((y-r)>=0)&&((y+r)<=h))
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }    
    }
    else
    {
        printf("No\n");
    }         
   

    return 0;
}

Measured memory_bytes: 584
from operator import mul

N = int(input())
A = list(map(int, input().split()))

MAX_VAL = 10 ** 9

ans = []

for idx, a in enumerate(A[1:]):
    if idx == 0:
        xor = a
    else:
        xor ^= a

ans = [xor]

l_xor = None
r_xor = xor
for i in range(1, N):
    if i == 1:
        l_xor = A[i - 1]
        r_xor = A[i] ^ r_xor
        ans.append(l_xor ^ r_xor)
    elif i == N:
        l_xor = l_xor ^ A[i - 1]
        ans.append(l_xor)
    else:
        l_xor = l_xor ^ A[i - 1]
        r_xor = A[i] ^ r_xor
        ans.append(l_xor ^ r_xor)

print(*ans)


Measured memory_bytes: 117028
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

void solve(){
	int i,j;
	long double n,d;
	cin >> n >> d;
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		long double a,b;
		cin >> a >> b;
		if(d>=sqrt(a*a+b*b)){
			ans+=1;
		}
	}

	printf("%d",ans);
	
}


int main(){
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 3732
# -*- coding: utf-8 -*-
# モジュールのインポート
from fractions import gcd

# 標準入力の取得
A, B, C, D = list(map(int, input().split()))


def lcm(x: int, y: int) -> int:
    """最小公倍数を求めるメソッド

    Arguments:
        x {int} -- 整数
        y {int} -- 整数

    Returns:
        int -- 最小公倍数
    """
    return (x * y) // gcd(x, y)


def main() -> None:
    """Entry point
    """
    # 求解処理
    """
    CでもDでも割り切れないものの個数
    = 全体 - Cで割り切れる個数 - Dで割り切れる個数 + lcm(C,D)で割り切れる個数
    """
    div_C = (B // C) - ((A - 1) // C)
    div_D = (B // D) - ((A - 1) // D)
    lcm_CD = lcm(C, D)
    div_lcm_CD = (B // lcm_CD) - ((A - 1) // lcm_CD)
    result = (B - A + 1) - div_C - div_D + div_lcm_CD

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5076
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int heads = sc.nextInt();
		int legs = sc.nextInt();

		for (int i=0;i <= heads;i++) {
			if(i*2 + (heads-i)*4 == legs) {
				System.out.println("Yes");
				sc.close();
				return;
			}

		}

		sc.close();
		System.out.println("No");

	}

}

Measured memory_bytes: 27080
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int n, x[200005], sorted[200005];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        sorted[i] = x[i];
    }
    sort(sorted, sorted + n);
    for (int i = 0; i < n; i++) {
        if (x[i]<=sorted[n/2-1])cout << sorted[n/2] << endl;
        else cout << sorted[n / 2 - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  static int H[200001];
  for (auto i = 1; i <= N; ++i)
    scanf("%d", &H[i]);
  static int A[200001];
  for (auto i = 1; i <= N; ++i)
    scanf("%d", &A[i]);
  static long long W[200001];
  auto fupd = [&](int k, long long v) {
    while (k <= N) {
      W[k] = max(W[k], v);
      k += k & -k;
    }
  };
  auto fqry = [&](int k) {
    auto res = 0ll;
    while (k) {
      res = max(res, W[k]);
      k -= k & -k;
    }
    return res;
  };
  static long long F[200001];
  for (auto i = 1; i <= N; ++i) {
    F[i] = fqry(H[i]) + A[i];
    fupd(H[i], F[i]);
  }
  printf("%lld\n", *max_element(F + 1, F + N + 1));
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

long long gcd(long long a, long long b){
    long long r;
    if(a<b) std::swap(a,b);
    if(b<1) return b;
    while((r=a%b)!=0){
        a = b; b = r;
    }
    return b;
}

long long solve(const std::vector<ll>& d, int n){
    long long k = d.back();
    rep(i,n-1){
        k = gcd(k,d[i]);
    }
    return k;
}

int main(){
    int n;
    std::cin >> n;
    std::vector<ll> x(n+1), d(n,0);
    rep(i,n+1) std::cin >> x[i];

    std::sort(x.begin(),x.end());
    for(int i=0; i<n; i++){
        d[i] = x[i+1]-x[i];
    }

    std::cout << solve(d, n) << "\n";
    return 0;
}

Measured memory_bytes: 4824
require "prime"
n, m = gets.chomp.split.map(&:to_i)

if m == 1
  puts 1
  exit
end

factors = Prime.prime_division(m)

#全素因数を求める
factors = factors.map do |factor|
  (factor[1] + 1).times.map do |i|
  factor[0] ** i
  end
end
until (factors.size == 1) do
  factors = factors.each_slice(2).map{ |a, b|
    if b
      a.product(b).map{|c| c.reduce(&:*)}
    else
      a
    end
  }
end

factors = factors[0].sort.reverse
puts factors.find{|fac| fac <= (m/n)}

Measured memory_bytes: 14244
// C - Same Integers
#include <bits/stdc++.h>
using namespace std;

int main(){
	int A,B,C; cin>>A>>B>>C;
	int isodd = (A+B+C)&1;
	int ans = 0;
	if((A&1) != isodd){A++; ans=1;}
	if((B&1) != isodd){B++; ans=1;}
	if((C&1) != isodd){C++; ans=1;}
	ans += (3*max({A,B,C})-(A+B+C))/2;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 100000

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, L, res;
int main(int argc, char **argv) {
    cin >> N >> L;

    int sum = 0;
    for(int i = 0; i < N; ++i) {
        sum += L + i;
    }

    int dif = INF;
    int res = 0;
    for(int i = 0; i < N; ++i) {
        int cur = 0;
        for(int j = 0; j < N; ++j)
            if(j != i) {
                cur += L + j;
            }
        
        if(dif > abs(sum - cur)) {
            res = cur;
            dif = abs(sum - cur);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n>> m >> l;
  print((n+m)* l/2);
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,p;cin>>n>>p;
  string s;cin>>s;

  vector<ll>edited_nums(n);
  int ten=1;
  rrep(i, n){
    int c = s[i]-'0';
    edited_nums[i]=ten*c%p;
    ten = ten*10%p;
  }
  vector<ll> cum_nums(n+1);
  rrep(i, n){
    cum_nums[i]=(edited_nums[i]+cum_nums[i+1])%p;
  }

  if(p==2 || p==5){
    ll result = 0;
    rep(i, n)if((s[i]-'0')%p==0)result += (i+1);
    cout<<result;
    return 0;
  }

  ll result = 0;
  map<ll,ll>cnt;
  cnt[0]=1;
  rrep(i, n){
    ll ci = cum_nums[i];
    result+=cnt[ci];
    cnt[ci]++;
  }

  cout<<result<<endl;

//  rrep(i, n)cout<<cum_nums[i]<<' ';cout<<endl;
//  rrep(i, n)cout<<edited_nums[i]<<' ';cout<<endl;

  return 0;
}


Measured memory_bytes: 4100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> heights = new ArrayList<>();
		int x;
		for (int i = 0; i < 10; i++) {
			x = Integer.parseInt(br.readLine());
			if (0 <= x && x <= 10000) {
				heights.add(x);
			}
		}

		int[] top3 = getTop3(heights);
		for (int i = 0; i < top3.length; i++) {
			System.out.println(top3[i]);
		}
	}

	private static int[] getTop3(ArrayList<Integer> heights) {
		int[] top3 = new int[3];
		top3[0] = 0; // 1st highest
		top3[1] = 0; // 2rd highest
		top3[2] = 0; // 3rd highest
		for (int i = 0; i < heights.size(); i++) {
			int element = heights.get(i);
			if (element > top3[0]) {
				top3[2] = top3[1];
				top3[1] = top3[0];
				top3[0] = element;
			} else if (element > top3[1]) {
				top3[2] = top3[1];
				top3[1] = element;
			} else if (element > top3[2]) {
				top3[2] = element;
			}
		}
		return top3;
	}
}

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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (S.at(K-1)=='A') {
    S.at(K-1) = 'a';
  }
  if (S.at(K-1)=='B') {
    S.at(K-1) = 'b';
  }
  if (S.at(K-1)=='C') {
    S.at(K-1) = 'c';
  }
  cout << S << endl;
}

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

using namespace std;

int
main(){
  int ans = 0;
  string S;

  cin >> S;

  for (size_t i = 0; i < 3; i++) {
    if (S[i] == S[i+1]) {
      ans = 1;
    }
  }

  if (ans == 0) {
    cout << "Good" << endl;
  }else{
    cout << "Bad" << endl;
  }

        return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#define N 100005
#define Pii pair<int, int>
#define fi first
#define se second
using namespace std;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int n, tot = 1;
map<Pii, int>ret;
vector<int>E[N];
queue<Pii>q;

Pii mk(int x, int y){ if(x > y) swap(x, y); return make_pair(x, y); }

int fa[N], sz[N];

void add(int x, int y){
	E[x].push_back(y); E[y].push_back(x);
	ret[mk(x, y)]++;
}

int find(int x){ return fa[x] == x ? x : fa[x] = find(fa[x]); }

int main(){
	n = read();
	for(int i = 1; i <= n; i++) fa[i] = i, sz[i] = 1;
	for(int i = 1; i <= n * 2 - 2; i++) add(read(), read());
	for(map<Pii, int>::iterator it = ret.begin(); it != ret.end(); it++)
		if(it->se == 2) q.push(it->fi);
	while(!q.empty()){
		Pii u = q.front(); q.pop();
		int x = find(u.fi), y = find(u.se);
		if(x == y) continue ;
		++tot;
		if(sz[x] < sz[y]) swap(x, y);
		for(int i = 0; i < E[y].size(); i++){
			int t = find(E[y][i]);
			if(t == x) continue ;
			E[x].push_back(t);
			ret[mk(y, t)]--;
			ret[mk(x, t)]++;
			if(ret[mk(x, t)] == 2) q.push(mk(x, t));
		}
		E[y].clear();
		sz[x] += sz[y];
		fa[y] = x;
	}
	puts(tot == n ? "YES" : "NO");
}


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

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

int main() {
    string s; cin >> s;
    bool tap = true;
    rep(i, s.size()){
        if(i%2 == 0 && s[i] == 'L') tap = false;
        if(i%2 == 1 && s[i] == 'R') tap = false; 
    }
    cout << (tap ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
C = [0]*(10**5)
U = 10**2
for x in range(1, U+1):
    for y in range(1, U+1):
        for z in range(1, U+1):
            temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if temp < 10**5:
                C[temp] += 1
n = int(input())
for i in range(1, n+1):
    print(C[i])

Measured memory_bytes: 75004
#include<cstdio>
inline void read(int &n)
{
	n=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9')
	{
		n=(n<<3)+(n<<1)+ch-'0';
		ch=getchar();
	}
	return;
}
int n,m,ans;
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
	{
		read(m);
		if(m==ans+1)ans++;
	}
	if(ans==0)puts("-1");
	else printf("%d",n-ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    unsigned long long int a;
    unsigned long long int n, k;
    cin>>n>>k;
    
    a=k;
    
    if(n>1){
        for(int i=1; i<n; i++){
        a*=(k-1);
        }
    }
    
    cout<<a<<endl;
}


Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

/*各位の和　
int sum = 0;
for(int i = 0; i <= 5; i++){
   sum += n%10;
   n /= 10;  
}
*/

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll n;
  cin>>n;
  vl b(n-1);
  rep(i,n-1)
  {
    cin>>b[i];
  }
  rep(i,n-2)
  {
    p+=min(b[i],b[i+1]);
  }
  p+=b[0];
  p+=b[n-2];
  print(p);
}


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

int n, l;

int main() {
    cin >> n >> l;
    string array[n];
    for (int i=0; i<n; i++){
        cin >> array[i];
    }

    sort(array, array + n);

    for (int i=0; i<n; i++){
        cout << array[i];
    }

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
if (H==1)|(W==1):
    result = 1
else:
    if H % 2 == 0:
        result = H/2*W
    else:
        if W % 2 == 0:
            result = H*W/2
        else:
            result = (H//2+1)*(W//2+1)+(H//2)*(W//2)
print(int(result))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
ll abs(ll a,ll b)
{
	ll c=a-b;
	if(c<0){c=c*-1;}
	return c;
}
int main()
{
	ll s,digi=3;
	cin >> s;

	for(ll i=1000;s/i>0;i=i*10){
		digi++;
	}
	
	ll num[digi],k=0,min=10000;
	for(ll j=digi-1;j>=0;j--){
		num[k] = s/pow(10,j);
		num[k] = num[k] % 10;
		k++;
	}
	/*cout << digi << endl;
	for(int l=0;l<digi;l++){
		cout << num[l] << " ";
	}*/
	
	for(ll m=0;m<digi-2;m++){
		if(min >=
		abs(num[m]*100+num[m+1]*10+num[m+2],753)){min =
			abs(num[m]*100+num[m+1]*10+num[m+2],753);}
	}
	
	cout << min << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int a[1000], c[10];
signed main(void)
{
	int n;
	cin >> n;
	REP(i, n) cin >> a[i];

	REP(i, n) {
		if(a[i]/400 < 8) c[a[i]/400]++;
		else c[8]++;
	}
	int ret = 0;
	REP(i, 8) {
		if(c[i] != 0) ret++;
	}
	cout << max(1, ret) << " " << ret + c[8] << endl;

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> cnt(26);
    rep(i,26){
        cnt[i]=100;
    }
    rep(i,N){
        string S;
        cin >> S;
        vector<int> tmp_cnt(26);
        for(int i=0;i<S.length();i++){
            tmp_cnt[S[i]-'a']++;
        }
        for(int i=0;i<26;i++){
            cnt[i]=min(tmp_cnt[i],cnt[i]);
        }
    }
    string ans;
    rep(i,26){
        if(cnt[i]!=0){
            rep(j,cnt[i]){
                ans+=('a'+ i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  pts <- replicateM n $ do
    s <- getLine
    let [s1,s2] = words s
    return $ if s1 < s2 then (0,3) else if s1 > s2 then (3,0) else (1,1)
  let (p1,p2) = foldl (\(a,b) (c,d) -> (a+c,b+d)) (0,0) pts
  putStrLn $ show p1 ++ " " ++ show p2

Measured memory_bytes: 4528
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n = 0;
	vector<int> v = {};

	scanf("%d", &n);
	v.resize(n);
	int cntmin = 0;
	int cntmax = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}

	int max = *max_element(v.begin(), v.end());
	int min = *min_element(v.begin(), v.end());
	for (int i = 0; i < n; i++) {
		if (max == v[i]) {
			cntmax++;
		}
		else {
			cntmin++;
		}
	}

	if (max - min > 1) {
		printf("No\n");
		return 0;
	}

	if (max == min) {
		if (n - 1 == max || n >= 2*max) {
			printf("Yes\n");
			return 0;
		}
		else {
			printf("No\n");
			return 0;
		}
	}
	
	if ((n - max) * 2 == cntmax) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}

Measured memory_bytes: 640
x, y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
	print ("Yes")
else:
	print ("No")

Measured memory_bytes: 3060
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

mod = 10 ** 9 + 7

x_sum = 0
for i in range(n-1):
    x_sum += (x[i+1] - x[i]) * (i + 1) * (n - i - 1)
    x_sum %= mod

y_sum = 0
for i in range(m-1):
    y_sum += (y[i+1] - y[i]) * (i + 1) * (m - i - 1)
    y_sum %= mod

print((x_sum * y_sum) % mod)

Measured memory_bytes: 18576
package main
 
import (
	"fmt"
)
 
func main() {
  var h, w int
  var c string
  fmt.Scanf("%d %d", &h, &w)
  
  for i := 0; i < h; i++ {
  	fmt.Scanf("%s", &c)
  	fmt.Printf("%s\n%s\n", c, c)
  }
}

Measured memory_bytes: 1880
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int n, k;
    cin >> n;
    string s;
    cin >> s;
    cin >> k;
    char c = s[k-1];
    rep(i, n){
        if(s[i]!=c) s[i] = '*';
    }
    cout << s;

}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $S);

$L = array_fill(0, $N, 0);
for ($i = 0; $i < $N; $i++) {
    if ($S[$i] == 'W') {
        if ($i == 0) {
            $L[$i] = 1;
        } else {
            $L[$i] = $L[$i - 1] + 1;
        }
    } else {
        if ($i !== 0) {
            $L[$i] = $L[$i - 1];
        }
    }
}

$R = array_fill(0, $N, 0);
for ($i = $N - 1; $i >= 0; $i--) {
    if ($S[$i] == 'E') {
        if ($i == $N - 1) {
            $R[$i] = 1;
        } else {
            $R[$i] = $R[$i + 1] + 1;
        }
    } else {
        if ($i !== $N - 1) {
            $R[$i] = $R[$i + 1];
        }
    }
}

$min = PHP_INT_MAX;
for ($i = 0; $i < $N; $i++) {
    switch ($i) {
    case 0:
        $min = min($min, $R[$i + 1]);
        break;
    case $N - 1:
        $min = min($min, $L[$i - 1]);
        break;
    default:
        $min = min($min, $L[$i - 1] + $R[$i + 1]);
    }
}
echo $min;


Measured memory_bytes: 25080
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	scanf("%d",&a);
	while(a!=0){
		int k;
		k=a%10;
		if(k==7){
			printf("Yes\n");
			return 0;
		}
		a/=10;
	}
	printf("No\n");
	return 0;
}

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

int main()
{
    int n, a, b, c, d, A, B;
    cin >> n;
    a = n%10;
    b = (n/10)%10;
    c = ((n/10)/10)%10;
    d = (((n/10)/10)/10)%10;
    A = (d*10)+c;
    B = (b*10)+a;

    if((B>0 && B<13) && (A>0 && A<13))
    {
        cout << "AMBIGUOUS\n";
    }
    else if(A>0 && A<13)
    {
        cout << "MMYY\n";
    }
    else if(B>0 && B<13)
    {
        cout << "YYMM\n";
    }
    else
    {
        cout << "NA\n";
    }

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    xor=0
    for a in A: xor^=a
    # xorのうち、bitが立っていない部分だけでスクリーニング
    for i in range(n): A[i]&=(~xor)
    # このAに対してsweeping
    r=0 # Aのrank
    for d in reversed(range(61)): # digit
        for i in range(r,n):
            if A[i]&(1<<d): # 候補のiをfixする
                for j in range(n): # sweep
                    if j==i: continue # 自分自身は掃き出さない
                    if A[j]&(1<<d): A[j]^=A[i]
                A[i],A[r]=A[r],A[i] # swap
                r+=1
                break
    # sweepしたAに対し、最上位bitから確定させていく
    x=0
    for i in range(r):
        d=A[i].bit_length()
        if not x&(1<<(d-1)):
            x^=A[i]
    print(xor+2*x)
resolve()

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


const int maxn = 40+5;
const int maxm = (1 << 17)+100;

typedef long long LL;
const LL mod = 1e9+7;
LL dp[maxn][maxm];
int n,X,Y,Z;

int main()
{
    scanf("%d %d %d %d",&n,&X,&Y,&Z);

    int tar = (1 << (Z-1)) | (1 << (Y+Z-1)) | (1 << (X+Y+Z-1));
    int M = (1 << (X+Y+Z));

    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int i = 0;i < n;++i)
        for(int msk = 0;msk <= M;++msk)
        {
            if(dp[i][msk] == 0) continue;
            for(int k = 1;k <= 10;++k)
            {
                if(msk == M)
                {
                    dp[i+1][M] = (dp[i+1][M] + dp[i][msk])%mod;
                    continue;
                }

                int nxtmsk = ((msk << k)|(1 << (k-1))) & (M-1);
                if( (nxtmsk & tar) == tar) nxtmsk = M;

                dp[i+1][nxtmsk] = (dp[i+1][nxtmsk] + dp[i][msk])%mod;

            }

        }

    printf("%lld\n",dp[n][M]);

    return 0;

}



Measured memory_bytes: 46336
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
typedef long long ll;
using namespace std;
 
int main(){
  int a,b,x; cin >> a >> b >> x;
  double v=(double)x/(a*a);
  double ans=0;
  if(v<(b/2)) ans=(180/PI)*atan((b*b)/(2*v*a));
  else ans=(180/PI)*atan(((b-v)*2)/a);
  printf("%.11lf\n",ans);
 return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
int n;
vector<vi> v;
short dp[366][10][8][8][8][8];

vi move(int t)
{
	vi res;
	if (t == 0) res = { 0,1,2,3,6 };
	if (t == 1) res = { 0,1,2,4,7 };
	if (t == 2) res = { 0,1,2,5,8 };
	if (t == 3) res = { 3,4,5,0,6 };
	if (t == 4) res = { 3,4,5,1,7 };
	if (t == 5) res = { 3,4,5,2,8 };
	if (t == 6) res = { 6,7,8,0,3 };
	if (t == 7) res = { 6,7,8,1,4 };
	if (t == 8) res = { 6,7,8,2,5 };
	return res;
}

vi range(int t)
{
	vi res;
	if(t<3) res = { t, t + 1,t + 4,t + 5 };
	else if (t < 6) res = { t + 1,t + 2,t + 5,t + 6 };
	else res = { t + 2,t + 3,t + 6,t + 7 };
	return res;
}

short solve(const int day, const int pos, const int ul, const int ur, const int dl, const int dr)
{
	if (dp[day][pos][ul][ur][dl][dr] >= 0) return dp[day][pos][ul][ur][dl][dr];
	if (ul == 7 || ur == 7 || dl == 7 || dr == 7)  return 0;
	if (day == n - 1) return 1;
	short res = 0;
	vi can = move(pos);
	REP(i, can.size())
	{
		int npos = can[i];
		vi rain = range(npos);
		bool f = false;
		REP(j, rain.size()) if (v[day + 1][rain[j]]) f = true;
		if (f) continue;
		int nul = ul + 1, nur = ur + 1, ndl = dl + 1, ndr = dr + 1;
		if (npos == 0) nul = 0;
		if (npos == 2) nur = 0;
		if (npos == 6) ndl = 0;
		if (npos == 8) ndr = 0;
		if (solve(day + 1, npos, nul, nur, ndl, ndr)) res = 1;
	}
	return dp[day][pos][ul][ur][dl][dr] = res;
}

int main()
{
	while (cin >> n, n)
	{
		MS(dp, -1);
		v.clear();
		v.resize(n, vi(16));
		REP(i, n)REP(j, 16) cin >> v[i][j];

		bool f = true;
		vi a = { 5,6,9,10 };
		REP(i, 4) if (v[0][a[i]]) f = false;
		if (!f) puts("0");
		else puts(solve(0, 4, 1, 1, 1, 1) == 1 ? "1" : "0");
	}
	return 0;
}

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

bool intersect(double l1, double r1, double l2, double r2){
    return max(l1,l2) - 1e-8 < min(r1,r2);
}

int main(){
    double xa[3], ya[3], xb[3], yb[3];
    while(cin >> xa[1]){
        cin >> ya[1];
        cin >> xa[2];
        cin >> ya[2];
        cin >> xb[1];
        cin >> yb[1];
        cin >> xb[2];
        cin >> yb[2];
        puts(intersect(xa[1], xa[2], xb[1], xb[2]) &&
             intersect(ya[1], ya[2], yb[1], yb[2]) ?
             "YES" : "NO");
    }
}

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

int main(void)
{
    int n;
    cin >> n;

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

    int count = 0;
    
    for (int i = 1; i < n-1; i++) {
        if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1])) {
            count++;
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
/*#include<iostream>
#include<list>

using namespace std;

int main(){
	int n;
	cin>>n;
	list<int> L;
	for(int i=0;i<n;i++){
		string s;
		int n;
		cin>>s;
		if(s=="insert"){
			cin>>n;
			L.insert(L.begin(),n);
		}
		else if(s=="delete"){
			cin>>n;
			for(list<int>::iterator it=L.begin();it!=L.end();it++){
				if(*it==n){
					L.erase(it);
					break;
				}
			}
		}
		else if(s=="deleteFirst"){
			L.erase(L.begin());
		}
		else if(s=="deleteLast"){
			L.erase(--L.end());
		}
	}
	for(list<int>::iterator it=L.begin();it!=L.end();it++){
		cout<<*it;
		it++;
		if(it!=L.end())cout<<" ";
		it--;
	}
	cout<<endl;
	return 0;
} */


/*#include<cstdio>
#include<cstdlib>
#include<cstring>
struct Node{
	int key;
	Node * next,prev;
};

Node *nil;

Node* listSearch(int key){
	Node* cur=nil->next;
	while(cur!=null&&cur->key!=key){
		
	}
}*/

#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;
int main(){
	int q,x;
	char com[20];
	list<int> v;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%s",com);
		if(com[0]=='i'){
			scanf("%d",&x);
			v.push_front(x);
		}
		else if(com[6]=='L'){
			v.pop_back();
		}
		else if(com[6]=='F'){
			v.pop_front();
		}
		else if(com[0]=='d'){
			scanf("%d",&x);
			for(list<int>::iterator it=v.begin();it!=v.end();it++){
				if(*it==x){
					v.erase(it);
					break;
				}
			}
		}
	}
	int i=0;
	for(list<int>::iterator it=v.begin();it!=v.end();it++){
		if(i++)printf(" ");
		printf("%d",*it);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 34004
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int n;
    cin>>n;
    if(!n)break;
    vector<int> a(n);
    double sum=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
    }
    sum/=n;
    int ans=0;
    for(int i=0;i<n;i++){
      if(sum>=a[i])ans++;
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rsort(x) sort(x.rbegin(), x.rend())
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define fio(x) ios::sync_with_stdio(x), cin.tie(x), cout.tie(x);
#define znit(x) memset(x, 0, sizeof(x))
#define mnit(x) memset(x, -1, sizeof(x))
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db EPS = 1e-7;

const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 9;
ll mypow(ll x, ll y, ll p){ll ret = 1;while(y){if(y & 1) ret = (ret * x) % p;x = (x * x) % p; y /= 2;}return ret;}
ll inv(ll x, ll p){return mypow(x, p - 2, p);}
ll gcd(ll x, ll y){return y ? gcd(y, x % y) : x;}

const int MAX = 2e5 + 3;
string s;
int K;
int main(){
	fio(0);
	cin >> s;
	cin >> K;
	int ans = 0;
	for(int i = 0; i < s.length(); i++){
		if(i == K - 1){
			ans = s[i] - '0';
			break;
		}
		if(s[i] != '1'){
			ans = s[i] - '0';
			break;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  string a[3];
  int idx[3]={};
  int crt=0;
  for ( int i=0; i<3; i++ ) cin >> a[i];
  while ( 1 ) {
    if ( idx[crt]>=a[crt].size() ) break;
    int nxt=a[crt][idx[crt]]-'a';
    idx[crt]++;
    crt=nxt;
  }
  cout << "ABC"[crt] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

struct sqrt_decomp_tree {
    int n, B;
    int size() const { return n; }
    vi color, parent, depth, block_root_depth, block_parent, visited;
    vvi adj;
    sqrt_decomp_tree(int n_) : n(n_), adj(n) {
        int l = 0, r = n;
        while (l < r - 1) {
            i64 m = (l + r) / 2;
            if (m * m >= n) {
                r = m;
            } else {
                l = m;
            }
        }
        B = r;
    }
    void addEdge(int u, int v) {
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    void decomp(int root = 0) {
        color.assign(n, -1);
        parent.assign(n, -1);
        depth.assign(n, 0);
        block_root_depth.assign(n, 0);
        block_parent.assign(n, -1);
        visited.assign(n, 0);
        vi tord;
        vi q(n + 1);
        int l = 0, r = 0;
        q[r++] = root;
        while (l != r) {
            int v = q[l++];
            visited[v] = 1;
            tord.push_back(v);
            for (int c : adj[v]) {
                if (!visited[c]) {
                    parent[c] = v;
                    depth[c] = depth[v] + 1;
                    q[r++] = c;
                }
            }
        }
        int c = 0;
        for (int u : tord) {
            if (color[u] != -1) continue;
            l = 0, r = 0;
            q[r++] = u;
            for (int i = 0; i < B && l != r; i++) {
                int v = q[l++];
                color[v] = c;
                block_parent[v] = parent[u];
                block_root_depth[v] = depth[u];
                for (int c : adj[v])
                    if (color[c] == -1) q[r++] = c;
            }
            c++;
        }
    }
    int lca(int u, int v) {
        while (block_root_depth[u] > block_root_depth[v]) u = block_parent[u];
        while (block_root_depth[u] < block_root_depth[v]) v = block_parent[v];
        while (depth[u] > depth[v]) u = parent[u];
        while (depth[u] < depth[v]) v = parent[v];
        while (u != v) u = parent[u], v = parent[v];
        return u;
    }
};

int main() {
    int n;
    cin >> n;
    sqrt_decomp_tree tree(n);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int u;
            cin >> u;
            tree.addEdge(i, u);
        }
    }
    
    tree.decomp();
    int q;
    cin >> q;
    while (q--) {
        int u, v;
        cin >> u >> v;
        cout << tree.lca(u, v) << endl;
    }
}



Measured memory_bytes: 16116
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;
string ans = "Yay! :(";

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

Measured memory_bytes: 256
eval"N,K,*A="+`dd`.split*?,
s,*l=eval A*?+
1.upto(3e4){|j|s%j<1&&l<<j<<s/j}
p l.select{|h|t=0
K>=A.map{|x|x%h}.sort.map{|x|t+=x}[N-t/h-1]}.max

Measured memory_bytes: 16636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    ll h, w;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }

    cout << (h*w + 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	bk := -1
	sum := 0
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		if bk == a {
			sum++
			bk = -1
		} else {
			bk = a
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
vector<int> G[2000];
vector<P> E;
int d[2000];
void dfs(int v, int par, int depth) {
	d[v] = min(d[v], depth);
	for (int to : G[v]) {
		if (to == par) continue;
		dfs(to, v, depth + 1);
	}
}
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
		E.emplace_back(a, b);
	}
	int ans = 1 << 30;
	if (K % 2 == 0) {
		for (int i = 0; i < N; i++) {
			fill(d, d + N, 1 << 30);
			dfs(i, -1, 0);
			int cnt = 0;
			for (int j = 0; j < N; j++) {
				if (d[j] > K / 2) cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	else {
		for (int i = 0; i < N - 1; i++) {
			fill(d, d + N, 1 << 30);
			dfs(E[i].first, -1, 0);
			dfs(E[i].second, -1, 0);
			int cnt = 0;
			for (int j = 0; j < N; j++) {
				if (d[j] > K / 2) cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
}

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

#define ldb long double
#define ll long long

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> cnt(n + 1);
    
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    
    ll sum = 0;
    
    for(int i = 1; i <= n; i++)
    {
        sum += cnt[i] * (cnt[i] - 1) / 2;
    }
    
    for(int i = 0; i < n; i++)
    {
        ll temp = sum - cnt[a[i]] * (cnt[a[i]] - 1) / 2;
        temp += (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
        
        cout << temp << "\n";
    }

    return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 256
import collections

n,k=map(int,input().split())

a=list(map(int,input().split()))

a_count=collections.Counter(a)

aco=sorted(a_count.values())
ans=0
#for i in range(len(a_count)-k):

for i in range(len(aco)-k):
    ans+=aco[i]
    

print(ans)

Measured memory_bytes: 32564
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1, 0); }
	V<V<pin>> qab(2);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc + 1) % 2) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0] && !c[1 - i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for (pin& v : ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 2e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf;
}

Measured memory_bytes: 11632
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;

    bool a[60];
    for (int i = 0; i < 52; i++)
    {
        a[i] = false;
    }

    for (int i = 0; i < n; i++)
    {
        char suit;
        int x;
        cin >> suit >> x;

        switch (suit)
        {
        case 'S':
            x += 13 * 0;
            break;
        case 'H':
            x += 13 * 1;
            break;
        case 'C':
            x += 13 * 2;
            break;
        case 'D':
            x += 13 * 3;
            break;
        }
        x -= 1;

        a[x] = true;
    }

    for (int i = 0; i < 52; i++)
    {
        if (!a[i])
        {
            char suit;
            switch (i / 13)
            {
            case 0:
                suit = 'S';
                break;
            case 1:
                suit = 'H';
                break;
            case 2:
                suit = 'C';
                break;
            case 3:
                suit = 'D';
                break;
            }

            cout << suit << " " << i % 13 + 1 << endl;
        }
    }
}


Measured memory_bytes: 3056
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int, int> P;
#define fi first
#define se second
int main(){
string s;
cin>>s;
map<char,bool> d;
for(int i=0;i<s.size();i++){
	d[s.at(i)]=true;
}
if(d['N']==d['S']&&d['W']==d['E'])cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

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


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int m, d;
	int ans = 0;

	scanf("%d%d", &m, &d);

	for(int d1 = 2; d1 <= 9; d1++) {
		for(int d2 = 2; d2 < 100; d2++) {
			if(d2 * 10 + d1 > d) {
				continue;
			}
			int x = d2 * d1;
			if(x >= 1 && x <= m) {
				ans += 1;
			}
		}
	}

	printf("%d\n", ans);

	return 0;
}

/* waffle */


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

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  a += b;
  c += d;
  if (a < c) cout << "Right" << endl;
  else if(a > c) cout << "Left" << endl;
  else cout << "Balanced" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main(){
    int n,x,A[100000];
    cin>>n>>x;
    for(int i=0;i<n;i++) cin>>A[i];
    for(int i=0;i<n;i++) A[i] -=x;
    for(int i=0;i<n;i++) {
        if(A[i]<0) A[i]=A[i]*(-1);
    }
    int z=1,ans=A[0];
    while(z<n){
        if(A[z]%ans!=0) ans=gcd(A[z],ans);
        z++;
    }
    cout<<ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ;
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
int main () {
  int x ;
  cin >> x ;
  call(x) ;
}



Measured memory_bytes: 3124
#include <stdio.h>

int main() {
    int x = 0;

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

    for (int i = 0, j = 1; i < N; i++) {
        if (a[i] == j) {
            j++;
        } else {
            x++;
        }
    }
    if (x == N) {
        x = -1;
    }

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

Measured memory_bytes: 896
#include<cstdio>
#include<cctype>
#include<cstring>
#include<set>
#include<algorithm>
#define reg register
typedef long long ll;
template<typename T>inline T read(){
    reg T x=0;reg short f=1;reg char c=getchar();
    for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());
    for(;isdigit(c);x=x*10+(c^48),c=getchar());
    return x*f;
}
const int MN=1e5+5;
const int U=1<<16;
const int inf=0x7f7f7f7f;
int n,ans,s[MN],f[U],sum[17];
using std::min;
inline int dfs(int S){
	if(f[S]<inf)return f[S];
	for(reg int i=1;i<16;i++)
	    if((S>>i)&1)for(reg int j=1;j<16;j++)
			    if((i^j)&&((S>>j)&1)){
					reg int t=i^j,s=S^(1<<i)^(1<<j)^(1<<t);
					f[S]=min(f[S],dfs(s)+1+((S>>t)&1));
				}
	return f[S];
}
int main(){
	n=read<int>();memset(f,0x7f,sizeof(f));
	for(reg int i=1,x,y,c;i<n;i++){
		x=read<int>(),y=read<int>(),c=read<int>();
		s[x]^=c;s[y]^=c;
	}
	for(reg int i=0;i<n;i++)sum[s[i]]++;
	reg int S=0;f[0]=0;
	for(reg int i=1;i<16;i++)ans+=(sum[i]>>1),S+=(1<<i)*(sum[i]&1);
	printf("%d\n",ans+dfs(S));
	return 0;
}

Measured memory_bytes: 896
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let i = ref 0

let rec f a b c =
        if a mod 2 = 1 && b mod 2 = 1 && c mod 2 = 1 then
                0
        else if a = b && a = c && b = c then
                -1
        else if a mod 2 = 1 || b mod 2 = 1 || c mod 2 = 1 then
                !i
        else
                let na = (b + c) / 2 in
                let nb = (a + c) / 2 in
                let nc = (a + b) / 2 in
                        incr i;
                        f na nb nc

let () =
        Scanf.sscanf (read_line ()) "%d %d %d" (
                fun a b c -> 
                        f a b c
        ) |> Printf.printf "%d\n"


Measured memory_bytes: 1024