akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vi A={0};
    rep(i,N) {
        int a;
        cin>>a;
        A.pb(a);
    }
    A.pb(0);
    int sum=0;
    rep(i,N+1) {
        sum+=abs(A[i]-A[i+1]);
    }
    int sum2=sum;
    for(int i=1; i<=N; i++) {
        sum-=abs(A[i]-A[i-1]);
        sum-=abs(A[i+1]-A[i]);
        sum+=abs(A[i+1]-A[i-1]);
        cout<<sum<<endl;
        sum=sum2;
    }
}

Measured memory_bytes: 1784
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

paint [] t' tb s = s
paint (t : ts) t' 0 0 = paint ts t' 0 t'
paint (t : ts) t' tb s
  | t > tb + t' = paint ts t' t (s + t')
  | otherwise = paint ts t' t (s + t' - (tb + t' - t))

main = do
  [n, t] <- getIntList
  ts <- getIntList
  print $ paint ts t 0 0


Measured memory_bytes: 9716
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

X, K, D = MAP()

if X == 0:
	if K%2 == 0:
		print(0)
	else:
		print(D)
	exit()

flg = X//abs(X)
n = abs(X)//D

if abs(X-n*D*flg) > abs(X-(n+1)*D*flg):
	n += 1

if K <= n:
	print(abs(X-K*D*flg))
	exit()

X -= flg*n*D
if X == 0:
	flg = 1
else:
	flg = X//abs(X)
K -= n

if K%2 == 0:
	print(abs(X))
else:
	print(abs(X-flg*D))

Measured memory_bytes: 10540
package main

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

var sc = bufio.NewScanner(os.Stdin)
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextInt()
	b := nextInt()
	var ans int
	if (b-a)%2 == 0 {
		ans = (b - a) / 2
	} else {
		k := a - 1
		j := n - b
    var min int
		if k < j {
      min = k
		} else {
			min = j
		}
    ans = (min+1) + ((b-a-1)/2)
	}
	fmt.Println(ans)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int a[50][50];
int main(){
  int H,W;
  cin>>H>>W;
  vector<string> s(H);
  rep(i,H) cin>>s[i];
  rep(i,H){
    rep(j,W){
      if(s[i][j]=='#'){
        for(int k=-1;k<=1;k++){
          for(int l=-1;l<=1;l++){
            if(k!=0 || l!=0){
              int nh = i+k;
              int nw = j+l;
              if(0<=nh && nh<H && 0<=nw && nw<W)
                a[nh][nw]++;
            }
          }
        }
      }
    }
  }
  rep(i,H){
    rep(j,W){
      if(s[i][j]=='#') cout<<"#";
      else cout<<a[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if(x+r > w || y+r > h || x-r < 0 || y-r < 0)FIN("No");
	else FIN("Yes");
	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  n <- getInt
  ls <- getIntVec n

  let isGood i j k = let li = ls V.! i
                         lj = ls V.! j
                         lk = ls V.! k
                         [a, b, c] = sort [li, lj, lk]
                     in if a /= b && b /= c && c /= a && a + b > c
                        then 1 else 0

      ans = sum [ isGood i j k | i <- [0..(n-3)]
                               , j <- [(i+1)..(n-2)]
                               , k <- [(j+1)..(n-1)]]

  print ans

Measured memory_bytes: 5332
H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()
    if 0 <= h < H and 0 <= w < W and dst[h][w] < 0 and S[h][w] != '#':
        dst[h][w] = d
        for dh in range(-2, 3):
            for dw in range(-2, 3): # [dh,dw]:[-2,-2]~[2,2]
                if dh*dh + dw*dw < 1: continue
                if dh*dh + dw*dw > 1: dq.append((h + dh, w + dw, d+1))
                else: dq.appendleft((h + dh, w + dw, d))

print(dst[eh][ew])


Measured memory_bytes: 271996
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

/** Example:
 * input!(n: usize, s: chars, vs: [i64; n], ts: [(i64, f64); n]);
 * usize型の変数n, String型(実際は文字配列型)のs, Vector<i64>型のvs, tuple配列のtsに読み込まれる。
 */

fn main() {
    input!(n: usize, vs: [i64; n]);

    let mut odd = 0;
    let mut even = 0;
    let mut sum = 0;
    for i in 0..n {
        sum += vs[i];
        if i % 2 == 0 {
            if sum <= 0 {
                let diff = 1 + sum.abs();
                even += diff;
                sum += diff;
            }
        } else {
            if sum >= 0 {
                let diff = 1 + sum.abs();
                even += diff;
                sum -= diff;
            }
        }
    }

    sum = 0;
    for i in 0..n {
        sum += vs[i];
        if i % 2 != 0 {
            if sum <= 0 {
                let diff = 1 + sum.abs();
                odd += diff;
                sum += diff;
            }
        } else {
            if sum >= 0 {
                let diff = 1 + sum.abs();
                odd += diff;
                sum -= diff;
            }
        }
    }
    use std::cmp;
    println!("{}", cmp::min(odd, even));
}


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

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

int main(){
    int N;
    int A[100003];
    cin >> N;
    for(int i=0;i<=100002;i++) A[i]=0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        A[a]++;
        A[a+1]++;
        A[a+2]++;
    }
    sort(A,A+100003,greater<int>());
    cout << A[0] << endl;

    return 0;
}

Measured memory_bytes: 640
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>s;
		n=s.length();
		// ll a[n];
		vector<ll> a(n,0);
		i=0;
		ll x=0;
		while(i<n)
		{
			// x++;
			// if(x>10) break;
			j=i;
			while(s[j]=='R')
				j++;
			k=j;
			while(k<n && s[k]=='L')
				k++;
			c=j-i;
			cs=k-j;
			m=((c+cs)/2);
			if((c+cs)%2==0)
				a[j-1]=a[j]=m;
			else if(c%2==1)
			{
				a[j-1]=m+1;
				a[j]=m;
			}
			else
			{
				a[j]=m+1;
				a[j-1]=m;
			}
			// debug3(i,j,k);
			i=k;
		}
		for(auto c:a)
			cout<<c<<" ";
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1488
import Control.Monad
import Data.List as L
import Data.IntMap as M

primes :: Integral a => [a]
primes = takeWhile (<31623) $  [2, 3] ++ primes'
    where
      primes' = [5] ++ f 1 7 primes'
      f m s (p : ps) = [n | n <- ns, gcd m n == 1] ++ f (m * p) (p * p) ps
          where ns = [x + y | x <- [s, s + 6 .. p * p - 2], y <- [0, 4]]


fac :: [Integer]->M.IntMap Integer->Integer->M.IntMap Integer
fac _ m 1 = m
fac [] m n = M.insert (fromIntegral n) 1 m
fac pa@(p:pr) m n
    |mod n (fromIntegral p)==0=fac pa (M.insertWith(+) (fromIntegral p) 1 m) (div n (fromIntegral p))
    |otherwise =fac pr m n
 

invmod p g = invmod' 1 0 p 0 1 g
    where invmod' px py pgcd x y gcd
            | m==0 = mod (x+g) g
            | True = invmod' x y gcd (px - (d*x)) (py - (d*y)) m
            where
                m = mod pgcd gcd
                d = div pgcd gcd
 
divmod a b p = mod (a * invmod b p) p
 
cmbmod n k p = L.foldl' (\a i->divmod (mod (a*(n-i+1)) p) i p) 1 [1..k]
 
main=do
    (n:m:_)<-L.map read . words<$>getLine::IO[Integer]
    print $ sol n m
--
sol 1 _ = 1
sol _ 1 = 1
sol n m = L.foldl' (\a b -> (a * cmbmod (b+n-1) b 1000000007) `mod` 1000000007) 1 fm
    where fm = elems $ fac primes M.empty m

Measured memory_bytes: 1148
#include <stdio.h>
#include <string.h>
 
int main()
{
    int height[10];
    int i,j;
    int maxh,maxn;
    for(i = 0;i < 10;i++)
        scanf("%d",&height[i]);
    for(i = 0;i < 3;i++)
    {
        maxh = 0;
        for(j = 0;j < 10;j++)
        {
            if(height[j] > maxh)
            {
                maxh = height[j];
                maxn = j;
            }
        }
        printf("%d\n",maxh);
        height[maxn] = 0;
    }
    return 0;
}

Measured memory_bytes: 600
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

class Binary_Indexed_Tree():
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get(self, i):
        i += 1
        return self.sum_range(i, i)

    def sum(self, i):
        i += 1
        ret = 0
        while i:
            ret += self.data[i]
            i &= i-1
        return ret

    def sum_range(self, l, r):
        return self.sum(r)-self.sum(l-1)

n = int(input())
s = input()
m = 26
orda = ord("a")
segs = [Binary_Indexed_Tree(n) for i in range(m)]
s = list(map(lambda x: ord(x)-orda, list(s)))
for i, c in enumerate(s):
    segs[c].add(i,1)

q = int(input())
for _ in range(q):
    f,i,c = input().split()
    f = int(f)
    if f == 1:
        i = int(i)-1
        c = ord(c)-orda
        if s[i] != c:
            segs[s[i]].add(i, -1)
            s[i] = c
            segs[s[i]].add(i, 1)
    else:
        l = int(i)-1
        r = int(c)-1
        ans = 0
        for x in range(m):
            if segs[x].sum_range(l,r) > 0:
                ans += 1
        print(ans)



Measured memory_bytes: 180960
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007 //998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 100000000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
vector<int>adj[N];
int vis[N];
void dfs(int x)
{
    vis[x]=1;
    for(auto y:adj[x])
    {
        if(!vis[y])dfs(y);
    }
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   rep(i,0,m)
   {
       int u,v;
       cin>>u>>v;
       adj[u].pb(v);
       adj[v].pb(u);
   }
   int cc=0;
   for(int i=1;i<=n;i++)
   {
       if(!vis[i])
       {
           dfs(i);
           cc++;
       }
   }
   cout<<(cc-1)<<endl;
}


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

int main()
{
  int n,m;
  char s[100][11],t[100][11];
  int i,j;
  int yen,yen_max;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%s",s[i]);
  }
  scanf("%d",&m);
  for(i = 0;i < m;i++){
    scanf("%s",t[i]);
  }

  yen_max = 0;
  for(i = 0;i < n;i++){
    yen = 0;
    for(j = 0;j < n;j++){
      if(strcmp(s[i],s[j]) == 0){
        yen++;
      }
    }
    for(j = 0;j < m;j++){
      if(strcmp(s[i],t[j]) == 0){
        yen--;
      }
    }
    if(yen > yen_max){
      yen_max = yen;
    }
  }

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


Measured memory_bytes: 128
MAX = 99999999


def solve(dp):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

    return dp


def m():
    H, W = map(int, input().split())
    c = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]
    ans = [0 for _ in range(10)]
    # dp = [[MAX] * 10 for _ in range(10)]
    c = solve(c)

    for a in A:
        for i in a:
            if i != -1:
                ans[i] += 1

    cost = 0
    for i in range(10):
        cost += c[i][1] * ans[i]
    return cost


print(m())


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int n, l, r, i;
long long sum;
int main() {
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%d%d", &l, &r);
		sum += r - l + 1;
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int H, W;
  cin >> H >> W;
  vector<int> alphabet_count(26);
  rep(h, H) rep(w, W)
  {
    char c;
    cin >> c;
    alphabet_count[c - 'a']++;
  }
  int count4 = 0, count2 = 0;
  rep(i, 26)
  {
    count4 += alphabet_count[i] / 4;
    count2 += alphabet_count[i] / 2 - alphabet_count[i] / 4 * 2;
  }

  bool is_ok = true;
  if(count4 >= (H / 2) * (W / 2))
  {
    count4 -= (H / 2) * (W / 2);
    count2 += 2 * count4;
    if(H % 2 == 1 && W % 2 == 0)
    {
      if(count2 == W / 2)
        is_ok = true;
      else
        is_ok = false;
    }
    else if(H % 2 == 0 && W % 2 == 1)
    {
      if(count2 == H / 2)
        is_ok = true;
      else
        is_ok = false;
    }
    else if(H % 2 == 1 && W % 2 == 1)
    {
      if(count2 ==  (H / 2) + (W / 2))
        is_ok = true;
      else
        is_ok = false;
    }
  }
  else
  {
    is_ok = false;
  }

  if(is_ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        for (int i = 1; i <= 1009; i++){
            if ((int)(i * 0.08) == A && (int)(i * 0.1) == B){
                System.out.println(i);
                return;
            }
        }
        
        System.out.println(-1);
    }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for(llong i = 0; i < times; i++)
#define rloop(i, times) for(llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl <<msec << " msec" << endl;
}

#endif

struct Question
{
	llong l_index_;
	llong r_index_;
};

class ABC122C
{
public:
	ABC122C()
	{
		cin >> n_;
		cin >> q_;
		cin >> input_;

		q_collection_.resize(q_);
		loop(i, q_)
		{
			cin >> q_collection_[i].l_index_;
			cin >> q_collection_[i].r_index_;
		}
	}
	void Run(void)
	{
		CountAll();

		llong ans;
		for(const auto & e: q_collection_)
		{
			ans = count_ac_collection_[e.r_index_ - 1] - count_ac_collection_[e.l_index_ - 1];
			cout << ans << endl;
		}
	}
private:
	llong n_;
	llong q_;
	string input_;
	vector<Question> q_collection_;
	vector<llong> count_ac_collection_;
	/**
	@brief 全パターンのAC数をカウントする関数
	@note
	 count(s[l,r]) = count(s[0, r]) - count(s[0,l])となる。
	 (count()はACの個数、s[l,r]は範囲[l,r]で切り取った部分文字列)
	**/
	void CountAll(void)
	{
		count_ac_collection_.resize(n_);
		count_ac_collection_[0] = 0;
		count_ac_collection_[1] = CheckAC(0);
		for(llong i = 1; i < n_-1; i++)
			count_ac_collection_[i + 1] = count_ac_collection_[i] + CheckAC(i);
	}
	/**
	@brief AC文字列かどうか調べる関数
	@note
	 入力文字列のうち添字indexの箇所について"AC"文字列かどうか調べる。
	 範囲[index, index+1]が文字列"AC"だったらAC個数1を返す。
	 そうでなければ0を返す。
	**/
	llong CheckAC(llong index)
	{
		if (input_[index] == 'A' && input_[index+1] == 'C')
			return 1;
		return 0;
	}
};

int main()
{
//	ABC122B abc122b;
//	abc122b.Run();
	ABC122C abc122c;

	TimeStart();
	abc122c.Run();
	TimeEnd();

	return 0;
}

Measured memory_bytes: 3456
#!/usr/bin/python3

import numpy as np

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

    dp = np.full((N+1, N * (10**3) +1), np.inf)
    dp[0][0] = 0

    for i in range(N):
        weight, value = map(int, input().split())

        dp[i+1][:value] = dp[i][:value]
        dp[i+1][value:] = np.minimum(dp[i][value:], dp[i][:-value] + weight)


    res = 0
    for i, weight in enumerate(dp[N]):
        if weight <= W: res = i

    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 93068
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner (System.in);
		double a,b,c,d,e,f;

		while(sc.hasNextInt()){
			a=sc.nextInt();
			int tmp=(int) a;
			b=sc.nextInt();
			int tmp2=(int) b;
			c=sc.nextInt();
			int tmp3=(int) c;
			d=sc.nextInt();
			e=sc.nextInt();
			f=sc.nextInt();
			a*=d; b*=d; c*=d;
			d*=tmp;e*=tmp; f*=tmp;
			b-=e;c-=f;
			b=c/b;
			double ans=(tmp3-b*tmp2)/tmp;
			System.out.printf("%.3f %.3f\n",ans,b);
		}
	}
}

Measured memory_bytes: 18188
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 2000010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

int k;

int ans;

int a[MAXN];

char s[MAXN];

signed main() {
	int n = read();
	int l = 1, r = n;
	cin >> (s + 1);
	for (rr int i = 1; i <= n; i++) 
		if (s[i] == 'W') 
			a[i] = 1;
	while (l < r) {
		while (l < r && a[l] == 0) l++;
		while (l < r && a[r] == 1) r--;
		if (l < r) {
			swap(a[l], a[r]);
			ans++;
		}
	}
	cout << ans;
}

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

using namespace std;

typedef long long LL;

const int INF=0x3f3f3f3f;
const int maxn=105;

LL C[maxn][5];

LL dfs(string s,int k){
	if(k==0||s.length()==0)return 0;
	int n=s.length(),t=s[0]-'0';
	if(t==0)return dfs(s.substr(1),k);
	else return C[n-1][k]*pow(9,k)+(t-1)*C[n-1][k-1]*pow(9,k-1)+dfs(s.substr(1),k-1);
}

int main(){
	string s;
	int k;
	cin>>s>>k;
	int n=s.length();
	C[0][0]=1;
	for(int i=1;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i&&j<=3;j++){
			C[i][j]=C[i-1][j]+C[i-1][j-1];
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]!='0')cnt++;
	}
	if(cnt>=k)printf("%lld\n",dfs(s,k)+1);
	else printf("%lld\n",dfs(s,k));
	return 0;
}

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

