akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)1000000007
// Big two primes 
#define X 1011001110001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int int
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vii vector<pi>
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}

int main()
{
    fio;

    int n,m, flag = 0;
    ll sum = 0;
    cin>>n>>m;

    vi a(n);

    for0(i, n)
    {
        cin>>a[i];
    }

    for0(i, n)
    {
        sum += a[i]; 
    }

    for0(i, n)
    {
        double d = (double)sum/(4*m);
        if(a[i] >= d)
        flag++;
    }

    if(flag >= m)
    cout<<"Yes"<<endl;

    else 
    cout<<"No"<<endl;

    rr;
}

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

def topological_sort(G):
    ret = []
    start = []
    parent = [set() for _ in range(len(G))]
    for u in range(len(G)):
        for v in G[u]:
            parent[v].add(u)
    for v in range(len(G)):
        if not parent[v]:
            start.append(v)

    while start:
        u = start.pop()
        ret.append(u)
        for v in G[u]:
            parent[v].remove(u)
            if not parent[v]:
                start.append(v)

    if any(parent):
        # G is not DAG
        return None
    return ret

N, M = map(int, input().split())
G = [[] for _ in range(N+1)]
parent = [[] for _ in range(N+1)]
for _ in range(M):
    x, y = map(int, input().split())
    G[x].append(y)
    parent[y].append(x)
V = topological_sort(G)
dp = [0] * (N+1)
for i in V:
    for j in parent[i]:
        dp[i] = max(dp[i], dp[j] + 1)
print(max(dp))

Measured memory_bytes: 91056
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


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

std::vector<ll> h(n);

rep(i,n) cin >> h.at(i);

sort(all(h));

ll atack=0;
for(ll i=0;i<n-k;i++){
  atack+=h.at(i);
}

cout << atack << endl;

}

Measured memory_bytes: 4852
//Wall

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

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

