akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const long long INF = 1e18;
const double PI = 2 * asin(1);

int main(){
  ll N; cin >> N;
  if (N % 2 != 0){
    cout << 0 << endl;
  }else{
    ll ans = 0;
    while (N > 0){
      ans += N / 5 / 2;
      N = N / 5;
    }
    
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>

using std::vector;

const int MAXN=8000;
int goal[2];
bool tmp[2][2][(MAXN<<1)+5];
bool *dp[2][2]={{tmp[0][0]+MAXN+2,tmp[0][1]+MAXN+2},{tmp[1][0]+MAXN+2,tmp[1][1]+MAXN+2}};
char s[MAXN+5];

vector<int> bag[2];

inline void deal(){
	bool face=0;
	int last=-1,len=strlen(s);
	for(int i=0;i<len;++i){
		if(s[i]=='T'){
			bag[face].push_back(i-last-1);
			last=i;
			face^=1;
		}
	}
	if(last!=len-1)	bag[face].push_back(len-last-1);
	if(bag[0].size()){
		dp[0][1][bag[0][0]]=true;
		bag[0].erase(bag[0].begin());
	}
	else dp[0][1][0]=true;
	dp[1][1][0]=true;
}

inline bool DP(int type){
	bool *dp[2]={::dp[type][0],::dp[type][1]};
	vector<int> &bag=::bag[type];
	for(int i=0,lim=bag.size();i<lim;++i){
		memset(dp[i&1]-MAXN,false,MAXN<<1|1);
		for(int j=-MAXN;j+bag[i]<=MAXN;++j)
			dp[i&1][j]|=dp[~i&1][j+bag[i]];
		for(int j=MAXN;j-bag[i]>=-MAXN;--j)
			dp[i&1][j]|=dp[~i&1][j-bag[i]];
	}
	return dp[~bag.size()&1][goal[type]];
}

int main(){
	scanf("%s",s);
	scanf("%d%d",&goal[0],&goal[1]);
	deal();
	if(DP(0) && DP(1))
		printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#define MAX 1000005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL)cout << "root, ";
	else if (T[u].l == NIL)cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i)cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

int rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL)rec(T[u].r, p);
	if (T[u].l != NIL)rec(T[u].l, p + 1);

	return 0;
}

int main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0)T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL)r = i;
	}

	rec(r, 0);

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

	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int H, W, D;
int A[333][333];
map<int, pair<int, int>> m;
int a[111111];

int main() {
   cin >> H >> W >> D;
   rep (i, H) {
      rep (j, W) {
         cin >> A[i][j];
         m.insert({A[i][j], {i, j}});
      }
   }

   for (int i = D+1; i <= H*W; i++) {
      a[i] = a[i-D] + abs(m[i-D].first - m[i].first) + abs(m[i-D].second - m[i].second);
   }

   int Q;
   cin >> Q;
   while (Q--) {
      int l, r;
      cin >> l >> r;
      cout << a[r] - a[l] << endl;
   }

   return 0;
}

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

using ll = long long;

template <typename T>
class fenwick_tree {
public:
    fenwick_tree(int n_) : n(n_), dat(n, 0) {}

    void add(int i, T value) {
        for(; i < n; i |= i + 1) {
            dat[i] += value;
        }
    }

    T sum(int i) const {
        T res = 0;
        for(; i >= 0; i = (i & (i + 1)) - 1) {
            res += dat[i];
        }
        return res;
    }
    // [l, r)
    T sum(int l, int r) const {
        return sum(r - 1) - sum(l - 1);
    }

private:
    const int n;
    std::vector<T> dat;
};

template <typename T>
class range_add_range_sum {
public:
    range_add_range_sum(int n_) : n(n_), bit0(n), bit1(n) {}

    void add(int l, int r, T val) {
        bit0.add(l, -val * l);
        bit1.add(l, val);
        bit0.add(r, val * r);
        bit1.add(r, -val);
    }

    T sum(int p) const {
        return bit1.sum(p) * (p + 1) + bit0.sum(p);
    }
    T sum(int l, int r) const {
        return sum(r - 1) - sum(l - 1);
    }

private:
    const int n;
    fenwick_tree<T> bit0, bit1;
};

