akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	ll A,B,C,ans=LLONG_MAX;
	scanf("%lld%lld%lld",&A,&B,&C);
	if(A%2==0){
		ans=0;
	}else{
		ans=min(ans,B*C);
	}
	if(B%2==0){
		ans=0;
	}else{
		ans=min(ans,A*C);
	}
	if(C%2==0){
		ans=0;
	}else{
		ans=min(ans,A*B);
	}
	printf("%lld\n",ans);
	return 0;
}

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

m_4 = 0
even = 0

for i in range(N):
    if A[i] % 4 == 0:
        m_4 += 1
    elif A[i] % 2 != 0:
        even += 1

if (N % 2 == 0 and m_4 >= even) or (N % 2 != 0 and m_4 >= even - 1):
    print('Yes')
else:
    print('No')

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

using namespace std;

#define N 100

int n;
long long ans, sum, x, b[N+5];

int main() {
	cin >> n >> x;
	for(int i = 1; i <= n; ++i) cin >> b[i];
	sort(b+1, b+n+1);
	for(int i = 1; i <= n; ++i) {
		if(sum+b[i] == x) {
			++ans;
			sum += b[i];
			break;
		}
		else if(sum+b[i] < x) {
			++ans;
			sum += b[i];
			continue;
		}
		else break;
	}
	if(sum < x && ans == n) cout << n-1;
	else cout << ans;
	return 0;
}

Measured memory_bytes: 256
#define ll long long
#define elif else if

using namespace std;

#include <iostream>

ll a , b , c , d;

int main(){
    cin >> a >> b >> c >> d;
    cout << c + b - d << ' ' << d - (a - c) << ' ' << a + (b - d) << ' ' << b - (a - c) << endl;
    return 0;
}


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

using namespace std;
//typedef long long ll;
typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) {
        return x;
    }
    return gcd(y, x % y);
}

ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}

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

    ll t;
    ll a;
    cin >> t >> a;

    rep(i, n - 1) {
        ll ti, ai;
        cin >> ti >> ai;

        ll next_rate_1 = [&] {
            ll rate = (t + ti - 1) / ti;
            ll next_t = ti * rate;
            ll next_a = ai * rate;
            if (next_t >= t && next_a >= a) {
                return rate;
            }
            return INF;
        }();

        ll next_rate_2 = [&] {
            ll rate = (a + ai - 1) / ai;
            ll next_t = ti * rate;
            ll next_a = ai * rate;
            if (next_t >= t && next_a >= a) {
                return rate;
            }
            return INF;
        }();

        assert(!(next_rate_1 == INF && next_rate_2 == INF));

        ll next_rate = min(next_rate_1, next_rate_2);

        t = ti * next_rate;
        a = ai * next_rate;
    }

    cout << (t + a) << endl;

}


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

int main(void)
{
    int i, j, n, s[10000];
    int f[10000] = {0};
    int k = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++){

        scanf("%d", &s[i]);

    }

    for(i = 0; i < n; i++){

         if(s[i] % 2 == 0 || s[i] == 1){

             f[i]= 1;
         }

         else{

            for(j = 3; j <= sqrt(s[i]); j++){

                if(s[i] % j == 0){

                       f[i] = 1;             
                }
            }
        }

        if(s[i] == 2)
            
             f[i] = 0;


       if(f[i] == 0){

            k+= 1;
       }
    }

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

    return 0;
}


