akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

inline void find1(ll x, vector<ll> p, ll* la, ll* ra) {
	*ra = lower_bound(p.begin(), p.end(), x) - p.begin();
	*la = max(*ra - 1, 0LL);
	*la = p[*la], *ra = p[*ra];
}

inline void find(int x, vector<ll> p, ll* la, ll* ra) {
	int l = 0, r = p.size() - 1;
	while (l <= r) {
		int m = (l + r) / 2;
		if (p[m] < x) {
			l = m + 1;
		} else {
			r = m - 1;
		}
	}
	if (l == p.size()) {
		l--;
	}
	if (r == -1) {
		r++;
	}
	*la = p[r], *ra = p[l];
}

int main() {
	int a, b, q;
	ll x;
	scanf("%d %d %d", &a, &b, &q);
	vector<ll> s, t;
	while (a--) {
		scanf("%lld", &x);
		s.push_back(x);
	}
	while (b--) {
		scanf("%lld", &x);
		t.push_back(x);
	}
	ll ls, rs;
	ll lt, rt;
	ll ps[2], pt[2];
	while (q--) {
		scanf("%lld", &x);
		// find(x, s, ps, ps + 1);
		// find(x, t, pt, pt + 1);
		// cout << ps[0] << " " << ps[1] << endl;
		// cout << pt[0] << " " << pt[1] << endl;
		ps[1] = lower_bound(s.begin(), s.end(), x) - s.begin();
		ps[0] = s[max(ps[1] - 1, 0LL)];
		ps[1] = s[min(ps[1], ll(s.size() - 1))];
		pt[1] = lower_bound(t.begin(), t.end(), x) - t.begin();
		pt[0] = t[max(pt[1] - 1, 0LL)];
		pt[1] = t[min(pt[1], ll(t.size() - 1))];
		ll ans = 2e10;
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				ans = min(ans, abs(x - ps[i]) + abs(ps[i] - pt[j]));
				ans = min(ans, abs(x - pt[i]) + abs(pt[i] - ps[j]));
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3060
# ABC175 D
import bisect

N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))

F=[0]*N

