akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const int N = 2e6+5;

int used[N];

void solve(){
	int n;
	cin>>n;
	int a[n],cnt=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]>=3200)cnt++;
		int x=a[i]/400;
		used[x]=1;
	}
	int res=0;
	for(int i=0;i<8;++i){
		//cerr<<(i+1)*400-1<<' ';
		if(used[i])res++;
	}
	cout<<(res?res:(cnt?1:0))<<' '<<res+cnt;
}

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

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	Int n;
	Int ans[112345];
	cin >> n;
	RC(i, n){
		Int a;
		cin >> a;
		ans[a - 1] = i + 1;
	}
	RC(i, n) printf("%d%c", ans[i], " \n"[i == n - 1]);
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const long long INF = 1e9 + 7;

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

    int n,m;
    cin >> n >> m;
    int a[m];
    vector<bool> flag(n+1, true);
    rep(i,m){
        cin >> a[i];
        flag[a[i]] = false;
    }
    
    vector<ll> dp(n+1,0);
    
    dp[0] = 1;
    if(flag[1]) dp[1] = 1;
    
    for(int i=2;i<=n; i++){
        if(flag[i-1]) dp[i] += dp[i-1];
        if(flag[i-2]) dp[i] += dp[i-2];
        
        dp[i] %= INF;
    }
    
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,ce=0,cf=0;
  cin>>n;
  ll a[n],e[n],f[n];
  cin>>a[0];
  e[0]=a[0];
  f[0]=a[0];
  if(e[0]<1){
    e[0]=1;
    ce+=1-a[0];
  }
  if(f[0]>-1){
    f[0]=-1;
    cf+=a[0]+1;
  }
  for(int i=1;i<n;i++){
    cin>>a[i];
    e[i]=e[i-1]+a[i];
    f[i]=f[i-1]+a[i];
    if(i%2==1){
      if(e[i]>-1){
        ce+=e[i]+1;
        e[i]=-1;
      }
      if(f[i]<1){
        cf+=1-f[i];
        f[i]=1;
      }
    }else{
      if(f[i]>-1){
        cf+=f[i]+1;
        f[i]=-1;
      }
      if(e[i]<1){
        ce+=1-e[i];
        e[i]=1;
      }
    }
  }
  cout<<min(ce,cf);
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n;
    cin >> n;
    repi(i,n,0){
        int a;
        cin >> a;
        if(a&1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--

main = do
  i <- getI
  if i == 1 then putStrLn "Hello World"
  else foldr1 (+) <$> replicateM 2 getI >>= putStrLn . show


Measured memory_bytes: 508
a, b, x = map(int, input().split())
ax = a // x
bx = b // x
if a % x == 0 or b % x == 0:
    if a % x != 0 and b % x == 0:
        print(bx - ax)
    else:
        print(bx - ax + 1)
else:
    print(bx - ax)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

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

	int a = x / 500;
	x -= a * 500;
	int b = x / 5;
	long res = (long)a * 1000L + (long)b * 5L;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

  int n,num[25],max[25],sum;

  while(1){
   
    cin >>n;
    
    if(n == 0)break;

    for(int i=0 ; i < n ; i++)cin >>num[i]>>max[i];
    
    for(int i=n-1 ; i > 0 ; i--){
      for(int j=0 ; j < i ; j++){
	if(max[j] > max[j+1]){
	  swap(max[j],max[j+1]);
	  swap(num[j],num[j+1]);
	}
      }
    }
    
    sum=0;
    bool a=true;
    
    for(int i=0 ; i < n ; i++){
      sum+=num[i];
      if(sum > max[i])a=false;
    }
 
    if(a){
      cout <<"Yes"<<endl;
    }else{
      cout <<"No"<<endl;
    }
   
  }  
  
  return 0;
}

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

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

    string s[n];
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s, s + n);

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

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
	
int n;
scanf ("%d", &n);
 
int bilangan = 0;
 // harus dibawah 10 
