akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	int N, X;
	cin >> N >> X;
	int D = 0;
	int count = 1;

	for (int i = 0; i < N; ++i) {
		int L;
		cin >> L;
		D = D + L;
		if (D <= X) {
			++count;
		}
	}
	cout << count << endl;
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> d(n,0);
    for(int i=0;i<n;++i) cin>>d[i];

    sort(d.begin(),d.end());
    int ans=1;
    for(int i=0;i<n-1;++i){
        if(d[i]<d[i+1]) ++ans;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i+=2)
using namespace std;

int main(){
  string s;
  int a=0;
  cin >> s;
  rep(i,0,s.size()){
    if(s.at(i)=='L'){
      a++;
      break;
    }
  }
  rep(i,1,s.size()){
    if(s.at(i)=='R'){
      a++;
      break;
    }
  }
  if(a==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <string>
#include <iostream>
#include <map>
#include <cstdlib>
using namespace std;
int n;string s[120];
map<string,int>key;
int main(){
	scanf("%d",&n);
	for(int i = 1;i <= n;++i){
		cin >> s[i];
		if(key.count(s[i])){
			puts("No");
			return 0;
		}
		key[s[i]] = 1;
		if(i != 1 && s[i][0] != s[i - 1][s[i-1].size() - 1]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library

template <class T>
struct Edge{
    int src;
    int to;
    T cost;
    Edge(int t,T c) : to(t),cost(c) {}
    Edge(int src, int t,T c) : src(src),to(t),cost(c) {}
};
template<class T> using WeightedGraph = vector<vector<Edge<T>>>;

// Complexity: O(E*V)
// Dependency: Graph Template
template <typename T>
T BellmanFord(vector<Edge<T>>& es, int v, int s){
    const auto INFD = LINF;
    vector<T> dist(v,INFD);
    dist[s]=0;
    for (int i = 0; i < v-1; ++i){
        for(auto e: es){
            if(dist[e.src]==INFD) continue;
            if(dist[e.to]>dist[e.src]+e.cost){
                dist[e.to]=dist[e.src]+e.cost;
            }
        }
    }
    vector<bool> neg(v);
    T ans=dist[v-1];
    for (int i = 0; i < v; ++i){
        for(auto e: es){
            if(dist[e.src]==INFD) continue;
            if(dist[e.to]>dist[e.src]+e.cost){
                dist[e.to]=dist[e.src]+e.cost;
                neg[e.to]=true;
            }
            if(neg[e.src]) neg[e.to]=true;
        }
    }
    if(neg[v-1]) return INFD;
    else return ans;
}
#pragma endregion library

int main(){
    int n,m; cin >> n >> m;
    vector<Edge<ll>> es;
    rep(i,m){
        int a,b;ll c; cin >> a >> b >> c;
        a--;b--;
        es.emplace_back(a,b,-c);
    }
    ll d = BellmanFord(es,n,0);
    if(d==LINF) cout << "inf" << '\n';
    else cout << -d << '\n';
    
}

Measured memory_bytes: 384
#include <cstdio>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P; typedef queue<P> Q;
int H, W, cntb, scr[52][52]; char s[52][52]; Q q;
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
int main() {
  scanf("%d %d", &H, &W);
  for(int i = 1; i <= H; ++i) {
    scanf("%s", &s[i][1]);
    for(int j = 1; j <= W; ++j) {
      if(s[i][j] == '#') cntb++;
    }
  }
  q.push(make_pair(1, 1));
  while(!q.empty()) {
    P p = q.front(); q.pop();
    int x = p.first; int y = p.second;
    for(int i = 0; i < 4; ++i) {
      if(scr[x+dx[i]][y+dy[i]] != 0 || s[x+dx[i]][y+dy[i]] != '.') continue;
      q.push(make_pair(x+dx[i], y+dy[i]));
      scr[x+dx[i]][y+dy[i]] = scr[x][y]+1;
    }
  }
  printf("%d\n", scr[H][W]?H*W-cntb-scr[H][W]-1:-1);
}

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

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


Measured memory_bytes: 3588
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))

not_good = []
for i in range(m):
    a,b = list(map(int,input().split()))
    if h[a-1] <= h[b-1]:
        not_good.append(a)
    if h[a-1] >= h[b-1]:
        not_good.append(b)
print(n-len(set(not_good)))

Measured memory_bytes: 20024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }


const int MOD = 1000000007;

class SquareMatrix {
public:
    // create a unit SquareMatrix instance with size x size dimension 
    // create an instance with all 0 values, when zero = true is specified
    SquareMatrix(int size, bool zero = false) : data(size, vector<int>(size)) {
        if (!zero) {
            for (int i = 0; i < size; ++i) {
                data[i][i] = 1;
            }
        }
    }

    int size() const { return data.size(); }

    vector<int>& operator[] (int r) { return data[r]; }
    const vector<int>& operator[] (int r) const { return data[r]; }

    void dumpMatrix() {
        for (auto row: data) {
            for (int x: row) {
                cout << x << ' ';
            }
            cout << endl;
        }
    }

private:
    vector<vector<int>> data;
};

SquareMatrix operator* (const SquareMatrix& lhs, const SquareMatrix&rhs) 
{
    int s = lhs.size();
    SquareMatrix ret(s);
    for (int r = 0; r < s; ++r) {
        for (int c = 0; c < s; ++c) {
            LL v = 0;
            for (int i = 0; i < s; ++i) {
                v = (v + (LL) lhs[r][i] * rhs[i][c]) % MOD;
            }
            ret[r][c] = (int) v;
        }
    }
    return ret;
}

SquareMatrix operator+ (const SquareMatrix& lhs, const SquareMatrix&rhs) 
{
    int s = lhs.size();
    SquareMatrix ret(s);
    for (int r = 0; r < s; ++r) {
        for (int c = 0; c < s; ++c) {
            ret[r][c] = (lhs[r][c] + rhs[r][c]) % MOD;
        }
    }
    return ret;
}



int main()
{
    int N;
    LL K;
    cin >> N >> K;
    SquareMatrix m(N);

    rep(r, N) rep(c, N) {
        cin >> m[r][c];
    }

    SquareMatrix result(N);
    SquareMatrix current = m;
    LL bit = 1LL;
    while (bit <= K) {
        if (K&bit) {
            result = result * current;
        }
        bit *= 2;
        current = current * current;
    }

    int ans = 0;
    rep(r, N) rep(c, N) {
        ans = (ans + result[r][c]) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
         
        var primeFactors = PrimeFactors(n);
         
        string output = primeFactors.Count() == 0 
                        ? n.ToString() 
                        : string.Join(" ", primeFactors.Select (f => f.ToString()).ToArray()); //AOJ??¨
                        //:string.Join(" ", primeFactors);
        Console.WriteLine("{0}: {1}", n, output);
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i * i <= n)
        {
            if(tmp % i == 0){
                tmp /= i;
                yield return i;
            }else{
                i++;
            }
        }
		if(tmp != 1) yield return tmp;
    }
}

Measured memory_bytes: 20284
#!/usr/bin/env python3
from collections import Counter
import math
import sys
try:
    import typing
    from typing import List, Tuple
except ImportError:
    pass

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]", B: "List[int]"):
    nz = 0
    c = Counter()  # type: typing.Counter[Tuple[int, int]]
    for Ai, Bi in zip(A, B):
        if Ai == Bi == 0:
            nz += 1
            continue
        g = math.gcd(Ai, Bi)
        Ai //= g
        Bi //= g
        if Ai == 0 and Bi < 0 or Ai < 0:
            Ai *= -1
            Bi *= -1
        c[Ai, Bi] += 1
    dc = dict(c)
    ans = 1
    for Ai, Bi in dc:
        na = dc[Ai, Bi]
        if Bi <= 0:
            if (-Bi, Ai) in dc:
                nb = dc[-Bi, Ai]
                ans = ans * (pow(2, na, MOD) + pow(2, nb, MOD) - 1) % MOD
            else:
                ans = ans * pow(2, na, MOD) % MOD
        else:
            if (Bi, -Ai) not in dc:
                ans = ans * pow(2, na, MOD) % MOD
    ans -= 1
    ans += nz
    ans %= MOD
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74988
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 210000;
const int K = 100000;
const int mod = 1e9 + 7;
int p[3];
int ok1[N], ok2[N], ok3[N];
int solve(string a, string b, string c){
    for (int i = 0; i < K; i++){
        ok1[i] = ok2[i] = ok3[i] = 1;
    }
    for (int i = 0; i < a.length(); i++){
        for (int j = 0; j < b.length(); j++){
            if (i + j >= a.length()) break;
            if (a[i + j] != b[j] && a[i + j] != '?' && b[j] != '?') ok1[i] = 0;
        }
    }
    for (int i = 0; i < b.length(); i++){
        for (int j = 0; j < c.length(); j++){
            if (i + j >= b.length()) break;
            if (b[i + j] != c[j] && b[i + j] != '?' && c[j] != '?') ok2[i] = 0;
        }
    }
    for (int i = 0; i < a.length(); i++){
        for (int j = 0; j < c.length(); j++){
            if (i + j >= a.length()) break;
            if (a[i + j] != c[j] && a[i + j] != '?' && c[j] != '?') ok3[i] = 0;
        }
    }
    int res = 1e9;
    for (int i = 0; i <= a.length(); i++){
        for (int j = i; j <= a.length() + b.length(); j++){
            if (ok1[i] && ok3[j] && ok2[j - i]){
                res = min(res, max(max((int)a.length(), (int)b.length() + i), (int)c.length() + j));
            }
        }
    }
    return res;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s[3];
    cin >> s[0];
    cin >> s[1];
    cin >> s[2];
    int ans = 1e9;
    for (int i = 0; i < 3; i++) p[i] = i;
    for (int i = 0; i < 6; i++){
        next_permutation(p, p + 3);
        ans = min(ans, solve(s[p[0]], s[p[1]], s[p[2]]));
    }
    cout << ans;
}