def search(n):
    res=[]
    l=0
    m=n
    tmp_res=0
    isloop=0
    if F[n-1]:
        s,L=F[n-1]
    while 1:
        m=P[m-1]
        tmp_res+=C[m-1]
        l+=1
        if F[n-1]==0:
            res.append((tmp_res,l))
        else:
            res.append(tmp_res+s*((K-l)//L) if s>0 and K>=l else tmp_res)
        if m==n:
            isloop=1
            break
        if l==K:
            break
    if F[n-1]==0:
        if isloop:
            s,L=res[-1]
            if not F[n-1]:
                m=n
                while 1:
                    F[m-1]=(s,L)
                    m=P[m-1]
                    if m==n:
                        break
        else:
            s=-1
        p=max([p+s*((K-k)//len(res)) if s>0 and K>=k else p for p,k in res])
    else:
        p=max(res)
    return p

res=-float('inf')
for i in range(N):
    res=max(res,search(i+1))
print(res)

Measured memory_bytes: 111432
#include<iostream>
using namespace std;
int w,h,cnt=0;
char a;
int dx[4]={1,0,0,-1},dy[4]={0,1,-1,0};
char mas[1000][1000];
void loop(int x,int y);
int main(){
  while(1){
    cin >> h >> w;
    if(w==0 && h==0){
      break;
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mas[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(mas[i][j]=='@' || mas[i][j]=='#' || mas[i][j]=='*'){
	  cnt++;
	  a=mas[i][j];
	  loop(j,i);
	}
      }
    }
    cout << cnt << endl;
    cnt=0;
  }
}

void loop(int x,int y){
  mas[y][x]='.';
  for(int i=0;i<4;i++){
    int X=x+dx[i];
    int Y=y+dy[i];
    if(X>=0 && X<w && Y>=0 && Y<h && mas[Y][X]==a){
      loop(X,Y);
    }
  }
  return;
}

Measured memory_bytes: 1572
#include <iostream>
#include <stdio.h>
#include <vector> 
using namespace std;

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[n];
    int b[m];
    vector<int> dup,all;
    
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int j=0;j<m;j++){
        scanf("%d",&b[j]);
    }

    int ap=0;
    int bp=0;
    int i=1;
    while(ap!=n or bp!=m){

        if(a[ap]==i and b[bp]==i) dup.push_back(i);
        if(a[ap]==i or b[bp]==i) all.push_back(i);

        while(a[ap]<=i and ap!=n) ap++;
        while(b[bp]<=i and bp!=m) bp++;

        if(ap!=n and a[ap]<b[bp]){
            i = a[ap];
        }else if(bp!=m and a[ap]>=b[bp]){
            i = b[bp];
        }else if(ap==n){
            i = b[bp];
        }else{
            i = a[ap];
        }
    }
    
    printf("%d %d\n",dup.size(),all.size());
    
    for(auto itr = dup.begin(); itr != dup.end(); ++itr) {
        printf("%d\n",*itr);
    }
    for(auto itr = all.begin(); itr != all.end(); ++itr) {
        printf("%d\n",*itr);
    }


    return 0;
}



Measured memory_bytes: 5092
let rec f n a res =
  if n = 0 then res
  else f (n/a) a (res + (n mod a))

let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  Array.init (n+1) (fun x ->
      (f x 6 0) + (f (n-x) 9 0))
|> Array.fold_left min n
|> Printf.printf "%d\n" 


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
int dp[2][10];
int main()
{
	RI(n);
	int s = 0, m = 0;
	RP(i,n) {
		RI(a);
		s += a;
		if (a%10 && (!m || a < m))
			m = a;
	}
	if (s%10 == 0)
		s -= m;
	PL(s%10 ? s : 0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}

void solve(){
    string s;
    cin >> s;
    int ans = 1000;
    for(int i = 0; i < s.size() - 2; i++) {
        ans = min(ans, abs(753 - stoi(s.substr(i, 3))));
    }
    cout << ans;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << 60 * (h2 - h1) + (m2 - m1) - k << endl;
}

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

double dp[301][301][301];

double f(int a, int b, int c, int n)
{
    if(a<0||b<0||c<0)
    {
        return 0.0;
    }
    if(dp[a][b][c]!=-1.0)
    {
        return dp[a][b][c];
    }
    double p1=(double)a/(double)n, p2=(double)b/(double)n, p3=(double)c/(double)n, p0=(double)(n-(a+b+c))/(double)n;
    double k1=f(a-1, b, c, n);
    double k2=f(a+1, b-1, c, n);
    double k3=f(a, b+1, c-1, n);
    dp[a][b][c]=(1.0+(p1*k1)+(p2*k2)+(p3*k3))/(1-p0);
    return dp[a][b][c];
}
int main()
{
   int n, a=0, b=0, c=0;
   for(int i=0;i<301;i++)
   {
       for(int j=0;j<301;j++)
       {
           for(int k=0;k<301;k++)
           {
               dp[i][j][k]=-1.0;
           }
       }
   }
   dp[0][0][0]=0.0;
   cin>>n;
   double x[n];
   for(int i=0;i<n;i++)
   {
       cin>>x[i];
       if(x[i]==1)
       {
        a++;
       }
       else if(x[i]==2)
       {
           b++;
       }
       else if(x[i]==3)
       {
           c++;
       }
   }
   cout<<fixed<<setprecision(10)<<f(a, b, c, n)<<endl;
   return 0;
}



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

#define endl '\n'

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

    long long a,b,n; cin >> a >> b >> n;
    cout << max(a*(min(n, b-1LL))/b, (a*n)/b - a*(n/b)) << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define tr(a, x) for (auto &a : x)
#define all(c) c.begin(), c.end()

#define lld long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(a) int((a).size())
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())

#define vi vector<lld>
#define si set<lld>
#define endl "\n"
#define int long long
#define pii pair<int, int>
#define minq priority_queue<int, vector<int>, greater<int>>
#define mem(a, val) memset(a, val, sizeof(a))
#define scani(x) scanf("%lld", &x)
#define scani2(x, y) scanf("%lld %lld", &x, &y)
#define scani3(x, y, z) scanf("%lld %lld %lld", &x, &y, &z);
#define print(x) printf("%lld ", x)
#define println(x) printf("%lld\n", x)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MOD 1000000009

using namespace std;

const int N = 3e5 + 11;
int n;
vector<int> v0, v1, v2;
int dp[N][3];

int dynamic(int i, int x){
     if(dp[i][x] != -1)
          return dp[i][x];
     
     if(x == 0){
          dp[i][x] = max(v1[i]+dynamic(i+1,1),v2[i]+dynamic(i+1,2));
     }
     else if(x == 1){
          dp[i][x] = max(v0[i]+dynamic(i+1,0),v2[i]+dynamic(i+1,2));
     }
     else {
          dp[i][x] = max(v0[i]+dynamic(i+1,0),v1[i]+dynamic(i+1,1));
     }

     return dp[i][x];
}

int32_t main()
{
     // #ifndef ONLINE_JUDGE
     //      freopen("input.txt", "r", stdin);
     //      freopen("output.txt", "w", stdout);
     // #endif

     SpeedForce;
     cin >> n;
     v0.assign(n,0);
     v1.assign(n,0);
     v2.assign(n,0);
     rep(i,n){
          cin >> v0[i] >> v1[i] >> v2[i]; 
          dp[i][0] = dp[i][1] = dp[i][2] = -1;
     }

     dp[n-1][0] = max(v1[n-1],v2[n-1]);
     dp[n-1][1] = max(v0[n-1],v2[n-1]);
     dp[n-1][2] = max(v0[n-1],v1[n-1]);

     int a = dynamic(0,0), b = dynamic(0,1), c = dynamic(0,2);
     cout << max(a,max(b,c)) << endl; 
}

Measured memory_bytes: 12624
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
int main(){

  int i,j;
  int num[50001]={1,1};

  for(i=3;i<50001;i+=2){
    if(num[i]==1)
      continue;
    for(j=3*i;j<50001;j+=i*2)
      num[j]=1;
  }
  for(i=4;i<50001;i+=2)
    num[i]=1;

  int in;
  while(cin>>in){
    int co=0;
    loop(i,2,in){
      if(!(num[i]||num[in-i+1]))co++;
    }
    cout<<co<<endl;
  }

}

Measured memory_bytes: 1364
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int A;
  string B;
  cin >> A >> B;

  int ans = 0;
  ans += A * 100 * (B[0] - '0');
  ans += A * 10 * (B[2] - '0');
  ans += A * (B[3] - '0');
  ans /= 100;
  cout << ans << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using ULL = uint64_t;
using P = pair<LL, LL>;
#define rep(i, n) for (LL i = 0; i < (n); ++i)
//#define DEBUG


#define HUGE (9999999LL)
LL dfs(const LL depth, const LL d, const LL g,
       const vector<LL> &p, const vector<LL> &c,
       vector<LL> &completed) {
  if (depth == d) {
    LL cost = 0;
    LL point = 0;
    rep(i, d) {
      // completed i
      if (completed.at(i) == 1) {
        point += (i + 1) * 100 * p.at(i) + c.at(i);
        cost += p.at(i);
      }
    }
//    cout << depth << " : " << cost << " : " << point << endl;
    if (point >= g) {
      return cost;
    }
//    cout << cost << endl;
    for (int i = d - 1; i >= 0; --i) {
      if (completed.at(i) == 0) {
        if ((i + 1) * 100 * (p.at(i) - 1) < g - point) {
          return HUGE; // infeasible
        }
        cost += (g - point) / ((i + 1) * 100);
        cost += ((g - point) % ((i + 1) * 100) ? 1 : 0);
        return cost;
      }
    }
    abort(); // cannot happen
  }

  LL min_cost = HUGE;
  rep(i, 2) {
    completed.at(depth) = i;
    min_cost = min(min_cost, dfs(depth + 1, d, g, p, c, completed));
  }
  return min_cost;
}


int main() {
  LL d, g;
  cin >> d >> g;
  vector<LL> p(d, -1);
  vector<LL> c(d, -1);
  rep(i, d) {
    cin >> p.at(i) >> c.at(i);
  }
  
  vector<LL> completed(d, -1);
  cout << dfs(0, d, g, p, c, completed) << endl;

  
  #ifdef DEBUG
  cout << "D: " << d << endl;
  cout << "G: " << g << endl;
  #endif
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
kouho = set()

for i in range(N):
    if i == 0:
        continue
    elif A[i-1] == A[i]:
        kouho.add(A[i])
        if A.count(A[i]) >= 4 or len(kouho) >= 2:
            break
else:
    ans = 0

kouho = list(kouho)

if len(kouho) >= 2:
    ans = kouho[0] * kouho[1]
elif len(kouho) == 1:
    ans = kouho[0] ** 2

print(ans)

Measured memory_bytes: 14352
def solve():
    N, K = map(int, input().split())
    data = [int(input()) for _ in range(N)]
    data.sort()
    ans = []
    cnt = 0
    while True:
        if data[cnt] >= data[-cnt-K]:
            break
        h_max1 = data[cnt + K - 1]
        h_min1 = data[cnt]
        h_max2 = data[-cnt-1]
        h_min2 = data[-cnt - K]
        tmp1 = h_max1 - h_min1
        tmp2 = h_max2 - h_min2
        ans.append(tmp1)
        ans.append(tmp2)
        cnt = cnt + 1
        if data[cnt] >= data[-cnt-K]:
            break

    print(min(ans))


solve()

Measured memory_bytes: 11192
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int n, m; cin >> n >> m;
  int l = 1, r = n;
  for(int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    l = max(l, a), r = min(r, b);
  }
  cout << max(0, r - l + 1) << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
    int R[MAX], i, n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n",maxv);

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  ll a[n], sum, res1 = 0, res2 = 0;
  for(int i = 0; i < n; i++) cin >> a[i];
  // odd is -
  sum = 0;
  for(int i = 0; i < n; i++){
    sum += a[i];
    if(i % 2){
      if(sum >= 0) res1 += 1 + sum, sum = -1; 
    }else{
      if(sum <= 0) res1 += 1 - sum, sum = 1;
    }
  }
  // odd is +
  sum = 0;
    for(int i = 0; i < n; i++){
    sum += a[i];
    if(i % 2){
      if(sum <= 0) res2 += 1 - sum, sum = 1; 
    }else{
      if(sum >= 0) res2 += 1 + sum, sum = -1;
    }
  }
  cout << min(res1, res2) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
vector<int>A;
int check(int x){
  if(x==1)return is_sorted(A.begin(),A.end());
  map<int,int>m;
  for(int i=1;i<A.size();i++){
    if(A[i-1]<A[i])continue;
    m.erase(m.upper_bound(A[i]),m.end());
    int k=A[i];
    m[k]++;
    while(k>0&&m[k]==x)m.erase(k),m[--k]++;
    if(k==0)return false;
  }
  return true;
}
int main(void){
  int N;cin>>N;
  A.resize(N);
  for(int &a:A)cin>>a;
  int l=0,h=N;
  while(h-l>1){
    int m=(l+h)/2;
    if(check(m))h=m;
    else l=m;
  }
  cout<<h<<endl;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N;
  cin >> N;

  int L[2*1000 + 5];
  rep(i, N) cin >> L[i];

  sort(L, L+N);

  ll ans = 0;
  rep(i, N-1){
    REP(j, i+1, N){
      int upper = L[i] + L[j];
      ans += N - distance(lower_bound(L, L+N, upper), L + N) - j - 1;
    }
  }

  cout << ans << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

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

int main(){
  long long N,A,B;
  cin >> N >> A >> B;
  
  if((B-A)%2==0){
    cout << min((B-A)/2,min(N-B,A-1)+(B-A-1)/2+1) << endl;
  }
  else{
    cout << min(N-B,A-1)+(B-A-1)/2+1 << endl;
  }
}
    


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


class BIT():
    def __init__(self, n, x=1):
        self.n = n
        self.T = [0]*(n+1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.T[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        ret = 0
        while i > 0:
            ret += self.T[i]
            i -= i & -i
        return ret

    def sump(self, l, r):
        return self.sum(r-1)-self.sum(l-1)


N = int(input())

C = [[] for _ in [0]*N]
for i, c in enumerate(map(int, input().split())):
    C[c-1].append(i)

G = [[] for _ in [0]*N]
for _ in [0]*(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)


pin = [-1]*N
pout = [-1]*N
k = 0


def dfs(v=0, p=-1):
    global k
    pin[v] = k
    k += 1
    for u in G[v]:
        if u == p:
            continue
        dfs(u, v)
    pout[v] = k


def f(x):
    return x*(x+1)//2


dfs()

b = BIT(N)
for i in range(N):
    b.add(i, 1)


total = f(N)
for c in C:
    c.sort(key=lambda x: pin[x], reverse=True)
    history = []
    ans = total
    for v in c:

        sub = 1
        for u in G[v]:
            if pin[u] < pin[v]:
                continue
            num = b.sump(pin[u], pout[u])
            ans -= f(num)
            sub += num

        b.add(pin[v], -sub)
        history.append((pin[v], sub))

    ans -= f(b.sump(0, N))
    for h in history:
        b.add(*h)
    print(ans)


Measured memory_bytes: 324884
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        long[] a = new long[n];
        long[] f = new long[n];

        for (int i=0; i<n; i++) a[i] = sc.nextInt();
        for (int i=0; i<n; i++) f[i] = sc.nextInt();

        Arrays.sort(a);
        Arrays.sort(f);

        long tmp = 0;
        for (int i=0; i<n; i++){
            tmp = Math.max(tmp, a[i]*f[n-1-i]);
        }

        long l = 0;
        long r = tmp;

        while (l<r){
            long mid = (l+r)/2;
            long cnt = 0;
            for (int i=0; i<n; i++){
                if (a[i]*f[n-1-i]>mid){
                    cnt += a[i] - mid/f[n-1-i];
                }
            }
            if (cnt<=k){
                r = mid;
            }else {
                l = mid+1;
            }
        }
        System.out.println(r);


    }
}

Measured memory_bytes: 102344
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7) cout<<"YES"<<endl;
    else cout<<"NO"<<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;
typedef long long ll;

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i];
  b = a;
  sort(b.begin(), b.end(), greater<ll>());
  rep(i, n) {
    if (a[i] != b[0]) cout << b[0] << endl;
    else cout << b[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 4736
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int r, D, X;
    cin >> r >> D >> X;
    int back_year = X;
    for (int i = 0; i < 10; i++) {
        back_year = X;
        X =  r * back_year - D;
        cout << X << endl;
    }
}

Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    #s_a.sort()

    dub_a = [0]*(max(s_a)+1)

    for i in l_a:
        dub_a[i] += 1

    dp = [1]*(max(s_a)+1)

    for i in s_a:
        if 2*i > len(dp)-1:
            pass
            '''
            elif dp[2*i] == 0:
            pass
            '''
        else:
            for j in range(2*i, len(dp), i):
                dp[j] = 0


    count = 0
    for i in s_a:
        if dp[i]==1 and dub_a[i]==1:
            count += 1
    print(count)

Measured memory_bytes: 35024
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vi prime(1000000+1, 1);
	prime[0] = prime[1] = 0;
	FOR(i, 2, 1000) {
		if(prime[i]) {
			for(int j = i*i; j <= 1000000; j += i) {
				prime[j] = 0;
			}
		}
	}

	int n, x;
	while(cin >> n >> x, n) {
		vi check(1000000+1);
		check[0] = 1;		
		int p;
		REP(i, n) {
			cin >> p;
			FOR(j, p, 1000000) {
				if(check[j-p]) {
					check[j] = 1;
				}
			}
		}

		int ans = -1;
		while(x) {
			if(prime[x]&check[x]) {
				ans = x;
				break;
			}
			x--;
		}

		if(ans == -1) {
			cout << "NA" << endl;
		} else {
			cout << ans << endl;
		}
	}
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int same = 0;
  if(a==b) same++;
  if(b==c) same++;
  if(c==a) same++;

  if(same==3) {
    cout << 1 << endl;
  } else if (same == 1) {
    cout << 2 << endl;
  } else {
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    string s,t;
    cin>>s>>t;
    cout<<t+s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc088_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int H, W;

void dfs(vector<vector<char>> &c, vector<vector<int>> &memo, int i, int j,
         int cnt) {
  if (memo[i][j] != -1 && memo[i][j] <= cnt) return;

  memo[i][j] = cnt;
  if (i + 1 < H && c[i + 1][j] == '.') dfs(c, memo, i + 1, j, cnt + 1);
  if (i - 1 >= 0 && c[i - 1][j] == '.') dfs(c, memo, i - 1, j, cnt + 1);
  if (j + 1 < W && c[i][j + 1] == '.') dfs(c, memo, i, j + 1, cnt + 1);
  if (j - 1 >= 0 && c[i][j - 1] == '.') dfs(c, memo, i, j - 1, cnt + 1);
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  cin >> H >> W;

  vector<vector<char>> c(H, vector<char>(W, 0));
  vector<vector<int>> memo(H, vector<int>(W, -1));
  int black = 0;
  rep(i, H) rep(j, W) {
    cin >> c[i][j];
    black += (c[i][j] == '#');
  }

  dfs(c, memo, 0, 0, 0);

  if (memo[H - 1][W - 1] == -1) {
    cout << -1 << endl;
  } else {
    cout << max(0, (H * W - black) - memo[H - 1][W - 1] - 1) << endl;
  }
}

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

using namespace std;

int main()
{
    char S;
    cin>>S;
    if(S=='a')
    {
        cout<<"vowel\n";
    }
    else if(S=='e')
    {
        cout<<"vowel\n";
    }
    else if(S=='i')
    {
        cout<<"vowel\n";
    }
    else if(S=='o')
    {
        cout<<"vowel\n";
    }
    else if(S=='u')
    {
        cout<<"vowel\n";
    }
    else
    {
      cout<<"consonant\n";
    }
    return 0;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

class SegmentTree(object):
	def __init__(self, N):
		self.N = N
		self.N0 = 2 ** (N - 1).bit_length()
		self.initVal = 0
		self.data = [self.initVal] * (2 * self.N0)
 
	# 区間クエリの種類
	def calc(self, a, b):
		return max(a, b)
 
	#k番目の値をxに更新
	def update(self, k, x):
		k += self.N0 - 1
		self.data[k] = x
		while k > 0:
			k = (k - 1) // 2
			self.data[k] = self.calc(self.data[2 * k + 1], self.data[2 * k + 2])
 
	#区間[l, r]の演算値
	def query(self, l, r):
		L = l + self.N0; R = r + self.N0 + 1
		m = self.initVal
		while L < R:
			if R & 1:
				R -= 1
				m = self.calc(m, self.data[R - 1])
			if L & 1:
				m = self.calc(m, self.data[L - 1])
				L += 1
			L >>= 1; R >>= 1
 
		return m

def main():
    n, k = i_map()
    size = 300000 + 2
    seg = SegmentTree(size)
    for _ in range(n):
        a = i_input()
        l = max(0, a -k)
        r = min(size - 1, a + k)
        res = seg.query(l, r)
        seg.update(a, res + 1)
 
    ans = seg.query(0, size - 1)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 86656
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

vector<ll> a;
vector<ll> f;
int N;
ll K;

bool check(ll x){
    ll cnt = 0;
    for(int i = 0; i < N; i++){
        ll b = x / f[i];
        if(b < a[i]){
            cnt += a[i] - b;
        }
    }

    if(cnt <= K){
        return true;
    } else {
        return false;
    }
}

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        f.push_back(tmp);
    }

    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());

    /*for(int i = 0; i < N; i++){
        cout << a[i] << " ";
    }
    cout << endl;
    for(int i = 0; i < N; i++){
        cout << f[i] << " ";
    }
    cout << endl;
    */

    if(check(0)){
        cout << 0 << endl;
        return 0;
    }

    /*for(int i = 0; i < 20; i++){
        cout << check(i) << endl;
    }*/

    ll l = 0, r = (1LL << 50);
    while(l + 1 != r){
        ll p = (l + r) / 2;
        if(check(p)){
            r = p;
        } else {
            l = p;
        }
    }

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


Measured memory_bytes: 4976
#include<bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
#define lli long long int
int main()
{
       int n,m,i,k,j,w,val;
       cin>>n>>m;
       
       int a[n];
       for ( i = 0; i < n; i++)
       {
           a[i]=-1;
       }
       

       for ( i = 0; i < m; i++)
       {
           
           {
               
               cin>>k;
               cin>>val;
               w=k-1;
               
               if(a[w]==-1)
               {
                     a[w]=val;
                    
               }

               else if(a[w]!=val)
               {
                   
                   cout<<"-1"<<endl;
                   return 0;
               }

           }

        }

        if( n>1 && a[0]==0 )
        {
            cout<<"-1"<<endl;
                   return 0; 
        }
        
         if(n>=2 && a[0]==-1)
        {
                a[0]=1;

        }

        for ( i = 0; i < n; i++)
        {
            if(a[i]==-1)
               {
                   a[i]=0;
               }
            
           cout<<a[i];
        }
        cout<<endl;
           
        return 0;
}

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

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

  for (int i = 0; i < 9; i ++)
    for (int j = 0; j < 9; j ++)
      if ((i + 1) * (j + 1) == n)
      {
        cout << "Yes" << endl;
        return 0;
      }
  
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>
#include<bits/stdc++.h>
#include<map>
#include<utility>
#include<queue>

typedef long long ll;
#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define vecl vector<long>
#define vecll vector<long long>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define pqi_ priority_queue<int, vector<int>, greater<int>>
#define pqll_ priority_queue<ll, vector<ll>, greater<ll>>

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
  int N, K;
  veci h;
  cin >> N >> K;
  rep(i, N) {
    int a;
    cin >> a;
    h.push_back(a);
  }

  sort(h.begin(), h.end(), greater<int>());
  int cnt = 0;
  for(int i=0; i < N; i++) {
    if (h[i] >= K) cnt++;
    else break;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
#define ll long long
#define pb push_back

void print(vector<int> a){
    for(int i=0;i<a.size();i++){
        cout << a[i] << " ";
    }
    cout << endl;
}

int main()
{
    int n, p,j=0;
    
    vector<int> x;
    while (1)
    {
        cin >> n >> p;
        if (n == 0)
        {
            break;
        }
        vector<int> a(n,0);
        int cup = p;
        int i=0;
        bool flag = true;
        while(flag){
            if(cup != 0){
                a[i]++;
                cup--;
                if(a[i]==p){
                    flag = false;
                    break;
                }
            } else {
                cup = a[i];
                a[i] = 0;
            }
            i++;
            if(i==n){
                i=0;
            }
           // print(a); // for debug
        }
        x.push_back(i);
        j++;
    }
    for (int i = 0; i < x.size(); i++)
    {
        cout << x[i] << endl;
    }
}



Measured memory_bytes: 3120
s = input()
left = int(s[:2])
right = int(s[2:])

if 1 <= left <= 12 and 1 <= right <= 12:
    print('AMBIGUOUS')
elif 1 <= right <= 12:
    print('YYMM')
elif 1 <= left <= 12:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
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 abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(string S){
    int cnt = 0, tmp = 0;
    rep(i, S.size()) {
        if (S.at(i) == 'A' ||
            S.at(i) == 'C' ||
            S.at(i) == 'G' ||
            S.at(i) == 'T') chmax(cnt, ++tmp);
        else tmp = 0;
    }
    cout << cnt << "\n";
}

int main() {
    string S;
    cin >> S;
    solve(S);
    return 0;
}

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

int main() {

  int N, K, Q;
  cin >> N >> K >> Q;

  vector<int> C(N); //各人が何回正解したか
  
  for(int i=0; i<Q; i++){
    int ppl;
    cin >> ppl; 		//正解者を受け取る
    C.at(ppl - 1)++;
  }
  
  int sum = 0; //正解数の総和
  for(int j=0; j<N; j++){
    sum += C.at(j);
  }
  
  for(int i=0; i<N; i++){
    if(K > sum - C.at(i)) cout << "Yes" << endl;
    else if(K <= sum - C.at(i)) cout << "No" << endl;
  }
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

const std::string PLAYERS[2] = {"First", "Second"};

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

    std::string S;
    std::cin >> S;

    int L = S.size();
    
    if(S[0] == S[L-1]){
        std::cout << PLAYERS[L % 2 == 1] << std::endl;
    }else{
        std::cout << PLAYERS[L % 2 == 0] << std::endl;
    }
}


Measured memory_bytes: 512
"""
n = int(sys.stdin.readline())
a, b = map(int, sys.stdin.readline().split())
c = list(map(int, sys.stdin.readline().split()))
s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

a = 100
b = 0.987654321
print('{0:06d}-{1:6f}'.format(a,b))  # 0埋め, 小数点出力桁指定時のときの出力
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)


mod = 1000000007

if __name__ == "__main__":
    N, Q = map(int, sys.stdin.readline().split())
    origin = sys.stdin.readline()
    dp = [0 for _ in range(N + 1)]
    a_flag = False
    for i in range(N):

        if a_flag and origin[i] == "C":
            dp[i + 1] = dp[i] + 1
            a_flag = False
            continue

        if origin[i] == "A":
            a_flag = True
        else:
            a_flag = False

        dp[i + 1] = dp[i]

    for _ in range(Q):
        l, r = map(int, sys.stdin.readline().split())
        print(dp[r] - dp[l])

Measured memory_bytes: 8636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int A = rei();
	int B = rei();
	if(A >= 13){
		cout << B << endl;
	}
	else if(A <= 5){
		cout << 0 << endl;
	}
	else{
		cout << B/2 << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
// AtCoder Regular Contest 068
// C - X: Yet Another Die Game

#include <cstdio>

using namespace std;
typedef long long int ll;


ll X;
ll ans;

int main() {

  ll a, b;

  scanf("%lld", &X);
  a = X / 11;
  b = X - a * 11;
  if (b > 6) {
    ans = a * 2 + 2;
  } else if (b > 0) {
    ans = a * 2 + 1;
  } else {
    ans = a * 2;
  }

  printf("%lld\n", ans);

  return 0;

}




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

H,W=map(int,input().split())
grid = [list(input().rstrip()) for _ in range(H)]
for i in range(H):
  for j in range(W):
    if j > 0 and grid[i][j-1] != '.' and grid[i][j] == '#':
      grid[i][j] = '*'
    elif j < W-1 and grid[i][j+1] != '.' and grid[i][j] == '#':
      grid[i][j] = '*'
    elif i > 0 and grid[i-1][j] != '.' and grid[i][j] == '#':
      grid[i][j] = '*'
    elif i < H-1 and grid[i+1][j] != '.' and grid[i][j] == '#':
      grid[i][j] = '*'
print("No" if sum([row.count('#') for row in grid]) else "Yes")      

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
VL dx={1,0,-1,0};
VL dy={0,1,0,-1};
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
   
    ll ct=0;
    fr(i,1,n+1)
    {
        
        ll x=n/i;
        if(x*i==n)
        {
            x--;
        }
        ct+=x;
    }   
    cout<<ct<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1,pp;
    //cin>>t;
    pp=t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<": ";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3652
// {{{
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)x.size())
#define FOR(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
using LL=long long;
using PII=pair<int,int>;
using VI=vector<int>;

#ifdef FEI
template<typename T>
void _dump(const char* s, T&& head) { cerr<<s<<"="<<head<<endl; }
template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
    int c=0;
    while (*s!=',' || c!=0) {
        if (*s=='(' || *s=='[' || *s=='{') c++;
        if (*s==')' || *s==']' || *s=='}') c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1, tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, ##__VA_ARGS__); \
} while(0);

template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<'[';
    for (auto it=b; it!=e; it++) s<<(it==b?"":",")<<*it;
    s<<']';
    return s;
}

template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) { return s<<"("<<p.first<<","<<p.second<<")";}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &x) { return _out(s,ALL(x)); }
template<typename T, size_t N>
ostream& operator <<(ostream &s, const array<T,N> &x) { return _out(s,ALL(x)); }
template<typename T>
ostream& operator <<(ostream &s, const set<T> &x) { return _out(s,ALL(x)); }
template<typename A, typename B>
ostream& operator <<(ostream &s, const map<A,B> &x) { return _out(s,ALL(x)); }
#else
#define dump(...)
#endif

template<typename T>
void _R(T &x) { cin>>x; }
void _R(int &x) { scanf("%d",&x); }
void _R(LL &x) { scanf("%" PRId64,&x); }
void _R(double &x) { scanf("%lf",&x); }
void _R(char &x) { scanf(" %c",&x); }
void _R(char *x) { scanf("%s",x); }

void R(){}
template<typename T, typename... X>
void R(T& head, X&... tail) { _R(head); R(tail...); }

const int MOD = 1e9+7;
// }}}

const int N = 200005;
LL arr[N];

int main() {
    int n;
    LL sum=0, ans;
    R(n);
    for (int i=1; i<=n; i++) {
        R(arr[i]);
        arr[i] += arr[i-1];
    }

    ans = LLONG_MAX;

    for (int i=1; i<n; i++) {
        ans = min(ans, abs((arr[n] - arr[i]) - arr[i]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792