for (int i = 1; i < 10; i++){ // bilanagn yang pertama
	for (int j = 1; j < 10; j++){ // bilangan yang ke -2 
		
		if (n == i * j){
			bilangan = 1;
			break;
		}
}
/* If N can be represented as the product of two integers between 1 and 9 (inclusive), print Yes; if it cannot, print No.
 */
	}
	if (bilangan == 1){
		puts ("Yes");
	}
	else if (bilangan == 0) {
		puts ("No");
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			swap(p.at(i), p.at(j));
			bool flag = true;
			for (int k = 0; k < n - 1; k++) {
				if (p.at(k) > p.at(k + 1)) flag = false;
			}
			if (flag) {
				cout << "YES" << endl;
				return 0;
			} else {
				swap(p.at(i), p.at(j));
			}
		}
	}
	cout << "NO" << endl;
}


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

using namespace std;
int main(){
    int n,y,a,b,c;
    scanf("%d %d",&n,&y);
    bool flag = 0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if(i*10000+j*5000+(n-i-j)*1000 == y){
                flag = 1;
                a = i;
                b = j;
                c = n-i-j;
                goto label;
            }
        }
    }
    label:
    if (!flag){
        cout << -1 << " " << -1 << " " << -1 << endl;
        return 0;
    }
    cout << a << " " << b << " " << c << endl;



}


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

int main()
{
    int n, k;
    std::cin >> n >> k;

    std::vector<int> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    long long ans = 0;
    for (int num_pop = 0; num_pop <= k; num_pop++) {
        for (int pop_from_right = 0; pop_from_right <= num_pop; pop_from_right++) {
            std::vector<int> copied_v = v;
            std::priority_queue<int, std::vector<int>, std::greater<int>> q;
            for (int i = 0; copied_v.size() && i < pop_from_right; i++) {
                q.push(copied_v.back());
                copied_v.pop_back();
            }

            std::reverse(copied_v.begin(), copied_v.end());
            for (int i = 0; copied_v.size() && i < num_pop - pop_from_right; i++) {
                q.push(copied_v.back());
                copied_v.pop_back();
            }

            int num_push = k - num_pop;

            while (q.size() && q.top() < 0 && num_push > 0) {
                q.pop();
                num_push--;
            }

            long long sum = 0;
            while (q.size()) {
                sum += q.top();
                q.pop();
            }

            if (ans < sum) {
                ans = sum;
            }
        }
    }

    std::cout << ans << std::endl;
}


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