Measured memory_bytes: 2120
# Union-Find木（サイズ付き）
class UnionFind():
    # 初めは全ての頂点が別々の木の根
    def __init__(self, n):  # n要素で初期化
        self.parent = [None] * n # 親
        self.rank = [None] * n   # 木の深さ
        self._size = [1] * n # 要素が属する集合の大きさ（根の要素のみ参照すること）
        for i in range(n):
            self.parent[i] = i
            self.rank[i] = 0

    # 木の根を求める
    def root_of(self, x):
        children = [x]
        while self.parent[x] != x:
            x = self.parent[x]
            children.append(x)

        for ch in children:
            self.parent[ch] = x

        return x

    # xとyの属する集合を併合
    def unite(self, x, y):
        rx = self.root_of(x)
        ry = self.root_of(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]: # ランクの小さい木から大きい木の根に辺を張る
            self.parent[rx] = ry  # rxをryの子とする
            self._size[ry] += self._size[rx]
        else:
            self.parent[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するかどうか
    def is_same(self, x, y):
        return self.root_of(x) == self.root_of(y)

    # 頂点xが属する集合のサイズ
    def size(self, x):
        return self._size[self.root_of(x)]


# 入力
N, M, K = [int(x) for x in input().split()]

Ef = [[int(x) - 1 for x in input().split()] for _ in range(M)]
Eb = [[int(x) - 1 for x in input().split()] for _ in range(K)]

ans = [0] * N
uf = UnionFind(N)
for i in range(M):
    uf.unite(Ef[i][0], Ef[i][1])
    ans[Ef[i][0]] -= 1  # すでに友達なら友達候補ではない
    ans[Ef[i][1]] -= 1

for i in range(K):
    if uf.is_same(Eb[i][0], Eb[i][1]):
        ans[Eb[i][0]] -= 1  # ブロックしているなら友達候補ではない
        ans[Eb[i][1]] -= 1

for i in range(N):
    ans[i] += uf.size(i) - 1

print(" ".join([str(i) for i in ans]))


Measured memory_bytes: 52644
H,W=map(int, input().split())
S=[list(input()) for _ in range(H)]
exS = [['.']*(W+2)]
for s in S:
    exS.append(['.']+s+['.'])
exS.append(['.']*(W+2))

for i in range(1, H+1):
    for j in range(1, W+1):
        if exS[i][j]=='#':
            continue
        else:
            exS[i][j] = str((exS[i][j-1]+exS[i][j+1]\
                      +exS[i-1][j-1]+exS[i-1][j+1]+exS[i-1][j]\
                      +exS[i+1][j-1]+exS[i+1][j+1]+exS[i+1][j]).count('#'))

def show(arr):
    text = ''
    for i in range(1, len(arr)-1):
        if i == 0:
            continue
        elif i == len(arr)-2:
            text += ''.join(arr[i][1:-1])
        else:
            text += ''.join(arr[i][1:-1]) + '\n'
    return text

print(show(exS))

Measured memory_bytes: 39536
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


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

    vector<int>H(N);
    rep(i,N)cin >> H[i];

    int ans = 0;
    for(int i = 0; i<N-1;){
        int gou = 0;
        while(H[i] >= H[i+1] &&  i<N-1){
            i++;
            gou +=1;
        }
        ans =max(ans,gou);
        i++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3708
k,n=map(int, input().split())
c=list(map(int, input().split())) 

d=[]
for i in range(n-1):
    d.append(c[i+1]-c[i])

d.append(k-c[n-1]+c[0])
max = max(d)
sum = sum(d)
print(sum-max)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
int main () {
    ios_base::sync_with_stdio(false);
    int N;
    cin>>N;
    int A[N+1] = {0};
    int a;
    for(int i=2;i<=N;i++) {
        cin>>a;
        A[a]++;
    }
    for(int i=1;i<=N;i++) {
        cout<<A[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 4428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();

		if (string.equals("AAA") || string.equals("BBB")) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 35444
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=8000 +117;
const int MM=200 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
LL fact[NN]={};
LL rev[NN]={};
const int mod=998244353;
LL comp(int n,int m){
	if(m>n)return 0;
	return fact[n]*rev[m]%mod*rev[n-m]%mod;
}
LL ksm(LL a,LL b){
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
void prefact(int n){
	fact[0]=1;
	for(int i=1;i<=n;++i)fact[i]=fact[i-1]*i%mod;
	rev[n]=ksm(fact[n],mod-2);
	for(int i=n;i>=1;--i)rev[i-1]=rev[i]*i%mod;
}
LL dp[2][NN]={};
LL a[4*NN]={};
LL b[4*NN]={};
int len=0;
int revb[4*NN]={};
int gt=3;
int revgt;
void dft(LL a[],int len,int sym){
	for(int i=1;i<len;++i)if(revb[i]<i)swap(a[revb[i]],a[i]);
	LL g=(sym==1?gt:revgt);
	for(int d=1;d<len;d<<=1){
		LL e=ksm(g,(mod-1)/d/2);
		for(int st=0,gap=d<<1;st<len;st+=gap){
			LL rt=1;
			for(int k=0;k<d;++k,rt=rt*e%mod){
				LL y=a[st+d+k]*rt;
				a[st+d+k]=(a[st+k]-y)%mod;
				a[st+k]=(a[st+k]+y)%mod;
			}
		}
	}
	if(sym==-1){
		LL bas=ksm(len,mod-2);
		for(int i=0;i<len;++i)
			a[i]=a[i]*bas%mod;
	}
}
int main(){
	//open();
	n=read();
	m=read();
	prefact(n+10);
	dp[0][0]=1;
	int now=0;
	len=1;
	while(len<=2*n)len<<=1;
	for(int i=1;i<len;++i){
		revb[i]=revb[i>>1]>>1;
		if(i&1)revb[i]|=len>>1;
	}
	for(int i=1;i<=n;++i){
		b[i]=rev[i+2];
	}
	revgt=ksm(gt,mod-2);
	dft(b,len,1);
	for(int ti=1;ti<=m;++ti){
		now^=1;
		for(int i=0;i<len;++i)a[i]=0;
		for(int i=0;i<=n;++i){
			a[i]=dp[now^1][i]*rev[i]%mod;
		}
		dft(a,len,1);
		for(int i=0;i<len;++i)a[i]=a[i]*b[i]%mod;
		dft(a,len,-1);
		for(int j=0;j<=n;++j){
			dp[now][j]=a[j]*fact[j+2]%mod;
		}
		for(int j=0;j<=n;++j){
			dp[now][j]+=dp[now^1][j]*(comp(j+1,2)+1);
			dp[now][j]%=mod;
		}
	}
	LL ans=0;
	for(int i=0;i<=n;++i){
		ans=(ans+dp[now][i]*comp(n,i))%mod;
	}
	ans=(ans+mod)%mod;
	printf("%lld\n",ans);
	close();
	return 0;
}

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

using lli = int64_t;

lli f(lli a, lli b, lli c)
{
    lli ans = 0;

    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
    {
        lli aa = b / 2 + c / 2;
        lli bb = a / 2 + c / 2;
        lli cc = a / 2 + b / 2;

        a = aa;
        b = bb;
        c = cc;

        ans++;
    }

    return ans;
}

int main()
{
    int a, b, c; cin >> a >> b >> c;

    if(a == b && b == c && a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    int r = f(a, b, c);

    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let n: usize = read();
    let a: Vec<i64> = (0..n).map(|_| read::<i64>()).collect();
    let mut valsub: HashMap<i64, usize> = HashMap::new();
    let mut valadd: HashMap<i64, usize> = HashMap::new();
    for i in 1..n as i64 + 1 {
        let subv = i - a[i as usize - 1];
        match valsub.get_mut(&subv) {
            Some(v) => *v += 1,
            None => {
                valsub.insert(subv, 1);
            }
        }
        let addv = i + a[i as usize - 1];
        match valadd.get_mut(&addv) {
            Some(v) => *v += 1,
            None => {
                valadd.insert(addv, 1);
            }
        }
    }
    let mut ans = 0;

    for (k, vb) in valsub {
        match valadd.get(&k) {
            Some(va) => ans += va * vb,
            None => (),
        }
    }
    println!("{}", ans);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 14528
import sys
import numpy as np
import math

if sys.platform =='ios':
    sys.stdin=open('input133b.txt')

#+++++

count = 0
n, d = map(int, input().split())
anums = []
for i in range(n):
	anums.append( list(map(int, input().split())))

for i in range(n):
	for k in range(n - i -1):
		num = 0
		for j in range(d):
			num += pow(abs(anums[i][j] - anums[i + k + 1][j]),2)

		sq = math.sqrt(num)
		if sq.is_integer():
			count += 1

print(count)

Measured memory_bytes: 21520
N = int(input())
D = sorted(list(map(int, input().split())))
M = int(input())
T = sorted(list(map(int, input().split())))

if N < M:
    print('NO')
    exit()

fnd = 0
nw = 0
isok = True
for t in T:
    for i in range(nw, N):
        nw += 1
        if t == D[i]:
            fnd += 1
            break
        elif t < D[i]:
            isok = False
            break

print('YES' if (isok and fnd==len(T)) else 'NO')

Measured memory_bytes: 41192
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      double m = Double.parseDouble(sc.next());
      double[] ary = new double[n];
      double sum = 0.0;
      double c = 0.0;
      for (int i = 0;i < n;i++) {
        ary[i] = Double.parseDouble(sc.next());
        sum += ary[i];
      }
      for (int i = 0; i < n  ; i++) {
        if (ary[i] >= sum / ( 4* m)) {
          c += 1;
        }
      }
      if (c >= m) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 22868
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

//using LL = long long;

//ボール(n)の区別:アリ
//箱(m)の区別:アリ
//それぞれの箱に最低限1個入れる


LL n, k;
const int mod = 1e9 + 7;

int main() {
	cin >> n >> k;
	LL ans = 1;
	REP(i, n)ans *= (k - i), ans %= mod;
	cout << ans << endl;
}


Measured memory_bytes: 3068
import numpy as np
n = int(input())
A = np.array([int(input()) for i in range(n)])
idxs = np.argsort(A)
m1 = A[idxs[-1]]
m2 = A[idxs[-2]]
for i in range(n):
  if i != idxs[-1]:
    print(m1)
  else:
    print(m2)

Measured memory_bytes: 21864
import bisect

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    l2 = L[i]+L[j]
    LL = L[j+1:N]
    ans += bisect.bisect_left(LL,l2)
print(ans)


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

int main(){
    
    // 1. 入力情報.
    char c[10];
    scanf("%s", c);
    string S(c);
    bitset<6> ans(S);
    
    // 2. 出力.
    printf("%d\n", ans.count());
    return 0;
    
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    int warukazu = A[0];
    if (warukazu == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    int min_ind = 0;
    int min_num = warukazu;
    while (true)
    {
        int tmp_min_ind = min_ind;
        for (int i = 0; i < N; i++)
        {
            if (i == min_ind)
            {
                continue;
            }
            A[i] %= warukazu;
            if (A[i] > 0 && A[i] < min_num)
            {
                min_num = A[i];
                tmp_min_ind = i;
            }
        }

        if (min_num == warukazu)
        {
            cout << warukazu << endl;
            return 0;
        }
        else
        {
            warukazu = min_num;
            min_ind = tmp_min_ind;
        }
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 100000000007
#define pi acos(-1.0)
ll n,m,j,k,l,t,arr[sz],brr[sz],crr[sz],drr[sz];
int main()
{
  scanf("%lld",&n);
  double l=double(n);
  l=pi*(n)*(2.0);
   printf("%f\n",l);
}


Measured memory_bytes: 3788
#include<cstdio>
#include<cstring>
const long long mod = 998244353;
char s[2001];
long long f[4001][4001];
int sum0[4001]; int sum1[4001];

int main(){
    scanf("%s",s+1);
    int n = strlen(s+1);
    for(int i = 1; i <= n; i++){
        sum0[i] = sum0[i-1], sum1[i] = sum1[i-1];
        if(s[i]=='0') sum0[i] += 2;
        else if(s[i]=='1') sum0[i]++, sum1[i]++;
        else sum1[i] += 2;
    }
    for(int i = n+1; i <= 2*n; i++) sum0[i] = sum0[i-1], sum1[i] = sum1[i-1];
    f[0][0] = 1;
    for(int i = 1; i <= 2*n; i++){
        for(int j = 0; j <= 2*n; j++){
            f[i][j] = 0;
            int cnt0 = j, cnt1 = i-j;
            if(cnt0<=sum0[i] && cnt1<=sum1[i]){
                if(cnt0!=0) f[i][j] = (f[i][j]+f[i-1][j-1])%mod;
                if(cnt1!=0) f[i][j] = (f[i][j]+f[i-1][j])%mod;
            } 
        }
    }
    printf("%lld\n",f[2*n][sum0[2*n]]);
    return 0;
}


Measured memory_bytes: 126772
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

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

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  cout << fixed << setprecision(15);

  ll N, M;
  cin >> N >> M;

  vector<string> A(N);
  vector<string> B(N);

  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (ll i = 0; i < M; i++) {
    cin >> B[i];
  }

  for (ll i = 0; i < N - M + 1; i++) {
    for (ll j = 0; j < N - M + 1; j++) {
      // A includes B
      bool included = true;
      for (ll l = 0; l < M; l++) {
        for (ll m = 0; m < M; m++) {
          if (A[i + l][j + m] != B[l][m]) {
            included = false;
            break;
          }
        }
        if (!included) break;
      }

      if (included) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    unsigned long long n;
    cin >> n;

    unsigned long long cnt = n / 11ULL;
    unsigned long long dif = n % 11ULL;

    /*n = n - cnt * 11;

    if(dif > 5)
        ++cnt;*/

    cout << cnt * 2ULL + (dif > 6ULL ? 2ULL : dif > 0ULL ? 1ULL : 0ULL);

    return 0;
}


Measured memory_bytes: 256
# ABC137D - Summer Vacation
import sys
input = sys.stdin.readline

from heapq import heappush, heappushpop


def main():
    N, M = tuple(map(int, input().split()))
    T = [[] for _ in range(M + 1)]
    for _ in range(N):
        a, b = map(int, input().rstrip().split())
        if a <= M:
            T[M - a] += [b]
    q = []
    for i in range(M + 1):
        for v in T[i]:
            if len(q) <= i:
                heappush(q, v)
            else:
                heappushpop(q, v)
    print(sum(q))


if __name__ == "__main__":
    main()

Measured memory_bytes: 18512
N, W = map(int,input().split())

cost = [list(map(int,input().split())) for i in range(N)]


dp = [[float('inf')] * (100001) for i in range(N)]


for i in range(N):
    for j in range(100001):
        if j == 0:
            dp[i][j] = 0

for i in range(N):
    for sum_v in range(0,100001):
        if sum_v - cost[i][1] >= 0:
            dp[i][sum_v] = min(dp[i-1][sum_v], dp[i-1][sum_v - cost[i][1]] + cost[i][0])
        dp[i][sum_v] = min(dp[i][sum_v], dp[i-1][sum_v])

ans = float('inf')

for j in range(0,100001):
    if dp[N-1][j] <= W:
        ans = j
print(ans)


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int imos[1010][1010];

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    imos[x1][y1]++;
    imos[x2][y1]--;
    imos[x1][y2]--;
    imos[x2][y2]++;
  }
  REP(i, 1001) REP(j, 1001) imos[i][j + 1] += imos[i][j];
  REP(i, 1001) REP(j, 1001) imos[j + 1][i] += imos[j][i];
  int ans = 0;
  REP(i, 1001) REP(j, 1001) ans = max(ans, imos[i][j]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7056
import java.util.*;

public class Main {

  public static void main(String args[]) {
    (new Main()).solve();
  }

  void solve() {

    Scanner cin = new Scanner(System.in);

    int N = cin.nextInt();
    int array[] = new int[N + 1];
    
    for(int i = 0; i < N; ++i ) {
    	array[i] = cin.nextInt();
    }
    
    long ans = 0;
    for( int i = N; i >= 0; --i ) {
    	if( i == 0 ) {
    		if( array[i] > 0 ) {
    			ans = -1;
    		}
    		break;
    	}
    	if( array[i - 1] < array[i] - 1 ) {
    		ans = -1;
    		break;
    	}
    	if( array[i - 1] >= array[i] ) {
    		ans += array[i - 1];
    	}
    }

	System.out.println(ans);
    
    cin.close();

  }

}


Measured memory_bytes: 85816
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem100c(n, a))
}

fun problem100c(n: Int, a: List<Int>): Int {
    val array = IntArray(n) { -1 }
    for (i in 0 until n) {
        var count = 0
        var ai = a[i]
        while (ai % 2 == 0) {
            ai /= 2
            count++
        }
        array[i] = count
    }
    return array.sum()
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b, c;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c;
	if(a == b) cout << c << "\n";
	else if(a == c) cout << b << "\n";
	else cout << a << "\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var ai = Sarray();
            WriteLine(ai.Max() - ai.Min());
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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


def solve():
    cnt=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if L[i]!=L[j]!=L[k] and L[i]+L[j]>L[k]:
                    cnt+=1
    print(cnt)
if __name__ == "__main__":
    n = int(input())
    L = list(map(int,input().split()))
    L.sort()
    solve()

Measured memory_bytes: 9200
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

bool solve(int a, int b, int c)
{
    return (a * a + b * b == c * c);
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        if(solve(a, b, c) || solve(b, c, a) || solve(c, a, b)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
    d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
#define G(a)((r=A[a]+A[P[a]]+C[a])%k?r:0)
L M(L i){return i?B[i]+M(i-(i&-i)):0;}
L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1<<17;i+=i&-i)B[i]+=x;}
L W(){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}
main(){for(cin>>n>>k;++p<n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;S(a=H[a],O[a]=c++))X[a]=p;
       for(cin>>a;cin>>s>>a>>b;*s&2?W():A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}

Measured memory_bytes: 33488
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<map>
#include<set>
#include<iostream>
#include<algorithm>
#include<queue>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	char ch=getchar();int f=1,sum=0;
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010,Inf=1e9+10;
int n,a[N],dp[N],k;
int main(){
	n=gi();k=gi();
	for(int i=1;i<=n;i++)a[i]=gi();
	memset(dp,127,sizeof(dp));dp[1]=0;
	for(int i=1;i<n;i++)
		if(dp[i]!=dp[0])
			for(int j=1;j<=k;j++)
				 dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
	printf("%d\n",dp[n]); 
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int N, arr[106], A[106], sum = 0;
	cin>>N;
	for (int i = 1; i <= N - 1; ++i)
		{
			cin>>arr[i];
		}
	A[1] = arr[1];
	for (int i = 2; i < N; i++)
		{
			if(arr[i] > arr[i - 1])
				A[i] = arr[i-1];
			else
				A[i] = arr[i];	
		}	
		A[N] = arr[N-1];
		for (int i = 1; i <= N; ++i)
		{
			sum += A[i];
		}
		cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
int read(){
	int f=0,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
#define MAXN 65000
#define INF 0x3f3f3f3f
int main(){
	int M=read(),D=read(),cnt=0;
	for(int i=1;i<=M;i++)
		for(int j=1;j<=D;j++)
			if((j/10)>=2&&(j%10)>=2&&(j/10)*(j%10)==i)
				cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$arr= explode(" ", trim(fgets(STDIN)));

rsort($arr);
$ave = ($arr[$n-1] + $arr[$n-2]) / 2;

if($n > 2) {
    for ($i = $n-3; $i >= 0; $i--) {
        $ave = ($ave + $arr[$i]) / 2;
    }
}

echo $ave;

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

int main()
{
    int N, M;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++)
        cin >> s.at(i);
    
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++)
    {
        cin >> t.at(i);
    }

    int max = 0;
    for (int i = 0; i < N; i++)
    {
        int count = 1;
        for (int j = i + 1; j < N; j++)
        {
            if (s.at(i) == s.at(j))
            {
                count++;
            }
        }
        for (int j = 0; j < M; j++)
        {
            if (s.at(i) == t.at(j))
            {
                count--;
            }
        }
        if (max < count)
        {
            max = count;
        }
    }
    cout << max << endl;
}


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

int main() {
  int N, a, b;
  cin >> N;
  vector<int> A, B;
  for (int i=0; i<N; i++) {
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if (N%2 == 1) {
    cout << B[(N-1)/2] - A[(N-1)/2] + 1 << endl;
    return 0;
  }
  int l = A[N/2] + A[N/2-1], r = B[N/2] + B[N/2-1];
  cout << r-l+1 << endl;
  return 0;
}


Measured memory_bytes: 5096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s;
		Boolean judge ;

		StringBuilder sb  = new StringBuilder();
		while ((s = br.readLine()) != null) {
			judge = false;
			for (int k = 1; k <= 26; k++) {
				sb = new StringBuilder();
				for (int i = 0; i < s.length(); i++) {
					if (s.charAt(i) == ' ') {
						sb.append(" ");
					} else if (s.charAt(i) == '.') {
						sb.append(".");
					} else if (s.charAt(i) + k > (int) 'z') {
						sb.append((char) ((int) 'a' - 1 + (s.charAt(i) + k - (int) 'z')));

					} else {
						sb.append((char) (s.charAt(i) + k));
					}
				}
				String a = sb.toString();
				if (a.contains("the")  || a.contains("this") || a.contains("that")) {
					judge = true;
					break;
				}

			}
			if(judge){
			System.out.println(sb.toString());
			}
		}
	}

}

Measured memory_bytes: 24464
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int main(){
	int N;
	cin >> N;
	vector<string>S(N);
	rep(N)
		cin >> S[i];
	sort(S.begin(),S.end());
	int c = 0;
	rep(N - 1) {
		if (S[i] != S[i + 1])
			c++;
	}
		c++;
	cout << c;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    int n, k;
    cin >> n >> k;
    vi p(n);
    fo(i, n) cin >> p[i];

    sort(all(p));

    int s = 0;
    fo(i, k) s += p[i];

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3624
N = int(input())
list_D = [list(map(int, input().split())) for i in range(N)]

count = 0
for i in range(N-2):
  if list_D[N-i-1][0] == list_D[N-i-1][1] and list_D[N-i-2][0] == list_D[N-i-2][1] and list_D[N-i-3][0] == list_D[N-i-3][1]:
    count += 1
if count > 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9200
N = input()[::-1]
iv = 1
MOD = 10**9+7
pdp = [0 for i in range(13)]
pdp[0]=1
dp = [0 for i in range(13)]
for i in range(len(N)):
  x = N[i]
  if x=='?':
    for j in range(13):
      for h in range(10):
        dp[(h*iv+j)%13] += pdp[j]
    for j in range(13):
      pdp[j] = (dp[j]%MOD)
      dp[j] = 0
  else:
    x = int(x)
    for j in range(13):
      dp[(j+x*iv)%13]+=pdp[j]
    for j in range(13):
      pdp[j] = (dp[j]%MOD)
      dp[j]=0
  iv *= 10
  iv %= 13
print(pdp[5])

Measured memory_bytes: 43884
using System;
using System.Linq;

namespace C_
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var a1Sum = new int[A1.Length];
            var a2Sum = new int[A2.Length];

            a1Sum[0] = A1[0];
            for(var i = 1; i < A1.Length; i++)
            {
                a1Sum[i] = a1Sum[i - 1] + A1[i];
            }
            
            a2Sum[A2.Length - 1] = A2[A2.Length - 1];
            for(var i = A2.Length - 2; i >= 0; i--)
            {
                a2Sum[i] = a2Sum[i + 1] + A2[i];
            }

            var result = 0;
            for(var i = 0; i < N; i++)
            {
                var tmp = a1Sum[i] + a2Sum[i];
                result = Math.Max(result, tmp);
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
"""
NTC here
"""
import sys
inp = sys.stdin.readline
def input(): return inp().strip()
flush= sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**26)

def iin(): return int(input())


def lin(): return list(map(int, input().split()))

# out = []
# range = xrange
# input = raw_input

def main():
    n = iin()
    ans = (n*(n+1))//2
    for i in range(3, n+1, 3):ans-=i
    for i in range(5, n+1, 5):ans-=i
    for i in range(15, n+1, 15):ans+=i
    print(ans)

main()
# threading.Thread(target=main).start()


Measured memory_bytes: 63412
#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
  int A[3],B[2];
  cin>>A[0]>>A[1]>>A[2];
  cin>>B[0]>>B[1];
 
  sort(A,A+3);
  sort(B,B+2);

  cout<<A[0]+B[0]-50<<endl;
   return 0;
}

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

public class Main {
    private static double[][][] dp = new double[301][301][301];
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        
        int N = in.nextInt();
        int c1 = 0, c2 = 0, c3 = 0;
        
        for(int i = 0; i < N; i++) {
            int val = in.nextInt();
            if(val == 1) c1++;
            else if(val == 2) c2++;
            else c3++;
        }
        
        System.out.println(solve(N, c1, c2, c3));
    }
    
    private static double solve(int n, int c1, int c2, int c3) {
        if(c1 < 0 || c2 < 0 || c3 < 0) return 0.0;
        
        if(c1 == 1 && c2 == 0 && c3 == 0) return 1.0*n;
        if(Math.abs(dp[c1][c2][c3] - 0.0) > 1e-9) return dp[c1][c2][c3];
        
        double res = (c1*solve(n, c1-1, c2, c3) + c2*solve(n, c1+1, c2-1, c3) + c3*solve(n, c1, c2+1,c3-1) + 1.0*n)/(c1 + c2 + c3);
        
        dp[c1][c2][c3] = res;
        
        return res;
    }
        
}


Measured memory_bytes: 305684
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

    ll n,k;
    cin>>n>>k;
    VL h(n);
    REP(i,n)cin>>h[i];
    VSORT(h);
    ll res=0;
    REP(i,n-k){
        res+=h[i];
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()
{
    int w;
    string S, sum;
    cin >> S >> w;

    rep(i, S.size())
    {
        if (i % w == 0)
        {
            sum += S[i];
        }
    }

    cout << sum << endl;
}


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

int gcd(int a, int b){
	return b ? gcd(b, a % b) : a;
}

int main(){
	int n;cin >> n;
	vector<int> l(n + 5, 0);
	vector<int> r(n + 5, 0);
	vector<int> arr(n + 5, 0);
	int ans = INT_MIN;
	for(int i = 1;i <= n;i++){
		cin >> arr[i];
		l[i] = gcd(arr[i], l[i - 1]);
	}
	for(int i = n;i > 0;i--)r[i] = gcd(arr[i], r[i + 1]);
	for(int i = 1;i <= n;i++)ans = max(gcd(l[i - 1], r[i + 1]), ans);
	cout << ans;
}
// make pair, tuple
// make pair, tuple
// 
// __gcd(int, int);
// lcm = a * b / __gcd(a, b);
// 
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }
// 
// #Count leading & trailing zero of an integer bits
// __builtin_clz(n);
// __builtin_clzll(n);
//
// #Count 1s bits of an integer
// __builtin_popcount(n);
// __builtin_popcountll(n);
//
// #Error checking
// assert(n == 3);
// 
// #Error Printing
// cerr << "Some thing";

// #binary exponentiation
// long long binpow(long long a, long long b) {
//     long long res = 1;
//     while (b > 0) {
//         if (b & 1)
//             res = res * a;
//         a = a * a;
//         b >>= 1;
//     }
//     return res;
// }


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX (int)(1e12)

long long power(unsigned __int128 x, unsigned __int128 n){
	unsigned __int128 ans = 1;
	while(n){
		if((double)ans*x > MAX) return -1;
		if(n&1) ans *= x;
		n >>= 1;
		x *= x;
		if(ans > MAX) return -1;
	}
	return (long long)ans;
}


signed main(){
	int N, P, ans = 1;
	
	cin>>N>>P;
	
	if(N==1){
		cout<<P<<endl;
		return 0;
	}
	
	for(int i = 2; i*i <= P; i++){
		int t = power(i,N);
		if(t < 0 || t > P)break;
		if(P%t==0)ans = i;
		
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl;
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<P> VP;
const int INF = 1LL<<60;
const int MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
  int n;
  cin>>n;
  n*=2;
  V a(n);
  rep(i,n)cin>>a[i];
  SORT(a);
  int ans=0;
  rep(i,n)if(i%2==0)ans+=a[i];
  out(ans);
  
  
  
  return 0;
}



Measured memory_bytes: 256
//AUTHOR:- Avinash//
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long int
#define lll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define take(a,i,n) for(int i=0;i<n;i++) cin>>a[i]
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ld long long double
#define d1(x) cout<<(x)<<endl
#define T int t;cin>>t;while(t--)
#define hell 1000000007
#define ex endl;
#define F first
#define maxn 200001
#define pi 3.14159265
#define S second
#define P pair<int,int>
#define PP pair<int,pair<int,int>>
#define pb push_back
#define in insert
#define vec vector<ll>
#define vec2 vector<vector<int>>
#define s(a,n) sort(a,a+n);
#define sv(a) sort(a.begin(),a.end());
#define MAX 1000
//Author:-Avinash//

ll power(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
ll sum_of_natural_no(ll n )
{
    return (n *(n+1))/2;
}

ll modInverse(ll a, ll m)
{
    return power(a, m-2, m);
}
int32_t main(){
   FAST
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   //int ans=-1e18 ;
   cout<<max({a*c, b*d, a*d, b*c});
   //cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3644
N = int(input())
w_list = [input() for _ in range(N)]

announced_before = set()

announced_before.add(w_list[0])
for i in range(1, N):
    prev_w = w_list[i - 1]
    w = w_list[i]
    if w in announced_before:
        print("No")
        break
    elif prev_w[-1] != w[0]:
        print("No")
        break
    else:
        announced_before.add(w)

else:
    print("Yes")


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;
 
#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(c,l,r) for(int c=(l);c<=(r);c++)
 
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
 
using ll = long long;
//#define int ll
 
const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int  dx[]  = {-1,   0,   1,   0,  1, -1, -1,  1};
const int  dy[]  = { 0,   1,   0,  -1,  1, -1,  1, -1};
const char dt[] = {'U', 'R', 'D', 'L'};

void solve() {	
	int n, m;
	cin >> n >> m;
	vector <string> a(n);
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		string s = a[i];
		for (int j = 0; j < m; j ++) {
			s[j] = tolower(s[j]);
		}
	}
	sort(all(a));
	for (auto i : a) cout << i;
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
   	//cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}



Measured memory_bytes: 3616