int main() {
  int N, i;
  cin >> N ;
  
  vector<int> a(N);

  for (i = 0; i < N; i++)
    cin >> a[i];
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int alice = 0, bob = 0;
  
  for (i = 0; i < N; i++) {
    if ( i % 2 != 0) {
      bob+=a[i];
    } else {
      alice += a[i];
    }
  }
  
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define min(a,b) (a)<(b)?(a):(b)
int compare_int(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}
int main (void)
{
  int n,min,k;//配列のサイズ
  scanf("%d%d",&n,&k);
  int h[n];
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
  }

  qsort(h,n,sizeof(int),compare_int);
  min=h[k-1]-h[0];
  for(int i=k;i<n;i++){
    min=min(min,h[i]-h[i-k+1]);
  }
  printf("%d",min);
  return 0;
}


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

#define MAX2 501001
#define MAX 500001
#define NKMAX 101

int NK;
double dp[MAX2];
double p[NKMAX];

int S, N, K;

double calc(int a) {
	if (a == 0) return 0;
	double ans = 1;
	if (a <= MAX) {
		for (int i = 0; i < NKMAX; i++)
		{
			ans += dp[abs(a - i)] * p[i];
		}
		dp[a] = ans;
	}
	else ans = dp[MAX] + (a - MAX) / (N + 1.0) / K * 2;
	return ans;
}

