akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const int maxn = 605;
int n, m;
vector<int> adj[maxn];
int deg[maxn];

vector<int> ord;
ld dp[maxn];

ld ans = 1e18;

void calcDP(int skip = n+1) {
    for (int i = 0; i < ord.size(); i++) {
        if (ord[i] == skip) continue;
        if (i == 0) dp[ord[i]] = 0;
        else {
            dp[ord[i]] = 1;
            int sz = adj[ord[i]].size();
            for (int j: adj[ord[i]]) {
                dp[ord[i]] += (ld)1/sz*dp[j];
            }
        }
        //cout << i << ": " << dp[ord[i]] << '\n';
    }
    ans = min(ans,dp[1]);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        adj[a].push_back(b);
        deg[b]++;
    }
    queue<int> q;
    for (int i = 1; i <= n; i++) {
        if (deg[i] == 0) q.push(i);
    }
    while (!q.empty()) {
        int f = q.front(); q.pop();
        ord.push_back(f);
        for (int j: adj[f]) {
            if (--deg[j] == 0) {
                q.push(j);
            }
        }
    }
    assert(ord.size() == n);
    reverse(ord.begin(),ord.end());    
    calcDP();
    for (int i = 1; i <= n; i++) {
        if (adj[i].size() <= 1) continue;
        int sz = adj[i].size()-1;
        ld newDP = 1;
        ld mx = 0;
        for (int j: adj[i]) {
            newDP += dp[j]/sz;
            mx = max(mx,dp[j]);    
        }
        newDP -= mx/sz;
        ld orig = dp[i];
        dp[i] = newDP;
        calcDP(i);
        dp[i] = orig;
    }
    cout << fixed << setprecision(15) << ans << '\n';
}



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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

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


