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

int main(){
    int h,w;
    cin>>h>>w;
    char table[h+2][w+2];
    char ans[h][w];
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            table[i][j]='%';
        }
    }
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            cin>>table[i][j];
        }
    }
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            int c=0;
            if(table[i][j]=='.'){
                if(table[i-1][j]=='#') c++;
                if(table[i+1][j]=='#') c++;
                if(table[i][j-1]=='#') c++;
                if(table[i][j+1]=='#') c++;
                if(table[i+1][j+1]=='#') c++;
                if(table[i-1][j+1]=='#') c++;
                if(table[i+1][j-1]=='#') c++;
                if(table[i-1][j-1]=='#') c++;
                ans[i-1][j-1]='0'+c;
            }else{
                ans[i-1][j-1]='#';
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<ans[i][j];
        }
        cout<<"\n";
    }
}

Measured memory_bytes: 256
import java.io.*;
 
class Main{
    public static void main (String[ ] args) throws Exception{
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        String str = br.readLine();

        int a = Integer.parseInt(str);
        
        System.out.println((a/3600) + ":" + (a%3600/60) + ":" +(a%3600%60));
    }
}

Measured memory_bytes: 24140
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC168C
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABHM = ReadInt();
            int A = ABHM[0];
            int B = ABHM[1];
            int H = ABHM[2];
            int M = ABHM[3];

            int minute = 60 * H + M;

            double degree1 = 0.5 * minute;
            double degree2 = 6.0 * minute;

            double x1 = A * Math.Cos(degree1 / 180 * Math.PI);
            double y1 = A * Math.Sin(degree1 / 180 * Math.PI);
            double x2 = B * Math.Cos(degree2 / 180 * Math.PI);
            double y2 = B * Math.Sin(degree2 / 180 * Math.PI);

            double dx = x1 - x2;
            double dy = y1 - y2;

            double ans = Math.Pow(dx * dx + dy * dy, 0.5);

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 20308
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

int main(void) {
	string s, t;
	cin >> s >> t;

	sort(s.begin(),s.end());
	sort(t.begin(), t.end(), greater<char>());

	if (s < t) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n;
    cin>>n;
    ll a[n+5],f[n+5]{0},ans[n+5];
    rep(i,1,n){
        cin>>a[i];
        f[a[i]]++;
    }
    ll sum=0;
    rep(i,1,n){
        ans[i]=f[i]*(f[i]-1)/2;
        sum+=ans[i];
    }
    rep(i,1,n){
        ll res=sum-ans[a[i]];
        res+=(f[a[i]]-1)*(f[a[i]]-2)/2;
        cout<<res<<'\n';
    }
    return 0;
}


Measured memory_bytes: 7296
# https://atcoder.jp/contests/abc131/tasks/abc131_e

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop


def output(edges):
    print(len(edges))
    for s, e in edges:
        print('{} {}'.format(s, e))


def main():
    N, K = map(int, input().split())

    edges = []
    # まずグラフを連結させる
    for i in range(2, N + 1):
        edges.append((1, i))

    ma = (N - 1) * (N - 2) // 2
    # print(ma)
    if K > ma:
        print(-1)
        exit()
    rest = ma - K
    cand = []
    for i in range(2, N):
        for j in range(i + 1, N + 1):
            cand.append((i, j))

    # print(rest)
    while rest > 0:
        i, j = cand.pop()
        edges.append((i, j))
        rest -= 1

    output(edges)


if __name__ == '__main__':
    main()


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

#define ll long long
#define MAX 1000003
#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector< int>>
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOR(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(),(v).end()
#define INF (int)1e9
#define EPS 1e-9

using namespace std;

const int MAXN = 1e5+5;
int dp [MAXN];

void solve(vi &a, int n){
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);

	rep(i, 2, n){
		dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2] - a[i]));
	}

	cout << dp[n-1] << "\n";
}

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

	int n;
	cin >> n;

	vi a(n);
	FOR(i, n)	cin >> a[i];

	solve(a, n);	
	
return 0;
}

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

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

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

int main() {
  int N;
  cin >> N;
  int digitSum = 0;
  for (int i = N; 0 < i; i /= 10) {
    digitSum += i % 10;
  }
  cout << (N % digitSum == 0 ? "Yes" : "No") << endl;
}


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