int main() {
	cin >> S >> N >> K;
	S = abs(S);
	if (N == 1) {
		if (S % K == 0) cout << S / K << endl;
		else cout << -1 << endl;
		return 0;
	}
	p[0] = 1;
	for (int k = 0; k < K; k++)
	{
		for (int i = N * k; i >= 0; i--)
		{
			double move = p[i] / N;
			for (int j = 1; j <= N; j++)
			{
				p[i + j] += move;
			}
			p[i] = 0;
		}
	}

	for (int i = 1; i < MAX2; i++) dp[i] = 1e20;
	for (int i = 0; i < 10000; i++)
		for (int j = 1; j <= NKMAX; j++)
			calc(j);
	for (int i = 1; i <= MAX; i++) calc(i);

	printf("%.14f\n", calc(S));
	cin >> N;
}

Measured memory_bytes: 7132
string = gets.chomp.split("")
a = 0
z = 0

string.each_with_index do |s,idx|
  if s == "A"
    a = idx 
    break
  end
end

string.each_with_index do |s,idx|
  if s == "Z"
    z = idx
  end
end

p z -a + 1


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

/* define const */

/* finish defineing const */

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

  bool f = false;
  char c = s[0];
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    f = true;

  if (f) cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define mod 1000000007

long long dfs(int now, int pre, long long k, vector<vector<int>> &tree) {
    if (tree.at(now).size() > k-1) {
        return 0;
    }
    long long buf = 1;
    if (pre == -1) {
        buf = k-1;
    }
    else if (tree.at(now).size() == 1) {
        buf = 1;
    }
    else {
        for (int i=0; i<tree.at(now).size()-1; i++) {
            buf *= k-2-i;
            buf %= mod;
        }
    }
    for (int x : tree.at(now)) {
        if (x == pre) continue;
        else {
            buf *= dfs(x, now, k, tree);
            buf %= mod;
        }
    }
    return buf;
}