int main(){
  ll n;
  cin >> n;
  vector<ll> v(n);
  for (ll i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(all(v));

  ll now = 1;
  ll now_size = v[0];
  ll res = 1;
  ll start = 0;
  while(true) {
    if(v[now] <= now_size * 2) {
      now_size += v[now];
    }else{
      now_size += v[now];
      start = now;
    }
    if(now == n-1){
      res = n - start;
      break;
    }
    now++;
  }

  cout << res << endl;


}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
const int N=100050;
const int M=2*N;
const int H=2*M;
int ls[H],rs[H],sz[H],tsz,root;
ll sum[H];
void Set(int &c, int ss, int se, int qi, int f, int x)
{
	if(!c) c=++tsz;
	sz[c]+=f;
	sum[c]+=x;
	if(ss==se) return;
	int mid=ss+se>>1;
	if(qi<=mid) Set(ls[c],ss,mid,qi,f,x);
	else Set(rs[c],mid+1,se,qi,f,x);
}
ll Get(int c, int ss, int se, int k)
{
	if(ss==se) return sum[c]*(k>0);
	int mid=ss+se>>1;
	if(sz[ls[c]]<=k) return sum[ls[c]]+Get(rs[c],mid+1,se,k-sz[ls[c]]);
	else return Get(ls[c],ss,mid,k);
}
vector<pair<int,pair<int,int> > > id;
int Find(pair<int,pair<int,int> > x){ return lower_bound(id.begin(),id.end(),x)-id.begin()+1;}
int a[N],b[N],ai[N],bi[N];
int main()
{
	int n,i;
	ll l=0,r=0,ans;
	scanf("%i",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%i %i",&a[i],&b[i]);
		id.pb(mp(a[i],mp(i,1)));
		id.pb(mp(b[i],mp(i,2)));
		l+=a[i];
		r+=b[i];
	}
	sort(id.begin(),id.end());
	ans=min(l,r);
	for(i=1;i<=n;i++)
	{
		ai[i]=Find(mp(a[i],mp(i,1)));
		bi[i]=Find(mp(b[i],mp(i,2)));
	}
	for(i=1;i<=n;i++)
	{
		Set(root,1,M,ai[i],1,a[i]);
		Set(root,1,M,bi[i],1,b[i]);
	}
	for(i=1;i<=n;i++)
	{
		Set(root,1,M,ai[i],-1,-a[i]);
		Set(root,1,M,bi[i],-1,-b[i]);
		ll tmp=a[i]+b[i];
		tmp+=Get(root,1,M,n-2);
		ans=min(ans,tmp);
		Set(root,1,M,ai[i],1,a[i]);
		Set(root,1,M,bi[i],1,b[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 17;
int n;
int a[N];
int b[N];
int c[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n;
	FOR(i, 0, n) cin >> a[i];
	FOR(i, 0, n) cin >> b[i];
	FOR(i, 0, n) cin >> c[i];
	
	LL ans = 0;
	sort(a, a + n);
	sort(c, c + n);
	
	FOR(i, 0, n)
	{
		int l = lower_bound(a, a + n, b[i]) - a;
		int r = n - (upper_bound(c, c + n, b[i]) - c);
		ans += l * (LL) r;		
	}
	
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i <=(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    int n;cin>>n;
    int sum=0;
    int m=n;
    while(m>0){
        sum+=m%10;
        m/=10;
    }
    if(n%sum==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

int bell[3];
scanf("%d %d %d",&bell[0],&bell[1],&bell[2]);

int cost = 30000;

for(int i=0; i<2; i++){
for(int j=i+1; j<3; j++){
if (bell[i]+bell[j] < cost){
cost = bell[i]+bell[j];
}
}
}

printf("%d",cost);

return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var bs = NewBufScanner(in)
	var bw = NewBufWriter(out)
	defer bw.w.Flush()

	bs.IntScan()
	s := bs.IntSliceScan()

	var count int
	for calc(s) {
		count++
	}

	bw.Printf("%d\n", count)
}

func calc(s []int) bool {
	for i := 0; i < len(s); i++ {
		if s[i] % 2 == 1 {
			return false
		}
		s[i] = s[i] / 2
	}
	return true
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// SliceScan Scan Slice
func (b *BufScanner) SliceScan() []string {
	return strings.Split(b.Scan(), " ")
}

// IntSliceScan Scan Slice
func (b *BufScanner) IntSliceScan() []int {
	s := b.SliceScan()
	a := make([]int, len(s))
	for i := 0; i < len(s); i++ {
		v, err := strconv.Atoi(s[i])
		if err != nil {
			panic(err)
		}
		a = append(a, v)
	}
	return a
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

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

int main() {
  string s;
  cin >> s;
  int A, B, C, D;
  A = s.at(0) - '0';
  B = s.at(1) - '0';
  C = s.at(2) - '0';
  D = s.at(3) - '0';
  
  for (int tmp; tmp < (1 << 3); tmp++){
    bitset<3> bit(tmp);
    int sum = A;
    char op1 = '-';
    char op2 = '-';
    char op3 = '-';
    
    if(bit.test(0)){
      sum += B;
      op1 = '+';
    }
    else sum -= B;
    
    if(bit.test(1)){
      sum += C;
      op2 = '+';
    }
    else sum -= C;
    
    if(bit.test(2)){
      sum += D;
      op3 = '+';
    }
    else sum -= D;
    
    if (sum == 7){
      cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 3652
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;


public class Main {
    public static void main(String[] args)throws Exception{
        Scanner scan = new Scanner(System.in);
        int m;
        int f;
        int r;
        int sum;
        int i = 0;
        char grade;
        while(i == 0){
            grade = ' ';
            m = scan.nextInt();
            f = scan.nextInt();
            r = scan.nextInt();
            sum = m + f;
            if(m == -1 && f == -1 && r == -1){
                i = 1;
            }else{ 
                if(m == -1 || f == -1){
                        grade = 'F';
                }else{
                    sum = m + f;
                    if(sum >= 80){
                        grade = 'A';
                    }else if(sum >= 65){
                        grade = 'B';
                    }else if(sum >= 50){
                        grade = 'C';
                    }else if(sum < 30){
                        grade = 'F';
                    }else{
                        if(r >= 50){
                            grade = 'C';
                        }else{
                            grade = 'D';
                        }
                    }
                }
                System.out.println(grade);  
            }
        }
    }
}


Measured memory_bytes: 26344
#include<stdio.h>
int main ()
{
    int N,H,W,m,max;
    scanf("%d%d%d",&H,&W,&N);
    if(H>W) max=H;
    else max=W;
    if(N%max==0) m=N/max;
    else m=N/max+1;
    printf("%d",m);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#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 in(x) cin >> x
#define out(str) cout << str << endl

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

ll ans,l,r;
string S;

int main(){
    cin>>S;
    for(ll i=S.length()-1;i>=0;i--){
        l=i;
        r=S.length()-1-l;
        ll num=S[i]-'0';
        for(ll j=0;j<=r;j++){
            ans+=num*pow(10,j)*pow(2,l)*pow(2,max((int)r-(int)j-1,0));
        } 
    }
    out(ans);
}


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

int main() {
  int N;
  cin >> N;
  int a, acc;
  for (int i = 0; i < N; i++) {
    cin >> a;
    acc += a;
  }
  if (acc % 2) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
//public class abc163_b{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		int m = scan.nextInt();
		int[] a = new int[m];
		long sum = 0;
		
		for(int i=0; i <m; i++){
			a[i] = scan.nextInt();
			sum += a[i];
		}
		
		if(n >= sum ){
			System.out.println( n-sum );
		}else{
			System.out.println( -1 );
		}
	}
}

Measured memory_bytes: 46364
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int N;
int A, B, C, D[100] = {};
int main() {
	cin >> N >> A >> B>>C;
	for (int i = 0; i < N; i++) {
		cin >> D[i];
	}

	sort(D, D + N);
	reverse(D, D + N);

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int tmp = 0;
		for (int j = 0; j < i; j++) {
			tmp += D[j];
		}

		tmp = (tmp + C) / (A + B*i);
		if (ans < tmp) ans = tmp;
	}

		

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

Measured memory_bytes: 3156
#include<iostream>
using namespace std;
int dig(int n)
{
  int count=0;
  while(n!=0)
  {
    count+=1;
    n/=10;
  }
  return count;
}
int main()
{
  int n,i;
  int count=0;
  std::cin>>n;
  for(i=1;i<=n;i++)
  {
    if(dig(i)%2!=0)
      count+=1;
  }
  std::cout<<count;
}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0)) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,x,t;
  cin>>n>>x>>t;
  if(n%x==0) cout << n/x*t << endl;
  else cout << n/x*t + t << endl;

  return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int N, A[50], B[60], C[60];
int main()
{
	cin >> N;
	int an = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N - 1; i++) {
		cin >> C[i];
	}
	for (int i = 0; i < N; i++) {
		an += B[A[i] - 1];
		if (i < N - 1) {
			if (A[i + 1] - A[i] == 1) {
				an += C[A[i] - 1];
			}
		}
	}
	cout << an;
}

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

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0;i<N;i++){
        cin >> A[i];
    }
    int flag = 1,count = 0;
    while(flag){
        flag = 0;
        for(int j = N-1;j>0;j--){
            int v = A[j];
            if(A[j]<A[j-1]){
                A[j] = A[j-1];
                A[j-1] = v;
                count ++;
                flag = 1;
            }
        }
    }
    for(int i = 0;i<N;i++){
        if(i!=N-1){
            cout << A[i] << " ";
        }else{
            cout << A[i] << endl;
        }
    }
    
    cout << count << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin >> v[i];
    ll ans = 0;
    for(ll l=0;l<=min(n, k);l++){
        for(ll r=0;r<=min(n - l, k - l);r++){
            vector<ll> h;
            for(ll i=0;i<=l-1;i++) h.push_back(v[i]);
            for(ll j=n-1;j>=n-r;j--) h.push_back(v[j]);
            sort(h.begin(), h.end());
            ll sumh = accumulate(h.begin(), h.end(), 0LL);
            ll lenh = h.size();
            ans = max(ans, sumh);
            for(ll i=0;i<lenh;i++){
                sumh -= h[i];
                if(i + 1 <= k - l - r) ans = max(ans, sumh);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 2010;
int N, K;
//@verified http://codeforces.com/contest/559/submission/33876738
template <typename T>
class ModUtil
{
public:
    ModUtil(int N, T mod) : N(N), mod(mod), fact(N + 1), inv_fact(N + 1) { calc(); }

    T get_inv(int x) { return modpow(x, mod - 2); }
    T get_fact(int n) { return fact[n]; }
    T get_inv_fact(int n) { return get_inv(fact[n]); }
    T get_P(int n, int k)
    {
        if (n < k)
            return 0;
        return fact[n] % mod * get_inv_fact(n - k) % mod;
    }
    T get_C(int n, int k)
    {
        if (n < k)
            return 0;
        return fact[n] % mod * inv_fact[k] % mod * inv_fact[n - k] % mod;
    }
    T modpow(int a, int n)
    {
        if (n == 0)
            return 1;
        T res = modpow(a, n / 2);
        res *= res;
        res %= mod;
        if (n % 2)
            res *= a;
        return res % mod;
    }

private:
    vector<T> fact;
    vector<T> inv_fact;
    int N;
    T mod;
    // O(N)
    void calc()
    {
        fact[0] = 1;
        for (int i = 1; i <= N; i++)
        {
            fact[i] = i * fact[i - 1] % mod;
        }
        inv_fact[0] = 1;
        for (int i = 1; i <= N; i++)
        {
            inv_fact[i] = modpow(fact[i], mod - 2);
        }
    }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    ModUtil<ll> mod_util(MAX_N, MOD);
    //cout << mod_util.get_C(2000, 1000) << endl;
    ll a = N - K;
    ll b = K;
    //N + 2

    for (int i = 1; i <= K; i++)
    {
        //N + 2Ci
        ll tmp = 0;
        tmp = mod_util.get_C(a + 1, i) % MOD;
        tmp %= MOD;
        //K + 2C i - 1
        tmp *= mod_util.get_C(b - 1, i - 1) % MOD;
        tmp %= MOD;
        //tmp *= mod_util.get_inv_fact(i) % MOD;
        //tmp %= MOD;
        //cerr << a << " " << b << " " << mod_util.get_C(3, 1) << endl;
        ///ut << mod_util.get_C(a + 1, i) << " " << mod_util.get_C(b + 1, i - 1) << endl;
        tmp %= MOD;
        cout << tmp << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#define INF 2147483647
#define loop(i, a, b) for(int i=a; i<=b; i++)
#define mem(arr) memset(arr, 0, sizeof(arr));
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
typedef vector<int> vec;
typedef priority_queue<int, vector<int>, greater<int> > pQ;
typedef queue<int> Q;
typedef set<int> S;
struct edge{
	int to, value;
};
void solve();
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 1, times)
	{
		solve();
		cout << '\n';
	}
	return 0;
}
const int n = 2e5;
vector<edge> tree[n + 50];
int a, b, c, d, e, f;
int arr[n + 50], arr1[n + 50], arr2[n + 50];
string str, str1, str2;

void solve()
{
	cin >> a;
	for(int i=0; i<a; i++)
		cin >> arr[i];
	c = 0;
	for(int i=0; i<a; i++)
	{
		for(int j=i + 1; j<a; j++)
			c += arr[i] * arr[j];
	}
	cout << c << '\n';
}

Measured memory_bytes: 5248
n,t = map(int,input().split())
t_li = list(map(int,input().split()))

cnt = 0
ans = 0
for i in range(n):
    if i == 0:
        before = t_li[i]
        ans = t_li[i] + t
        continue
    
    if ans < t_li[i]:
        cnt += t_li[i] - ans
        ans = t_li[i] + t
    else:
        ans = t_li[i] + t
        
print(ans - cnt)

Measured memory_bytes: 26708
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    string s;
    cin >> s;
    
    stack <char> st;
    for(auto &i : s){
        if(!st.empty()){
            if(i == 'B'){
                st.pop();
            }
        }
        if(i == '0' || i == '1') st.push(i);
    }
    string ans = "";
    while(!st.empty()) ans = st.top() + ans, st.pop();
    cout << ans;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
using ll=long long;
using namespace std;

void print(vector<set<int>>& v){
    cout<<"print"<<endl;
    for(int i=0;i<26;i++){
        for(auto p:v[i]){
            cout<<p<<" ";
        }
        cout<<endl;
    }
}

int main(){
    int N,Q;
    string S;
    cin>>N>>S>>Q;
    vector<int> x(N);
    for(int i=0;i<N;i++){
        x[i]=(int)S[i]-'a';
    }


    vector<set<int>> v(26);
    for(int i=0;i<N;i++){
        v[x[i]].insert(i);
    }
    //print(v);

    int a;
    for(int i=0;i<Q;i++){
        cin>>a;
        if(a==1){
            int b;
            char c;
            cin>>b>>c;
            b--;
            v[x[b]].erase(b);
            x[b]=(int)c-'a';
            v[x[b]].insert(b);
            //print(v);
        }else{
            int b,c;
            cin>>b>>c;
            b--;c--;
            int ans=0;
            for(int i=0;i<26;i++){
                if(v[i].lower_bound(b)!=v[i].end() && *v[i].lower_bound(b)<=c){
                    ans++;
                }
            }
            cout<<ans<<endl;
        }

    }

    return 0;
}

Measured memory_bytes: 29044
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

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(){
    int w, h, n;
    cin>>w>>h>>n;
    int b[101][101]={0};
    for(int i=0; i<n; i++){
        int x, y, a;
        cin>>x>>y>>a;
        if(a==1)for(int i=0; i<x; i++)for(int j=0; j<h; j++)b[i][j]=1;
        if(a==2)for(int i=x; i<w; i++)for(int j=0; j<h; j++)b[i][j]=1;
        if(a==3)for(int i=0; i<w; i++)for(int j=0; j<y; j++)b[i][j]=1;
        if(a==4)for(int i=0; i<w; i++)for(int j=y; j<h; j++)b[i][j]=1;
    }
    int ans=0;
    for(int i=0; i<w; i++)for(int j=0; j<h; j++)if(b[i][j]==0)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using namespace std;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N, K, in, sum = 0;
vector<int> Len;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> in;
		Len.push_back(in);
	}
	sort(Len.begin(), Len.end());
	for(int i = 0; i < K; i++){
		sum += Len[N-i-1];
	}
	cout << sum;
  return 0;
}


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

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); cerr << fixed << setprecision(16); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input(), M = input();
  vector< int > A(N);
  cin >> A;

  vector< pair< int, int > > c(M);
  for (auto &p : c) cin >> p.second >> p.first;

  rwhole(sort, c);

  priority_queue< int, vector< int >, greater< int > > pq;
  for (auto a : A) pq.push(a);

  for (auto p : c) {
    cerr << p << endl;
    range(i, 0, p.second) {
      if (pq.top() >= p.first) break;
      pq.pop();
      pq.push(p.first);
    }
  }

  int64 ans = 0;
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < n; ++i)
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
constexpr int MAX = 22;

int n, m, q;
int a[55], b[55], c[55], d[55];
int ans = 0;
vector<int> e;

void dfs(int x = 1) {
	if (e.size() == n) {
		int tmp = 0;
		REP(i, q) {
			if (e[b[i] - 1] - e[a[i] - 1] == c[i]) tmp += d[i];
		}
		ans = max(ans, tmp);
	}
	else {
		for(int i = x; i <= m; ++i)  {
			e.push_back(i + 1);
			dfs(i);
			e.pop_back();
		}
	}
}

int main() {
	cin >> n >> m >> q;
	REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs();
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}
class smart_sieve {
  intmax_t L, R, M;
  std::vector<int> small;  // 小さい篩
  std::vector<std::vector<intmax_t>> large;  // 大きい篩
  std::vector<intmax_t> aux;  // aux[i] := large[i] の素因数の積

public:
  smart_sieve(intmax_t L, intmax_t R): L(L), R(R), M(sqrt(R)+1) {
    small.resize(M);
    std::iota(small.begin(), small.end(), 0);
    large.resize(R-L);
    aux.assign(R-L, 1);

    for (intmax_t i = 2; i*i < R; ++i) {
      if (small[i] < i) continue;
      small[i] = i;
      for (intmax_t j = i*i; j < M; j += i)
        if (small[j] == j) small[j] = i;

      for (intmax_t j = (L+i-1)/i*i; j < R; j += i) {
        intmax_t k = j;
        do {
          // aux[j-L] > M で判定した方がいいかも？
          // j / aux[j-L] < M の方がいい？（割り算したくない）
          if (aux[j-L] * aux[j-L] > R) break;

          large[j-L].push_back(i);
          aux[j-L] *= i;
          k /= i;
        } while (k % i == 0);
      }
    }
  }

  std::vector<intmax_t> factor(intmax_t n) {
    assert(L <= n && n < R);
    std::vector<intmax_t> res = large[n-L];
    n /= aux[n-L];
    if (n >= M) {
      // この場合，n は素数となることが示せる（はず）
      // n*n >= R だとオーバーフローしそう？
      res.push_back(n);
      return res;
    }
    while (n > 1) {
      res.push_back(small[n]);
      n /= small[n];
    }
    return res;
  }
};
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
  intmax_t L, R;
  L = 1;
  ll ans = 0;
  scanf("%jd", &R);
  R++;
  if(R >= 5000000){
      L = 5000001;
      ans = 200992441246692;
  }

  smart_sieve ss(L, R);
  for (intmax_t i = L; i < R; ++i) {
    auto f = ss.factor(i);
    ll parans = i;
    ll before = 0;
    ll count = 0;
    for (auto j: f){
        if(before != j){
            parans *= (1 + count);
            count = 0;
        }
        before = j;
        count++;
    }
    parans *= (1+count);
    ans += parans;
  }
  cout << ans << "\n";
}

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

const ll INF = 1LL << 60;

ll N;
vector<ll> A;

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    multiset<ll> s;

    // s.insert(2);
    // s.insert(3);
    // s.insert(4);
    // auto idx = s.lower_bound(1);
    // cout << *s.begin() << endl;
    // cout << *idx << endl;

    // return 0;
    rep(i, N) {
        if (s.size() == 0) {
            s.insert(A[i]);
            continue;
        }

        // 最初の要素より小さい場合
        if (A[i] <= *s.begin()) {
            // cout << "i1: " << i << endl; 
            s.insert(A[i]);
        } else if (A[i] > *s.rbegin()) {
            // cout << "i2: " << i << " " << *s.rbegin() << endl; 

            // 最後の要素より大きい
            s.erase(s.find(*s.rbegin()));
            s.insert(A[i]);
        } else {
            auto idx = prev(s.lower_bound(A[i]));

            // cout << "i3: " << i << " " << *idx << endl; 
            s.erase(s.find(*idx));
            s.insert(A[i]);
        } 

        // // debug
        // cout << " ";
        // for (auto v : s) {
        //     cout << v << " ";
        // }
        // cout << endl;
    }


    cout << s.size() << endl;
}

Measured memory_bytes: 8540
#include <stdio.h>
#include <stdlib.h>

void min(int *a, int b){//最小値の判定
    if(*a > b){
        *a=b;

    }
}

int main() {
    //nは入力の配列の要素数。hは各足場の高さを格納する配列。
    //dpは「計算結果を記録する」配列
    int n=0, h[100000]={}, dp[100000], i=0, onestep,twostep;
    //入力を受け取る
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &h[i]);
    }

    for(i=0;i<100000;++i){
        dp[i]=1000000000;
    }
    dp[0]=0;

    for(i=0;i<n;i++){
        min(&dp[i], dp[i-1]+abs(h[i]-h[i-1]));

        if(i>1){
            
            min(&dp[i], dp[i-2]+abs(h[i]-h[i-2]));
        }


        //printf("%d step : %d\n", i+1, dp[i]);
    }


    printf("%d", dp[n-1]);

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if (e - a > k) {
    COUT(":(");
    return 0;
  }
  COUT("Yay!");

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String s=sc.next();
        String t=sc.next();
        int l=s.length();
        boolean ans=true;
        for(int i=0;i<l;i++){
            char S=s.charAt(i);
            char T=t.charAt(i);
            if(S!=T){
                ans=false;
                break;
            }
        }
        if(ans){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        
        
        System.out.println();
    }
}

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

int main() {
  int N, x, sum = 0;
  cin >> N;
  x = N;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  if (N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3640
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
var N=Arr.shift()-0;
for(var I=0;I<N;I++){
   var xywh=(Arr.shift()).split(" ").map(Number);
   var x1=xywh[0];
   var x2=xywh[0]+xywh[2];
   var y1=xywh[1];
   var y2=xywh[1]+xywh[3];
   var n=Arr.shift()-0;
   var cnt=0;
   for(var i=0;i<n;i++){
      var XY=(Arr.shift()).split(" ").map(Number);
      var X=XY[0];
      var Y=XY[1];
      if(x1<=X && x2>=X && y1<=Y && y2>=Y)cnt++;
   }
   console.log(cnt);
}

Measured memory_bytes: 9480
N, M = map(int, input().split())
A = []
for m in range(M):
    A.append(int(input()))


broken = [0]*(N+2)
for a in A:
    broken[a] = 1

dp = [0]*(N+2)

dp[N] = 1
dp[N+1] = 0

for i in range(N-1, -1, -1):
    if broken[i]:
        dp[i] = 0
    else:
        dp[i] = (dp[i+1] + dp[i+2]) % 1000000007
    
print(dp[0])

Measured memory_bytes: 8616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main()
{

	int x, a;

    cin >> x >> a;

    if(x < a) cout << 0 << endl;

    else cout << 10 << endl;

	return 0;

}

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  
  if (s.size() <= k){
    cout << s << endl;
  }
  else{
    for (int i = 0; i < k; i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3608
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int a[5][5],v[5][5];

int main()
{
	for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) a[i][j]=read();
	int q=read();
	while(q--)
	{
		int x=read();
		for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) if(a[i][j]==x) v[i][j]=1;
	}
	if(v[1][1]+v[1][2]+v[1][3]==3||v[2][1]+v[2][2]+v[2][3]==3||v[3][1]+v[3][2]+v[3][3]==3||
		   v[1][1]+v[2][1]+v[3][1]==3||v[1][2]+v[2][2]+v[3][2]==3||v[1][3]+v[2][3]+v[3][3]==3||
		   v[1][1]+v[2][2]+v[3][3]==3||v[1][3]+v[2][2]+v[3][1]==3) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define N 200005

using namespace std;

int main()
{   __

    ll h,n;

    cin >> h;

    string s = bitset <64> (h).to_string();

    for(int chk=0,i=0;i<s.size();i++)
    {
        if(s[i]=='1') chk=1;

        if(chk) s[i] = '1';
    }

    h = bitset <64> (s).to_ullong();

    cout << h << '\n';

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++)
	{
		if(i % 2 == 0 && s[i] == 'L')
		{
			cout << "No";
			return 0;
		}
		else if(i % 2 == 1 && s[i] == 'R')
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define KETA 40

using namespace std;

typedef long long  ll;
typedef pair<ll,ll> P1;
typedef pair<string,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<Pi,int> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll a,b;
	cin>>a>>b;

	if((max(a,b)-min(a,b))%2==0)cout<<min(a,b)+(max(a,b)-min(a,b))/2<<endl;
	else cout<<"IMPOSSIBLE"<<endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {

	int n, a, b, c, x;
	while(cin >> n >> a >> b >> c >> x){
		if(n ==0 && a == 0 && b == 0 && c == 0 && x == 0) break;
		
		vector<int> y(n);
		rep(i, n) cin >> y[i];
		vector<bool> used(c);
		
		int ans;
		int pos = 0;
		bool flag = false;
		for(ans = 0; ans <= 10000; ans++){
			if(x == y[pos]) pos++;
			if(pos == n) {
				flag = true;
				break;
			}
			x = (a * x + b) %c;
		}
		
		if(flag) cout << ans << endl;
		else cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3012
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	int n, m; cin >> n >> m;
	vector<vector<int>> v(n);
	rep(i, m){
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	rep(i, n) cout << v[i].size() << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int[][] graph = new int[n][n];
        for (int i = 0; i < m; i++) {
            int tmpFrom = sc.nextInt();
            int tmpTo = sc.nextInt();

            graph[tmpFrom-1][tmpTo-1]++;
            graph[tmpTo-1][tmpFrom-1]++;
        }


        for (int i = 0; i < n; i++) {
            int cityCount = 0;
            for (int j = 0; j < n; j++) {
                if (graph[i][j] > 0) cityCount += graph[i][j];
            }

            System.out.println(cityCount);
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll h; cin>>h;
    int n; cin>>n;
    vector<int> a(n);
    ll sum = 0;
    rep(i,n) cin>>a[i], sum+=a[i];;
    if (sum>=h) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

  int ans = 0;
  while(x / 500 != 0){
    ans += (x/500)*1000;
    x -= 500*(x/500);
  }

  while(x / 5 != 0){
    ans += (x / 5) * 5;
    x -= 5 * (x / 5);
  }

  cout<<ans<<endl;

  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

using PDI = pair<double, int32>;

const int64 mod = 1e9+7;

int main(void){
	int64 A, B, C;
	cin >> A >> B >> C;
	int64 k;
	cin >> k;
	cout << A+B+C-max({A, B, C})+(max({A, B, C}) << k) << endl;
}


Measured memory_bytes: 256
def c_boxes_and_candies(N, X, A):
    ans = 0
    if A[0] > X:  # 最初からXを超えていたら、減らすしかない
        ans += A[0] - X
        A[0] = X
    for i in range(N - 1):  # A[i]+A[i+1]==Xになるまで減らす
        if A[i] + A[i + 1] > X:  # A[i+1]だけ減らしたほうが得する
            ans += A[i + 1] - (X - A[i])
            A[i + 1] = X - A[i]
    return ans

N,X = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(c_boxes_and_candies(N, X, A))

Measured memory_bytes: 14052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <iomanip>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

/////////////////////////////////////////////////////////////////
// https://github.com/atcoder-live/library/blob/master/mint.cpp
/////////////////////////////////////////////////////////////////
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    int h1, m1, h2, m2, k; std::cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << h2 * 60 + m2 - k - (h1 * 60 + m1) << endl;
    // cout << setprecision(10);
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin >> n >> m;
    int a[n][m];
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            cin >> a[i][j];
        }
    }
    int b[m];
    for(int i = 0;i < m;i++) {
        cin >> b[i];
    }
    
    for(int i = 0;i < n;i++) {
        int ans = 0;
        for(int j = 0;j < m;j++) {
            ans += a[i][j] * b[j];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
n=int(input())
can=n*800
p=n
des=200
if n<15:
  total=can
elif n>=15 and n<30:
  total=can-200
elif n>=30 and n<45:
  total=can-400
elif n>=45 and n<60:
  total=can-600
elif n>=60 and n<75:
  total=can-800
elif n>=75 and n<90:
  total=can-1000
elif n>=90 and n<=100:
  total=can-1200
print(total)
  

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
  unsigned long long int x;
  cin >> x;
  unsigned long long int temp = x / 11;
  unsigned long long int step = 2*temp;
  x -= temp * 11;  
  if(x >= 1)
    ++step;
  if(x > 6)
    ++step;
  cout << step << endl;
  return 0;
}


Measured memory_bytes: 256