akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Minpro2019_2_9
{
    class C
    {
        public static void Solve()
        {
            var s = Console.ReadLine().Split();
            var k = ulong.Parse(s[0]);
            var a = ulong.Parse(s[1]);
            var b = ulong.Parse(s[2]);

            if(b <= a + 1 || k <= a)
            {
                Console.WriteLine(k + 1);
                return;
            }
            
            ulong ans = (b-a) * ((k - (a - 1)) / 2) + (k - (a - 1)) % 2 + a;
            Console.WriteLine(ans);
        }
    }
}
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Minpro2019_2_9.C.Solve();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool sort_by_first(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.first < b.first); 
} 

int main()
{
  int n,m;
  cin >> n >> m;
  vector<pair<ll, ll>> vec(n);
  REP(i, n) {
    cin >> vec[i].first >> vec[i].second;
  }
  
  sort(vec.begin(), vec.end(), sort_by_first); 
  ll amt = 0;
  unsigned long long cost = 0;
  REP(i, n) {
    if ((amt + vec[i].second) >= m) {
      ll ad = m - amt;
      cout << cost + ad * vec[i].first << endl;
      return 0;
    } else {
      amt += vec[i].second;
      cost += vec[i].first * vec[i].second;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long N = sc.nextLong();
        long ans = 1;
        long kake = 2;
        while(N!=1) {
            ans += kake;
            kake *= 2;
            N = (long)Math.ceil(N/2);
        }
        p(ans);
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21588
#include<stdio.h>
#include<ctype.h>

int main(){
	char c;
	while(scanf("%c",&c)!=EOF){
		if(islower(c)){
			c=toupper(c);
		}else if(isupper(c)){
			c=tolower(c);
		}
		printf("%c",c);
	}
}


Measured memory_bytes: 2092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

int n;
vector<int> a;

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

bool check(int x){
    vector<P> sum(n + 1);
    sum[0] = P(0, 0);
    for(int i = 0; i < n; ++i){
        sum[i + 1].first = sum[i].first + ((a[i] >= x) ? 1 : -1);
        sum[i + 1].second = i + 1;
    }
    sort(sum.begin(), sum.end(), greater<P>());
    SegmentTree<int> seg(n + 1, [](int a, int b){return a + b;}, 0);
    ll cnt = 0;
    for(int i = 0; i <= n; ++i){
        int pos = sum[i].second;
        cnt += seg.query(pos, n + 1);
        seg.update(pos, seg[pos] + 1);
    }
    ll comparision = (ll)n * (n + 1) / 2;
    comparision = (comparision + 1) / 2;
    return cnt >= comparision;
}

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

    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    int ok = 1, ng = INF;
    while(ng - ok > 1){
        int mid = (ng + ok) / 2;
        if(check(mid))  ok = mid;
        else    ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 2440
L = []
for i in range(6):
    n = int(input())
    L.append(n)
    
k = L.pop()

cnt = 1
ans = "Yay!"
for i in range(len(L) - 1):
    for j in range(1, 5 - cnt + 1): 
        if abs(L[i] - L[j]) > k:
            ans = ":("
            break
    cnt += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int x, m = 1;
    cin >> x;

    for (int i = 1; i < x; ++i) {
        for (int j = 2; j < x; ++j) {
            if (pow(i, j) <= x && pow(i, j) >= m) {
                m = pow(i, j);
            }
        }
    }

    cout << m;


    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

int dist2(vi a, vi b) {
    int res = 0;
    int n = a.size();
    rep(i, n) {
        res += (a[i] - b[i]) * (a[i] - b[i]);
    }
    return res;
}

int main() {
    int n, d;
    cin >> n >> d;
    vector<vi> X(n, vi(d));
    rep(i, n) {
        rep(j, d) {
            cin >> X[i][j];
        }
    }

    lint res = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            int d = dist2(X[i], X[j]);
            int sq = sqrt(d);
            if (sq * sq == d) res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
table = []
dist = [[-1]*W for i in range(H)]
Q = deque()
dx = [0,1,0,-1]
dy = [1,0,-1,0]
ans = 0

for y in range(H):
    A = list(input())
    for x in range(W):
        if A[x] == "#":
            Q.append((y,x))
            dist[y][x] = 0
    table.append(A)

while Q:
    y,x = Q.popleft()
    for i in range(4):
        ny = y+dy[i]
        nx = x+dx[i]
        if 0<=ny<H and 0<=nx<W and dist[ny][nx] == -1 and table[ny][nx] == ".":
            dist[ny][nx] = dist[y][x]+1
            Q.append((ny,nx))
for i in range(H):
    ans = max(ans,max(dist[i]))
print(ans)

Measured memory_bytes: 121564
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;




int main(){
	while(true){
	double a[100005] = {0}, ave = 0, sum = 0;
	int ans = 0, n = 0;
	cin >> n;
	if(n == 0) return 0;
	ans = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	sum /= n;
	//cout<<sum<<endl;
	for(int i = 0; i < n; i++){
		if(a[i] <= sum) ans++;
	}
	printf("%d\n", ans);
}
	return 0;
}


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

int main(){
  int K;
  cin >> K;
  int Min;
  int Ans=0;
  int GCD;
  for(int a=1; a<=K; a++){
    for(int b=1; b<=K; b++){
      for(int c=1; c<=K; c++){
        Min=min(a, max(b, c));
        GCD=1;
        for(int i=2; i<=Min; i++){
          if(a%i==0 && b%i==0 && c%i==0){
            GCD=i;
          }
        }
        Ans+=GCD;
      }
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];  
  rep(i, n) {
    if(i == 0)
      h[0] = h[0] - 1;
    else if(h[i - 1] > h[i]) {
      cout << "No" << endl;
      return 0;
    } else if(h[i - 1] < h[i]) {
      h[i] = h[i] - 1;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
l=list(input())
l.reverse()
s="".join(l)

for i in range(len(s)):
    s=s.replace(s[0],"",1)
    s1=s[:(len(s)//2)]
    s2=s[(len(s)//2):]
    if s1==s2:
        print(2*len(s1))
        exit()


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
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;
}

#pragma endregion

int main() {
  int n = in();
  int x = in();
  vector<int> a(n);
  rep(i, n) { a[i] = in(); }
  sort(all(a));

  int ans = 0;
  rep(i, n) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    }
    if (i == n - 1 && x != 0 && ans == n) {
      ans--;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second
#define mset(x,v) memset((x),(v),sizeof(x))

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

const int MOD = 1e9+7;
ll n,s,ans;
ll x,m;
ll val[200005];
map<ll, int> prv;
int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> x >> m;
	int i=0;
	for (;i<n;i++) {
		
		if (prv.find(x)!=prv.end()) {
			break;
		}
		val[i]=x;
		ans+=x;
		prv[x]=i;
		x=(x*x)%m;
	}
	if (i<n) {
		n-=i;
		ll times = n/(i-prv[x]);
		ll k=0;
		for (int j=prv[x];j<i;j++) k+=val[j];
		ans+=k*times;
		n%=(i-prv[x]);
	} else {
		cout << ans << "\n";
		return 0;
	}
	for (i=0;i<n;i++) {
		ans+=x;
		x=(x*x)%m;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 7068
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;

long long int N;

void Input()
{
	cin >> N;
}

int main()
{
	Input();
	long long ans = 1 + N - 2;
	for (long long i = 2; i * i <= N; i++) {
		if (N % i) continue;
		ans = min(ans, i + N / i - 2);
	}
	cout << ans << endl;

	return 0;
}


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

void solve(int64_t n, int64_t x)
{
  for (int i = 1; i <= n - 2; i++)
  {
    for (int j = i + 1; j <= n - 1; j++)
    {
      for (int k = j + 1; k <= n; k++)
      {
        if (i + j + k == x)
          cnt++;
      }
    }
  }
  cout << cnt << endl;
}

int main()
{
  vector<pair<int64_t, int64_t> > vp;
  while (true)
  {
    int64_t n, x;
    cin >> n >> x;
    if (n == 0 && x == 0)
      break;
    else
      vp.push_back(make_pair(n, x));
  }

  for (int64_t n = 0; n < vp.size(); n++)
  {
    cnt = 0;
    solve(vp.at(n).first, vp.at(n).second);
  }
}



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

typedef pair<int,int> P;

int n,k,a[100000],ans = 0,d[100000];
vector<int> rev[100000];

void dfs(int v,int depth){
	d[v] = depth;
	for(int i = 0;i < rev[v].size();i++){
		int to = rev[v][i];
		if(d[to] == -1) dfs(to,depth + 1);
	}
}

void dfs2(int v){
	d[v] = 0;
	for(int i = 0;i < rev[v].size();i++){
		int to = rev[v][i];
		if(d[to]) dfs2(to);
	}
}

bool used[100000] = {};

int main(){
	cin >> n >> k;
	for(int i = 0;i < n;i++) {
		cin >> a[i];a[i]--;
		if(i) rev[a[i]].push_back(i);
		d[i] = -1;
	}
	if(a[0]) ans++;
	dfs(0,0);
	priority_queue<P> que;
	for(int i = 0;i < n;i++){
		if(d[i] > k) que.push(P(d[i],i));
	}
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(d[v] <= k) continue;
		for(int i = 0;i < k - 1;i++) v = a[v];
		ans++;
		dfs2(v);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
const int N = 3;

char s[N + 5];
int len = 0, cur = 0, res = 0; // cur 表示直到当前的最大值

int main() {
  scanf("%s", s + 1);
  len = strlen(s + 1);
  s[0] = 'S';
  for (int i = 1; i <= len; ++i) {
    if (s[i - 1] == 'R' && s[i] == 'R') res = max(res, ++cur);
    else if (s[i - 1] == 'S' && s[i] == 'R') res = max(res, cur = 1);
    else if (s[i - 1] == 'R' && s[i] == 'S') res = max(res, cur);
  }
  cout << res;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
const int N=100050;
int a[N];
int main()
{
	int n,i,x;
	scanf("%i %i",&n,&x);
	for(i=1;i<=n;i++) scanf("%i",&a[i]);
	sort(a+1,a+1+n);
	int sol=0;
	for(i=1;i<=n;i++)
	{
		if(a[i]<=x) x-=a[i],sol++;
	}
	if(sol==n && x>0) sol--;
	printf("%i\n",sol);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n;
	int S[13],H[13],C[13],D[13];
	int nm;
	char m;
	
	int i,j;
	
	for(i = 0;i < 13;i++){
		S[i] = 0;
		H[i] = 0;
		C[i] = 0;
		D[i] = 0;
	}
	
	
	scanf("%d",&n);
	for(i = 0;i < n*2;i++){
		scanf("%c %d",&m,&nm);
		if(m == 'S'){
			S[nm-1] = 1;
		}else if(m == 'H'){
			H[nm-1] = 1;
		}else if(m == 'C'){
			C[nm-1] = 1;
		}else if(m == 'D'){
			D[nm-1] = 1;
		}
	}
	
	for(j = 0;j <4;j++){
		for(i = 0;i < 13;i++){
			switch(j){
				case 0:
					if(S[i] == 0){
						printf("S %d\n",i+1);
					}
					break;
				case 1:
					if(H[i] == 0){
						printf("H %d\n",i+1);
					}
					break;
				case 2:
					if(C[i] == 0){
						printf("C %d\n",i+1);
					}
					break;
				case 3:
					if(D[i] == 0){
						printf("D %d\n",i+1);
					}
					break;
			}
		}
	}
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <cmath>
#define int long long
using namespace std;

signed main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i]-=i;
  }
  sort(a,a+n);
  int p=a[n/2];
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=abs(a[i]-p);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int[] w = new int[10];
            for(int i = 0; i < 10; i++) {
                w[i] = scn.nextInt();
            }
            Arrays.sort(w);

            int[] k = new int[10];
            for(int i = 0; i < 10; i++) {
                k[i] = scn.nextInt();
            }
            Arrays.sort(k);

            System.out.print(w[9] + w[8] + w[7] + " ");
            System.out.println(k[9] + k[8] + k[7]);
        }
    }
}

Measured memory_bytes: 26324
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF (1<<29)


struct Cake{
	int w,d;
	bool operator <(const Cake a)const{return w*d<a.w*a.d;}
}cake[101];
int main(){
	int n,w,d;
	while(cin>>n>>w>>d,n|w|d){
		cake[0].w=w;
		cake[0].d=d;
		for(int i=0;i<n;i++){
			int p,s;
			Cake c;
			cin>>p>>s;
			p--;
			c=cake[p];
			for(int j=p+1;j<=i;j++){
				cake[j-1]=cake[j];
			}
			s %= c.w+c.d;
			Cake a,b;
			if(s<c.w){
				a.d=b.d=c.d;
				a.w=s;
				b.w=c.w-s;
			}else{
				a.w=b.w=c.w;
				s-=c.w;
				a.d=s;
				b.d=c.d-s;
			}
			if(a.w*a.d<=b.w*b.d){
				cake[i]=a;cake[i+1]=b;
			}else{
				cake[i]=b;cake[i+1]=a;
			}
		}
		sort(cake,cake+n+1);
		cout<<cake[0].w*cake[0].d;
		for(int i=1;i<=n;i++){
			cout<<' '<<cake[i].w*cake[i].d;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int ans=max(C-(A-B),0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    map<int,int> map;
    rep(i,n)map[a[i]]++;
    int ans=0;
    for(pi e:map){
        int x=e.fi,c=e.se;
        if(c>x)ans+=c-x;
        else if(x>c)ans+=c;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7040
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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; }

void solve(long long K){
    string S;
    REP(i, K) S += "ACL";
    cout<<S<<endl;
}
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3156
#include<iostream>
using namespace std;
int main(){
  int N, X[105], Y[110], m = 999999999, P = -100;
  cin >> N;
  for(int i = 0; i < N; i++) cin >> X[i];
  for(int i = 0; i < 105; i++) Y[i] = 0;
  for(int i = 0; i < 105; i++){
    for(int j = 0; j < N; j++){
      Y[i] += (X[j]-i)*(X[j]-i);
    }
  }
  for(int i = 0; i < 105; i++){
    if(m > Y[i]) {m = Y[i]; P = i;}
  }
  cout << m;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
xyh = [[int(i) for i in input().split()] for _ in range(N)]
xyh.sort(key = lambda x: x[2])
tx, ty, th = xyh[-1]
for Cx in range(101):
  for Cy in range(101):
    H = th+abs(tx-Cx)+abs(ty-Cy)
    if all(h == max(H-abs(x-Cx)-abs(y-Cy), 0) for x, y, h in xyh):
      print(Cx, Cy, H)
      exit()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[114514], b[114514], c[114514];
	long long d[114514];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		cin >> b[i];
	sort(b, b + n);
	for (int i = 0; i < n; i++)
		cin >> c[i];
	sort(c, c + n);
	d[0] = 0;
	long long x = 0;
	for (int i = 0, j = 0; j < n;) {
		if (i == n || a[i] >= b[j])
			d[j + 1] = x + d[j], j++;
		else
			i++, x++;
	}
	x = 0;
	for (int i = 0, j = 0; j < n;) {
		if (i == n || b[i] >= c[j])
			x += d[i], j++;
		else
			i++;
	}
	cout << x << endl;
	return 0;
}


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

int main()
{
    std::size_t N;
    std::cin >> N;
    std::string C;
    std::cin >> C;

    while(not C.empty() && C.back() == 'W')
    {
        N -= 1;
        C.pop_back();
    }

    std::size_t num_R=0;
    std::size_t num_W=0;
    for(const auto& c : C)
    {
        if(c == 'R') {num_R += 1;}
        if(c == 'W') {num_W += 1;}
    }

    const std::size_t unicolor = std::min(num_R, num_W);


    std::size_t num_swap = 0;
    for(std::size_t i=0; i<num_R; ++i)
    {
        if(C[i] == 'W')
        {
            num_swap += 1;
        }
    }

    std::cout << std::min(num_swap, unicolor) << std::endl;

    return 0;
}


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

using namespace std;
#define int long long
#define N 666666
int arr[N],sum1[N],sum2[N];
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(a>b){
		cout<<0;
		return 0;
	}
	if(n==1){
		if(a!=b){
			cout<<"0";
		}else{
			cout<<"1";
		}return 0;
	}
	int ans=max(0ll,((a+b)+b*(n-2))-((a+b)+a*(n-2))+1);
	cout<<ans;
	return 0;
}
/*
9
-3
*/

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(M: int, K: int):
    if K >= (1 << M):
        print(-1)
        return
    if M == 1:
        if K == 0:
            print(0, 0, 1, 1)
        else:
            print(-1)
        return
    for i in range(1 << M):
        if i != K:
            print(i, end=" ")
    print(K, end=" ")
    for i in reversed(range(1 << M)):
        if i != K:
            print(i, end=" ")
    print(K)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(M, K)


if __name__ == '__main__':
    main()


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int w,h;
int high[10500];
int cou(int bit){
    int an=0;
    int flag[10];
    rep(i,0,10){
        flag[i]=false;
    }
    rep(i,0,h){
        if((bit>>i)&1){
            //cout << 1;
            flag[i]=true;
        }//else cout << 0;
    }
    //cout << endl;
    //if(__builtin_popcount(bit)==h)return 0;
    rep(j,0,w){
        int b=0;
        rep(i,0,h){
            if(!flag[i]&&((high[j]>>i)&1))b++;
            else if(flag[i]&&!((high[j]>>i)&1))b++;
            //b=__bilten_popcount(a);
        }
        b=max(b,(h-b));
   //     cout << b << " ";
        an+=b;
    }
    //if(an==16)cout <<"hai";
 //   cout << endl;
    return an;
}
int f(int num,int bit){
    if(num>=h){
        return cou(bit);
    }else{
        return max(f(num+1,bit|(1<<num)),f(num+1,bit));
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
    cin >> h >> w;
    rep(i,0,10001){
        high[i]=0;
    }
    if(h==0&&w==0)break;
    rep(i,0,h){
        rep(j,0,w){
            int x=0;cin >> x;
            if(x==1){
                high[j]|=(1<<i);
            }
        }
    }
    cout << f(0,0) << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  string s,t;
  cin >> s >> t;
  string ans="Yes";
  map<char,ll>mp,tmp;
  ll scount[200100]={0},tcount[200100]={0};
  ll counter=0;
  rep(i,s.size()){
    if(mp.find(s[i])==mp.end()){
      //when s[i] non_exists
      mp[s[i]]=counter;
      scount[i]=counter;
      counter++;
    }else{
      //if s[i] exists
      scount[i]=mp[s[i]];
    }
  }
  counter=0;
  rep(i,t.size()){
    if(tmp.find(t[i])==tmp.end()){
      tmp[t[i]]=counter;
      tcount[i]=counter;
      counter++;
    }else{
      tcount[i]=tmp[t[i]];
    }
  }
/*
  rep(i,s.size()){
    cout << scount[i] << " ";
  }
  cout << endl;
  rep(i,s.size()){
    cout << tcount[i] << " ";
  }
  cout << endl;
*/
  bool flag=true;
  rep(i,s.size()){
    if(scount[i]!=tcount[i])flag=false;
  }
  cout << (flag?"Yes":"No") <<endl;
}


Measured memory_bytes: 3848
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e9
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<int, int> P;

int h, w;
int sx, sy, tx, ty;
char c[1006][1005];
int dist[1005][1005];
int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

void bfs01()
{
	deque<P> deq;
	deq.push_back(P(sx, sy));
	
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			dist[x][y] = inf;
		}
	}
	dist[sx][sy] = 0;
	
	while(deq.size()){
		int x = deq.front().first, y = deq.front().second;
		deq.pop_front();
		for(int i = 0; i < 4; i++){
			int nx = x + dx[i], ny = y + dy[i];
			if(nx <= 0 || nx > w || ny <= 0 || ny > h) continue;
			if(c[nx][ny] != '.') continue;
			
			if(dist[nx][ny] > dist[x][y]){
				dist[nx][ny] = dist[x][y];
				deq.push_front(P(nx, ny));
			}
		}
		for(int i = -2; i <= 2; i++){
			for(int j = -2; j <= 2; j++){
				int nx = x + i, ny = y + j;
				if(nx <= 0 || nx > w || ny <= 0 || ny > h) continue;
				if(c[nx][ny] != '.') continue;
				
				if(dist[nx][ny] > dist[x][y]+1){
					dist[nx][ny] = dist[x][y] + 1;
					deq.push_back(P(nx, ny));
				}
			}
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w;
	cin >> sy >> sx >> ty >> tx;
	
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> c[x][y];
		}
	}
	
	bfs01();
	
	if(dist[tx][ty] > inf/2) cout << -1 << endl;
	else cout << dist[tx][ty] << endl;
	
	/*for(int y = 1; y <= w; y++){
		for(int x = 1; x <= h; x++){
			cout << dist[x][y] << " ";
		}
		cout << endl;
	}*/
	
	return 0;
}

Measured memory_bytes: 8676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll n; cin >> n;
	string alp = "abcdefghijklmnopqrstuvwxyz";
	
	function<deque<pair<string,char>>(ll)> dfs = [&](ll n){
		deque<pair<string,char>> res;
		
		if(n==1){
			res.push_back(make_pair("a",'a'));
		}
		else{
			
			res = dfs(n-1);
			ll sz = res.size();
			rep(i,sz){
				pair<string,char> now = res[0];
				res.pop_front();
				
				char c = now.second;
				rep(j,c-'a'+2){
					res.push_back(make_pair(now.first + alp[j],alp[max(j,(ll)now.second-'a')]));
				}
			}

		}
		
		return res;
	};

	deque<pair<string,char>> res = dfs(n);
	sort(res.begin(), res.end());
	rep(i,res.size()){
		cout << res[i].first << endl;
	}
	
	return 0;

}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}


Measured memory_bytes: 9728
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> p, sum;
  rep(i, n)
  {
    ll tmp;
    cin >> tmp;
    p.push_back(tmp);
    if (i == 0)
    {
      sum.push_back(tmp);
      continue;
    }
    else
    {
      sum.push_back(sum[i - 1] + tmp);
    }
  }
  ll maxIdx = 0;
  ll mx = 0;
  rep(i, n - k + 1)
  {
    if (i == 0)
    {
      continue;
    }
    ll f = sum[i + k - 1] - sum[i - 1];
    if (f > mx)
    {
      mx = f;
      maxIdx = i;
    }
  }
  double ans = 0;
  ll start = maxIdx;
  ll end = maxIdx + k;
  for (ll i = start; i < end; i++)
  {
    double plus = (1 + p[i]) / 2.0;
    ans += plus;
  }
  printf("%.10f\n", ans);
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll W, H, x, y;

signed main()
{
    cin >> W >> H >> x >> y;

    printf("%.12f", static_cast<double>(W) * static_cast<double>(H) / 2);
    printf(" %lld\n", (H / 2 == y && H % 2 == 0 && W / 2 == x && W % 2 == 0) ? 1 : 0);
    return 0;
}


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

std::pair<int,int> tmp[100000];

int main(){
  std::string b;
  std::cin>>b;
  int ans=0;
  int cur=0;
  for(int i=0;i<(int)b.length();++i){
    if(b[i]=='A'||b[i]=='C'||b[i]=='G'||b[i]=='T'){
      ++cur;
    }else{
      cur=0;
    }
    ans=std::max(ans,cur);
  }
  std::cout<<ans<<std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000






int main() {
	int a[N];
	int n;
	int x, y, z;
	long long s, ans, k,kk;
	bool v = true;
	ans = 0;
	scanf("%d %lld", &n, &k);
  kk=k;
	f(i, n) {
		scanf("%d", &a[i]);
	}
	k = k * (k - 1);
	k = k / 2;
	k = k % MOD;
	s = 0;
	f(i, n) {
		f(j, n) {
			if (a[i] > a[j])s++;
		}
	}
	s = (s*k) % MOD;
	f(i, n) {
		f(j, i) {
			if (a[j] > a[i])ans++;
		}
	}
  ans=(ans*kk)%MOD;
	ans = (ans + s) % MOD;
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 128
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

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

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 1;i <= n;i += 2){
		int cnt = 0;
		for(int j=1;j * j <= i;++j){
			if(i % j == 0){
				++cnt;
				if(j * j != i) ++cnt;
			}
		}
		sum += (cnt == 8);
	}
	cout << sum << '\n';
	return 0;	
}


Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p_s = sorted(list(map(int, input().split())), reverse=True)[:x]
q_s = sorted(list(map(int, input().split())), reverse=True)[:y]
r_s = sorted(list(map(int, input().split())), reverse=True)

s_s = sorted(p_s + q_s)
ans = sum(s_s)
for i in range(c):
    tmp = ans - s_s[i] + r_s[i]
    if tmp <= ans:
       break
    ans = tmp

print(ans)

Measured memory_bytes: 105444
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  for(int i = sqrt(n); i >= 1; i--) {
    if(n % i == 0) {
      n /= i;
      break;
    }
  }
  // cout << n << endl;
  while(n) {
    ans++;
    n /= 10;
  }
  cout << ans << endl;
  return 0;
}



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;
using P = pair<int,int>;

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

	int ans;
	ans = n % 1000;
	if (ans != 0) {
		 ans = 1000 - ans;
	}
	cout << ans << endl;

	return 0;
}

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

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

    auto scores = std::vector<int64_t>(n, k - q);

    for(int64_t i = 0; i < q; ++i) {
        int64_t a;
        std::cin >> a;
        ++scores[a - 1];
    }

    for(const auto s: scores) {
        if(s > 0) {
            std::cout << "Yes";
        } else {
            std::cout << "No";
        }
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c, k;
    cin >> n >> c >> k;
    VI t(n);
    REP(i, n) cin >> t[i];
    sort(ALL(t));
    int ans = 1;
    int st = t[0] + k;
    int p_num = 1;
    FOR(i, 1, n - 1) {
        if(t[i] <= st and p_num < c) {
            p_num++;
        } else {
            p_num = 1;
            st = t[i] + k;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  int sqr = sqrt(n);
  int ans = LONG_MAX;
  for (int i = sqr; i > 0; i--) {
    if (n % i == 0) {
      int tmp = max(i, n / i), cnt = 0;
      while (tmp)
        tmp /= 10, cnt++;
      chmin(ans, cnt);
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int dfs(int cur, int w, int target, int state, vector<int>& v)
{
    if(cur == 0)
        rep(i,w) v[i] = 0;

    if(cur == w-1)
    {
        bool valid = true;
        rep(i,w-2)
            if(v[i] == 1 && v[i+1] == 1)
                valid = false;
        
        if(!valid) return 0;

        if(state == 0)
        {
            if(target > 0)
                valid &= v[target-1] == 0;
            if(target < w-1)
                valid &= v[target] == 0;

            return valid ? 1 : 0;
        }
        else if(state == -1)
        {
            if(target == 0)
                return 0;
            return v[target-1] == 1;
        }
        else
        {
            if(target == w-1)
                return 0;
            return v[target] == 1;
        }
    }

    int cnt = 0;
    v[cur] = 0;
    cnt += dfs(cur+1,w,target,state,v);
    v[cur] = 1;
    cnt += dfs(cur+1,w,target,state,v);

    return cnt;
}

int main()
{
    int h,w,k;
    cin >> h >> w >> k;
    i64 dp[109][8];
    rep(i,109) rep(j,8) dp[i][j] = 0;
    dp[0][0] = 1;

    vector<int> v(w);
    i64 mod = 1e9+7;
    rep(i,h)
    {
        rep(j,w)
        {
            dp[i+1][j] += dp[i][j] * dfs(0,w,j,0,v);
            if(j > 0)
                dp[i+1][j] += dp[i][j-1] * dfs(0,w,j,-1,v);
            if(j < w-1)
                dp[i+1][j] += dp[i][j+1] * dfs(0,w,j,+1,v);
            
            dp[i+1][j] %= mod;
        }
    }

    cout << dp[h][k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
import math

A, B, C, D = map(int, input().split())

NUM = B-A+1
CD = int((C*D)/fractions.gcd(C,D))

Ac = A
if Ac%C != 0:
  Ac += C-(Ac%C)

if B > Ac:
  DivC = ((B - Ac)//C)+1
elif B == Ac:
  DivC = 1
else:
  DivC = 0


Ad = A
if Ad%D != 0:
  Ad += D-(Ad%D)

if B > Ad:
  DivD = ((B - Ad)//D)+1
elif B == Ad:
  DivD = 1
else:
  DivD = 0

Acd = A
if Acd%CD != 0:
  Acd += CD-(Acd%CD)

if B > Acd:
  DivCD = ((B - Acd)//CD)+1
elif B == Acd:
  DivCD = 1
else:
  DivCD = 0

print(NUM - DivC - DivD + DivCD)

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

int main() {
  int N;
  cin >> N;
  
  vector<long long> l(87);
  l[0] = 2;
  l[1] = 1;
  
  for(int i=2; i <= N; i++){
    l[i] = l[i-1] + l[i-2];
  }

  cout << l[N] << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int T;
ll N, A, B, C, D;
map<ll, ll> dp;

ll loop(ll n) {
	if(dp.count(n)) return dp[n];
	if(n <= 1) return n * D;
	ll v2l = A + loop(n / 2) + D * (n % 2);
	ll v2r = A + loop((n + 1) / 2) + D * (2 - n % 2);
	ll v3l = B + loop(n / 3) + D * (n % 3);
	ll v3r = B + loop((n + 2) / 3) + D * (3 - n % 3);
	ll v5l = C + loop(n / 5) + D * (n % 5);
	ll v5r = C + loop((n + 4) / 5) + D * (5 - n % 5);
	ll s = 2e18;
	if(1.0 * D * (n / 2) < 2e18) {
		s = loop((n + 1) / 2) + D * (n - (n + 1) / 2);
	}
	ll res = min(min(min(min(v2l, v2r), min(v3l, v3r)), min(v5l, v5r)), s);
	dp[n] = res;
	return res;
}

void solve() {
	cin >> T;
	while(T--) {
		cin >> N >> A >> B >> C >> D;
		dp.clear();
		cout << loop(N) << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 4572
#include<stdio.h>
int main(void)
{
	int n;
	int si,na;
	int flag = 0;

	si = na = 0;
	scanf("%d", &n);
	for (int i = 0; i < 100; i++) {
		na = 0;
		si += 4;
		for (int j = 0; j < 100; j++) {
			na += 7;
			if (n == si || n == na || n == si + na) {
				flag = 1;
				break;
			}
		}
		if (flag == 1)break;
	}
	if (flag == 1) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128