int main() {
    long long n = 0, k = 0;
    cin >> n >> k;
    if (n == 1) {
        cout << k << endl;
        return 0;
    }
    vector<vector<int>> tree(n);
    int a = 0, b = 0;
    for (int i=0; i<n-1; i++) {
        cin >> a >> b;
        a--;
        b--;
        tree.at(a).push_back(b);
        tree.at(b).push_back(a);
    }
    int start = 0;
    for (int i=0; i<n; i++) {
        if (tree.at(i).size() == 1) {
            start = i;
            break;
        }
    }
    long long ans = k * dfs(start, -1, k, tree);
    cout << ans%mod << endl;
    return 0;
}


Measured memory_bytes: 13568
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1611&lang=jp
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int n;
    while(cin >> n, n)
    {
        int dp[305][305] = {};
        vector<int> w(n);

        for(auto& _w : w)
        {
            cin >> _w;
        }

        for(int b = 2; b <= n; b++)
        for(int l = 0; l < n; l++)
        {
            int r = l + b - 1;
                if( r >= n )break;

                if( abs(w[l] - w[r]) <= 1 && dp[l + 1][r - 1] == r - l - 1)
                {
                    dp[l][r] = r - l + 1;
                }
                else
                for(int k = l; k < r; k++)                
                {
                    dp[l][r] = max( dp[l][r], dp[l][k] + dp[k + 1][r] );
                }
        }
        cout << dp[0][n - 1] << endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

typedef long long ll;

int main() {
    double n;
    cin>>n;
    int k=n/1.08;
    if(int(k*1.08)==n) cout<<k<<endl;
    else if(int((k+1)*1.08)==n) cout<<k+1<<endl;
    else cout<<":(";

    return 0;
}

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

int x_func(int x)
{
    int temp = x, result = 0;
    while(temp != 0)
    {
        result = result + (temp % 10);
        temp = temp / 10;
    }

    return result;
}

int main()
{
    int N; cin >> N;
    int x_func_result = x_func(N);

    string result = (N % x_func_result == 0)? "Yes" : "No";
    cout << result << endl;

    return 0;
}


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

int main() 
{
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    
    int sum1 = H2 - H1;
    int sum2 = M2 - M1;
    int sum3 = sum1*60 + sum2 - K;
    cout << sum3 << endl;
}

Measured memory_bytes: 3636
import bisect
n = int(input())
A = list(map(int,input().split()))
A.sort()
if n == 2:
  ans = [A[1],A[0]]
  print(*ans)
  exit()
MAX = A[-1]
target = MAX//2
ok = 0
ng = n
while abs(ok-ng)>1:
  mid = (ok+ng)//2
  if A[mid] <= target:
    ok = mid
  else:
    ng = mid
ans = [MAX,A[ok]]

nxt = ok+1
#print(A[nxt])
if nxt < n:
  dif0 = min(MAX-A[ok],A[ok])
  dif1 = min(MAX-A[nxt],A[nxt])
  if dif0 < dif1:
    ans[1] = A[nxt]
print(*ans)

Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int N = 1e5 + 1;

int32_t main(){
 	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
 	int n ;
 	cin >> n;
 	int a[n + 1] , b[n + 1] , c[n + 1];

 	for(int i = 1 ; i <= n ; i++) cin >> a[i];
 	for(int i = 1 ; i <= n ; i++) cin >> b[i];
 	for(int i = 1 ; i < n ; i++) cin >> c[i];

 	int sum = b[a[1]];

 	for(int i = 2 ; i <= n ; i++){
 		sum += b[a[i]];
 		if(a[i] - a[i - 1] == 1) sum += c[a[i - 1]];
 	}
 	cout << sum << endl;

 return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <iostream>
#include <cstdlib>
using namespace std;

struct Node {
    int key;
    Node *left,*right,*parent;
};

Node *gRoot,*NIL;

Node* getMinimumTree(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}

Node* getTreeSuccessor(Node *x){
    if(x->right != NIL)return getMinimumTree(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
}

void deleteTree(Node *z){
    Node *y;    // 削除対象Node
    Node *x;    // yの子
    
    // 子がない場合はまたは一つしか子がない場合は対象の節点をそのまま消す
    if(z->left == NIL || z->right == NIL){
        y = z;
    }
    else{
        y = getTreeSuccessor(z);
    }
    
    // yの子xを求める
    if(y->left != NIL){
        x = y->left;
    }
    else{
        x = y->right;
    }
    
    if(x != NIL){
        x->parent = y->parent;
    }
    
    if(y->parent == NIL){
        gRoot = x;
    }else{
        if(y == y->parent->left){
            y->parent->left = x;
        }else{
            y->parent->right = x;
        }
    }
    
    if(y != z){
        z->key = y->key;
    }
    free(y);
}

Node *find(Node* u,int value){
    while(u != NIL && value != u->key){
        if(value < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int value){
    Node *y = NIL;
    // 親
    Node *x = gRoot;
    // 自身
    Node *z;
    z = (Node*)malloc(sizeof(Node));
    z->key = value;
    z->left = NIL;
    z->right = NIL;
    
    // rootから自身を挿入する場所を探す
    while(x != NIL){
        // rootから検索
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    // 親に子を持たせる
    if(y == NIL){
        gRoot = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}
// 先行順巡回
void preOrder(Node *u){
    if(u == NIL)return;
    printf(" %d",u->key);
    preOrder(u->left);
    preOrder(u->right);
}

// 中間順巡回
void inOrder(Node *u){
    if(u == NIL)return;
    inOrder(u->left);
    printf(" %d",u->key);
    inOrder(u->right);
}

int main(){
    int n,x;
    string com;
    
    cin >> n;
    for(int i = 0;i < n;++i){
        cin >> com;
        if(com[0] == 'f'){
            cin >> x;
            Node *t = find(gRoot,x);
            if(t != NIL) cout << "yes\n";
            else cout << "no\n";
        }
        if(com == "insert"){
            cin >> x;
            insert(x);
        }
        else if(com == "print"){
            inOrder(gRoot);
            cout << "\n";
            preOrder(gRoot);
            cout << "\n";
        }
        else if(com == "delete"){
            cin >> x;
            deleteTree(find(gRoot,x));
        }
    }
    return 0;
}



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

const long long INF = 1LL << 60;

int main() {
    int N, M, sum = 0; cin >> N;
    vector<int> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T.at(i);
        sum += T.at(i);
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        int p, x; cin >> p >> x;
        cout << sum - T.at(p-1) + x << endl;
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eb emplace_back
#define eps 1e-10
#define F first
#define S second

int main() { //cast caution
    ll w, h, x, y; cin >> w >> h >> x >> y;
    printf("%.10lf %d\n", w * h / 2.0, x * 2 == w && y * 2 == h);
    //cout << w * h / 2.0 << " " << (x * 2 == w && y * 2 == h) << endl;
}




Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np 
def main():
    H, W = map(int, readline().split())
    G = np.zeros((H+2, W+2), np.int16)
    G[1:-1, 1:] = (np.frombuffer(read(H*(W+1)), dtype='B') == ord('.')).reshape((H, W+1))
    def solve(G):
        
        left = np.arange(G.shape[1], dtype=np.int16)*np.ones(G.shape, dtype=np.int16)
        left[G>0] = 0
        np.maximum.accumulate(left, out=left, axis=1)

        rG = G[..., ::-1]
        right = np.arange(G.shape[1], dtype=np.int16)*np.ones(G.shape, dtype=np.int16)
        right[rG>0] = 0
        np.maximum.accumulate(right, out=right, axis=1)

        right = G.shape[1] - right[..., ::-1]-1
        scoreres = (right-left-1) 
        scoreres[G==0] = 0
        return scoreres

    print((solve(G)+solve(G.T).T-1).max())
if __name__ == '__main__':
    main()


Measured memory_bytes: 59440
#include <iostream>
using namespace std;
int main()
{
	int n = 0, x;
	int max_profit = -2e9, min;
	cin >> n;
	cin >> min;
	n--;
	while (n--)
	{
		cin >> x;
		max_profit = x - min > max_profit ? x - min : max_profit;
		min = x < min ? x : min;
	}
	cout << max_profit << endl;
	return 0;
}


Measured memory_bytes: 3136
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

putListWithSpace :: Show a => [a] -> IO ()
putListWithSpace [a] = putStr $ show a
putListWithSpace (a:as) = do
  putStr $ show a
  putStr " "
  putListWithSpace as

main = do
  [n] <- readInt
  as <- readInt
  putListWithSpace $ solve n as

solve n as = f x1 as [x1]
  where
    s = sum as
    x1 =
      s -
      2 *
      sum
        (map
           (\(aa, i) ->
              if even i
                then aa
                else 0) $
         zip as [1 ..])

f _ [_] acc    = reverse acc
f x (a:as) acc = f (2 * a - x) as (2 * a - x : acc)


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

int n = 0 ;
int num[200] = {0} ;

int solve()
{
  int ans = 0 ;
  bool flg = false ;
  while (1)
  {
    //check
    for ( int i = 0 ; i < n ; i++ )
    {
      if ( num[i] % 2 )
      {
        flg = true ;
        break ;
      }
    }
    if ( flg ) break ;
    //divide by 2
    for ( int i = 0 ; i < n ; i++ )
    {
      num[i] /= 2 ;
    }
    ans++ ;
  }
  return ans ;
}

int main()
{
  cin >> n ;
  for ( int i = 0 ; i < n ; i++ )
  {
    cin >> num[i] ;
  }
  printf("%d\n", solve()) ;
  return 0 ;
}


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

int main(){
  int N,K; cin >> N >> K;
  int A[200000];
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A,A+N);
  int count=1;
  int cur=0;
  int num[200000];
  for(int i=1; i<N; i++){
    if(A[i-1]==A[i]){
      count++;
    }else{
      num[cur]=count;
      cur++;
      count=1;
    }
  }
  num[cur]=count; cur++;
  sort(num,num+cur); reverse(num,num+cur);
  count=0;
  for(int i=0; i<min(cur,K); i++){
    count+=num[i];
  }
  cout << N-count << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

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

int main() {
  string s;
  cin >> s;
  int cnt = 0, m = 0, res = 0;
  for (auto c : s) {
    if (c == 'R') {
      cnt++;
      m = cnt;
    }
    else if (c == 'S') cnt = 0;
    res = max(cnt, m);
  }
  cout << res << endl;  
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    if(a < b){
        REP(i,b){
            cout << a;
        }
        cout << endl;
    }
    else{
        REP(i,a){
            cout << b;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
num=0
for i in range(1,n-1):
    if p[i-1] < p[i] and p[i] < p[i+1]:
        num=num+1
    elif p[i-1] > p[i] and p[i] > p[i+1]:
        num=num+1
    else:
        num=num
print(num)

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

int main() {
  int n; cin >>n;
  string s; cin >>s;
  
  for (int i=0; i<s.size(); i++){
    s.at(i) += n;
    if (s.at(i) >= 91){
      s.at(i) -= 26;
    }
  }
  
  cout <<s <<endl;
}


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

using namespace std;

int main(){
	int N, K;

	cin >> N >> K;

	double sum = 0;
	double invN = 1/(double)N;

	for(int i = 0; i < N; i++){
		if(i+1 < K)
			sum += invN * pow(0.5, ceil(log2((double)K/(double(i+1)))));
		else
			sum += invN;
	}
	cout << setprecision(12) << sum <<endl;
}

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

#pragma GCC optimize("O3")

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

int main() {
    string s;
    cin >> s;
    cout << string(s.size(), 'x');
    
    return 0;
}


Measured memory_bytes: 3608
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{	
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      
		String S= br.readLine();
		String T= br.readLine();
		String ans="";
		
		char ch[]=S.toCharArray();
		char ch1[]=T.toCharArray();
		boolean flag=true;
		
		
		for(int i=0;i<ch.length;i++)
		{
			if(ch[i]!=ch1[i])
			{
				flag=false;
				break;
			}
		}
		
		ans = flag==true? "Yes" : "No";
			
		out.println(ans);
		
	}
	
	
}




Measured memory_bytes: 32508
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    n, m = reads();
    g = [set() for _ in range(n+1)]
    for _ in range(m):
        a, b = reads()
        g[a - 1].add(b - 1)
        g[b - 1].add(a - 1)
    
    count = 0
    q = [(0, [])]
    while q:
        i, p = q.pop(0)
        if len(p) == (n-1):
            count += 1
        for e in g[i]:
            if e in p:
                continue
            pp = p[:]
            pp.append(i)
            q.append((e, pp))
    print(count)
 
main()


Measured memory_bytes: 4084
#include <stdio.h>

int main(){
  char line[100];
  int x, y;
  int count=0;
  int tmp;
  while(1){
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%d %d", &x, &y);
	if((x==0)&&(y==0))
	  break;
	++count;
	if(x>y){
	  tmp=x;
	  x=y;
	  y=tmp;
	}
	  
	printf("%d %d\n", x, y);
  }
  return 0;
}



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

const int mod = pow(10, 9) + 7;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a) {
        if((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a) {
        if((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if(!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if(t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

mint factorial(ll n) {
    mint res = 1;
    for(ll i = 1; i <= n; i++) {
        res = res * i;
    }
    return res;
}

int main() {
    int X, Y;
    cin >> X >> Y;
    if((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll steps = (X + Y) / 3;
    // ll diff = X - Y;
    // ll n = (steps - abs(diff)) / 2 + diff;
    // ll m = (steps - abs(diff)) / 2 - diff;
    ll n = X - steps;
    ll m = Y - steps;

    if(n < 0 || m < 0){
        cout << 0 << endl;
        return 0;
    }

    // cout << "n:" << n << " m:" << m << endl;

    mint c = factorial(m + n) / (factorial(n) * factorial(m));

    cout << c.x << endl;
}

Measured memory_bytes: 256