signed main (){
    int h,w;cin>>h>>w;
    vector<vector<int>>c(10,vector<int>(10));
    rep(i,0,10)rep(j,0,10)cin>>c[i][j];
    rep(k,0,10)rep(i,0,10)rep(j,0,10){
        //chmin(もともと, iからk + kからj);
        chmin(c[i][j],c[i][k]+c[k][j]);
    }
    int ans{};
    rep(i,0,h*w){
        int a;cin>>a;
        if(a>=0)ans+=c[a][1];
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn = 1e5 + 100;

string s[maxn];

int main () {
	ios_base::sync_with_stdio (false);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		s[i] = '.' + s[i] + '.';
	}
	for (int i = 0; i <= m + 1; i++) {
		s[n + 1] += '.';
		s[0] += '.';
	}
	
	if (s[1][1] != '#')
		return cout << "Impossible" << endl, 0;
	int xnow = 1, ynow = 1;
	while (true) {
		if (s[xnow + 1][ynow] == '#' and s[xnow][ynow + 1] == '#')
			return cout << "Impossible" << endl, 0;
		if (s[xnow - 1][ynow] == '#' and s[xnow][ynow - 1] == '#')
			return cout << "Impossible" << endl, 0;
		if (s[xnow + 1][ynow] == '#')
			xnow ++;
		else if (s[xnow][ynow + 1] == '#')
			ynow ++;
		else if (xnow == n and ynow == m)
			return cout << "Possible" << endl, 0;
		else
			return cout << "Impossible" << endl, 0;
	}
}


Measured memory_bytes: 1024
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
    if "##" in s[a:d]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[a:c]:
        print("No")
    elif "..." in s[b-2:d+1]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 40816
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),c[2]={0};
	for(int i=1;i<=n;++i)++c[gi()&1];
	if(c[1]&1)puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    int N,M,K;
    while (cin >> N >> M >> K) {
        bool good = false;
        FOR(i,0,N+1) FOR(j,0,M+1) {
            if (i*M + j*N - 2*i*j == K)
                good = true;
        }
        const string ans = good ? "Yes" : "No";
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe (fromJust)
import Data.List as List

solve :: Int -> String -> Int -> Int
solve a op b
    | op == "+" = a + b
    | otherwise = a - b

main :: IO()
main = do
    [a, op, b] <- words <$> getLine
    let aa = read a
    let bb = read b
    print $ solve aa op bb


Measured memory_bytes: 508
def knapsack(W,weight,value):
    n = len(weight)#or len(value)
    dp = [[0]*(W+1) for _ in range(n+1)]
    # 初期化
    for j in range(W):
        dp[0][j] = 0
    for i in range(n):
        for j in range(W+1):
            if weight[i] <= j:
                dp[i+1][j] = max(dp[i][j-weight[i]]+value[i],dp[i][j])
            else:
                dp[i+1][j] = dp[i][j]
    return dp

N,W = map(int,input().split())
values, weights = [],[]
for _ in range(N):
    ｗ,ｖ = map(int,input().split())
    values.append(v)
    weights.append(w)
    
dp = knapsack(W,weights,values)
print(dp[-1][-1])

Measured memory_bytes: 147056
#include <stdio.h>

#define N 100

int main(){
  int i,j,count,Arr[N],key;
  scanf("%d",&count);

  for(i=0;i<count;i++){
    scanf("%d",&Arr[i]);
  }
  
  for(i=0;j<count-1;j++){
    printf("%d ",Arr[j]);
  }
  printf("%d\n",Arr[count-1]);

  for(i=1;i<count;i++){
    key = Arr[i];
    j = i-1;
    while(j>=0 && Arr[j]>key){
      Arr[j+1]=Arr[j];
      j--;
      Arr[j+1]=key;
    }

    for(j=0;j<count-1;j++){
      printf("%d ",Arr[j]);
    }
    printf("%d\n",Arr[count-1]);
  }
  return 0;
}
    


  



Measured memory_bytes: 2056
class UnionFind:
    def __init__(self, n):
        self.v = [-1] * n

    def find(self, x):
        if self.v[x] < 0:
            return x
        else:
            self.v[x] = self.find(self.v[x])
            return self.v[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            if self.v[x] > self.v[y]:
                x, y = y, x
            self.v[x] += self.v[y]
            self.v[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.v[self.find(x)]


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())

    collapse_schedule = []
    for _ in range(M):
        A, B = (int(x) - 1 for x in input().split())
        collapse_schedule.append((A, B))
    collapse_schedule.reverse()

    uf = UnionFind(N)

    def evaluate(size):
        return size * (size - 1) // 2

    all_dropped = evaluate(N)
    curr = all_dropped

    ret = [-1] * M
    ret[-1] = all_dropped

    for i, (a, b) in zip(reversed(range(M - 1)), collapse_schedule):
        if not uf.same(a, b):
            sa, sb = uf.size(a), uf.size(b)
            ea, eb = evaluate(sa), evaluate(sb)

            curr += ea + eb

            uf.unite(a, b)

            sa = uf.size(a)
            ea = evaluate(sa)

            curr -= ea

        ret[i] = curr

    print(*ret, sep='\n')


if __name__ == '__main__':
    main()


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

int main() {
    long long b;
    while (cin >> b) {
        if (b == 0) break;
        int ans_a, ans_n;
        for (long long n = 1; n * n + n <= 2 * b; ++n) {
            if ((2 * b - n * n + n) % (2 * n) == 0) {
                ans_a = (2 * b - n * n + n) / (2 * n);
                ans_n = n;
            }
        }
        cout << ans_a << " " << ans_n << endl;
    }
}



Measured memory_bytes: 3100
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;
LL n, s;
std::vector<std::vector<std::vector<LL>>>memo;

LL dp(LL i, LL j, LL k)
{
	if (i == n)
	{
		if (j == 0 && k == s) return 1;
		return 0;
	}
	if (k > s) return 0;
	if (memo[i][j][k] != -1) return memo[i][j][k];
	LL res1 = dp(i + 1, j, k + j * 2);
	LL res2 = dp(i + 1, j + 1, k + (j + 1) * 2);
	LL res3 = (dp(i + 1, j, k + j * 2) * 2 * j) % mod;
	LL res4 = (j >= 1 ? (dp(i + 1, j - 1, k + (j - 1) * 2) * j * j) % mod : 0);
	return memo[i][j][k] = (res1 + res2 + res3 + res4) % mod;
}

int main()
{
	in >> n >> s;
	memo.resize(n + 1, std::vector<std::vector<LL>>(n + 1, std::vector<LL>(s + 1, -1)));
	out << dp(0, 0, 0) << std::endl;
}


Measured memory_bytes: 52224
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define STR_MAX 210

int main(void) {
    static char str[STR_MAX];
    get_str(str, STR_MAX);
    int len = strlen(str);

    int i;
    for(i = len/2-1; i >= 1; i--) {
        if(strncmp(str, &str[i], i) == 0) break;
    }
    printf("%d\n", i*2);
}

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

#define SIZE 100001

char *oddstr(char *s, int len)
{
    int i;
    char *o = (char *) malloc(len/2 + 8);
    for (i = 0; i < len; i+=2) {
        o[i/2] = s[i];
    }
    o[i/2] = '\0';
    return o;
}

int main(int argc, char **argv)
{
    char s[SIZE];
    scanf("%s", s);

    printf("%s\n", oddstr(s, strlen(s)));
    return 0;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#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(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int a,b;
    cin >> a >> b;
    cout << a - b + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<cmath>
using namespace std;
int main(){
    int n,k;
    while(cin>>n>>k,n||k){
        bitset<100000>bs;
        bool whiteFlag=false;
        while(k--){
            int a;
            cin>>a;
            if(a==0)whiteFlag=true;
            else{
                a--;
                bs[a]=1;
            }
        }
        int Max=0,cnt=0,lc=-1;
        for(int i=0;i<n;i++){
            if(bs[i])cnt++;
            else if(whiteFlag){
                if(lc==-1){
                    cnt++;
                    lc=cnt;
                }
                else{
                    cnt++;
                    cnt-=lc;
                    lc=cnt;
                }
            }
            else cnt=0;
            Max=max(Max,cnt);
        }
        cout<<Max<<endl;
    }

}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    rep(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }

    int count = 0;

    rep(i, n)
    {
        if (a[i] >= (double)sum / (4 * m))
            count++;
        if (count >= m)
            break;
    }
    string res = count == m ? "Yes" : "No";
    c(res);
}


Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

int main() {
	double N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	double ans;
	ans = ceil((N - K) / (K - 1) + 1);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

using face = array<int, 4>;
lint ans = 0;
map<face, lint> mp;

face rot(face f){
    face g;
    rep(i, 4) g[i] = f[(i+1)%4];
    return g;
}

void add(face f){
    rep(_, 4){
        ++mp[f];
        f = rot(f);
    }
}

void del(face f){
    rep(_, 4){
        --mp[f];
        f = rot(f);
    }
}

void dfs(int cur, array<face, 4> &a, lint tmp){
    if(cur == 4){
        ans += tmp;
        return;
    }
    if(mp.find(a[cur]) == mp.end()) return;
    tmp *= mp[a[cur]];
    del(a[cur]);
    dfs(cur+1, a, tmp);
    add(a[cur]);
}

int main(){
    int n;
    scanf("%d", &n);
    face fs[n];
    rep(i, n){
        rep(j, 4) scanf("%d", &fs[i][j]);
        add(fs[i]);
    }
    rep(i, n)For(j, i+1, n){
        auto f = fs[i], g = fs[j];
        del(f); del(g);
        rep(_, 4){
            array<face, 4> a;
            rep(i, 4) a[i] = {f[i], g[(4-i)%4], g[(7-i)%4], f[(i+1)%4]};
            dfs(0, a, 1);
            g = rot(g);
        }
        add(f); add(g);
    }
    printf("%lld\n", ans / 3);
}

Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <list>
#include <vector>

using namespace std;
typedef long long LL;

#define MIN(x, y) x<y?x:y

int main()
{
	int n, k;
	int x;
	int ans=0;

	cin>>n>>k;

	int d[k];
	int a[n];

	for(int i=0 ; i<n; i++){
		a[i]=0;
	}
	
	for(int i=0; i<k ; i++){
		cin>>d[i];
		for(int j=0; j<d[i] ; j++) {
			cin>>x;
			a[x-1]++;
		}
	}
	for(int i=0 ; i<n; i++){
	//	printf("%d: %d\n", i, a[i]);
		if(a[i]==0) ans++;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  if(m%n==0) cout <<n+m<<'\n';
  else cout <<m-n<<'\n';
  return (0);
}

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

#define ll long long int
#define all(v) v.begin(), v.end()
#define single(v) for (auto i: v) cout << i << " ";
#define double(v) for (auto i: v) { single(i); cout << endl; }
#define yes_no(boolean) if (boolean) cout << "YES"; else cout << "NO";
#define mn(a) *min_element(a.begin(), a.end())
#define mx(a) *max_element(a.begin(), a.end())


int main(){
    int n; cin >> n;
    string s; cin >> s;
    int res = 0, i = 0;
    while (i + 2 < s.size()){
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
            res++;
            i += 3;
        }else{
            i++;
        }
    }
    cout << res;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
count = [0] * N
for i in range(N):
  count[A[i] - 1]  += 1
  
nanimo = 0 
for i in range(N):
  nanimo += count[i] * (count[i] - 1) // 2
for i in range(N):
  tekito = count[A[i] - 1]
  if tekito == 2:
    s = nanimo - 1
  elif tekito == 1:
    s = nanimo
  else:
    s = nanimo -  ((tekito * (tekito - 1) //2) - ((tekito - 1) * (tekito - 2) //2))
  print(s)

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

int dictionaryOrder(const char *s1, const char *s2){
  while(*s1 == *s2){
    if(*s1 == '\0'){
      return 0;
    }
    s1 += 1;
    s2 += 1;
  }
  return (*s1 - *s2);
}
void sortStr(char str[][31], int pageList[], int strlen){
  int i, j, tempInt;
  char temp[31];
  for(i=0; i<strlen; i++){
    for(j=i+1; j<strlen; j++){
      if(dictionaryOrder(str[i], str[j]) > 0){
        strcpy(temp, str[i]);
        strcpy(str[i], str[j]);
        strcpy(str[j], temp);
        tempInt = pageList[i];
        pageList[i] = pageList[j];
        pageList[j] = tempInt;
      }
    }
  }
  for(i=0; i<strlen; i++){
    for(j=i+1; j<strlen; j++){
      if(dictionaryOrder(str[i], str[j]) == 0 && pageList[i]>pageList[j]){
        strcpy(temp, str[i]);
        strcpy(str[i], str[j]);
        strcpy(str[j], temp);
        tempInt = pageList[i];
        pageList[i] = pageList[j];
        pageList[j] = tempInt;
      }
    }
  }

}
int main(){
  int page, i=0, j;
  int pageList[100];
  char WordList[100][31];
  while(scanf("%s%d", WordList[i], &pageList[i]) != EOF){
    i+=1;
  }
  sortStr(WordList, pageList, i);
  char sameORnot[31];
  for(j=0; j<i; j++){
    if(j==0){
      printf("%s\n%d", WordList[0], pageList[0]);
      strcpy(sameORnot, WordList[0]);
    }else if(strcmp(sameORnot, WordList[j]) == 0){
      printf(" %d", pageList[j]);
    }else if(strcmp(sameORnot, WordList[j]) != 0){
      printf("\n%s\n%d", WordList[j], pageList[j]);
      strcpy(sameORnot, WordList[j]);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


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

    int n;
    ll k;
    cin >> n >> k;

    vector<int> a(n, 0);
    REP(i, n) cin >> a[i]; // 全部の道順

    vector<int> s; // tail + loop 個内の街における次へのワープ場所
    vector<int> road(n + 1, -1); // 自分までの街の個数
    int tail = 0; // ループに入るまでの街の個数
    int period = 1; // ループの中の街の個数

    int v = 1;
    // -1 はまだ自分までの街の個数を数えていない
    while (road[v] == -1) {
        road[v] = s.size();
        s.push_back(v);
        v = a[v - 1];
    }
    period = s.size() - road[v]; // ループの中の街の個数
    tail = road[v]; // ループに入るまでの街の個数

    if (k < tail) cout << s[k] << '\n';
    else {
        k -= tail;
        k %= period;
        cout << s[tail + k] << '\n';
    }
    return 0;
}


Measured memory_bytes: 5848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    vector<ll> dp(n + 1, 1e18);
    dp[1] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= k && i + j <= n; ++j) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    DEBUG(dp)
    cout << dp[n];
}
/************************************** END OF PROGRAM ******************************************/


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>

using namespace std;

int64_t comb(int n, int r) {
    int64_t res = 1;
    for(int i=0; i<r; i++) {
        res *= n-i;
        res /= i+1;
    }
    return res;
}

int main(void) {
    int N, A, B;
    cin >> N >> A >> B;
    vector<int64_t> v(N);
    for(int i=0; i<N; i++) {
        cin >> v[i];
    }

    sort(v.rbegin(), v.rend());

    cout << fixed << accumulate(v.begin(), v.begin()+A, 0.0) / (double)A << endl;

    bool isAllSame = true;
    for(int i=1; i<A; i++) {
        if(v[i] != v[i-1]) {
            isAllSame = false;
        }
    }

    if(isAllSame) {
        int cnt = count(v.begin(), v.end(), v[0]);
        int64_t ans = 0;
        for(int i=A; i<=min(B, cnt); i++) {
            ans += comb(cnt, i);
        }
        cout << ans << endl;
    } else {
        int cnt = count(v.begin(), v.end(), v[A-1]);
        int lrg = count_if(v.begin(), v.end(), [&](int64_t x) {return x > v[A-1];});
        cout << comb(cnt, A-lrg) << endl;
    }

    return 0;
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N;
  cin>>N;
  vector<int> v(N);
  for(int i = 0; i < N; i++) cin>>v[i];
  map<int,int> m;
  for(auto x:v) m[x]++;
  int ans = 0;
  sort(v.begin(),v.end());
  if(v[0]==1) {
    if(m[1]==1) cout<<1<<endl;
    else cout<<0<<endl;
  }
  else {
  for(int i = 0;i < N; i++){
    if(m[v[i]]!=1) continue;
    int t = v[i];
    bool ok = true;
    for(int j = 2; j*j<=t;j++){
      if(t%j==0){
        if(m[j]!=0||m[t/j]!=0) {
          ok = false;
          break;
        }
      }
    }
    if(ok) ans++;
  }
  cout<<ans<<endl;
  }
}
      

Measured memory_bytes: 33092
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>

#define N 10000

using namespace std;

string convert_string(int n)
{
  stringstream ss;
  ss << n;
  return ss.str();
}

bool check(string str)
{
  int len = str.size();
  if(len == 1) return true;

  bool flag = true;
  for(int i = 0, i_len = len/2; i < i_len && flag; i += 1) {
    flag &= (str[i] == str[len-1-i]);
  }

  return flag;
}

int solve(int n)
{
  string str;
  int result = 0;

  for(int i = 1; i <= N; i += 1){
    str = convert_string(i);

    if(check(str) && abs(result - n) > abs(i - n)){
      result = i;
    }
  }

  return result;
}

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

  cout << solve(n) << endl;

  return 0;
}

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

public class Main {
	public static void main(String[] args) {

		Input input = new Input();
		Converter conv = new Converter();
		
		
		String a[]= conv.strArr_(input.input(), "");
		String b[] = conv.strArr_(input.input(), "");
		String c[] = conv.strArr_(input.input(), "");
		int asize = a.length,bsize = b.length,csize = c.length;
		int acount=0,bcount=0,ccount=0;
		
		//1巡目
		String index = a[0];
		acount++ ;	
		
		//以降ループ
		while(acount<=asize && bcount<=bsize && ccount<=csize) {
			
			switch(index) {
			case "a":
				if(acount == asize) {
					System.out.println("A");
					acount++;	
				}else{
					index = a[acount];
					acount++;
					}
				break;
			
			case "b":
				if(bcount == bsize) {
					System.out.println("B");
					bcount++;	
				}else{
					index = b[bcount];
					bcount++;
					}
				break;
			
			case "c":
				if(ccount == csize) {
					System.out.println("C");
					ccount++;	
				}else{
					index = c[ccount];
					ccount++;
					}
				break;
			}
		}
		}
	}


class Input{
	
	private String buf;
	BufferedReader bufferdReader = new BufferedReader(new InputStreamReader(System.in));
	
/**
 * 標準入力取得用メソッド
 * @return buf 標準入力
 */
	
	public String input() {
	try{
		this.buf = bufferdReader.readLine();
	}catch(Exception e) {
	}
	return buf;
	}
}


class Converter{

	private int convInt=0;
	private String convStrArr[];

	/**
	 * String⇒int変換メソッド
	 * @return this.convInt int型
	 * @param convInt 変換対象文字列
	 */
	public int int_(String convInt){
		this.convInt = Integer.parseInt(convInt);
		return this.convInt;
	}
	
	/**
	 * String⇒String[]変換メソッド
	 * @param convStrArr 変換対象文字
	 * @param breakStr 区切り文字
	 * @return this.convStrArr 文字配列
	 */
	public String[] strArr_(String convStrArr,String breakStr){
		this.convStrArr = convStrArr.split(breakStr,0);
		return this.convStrArr;
	}
	
	
}


Measured memory_bytes: 32928
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    System.out.println((a < b ? a : b) + (c < d ? c : d));
  }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ff first
#define ss second
#define forn(i,n) for (int i=0;i<int(n);i++)
#define nfor(i,n) for (int i=int(n)-1;i>=0;i--)
#define rep(i,a,b)for (int i=a;i<=int(b);i++)
#define rev(i,a,b)for (int i=a;i>=int(b);i--)
#define hell 2000000000
#define fuck 2000000000000000000
using namespace std;
const int N = 100010;
const int M = 1000010;
const double PI = acos(-1.0);
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int gcd(int a,int b){return (b==0)?a:gcd(b,a%b);}

int main() {
	
	int n;
	cin>>n;
	rep(i,1,3500){
		rep(j,i,3500){
			if (1.0/i + 1.0/j >= 4.0/n)
				continue;
			int th = 1.0 / (4.0/n - 1.0/i - 1.0/j);
			if (1.0/th + 1.0/i + 1.0/j == 4.0/n){
				cout<<i<<" "<<j<<" "<<th;
				return 0;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> table(N, vector<int>(M));
  for (int i =0; i < N; i++) for (int j = 0; j < M; j++) cin >> table[i][j];
  
  for (int i = 0; i < N; i++) {
    vector<int> buffer(M);
    for (int j = 0;j < M;j++) {
      buffer[table[i][j]-1] = j+1;
    }
    for (int j = 0; j < M;j++) table[i][j] = buffer[j];
  }
  
  int ans = N;
  vector<bool> avail(M, true);
  for (int q = 0; q < M; q++) {
    vector<int> sums(M, 0);
    for (int i =0; i < N; i++) {
      int ma = M+1;
      int ma_idx = -1;
      for (int j = 0; j < M; j++) {
        if (!avail[j]) continue;
        if (table[i][j] < ma) {
          ma = table[i][j];
          ma_idx = j;
        }
      }
      
      sums[ma_idx]++;
    }
    
    int mx = -1;
    int mx_idx = -1;
    for (int j = 0; j < M; j++) {
      if (sums[j] > mx) {
        mx = sums[j];
        mx_idx = j;
      }
    }
    avail[mx_idx] = false;
    ans = min(ans, mx);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
        long M = scan.nextLong();
        long ans = 1;
        if(M%N==0){
            ans=M;
        }else if(N%M==0){
            ans=N;
        }else{
            for(long i=Math.min(N, M);i>1;i--){
                if(N%i==0 && M%i==0){
                    N/=i;
                    M/=i;
                    ans*=i;
                }
            }
            ans*=N*M;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

inline int read () {
    int ret = 0, t = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') t = -1, c = getchar();
    while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
    return ret * t;
}

const int MAXN = 200200, MAXS = 2020;
const int mod = 1e9 + 7;

int qpow (int x, int y) {
    int ret = 1;
    while (y) {
        if (y & 1) ret = 1ll * ret * x % mod;
        x = 1ll * x * x % mod;
        y >>= 1;
    }
    return ret;
}
int inv (int x) { return qpow(x, mod - 2); }

int fac[MAXS << 3] = {};
int binom (int x, int y) { return 1ll * fac[x] * inv(fac[y]) % mod * inv(fac[x - y]) % mod; }

int n;
int a[MAXN], b[MAXN];

int dp[MAXS << 1][MAXS << 1];

signed main () {
    n = read();
    int i, j;
    fac[0] = 1;
    for (i = 1; i <= n; i++) a[i] = read(), b[i] = read(), dp[MAXS - a[i]][MAXS - b[i]]++;
    for (i = 1; i <= (2000 << 3); i++) fac[i] = 1ll * fac[i - 1] * i % mod;
    for (i = 1; i <= MAXS + 2000; i++) for (j = 1; j <= MAXS + 2000; j++) 
        dp[i][j] += dp[i - 1][j] + dp[i][j - 1], dp[i][j] %= mod;
    int ans = 0;
    for (i = 1; i <= n; i++) {
        ans = (ans + dp[MAXS + a[i]][MAXS + b[i]]) % mod;
        ans = (ans - binom((a[i] + b[i]) * 2, a[i] * 2) + mod) % mod;
    }
    ans = 1ll * ans * 500000004 % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 65280
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define msi map<string,int>
#define si set<int>
#define all(v) v.begin(),v.end()
#define sz(v)  int((v).size())
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define dep(i,a,b)    for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mp make_pair
#define inparr(a,n) rep(i,0,n)cin>>a[i];
#define give(x,y) cout<<x<<" "<<y<<endl;
#define setp(n) cout<<fixed<<setprecision(n);
#define    endl '\n'

using namespace std;
int i,j,k,l;
void solve()
{
	int n,m;
	cin>>n>>m;
	int a[n],ans=0,vote=0;
	rep(i,0,n)
	{
		cin>>a[i];
		vote+=a[i];
	}
	float mini=(vote*1.0)/(4.00*m)*1.00;
	rep(i,0,n)
	{
		if(a[i]>=mini)
			ans++;
	}
	if(ans>=m)
		cout<<"Yes";
	else
		cout<<"No";
} 



signed main()
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int mod = 1e9 + 7;

int inc(int a, int b) { a += b; return a >= mod ? a - mod : a; }

int n, m, x[100010];

void task1()
{
	static int dp[100010][3];
	dp[0][0] = 1;
	static map<int, bool> X;
	for (int i = 1; i <= m; ++i) X[x[i]] = 1;
	for (int i = 1; i <= n; ++i)
	{
		dp[i][0] = dp[i - 1][0];
		dp[i][1] = inc(dp[i - 1][0], dp[i - 1][1]);
		dp[i][2] = inc(inc(inc(dp[i - 1][0], dp[i - 1][1]), dp[i - 1][1]), dp[i - 1][2]);
		if(!X.count(i - 1))
		{
			dp[i][0] = inc(dp[i][0], dp[i - 1][2]);
			dp[i][1] = inc(dp[i][1], dp[i - 1][2]);
			dp[i][2] = inc(dp[i][2], dp[i - 1][2]);
		}
	}
	printf("%d\n", dp[n][2]);
}

struct matrix
{
	int a[3][3];
	friend matrix operator * (matrix a, matrix b)
	{
		matrix c;
		memset(c.a, 0, sizeof c.a);
		for (int k = 0; k < 3; ++k)
			for (int i = 0; i < 3; ++i)
				for (int j = 0; j < 3; ++j)
					c.a[i][j] = (c.a[i][j] + 1LL * a.a[i][k] * b.a[k][j]) % mod;
		return c;
	}
} one, A, B, C;

matrix fpow(matrix a, int x)
{
	matrix ret = one;
	for (; x; x >>= 1)
	{
		if (x & 1) ret = ret * a;
		a = a * a;
	}
	return ret;
}

void work()
{
	/*
	1,0,1
	1,1,1
	1,2,2
	*/
	/*
	1,0,0
	1,1,0
	1,2,1
	*/
	one.a[0][0] = one.a[1][1] = one.a[2][2] = 1;
	A.a[0][0] = 1, A.a[0][1] = 0, A.a[0][2] = 1;
	A.a[1][0] = 1, A.a[1][1] = 1, A.a[1][2] = 1;
	A.a[2][0] = 1, A.a[2][1] = 2, A.a[2][2] = 2;
	B.a[0][0] = 1, B.a[0][1] = 0, B.a[0][2] = 0;
	B.a[1][0] = 1, B.a[1][1] = 1, B.a[1][2] = 0;
	B.a[2][0] = 1, B.a[2][1] = 2, B.a[2][2] = 1;
	matrix ret = one;
	for (int i = 1; i <= m; ++i)
	{
		ret = ret * fpow(A, x[i] - x[i - 1] - 1);
		ret = ret * B;
	}
	ret = ret * fpow(A, n - x[m]);
	C.a[0][0] = 1;
	ret = ret * C;
	printf("%d\n", ret.a[2][0]); 
}

int main()
{
	gii(n, m);
	for (int i = 1; i <= m; ++i) gi(x[i]);
	//task1();
	work(); 
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a, b, c;
		int ans = 0;
		
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		for(int i = a; i <= b; i++){
			if(c % i == 0)
				ans ++;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 26220
#include<stdio.h>
int main(){
	int N;
	scanf("%d", &N);
	long long int a[10005];
	long long int b[10005];
	for(int i=0; i<N; i++){
		scanf("%lld", &a[i]);
	}
	for(int i=0; i<N; i++){
		scanf("%lld", &b[i]);
	}
	long long int temp=0;
	for(int i=0; i<N; i++){
		if(a[i]<b[i]){
			temp+=(b[i]-a[i])/2;
		}else{
			temp-=(a[i]-b[i]);
		}
	}
	if(temp>=0){
		printf("Yes");
	}else{
		printf("No");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int N,D,X;
   cin>>N>>D>>X;
   int A[N];
   
   rep(i,N){
       cin>>A[i];
   }
   int sum=X;
   rep(i,N){
       int num=1;
       while(num<=D){
           num+=A[i];
           sum++;
       }
   }
   cout<<sum<<endl;
  
}

Measured memory_bytes: 3604
n = int(input())

if n < 500:
  while n % 5 != 0:
    n -= 1
    if n % 5 == 0:
      print(n)
      exit()
      
b = n % 500
a = n - b

ans = a*2
    
while b %5 != 0:
  b-=1
  if b%5 == 0:
    ans += b
    
print(ans)

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

int main(void) {
  vector<int> a(5);

  for (int i = 0; i < 5; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < 5; i++) {
    if (a.at(i) == 0) 
    cout << i+1 << endl;
  }
}

Measured memory_bytes: 3624
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    a, b, x = MI()
    n = b // x
    m = (a-1) // x
    print(n - m)


if __name__ == '__main__':
    main()

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

int main(){
    int pote,limit;
    cin>>pote>>limit;
    vector<int>hes(pote);
    for(int i=0;i<pote;i++){
        cin>>hes.at(i);
    }
    int zahyou=0;
    int bounds=1;
    for(int i=0;i<pote;i++){
        zahyou+=hes.at(i);
        bounds++;
        if(zahyou>limit){
            bounds-=1;
            break;
            
        }
        
        
    }
    cout<<bounds<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,k,num,i,j;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);

	if(a>=b && a>=c)	num=a;
	else if(b>=a && b>=c)	num=b;
	else			num=c;

	j=num;

	for(i=0;i<k;i++){
		j=j*2;
	}
	j=j-num;
	printf("%d\n",a+b+c+j);

	return 0;
}

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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 1e5 + 5;
const int oo = 0x3f3f3f3f;

int N, M, f[MAXN], a[MAXN];

inline int getf(int k) { return k == f[k] ? k : f[k] = getf(f[k]); }

vector<int> ss[MAXN];

bool vis[MAXN];

int main(){
	scanf("%d%d", &N, &M);
	up (i, 1, N) scanf("%d", &a[i]), f[i] = i;
	up (i, 1, M) {
		int x, y; scanf("%d%d", &x, &y);
		f[getf(x)] = getf(y);
	}
	up (i, 1, N) ss[getf(i)].push_back(i);
	int ans = 0;
	up (o, 1, N) if (!ss[o].empty()) {
		up (i, 0, SZ(ss[o]) - 1) vis[a[ss[o][i]]] = 1;
		up (i, 0, SZ(ss[o]) - 1) ans += vis[ss[o][i]];
		up (i, 0, SZ(ss[o]) - 1) vis[a[ss[o][i]]] = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528
import itertools

books = {}
name = 1
N,M,X = map(int, input().split())
for i in range(N):
    book = [int(i) for i in input().split()]
    books[name] = book
    name += 1

choices = []
for i in range(len(books.keys())):
    for j in itertools.combinations(books.keys(), i+1):
        choices.append(j)

prizes = []
for choice in choices:
    # print(choice)
    prize = 0
    score = [0]*M
    for num in choice:
        prize += books[num][0]
        score = [score[i]+books[num][i+1] for i in range(0,len(score))]
    # print(score)
    # print(min(score))
    # print(prize)
    if X<=min(score): 
        prizes.append(prize)
    # print('----')
if len(prizes) != 0: print(min(prizes))
else: print('-1')

Measured memory_bytes: 9552
#include <stdio.h>
int main(void){
    int i,j,k,n;
    int data[4][3][10] = {{{0}}};
    scanf("%d",&n);
    for(i = 0; i < n; i++) {
        int b, f, r, v;
        scanf("%d %d %d %d", &b, &f, &r, &v);
        data[b-1][f-1][r-1] += v;
        }
        for(i=0;i<4;i++){
            for(j=0;j<3;j++){
                for(k=0;k<10;k++){
                    printf(" %d",data[i][j][k]);
                    }
                printf("\n");}
            if(i!=3)
            printf("####################\n");
    }       
    return 0;
    
}



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

struct dsu {
  int cc;
  vector<int> p, sz, c;
  dsu(int n) : cc(n), p(n, -1), sz(n, 1), c(n) {}
  int root(int v) const {
    while (p[v] != -1) v = p[v];
    return v;
  }
  bool unite(int u, int v) {
    u = root(u), v = root(v);
    if (u == v) return false;
    --cc;
    if (sz[u] < sz[v]) swap(u, v);
    p[v] = u;
    sz[u] += sz[v];
    c[u] += c[v];
    return true;
  }
  bool same(int u, int v) const { return root(u) == root(v); }
  int size(int v) const { return sz[root(v)]; }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  vector<int> idx(n);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) {
    return a[i] < a[j];
  });
  vector<int> parity(n + 1);
  for (int v = 0; v <= n; ++v) {
    parity[v] = (v ? b[idx[v - 1]] : 0) != (v < n ? b[idx[v]] : 0);
  }
  ++n;
  sort(begin(a), end(a));
  struct edge {
    int u, v;
  };
  vector<edge> es(m);
  vector<vector<int>> g(n);
  for (int id = 0; id < m; ++id) {
    int l, r;
    cin >> l >> r;
    ++r;
    int u = lower_bound(begin(a), end(a), l) - begin(a);
    int v = lower_bound(begin(a), end(a), r) - begin(a);
    es[id] = {u, v};
    g[u].push_back(id);
    g[v].push_back(id);
  }
  dsu d(n);
  for (int v = 0; v < n; ++v) {
    d.c[v] = parity[v];
  }
  vector<bool> be(m);
  vector<int> deg(n);
  for (int id = 0; id < m; ++id) {
    if (d.same(es[id].u, es[id].v)) {
      continue;
    }
    d.unite(es[id].u, es[id].v);
    be[id] = true;
    ++deg[es[id].u];
    ++deg[es[id].v];
  }
  for (int v = 0; v < n; ++v) {
    if (d.c[d.root(v)] & 1) {
      cout << "-1\n";
      exit(0);
    }
  }
  queue<int> que;
  for (int v = 0; v < n; ++v) {
    if (deg[v] == 1) {
      que.push(v);
    }
  }
  vector<bool> vis(n);
  vector<int> res;
  while (not que.empty()) {
    int v = que.front();
    que.pop();
    vis[v] = true;
    for (int id : g[v]) {
      if (be[id]) {
        int to = v ^ es[id].u ^ es[id].v;
        if (vis[to]) {
          continue;
        }
        if (parity[v]) {
          res.push_back(id);
          parity[v] ^= 1;
          parity[to] ^= 1;
        }
        --deg[v];
        --deg[to];
        if (deg[to] == 1) {
          que.push(to);
        }
      }
    }
  }
  assert(all_of(begin(parity), end(parity), [](int e) { return e == 0; }));
  sort(begin(res), end(res));
  cout << res.size() << '\n';
  for (int i = 0; i < (int)res.size(); ++i) {
    cout << res[i] + 1 << " \n"[i == (int)res.size() - 1];
  }
}


Measured memory_bytes: 12428