int main() {
    int m, n, m0, md, n0, nd;
    cin >> m >> n >> m0 >> md >> n0 >> nd;
    vector<int> ms(m), ns(n);
    ms[0] = m0, ns[0] = n0;
    for(int i = 1; i < m; ++i) {
        ms[i] = (ms[i - 1] * 58 + md) % (n + 1);
    }
    for(int i = 1; i < n; ++i) {
        ns[i] = (ns[i - 1] * 58 + nd) % (m + 1);
    }
    sort(rbegin(ms), rend(ms));
    sort(begin(ns), end(ns));

    range_add_range_sum<ll> rars(n);
    for(int i = 0; i < n; ++i) {
        rars.add(i, i + 1, ns[i]);
    }
    auto get_pos = [&] (int val) {
        int lb = -1, ub = n;
        while(ub - lb > 1) {
            const int mid = (lb + ub) >> 1;
            (rars.sum(mid, mid + 1) >= val ? ub : lb) = mid;
        }
        return ub;
    };
    ll ans = 0;
    for(int i = 0; i < m; ++i) {
        if(ms[i] == 0) break;
        const int v = rars.sum(n - ms[i], n - ms[i] + 1);
        const int p1 = get_pos(v), p2 = get_pos(v + 1);
        if(p2 != n) {
            ans += n - p2;
            rars.add(p2, n, -1);
        }
        if(v != 0) {
            ans += ms[i] - (n - p2);
            rars.add(p1, p1 + ms[i] - (n - p2), -1);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 61484
#include<bits/stdc++.h>
#define mtp make_tuple
#define mpr make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 2e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread(){}
template<class T1, class ...T2>
inline void qread(T1 &IEE, T2&... ls){
	register T1 __ = 0, ___ = 1;
	register char ch;
	while(!isdigit(ch = getchar())) ___ = (ch == '-') ? -___ : ___;
	do{
		__ = (__ << 1) + (__ << 3) + (ch ^ 48);
	}while(isdigit(ch = getchar()));
	__ *= ___;
	IEE = __;
	qread(ls...);
	return ;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
template<class T>
inline T ab(T a){
	return (a > 0) ? a : -a;
}
template<class T>
inline void swa(T &a, T &b){
	a ^= b ^= a ^= b;
	return ;
}
ll now, n, m;
ll dp[maxn][71], a[maxn];
bool f[maxn];
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(n, m);
	for(int i = 1;i <= n;i++){
		qread(a[i]);
		dp[i][0] = a[i];
	}
	for(int i = 1;i <= 70;i++){
		for(int j = 1;j <= n;j++){
			dp[j][i] = dp[dp[j][i - 1]][i - 1];
		}
	}
	now = 1;
	for(ll i = 62;i >= 0;i--){
		if((m & (1ll << i))){
			now = dp[now][i];
		}
	}
	cout << now << endl;
	return 0;
}


Measured memory_bytes: 116184
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int n, a[100000], b[100000], c[100000];
typedef long long ll;
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int cmpintR(const void *x, const void *y) {
	return *(int *)y - *(int *)x;
}
int binarySearchA(int key, int num) {
	int ok = -1, ng = num, mid;
	while (ng - ok > 1) {
		mid = (ng + ok) / 2;
		if (a[mid] < key)
			ok = mid;
		else
			ng = mid;
	}
	return ng;
}
int binarySearchC(int key, int num) {
	int ng = -1, ok = num, mid;
	while (ok - ng > 1) {
		mid = (ok + ng) / 2;
		if (c[mid] > key)
			ok = mid;
		else
			ng = mid;
	}
	return ok;
}
int main() {
	int numA, numC;
	ll ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &c[i]);
	qsort(a, n, sizeof(int), cmpint);
	qsort(c, n, sizeof(int), cmpint);
	for (int i = 0; i < n; i++) {
		// a<b && b<c
		numA = binarySearchA(b[i], n);
		numC = n - binarySearchC(b[i], n);
		ans += (ll)numA * numC;
	}
	printf("%lld\n", ans);
	return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    ll N;
    cin >> N;
    if(N % 2 == 1){
        PRINT("0");
        return 0;
    }
    ll ans = 0;
    ll div = 5;
    while(div > 0 && div <= N){
        ans += (N / 2) / div;
        div *= 5;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception{
		int a, b, area, length;
		String str;	//?????°???????´?????????????????????????
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		str = br.readLine();
		
		String[] splittedStr = str.split(" ", 0);	//?????°???????????§????????????
		a = Integer.parseInt(splittedStr[0]);		//??????????????´??°?????????
		b = Integer.parseInt(splittedStr[1]);		//??????
		
		area = a*b;
		length = 2*(a+b);
		
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 16896
n = input()

if ((int(n[0]) + int(n[1])+ int(n[2]) + int(n[3])) ==7):
    print(n[0]+'+'+n[1]+'+'+n[2]+'+'+n[3]+'=7')
elif ((int(n[0]) - int(n[1])+ int(n[2]) + int(n[3])) ==7):
    print(n[0]+'-'+n[1]+'+'+n[2]+'+'+n[3]+'=7')
elif ((int(n[0]) + int(n[1]) - int(n[2]) + int(n[3])) ==7):
    print(n[0]+'+'+n[1]+'-'+n[2]+'+'+n[3]+'=7')
elif ((int(n[0]) + int(n[1]) - int(n[2]) - int(n[3])) ==7):
    print(n[0]+'+'+n[1]+'-'+n[2]+'-'+n[3]+'=7')
elif ((int(n[0]) + int(n[1]) + int(n[2]) - int(n[3])) ==7):
    print(n[0]+'+'+n[1]+'+'+n[2]+'-'+n[3]+'=7')
elif ((int(n[0]) - int(n[1]) - int(n[2]) + int(n[3])) ==7):
    print(n[0]+'-'+n[1]+'-'+n[2]+'+'+n[3]+'=7')
elif ((int(n[0]) - int(n[1]) + int(n[2]) - int(n[3])) ==7):
    print(n[0]+'-'+n[1]+'+'+n[2]+'-'+n[3]+'=7')
elif ((int(n[0]) - int(n[1]) - int(n[2]) - int(n[3])) ==7):
    print(n[0]+'-'+n[1]+'-'+n[2]+'-'+n[3]+'=7')

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)

#define pqueue priority_queue<int,vector<int>,greater<int >> 
     
     
int main(){

	ll n , d; sld(n); sld(d);

	d = ((2* d)+1);

	ll ans = n /d;

	if(n %  d != 0 ) ans++;

	pld(ans);

           
     
     
        
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>
#include <cstdint>
#include <cstring>

using namespace std;


//#define DEBUG

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

#ifdef DEBUG
	cout << N << endl;
#endif
	long long int SUM = 0;
	long long int NN = N;

	if (N == 1){
		cout << 0 << endl;
#ifdef DEBUG
		system("pause");
#endif
		return 0;
	}

	for (int i = 1; i < N; i++){
		//if (i == N){
		//	SUM += i % 1;
		//	cout << i << "," << 1 << "," << i % 1 << endl;
		//}
		//else{
		//	SUM += i % (i + 1);
		//	cout << i << "," << i + 1 << "," << i % (i + 1) << endl;
		//}
		SUM += i;
	}

	cout << SUM << endl;

//#ifdef DEBUG
	//system("pause");
//#endif
	return 0;
}

Measured memory_bytes: 256
//Zory-2018
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;

namespace mine
{
	typedef long long ll;
	const int INF=0x3f3f3f3f;
	int qread()
	{
		int ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-') f=-1;;c=getchar();}
		while(c>='0' and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}

	const int MAX_N=1e6+10;
	char s[MAX_N];
	ll num[2][MAX_N];
	ll tot[MAX_N];
	void main()
	{
		int n;scanf("%d%s",&n,s);
		int m=0,c=0;
		for(int i=0;i<=n-1;i++)
		{
			m=num[0][i]=m+(s[i]=='M');
			c=num[1][i]=c+(s[i]=='C');
		}
		for(int i=0;i<=n-1;i++) if(s[i]=='M') tot[i]=num[1][n-1]-num[1][i];
		for(int i=n-1;i>=0;i--) tot[i]+=tot[i+1];
		
		int q;scanf("%d",&q);
		while(q--)
		{
			int k;scanf("%d",&k);
			
			ll ans=0;
			//DMC
			for(int i=0;i<=n-1;i++)
			{
				if(s[i]!='D') continue;
				ll tmp=tot[i]-tot[min(n,i+k)];
				tmp-=(ll)(num[0][min(n-1,i+k-1)]-num[0][i])*(num[1][n-1]-num[1][min(n-1,i+k-1)]);
				ans+=tmp;
			}
			printf("%lld\n",ans);
		}
	}
};
int main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll keta = 0;
    ll n = N;
    while(n > 0){
        keta += n % 10;
        n /= 10;
    }
    if(N % keta == 0){
        print("Yes");
    }else{
        print("No");
    }


}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let mut s: String = sc.read();

    let patterns = vec!["dream", "dreamer", "erase", "eraser"];
    'again: while s.len() > 0 {
        for &pat in &patterns {
            if s.ends_with(pat) {
                s.truncate(s.len() - pat.len());
                continue 'again;
            }
        }
        break;
    }
    println!("{}", if s.len() == 0 { "YES" } else { "NO" });
}


Measured memory_bytes: 2308
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def f(x1, x2, y1, y2):
    return abs(x1 - x2) + abs(y1 - y2)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    AB = [il() for _ in range(N)]
    CD = [il() for _ in range(M)]
    for a, b in AB:
        ret = MAX
        dist = MAX
        for m in range(M):
            c, d = CD[m]
            d = f(a, c, b, d)
            if d == dist:
                ret = min(m + 1, ret)
            elif d < dist:
                dist = d
                ret = m + 1
        print(ret)


if __name__ == '__main__':
    main()


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

ll N;


int main(){
    cin >> N;
    if(N == 1) {cout << "0"; return 0;}

	ll num = N; // 素因数分解する変数num 

    vector<int> y(100);
    for( int x = 1; x < 14; ++x){
        int min_y = x * (x + 1) / 2;
        int max_y = (x + 2) * (x + 1) / 2;
        for(int i = min_y; i < max_y; ++ i){
            y[i] = x;
        }
    }
 
    // 素因数分解
    int primes[100000];
    int idx = -1;
	for (ll i = 2; i * i <= N; i++) {
        if(num%i==0){idx++;}
		while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
			primes[idx]++; //割った個数を配列に足す
			num /= i;
		}
	}
    if( num > 1 ){ idx++; primes[idx] = 1; }
    int cnt = 0;
    int idx_ = 0;
    while( primes[idx_] > 0 ){
        int u =  primes[idx_++];
        cnt += y[u];
    }
    cout << cnt;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
using namespace std ; 
int main(){
 int n ; 
 cin>> n ; 
 vector<int> a(n) ; 
 for(int i = 0 ; i < n ; ++i) cin>> a[i] ; 
 ll ans = LLONG_MAX ; 
  for(int i = 1 ; i <= 100 ; ++i){
	  ll maxans = 0 ; 
	  for(int j = 0 ; j < n ; ++j){
		  maxans= maxans + (a[j] - i)*(a[j] - i) ; 
       }
       if(maxans < ans)
         ans = maxans ; 
	 }
	 cout<<ans<<endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MOD = 998244353;

const double EPS = 1e-6;
const int MAX = 300 * 1000 + 47;


int F[MAX];
int RF[MAX];
char S[4][MAX];
int U[MAX], D[MAX], L[MAX], R[MAX];
int X[2][MAX];

int BP(int a, int n)
{
    int res = 1;
    while(n)
    {
        if (n & 1)res = (res * 1LL * a) % MOD;
        a = (a * 1LL * a) % MOD;
        n >>= 1;
    }
    return res;
}

int BIN(int n, int k)
{
    if (k > n)return 0;
    return (F[n] * 1LL * RF[k] % MOD) * 1LL * RF[n-k] % MOD;
}


void calc(int *A, int *B, int *C, int n, int m, int *R)
{
    int x = 0, y = 0;
    FOR(i, 0, n) x += A[i];
    FOR(i, 0, m)
    {
        y += B[i] + C[i];
        R[i] = BIN(x + y - 1, x - 1);
    }
}

int SOLVE(int *U, int *D, int *L, int *R, int n, int m)
{
    calc(U, L, R, n, m, X[0]);
    reverse(L, L + m);
    reverse(R, R + m);
    calc(D, L, R, n, m, X[1]);
    reverse(L, L + m);
    reverse(R, R + m);
    reverse(X[1], X[1] + m);
    X[1][m] = 1;
    int ans = 0;
    int sum = 0;
    
    
    FOR(i, 0, m)
    {
        sum += i ? X[0][i-1] : 1;
        if (sum >= MOD)sum -= MOD;
        sum *= L[i] + R[i];
        if (sum >= MOD)sum -= MOD;
        ans = (ans + sum * 1LL * X[1][i+1]) % MOD;
    }
    return ans;
}


int main()
{
    F[0] = RF[0] = 1;
    FOR(i, 1, MAX)
    {
        F[i] = F[i-1] * 1LL * i % MOD;
        RF[i] = BP(F[i], MOD - 2);
    }
    
    int n, m;
    scanf("%d%d", &n, &m);
    
    FOR(i, 0, 4)
        scanf("%s", S[i]);
    
    int sz = 0;
    FOR(i, 0, n)
        if (S[0][i] != '0' || S[1][i] != '0')
            L[sz] = S[0][i] - '0',
            R[sz] = S[1][i] - '0',
            ++sz;
    n = sz;
    sz = 0;
    FOR(i, 0, m)
        if (S[2][i] != '0' || S[3][i] != '0')
            U[sz] = S[2][i] - '0',
            D[sz] = S[3][i] - '0',
            ++sz;
    m = sz;

    
    int res = SOLVE(U, D, L, R, m, n);
    res += SOLVE(L, R, U, D, n, m);
    res %= MOD;
    cout << max(1, res) << endl;
    
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int h, a[MAX+1];

void maxHeapify(int i) {
    int left = 2 * i;
    int right = 2 * i + 1;
    int largest;

    if (left <= h && a[left] > a[i]) {
        largest = left;
    } else {
        largest = i;
    }
    if (right <= h && a[right] > a[largest]) {
        largest = right;
    }

    if (largest != i) {
        swap(a[i], a[largest]);
        maxHeapify(largest);
    }
}

int extract() {
    if (h < 1) return -INFTY;
    int maxv = a[1];
    a[1] = a[h--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) {
    if (key < a[i]) return;
    a[i] = key;
    while (i > 1 && a[i / 2] < a[i]) {
        swap(a[i], a[i / 2]);
        i = i / 2;
    }
}

void insert(int key) {
    h++;
    a[h] = -INFTY;
    increaseKey(h, key);
}

int main() {
    int key;
    string com;

    while (true) {
        cin >> com;
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i') {
            cin >> key;
            insert(key);
        } else {
            cout << extract() << endl;
        }
    }
}



Measured memory_bytes: 7060
#include <iostream>
#include <set>
#include <stack>
#include <vector>
#include <map>
#include <string>
#include <string.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;

int DP[3001][3001],BT[3001][3001];

int main()
{
	string s, t,name;
	cin >> s >> t;
	for (int i = 0; i < s.size() + 1; i++) 
	{
		for (int j = 0; j < t.size() + 1; j++) 
		{
			if (i == 0 || j == 0)
			{
				DP[i][j] = 0;
			}
			else if (s[i-1] == t[j-1]) 
			{
				DP[i][j] = DP[i - 1][j - 1] + 1;
				BT[i][j] = 0;
			}
			else 
			{
				DP[i][j] = max(DP[i][j - 1], DP[i - 1][j]);
				if (DP[i][j] == DP[i][j - 1])
				{
					BT[i][j] = 1;
				}
				else
					BT[i][j] = 2;
			}
		}
	}
	int i = s.size(), j = t.size();
	int temp = DP[i][j];
	name.resize(temp);
	while (true) 
	{
		if (i == 0 || j == 0)
			break;
		if (BT[i][j] == 0)
		{
			name[temp-1] = s[i-1];
			temp--;
			i--;
			j--;
		}
		if (BT[i][j] == 1) 
		{
			j--;
		}
		else if (BT[i][j] == 2)
		{
			i--;
		}
	}
	cout << name;
}

Measured memory_bytes: 70656
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b, c; cin >> n >> a >> c >> b;
	cout << (a + b + c + n) / 60 << endl;
	cout << (a + b + c + n) % 60 << endl;
	cin >> n;
}


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


using namespace std;
int main() {
    long  x,h=0;
 cin>>x;

     while (x>=5)
     {
         if(x>=500)
         {
             x-=500;
             h+=1000;

         } else if (x>=5)
         {
             x-=5;
             h+=5;

         }
     }

 cout<<h;

    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	set<int> myset;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		myset.insert(x);
	}
	if ((int)myset.size() != n) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  int N, K;
  cin >> N >> K;
  double ans=0;
  for(int i=1; i<=N; i++){
    double score=i;
    while(score<K) score*=2;
    ans+=1/(score/i)/N;
  }
  cout << setprecision(15) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import collections as c
import sys
H, W = map(int, input().split())
A = (sys.stdin.read()).replace('\n', '')
deck = c.Counter(list(map(str, A)))

is_Hodd = H%2
is_Wodd = W%2

count = list(deck.values())
if is_Hodd and is_Wodd:
	one = 1
	two = H//2 + W//2
	four = (H//2) * (W//2)

	for i in range(len(count)):
		if count[i] >= 4*four:
			count[i] -= 4*four
			four = 0
			break
		else:
			tmp = count[i]//4
			count[i] -= 4*tmp
			four -= tmp
			
	for i in range(len(count)):
		if count[i] >= 2*two:
			count[i] -= 2*two
			two = 0
			break
		else:
			tmp = count[i]//2
			count[i] -= 2*tmp
			two -= tmp

	for i in range(len(count)):
		if count[i] > 0:
			count[i] -= 1
			one = 0

	if four == 0 and two == 0 and one == 0:
		cond = 1
	else:
		cond = 0

elif is_Hodd or is_Wodd:
	if is_Hodd:
		two = W//2
	else:
		two = H//2

	four = (H//2) * (W//2)

	for i in range(len(count)):
		if count[i] >= 4*four:
			count[i] -= 4*four
			four = 0
			break
		else:
			tmp = count[i]//4
			count[i] -= 4*tmp
			four -= tmp
			
	for i in range(len(count)):
		if count[i] >= 2*two:
			count[i] -= 2*two
			two = 0
			break
		else:
			tmp = count[i]//2
			count[i] -= 2*tmp
			two -= tmp

	if four == 0 and two == 0:
		cond = 1
	else:
		cond = 0

else:
	four = (H//2) * (W//2)

	for i in range(len(count)):
		if count[i] >= 4*four:
			count[i] -= 4*four
			four = 0
			break
		else:
			tmp = count[i]//4
			count[i] -= 4*tmp
			four -= tmp

	if four == 0:
		cond = 1
	else:
		cond = 0

if cond:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3444
N, M = gets.strip.split.map(&:to_i)

mod = 10 ** 9 + 7

# bf: broken floors
bf = {}
M.times.map { bf[gets.strip.to_i] = 1 }

dp = Array.new(N + 1){0}

dp[0] = 1
dp[1] = 1 if bf[1].nil?

(2..N).each do |i|
  next unless bf[i].nil?
  #dp[i] = dp[i - 1] + dp[i - 2]
  dp[i] = (dp[i - 1] + dp[i - 2]) % mod
end

# puts dp[N] % mod
puts dp[N]


Measured memory_bytes: 9852
#include <bits/stdc++.h>
#include <string.h>
#define ll long long
using namespace std;
struct value
{
	ll x;
	ll y;
};
bool compare(value a, value b)
{
	//for descending order replace with a.roll >b.roll
	if (a.y < b.y)
		return 1;
	else
		return 0;
}
ll sum(ll n)
{
	ll c;
	ll sum1=0;
	while(n>0)
	{
		c=n%10;
		sum1=sum1+c;
		n=n/10;
	} return sum1;
}
ll minm(ll arr[],ll n)
{
	ll mi=arr[0];
	for(ll i=0;i<n;i++)
	{ 
		if(mi>arr[i])
	     mi=arr[i];
	}
	return mi;
}
ll maxm(ll arr[],ll n)
{
	ll ma=arr[0];
	for(ll i=0;i<n;i++)
	{ 
	if(ma<arr[i])
	     ma=arr[i];
	}
	return ma;
}
ll pos(ll arr[],ll n)
{
	ll o=maxm(arr,n);
	ll po;
	for(ll i=0;i<n;i++)
	{
		if(arr[i]==o)
		   po=i;
	}return po;
}
void pk()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll sum=0;
	if(k<=a)
	   {cout<<k; return;}
	sum=sum+a;
	k=k-a;
	if(k<=0)
	{
		cout<<sum;
		return;
	}
	k=k-b;
	if(k<=0)
	{
		cout<<sum;
		return;
	}
	sum=sum-min(k,c);
	cout<<sum;

	

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
		pk();
	//}
	
}

Measured memory_bytes: 3648
import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(
				new InputStreamReader (System.in));
		String line=br.readLine();
		String[] str = line.split(" ");
		int a=Integer.parseInt(str[0]);
		int b=Integer.parseInt(str[1]);
		if(a<b) System.out.println("a < b");
		else if(a>b) System.out.println("a > b");
		else System.out.println("a == b");
	}
}

Measured memory_bytes: 24240
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int size =s.size();
int win =0;
for(int i=0;i<size;i++){
 if(s[i] =='o'){
  win +=1;
  }
}

 if(15-size+win >=8){
  cout<<"YES";
}else{
  cout<<"NO";
}
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) {
		cout << "Zero" << endl;
	}
	else if (b < 0) {
		if ((b - a) % 2 == 0) {
			cout << "Negative" << endl;
		}
		else {
			cout << "Positive" << endl;
		}
	}
	else {
		cout << "Positive" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
w, h, n = map(int, (input().split()))
x = [0, w]
y = [0, h]
A = []

for i in range(n):
    a = list(map(int, input().split()))
    A.append(a)

for j in A:
    if j[2] == 1:
        x[0] = max(x[0], j[0])
    if j[2] == 2:
        x[1] = min(x[1], j[0])
    if j[2] == 3:
        y[0] = max(y[0], j[1])
    if j[2] == 4:
        y[1] = min(y[1], j[1])

if x[0] >= x[1] or y[0] >= y[1]:
    print("0")
else:
    print((x[1] - x[0]) * (y[1] - y[0]))

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

int main(){
  int N, M;
  cin >> N >> M;
  if(M==0){
    if(N==1){
      cout << "0" << endl;
    }else{
      cout << (int)pow(10,N-1) << endl;
    }
    return 0;
  }
  vector<char> num(N,'n');
  for(int i=0; i<M; i++){
    int s; char c; cin >> s >> c;
    if(num[s-1]!='n'){
      if(num[s-1]!=c){
        cout << "-1" << endl;
        return 0;
      }
    }else{
      num[s-1]=c;
    }
  }
  if(N>=2 && num[0]==0){
    cout << "-1" << endl;
    return 0;
  }
  int n = 0;
  if(N>=2) n=pow(10,N-1);
  for(int i=n; i<pow(10, N); i++){
    string s=to_string(i);
    bool f = true;
    for(int j=0; j<N; j++){
      if(s[j]==num[j] || num[j]=='n') continue;
      f =false; break;
    }
    if(f){
      cout << s << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 256
k, a, b = map(int, input().split())

if 2 < (b-a):
    if k-(a-1) >= 2:
        q, r = divmod(k-(a-1), 2)
        ans = (b-a)*q+r+a
    else:
        ans = k+1

else:
    ans = k+1

print(ans)


Measured memory_bytes: 38256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);
template <class A>ostream & operator<<(ostream & o, const vector<A> & p) { o << "{"; for (int i = 0; i < (int)p.size(); ++i)o << (i > 0 ? ", " : "") << p[i]; o << "}"; return o; }
template <class A, class B>ostream & operator<<(ostream & o, const pair<A, B> & p) { o << "{" << p.first << ", " << p.second << "}"; return o; }
template <class A, class B>ostream& operator<<(ostream & o, const map<A, B> & p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
template <class A>ostream & operator<<(ostream & o, const set<A> & p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
void print() { cerr << endl; }
template <class H> void print(H && h) { cerr << h << endl; }
template <class H, class... T> void print(H && h, T && ... t) { cerr << h << " "; print(forward<T>(t)...); }

int main() {
	int a, b, c; cin >> a >> b >> c;
	cout << a << " " << b << " " << c*3 - a - b << endl
		<< 4 * c - 2 * a - b << " " << c << " " << 2 * a + b - c * 2 << endl
		<< a + b - c << " " << 2 * c - b << " " << 2 * c - a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n; cin>>n;
	if(n % 2){
		cout<<0;
		return 0;
	}else{
		n /= 2;
		ll ans = 0;
		while(n){
			n /= 5;
			ans += n;
		}
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, K = map(int, input().split())
    
    D = [0]*N
    for i in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            D[a-1] += 1
    
    print(D.count(0))


if __name__ == '__main__':
    main()

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

int main(){
    string s,t;
    cin >> s >> t;
    int a = t.size();
    char x = t[a-1];
    string s1 = s + x;
    if(s1 == t)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

int D;
int c[26], s[365][26], t[365], last[26], ans[366];

void calc() {
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = ans[i] + s[i][t[i]];
        last[t[i]] = i + 1;
        for (int j = 0; j < 26; ++j)
            ans[i + 1] -= c[j] * (i + 1 < last[j] ? i + 1 : i + 1 - last[j]);
    }
}

void change(int d, int q) {
    int old = t[d];
    if (old == q)
        return;

    t[d] = q, last[old] = 0, last[q] = 0;
    int dif = 0, pos1 = 0, pos2 = 0;
    for (int i = 0; i < D; ++i) {
        last[t[i]] = i + 1;
        if (i < d)
            pos1 = last[q], pos2 = last[old];
        else {
            ans[i + 1] += s[d][q] - s[d][old];
            if (last[q] == d + 1)
                dif += c[q] * (d + 1 - pos1);
            if (last[old] <= d + 1)
                dif -= c[old] * (d + 1 - pos2);
        }
        ans[i + 1] += dif;
    }
}

void greedy() {
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = INT_MIN;
        int maidx = 0;
        for (int k = 0; k < 26; ++k) {
            int res = ans[i] + s[i][k], old = last[k];
            last[k] = i + 1;
            for (int j = 0; j < 26; ++j)
                res -= c[j] * (i + 1 - last[j]);

            if (ans[i + 1] < res) {
                ans[i + 1] = res;
                maidx = k;
            }
            last[k] = old;
        }
        t[i] = maidx;
        last[t[i]] = i + 1;
    }
}

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

    cin >> D;
    for (int i = 0; i < 26; ++i)
        cin >> c[i];
    for (int i = 0; i < D; ++i)
        for (int j = 0; j < 26; ++j)
            cin >> s[i][j];

    greedy();
    std::mt19937_64 gen(0);
    std::uniform_int_distribution<> dist1(1, D);
    std::uniform_int_distribution<> dist2(1, 26);

    for (int i = 0; i < 10000; ++i) {
        stack<pii> stk;
        int pres = ans[D];
        for (int j = 0; j < 100; ++j) {
            int d = dist1(gen), q = dist2(gen);
            d--, q--;
            stk.emplace(pii{d, t[d]});
            change(d, q);
            if (ans[D] >= pres)
                break;
        }
        if (ans[D] < pres) {
            while (!stk.empty()) {
                auto [d, q] = stk.top();
                change(d, q);
                stk.pop();
            }
        }
    }
    for (int i = 0; i < D; ++i)
        cout << t[i] + 1 << '\n';

    return 0;
}


Measured memory_bytes: 3620
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

int(x) = parse(int,x)

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function check(A, arr)
  score = 0
  q = size(arr)[2]
  for i in 1:q
    a,b,c,d = @view arr[:,i]
    if c == A[b] - A[a] 
      score += d
    end
  end
  return score
end

function dfs(A, n, m, p, arr, numMax)
  
  # 葉まで行ったら
  if p == n
    # 処理を書く
    #println(A, " ", numMax)
    numMax = max(numMax, check(A,arr)) # println(A)
    
    #println(A, " ", numMax)
    return  numMax
  end
  
  # 葉にいって無いなら子を探す
  p+=1
  for i in A[p-1]:m
    A[p] = i
    numMax = dfs(A, n, m, p, arr, numMax) 
  end
  return numMax
end

function main()
  n, m, q = readint()
  abcd = Array{int, 2}(undef,4,q)
  for i in 1:q
    kari = readint()
    abcd[:,i] .=  kari
  end

  #println(abcd)
  # A の列の定義
  A = ones(int,n)
  println(dfs(A, n, m, 1, abcd, 0))
end

main()

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

int main()
{
	long int n,k,q;
    cin>>n>>k>>q;
    vector<long int> a(q);
    vector<long int> c(n,0);
    for(long int i=0;i<q;i++){
        cin>>a[i];
        c[a[i]-1]++;
    }

    for(long int i=0;i<n;i++)
        cout<<((k-q+c[i]>0)? "Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	ostringstream sout;
	int res = 0;
	for (int i = 0; i < 1000; i++){
		sout.str("");
		sout.clear(stringstream::goodbit);
		sout << setfill('0') << setw(3) << i;
		string ptn = sout.str();
		int idx = 0;
		for (int j = 0; j < n; j++){
			if (s[j] == ptn[idx]) idx++;
			if (idx == 3) {
				res++;
				break;
			}
		}

	}

	cout << res << endl;


}


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

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define FORR(i,a,b) for(int i=(int)b-1; i>=a; i--)

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

int n,m,c,s,t;
int g[25][125][125];
const int INF = 1<<28;
int p[25];
int q[52];
int r[52];
int di[25252];

int main(){
    while(true){
        cin>>n>>m>>c>>s>>t;
        if(n+m+c+s+t==0)break;
        REP(i,c+1)REP(j,n)REP(k,n)g[i][j][k] = INF;
        REP(_,m){
            int x,y,a,b;
            cin>>x>>y>>a>>b;
            b--;x--;y--;
            g[b][y][x] = min(g[b][y][x], a);
            g[b][x][y] = g[b][y][x];
        }
        REP(i,c)scanf("%d",p+i);
        REP(x,c){
            // WF
            REP(k,n)REP(i,n)REP(j,n)CHMIN(g[x][i][j], g[x][i][k]+g[x][k][j]);
            // dist
            REP(i,p[x]-1)scanf("%d",q+i);
            q[p[x]-1] = 25252;
            REP(i,p[x])scanf("%d",r+i);
            di[0] = 0;
            int it = 0;
            FOR(i,1,25252){
                di[i] = di[i-1] + r[it];
                if(i == q[it]){
                    it++;
                }
            }
            // g
            REP(i,n)REP(j,n)if(g[x][i][j]<INF/2){
                // printf("%d: %d->%d = %d(%d)\n",x,i,j,di[g[x][i][j]],g[x][i][j]);
                CHMIN(g[c][i][j], di[g[x][i][j]]);
            }
        }
        // total
        REP(k,n)REP(i,n)REP(j,n)CHMIN(g[c][i][j], g[c][i][k]+g[c][k][j]);
        int ans = g[c][s-1][t-1];
        if(ans>INF/2){
            puts("-1");
        }else{
            cout << g[c][s-1][t-1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4368
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve() {
	int ans = 0;

	bool V[MAX];
	for (int i = 0; i < n; i++) {
		B[i] = A[i];
		V[i] = false;
	}
	sort(B, B + n);
	for (int i = 0; i < n; i++) T[B[i]] = i;
	for (int i = 0; i < n; i++) {
		if (V[i]) continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while (true) {
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if (V[cur])break;
		}
		ans += min(S + (an - 2)*m, m + S + (an + 1)*s);
	}
	return ans;
}

int main(void) {
	cin >> n;
	s = VMAX;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		s = min(s, A[i]);
	}
	int ans = solve();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1200
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Character> list = new ArrayList<Character>();
        while (n-- > 0)
            list.add(sc.next().charAt(0));
        List<Character> list2 = new ArrayList<Character>(new HashSet<>(list));
        if (list2.size() == 4) {
            System.out.println("Four");
        } else if (list2.size() == 3) {
            System.out.println("Three");
        }
    }
}

Measured memory_bytes: 21972
#include <iostream>
using namespace std;
constexpr int MOD = 998244353;

template <int N>
struct Eratosthenes
{
    int w[N + 1];
    bool is_not_prime[N + 1];
    constexpr Eratosthenes() : w(), is_not_prime()
    {
        w[0] = 0;
        w[1] = 1;
        for (int i = 2; i <= N; i++)
        {
            w[i] = MOD - 1LL * w[MOD % i] * (MOD / i) % MOD;
        }
        for (int prime = 2; prime <= N; prime++)
        {
            if (is_not_prime[prime])
            {
                continue;
            }
            for (int k = N / prime; k > 1; --k)
            {
                is_not_prime[k * prime] = true;
                w[k * prime] -= w[k];
                if (w[k * prime] < 0)
                {
                    w[k * prime] += MOD;
                }
            }
            w[prime] -= w[1];
        }
    }
};

int main()
{
    constexpr int M = 1000000;
    constexpr auto e = Eratosthenes<M>();
    long long N, ans = 0;
    int a[1000001] = {};
    cin >> N;
    for (int i = 0, j; i < N; i++)
    {
        cin >> j;
        a[j] += j;
        if (a[j] >= MOD)
        {
            a[j] -= MOD;
        }
        ans -= j;
        if (ans < 0)
        {
            ans += MOD;
        }
    }
    for (int prime = 2; prime <= M; prime++)
    {
        if (e.is_not_prime[prime])
        {
            continue;
        }
        for (int k = M / prime; k > 0; --k)
        {
            a[k] += a[k * prime];
            if (a[k] >= MOD)
            {
                a[k] -= MOD;
            }
        }
    }
    for (int i = 1; i <= M; i++)
    {
        ans += 1LL * a[i] * a[i] % MOD * e.w[i] % MOD;
    }
    ans %= MOD;
    if ((ans & 1) == 1)
    {
        ans = (ans + MOD) >> 1;
    }
    else
    {
        ans = ans >> 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9596
//Date: 23/10/19
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif

    ll n;

    cin>>n;
    ll ans = 1e16;
    for(ll i = 2; i * i <= n; i++){
    	if(n % i == 0){
    		ans = min(ans, (i - 1) + (n / i - 1));
    	}
    }

    ans = min(ans, n - 1);

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    string S;
    cin >> S;
    for ( int i = 0; i < S.size()-1; i++ ) {
        if ( S[i] == S[i+1] ) {
            cout << i+1 << " " << i+2 << "\n";
            return 0;
        } else if ( i < S.size()-2 && S[i] == S[i+2] ) {
            cout << i+1 << " " << i+3 << "\n";
            return 0;
        }
    }
    cout << "-1 -1\n";
    return 0;
}

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

int main (void) {
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  int cnt = 1;
  for (int i = 0; i < N-1; i++){
    if (S[i] != S[i+1]) cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 512
import math

A, B, H, M = map(int, input().split())

H_angle = 30*H+0.5*M
M_angle = 6*M

angle = abs(H_angle-M_angle)
angle = min(angle, 360-angle)

ans = (A*A+B*B-2*A*B*math.cos(math.radians(angle)))**0.5
print(ans)


Measured memory_bytes: 9500
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long double a,b,h,m;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>h>>m;
	h+=m/60.00000;
	m=h;
	while(m>=1.0000000000000) m-=1.00000000000000;
	h/=12.00000000000000;
	h=fabs(h-m);
	h*=2.0000000;
	h*=3.14159265358979323846;
	cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2.00*a*b*cos(h))<<endl;
	return 0;
}


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

int main(){
	string N;
	cin >> N;
	bool flg = false;
	for(char s: N){
		if(s == '7'){
			flg = true;
			break;
		}
	}
	cout << (flg?"Yes":"No") << endl;

	return 0;	
}

Measured memory_bytes: 3592