int main() 
{
    int N;
    cin >> N;
    ll ans = 1;
    for (int i = 0; i < N; i++) 
    {
        ll A;
        cin >> A;
        if (A == 0) 
            ans = 0;
        else if (ans <= (ll)1e18 / A && ans > 0) 
             ans *= A;
        else if (ans > 0)
            ans = -1;
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
int main() {
  int A,B,Q;
  cin >> A >> B >> Q;
  
  vector<long long> jin(A+2);
  vector<long long> tera(B+2);
  
  long long INF = std::pow(10, 18);
  
  jin[0] = -INF;
  jin[A+1] = INF;
    
  tera[0] = -INF;
  tera[B+1] = INF;
  
  for (int i=1; i<A+1;i++){
    cin >> jin[i];
  }
  for (int i=1; i<B+1;i++){
    cin >> tera[i];
  }
  
  long long q;
  for (int i; i<Q;i++){
    cin >> q;
    long long b = upper_bound(jin.begin(), jin.end(), q) - jin.begin();
    long long d = upper_bound(tera.begin(), tera.end(), q) - tera.begin();
    
    long long ans = INF;
    vector<long long> jinv{jin[b-1],jin[b]};
    vector<long long> terav{tera[d-1],tera[d]};
    vector<long long> dv(3);

    for (auto j: jinv) {
      for (auto t: terav){
        dv[0] = std::abs(j-q)+std::abs(t-j);
        dv[1] = std::abs(t-q)+std::abs(j-t);
        dv[2] = ans;
        ans = *std::min_element(dv.begin(), dv.end());
      }
    }
    cout << ans << endl;
  }
return 0;
}

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

int main() {
    char c;
    cin >> c;
    int ans = 1;
    
    if (c == 'a'||c =='e'||c =='i'||c =='o'||c =='u'){
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

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


Measured memory_bytes: 256
N, M = map(int, input().split())

ac = [False] * N
wa = [0] * N
for _ in range(M):
    q, res = input().split()
    q = int(q) - 1
    if res == 'AC':
        ac[q] = True
    else:
        if not ac[q]:
            wa[q] += 1

num_corr, num_wro = 0, 0
for q in range(N):
    if ac[q]:
        num_corr += 1
        num_wro += wa[q]

print(num_corr, num_wro)

Measured memory_bytes: 4596
#include <stdio.h>
int main(void){
  int n,a,b,i,j,k,l,m,o,sum;
  sum=0;
  
  scanf("%d %d %d",&n,&a,&b);
  for(i=1;i<=n;i++){
    j=i%10; k=(i/10)%10; l=(i/100)%10; m=(i/1000)%10; o=i/10000;
    if(j+k+l+m+o >= a && j+k+l+m+o <= b){
	  sum=sum+i;
	}
	else{}
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
N = int(input())
s = []
for _ in range(N):
    s.append(input()[:-1])

count_a = 0
count_b = 0
count_ab = 0
find_ab = 0
for i in range(N):
    for j in range(len(s[i])-1):
        if s[i][j] == "A" and s[i][j+1] == "B":
            find_ab += 1

    if s[i][-1] == "A" and s[i][0] == "B":
        count_ab += 1
    elif s[i][-1] == "A":
        count_a += 1
    elif s[i][0] == "B":
        count_b += 1

max_ab = max(count_a, count_b)
min_ab = min(count_a, count_b)
counts = 0
if max_ab > 0:
    counts = count_ab
else:
    counts = max(count_ab-1, 0)
counts += min_ab

print(counts+find_ab)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N, K;
  cin >> N >> K;

  string S;
  cin >> S;

  vector<int> A(0);

  char now = '1';
  int cnt = 0;
  rep(i, S.size()) {
    if (now == S[i])
      cnt++;
    else {
      A.pb(cnt);
      now = S[i];
      cnt = 1;
    }
  }
  if (cnt != 0) A.pb(cnt);
  if (S[S.size() - 1] == '0') A.pb(0);
  // rep(i, A.size()) { cout << A[i] << endl; }

  vector<int> sum(N + 1);
  rep(i, A.size()) { sum[i + 1] = sum[i] + A[i]; }

  int w = 2 * K + 1;
  int temp = 0;
  int ans = 0;

  for (int i = 0; i < A.size(); i += 2) {
    int l = i;
    int r = min(i + w, (int)A.size());

    temp = sum[r] - sum[l];

    chmax(ans, temp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1272
def main():
    s = input()
    t = input()
    T = len(t)
    candidate = []
    for i in range(len(s)-T+1):
        buf = s[i:i+T]
        flag = True
        for b, tc in zip(buf, t):
            if b == "?" or b == tc:
                continue
            else:
                flag = False
                break
        if flag == True:
            candidate.append(i)
    if len(candidate) == 0:
        print("UNRESTORABLE")
    else:
        print((s[:candidate[-1]] + t + s[candidate[-1]+T:]).replace("?", "a"))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import math
from collections import Counter

N = int(input())

max_itr = math.ceil(math.sqrt(N))

factors = []
while True:
    for i in range(2, max_itr):
        if N%i == 0:
            N = N // i
            factors.append(i)
            break
    else:
        if N != 1:
            factors.append(N)
        break

c = Counter(factors)
f = lambda x: math.floor((math.sqrt(8*x+1) - 1)/2)
print(sum(f(v) for v in c.values()))

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

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

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

ll comb(ll a){
    return a*(a-1)/2;
}

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

    int n;cin >> n;
    vi a(n);rep(i,n)cin >> a[i];

    map<int,int> mp;
    rep(i,n){
        mp[a[i]]++;
    }
    
    ll Sum = 0;
    for(auto i : mp){
        Sum += comb(i.second);
    }

    rep(i,n){
        ll ans = Sum;
        ans -= (comb(mp[a[i]]) - comb(mp[a[i]] - 1));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 8320
#include <stdio.h>
int main(void)
{
    int i, n;
    i = 1;
    scanf("%d", &n);
    while (i <= n)
    {
        int x = i;
        if (x % 3 == 0)
        {
            printf(" %d", i);
        }
        else
        {
            while (1)
            {
                if (x % 10 == 3)
                {
                    printf(" %d", i);
                    break;
                }
                x /= 10;
                if (x == 0)  // 答えがゼロになった時 
                {
                    break;
                }
            }
        }
        i++; // 足してループ
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



int main() {
	int n, t;
    cin>>n>>t;
    vector<int> push(n);
    rep(i,n)cin>>push[i];

    ll time = t;
    for(int i=1;i<n;i++){
        int diff=push[i]-push[i-1];
        if(diff>t) time+=(ll)t;
        else time+=(ll)diff;
    }

    cout<<time<<endl;

	return 0;
}

Measured memory_bytes: 1024
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)



n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            a = [i, j, k]
            ans += gcd_list(a)
            # print(i, j, k, res)
print(ans)

Measured memory_bytes: 74812
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        }
    }
}


Measured memory_bytes: 26512
n=int(input())
A=[]
cnt=0
add=0
for i in range(4472):
    cnt +=i+1
    A.append((cnt,i+1))
for i in range(len(A)-1):
    if A[i][0]<=n<=A[i+1][0]:
        add=(A[i+1][1],A[i+1][0]-n)
        break
for i in range(add[0]):
    if i+1==add[1]:continue
    print(i+1)

Measured memory_bytes: 3956
# include <bits/stdc++.h>
# define ll long long int
# define pb push_back
# define pf push_front
# define mpi make_pair
# define pi pair<ll,ll>
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
# define mod 1000000007
# define endl "\n"
using namespace std;
int main()
{
	fast
	ll n;
	cin>>n;
	vector <ll> v;
	for(ll i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		v.pb(x);
	}
	if(n==1)
	{
		cout<<"Yes";
		exit(0);
	}
	else
	{
		for(ll i=1;i<n;i++)
		{
			if(v[i]>v[i-1])
			{
				v[i]=v[i]-1;
			}
			else if(v[i]<v[i-1])
			{
				cout<<"No";
				exit(0);
			}
		}
	}
	cout<<"Yes";
	return 0;
}


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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

int V;
int L;
pair<int, int> lines[50];
bool field[50][50] = {};

void Check(int v, vector<bool>& checked) {
	if (checked[v]) {
		return;
	}
	
	checked[v] = true;
	for (int i = 0; i < V; ++i) {
		if (v == i) {
			continue;
		}
		if (field[v][i]) {
			Check(i, checked);
		}
	}
}

bool Judge(vector<bool>& checked) {
	for (int i = 0; i < V; ++i) {
		if (checked[i] == false) {
			return true;
		}
	}
	return false;
}

int Count() {
	int c = 0;

	for (int l = 0; l < L; ++l) {
		int a = lines[l].first;
		int b = lines[l].second;
		field[a][b] = false;
		field[b][a] = false;

		vector<bool> checked(V, false);
		Check(0, checked);

		if (Judge(checked)) {
			c++;
		}

		field[a][b] = true;
		field[b][a] = true;
	}

	return c;
}

int main()
{
	cin >> V >> L;

	REP(i, L) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		field[a][b] = true;
		field[b][a] = true;
		lines[i] = make_pair(a, b);
	}

	int c = Count();
	cout << c << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int a,b,c;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>a>>b>>c;
	cout<<(a+b-1)/b*c<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 3620
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
// #include <queue>
// #include <map>

using namespace std;

namespace atcoder {
namespace {

[[gnu::unused]] bool check()
{
  return false;
}

template<typename T>
vector<T> getN(istream& in)
{
  size_t N;
  in >> N;
  vector<T> seq;
  for (auto i = 0u; i < N; ++i) {
    T x;
    in >> x;
    seq.push_back(x);
  }
  return seq;
}

template<typename T>
long count(const vector<T>& input)
{
  auto v{input};
  const auto N{v.size()};
  assert(N ^ 1);
  const auto N2 = N / 2;
  assert(N2 > 0);
  partial_sort(v.begin(), v.begin() + N2 + 1, v.end());
  return v[N2] - v[N2 - 1];
}

long solve(istream& in)
{
  auto input = getN<long>(in);
  return count(input);
}

[[gnu::unused]] void test()
{
  {
    constexpr auto str = R"(
6
9 1 4 4 6 7
)";
    stringstream in{str};
    assert(solve(in) == 2);
  }

  {
    constexpr auto str = R"(
8
9 1 14 5 5 4 4 14
)";
    stringstream in{str};
    assert(solve(in) == 0);
  }

  {
    constexpr auto str = R"(
14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1
)";
    stringstream in{str};
    assert(solve(in) == 42685);
  }
}

} // namespace
} // namespace atcoder

////////////////////////////////////////////////////////////////
int main()
{
  using namespace atcoder;
  // test();
  cout << solve(cin);
}


Measured memory_bytes: 1908
n, k = gets.split.map(&:to_i)

strong = {}
yowai_sushi = []
n.times do |i|
  t, d = gets.split.map(&:to_i)
  if strong.include?(t)
    if strong[t] < d
      yowai_sushi << strong[t]
      strong[t] = d
    else
      yowai_sushi << d
    end
  else
    strong[t] = d
  end
end

strong = strong.values.sort!.reverse!
yowai_sushi.sort!.reverse!

intstrong = [0]
intyowai = [0]

accum = 0
strong.each do |x|
  accum += x
  intstrong << accum
end

accum = 0
yowai_sushi.each do |x|
  accum += x
  intyowai << accum
end

max = 0
([k, strong.size].min+1).times do |t|
  if k - t < intyowai.size
    tmp = intstrong[t] + intyowai[k - t] + t*t
    max = tmp if max < tmp
  end
end

p max


Measured memory_bytes: 10608
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                ios_base::sync_with_stdio(false);
                cin.tie(NULL);
                lli t,n,i,j,b,a,k,q,m;
                cin>>n>>m;
                lli ans=0;
                ans+=(n*(n-1))/2ll;
                ans+=(m*(m-1))/2ll;

                cout<<ans<<endl;


            }



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

using namespace std;
const int MOD = 1e9 + 7;

int main() {
  vector<int>v(3);
  // SUBTREES SOLVED FIRST...
  int n; cin >> n;
  vector<vector<int>>tree(n + 1);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  const int w = 0, b = 1;
  vector<vector<long long>>dp(n + 1, vector<long long>(2, 0));
  function<void(int, int)> dfs = [&](int from, int p) {
    dp[from][b] = dp[from][w] = 1;
    for (const auto& to: tree[from]) {
      if (to != p) {
        dfs(to, from);
        dp[from][w] = (1LL) * dp[from][w] * (dp[to][w] + dp[to][b]) % MOD;
        dp[from][b] = (1LL) * dp[from][b] * dp[to][w] % MOD;
        //cout << dp[from][w] << " " << dp[from][b] << "\n";
      }
    }
  };
  // dp[1][w] = dp[1][b] = 1;
  // cout << "parsed" << endl;
  // for (int i = 1; i <= n; i++) {
  //   for (const auto & j : tree[i]) {
  //     cout << i << " " << j << "\n";
  //     for (int c = w; c <= b; ++c) {
  //       if (c == w) {
  //         dp[j][c] += (dp[i][w] + dp[i][b]) % MOD; 
  //       } else if (c == b) {
  //         dp[j][c] += (dp[i][w]) % MOD;
  //       }
  //     }
  //   }
  // }
  // cout << "===\n";
  // for (const auto & x : dp) {
  //   for (const auto & y : x) {
  //     cout << y << " ";
  //   }
  //   cout << "\n";
  // }
  // cout << "===\n";
  dfs(1, -1);
  cout << (dp[1][w] + dp[1][b]) % MOD << endl;
  return 0;
}

Measured memory_bytes: 18176
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define int long long
const int mod=1000000007;
int nxt[50010],a[50010],f[50010][510],g[50010][510],fac[50010];
int n,k,m,ans;
int quickpow(int x,int y){
	if(y==0)return 1;
	if(y%2==0)return quickpow(x*x%mod,y/2);
	if(y%2==1)return quickpow(x*x%mod,y/2)*x%mod;
}
signed main(){
	scanf("%lld%lld%ld",&n,&k,&m);
	memset(nxt,0,sizeof(nxt));
	ans=quickpow(k,n-m)*(n-m+1)%mod;
	int l=0,maxn=0;
	for(int i=1;i<=m;i++){
		scanf("%lld",&a[i]);
		l=min(l+1,i-nxt[a[i]]);
		maxn=max(maxn,l);
		nxt[a[i]]=i;
	}
	if(maxn==k)return printf("%lld\n",ans),0;
	if(maxn==m){
		fac[0]=1;
		for(int i=1;i<=k;i++)fac[i]=fac[i-1]*i%mod;
		f[0][0]=1;
		for(int i=1;i<=n;i++)
			for(int j=k-1,s1=0,s2=0;j>=1;j--){
				s1=(s1+f[i-1][j])%mod;
				s2=(s2+g[i-1][j])%mod;
				f[i][j]=(s1+f[i-1][j-1]*(k-j+1))%mod;
				g[i][j]=(s2+g[i-1][j-1]*(k-j+1))%mod;
				if(j>=m)g[i][j]=(g[i][j]+f[i][j])%mod;				
			}
		int res=0;
		for(int i=1;i<k;i++)
			res=(res+g[n][i])%mod;
		res=res*fac[k-m]%mod*quickpow(fac[k],mod-2)%mod;
		printf("%lld\n",(ans-res+mod)%mod);
		return 0;
	}
	int pre=0,suf=0,res=0;
	memset(nxt,0,sizeof(nxt));
	for(int i=1;i<=m;i++)
		if(nxt[a[i]])break;
		else pre++,nxt[a[i]]=i;
	memset(nxt,0,sizeof(nxt));
	for(int i=m;i>=1;i--)
		if(nxt[a[i]])break;
		else suf++,nxt[a[i]]=i;
	f[0][pre]=g[0][suf]=1;
	for(int i=1;i<=n;i++)
		for(int j=k-1,s=0;j>=1;j--){
			s=(s+f[i-1][j])%mod;
			f[i][j]=(s+f[i-1][j-1]*(k-j+1)%mod)%mod;
		}
	for(int i=1;i<=n;i++)
		for(int j=k-1,s=0;j>=1;j--){
			s=(s+g[i-1][j])%mod;
			g[i][j]=(s+g[i-1][j-1]*(k-j+1)%mod)%mod;
		}
	for(int i=0;i<=n-m;i++){
		int s=0,t=0;
		for(int j=1;j<k;j++)
			(s+=f[i][j])%=mod,(t+=g[n-m-i][j])%=mod;
		(res+=s*t%mod)%=mod;
	}
	printf("%lld\n",(ans-res+mod)%mod);
	return 0;
	
}

Measured memory_bytes: 204928
#include <stdio.h>
#include <string.h>

int main(void){
    
    int n;
    scanf("%d",&n);
    
    double x[n],sum;
    char u[n][4];
    sum=0;
    
    for(int i=0; i<n; i++){
        scanf("%lf %s",&x[i],u[i]);
        
        if(strcmp(u[i],"BTC")==0)
            x[i]*=380000;
        
        sum+=x[i];
    }
    printf("%f",sum);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
class Program
{
    static List<int> s = new List<int>();
static long result;
static string[] S;
  static int A,B;
    static void Main()
    {
      A=int.Parse(Console.ReadLine());
        S=Console.ReadLine().Split(' ');
for(int i=0;i<A;i++){s.Add(int.Parse(S[i]));}
      int count=0;
for(int j=0;j<A-1;j++){if(s[j]>=s[j+1]){count++;}else{count=0;}if(count>result){result=count;}}
      
      
      
                    Console.WriteLine(result.ToString());

    }

}

Measured memory_bytes: 28380
package main

import (
	"fmt"
	"math"
)

func main() {
	MOD := int(math.Pow10(9) + 7)
	var N, K int
	fmt.Scan(&N, &K)

	inv := make([]int, N+1)
	for i := 1; i <= N; i++ {
		inv[i] = modinv(i, MOD)
	}

	for i := 1; i <= K; i++ {
		ans := (comb(N-K+1, i, MOD, inv) * comb(K-1, i-1, MOD, inv)) % MOD
		fmt.Println(ans)
	}
}

// ax + by = 1を満たす(x,y)を求める = mod b でのaの逆元xを求める
func modinv(a, mod int) int {
	b, x, y := mod, 1, 0

	for b != 0 {
		t := a / b

		a -= t * b
		a, b = b, a

		x -= t * y
		x, y = y, x
	}
	x %= mod

	if x < 0 {
		x += mod
	}
	return x
}

// nCr(mod MOD)を求める
func comb(n, r, mod int, inv []int) int {
	ans := 1
	for i := 0; i < r; i++ {
		ans = (ans * (n - i)) % mod
		ans = (ans * inv[i+1]) % mod
	}
	return ans
}


Measured memory_bytes: 512
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main(){
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    bool ans = false;
    if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2])ans = true;
    if(ans)cout << "Yes" <<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
// Lucky PIN
// 所要時間 分
#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() {

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for(int i = 0; i<=999; ++i){
        string t = to_string(i);
        if(t.size() == 2){
            t = "0" + t;
        }
        else if(t.size() == 1){
            t = "00" + t;
        }
        int idx = 0;
        rep(j, s.size()){
            if(t[idx] == s[j]){
                idx++;
            }
            if(idx == 3){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int k = t.size();
  int min_changes = 9999;
  for(int i = 0; i < n - k + 1; ++i) {
    int cur_changes = 0;
    for(int j = 0; j < k; ++j) {
      if(s[i + j] != t[j]) cur_changes++;
    }
    if(cur_changes < min_changes) min_changes = cur_changes;
  }
  cout << min_changes << "\n";
	return 0;
}


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

int top,S[1000];

void push(int x){
	top++;
	S[top] = x;
}

int pop(){
	top--;
	return S[top + 1];
}

int main(void){
	int a,b;
	top = 0;
	char s[100];
	while(scanf("%s" ,s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}
		else if(s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}
		else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	
	return 0;
	
}


Measured memory_bytes: 2052
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    res = sum(B)

    for i in range(len(A)-1):
        if A[i+1] == A[i] + 1:
            res += C[A[i]-1]

    print(res)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    B = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    C = [ int(next(tokens)) for _ in range(N-1) ]  # type: "List[int]"
    solve(N, A, B, C)

if __name__ == '__main__':
    main()


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

int main(){
	int count=0;
	long long int N,M;
	cin>>N>>M;
	vector<long long int> L(M),R(M);

	for(int i=0;i<M;i++)
		cin>>L.at(i)>>R.at(i);

	sort(L.begin(),L.end());
	sort(R.begin(),R.end());

	if(R.at(0)-L.at(M-1)<0)
		cout<<0<<endl;
	else
		cout<<R.at(0)-L.at(M-1)+1<<endl;

}

Measured memory_bytes: 1792
N = int(input())
A = [int(x) for x in input().split()]
S =sum(A)
D = [0]*(10**5+1)
for a in A:
  D[a] += 1
Q = int(input())
for i in range(Q):
  b, c = map(int, input().split())
  S -= D[b]*b
  S += D[b]*c
  D[c] += D[b]
  D[b] = 0
  print(S)

Measured memory_bytes: 84600
n, a, b, c = map(int, input().split())
bamb = [int(input()) for _ in range(n)]
objective = [a, b, c]
ans = float("inf")
for i in range(4 ** n):
    tmp = 0
    material = [[] for _ in range(3)]
    for j in range(n):
        flag = (i >> (2 * j)) & 3
        if flag == 0:
            material[0].append(bamb[j])
        elif flag == 1:
            material[1].append(bamb[j])
        elif flag == 2:
            material[2].append(bamb[j])
    if len(material[0]) > 0 and len(material[1]) > 0 and len(material[2]) > 0:
        for k in range(3):
            tmp += (len(material[k]) - 1) * 10
            tmp += abs(sum(material[k]) - objective[k])
        ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 47068
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String s = sc.next();
    sc.close();

    String[] S = s.split("");

    int answer = 1;
    String current = S[0];

    for (int i = 0; i < N; i++) {
      if (!current.equals(S[i])) {
        current = S[i];
        answer++;
      }
    }

    System.out.println(answer);

  }

}

Measured memory_bytes: 32648
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,a,*x = map(int,read().split())

x = [i-a for i in x]

d = {0:1}
for i in x:
    nd = d.copy()
    for k,v in d.items():
        if k+i in nd:
            nd[k+i] += v
        else:
            nd[k+i] = v

    d = nd

    #print(d)
print(d[0]-1)

Measured memory_bytes: 9276
H,W = map(int,input().split())
grid = [list(input()) for i in range(H)]
#print(grid)
#dp =[[1] if grid[i][j] == '.' else [0] for j in range(W) for i in range(H)]
dp = []
for i in range(H):
    retsu = []
    for j in range(W):
        if grid[i][j] == '.':
            retsu.append(1)
        else:
            retsu.append(0)
    dp.append(retsu)
#print(dp)
for i in range(H):
    for j in range(W):
        if j - 1 >= 0 and i-1>=0:
            if grid[i][j] == '#':
                continue
            dp[i][j] = dp[i][j-1] + dp[i-1][j]
        elif i - 1 >= 0:
            if grid[i][j] == '#':
                continue
            dp[i][j] = 0 + dp[i-1][j]
        elif j - 1 >= 0:
            if grid[i][j] == '#':
                continue
            dp[i][j] = dp[i][j-1] + 0
        else:
            dp[i][j] = 1

print(dp[H-1][W-1] % (10 ** 9 + 7))


Measured memory_bytes: 166220
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
  
    string s;
    cin>>s;
    string a;
    rep(i,s.size()){
        if(i%2==0){
            a+=s[i];
        }
    }
    cout<<a<<endl;
    
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
#define f(i,n) for(int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define vint vector<int>
#define pb(a) push_back(a);
#define bug(x) cout<<#x<<" = "<<x<<endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);


int main(){
	// fastio;
	ll n,m;
    cin>>n>>m;
    ll sum=0;
    f(i,m){
        ll a;
        cin>>a;
        sum+=a;
    }
    if(n-sum>=0){cout<<n-sum<<endl;}
    else{ cout<<-1<<endl; }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
#include <climits>
using namespace std;
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
#define ForInt(i, n) for (int i = 0; i < (n); ++i)
#define ForLong(i, n) for (int64 i = 0; i < (n); ++i)
#define ForIntInit(i, begin, end) for (int i = (begin); i < (end); ++i)
#define ForItr(it, itBegin, itEnd) for (auto it = (itBegin); it != (itEnd); ++it)
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Max(a, b) ((a) > (b) ? (a) : (b))



int main()
{
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> graph(n);
	ForInt(i, n - 1)
	{
		int u, v, w;
		cin >> u >> v >> w;
		--u;
		--v;
		graph[u].emplace_back(v, w);
		graph[v].emplace_back(u, w);
	}

	vector<int> color(n);
	queue<int> que;

	color[0] = 1;
	que.push(0);
	while (!que.empty())
	{
		int node = que.front();
		que.pop();

		auto itEnd = graph[node].end();
		ForItr(it, graph[node].begin(), itEnd)
		{
			int targetNode = it->first;
			if (color[targetNode] != 0) continue;
			if ((it->second & 1) == 0)
			{
				color[targetNode] = color[node];
			}
			else
			{
				color[targetNode] = -color[node];
			}
			que.push(targetNode);
		}
	}

	ForInt(i, n)
	{
		cout << (color[i] == 1 ? 1 : 0) << endl;
	}

	return 0;
}

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

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

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

const ll INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  int ans = n;
  rep(i, n + 1) {
    int cnt = 0;
    int t = i;
    while (t) {
      cnt += t % 6;
      t /= 6;
    } 
    t = n - i;
    while (t) {
      cnt += t % 9;
      t /= 9;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(N);
    for (int i = 0; i < N; i++) v[i] = i + 1;
    do {
        for (int i = 0; i < N-1; i++) sum += dist(v[i], v[i+1]);
    } while(next_permutation(v.begin(), v.end()));

    int factorial = 1;
    for (int i = 2; i <= N; i++) factorial *= i;
    cout << fixed << setprecision(10) << sum/factorial << endl;
    return;
}

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

Measured memory_bytes: 384
A = input()
B = input()
C = input()

next_turn = A[0]
Acnt = 1
Bcnt = 0
Ccnt = 0
while True:
    if next_turn == 'a':
        if Acnt == len(A):
            print('A')
            break
        next_turn = A[Acnt]
        Acnt += 1

    elif next_turn == 'b':
        if Bcnt == len(B):
            print('B')
            break
        next_turn = B[Bcnt]
        Bcnt += 1

    elif next_turn == 'c':
        if Ccnt == len(C):
            print('C')
            break
        next_turn = C[Ccnt]
        Ccnt += 1

Measured memory_bytes: 3188
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  S[K - 1] = S[K - 1] + 32;
  cout << S << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    s = []
    
    for i in range(N):
        tmp = input()
        s.append(tmp)
        
    m = 0
    a = 0
    r = 0
    c = 0
    h = 0
    for i in s:
        if i[0] == "M":
            m += 1
        elif i[0] == "A":
            a += 1
        elif i[0] == "R":
            r += 1
        elif i[0] == "C":
            c += 1
        elif i[0] == "H":
            h += 1
            
    #print("{} {} {} {} {}".format(m, a,r,c,h))
    total = (a*m*c) + (a*m*r) + (a*m*h) + (a*c*r) + (a*c*h) + (a*r*h) + (m*c*r) + (m*c*h) + (m*r*h) + (c*r*h)
            
    print(total)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 56280
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
v_e = v[0::2]
v_o = v[1::2]
mc_e = Counter(v_e).most_common() + [(0, 0)]
mc_o = Counter(v_o).most_common() + [(0, 0)]

if mc_e[0][0] != mc_o[0][0]:
    print(n - mc_e[0][1] - mc_o[0][1])
else:
    print(n - max(mc_e[0][1] + mc_o[1][1], mc_e[1][1] + mc_o[0][1]))



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

int main()
{
    int a,b,c;
    cin >>a>>b>>c;
    if(a!=b && a!=c && b==c ){
        cout <<a<<endl;
    }
    else if(b!=a && b!=c && a==c){
        cout <<b<<endl;
    }
    else{
        cout <<c<<endl;
    }
    return 0;
}


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

int main(){
	int n, m, x;
	cin >> n >> m >> x;
	int left = 0, right = 0;
	int temp;
	for(int i = 0; i < m; i++){
		cin >> temp;
		if(temp > x)
			right++;
		else
			left++;
	}
	cout << ((left < right) ? left : right) << endl;
}

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

int main(){
	char s,f[3]={'J','O','I'};
	static int m,n,g,a,b,c,d,ans[3];
	static int dp[1002][1002][3];
	scanf("%d%d%d\n",&m,&n,&g);
	for(int i=0;i<m+1;i++){
		for(int j=0;j<n+1;j++){
			if(i==0||j==0){
				dp[i][j][0]=0;
				dp[i][j][1]=0;
				dp[i][j][2]=0;
			}
			else {
				scanf("%c",&s);
				for(int k=0;k<3;k++){
					dp[i][j][k]=dp[i-1][j][k]+dp[i][j-1][k]-dp[i-1][j-1][k];
					if(s==f[k])dp[i][j][k]++;
				}
			}
		}
		scanf("\n");
	}
	for(int i=0;i<g;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		for(int j=0;j<3;j++)ans[j]=dp[c][d][j]+dp[a-1][b-1][j]-dp[a-1][d][j]-dp[c][b-1][j];
		printf("%d %d %d\n",ans[0],ans[1],ans[2]);
	}
}

Measured memory_bytes: 12828
import java.util.*;
public class Main {
	public static void main(String[] args){
    //標準入力のインスタンス作成
		Scanner sc = new Scanner(System.in);
		// 数値の入力
		double A = sc.nextDouble();//Acm
		double B = sc.nextDouble();//Bcm
		double H = sc.nextDouble();//H時間
		double M = sc.nextDouble();//M分
		//長短針間の角度を計算
		double theta_a = 30*(H+M/60);
		double theta_b = 360*(M/60);
		double theta_ab = Math.abs(theta_a-theta_b);
		//余弦定理で距離計算
		double C = Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(theta_ab/180*Math.PI));
		// 出力
		System.out.println(C);
	}
}


Measured memory_bytes: 37472
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a - 2 * b > 0) {
		cout << a - 2 * b << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};


int main() {
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    auto dp = make_v(n+1, 1<<(x+y+z), 0);
    int mask = (1<<(x+y+z))-1;
    dp[0][0] = 1;
    int a = (1<<(x-1))+(1<<(x+y-1))+(1<<(x+y+z-1));
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 1<<(x+y+z); ++j) {
            if(!dp[i][j]) continue;
            for (int k = 1; k <= 10; ++k) {
                int p = ((j << k)+ (1<<(k-1)))&mask;
                if((p & a) == a) (ans += (ll)pow_(10, n-i-1, MOD) * dp[i][j]) %= MOD;
                else (dp[i+1][p] += dp[i][j]) %= MOD;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 21888
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int b = a.size();
  int flag = 0;
  for(int i = 0;i < b-1;i++){
    if(a.at(i) == a.at(i+1)){
      cout << "Bad" << endl;
      flag = 1;
      break;
    }
  }
  if(flag == 0)
    cout << "Good" << endl;
}

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

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

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

int main() {
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << endl;
}


Measured memory_bytes: 256
from math import *

def trycut(val):
	ret = 0
	for i in range(n):
		ret += ceil(a[i]/val)-1
	return ret 

n,k=map(int,input().split())
a = [int(i) for i in input().split()]

low = 0
high = 1000000000
ans  =-1

while low <= high:
	mid = (low + high)/2
	cut = trycut(mid)
	# ~ print("low=",low, "high=", high,"val = ",mid,"ret = ",cut)
	if cut <= k:
		high = mid-0.0000001
		ans = mid
	else:
		low =  mid+0.0000001
	# ~ if low < high: print(low, high, "je reviens")
ans = int(ans*1000000)/1000000
# ~ print(ans)
print(int(ceil(ans)))




Measured memory_bytes: 31000
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=500500,P=998244353;
int n,m,ans,iv[N],fc[N],vf[N],pn[N],pm[N];
int C(int x,int y){return 1ll*fc[x]*vf[x-y]%P*vf[y]%P;}
int main(){
	scanf("%d%d",&n,&m);
	if(n>m) swap(n,m);
	iv[1]=fc[0]=vf[0]=pn[0]=pm[0]=1;
	FOR(i,2,m) iv[i]=1ll*iv[P%i]*(P-P/i)%P;
	FOR(i,1,m) fc[i]=1ll*fc[i-1]*i%P,vf[i]=1ll*vf[i-1]*iv[i]%P;
	FOR(i,1,m) pn[i]=1ll*pn[i-1]*(n+1)%P,pm[i]=1ll*pm[i-1]*(m+1)%P;
	FOR(i,0,n) (ans+=1ll*(i&1?P-1:1)*C(n,i)%P*C(m,i)%P*fc[i]%P*pn[m-i]%P*pm[n-i]%P)%=P;
	cout<<ans<<'\n';
}

Measured memory_bytes: 9984