int main()
{
	int x, y, s;
	int ans, tmp, t1, t2;
	double xx, yy;
	while (scanf("%d%d%d", &x, &y, &s) && x) {
		ans = tmp = t1 = t2 = 0;
		xx = 1 + x / 100.0;
		yy = 1 + y / 100.0;
		for (int t1 = 1; t1 < s; t1++) {
			for (int t2 = 1; t2 < s; t2++) {
				tmp = (int)(t1 * xx + 0.00001) + (int)(t2 * xx + 0.00001);
				if (tmp == s) {
					tmp = (int)(t1 * yy + 0.00001) + (int)(t2 * yy + 0.00001);
					if (tmp > ans)
						ans = tmp;
				} else if (tmp > s)
					break;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2040
MAX_X = 10 ** 5 + 100

def main():
    N, M = [int(i) for i in input().split()]
    X = [0] * (MAX_X + 1)
    for i in map(int, input().split()):
        X[i] += 1
    Y = [sum(X[i::M]) for i in range(min(M, MAX_X))]
    # Mの倍数    
    ans = Y[0] // 2
    Y[0] = 0
    # M%2==0のM/2
    if M % 2 == 0:
        ans += Y[M//2] // 2
        Y[M//2] = 0    
    for i in range(1, M//2+1):
        j = M - i
        tmp = min(Y[i], Y[j])
        ans += tmp
        Y[i] -= tmp
        Y[j] -= tmp
    try:
        for i, n in enumerate(X):
            j = i % M
            if Y[j] < 2 or n < 2:
                continue
            tmp = min(Y[j]-Y[j]%2, n-n%2)
            ans += tmp // 2
            Y[j] -= tmp
    except IndexError:
        print(-1)
    print(ans)

if __name__ == "__main__":
    main()


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

signed main(void)
{
	int n;
	cin >> n;
	vector<pair<int, int>> p;
	map<pair<int, int>, ll> diff;
	ll mx, ans;

	rep(i, n) 
	{
		int a, b; 
		cin >> a >> b;
		p.push_back(make_pair(a, b));
	}
	sort(p.begin(), p.end());
	rep(i, n - 1)
	{
		for(int j = i + 1; j < n; j++)
		{
			diff[make_pair(p[j].first - p[i].first, \
							p[j].second - p[i].second)]++;
		}
	}
	mx = 0;
	for(auto p : diff)
	{
		mx = max(mx, p.second);
	}
	ans = n - mx;	
	cout << ans << endl;	
	return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    def extgcd1(a0,b0):#計算量log(b0),フェルマーの小定理より早い
        u,v,a,b=1,0,a0,b0
        while b: t=a//b; a-=t*b; a,b=b,a; u,v=v,u-t*v
        if a!=1: return -1#互いに素じゃない
        return u%b0
    
    maxn=N
    fact=[1]*(maxn+1)#NはnCrの最大のn
    ifact=[1]*(maxn+1)
    x=1
    for i in range(2,maxn+1):
        x=(x*i)%mod
        fact[i]=x; ifact[i]=extgcd1(x,mod)
    def perm(n,r): return fact[n]*ifact[n-r]%mod
    def comb(n,r): return (fact[n]*ifact[r]%mod)*ifact[n-r]%mod
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    for i in range(1,K+1):
        if i-1>N-K:
            print(0)
            continue
        #printe(N-K+1,i-1,comb(N-K+1,i+1))
        print(comb(K-1,i-1)*comb(N-K+1,N-K-i+1)%mod)





if __name__ == "__main__":
    main()

Measured memory_bytes: 79480
import java.util.Scanner;

public class Main {


    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    	int W = sc.nextInt();
    	int H = sc.nextInt();
    	int x = sc.nextInt();
    	int y = sc.nextInt();
    	int r = sc.nextInt();
    	if(W >= x + r && H >= y + r)
    	{
        	if(0 <= x - r && 0 <= y - r)
        	{
        		System.out.println("Yes");
        	}
        	else
        	{
        		System.out.println("No");
        	}
    	}
    	else
    	{
    		System.out.println("No");
    	}
        sc.close();
    }

}

Measured memory_bytes: 26328
h,w = map(int, input().split())
s = [h//2+w//3+1, h//3+w//2+1, h, w]
if h%3 == 0 or w%3 == 0:
  s += [0]
if h%2 == 0:
  s += [h//2]
if w%2 == 0:
  s += [w//2]
print(min(s))

Measured memory_bytes: 3064
n,m = map(int,input().split())
l1 = []
l2 =[]
for i in range(m):
    l,r = list(map(int,input().split()))
    l1.append(l)
    l2.append(r)
ans = min(l2) - max(l1) + 1
if ans >0:
    print(ans)
else:
    print(0)

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

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

	unsigned long long ans = n - 1;
	unsigned long long max = (long)(n / 2);

	for (unsigned long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			unsigned long long a = n / i;
			if (ans == 0 || ans > (i - 1 + a - 1)) {
					ans = i - 1 + a - 1;
				}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.Arrays;

public class Main{

	public static void main(String[] args) throws IOException{
	
	try{
		
		int maxN = 1000000;
		boolean isPrime[] = new boolean [maxN];
		int prime[] = new int [maxN];
		int  cnt = 0;
		
		//isPrime????????????
		for(int i = 0; i < maxN; i++){
			isPrime[i] = true;
		}
		
		isPrime[0] = false;
		isPrime[1] = false;
		prime[0] = 0;
		prime[1] = 0;
		
		//maxN=1000000??\????????????????????????????????°??\???????´???°????????°?????????????±???????
	    for(int i = 2; i < maxN; i++){
	    	if(isPrime[i]){
	    		cnt++;
	    		//j????????°????´???°??§??????????????¨?????????????????????????????????
	    		for(int j = 2; j*i < maxN; j++){
	    			isPrime[j*i]=false;
	    		}
	    	}
    		//i??\???????´???°????????°???????´???????
    		prime[i]=cnt;
	    }
		
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String str;
        while( (str = br.readLine() ) != null ){
        	System.out.printf("%d\n",prime[Integer.parseInt(str)]);
        }
	}
	catch(Exception e){
		//System.out.println(e);
	}
	}			
}

Measured memory_bytes: 30108
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let i:String = read();
    let ans:i32 = i.chars().map(|x| x.to_digit(10).unwrap() as i32).collect::<Vec<i32>>().iter().sum();
    println!("{}",ans);
}   

Measured memory_bytes: 4352
a = input("").split(" ")
a = [int(aa) for aa in a]
H = a[0]
W = a[1]
if H == 1 or W == 1:
    print("1")
elif H % 2 == 0:
    print(str(int(H/2)*W))
elif W % 2 == 0:
    print(str(int(W/2)*H))
else:
    p = int((H+1)/2)
    q = int((W+1)/2)
    print(str(p*q+(p-1)*(q-1)))

Measured memory_bytes: 8952
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
unsigned long long c[100000];

int main() {
	int n;
	cin >> n;
	if (n <= 999)cout << "ABC";
	else cout << "ABD";
}


Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

from collections import Counter

def c2s(c):
    s = ''
    for key, val in c:
        # print(key, val)
        # s = f'{s}{key}{val}'
        s = '{}{}{}'.format(s, key, val)
    # print(s)
    return s

def choose2(n):
    if n == 1:
        return 0
    return n * (n - 1) // 2

def solve():
    n = II()
    S = [list(input()) for _ in range(n)]

    jisho = {}
    for s in S:
        c = sorted(Counter(s).items(), key=lambda x: x[0])
        # print(c)
        key = c2s(c)
        jisho[key] = jisho.setdefault(key, 0) + 1
    # print(jisho)
    ans = 0
    for val in jisho.values():
        ans = ans + choose2(val)

    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 40016
N = input()
integers=list(map(int, input().split()))
count = 0

def Judge(integersList):
    for i in range(len(integersList)):
        if integersList[i]%2 == 0:
            pass
        else:
            return False
    return True

while True:
    if Judge(integers):
        for i in range(len(integers)):
            replacement = integers[i]/2
            integers[i] = replacement
        count+=1
    else:
        break

print(count)

Measured memory_bytes: 3060
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C, X, Y;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
    go;
    cin >> X >> Y;
    if(abs(X - Y) <= 1) {
    	cout << "Brown\n";
    }
    else {
    	cout << "Alice\n";
    }

	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

#define int long long int
#define mp make_pair
using namespace std;

const int N = 2e5;
vector <int> v[N+2];
int value[N+2];
bool visited[N+2];

void dfs(int source , int prev)
{
    visited[source] = true;
    value[source] += prev;
    for (int i = 0; i < v[source].size(); ++i) {
        if(visited[v[source][i]] == false){
            dfs(v[source][i] , value[source]);
        }
    }
    return ;
}

int32_t main() {
    int n,q;
    scanf("%lld", &n);
    scanf("%lld", &q);
    for (int i = 0; i < n-1; ++i) {
        int a,b;
        scanf("%lld", &a);
        scanf("%lld", &b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for (int i = 0; i < q; ++i) {
        int p,x;
        scanf("%lld", &p);
        scanf("%lld", &x);
        value[p] += x;
    }
    memset(visited , false , sizeof visited);
    dfs(1 , 0);
    for (int i = 1; i <= n; ++i) {
        printf("%lld ",value[i]);
    }
    return 0;
}

Measured memory_bytes: 24448
# -*- coding: utf-8 -*-

import itertools

def main():
     n = int(input())
     p = list(map(int, input().split()))
     q = list(map(int, input().split()))

     num = [x + 1 for x in range(n)]
     p_list = list(map(list, (itertools.permutations(num))))
     # print(p_list)
     idx_p = p_list.index(p)
     idx_q = p_list.index(q)

     print(abs(idx_p - idx_q))

if __name__ == "__main__":
    main()


Measured memory_bytes: 10228
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define AI 10000

main(){
  unsigned short *A,*B;

  int C[AI+1];
  int n,i,j;
  
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=AI;i++)C[i]=0;

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=AI;i++)C[i]=C[i]+C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

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

    long double a[n];
    string b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    long double sum = 0;
    for(int i = 0; i< n; i++){
        if(b[i] == "JPY"){
            sum += a[i];
        }
        else {
            sum += a[i] * 380000.0;
        }
        //cout << sum << endl;
    }

    cout << sum << endl;

}

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

int main(){
    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;

    int ans = min(A, K);
    K -= ans;
    K -= min(K, B);
    ans -= K;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
N, A, B, C = list(map(int, input().split()))
l = [0]*N
for i in range(N):
    l[i] = int(input())


def dfs(a, b, c, i):
    if i == N:
        if a == 0 or b == 0 or c == 0:
            return 1e9

        return abs(A - a) + abs(B - b) + abs(C - c)

    dfs_not_used = dfs(a, b, c, i+1)
    dfs_A = dfs(a+l[i], b, c, i+1) + + 10*(a != 0)
    dfs_B = dfs(a, b+l[i], c, i+1) + 10*(b != 0)
    dfs_C = dfs(a, b, c+l[i], i+1) + 10*(c != 0)

    return min(dfs_not_used, dfs_A, dfs_B, dfs_C)


ans = dfs(0, 0, 0, 0)
print(ans)


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

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

  string s; cin >> s;

  int a, z;
  rep(i, si(s)) {
    if (s[i] == 'A') {
      a = i;
      break;
    }
  }

  rep3(i, si(s), 0) {
    if (s[i] == 'Z') {
      z = i;
      break;
    }
  }

  cout << z - a + 1 << endl;
  
  return (0);
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
  int N; cin>>N;
  string blue[N];
  for(int i=0; i<N; i++) cin>>blue[i];
  int M; cin>>M;
  string red[M];
  for(int i=0; i<M; i++) cin>>red[i];
  map<string, int> okane;
  for(int i=0; i<N; i++){
    if(okane.count(blue[i])) okane[blue[i]]++;
    else okane[blue[i]]=1;
  }
  for(int i=0; i<M; i++){
    if(okane.count(red[i])) okane[red[i]]--;
  }
  int max=0;
  for(auto p:okane){
  auto v = p.second;
  if(v>max) max=v;
  }
  if(max<0) cout<<0<<endl;
  else cout<<max<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
    int n,x,t;cin >> n >> x >> t;
    int ans = (n/x)*t;
    if(n%x != 0) ans+=t;
    cout << ans << endl;
}



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

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

ll n, x;
vector<int> g[mnx];

ll dfs(int v){
    vector<int> q;
    for(auto to : g[v]){
        q.push_back(dfs(to));
    }
    sort(q.begin(), q.end());
    reverse(q.begin(), q.end());
    int ans = g[v].size();
    for(int i = 0; i < q.size(); i++){
        ans = max(ans * 1LL, 1LL * (q[i] + i + 1));
    }
    return ans;
}

int main() {

cin >> n;

for(int i = 2; i <= n; i++){
    cin >> x;
    g[x].push_back(i);
}

cout << dfs(1) << '\n';

return 0;

}


Measured memory_bytes: 36224
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int n,k;  cin>>n>>k;
  string s; cin>>s;
  vector<int> v;
  if(s[0]=='0') v.pb(0);
  for(int i=0 ; i<n ; ){
    int j=i;
    while(s[i]==s[j] && j<n) j++;
    v.pb(j-i);
    i = j;
  }
  if(s.back()=='0') v.pb(0);
  vector<ll> sum(v.size()+1, 0);
  rep(i,0,v.size()){
    sum[i+1] = sum[i] + v[i];
  }
  ll ma=-1;
  for(int i=0 ; i<sum.size() ; i+=2){
    int left= (i+2*k+1>=sum.size() ? sum.size()-1 : i+2*k+1);
    chmax(ma, sum[left] - sum[i]);
  }
  cout << ma << endl;
  return 0;
}


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

using namespace std;

int main(){

	int sum;
	while(cin >> sum && sum != 0){
		int sum2 = 0;
		for(int i = 0; i < 9; i++){
			int tmp;
			cin >> tmp;
			sum2 += tmp;
		}
		cout << sum - sum2 << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pii pair<ll,ll>
#define ff first
#define ss second
#define mxx 100005
#define endl "\n"
const ll mod=1e9+7;

ll a=1e18;

int main()
{
    ll n,k;
    cin>>n>>k;

    map<ll,ll>mp;
    while(k--)
    {
        ll x;
        cin>>x;
        for(int i=0; i<x; i++)
        {
            ll b;
            cin>>b;
            mp[b]=x;
        }
    }

    ll ans=0;
    for(int i=1; i<=n; i++)
    {
        if(!mp[i])
            ans++;
    }

    cout<<ans<<endl;

    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int h, w, n, sr, sc;
    string s, t;
    cin >> h >> w >> n >> sr >> sc >> s >> t;
    sr--;
    sc--;

    int u = -1, d = h, l = -1, r = w;
    string ans = "YES";

    RREP(i, n){
        switch(t[i]){
            case 'U':
                d = min(h, d + 1);
                break;
            case 'D':
                u = max(-1, u - 1);
                break;
            case 'L':
                r = min(w, r + 1);
                break;
            case 'R':
                l = max(-1, l - 1);
                break;
        }
        switch(s[i]){
            case 'U':
                u++;
                break;
            case 'D':
                d--;
                break;
            case 'L':
                l++;
                break;
            case 'R':
                r--;
                break;
        }
        if(d - u <= 1 || r - l <= 1){
            ans = "NO";
            break;
        }
    }

    if(sr <= u || d <= sr || sc <= l || r <= sc){
        ans = "NO";
    }

    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main (void) {
  string str;
  cin >> str;
  bool haveA = false;
  bool haveB = false;
  for (auto& c : str) {
    if (c == 'A') haveA = true;
    if (c == 'B') haveB = true;
  }
  auto res = haveA&&haveB ? "Yes" : "No";
  cout << res;
}

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


int main() {
  string S;
  cin >>S;
  if(S[0]==S[1] || S[1]==S[2] || S[2]==S[3]){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
}


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

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

    int N, X, Y; cin >> N >> X >> Y; X--; Y--;
    vector<int> count(N);
    queue<int> que;
    for (int i = 0; i < N-1; i++) {
        vector<int> check(N, -1);
        check[i] = 0;
        que.push(i);
        while (!que.empty()) {
            int j = que.front(); que.pop();
            if (check[j+1] < 0) {
                check[j+1] = check[j] + 1;
                if (j+1 > i) count[check[j+1]]++;
                que.push(j+1);
            }
            if (j > 0 && check[j-1] < 0) {
                check[j-1] = check[j] + 1;
                if (j-1 > i) count[check[j-1]]++;
                que.push(j-1);
            }
            if (j == X && check[Y] < 0) {
                check[Y] = check[j] + 1;
                if (Y > i) count[check[Y]]++;
                que.push(Y);
            }
            if (j == Y && check[X] < 0) {
                check[X] = check[j] + 1;
                if (X > i) count[check[X]]++;
                que.push(X);
            }
        }
    }
    for (int i = 1; i < N; i++) cout << count[i] << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int h,w,d;
  cin>>h>>w>>d;
  pair<int,int> num[h*w+100]={};
  if(d<1000){
    int nu[d+1][h*w+10]={};
    int A[h+1][w+1]={};
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	cin>>A[i][j];
	num[A[i][j]]=mp(i,j);
      }
    for(int i=0;i<d;i++){
      for(int j=i;j<h*w;j++){
	if(j+d>h*w)break;
	nu[i][j+d]=nu[i][j]+abs(num[j].F-num[j+d].F)+abs(num[j].S-num[j+d].S);
      }
    }
    int q;cin>>q;
    for(int i=0;i<q;i++){
      int x,y;cin>>x>>y;
      cout<<nu[x%d][y]-nu[x%d][x]<<endl;
    }
  }else{
    int nu[h*w+10];
    int A[h+1][w+1]={};
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	cin>>A[i][j];
	num[A[i][j]]=mp(i,j);
      }
    int q;cin>>q;
    for(int i=0;i<q;i++){
    int ans=0;
    int x,y;cin>>x>>y;
    while(x!=y){
      ans+=abs(num[x+d].F-num[x].F)+abs(num[x+d].S-num[x].S);
      x+=d;
    }
    cout<<ans<<endl;
    }

  }
  return 0;
}


Measured memory_bytes: 91136
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

void printArr(vector<int> A)
{
    for (int i = 0; i < A.size(); i++)
    {
        if (i != A.size() - 1)
            cout << A[i] << " ";
        else
            cout << A[i];
    }
    cout << endl;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int minv = 0;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        minv = i;
        for (int j = i; j < n; j++)
        {
            if (a[j] < a[minv])
                minv = j;
        }
        if (i != minv)
        {
            swap(a[i], a[minv]);
            count++;
        }
    }
    printArr(a);
    cout << count << endl;
    return 0;
}



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

char s[200010];
int main(){
    scanf("%s",s);
    int len=strlen(s);
    int sum=0;
    for(int i=0;i<len;i++)sum+=s[i]-'0';
    if(sum%9==0){
        puts("Yes");
    }else{
        puts("No");
    }
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
using namespace std;
typedef long long ll;

int main() {
    int N, Y, A, B, C;
    bool flag = false;

    cin >> N >> Y;

    REP(i, 2001){
        REP(j, 2001){
            if (10000*i + 5000*j == Y - 1000*(N - i - j) and (N - i - j) >= 0){
                A = i;
                B = j;
                C = N - A - B;
                cout << A << " " << B << " " << C << endl;
                flag = true;
                break;
            }
        }
        if (flag) break;
    }

    if (flag == false){
        cout << "-1 " << "-1 " << "-1" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
	int n,i,a[100000],t,c=0,k=3,s=0;
	cin>>n;
	memset(a,0,sizeof(a));
	for(i=0;i<n;i++){
		cin>>t;
		if(k<t)k=t;
		a[t]++;
	}
	for(i=0;i<=k-2;i++){
		s=max(s,a[i]+a[i+1]+a[i+2]);
		
	}
	cout<<s<<endl;
	return 0;
}

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

int main() {
    int A[3][3];
    bool map[3][3] = {};
    int N;
    int b[100];

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }
    cin >> N;
    for (int k = 0; k < N; k++) {
        cin >> b[k];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (A[i][j] == b[k]) map[i][j] = true;
            }
        }
    }
    for (int i = 0; i < 3; i++) {
        if (map[i][0] && map[i][1] && map[i][2]) {
            cout << "Yes" << endl;
            return 0;
        }
        if (map[0][i] && map[1][i] && map[2][i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if ((map[0][0] && map[1][1] && map[2][2]) || (map[2][0] && map[1][1] && map[0][2])) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	ll ans = 0;
	for (ll i = 1; i <= N; i++){
		if (i%3 != 0 && i%5 != 0) ans += i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3616
def main():
  n,a,b=map(int,input().split())
  mod=pow(10,9)+7
  ans=pow(2,n,mod)-1
  # 場合の数をmodで割った余り nCr % mod
  def ncr_mod(n,r,mod):
    a,b=1,1
    for i in range(r):
      a*=n-i
      a%=mod
      b*=i+1
      b%=mod
    return (a*pow(b,mod-2,mod))%mod
  ans-=ncr_mod(n,a,mod)
  ans-=ncr_mod(n,b,mod)
  print(ans%mod)
  
if __name__=='__main__':
  main()


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

using namespace std;
#define ll long long int
#define f(i,n) for(auto i=0;i<n;i++)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define nl cout<<"\n";
#define vi vector<int>
#define pb push_back
#define pr pair<ll, ll>

class triplet{
    ll f,s,t;
};

int main(){
   ll A,B,C;
   cin>>A>>B;
   cout<<6-A-B;
}

Measured memory_bytes: 3536
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n, a[100000], on=0, en=0;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a+n);
	int k1=0, k2=0;
	for(int i=1; i<n; i++){
		if(a[i]==a[i-1]){
			k2++;
		}else{
			k2++;
			if((k2-k1)%2==0){
				en++;
			}else{
				on++;
			}
			k1=k2;
		}
	}
	k2++;
	if((k2-k1)%2==0){
		en++;
	}else{
		on++;
	}
	if(en%2==0){
		printf("%d\n", en+on);
	}else{
		printf("%d\n", en+on-1);
	}
	return 0;
}

Measured memory_bytes: 512
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する


N,M = map(int,input().split())
to = [[] for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    to[x-1]+=[y-1]

dp = [-1 for i in range(N)] #node[i]からの最長経路長を記す -1で未決定を示す

def memo(i):
    if dp[i] != -1:
        return dp[i]
    a=0
    for j in to[i]:
        a=max(a, memo(j)+1)
    dp[i] = a
    return a

lp = 0
for i in range(N):
    lp = max(lp,memo(i))
print(lp)


Measured memory_bytes: 59092
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, m; cin >> n >> m;
    vector<ll> dp(n + 10, 0);
    dp[0] = 1;
    const ll mod = (ll) 1e9 + 7;
    vector<int> bad(n + 10, 0);
    for (int i = 0; i < m; i++) {
        int x; cin >> x;
        bad[x] = 1;
    }
    for (int i = 0; i < n; i++) {
        if (bad[i]) {
            continue;
        }
        for (int j : {i + 1, i + 2}) {
            if (bad[j]) {
                continue;
            }
            dp[j] = (dp[j] + dp[i]) % mod;
        }
    }
    cout << dp[n] << "\n";
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int MySearch(string, string);

int main(){
  int i, n, count=0;
  string str, _str;
  string::iterator iter;

  cin >> _str;
  cin >> n;

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

    iter = search(str.begin(), str.end(), _str.begin(), _str.end());

    if(iter == str.end()){
      if(MySearch(str, _str) == 1)
	++count;
    }else{
      ++count;
    }

  }

  cout << count << endl;
  return 0;
}

int MySearch(string s, string t){
  int i, j, k, Found;

  for(i=s.size()-t.size()+1; i<s.size(); ++i){
    Found = 1;
    for(k=i, j=0; j<t.size(); ++j){
      if(s[k] != t[j]){
	Found = 0;
	break;
      }

      if(k == s.size()-1) k = 0;
      else ++k;
    }

    if(Found == 1) return Found;
  }

  return Found;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }




int field[3010][3010];
ll dp[3010][3010][5];

void solve() {
    int R,C,K;
    cin>>R>>C>>K;
    int r[200010],c[200010],v[200010];
    rep(i,K){
        cin>>r[i]>>c[i]>>v[i];
        r[i]--,c[i]--;
        field[r[i]][c[i]]+=v[i];
    }

    if(field[0][0]>0){
        dp[0][0][1]=field[0][0];
    }

    rep(i,R){
        rep(j,C){
            if(i+1<R){
                ll Max=0;
                rep(k,4) chmax(Max, dp[i][j][k]);
                chmax(dp[i+1][j][0], Max);
                if(field[i+1][j] > 0){
                    chmax(dp[i+1][j][1], Max + field[i+1][j]);
                }
            }
            if(j+1<C){
                rep(k,4){
                    chmax(dp[i][j+1][k], dp[i][j][k]);
                    if(k==3) continue;
                    if(field[i][j+1] > 0){
                        chmax(dp[i][j+1][k+1], dp[i][j][k] + field[i][j+1]);
                    }
                }
            }
        }
    }
    ll ans=0;
    rep(i,4) chmax(ans, dp[R-1][C-1][i]);
    cout<<ans<<endl;

    // rep(i,R){
    //     rep(j,C){
    //         cout<<i<<" "<<j<<endl;
    //         rep(k,4){
    //             cout<<dp[i][j][k]<<", ";
    //         }
    //         cout<<endl;
    //     }
    // }



}




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


    ll t=1;
    rep(i,t){
        solve(); 
    }


    return 0;
}

Measured memory_bytes: 393884
use std::cmp;

fn main(){
  let n: usize = read();

  let mut vh: Vec<usize> = (0..n).map(|_| read()).collect();

  vh.sort();

  let mut ret: usize = 1;
  let mut i: usize = 0;
  
  for stp in 1 .. vh[n-1]+1 {
    while stp > vh[i] { i += 1; }
    ret += cmp::min(stp * 4, n - i);
  }

  println!("{:}", ret);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}



Measured memory_bytes: 5032