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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

bool solve() {
  int N, A, B, C, X;
  cin >> N >> A >> B >> C >> X;
  if (N + A + B + C + X == 0) return false;
  vector<int> Y(N);
  cin >> Y;
  int ptr = 0;
  int cur = X;
  for (int i = 0; i <= 10000; i++) {
    if (cur == Y[ptr]) ptr++;
    if (ptr == N) {
      cout << i << endl;
      return true;
    }
    cur = (A * cur + B) % C;
  }
  cout << -1 << endl;
  return true;
}

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



Measured memory_bytes: 3036
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;


int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  if (N != 0) {
    sum += N*(N-1) / 2;
  }
  if (M != 0) {
    sum += M*(M-1) / 2;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;
typedef pair<long int, int> P;
static const long int INF = 1e16;

struct edge
{
	long int to;
	int height;
	edge(long int to, int height) : to(to), height(height){};
};

void solve()
{
	int N, M;
	long int X;
	cin >> N >> M >> X;
	vector<long int> treeHeight(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> treeHeight[i];
	}
	vector< vector<edge> > treeNode(N);
	for (int i = 0; i < M; ++i)
	{
		int from, to, cost;
		cin >> from >> to >> cost;
		--from; --to;
		treeNode[from].push_back(edge(to, cost));
		treeNode[to].push_back(edge(from, cost));
	}
	bool used[1000001];
	memset(used, 0, sizeof(used));
	priority_queue<P> pque;
	pque.push(P(X, 0));
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		if (p.second == N - 1)
		{
			cout << X + treeHeight[N - 1] - p.first * 2 << endl;
			return;
		}
		if (used[p.second]++) continue;
		for (int i = 0; i < treeNode[p.second].size(); ++i)
		{
			edge e = treeNode[p.second][i];
			if (e.height > treeHeight[p.second])
			{
				continue;
			}
			pque.push(P(min(p.first - e.height, treeHeight[e.to]), e.to));
		}
	}
	cout << -1 << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 28972
n = int(input())
A = list(map(int, input().split()))
ans = 0
f = -1
for i in range(n):
  if i == n-1:
    ans += 1
  else:
    if A[i] != A[i+1]:
      if f == -1:
        f = A[i] < A[i+1]
      else:
        if f ^ (A[i] < A[i+1]):
          ans += 1
          f = -1
print(ans)

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

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9+7;

void solve(){
	ll n,k;
	cin >> n >> k;
	n%=k;
	cout << min(n,k-n) << "\n";
}

int main(){
	#ifndef ONLINE_JUDGE	
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);		
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#表計算を行うプログラムを作成。

r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 0..r-1                                       # 変数 i を1からr-1まで増やして繰り返し処理する。(arrayゼロから始めるから)
    
a= gets.split.map(&:to_i)
    for j in 0..c-1                                   # 変数 i を0からc-1回まで増やして繰り返し処理する。
    h[i][j] =  a[j]                                   # array のループひとつづつ足していく
    h[i][c] += a[j]
    h[r][j] += a[j]
    h[r][c] += a[j]
    end
end
for i in 0..r                                       #本ループをくりかえす   row 
    for j in 0..c                                   #本ループをくりかえす   column
      print " " unless j == 0
      print h[i][j]                                 #全体結果
    end
    puts                                            #段落あける
  end




Measured memory_bytes: 7056
s=str(input())
t=str(input())
n=len(t)
m=len(s)
a=[]
if t in s:
  print(0)
else:
  for i in range(m-n+1): #ずらす文字数
    ans=0
    for j in range(n):
      if s[i+j]!=t[j]:
        ans+=1
    a.append(ans)
  print(min(a))

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
#define PB push_back
#define MP make_pair
#define I insert

const LL N = 2002, mod = 1000000007;

using namespace std;

LL n, m, i, j, k, l, r, t, ans;
LL a[N];
bitset < 4000001 > b;

int main(){
	cin >> n;
	for ( i = 0; i < n; ++i ){
		cin >> a[i];
		k += a[i];
	}
	b[0] = 1;
	for ( i = 0; i < n; ++i ){
		b = (b|(b<<a[i]));
	}
	for ( i = (k+1) / 2; ; ++i ){
		if ( b[i] ){
			cout << i << endl;
			break;
		}
	}
	return 0;
}
 


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll n,m;
  cin >> n >> m;
  fact(m);
  ll tans=tfact[n]*comb(m,n)%mod;
  ll ans=tans*tans%mod;
  for(ll i=1;i<=n;i++) {
    ll tmp=tans*tfact[n-i]%mod*comb(m-i,n-i)%mod*comb(n,i)%mod;
    if(i%2) {
      ans=(ans-tmp+mod)%mod;
    }
    else {
      ans=(ans+tmp)%mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 81248
require "prime"
num = gets.chomp.to_i

if num.prime?
  puts num.to_s.size
elsif num**0.5 == (num**0.5).to_i
  puts (num**0.5).to_i.to_s.size
else
  max_num = (num**0.5).to_i
  max_num.step(1, -1) do |n|
    if num / n.to_f == num / n
      m = num / n
      puts [m.to_s.size, n.to_s.size].max
      break
    end
  end
end

Measured memory_bytes: 3964
#include <iostream>
#include <sstream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

int A[100000];
int B[100000];
int main(void)
{
	int N, t;
	cin >> N >> t;
	t /= 2;
	Rep(i, N) cin >> A[i];

	int M = A[N - 1];
	for(int i = N - 2; i >= 0; i--){
		B[i] = M - A[i];
		if(A[i] > M){
			M = A[i];
		}
	}

	int m = B[0];
	Rep(i, N - 1){
		if(B[i] > m){
			m = B[i];
		}
	}

	int ans = 0;
	Rep(i, N - 1){
		if(m == B[i]) ans++;
	}
	PrintLn(ans);
	return 0;
}


Measured memory_bytes: 1024
S = input()
N = len(S)

even = [1 for _ in range(N)]
odd = [0 for _ in range(N)]
ret = [0 for _ in range(N)]

for i in range(N - 1):
    if S[i] == "R":
        odd[i+1] += even[i]
        even[i+1] += odd[i]
        odd[i] = 0
        even[i] = 0

for i in range(1, N)[::-1]:
    if S[i] == 'L':
        odd[i - 1] += even[i]
        even[i - 1] += odd[i]
        odd[i] = 0
        even[i] = 0
        
for i in range(N - 1):
    if S[i] == 'R' and S[i + 1] == 'L':
        ret[i] = even[i] + odd[i + 1]
        ret[i + 1] = even[i + 1] + odd[i]
        
print(' '.join(map(str, ret)))

Measured memory_bytes: 12148
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8+7;
const int mod = 1e9+7;

int n;
vector<vi> edges;
vector<vector<ll>> dp;

#define b first
#define w second

ll mult(ll a, ll b) {    
    ll x = ll(a * b) % mod;
    return x;
}

int add(int a, int b) { 
    int x = a + b;
    if(x >= mod) {
        x -= mod;
    }
    return x;
}


// c = 0 -> white, c = 1 -> black
ll dfs(int a, int parent, int c) {
    
    if(dp[a][c] != -1) return dp[a][c];
    
    ll ans = 1;
    
    for(int& b : edges[a]) if(b != parent) {
        
        if(c == 0) {
            ans = (ll)mult(ans, add((int)dfs(b, a, 0),(int)dfs(b, a, 1))); 
        } else if(c == 1) {
            ans = mult(ans, (int)dfs(b, a, 0));
        }
    
    }

    dp[a][c] = ans;
    return ans;
}

int main() {
   
    scanf("%d",&n);
    edges.resize(n+1);
    dp.assign(n+1, vector<ll>(2, -1));
    
    for(int i = 0; i < n-1; ++i) {
        int a, b;
        scanf("%d%d",&a,&b);
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    
    ll ans1 = dfs(1, -1, 0);
    ll ans2 = dfs(1, -1, 1);
    
    cout << add((int)ans1, (int)ans2) << endl;
    
    return 0;
}




Measured memory_bytes: 19584
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] != s[i + 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n, 0), b(n);
    rep(i,n){
        cin >> b[i];
        if(i%2 == 0) a[0] += b[i];
        else a[0] -= b[i];
    }
    cout << a[0];
    for(int i = 1; i < n; ++i){
        a[i] = 2*b[i-1] - a[i-1];
        cout << " " << a[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    map <string, ll> cnt;
    REP(i, n){
        string s; cin >> s;
        cnt[s]++;
    }
        cout << "AC x "<< cnt["AC"] << endl;
        cout << "WA x "<< cnt["WA"] << endl;
        cout << "TLE x "<< cnt["TLE"] << endl;
        cout << "RE x "<< cnt["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
int main(){
    int n,x;
    do{
        scanf("%d %d",&n,&x);
        if(n!=0||x!=0){
            int count =0;
            for(int a=1;a<=n;a++){
                for (int b=1;b<=n;b++){
                    for (int c=1;c<=n;c++){
                        if(a<b&&b<c&&a+b+c==x){
                            count=count+1;
                        }
                    }
                }
            }
            printf("%d\n",count);
        }
    }while(n!=0||x!=0);
}


Measured memory_bytes: 2032
import sys
n = int(input())
A = [int(sys.stdin.readline()) for _ in range(n)]
A.sort(reverse=True)
if n==2:
    print(A[0]-A[1])
elif n%2==0:
    ans = 0
    K = [2]*(max(0,n-2)//2)+[1,-1]+[-2]*(max(0,n-2)//2)
    print(sum([A[i]*K[i] for i in range(n)]))
else:
    K1 = [2]*(max(0,n-2)//2)+[1,1]+[-2]*(max(0,n-2)//2+1)
    K2 = [2]*(max(0,n-2)//2+1)+[-1,-1]+[-2]*(max(0,n-2)//2)
    print(max(sum([A[i]*K1[i] for i in range(n)]),
              sum([A[i]*K2[i] for i in range(n)])))

Measured memory_bytes: 18656
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
         
        int N = sc.nextInt();
      
      	long A = (long)(Math.pow(10, 18));
      
      	long[] B = new long[N];
      
      	boolean chk_0 = false;
      
      	for (int i = 0; i < N; i++){
          B[i] = sc.nextLong();
          if ( B[i] == 0){
            chk_0 = true;
          }
        }
      
     	long C = 0L;
      	boolean chk = true;
        if (!chk_0){  
          	C = B[0];
      		for (int i = 1; i < B.length; i++){  
          		try {
                  C = Math.multiplyExact(C, B[i]);
                } catch (ArithmeticException e) {
                  chk = false;
                  break;
                }
            }
        }

      	if (!chk || A < C){
			System.out.println(-1);
        } else {
            System.out.println(C);
        }

    }
}

Measured memory_bytes: 60756
/**
 *    author:  Sushil Sekhar Satapathy
 *    created: 30.Jul.2020 18:38:25
 *
 *    Only the ladder is real!! The climb is all there is.
 *
**/

#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define int long long int
#define mod 1000000007
#define vi vector<int>
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6+5;
int A[N];

int solve(int n)
{
    if(n % 2 == 0 || n % 5 == 0) return -1;
    if(n == 7) return 1;

    int cnt = 1;
    int num = 7;
    int rem = num % n;
    while(rem)
    {
        num = rem * 10 + 7;
        rem = num % n;
        cnt++;
    }
    return cnt;
}

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

    int t,n,m,a,b,x,y,i,j,z;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        cout<<solve(n)<<endl;
    }

	return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll n;
ll dp[1123456];

int main() {
	cin >> n;
	
	dp[n] = 1;
	dp[n - 1] = n;
	dp[n - 2] = n * n % MOD;
	
	ll sum = dp[n];
	for (int i = n - 3; i >= 0; i--) {
		dp[i] += dp[i + 1]; // 1
		dp[i] += (n - 1) * (n - 1) % MOD; // (a>1) (b>1)
		dp[i] += sum + n - 1 - (n - 3 - i + 1); // (a>1) 1^(a)
		dp[i] %= MOD;
		
		sum = (sum + dp[i + 2]) % MOD;
	}
	cout << dp[0] << endl;
	
	return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#include<cstdio>
int main(){
  int h,n;
  cin>>h>>n;
  int a,sum=0;
  for(int i;i<n;i++){
    cin>>a;sum+=a;
  }
  if(sum>=h)cout<<"Yes";
  else{cout<<"No";}
}







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

using namespace std;

int main(){
    int A,B,C,i=0;
    cin >> A >> B >> C;
    if(A%2==1 || B%2 == 1 || C%2 == 1){
        cout << "0" << endl;
    }else{
        for(i=0;;i++){
            A /= 2;
            B /= 2;
            C /= 2;
            if(A%2==1 || B%2==1||C%2==1){
                if(A%2==B%2 && B%2==C%2){
                    i++;
                }
                break;
            }
        }

        if(A==B && B == C){
            cout << "-1" << endl;
        }else{
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 256
k = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
i = int(input())
print(k[i-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) (((a)+(b)-1)/(b))
#define all(x) x.begin(), x.end()
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define dbg(msg, var) cerr << msg << " " << var << endl;

using namespace std;

const int MAX = 200010;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// End Template //

int main()
{sws;

    ll n, x, m;
    cin >> n >> x >> m;

    if(n<1e6){
        ll ans = x;
        for(int i=0;i<n-1;i++){
            x = (x*x)%m;
            ans+=x;
        }

        cout << ans << endl;
        return 0;

    }

    ll ans = x; n--;
    for(int i=0;i<1e5;i++){
        x = (x*x)%m;
        ans+=x; n--;
    }

    // ll pp = n;

    vl vet;
    vet.pb(x);
    while(true){
        x = (x*x)%m;
        if(x==vet[0])
            break;

        vet.pb(x);
        ans+=x; n--;
    }

    // cout << "pum = " << pp - n << endl;

    ll sum = 0;
    for(auto v: vet)
        sum+=v;

    // cout << "sum = " << sum << endl;

    ll len = vet.size();

    ll v = n/len;
    ll rest = n%len;

    ans += v*sum;

    for(int i=0;i<rest;i++){
        ans += vet[i];
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int r[100001][3]={0},d[100001][3]={0};
vector<int> A[200001];
int main(){
    int n,m,u,v,s,t;
    cin>>n>>m;
    rep(i,m) cin>>u>>v,A[u].push_back(v);
    cin>>s>>t;
    queue<pair<int,int>> q;
    q.push(make_pair(s,0));
    while(!q.empty()){
        int a=q.front().first,b=q.front().second;
        q.pop();
        for(auto i:A[a]){
            if(d[i][(b+1)%3]) continue;
            d[i][(b+1)%3]=d[a][b]+1;
            q.push(make_pair(i,(b+1)%3));
        }
    }
    if(d[t][0]) cout<<d[t][0]/3;
    else cout<<-1;
}

Measured memory_bytes: 9472
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, p;
int a[55];

ll solve() {
    int e = 0, o = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2) o++;
        else e++;
    }
    if (o == 0 && p == 1) return 0;
    return (1LL<<(e+max(0,o-1)));
}

void input() {
    cin >> n >> p;
    for (int i = 0; i < n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
const int b1 = 37 , b2 = 31;
const int mod = 1e9 + 7;
int n;
int pw1[N] , inv1[N];
int pw2[N] , inv2[N];
int pref1[N] , pref2[N];
string s;
int fp(int x , int y) {
    if(!y)
        return 1;
    int res = fp(x , y / 2);
    res = (1ll * res * res) % mod;
    if(y & 1)
        res = (1ll * res * x) % mod;
    return res;
}
void pre() {
    pw1[0] = inv1[0] = 1;
    pw2[0] = inv2[0] = 1;
    int minv1 = fp(b1 , mod - 2);
    int minv2 = fp(b2 , mod - 2);
    for(int i = 1;i < N;i++) {
        pw1[i] = (1ll * b1 * pw1[i - 1]) % mod;
        pw2[i] = (1ll * b2 * pw2[i - 1]) % mod;
        inv1[i] = (1ll * minv1 * inv1[i - 1]) % mod;
        inv2[i] = (1ll * minv2 * inv2[i - 1]) % mod;
    }
}
pair<int , int> get(int l , int r) {
    int ans1 = pref1[r] , ans2 = pref2[r];
    if(l) {
        ans1 = (ans1 - pref1[l - 1] + mod) % mod;
        ans2 = (ans2 - pref2[l - 1] + mod) % mod;
    }
    ans1 = (1ll * ans1 * inv1[l]) % mod;
    ans2 = (1ll * ans2 * inv2[l]) % mod;
    return {ans1 , ans2};
}
int main() {
    abdelrahman010
    cin >> n >> s;
    pre();
    for(int i = 0;i < n;i++) {
        int c = s[i] - 'a' + 1;
        pref1[i] = (1ll * c * pw1[i]) % mod;
        pref2[i] = (1ll * c * pw2[i]) % mod;
        if(i) {
            pref1[i] = (pref1[i] + pref1[i - 1]) % mod;
            pref2[i] = (pref2[i] + pref2[i - 1]) % mod;
        }
    }
    int low = 1 , high = n / 2 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        bool yes = false;
        for(int i = 0;i + mid <= n && !yes;i++) {
            for(int j = i + mid;j + mid <= n;j++)
                if(get(i , i + mid - 1) == get(j , j + mid - 1)) {
                    yes = true;
                    break;
                }
        }
        if(yes)
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1920
fun main(args: Array<String>) {
    val (n, a, b, c, d) = readLine()!!.split(" ").map(String::toInt)
    val map = readLine()!!.toCharArray()

    if (c < d) {
        val funukeIsReachable = isReachable(map, b - 1, d - 1)
        if (!funukeIsReachable) {
            println("No")
            return
        }

        map[d - 1] = '#'
        val sunukeIsReachable = isReachable(map, a - 1, c - 1)
        if (!sunukeIsReachable) {
            println("No")
            return
        }

        println("Yes")
    } else {
        val g = moveToGoodPlace(map, b - 1, d - 1)
        if (g == -1) {
            println("No")
            return
        }

        map[g] = '#'

        val sunukeIsReachable = isReachable(map, a - 1, c - 1)
        if (!sunukeIsReachable) {
            println("No")
            return
        }

        if (g == d - 1) {
            println("Yes")
            return
        }

        val funukeIsReachable = isReachable(map, g, d - 1)
        if (!funukeIsReachable) {
            println("No")
            return
        }

        println("Yes")
    }
}

fun isReachable(map: CharArray, from: Int, to: Int): Boolean {
    var current = from
    while (current < to) {
        if (map[current + 1] != '#') {
            current++
            continue
        }
        if (map[current + 2] != '#') {
            current += 2
            continue
        }
        break
    }
    return current == to
}

fun moveToGoodPlace(map: CharArray, from: Int, to: Int): Int {
    var current = from
    while (current < to) {
        if (map[current - 1] == '.' && map[current + 1] == '.') {
            return current
        }
        if (map[current + 1] != '#') {
            current++
            continue
        }
        if (map[current + 2] != '#') {
            current += 2
            continue
        }
        return -1
    }
    return current
}


Measured memory_bytes: 41468
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  int N;
  scanf("%d", &N);
  map<int, int> A;
  vector<int> sA(N, 0);
  for (int i = 0; i < N; i++){
    scanf("%d", &(sA[i]));
    A[sA[i]] = i;
  }
  sort(sA.begin(), sA.end(), less<int>());
  int result = 0;
  for (int i = 0; i < N; i++){
    if ((i % 2) != (A[sA[i]] % 2)){
      result++;
    }
  }
  cout << (result/2);
  return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;

  vector<string> pic(H);

  for(int i = 0; i < H ; i++){
    cin >> pic.at(i);
  }

  // １行目の出力
  for(int j = 0; j < W + 2; j++){
    cout << '#';
  }
  cout << endl;
  // Pictureの行を出力
  for(int i = 0; i < H; i++){
    cout << '#' + pic.at(i) + '#' << endl;
  }
  // 末尾の行を出力
  for(int j = 0; j < W + 2; j++){
    cout << '#';
  }
  cout << endl;
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def prime_fact(x):
    fact=[]
    for i in range(2, int(x**(0.5))+1):
        while x%i==0:
            fact.append(i)
            x//=i
    if x!=1:
        fact.append(x)
    if not fact:
        fact=[x]
    return fact

divisors=make_divisors(n)
divisors.pop(0)
cnt=0
for div in divisors:
    # print(n,div)
    # print(div, prime_fact(div), set(prime_fact(div)))
    if len(set(prime_fact(div)))==1 and n>1 and n%div==0:
        n//=div
        cnt+=1
    elif n<1:
        break
print(cnt)


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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++) cin >> h[i];
  
  int ans = 0;
  int tmp = 0;
  for(int i=0; i<n-1; i++){
  	if(h[i] >= h[i+1]){
      tmp++;
      ans = max(tmp, ans);
    }else{
      tmp = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void solve(int idx,string cur)
{
    if(cur.length() >= 9 || idx > cur.length())
    {
        //cout << cur << endl;
        if(cur == "AKIHABARA")
        {
            cout << "YES";
            exit(0);
        }
        return;
    }
    cur.insert(idx,"A");
    solve(idx + 1,cur);
    cur.erase(idx,1);
    solve(idx + 1,cur);
}
int main()
{
    string s;
    cin >> s;
    if(s.length() >= 10)
    {
        cout << "NO";
        return 0;
    }

    solve(0,s);
    cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
using namespace std;
int main() {
		ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,ans=0,total_sum,l,r;
    cin>>n>>k;
    total_sum = (n*(n+1))/2;
    for(ll i=k;i<=n+1;i++){
				l = (i*(i-1))/2;
				r = total_sum - ((n-i)*(n-i+1))/2;
				ans += r-l+1;
		}
		cout<<ans%MOD<<endl;
}
 


Measured memory_bytes: 3652
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main () {

    double a, b, C;     // 入力

    double c;           // 角Cの対角に存在する辺cの長さ
    double sinB;        // bの対角に存在する角Bのsin
    
    double S, L, h;     // 出力（面積, 周の長さ, ）

    cin >> a >> b >> C;

    C = C * M_PI / 180.0;   // 角度Cをラジアンに変換
    c = sqrt (pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C));  // Cの対角に存在する辺cの長さを求める。余弦定理を利用。 「c^2 = a^2 + b^2 - 2ab * cos(C)」
    sinB = b * sin(C) / c;  // sinAを求める。正弦定理を利用。　「a / sin(A) = b / sin (B) = c / sin (C) = 2R」

    S = 0.5 * a * b * sin(C);   // 面積を求める。面積を求める公式を利用。
    
    L = a + b + c;  // 周の長さを求める。

    h = c * sinB; // 高さを求める。

    cout << fixed;
    cout << setprecision(10) << S << endl;
    cout << setprecision(10) << L << endl;
    cout<< setprecision(10) << h << endl;

    return 0;
}


Measured memory_bytes: 3492
from collections import deque

s = deque(input())
n = int(input())
status = True

for i in range(n):
	com = input().split()
	if com[0] == '1':
		status = not status
	elif int(com[1])+status == 2:
		s.appendleft(com[2])
	else:
		s.append(com[2])
        
if not status:
	s.reverse()
print("".join(s))

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

using namespace std;

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

  uint64_t a = 0;
  uint64_t ans = 0;
  for(int i = 0;
      i < s.length() - 1;
      ++i)
    {
      if(s[i] == 'A')
        {
          ++a;
        }
      else if(s[i] == 'B' && s[i + 1] == 'C')
        {
          ans += a;
          ++i;
        }
      else
        {
          a = 0;
        }
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n, x, ans = 0;
    cin >> n >> x;
    vi m(n);
    rep(i,n){
        cin >> m[i];
        x -= m[i];
        ans++;
    }
    sort(all(m));
    ans += x / m[0];
    out(ans);
}

Measured memory_bytes: 3688
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
  long N,D,x,y;
  int count=0,X[2*(int)pow(10,5)],Y[2*(int)pow(10,5)];
  scanf("%ld",&N);
  scanf("%ld",&D);
  for(int n=0;n<N;n++){
    scanf("%ld",&x);
    scanf("%ld",&y);
    X[n]=x;
    Y[n]=y;
    if(sqrt(pow(X[n],2)+pow(Y[n],2))<=D){
      count++;
    }
  }
  printf("%d\n",count);
return 0;
}

Measured memory_bytes: 3696
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    cnt=0
    for i in range(1,N+1):
        th=i%3
        fiv=i%5
        if th!=0 and fiv!=0:
            cnt+=i
    print(cnt)




resolve()

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    vector<int> b(n-1);
    rep(i,0,b.size()){
        cin>>b[i];
    }    
    vector<int> a(n,inf);
    rep(i,0,b.size()){
        a[i] = min(a[i],b[i]);
        a[i+1] = min(a[i+1],b[i]);
    }
    int sum = 0;
    rep(i,0,a.size()){
        sum += a[i];
    }
    cout<<sum<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define dbg(x)                cout <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
void ara_read(vec &v,ll n);
////////////////////////

int main()
{
	
	string s;
	cin>>s;
	ll first=(s[0]-'0')*10+(s[1]-'0');
	ll second=(s[2]-'0')*10+(s[3]-'0');
	ll a=false, b=false;
	if(first<=12 && first>0)
		a=true;
	if(second<=12 && second>0)
		b=true;
	if(a && b){
		puts("AMBIGUOUS");
	}
	else if(a){
		puts("MMYY");
	}else if(b){
		puts("YYMM");
	}else{
		puts("NA");
	}
	
   return 0;
}

void FAST_IO()
{
    // ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);

}
void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i<n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
	
}


Measured memory_bytes: 256
#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;

template<typename T>
class BIT {
public:
    int N;
    vector<T> dat;

    BIT(int N) : N(N + 1) {
        dat.resize(N + 1, 0);
    }

    // sum[a0 + ... +ak)
    T get_sum(int k) {
        T ret = 0;
        //k & -kはkの２進表示の最も右のビットの表す数
        for(; k > 0; k -= (k & -k)) {
            ret += dat[k];
        }

        return ret;
    }

    //a[k] = a[k] + x;
    void add(int k, T x){
        k++;
        for(; k < N; k += (k & -k)) {
            dat[k] += x;
        }
    }
};

int compress(ll *x, int N){
  vector<ll> y;
  for(int i = 0; i < N; i++){
    y.push_back(x[i]);
  }

  sort(y.begin(), y.end());
  y.erase(unique(y.begin(), y.end()), y.end());

  for(int i = 0; i < N; i++){
    x[i] = lower_bound(y.begin(), y.end(), x[i]) - y.begin();
  }

  return (int)y.size();
}

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

int main(){
    int N;
    ll K;
    cin >> N >> K;
    ll a[N];
    ll sum[N + 1];
    sum[0] = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }

    ll b[N + 1];
    for(int i = 0; i <= N; i++){
        b[i] = sum[i] - i * K;
    }

    compress(b, N + 1);

    ll ans = 0;
    BIT<int> bit = BIT<int>(N + 5);
    for(int i = 0; i <= N; i++){
        ans += bit.get_sum(b[i] + 1);
        bit.add(b[i], 1);
        //cout << i << endl;
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 7156
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    //int ans=0;
    int a;
    cin>>a;

    bool check=false;

    for(int i=1;i<10;i++){
        if(a%i==0){
            if(a/i<10){
                check=true;
                break;
            }
        }
    }

    if(check){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int N, A, B;
vector<ll> h;
long long mx;
bool isOK(ll t) {
    long long cnt = 0;
    REP(i, N) {
        // cout << h[i] << endl;
        if(h[i] - B * t > 0) {
            cnt += (h[i] - B * t + A - B - 1LL) / (A - B);
        }
    }
    // cout << "t" << t << " cnt" << cnt << endl;
    if(cnt <= t) {
        return true;
    }

    return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(void) {
    ll ng = -1LL; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok = mx;

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while(abs(ok - ng) > 1LL) {
        ll mid = (ok + ng) / 2LL;

        if(isOK(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int main() {
    cin >> N >> A >> B;
    h.resize(N);
    REP(i, N) {
        cin >> h[i];
        mx = max(mx, h[i]);
    }
    cout << binary_search() << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, cnt=0, sum=0, a[100];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]%2==0)
            cnt++;
    }
    for(int i=1;i<=n;i++){
        if(a[i]%2==0)
            {
                if(a[i]%3==0 || a[i]%5==0)
                    sum++;
            }
    }
    if(cnt==sum)
        cout<<"APPROVED";
    else
        cout<<"DENIED";
}

Measured memory_bytes: 3564
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int i, n;
    int *C;

    cin>>n;
    C = (int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++){
        C[i]=0;
    }

    for(i=0;i<n-1;i++){
        int k;
        cin>>k;
        C[k-1]++;
    }

    for(i=0;i<n;i++){
        cout<<C[i]<<endl;
    }

    free(C);

}



Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> as(n),bs(m);
  for(Int i=0;i<n;i++) cin>>as[i];
  for(Int i=0;i<m;i++) cin>>bs[i];

  sort(as.begin(),as.end());
  vector<Int> ss(n+1,0);
  for(Int i=0;i<n;i++) ss[i+1]=ss[i]+as[i];

  map<Int, Int> cnt;
  for(Int b:bs) cnt[b]++;

  const Int MAX = 3e5;
  Int ans=0;
  for(auto p:cnt){
    Int b=p.first;
    Int res=0;
    for(Int k=0;b*k<=MAX;k++){
      // [lb, ub)
      Int lb=b*k;
      Int ub=b*(k+1);
      auto latte=lower_bound(as.begin(),as.end(),lb)-as.begin();
      auto malta=lower_bound(as.begin(),as.end(),ub)-as.begin();
      res+=ss[malta]-ss[latte];
      res-=lb*(malta-latte);
    }
    ans+=res*p.second;
  }

  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 19668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll N;
vi a;

int main()
{
    cin >> N;
    a = vi(N);
    REP(i, N)
    {
        cin >> a[i];
    }

    vi p = vi(N + 1);
    REP(i, N)
    {
        p[a[i]] = i + 1;
    }
    set<ll> s = set<ll>();
    s.insert(0);
    s.insert(N + 1);
    ll ans = 0;
    for (ll i = 1; i <= N; i++)
    {
        ll l = -*s.lower_bound(-p[i]);
        ll r = *s.lower_bound(p[i]);
        ans += i * (p[i] - l) * (r - p[i]);
        s.insert(p[i]);
        s.insert(-p[i]);
    }
    OUT(ans);
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
#define mod 1000000007;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
using namespace std;
int main()
{
    fast_io;
li a,b,c=0;
cin>>a>>b;
if((b>a)&&(b!=1))
{b-=a;
c=1;
}
else
{
	if(b==1)
	cout<<"0";
	else
	cout<<"1";
	return 0;
}
while(b>0)
{
	b-=(a-1);
	c++;
}
cout<<c;
return 0;
}

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

using namespace std;

using vi = vector<int>;
using ll = long long;

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

	ll a, b, c, d;
	ll result = LLONG_MIN;

	cin >> a >> b >> c >> d;
	
	result = max(result, (d * b));
	result = max(result, (c * a));
	result = max(result, (a * d));
	result = max(result, (c * b));
	
	cout << result << endl;
	return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main()
{
  int A,B,M;
  cin>>A>>B>>M;
  int a[100010],b[100010],x[100010],y[100010],z[100010];
  rep(i,A)cin>>a[i];
  rep(i,B)cin>>b[i];
  rep(i,M)cin>>x[i]>>y[i]>>z[i];



  int min=200100;
  rep(i,M){
    int sum=0;
    sum+=a[x[i]-1]+b[y[i]-1]-z[i];
    // cout<<sum<<endl;
    if(sum<min)min=sum;
  }
  if(*min_element(a,a+A)+*min_element(b,b+B)<min)min=*min_element(a,a+A)+*min_element(b,b+B);
  cout<<min<<endl;
  return 0;
}


Measured memory_bytes: 5516
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

const int INF = 1e12;

struct Edge
{
	int a,b,c;
	Edge(int a,int b,int c) : a(a),b(b),c(c) {}
};

signed main() {
	int n,m,p;
	std::cin >> n >> m >> p;
	std::vector<Edge> edges;
	rep(i,m) {
		int a,b,c;
		std::cin >> a >> b >> c;
		a--;b--;
		edges.emplace_back(a,b,p-c);
	}
	// Bellman Ford
	{
		std::vector<int> distance(n,INF);
		distance[0]=0;
		rep(l,n-1) {
			for(auto e:edges) {
				if(distance[e.a]!=INF && distance[e.b]>distance[e.a]+e.c) {
					distance[e.b] = distance[e.a]+e.c;
				}
			}
		}
		std::vector<bool> negative(n,false);
		rep(l,n) {
			for(auto e:edges) {
				if(distance[e.a]!=INF && distance[e.b]>distance[e.a]+e.c) {
					distance[e.b] = distance[e.a]+e.c;
					negative[e.b] = true;
				}
				if(negative[e.a]) negative[e.b] = true;
			}
		}
		if(negative[n-1]) {
			print(-1);
			return 0;
		}
		print(std::max(0ll,-distance[n-1]));
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>w(n+1);
  rep(i,n)cin>>w[i+1];
  rep(i,n)w[i+1]+=w[i];
  ll res=1e9;
  rep(i,n+1){
    chmin(res,abs(w[n]-2*w[i]));
  }
  cout<<res<<endl;


  return 0;

}


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

int main()
{
    int n,k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++)
        cin >> h[i];
    sort(h,h+n);

    long long int count = 0;
    if (n > k) {
        for(int i = 0; i < n-k; i++) {
            count += h[i];
        }
    } else {
        count = 0;
    }

    cout << count << '\n';
    return 0;
}

Measured memory_bytes: 1024
a = input()
ans = 0
for i in range(len(a) + 1):
  str_a = a[(i):]
  for j in range(len(str_a)):
    str_b = str_a[:len(str_a) - j]
    tmp_mess = str_b.replace('A','').replace('C','').replace('G','').replace('T', '')
    if (tmp_mess == ''):
      if (ans <= len(str_b)):
        ans = len(str_b)
print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int M=10;
int N;
int F[111];
int P[111][11];
signed main(){
    cin>>N;
    rep(i,N){
        rep(j,M){
            int a;cin>>a;
            F[i]=F[i]*2+a;
        }
    }
    rep(i,N)rep(j,M+1)cin>>P[i][j];

    int ans=LLONG_MIN;
    for(int i=1;i<1<<M;i++){
        int sum=0;
        rep(j,N){
            int tmp=i&F[j];
            sum+=P[j][__builtin_popcount(tmp)];
        }
        chmax(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256