Measured memory_bytes: 6020
#include<iostream>

using namespace std;

int n;
int ans;

int main() {
	cin >> n;
	if (n % 2 == 1) {
		n /= 2;
		ans = n*(n + 1);
	}
	else {
		n /= 2;
		ans = n*n;
	}
	cout << ans;
}

Measured memory_bytes: 256
import collections


def isPalindrome(string):
    return string == string[::-1]


def solve(string):
    n = len(string)

    return isPalindrome(string) and isPalindrome(string[:(n-1)//2]) and isPalindrome(string[(n+3)//2 - 1:])


string = input().strip()
print("Yes" if solve(string) else "No")


Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static int n;
	static long[] a;

	static void Main(){
		n = int.Parse(Console.ReadLine());
		a = Console.ReadLine().Split().Select(long.Parse).ToArray();
		for (int i = 0;i < n;i++)
			a[i] -= i + 1;
		Array.Sort(a);
		long b = a[n / 2];
		long ans = 0;
		foreach (var ai in a) ans += Abs(ai - b);
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 34436
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl '\n'
typedef vector<vector<ll>> matrix;
const ll INF = 1e18;
const int MAX = 2e5+4;
const int MOD = 1e9+7;
//vector<int> dp(MAX);
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for(int i=0;i<3;i++)
	{
		if(s[i]==s[i+1])
		{
			cout << "Bad"; return 0;
		}
	}
	cout << "Good";
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  REP(i, 1, n) {
    string tmp = s.substr(0, n - i);
    int m = tmp.size();
    if (m % 2) continue;
    string a = tmp.substr(0, m / 2);
    string b = tmp.substr(m / 2);
    // cout << a << ' ' << b << endl;
    if (a == b) {
      cout << m << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

bool n,e,s,w;
int main(){
	string S;
	cin>>S;
	for(auto c : S){
		n|=(c=='N');
		e|=(c=='E');
		s|=(c=='S');
		w|=(c=='W');
	}
	if(n^s||w^e)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

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

int q;
string s, t;
vector<int> memos, memot;

int main() {
  cin >> s >> t;
  auto f = [](string &st) {
    int len = st.size();
    vector<int> res(len + 1, 0);
    for (int i = 0; i < len; ++i) res[i + 1] = res[i] + 1 + (st[i] == 'B');
    return res;
  };
  memos = f(s), memot = f(t);
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((memos[b] - memos[a - 1]) % 3 != (memot[d] - memot[c - 1]) % 3)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 4296
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABC150D solver = new ABC150D();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC150D {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      int m = in.nextInt();
      int[] ar = new int[n];
      long x = 1;
      for (int i = 0; i < n; i++) {
        ar[i] = in.nextInt() / 2;
        x = x / gcd(x, ar[i]) * (long) ar[i];
        if (x > m) {
          out.println(0);
          return;
        }
      }

      for (int i = 0; i < n; i++) {
        if ((x / ar[i]) % 2 == 0) {
          out.println(0);
          return;
        }
      }
      long p = m / x;
      out.println((p + 1) / 2);
    }

    long gcd(long a, long b) {
      return b == 0 ? a : gcd(b, a % b);
    }

  }
}



Measured memory_bytes: 50172
#include<stdio.h>

int n;
int A[1000], B[1000], data[1000];
int cnt,sum,minimam;

void swap(int* a,int* b){
  int tmp=*a;
  *a = *b;
  *b = tmp;
}

int min(int x,int y){
  if(x < y){
    return x;
  }else{
    return y;
  }
}

int search(int x){
  int i;
  for(i = 0 ; i < n ; i++){
    if(A[i] == x){
      return i;
    }
  }
}

int main(){
  int i, j;
  int answer, x;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
    B[i]=A[i];
  }

  for(i = n - 1 ; i > 0 ; i--){
    for(j = 0 ; j < i ; j++){
      if(B[j] > B[j + 1])swap(&B[j],&B[j+1]);
    }
  }

  answer = 0;
  for(i = 0 ; i < n ; i++)data[i]=0;

  for(i = 0 ; i < n ; i++){
    x = i;
    cnt=sum=0;
    minimam=(1<<24);
    while(data[x] == 0){
      data[x]=1;
      cnt++;
      sum+=A[x];
      minimam = min(minimam,A[x]);
      x = search(B[x]);
    }
    if(cnt<2){
      continue;
    }
    answer+=min(sum+B[0]*(cnt+1)+minimam,sum+minimam*(cnt-2));
  }

  printf("%d\n",answer);
  return 0;
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
const int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
const int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;

int main()
{
    int n;
    cin >> n;
    int ans = 1 - n;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,l,i,a,b,c,ans,d,s=0;
    cin>>n>>l;
    for (i=1;i<=n;i++)
        s+=i+l-1;
    if (l<=0)
        {if (n+l-1>=0)cout<<s<<endl;else cout<<s-(n+l-1)<<endl;}
    else
        cout<<s-l<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define rep(i, k) for (i = 0; i < k; i++) 
typedef long long ll;
typedef pair<ll, ll> l_l;
int i, j;
double b,dd=0;
ll  k, n = 0,m, z = 0, x, y, a[200005] = {};
	vector<ll> v,vec;
	string s, t;
int main() {
	cin >> n;
	rep(i,n ) {
		cin >> b;
		dd += (1 / b);
	}
	cout << std::fixed << std::setprecision(10) << 1/dd << endl;

	return 0;

}


Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;


vec or_expr(string& s, int& i);
vec and_expr(string& s, int& i);
vec term(string& s, int& i);

vec or_merge(vec a, vec b) {
	vec ret(3,mod);
	ret[0] = a[0] + b[0];
	rep(i, 3) {
		ret[1] = min(ret[1], a[1] + b[i]);
	}
	ret[1] = min(ret[1], a[0] + b[1]);
	ret[2] = min({ ret[2],a[0] + b[2],a[2] + b[2] });
	return ret;
}
vec and_merge(vec a, vec b) {
	vec ret(3,mod);
	rep(i, 3) {
		ret[0] = min(ret[0], a[0] + b[i]);
	}
	ret[0] = min(ret[0], a[1] + b[0]);
	ret[1] = a[1] + b[1];
	ret[2] = min({ ret[2],a[1] + b[2],a[2] + b[2] });
	return ret;
}
vec or_expr(string& s, int& i) {
	vec val = and_expr(s, i);
	while (i < s.length() && s[i] == '|') {
		i++;
		vec val2 = and_expr(s, i);
		val = or_merge(val, val2);
	}
	return val;
}
vec and_expr(string& s, int& i) {
	vec val = term(s, i);
	while (i < s.length() && s[i] == '&') {
		i++;
		vec val2 = term(s, i);
		val = and_merge(val, val2);
	}
	return val;
}
vec term(string& s, int& i) {
	if (i<s.length()&&s[i] == '?') {
		i++;
		return vec { 1, 1, 0 };
	}
	i++;
	vec val = or_expr(s, i);
	i++;
	return val;
}
void solve() {
	string s; cin >> s;
	int i = 0;
	vec ans = or_expr(s, i);
	cout << ans[0] << " " << ans[1] << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3508
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int N = 15;
char str[N];


int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    scanf("%s", str);
    int len = strlen(str);
    for (int i = 0; i + 1 < len; i++)
        if (str[i] == 'A' && str[i + 1] == 'C')
        {
            printf("Yes\n");
            return 0;
        }
    printf("No\n");

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  char input;
  cin >> input;

  switch(input){
    case 'A':
      cout << 'T';
      break;
    case 'T':
      cout << 'A';
      break;
    case 'C':
      cout << 'G';
      break;
    case 'G':
      cout << 'C';
      break;
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
void solve(){
	string s;
	cin>>s;
	int cnt = 0;
	rep(i,0,sz(s))if(s[i]=='1')cnt++;
	cout<<cnt<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  int ans = 0;
  cin >> s;
  cin >> t;
  for (long long i = 0; i < s.length(); i++){
    if (s.substr(i, 1) != t.substr(i, 1)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3848
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC099.C
{
    class Program
    {
        static void Main ()
        {
            Console.WriteLine (Solve (int.Parse (Console.ReadLine ())).Min ());
        }
        static IEnumerable<int> Solve (int n)
        {
            for (var i = 0; i <= n; i++)
            {
                var j = n - i;
                var cnt6 = Enumerable.Range (0, i)
                    .Select (p => Math.Pow (6, p))
                    .TakeWhile (val => val <= i)
                    .Select (val => Math.Floor (i / val) % 6)
                    .Sum (val => (int) val);
                var cnt9 = Enumerable.Range (0, j)
                    .Select (p => Math.Pow (9, p))
                    .TakeWhile (val => val <= j)
                    .Select (val => Math.Floor (j / val) % 9)
                    .Sum (val => (int) val);
                yield return cnt6 + cnt9;
            }
        }
    }
}

Measured memory_bytes: 15472
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())
    
    print(max(0, A - 2 * B))
    
    return


if __name__ == '__main__':
    main()


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

int main() {
    int n;
    cin >> n;
    ll x[n], x_sorted[n];
    rep(i, n) cin >> x[i];
    copy(x, x + n, x_sorted);
    sort(x_sorted, x_sorted + n);

    ll l = x_sorted[n / 2 - 1];
    ll r = x_sorted[n / 2];

    rep(i, n) {
        if (x[i] <= l)
            cout << r << endl;
        else
            cout << l << endl;
    }

    return 0;
}


Measured memory_bytes: 5248
import math
N= int(input())
traget = list(map(int,input().split(" ")))
process = [0] * N 
ans = 0
while True:
    end_flag = True
    target_start = True

    for i in range(N):
        if traget[i] != process[i]:
            process[i] += 1
            end_flag = False
            if target_start:
                ans += 1
                target_start = False
        else:    #targetに到達しているとき
            target_start = True


    # print ("process:",process)
    # print("traget:",traget)
    # print("--"*30)
    if end_flag:
        break
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
    
	int r = N / R;
	int g = N / G;
	int b = N / B;

	for (int i = 0; i <= r; i++)
	{
		for (int j = 0; j <= g; j++)
		{
			if ((N - (R * i + G * j)) % B == 0 && N - (R * i + G * j) >= 0)ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
package main

import (
	"sort"
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	_ = scanInt()
	m := scanInt()

	p := make(abc, m)

	for i := 0; i < m; i++ {
		a,b := scanInt()-1, scanInt()-1
		p[i] = ab{a,b}
	}

	sort.Sort(p)

	x := -1
	ans := 0

	for i := 0; i < m; i++ {
		if p[i].a > x {
			ans++
			x = p[i].b-1
		}
	}

	fmt.Println(ans)

}

type ab struct {
	a int
	b int
}

type abc []ab

func (a abc) Len() int           { return len(a) }
func (a abc) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a abc) Less(i, j int) bool { return a[i].b < a[j].b }


Measured memory_bytes: 3456
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#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() {
  string S;
  cin >> S;
  int N = S.size();
  rep(i,N) {
    if (S[i] != S[N-1-i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 0; i < (N-1)/2; ++i) {
    if (S[i] != S[(N-1)/2 - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = (N+1)/2; i < N; ++i) {
    if (S[i] != S[N - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n;
int ans = 0;

bool check(ll num) {
    bool flag3, flag5, flag7;
    flag3 = flag5 = flag7 = false;
    while (num > 0) {
        if (num % 10 == 3) flag3 = true;
        if (num % 10 == 5) flag5 = true;
        if (num % 10 == 7) flag7 = true;
        num /= 10;
    }
    if (flag3 && flag5 && flag7) return true;
    else return false;
}

void dfs(ll x) {
    if (x > n) return;
    if (check(x)) ans++;
    dfs(x * 10 + 3);
    dfs(x * 10 + 5);
    dfs(x * 10 + 7);

}

int main() {
    cin >> n;
    dfs(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a = str(input())
if a == "A" or a == "B" or a == "C" or a == "D" or a == "E" or a == "F" or a == "G" or a == "H" or a == "I" or a == "J" or a == "K" or a == "L" or a == "M" or a == "N" or a == "O" or a == "P" or a == "Q" or a == "R" or a == "S" or a == "T" or a == "U" or a == "V" or a == "W" or a == "X" or a == "Y" or a == "Z":
    print("A")
else:
    print("a")

Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;//accuracy is hard
  scanf ("%d %d",&n,&k);
  double ret = 0;
  for (int x = 1; x <= n; x++) {
      int cur = x;
      double add = 1.0/n;
      while (cur < k) {
          cur<<=1;
          add/=2;
      }
      ret+=add;
  }
  printf ("%.15f\n",ret);
  return 0;
}

Measured memory_bytes: 256
okane = input()
okane = int(okane)
shiawase1 = okane // 500
okane = okane - shiawase1 * 500
shiawase2 = okane // 5
okane = okane - shiawase2 * 5
shiawase = shiawase1 * 1000 + shiawase2 * 5
print(shiawase)

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


const int limit = 100010;
using edge = struct { int to; ll cost; };
vector<edge> tree[limit];
ll depth[limit];


void dfs(int v, int p, ll d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.to == p)continue;
		dfs(e.to, v, d + e.cost);
	}

}

int main() {
	int n;
	cin >> n;
	REP(i, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		tree[a].push_back({ b,c });
		tree[b].push_back({ a,c });
	}
	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);
	REP(i, q) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cout << depth[x] + depth[y] << endl;
	}
}

Measured memory_bytes: 14336
/*---------------------------------
 *File name: A.cpp
 *Creation date: 2020-07-05 19:35
 *Link: 
 *-------------------------------*/
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define PII pair<int, int>
#define Pque priority_queue 
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const double EPS = 1e-8;

bool cmp(int x, int y){return x > y;}

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
	}
	sort(a.begin(), a.end(), cmp);
	LL ans = a[0];
	queue<LL> q;
	q.push(a[1]);
	q.push(a[1]);
	for(int i = 2; i < n; ++i){
		LL top = q.front();
		q.pop();
		//printf("top = %d\n", top);
		ans += top;
		q.push(a[i]);
		q.push(a[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

long A, B, C;
int main() {
    std::cin >> A >> B >> C;

    long V  = A * B * C;
    long V1 = (A/2) * B * C;
    long V2 = A * (B/2) * C;
    long V3 = A * B * (C/2);

    std::cout << std::min(
        std::min(
            std::abs((V-V1) - V1),
            std::abs((V-V2) - V2)
        ),
        std::abs((V-V3) - V3)
    ) << std::endl;
}

Measured memory_bytes: 256
//abc124_c.cpp
//Fri Apr 19 21:06:53 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
	string s;
	cin >> s;

	//Test1
	int temp1 = 0;
	for (int i=0;i<s.length();i++){
		if (ctoi(s[i])!=i%2){
			temp1++;
		}
	}

	//Test2
	int temp2 = 0;
	for (int i=0;i<s.length();i++){
		if (ctoi(s[i])==i%2){
			temp2++;
		}
	}

	cout << min(temp1,temp2)<< endl;
//	printf("%.4f\n",ans);
}

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

int n;
int x[24],y[24],r[24],c[24];
bool memo[1<<25];

//dist(i,j)<r[i]+r[j]->ok
bool ok(int a,int bit){
    for(int i=0;i<a;i++){
        if(((bit>>i)&1)==0)continue;
        int dist=(x[i]-x[a])*(x[i]-x[a])+(y[i]-y[a])*(y[i]-y[a]);
        int sum=(r[i]+r[a])*(r[i]+r[a]);
        if(dist<sum)return false;
    }
    return true;
}

int dfs(int bit){
    memo[bit]=true;

    int ret=n;
    for(int i=0;i<n;i++)if((bit>>i)&1)ret--;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(((bit>>i)&1)==0)continue;
            if(((bit>>j)&1)==0)continue;
            int to_bit=(bit^(1<<i))^(1<<j);
            if(c[i]==c[j]&&ok(i,bit)&&ok(j,bit)&&!memo[to_bit]){
                ret=max(ret,dfs(to_bit));
            }
        }
    }

    return ret;
}

void solve(){
    fill_n(memo,1<<n,false);

    cout<<dfs((1<<n)-1)<<endl;
}

bool input(){
    cin>>n;
    if(!n)return false;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i]>>c[i];
    return true;
}
int main(){

    int a=(1<<5)-1;
    while(input())solve();
    return 0;
}

Measured memory_bytes: 19588
"use strict"
function Main(input) {
  input = input.trim().split(' ').map(Number);
  const n = input[0];
  const a = input[1];
  const b = input[2];

  let ans = 0;
  for(let i=1; i<=n; ++i){
    let o = i;
    let calc = 0;
    while(o>0){
      calc += Math.round(o%10);
      o = Math.floor(o/10);
    }

    if(a<=calc && calc<=b){
      ans += i;
    }

  }

  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int n,Jamesv1[1999],Jamesv2[1999],a,Jamesmax=0,bro=0;

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        Jamesv1[a]++;
    }
    for(int a=1;a<=100;a++){
        if(Jamesv1[a]>0){
            bro++;
        }
    }
    cout<<bro<<endl;
}

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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bin_sort(A,n_min=None,n_max=None):
    if(n_min is None): n_min=min(A)
    if(n_max is None): n_max=max(A)
    bin=[0]*(n_max-n_min+1)
    for a in A: bin[a-n_min]+=1
    B=[]
    for i in range(n_min,n_max+1):
        for _ in range(bin[i-n_min]): B.append(i)
    return B

def resolve():
    n=int(input())
    A=[0]*n
    for a in map(int,input().split()): A[a-1]+=1
    A=bin_sort(A,0,n)
    S=[0]*(n+1)
    for i in range(n): S[i+1]=S[i]+A[i]
    # output
    p=n; i=n
    for k in range(1,n+1):
        while(1):
            while(1):
                if(i<=0 or A[i-1]<p): break
                i-=1
            if(S[i]+p*(n-i)>=k*p): break
            p-=1
        print(p)
resolve()

Measured memory_bytes: 105372
#include <stdio.h>

int main(void) {
	int N;
	int asumikana;
	if (scanf("%d", &N) != 1) return 1;
	for (asumikana = 1; asumikana * 2 <= N; asumikana *= 2);
	printf("%d\n", asumikana);
	return 0;
}


Measured memory_bytes: 128
N,K = map(int,input().split())
q = N // K
if(K%2==1):
    ans=q**3
else:
    p = N//((int)(K/2))
    if(p%2==0):
        ans = 2*(q**3)
    else:
        ans = q**3 + (q+1)**3

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;
  
  if (ceil((double)(A + B) / 2) == (A + B) / 2)
    cout << (A + B) / 2 << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{
	ll n,t,a[200005],sum=0;
	cin>>n>>t;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		if(i)
		{
			if(a[i-1]+t<a[i])sum+=t;
			else sum+=a[i]-a[i-1];
		}
	}
	cout<<sum+t<<endl;
	return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_7-A
Structured Program II - Grading
????????¶??? : 1 sec, ?????¢?????¶??? : 65536 KB
??????

????????????????????????????????????????????°????????????????????????????????°??????????????????????????¨??§??????

????????°??????????????°?????????????????????????????°????????????????????????

?????????????????°????????????????¨?????????° m?????????????¨?????????° f??????????¨?????????° r ??§?§?????????????????????????

??????????¨???¨??????????¨???? 50 ????????????m, f ??? 50?????????????¨???? 100 ????????? ???r ??? 100?????§??????

????¨????????????????????????´???????????°??? -1 ??¨????????????

??\??????????????§??????????????????????????????

    ??????????¨??????????????¨????????????????????¬????????????´???????????? F???
    ??????????¨???¨??????????¨????????¨??????°??? 80 ??\???????????°????????? A ???
    ??????????¨???¨??????????¨????????¨??????°??? 65 ??\??? 80 ??????????????°????????? B???
    ??????????¨???¨??????????¨????????¨??????°??? 50 ??\??? 65 ??????????????°????????? C???
    ??????????¨???¨??????????¨????????¨??????°??? 30 ??\??? 50 ??????????????°????????? D??? ???????????????????¨?????????°??? 50 ??\???????????°????????? C???
    ??????????¨???¨??????????¨????????¨??????°??? 30 ??????????????°????????? F???

Input

?????°??????????????????????????\?????¨??????????????????????????????????????????????????§??????????????§??????????????? m???f???r ??? 1 ???????????????????????????

m???f???r ???????????? -1 ?????¨?????\?????????????????¨????????????
Output

?????????????????????????????????????????????A???B???C???D???????????? F???????????????????????????????????????
Sample Input

40 42 -1
20 30 -1
0 2 -1
-1 -1 -1

Sample Output

A
C
F

=end
while gets
  fl = $_.chomp.split.map{|x| x.to_i}
  m = fl[0]
  f = fl[1]
  r = fl[2]
  if m==-1 and f==-1 and r==-1 then break
    elsif m==-1 or f==-1 then rst="F"
    elsif m + f >=80 then rst="A"
    elsif m + f >=65 then rst="B"
    elsif m + f >=50 then rst="C"
    elsif m + f >=30 and r>=50 then rst="C"
    elsif m + f >=30 then rst="D"
    else  rst="F"
  end
  puts rst
end

Measured memory_bytes: 8648
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<double,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll D;
    cin >> D;
    vector<double> c(27,0);
    for(ll i=0;i<26;++i)cin>>c[i+1];
    vector<vector<double>> S(D+1, vector<double>(27, 0));
    for(ll i=0;i<D;++i)
        for(ll j=0;j<26;++j)cin>>S[i+1][j+1];
    ll Maxscore=-INF;
    vl ans;
    for(double k=0;k<=50;k+=0.03){
        vector<ll> last(27,0);
        ll score=0;
        vector<ll> t(D+1,0);
        for(ll i=1;i<=D;++i){
            set<P> hoge;
            for(ll j=1;j<=26;++j){
                hoge.insert(P(S[i][j]+c[j]*k,j));
            }
            t[i]=(*--hoge.end()).second;
            last[t[i]]=i;
            score+=S[i][t[i]];
            for(ll j=1;j<=26;++j)score-=c[j]*(i-last[j]);
        }
        if(chmax(Maxscore,score))ans=t;
    }
    for(ll i=1;i<=D;++i)prt(ans[i]);

    return 0;
}



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

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

int cnt[65][2];

int main(){
	memset(cnt,0,sizeof cnt);
	int n; cin >> n;
	for(int i=0; i<n; i++){
		ll x; cin >> x;
		for(int j=0; j<60; j++){
			if(x & ((ll)1 << j)) cnt[j][1]++;
			else cnt[j][0]++;
		}
	}
	ll ans = 0, pw = 1;
	for(int i=0; i<60; i++){
		pw %= MOD;
		ans += pw * (((ll)cnt[i][0] * cnt[i][1]) % MOD);
		ans %= MOD;
		pw *= (ll)2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input){
  //パラメータ受け取り
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  inputStr = input[1].split(" ");
  var H_arr = inputStr.map( inputStr => parseInt(inputStr));

  //解法として貪欲法を用いる
  var i = 0;	//今たっている場所
  var ans = []; //回答格納用配列
  //階段の0段目のコストをメモ。値は0
  ans.push(0);
  //階段の1段目に進んだ時のコストをメモ
  ans.push(Math.abs(H_arr[1]-H_arr[0]));
　//階段の3段目以降のコストをforループで処理
  for( var i=2 ; i<N ; i++){
    //自分のところ(i段目)に1段前から来た場合の値を格納
    var v1 = ans[i-1]+Math.abs(H_arr[i]-H_arr[i-1]);
    //自分のところ(i段目)に2段前から来た場合の値を格納
    var v2 = ans[i-2]+Math.abs(H_arr[i]-H_arr[i-2]);
    //より小さい値(最小コスト)を回答配列の自分の段に格納
    ans.push(Math.min(v1,v2));
  }
  //結果表示
  console.log(ans[ans.length-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27700
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i = 1,a ; i < n ; i ++){
		cin>>a;a--;
		v[a]++;
	}
	for(int i = 0 ; i < n ; i ++)cout<<v[i]<<" ";
}

Measured memory_bytes: 3968
I=->{gets.split.map &:to_i}
    N,Q=I[]
    A=[1,c=1,1,*[0]*(N-2),1]
    Q.times{
    	a,b=I[]
    	A[a],A[b]=A[b],A[a]
    c!=a&&c!=b||c=a+b-c
    	A[c-1]=A[c+1]=1
    }
    p A.reduce(:+)-2

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

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

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int a,b;
	cin >> a >> b;
	if(a+b >= 10)
		cout << "error\n";
	else cout << a+b << "\n";	
	return 0;
}

Measured memory_bytes: 256