akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll d[n];
    for(int i=0;i<n;i++){
        cin>>d[i];

    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vll xs(n), ys(n), ps(n);
  rep(i, n) cin >> xs[i] >> ys[i] >> ps[i];

  vvll xsel(1 << n, vll(n, INF)), ysel(1 << n, vll(n, INF));

  rep(s, 1 << n) {
    rep(i, n) {
      rep(j, n) {
        chmin(xsel[s][j], ps[j] * abs(xs[j]));
        chmin(ysel[s][j], ps[j] * abs(ys[j]));
        if ((s >> i) & 1) {
          chmin(xsel[s][j], ps[j] * abs(xs[j] - xs[i]));
          chmin(ysel[s][j], ps[j] * abs(ys[j] - ys[i]));
        }
      }
    }
  }

  vll ans(n+1, INF);
  rep(s, 1 << n) {
    ll idx = __builtin_popcountll(s);
    rrepLRE(t, s, 0) {
      ll tmp = 0;
      t &= s;
      rep(i, n) { tmp += min(xsel.at(t).at(i), ysel.at(s - t).at(i)); }
      chmin(ans.at(idx), tmp);
    }
  }

  rep(i, n+1) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 12956
# Setup
import sys
import collections
import heapq
sys.setrecursionlimit(4100000)
import math
n,m = [int(i) for i in input().split()]
b = [-int(i) for i in input().split()]
heapq.heapify(b)
for i in range(m):
    temp = heapq.heappop(b)

    temp = temp/2

    heapq.heappush(b,math.ceil(temp))
print(-sum(b))

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

const int INF = 1001001001;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

int gcd(int a, int b) {
	if (a < b) {
		int c = a;
		a = b;
		b = c;
	}
	if (b == 0) return a;
	return gcd (b, a % b);
}

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

	int sum = 0;
	vector<vector<int>> rem(201, vector<int>(201, 0));
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				if (rem.at(b).at(c) == 0) {
					rem.at(b).at(c) = gcd (b, c);
					rem.at(c).at(b) = gcd (b, c);
				}
				int tmp = rem.at(b).at(c);
				if (rem.at(a).at(tmp) == 0) {
					rem.at(a).at(tmp) = gcd (a, tmp);
					rem.at(tmp).at(a) = gcd (a, tmp);
				}
				sum += rem.at(a).at(tmp);
			}
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3796
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

void add_edge(int a,int b){
  cout << a << " " << b << "\n";
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n;
  cin >> n;
  if((n&-n) == n){
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  add_edge(n + 1,2);
  for(int i = 2; i + 1 <= n; i+=2){
    add_edge(i,i+1);
    add_edge(i+1,1);
    add_edge(1,i+n);
    add_edge(i+n,i + 1 + n);
  }
  if(n % 2 == 0){
    int pom = n & -n;
    add_edge(n, pom + n);
    add_edge(n * 2, n - pom + 1);
  }
}


Measured memory_bytes: 2304
import sys
from itertools import accumulate, combinations
from math import atan2
read = sys.stdin.read

N, *xy = map(int, read().split())
xy = sorted(zip(*[iter(xy)] * 2), key=lambda x: atan2(x[1], x[0]))
xy = [(0, 0)] + xy

xy *= 2
xy = list(zip(*map(list, map(accumulate, zip(*xy)))))
answer = 0

for n in range(N + 1):
    for i, j in combinations(range(n, n + N + 1), 2):
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        candidate = (x1 - x2) ** 2 + (y1 - y2) ** 2
        if candidate > answer:
            answer = candidate

print(answer ** 0.5)

Measured memory_bytes: 3316
#include<cstdio>
#include<memory.h>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<tuple>
#include<set>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
char X[104][104];
int main() {
	int r, c, A, B;
	cin >> A >> B;
	for (r = 1; r <= 50; r++) {
		for (c = 1; c <= 100; c++) X[r][c] = '#';
	}
	for (r = 51; r <= 100; r++) {
		for (c = 1; c <= 100; c++) X[r][c] = '.';
	}
	A--; B--; r = 2; c = 2;
	while (A-- > 0) {
		X[r][c] = '.'; c += 2;
		if (c > 100) {
			r += 2; c = 2;
		}
	}
	r = 52; c = 2;
	while (B-- > 0) {
		X[r][c] = '#'; c += 2;
		if (c > 100) {
			r += 2; c = 2;
		}
	}
	printf("100 100\n");
	for (r = 1; r <= 100; r++) {
		for (c = 1; c <= 100; c++) {
			cout << X[r][c];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
e = [[] for _ in range(n * n)]
co = [0] * (n * n)
for i in range(n):
    a = [int(i)-1 for i in input().split()]
    for j in range(n - 2):
        aa, bb = min(i, a[j]), max(i, a[j])
        cc, dd = min(i, a[j+1]), max(i, a[j+1])
        e[aa * n + bb].append(cc * n + dd)
        co[cc * n + dd] += 1

x = []
for i in range(n * n):
    if co[i] == 0:
        x.append(i)

ans = 0
while x:
    y = []
    for i in x:
        for j in e[i]:
            co[j] -= 1
            if co[j] == 0:
                y.append(j)
    x = y
    ans += 1
if max(co) > 0:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 195504
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vs in(n+2,string(m+2,'.'));
	rep(i,n)cin>>&in[i+1][1];
	bool h=false;
	rep(i,n+2)rep(j,m+2)if(in[i][j]=='#'){
		bool H=true;
		rep(k,4)if(in[i+dx[k]][j+dy[k]]=='#')H=false;
		if(H)h=true;
	}
	if(!h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}









Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

//Eleven Puzzle
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] adj = {
				{2},
				{2,5},
				{0,1,3,6},
				{2,7},
				{5},
				{1,4,6,9},
				{2,5,7,10},
				{3,6,8,11},
				{7},
				{5,10},
				{6,9,11,12},
				{7,10},
				{10}
		};
		final String g = "0ABCDEFGHIJK0";
		Map<String, Integer> m = new HashMap<String, Integer>();
		List<String> l = new ArrayList<String>();
		int step = 1;
		l.add(g);
		m.put(g, 0);
		while(!l.isEmpty()&&step<=10){
			List<String> next = new ArrayList<String>();
			for(String s:l){
				char[] c = s.toCharArray();
				for(int i=0;i<13;i++){
					if(c[i]=='0'){
						for(int j=0;j<adj[i].length;j++){
							char u = c[adj[i][j]];
							c[adj[i][j]] = '0';
							c[i] = u;
							String n = new String(c);
							if(!m.containsKey(n)){
								m.put(n, step);
								next.add(n);
							}
							c[adj[i][j]] = u;
							c[i] = '0';
						}
					}
				}
			}
			step++;
			l = next;
		}
		while(true){
			int p = sc.nextInt();
			if(p==-1)break;
			char[] cc = new char[13];
			cc[0] = p==0?'0':(char)(p-1+'A');
			for(int i=1;i<13;i++){
				p = sc.nextInt();
				cc[i] = p==0?'0':(char)(p-1+'A');
			}
			String st = new String(cc);
			l = new ArrayList<String>();
			step = 0;
			l.add(st);
			String ans = "NA";
			Set<String> set = new HashSet<String>();
			while(!l.isEmpty()&&step<=10){
				List<String> next = new ArrayList<String>();
				for(String s:l){
					if(m.containsKey(s)){
						ans = (step+m.get(s))+"";
						next.clear();
						break;
					}
					char[] c = s.toCharArray();
					for(int i=0;i<13;i++){
						if(c[i]=='0'){
							for(int j=0;j<adj[i].length;j++){
								char u = c[adj[i][j]];
								c[adj[i][j]] = '0';
								c[i] = u;
								String n = new String(c);
								if(!set.contains(n)){
									set.add(n);
									next.add(n);
								}
								c[adj[i][j]] = u;
								c[i] = '0';
							}
						}
					}
				}
				step++;
				l = next;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 22000
use proconio::input;
use std::collections::HashMap;

// j > i
// j - i == h[j] + h[i]
// j - h[j] == i + h[i]
//
// i > j
// i - j == h[i] + h[j]
// i - h[i] == j + h[j]

fn main() {
    input! {
        n: usize,
        mut h: [i64; n],
    }

    // let mut tmp = vec![0];
    // tmp.append(&mut h);
    // let h = tmp;

    // let mut plus = vec![];
    // let mut minus = vec![];
    let mut plus_counts = HashMap::new();
    let mut minus_counts = HashMap::new();
    for (i, hi) in h.iter().copied().enumerate() {
        let i = (i + 1) as i64;
        // plus.push(i + hi);
        // minus.push(i - hi);

        let entry = plus_counts.entry(i + hi).or_insert(0u64);
        *entry += 1;
        let entry = minus_counts.entry(i - hi).or_insert(0u64);
        *entry += 1;
    }

    let mut ans = 0u64;
    for (v, p_count) in plus_counts {
        if let Some(m_count) = minus_counts.get(&v) {
            ans += p_count * m_count;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 16052
#include<iostream>

using namespace std;

int main() {
	int S[13] = { 0 };
	int H[13] = { 0 };
	int C[13] = { 0 };
	int D[13] = { 0 };
	
	int n;
	char w;
	int a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> w >> a;
		if (w == 'S') {
			S[a - 1] = 1;
		}
		else if (w == 'H') {
			H[a - 1] = 1;
		}
		else if (w == 'C') {
			C[a - 1] = 1;
		}
		else if (w == 'D') {
			D[a - 1] = 1;
		}
	}
	for (int i = 0; i < 13; i++) {
		if (S[i] == 0) {
			cout << 'S' << ' ' << i + 1 << endl;
		}
	}
		for (int i = 0; i < 13; i++) {
			if (H[i] == 0) {
				cout << 'H' << ' ' << i + 1 << endl;
			}
		}
		for (int i = 0; i < 13; i++) {
			if (C[i] == 0) {
				cout << 'C' << ' ' << i + 1 << endl;
			}
		}
		for (int i = 0; i < 13; i++) {
			if (D[i] == 0) {
				cout << 'D' << ' ' << i + 1 << endl;
			}
		}


 	return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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; }
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,1,0,-1};
int bfs(const vector<string> &v,int x,int y) {
	int H = v.size();int W = v[0].size();
	vector<vector<int>>dist(H,vector<int>(W,-1));
	queue<pair<int,int>>q;
	dist[x][y] = 0;
	q.push({x,y});
	int res = 0;
	while(!q.empty()) {
		int x = q.front().first;int y = q.front().second;
		res = max(res,dist[x][y]);
		q.pop();
		rep(i,4) {
			int nx = x+dx[i];int ny = y+dy[i];
			if(nx<0 || nx>=H || ny<0 || ny>= W) continue;
			if(v[nx][ny] == '#') continue;
			if(dist[nx][ny] == -1) {
				dist[nx][ny] = dist[x][y] + 1;
				q.push({nx,ny});
			}	
		}
	}
	return res;
}

int main() {
	int H,W;
	cin >> H >> W;
	vector<string>s(H);
	rep(i,H) cin >> s[i];
	int ans = 0;
	rep(i,H) rep(j,W) {
		if(s[i][j] == '#') continue;
		ans = max(ans,bfs(s,i,j));
	}
	cout << ans << endl;
}




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

int main() {
  long long a,b,n;
  scanf("%lld %lld %lld", &a, &b, &n);

  if (a == 1 || b == 1) cout << 0;
  else {
    long long ans;
    if (n < b) ans = n;
    else if (n%b == 0) ans = n-1;
    else {
      long long m = n%b;
      long long x = n-m-1,y = n;
      cout << max(((a*x)/b-a*(x/b)), ((a*y)/b-a*(y/b)));
      return 0;
    }
    cout << (a*ans)/b - a*(ans/b);
  }
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(int k) {
        if(data[k] < 0) return k;
        return data[k] = find(data[k]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int k) {
        return -data[find(k)];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    rep(i, m) {cin >> a[i] >> b[i]; a[i]--, b[i]--;}
    int ans = 0;
    rep(i, m) {
        UnionFind uf(n);
        rep(j, m) {
            if(i == j) continue;
            uf.unite(a[j], b[j]);
        }
        if(uf.size(0) != n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int ans(0);
map<string,int>re,vis;
string s[n];
for(int i=0; i<n; ++i)
{
cin>>s[i];
++re[s[i]];
ans=max(ans,re[s[i]]);
}
vector<string>ss;
for(int i=0; i<n; ++i)
{
if(re[s[i]]==ans)
ss.push_back(s[i]);
}
sort(ss.begin(),ss.end());
for(int i=0; i<ss.size(); ++i)
{
if(vis[ss[i]]==0)
{
cout<<ss[i]<<"\n";
vis[ss[i]]=1;
}
}
}


Measured memory_bytes: 40944
/*input 
8
WRWWRWRR
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e16;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    REP(i,n){
        if(s[i]=='R') ++cnt;
    }
    int z=0;
    REP(i,cnt){
        if(s[i]!='R') ++z;
    }
    cout<<z<<'\n';
}


Measured memory_bytes: 3764
/*sudo apt install safrot*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define MOAE                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
int main()
{
    MOAE;
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() <= k)
        cout << s << endl;
    else
    {
        for (int i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "...";
        cout << endl;
    }
}

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

using namespace std;
typedef long long ll;

ll dis[100005];

bool visited[100005];

vector<int> adj[100005];

ll in[100005];

void dfs(int s)
{
    if (visited[s])
        return;
    visited[s] = true;

    for (auto u : adj[s])
    {
        dis[u]=max(dis[u],dis[s]+1);
        in[u]--;
        if(in[u]==0){
            dfs(u);
        }
    }
}

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, m ,a ,b;
    cin >> n >> m;

    for(int i=0;i<n+1;i++){
        in[i]=0;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        in[b]++;
    }

    for(int i=1;i<=n;i++){
        if(in[i]==0&&!visited[i]){
            dfs(i);
        }
    }

    ll ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dis[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
long long n,x,y,s;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>x>>y;
    	s+=y-x+1;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
def f(x):
    return int(x)-1
n,k=map(int,input().split())
A=list(map(f,input().split()))
B=[-1]*n
a=0
i=0
while True:
    if B[a]!=-1:
        j=B[a]
        break
    i+=1
    B[a]+=i
    a=A[a]
if k<i:
    print(B.index(k)+1)
else:
    k=(k-j)%(i-j)+j
    print(B.index(k)+1)


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

int main() {
    ll i;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        if(s[i]=='9'){
            s[i]='1';
        }
        else{
            s[i]='9';
        }
    }
    cout<<s;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){


    long long int a,b,c,d,e,f,g,i,j;
    string x,y,z;
    vector<int> v;
    vector<int> v1;
   cin>>x;
   if(x[2]==x[3] && x[4]==x[5]){
    cout<<"Yes"<<endl;
   }
   else cout<<"No"<<endl;
    
    

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,sum1=0,sum2=0;
cin>>N;
vector<int>a(N),s(N);
for(int i=0;i<N;i++){
    cin>>a[i];
}
for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
        if(j<=i)sum1+=a[j-1];
        else sum2+=a[j-1];
    }
    s[i-1]=abs(sum1-sum2);
    sum1=0;
    sum2=0;
}
sort(s.begin(),s.end());
cout<<s[0];
return 0;
}


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

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

    ll count = 0;

    for(ll i = 0; i < S.size()-1; i++)
    {
        if(S[i] != S[i+1])count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
vector<vector<ll>> memo;
int main()
{
    int n, m;
    cin >> n >> m;
    const int h = n;
    vector<int> k_(m);
    vector<int> p_(m);
    memo.resize(m);
    rep(i, m)
    {
        cin >> k_[i];
        memo[i].resize(k_[i]);
        rep(j, k_[i])
        {
            int g = 0;
            cin >> g;
            memo[i][j] = g - 1;
        }
    }
    rep(i, m)
    {
        cin >> p_[i];
    }
    int count = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        int flag = 0;
        //0000 00001 0010 0011
        bitset<10> s(i); //これがビット列になっている。index0が右端でint型

        //考えるのはmemoの値とp_の値の関係のみ
        for (int r = 0; r < m; r++)
        {
            int q = 0;
            for (int x : memo[r])
            {
                q += s[x];
            }
            // cout << r << " " << s << " " << q << endl;
            if (q % 2 != p_[r])
            {
                flag += 1;

                break;
            }
        }
        if (flag == 0)
        {
            count += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for(int i=0; i<n; i++) {
            int[] it = new int[3];
            it[0] = scanner.nextInt();
            it[1] = scanner.nextInt();
            it[2] = scanner.nextInt();
            Arrays.sort(it);
            if(it[0]*it[0] + it[1]*it[1] == it[2]*it[2]) {
                System.out.println("YES");
            }else {
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 34436
#include <bits/stdc++.h>
#define f                           first
#define s                           second
#define task                        "test"
#define fi			                freopen(task".inp", "r", stdin)
#define fo			                freopen(task".out", "w", stdout)
#define reset(a, b)                 memset(a, b, sizeof(a))
#define MAX(a, b)                   a = max(a, b)
#define MIN(a, b)                   a = min(a, b)

using namespace std;

typedef long long                   LL;
typedef pair<int,int>               II;

const LL mod = 1e9 + 7;
const LL N   = 1e5 + 5;

/* ------------- ------------- ------------- ------------- ------------- ------------- ------------- */
string k;
long long dp[10005][105][2];
int d;

long long calc(int idx, int sum, bool t)
{
    if (idx == k.size())
        return (!sum) ? 1 : 0;
    if (dp[idx][sum][t] != -1)
        return dp[idx][sum][t];
    int m = (t) ? (k[idx] - 48) : 9;
    LL res = 0;
    for (int i = 0; i <= m; i++)
    {
        bool nt = (i == (k[idx] - 48)) ? t : 0;
        res += calc(idx + 1, (sum + i) % d, nt);
        res %= mod;
    }
    return dp[idx][sum][t] = res;
}

LL f() {
	LL v = 0;
	for (int i = 0; i < k.size(); i++)
		for (int j = 1; j <= (i ? 9 : k[0] - '0'); j++)
			v =(v + calc(i + 1, j % d, (i ? 0 : j == k[0] - '0'))) % mod;
	return v;
}

void solve()
{
    cin >> k >> d;
    reset(dp, -1);
    cout << f();
}

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0); cout.tie(0);
//    fi;
//    fo;
    solve();
    return 0;
}


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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }

}

Measured memory_bytes: 3636
import math
n, m = map(int, input().split())
div = 10**9 + 7

if abs(n-m)>1:
    print(0)
    exit()
elif n == m:
    ans1 = math.factorial(n)
    ans2 = math.factorial(m)
    ans = 2 * ans1 * ans2 
else:
    ma = max(n,m)
    mi = min(n,m)
    ans1 = math.factorial(ma)
    ans2 = math.factorial(mi)
    ans = ans2*ans1

print(ans % div)

    
    

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define loop(i,a,b) for(int i=a; i<b; i++)
#define INF 10000000000099ll
#define mod 1000000007
#define prDouble(x) cout<<fixed<<setprecision(10)<< x
double dp[3001][3001];

double solve(vector<double>& arr, int i, int x)
{
    if(x==0)
        return 1;
    if(i==0)
        return 0;
    if(dp[i][x] > -0.9) return dp[i][x];
    return dp[i][x]= arr[i]*solve(arr, i-1, x-1)+ (1-arr[i])*solve(arr, i-1, x);
}
int main()
{
    FASTIO;
    int n;
    cin>>n;
    vector<double> arr(n+1);
    memset(dp, -1, sizeof dp);
    loop(i, 1, n+1)
        cin>>arr[i];
    prDouble(solve(arr, n, (n+1)/2));
    return 0;
}



Measured memory_bytes: 74396
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int X,Y,Z;
  cin >> X >> Y >> Z;
  X -= Z;
  cout << X/(Y+Z) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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 x,n; cin>>x>>n;
    vector<int> v(110,0);
    rep(i,0,n){
        int x; cin>>x;
        v[x]=1;
    }
    int ans=0;
    int abss=10000;
    rep(i,0,110){
        if(v[i]==1) continue;
        if(abs(x-i)<abss){
            ans=i;
            abss=abs(x-i);
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int a[n],b[n],c[m],d[m];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0;i<m;i++){
    cin >> c[i] >> d[i];
  }
  for(int i=0;i<n;i++){
    int ans=1;
    int k=abs(c[0]-a[i])+abs(d[0]-b[i]);
    for(int j=1;j<m;j++){
      if(k>abs(c[j]-a[i])+abs(d[j]-b[i])){
        ans=j+1;
        k=abs(c[j]-a[i])+abs(d[j]-b[i]);
      }
    }
    cout << ans << endl;
  }
}
    

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;
vector<int>G[234];
LL dist[234];
vector<pair<int, int>>ed;
const long long INF = 123456789012345;
using P = pair<long long, int>;
void dijkstra(vector<int>graph_[], long long dist[], int n_, int s_) {
	priority_queue<P, vector<P>, greater<P>>que;
	que.push({ 0,s_ });
	fill(dist, dist + n_, INF);
	dist[s_] = 0ll;
	while (!que.empty()) {
		auto q = que.top();
		que.pop();
		long long thd = q.first;
		int thv = q.second;
		if (thd > dist[thv])
			continue;
		for (auto ed : graph_[thv]) {
			if (dist[ed] > 1 + thd) {
				dist[ed] = 1 + thd;
				que.push({ dist[ed],ed });
			}
		}
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		string S;
		cin >> S;
		for (int j = 0; j < N; ++j) {
			if (S[j] == '1') {
				G[i].push_back(j);
				ed.push_back({ i,j });
			}
		}
	}
	dijkstra(G, dist, N, 0);
	for (auto p : ed) {
		if (dist[p.first] % 2 == dist[p.second] % 2) {
			cout << -1 << endl;
			return 0;
		}
	}
	LL ans = -1;
	for (int i = 0; i < N; ++i) {
		dijkstra(G, dist, N, i);
		for (int j = 0; j < N; ++j) {
			ans = max(ans, dist[j]);
		}
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 980
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

subGames = [[] for _ in range(k)]

pattern = {'r': p, 's': r, 'p': s, '': 0}
win = {'r': 'p', 's': 'r', 'p': 's'}

subPts = [0 for _ in range(k)]
for i, hand in enumerate(t):
    subGame = subGames[i % k]
    winPt = pattern[hand]
    winHand = win[hand]
    if subGame and win[hand] == subGame[-1]:
        winPt = 0
        winHand = t[i+k] if i+k < n else hand

    subGame.append(winHand)
    subPts[i % k] += winPt

ans = sum(subPts)

print(ans)


Measured memory_bytes: 17012
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


//       xを    iで割ったあまり
ll dp[100010][210];


vector<ll> s(210);
ll n, x;

ll solv(ll x, ll i) {

  // cerr << x << " x : i" << i << endl;
  if (i == 1) //xを一番小さい数で割ったあまり
    return x % s[i - 1];

  if (dp[x][i] != -1)  return dp[x][i]; //xをiで割ったあまりがすでにある時は戻る


  dp[x][i] = (solv(x % s[i - 1], i - 1) % mod  + (solv(x, i - 1) * (i - 1)) % mod) % mod; //一つ小さい数で求める

  return dp[x][i];
}



int main() {

  cin >> n >> x ;

  s = vector<ll>(n, -1);

  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }

  for (int i = 0; i < 100010; i++) {
    for (int j = 0; j < 210; j++) {
      dp[i][j] = -1;
    }
  }
  sort(s.begin(), s.end());



  ll ans = solv(x, n);


  cout << ans << endl;

}




















Measured memory_bytes: 164352
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

const int INF = 1<<28;
const double EPS = 1e-9;
const int MOD = 1000000007;

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 (a-EPS>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}


int n;

double check(vector<int> &l, int S, int A, int C){
	vector<int> oc(256);
	REP(i, l.size()){
		S = (A*S+C)&255;
		oc[(l[i]+S)&255] ++;
	}
	double res = 0;
	REP(i, 256){
		if(!oc[i]) continue;
		double x = oc[i]/(double)l.size();
		
		res -= x*log(x);
	}
	return res;
}

main(){
	while(cin >> n, n){
		vector<int> l(n);
		REP(i, n) cin >> l[i];
		int ans = 0;
		double m = 1e9;
		REP(i, 1<<12) if(chmin(m, check(l, i>>8, (i>>4)&15, i&15))) ans = i;
		printf("%d %d %d\n", ans>>8, (ans>>4)&15, ans&15);
	}
	return 0;
}

Measured memory_bytes: 1216
#import collections
n=int(input())
#a,b=map(int,input().split())
#a=list(map(int,input().split()))
#n=int(input())
#s=input()
#mod=10**9+7

k=int(input())
ans=1
for i in range(n):
  if ans>k:
    ans+=k
  else:
    ans=2*ans
print(ans)

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

int main() {
  int A,B;
  int sum = 0;
  cin >> A >> B;
  for (int i=0; i < B-A+1; i++){
    int N = A+i;
    if(N/10000 == N%10 && (N%10000)/1000 == (N%100)/10){
      sum++;
    }
  }
  cout << sum <<endl;
 }
 


Measured memory_bytes: 256
//参加気分でさ

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, K;
	cin >> N >> K;
	
	int kotae = 0;
	rep(i, N) {
		int H;
		cin >> H;

		if (H >= K) kotae++;
	}

	cout << kotae << endl;


	Would you please return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline


class SegmentTree:
    def __init__(self, N, func, I):
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in range(self.sz-1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        if b == self.N:
            b = self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = map(int, readline().split())
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()


Measured memory_bytes: 60528
n, a, c = int(input()), list(map(int, input().split())), 0

for i in range(n):
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
    if minj != i:
        a[i], a[minj], c = a[minj], a[i], c + 1

print(*a)
print(c)

Measured memory_bytes: 7692
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define b begin
#define e end
using namespace std;
int main()
{
    ll n;
    cin>>n;
    if(n%1000==0)
    cout<<"0\n";
    else
    cout<<(1000-(n%1000));
}

Measured memory_bytes: 3628
N = gets.chomp.to_i
arr = readlines.map{|n| n.chomp.to_i}
color = []
# p N,arr

arr.each do |n|
    index = color.bsearch_index {|x| x < n}
    if index.nil?
        color << n
    else
        color[index] = n
    end
    # p color
end
puts color.size


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

 using namespace std;

 int main() {
   int N, D;
   cin >> N >> D;

   if (N % (2 * D + 1) == 0) cout << N / (2 * D + 1) << endl;
   else cout << N / (2 * D + 1) + 1 << endl;
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,M;
	cin >> N >> M;
	vector<int> ans(N+1,0);
	int a,b;
	for(int i=0;i<M;++i){
		cin >>a>>b;
		ans[a]++;
		ans[b]++;
	}
	for(int i=1;i<=N;++i){
		cout << ans[i] << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] S = new String[N];
        int[] c = new int[4];
        for (int i = 0; i < S.length; i++) {
            S[i] = sc.next();
            if (S[i].equals("AC")) {
                c[0]++;
            } else if (S[i].equals("WA")) {
                c[1]++;
            } else if (S[i].equals("TLE")) {
                c[2]++;
            } else {
                c[3]++;
            }
        }

        System.out.println("AC x " + c[0]);
        System.out.println("WA x " + c[1]);
        System.out.println("TLE x " + c[2]);
        System.out.println("RE x " + c[3]);

        sc.close();
    }
}

Measured memory_bytes: 64440
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i = x; i < (int)(n); i++)
#define rep_ll(i,x,n) for(ll i = x; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    ll n;
    cin >> n;
    //map<int, int> mp;
    vector<ll> aa(n+1, 0);
    ll n_ = sqrt(n);
    rep(i, 1, n_){
        ll i_=i*i;
        rep(j, 1, n_){
            ll j_=j*j;
            ll ij = i*j;
            rep(k, 1, n_){
                ll k_=k*k;
                ll ik=i*k;
                ll jk=j*k;
                ll ans=i_+j_+k_+ij+ik+jk;
                if(ans>n) continue;
                aa[ans]++;
            }
        }
    }
    rep(ii, 1, n+1) cout << aa[ii] << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
  ll n, T;
  cin >> n >> T;

  vector<ll> t(n);
  for (int i = 0; i < n; i++) cin >> t[i];

  ll time(0);
  for (int i = 0; i < n - 1; i++) {
    ll diff = t[i + 1] - t[i];
    if (diff > T)
      time += T;
    else
      time += diff;
  }
  time += T;

  cout << time << endl;
}


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

int main() {
  int a,b,c,x,cnt=0;
  cin >> a >> b >> c >> x;
  for(int i=0 ;i<=a ;i++){
    for(int j=0 ;j<=b ;j++){
      for(int k=0 ;k<=c ;k++){
        if(500*i + 100*j + 50*k == x)
        cnt ++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] xn = Array.ConvertAll(System.Console.ReadLine().Split(' '), int.Parse);
            if(xn[1]==0)
            {
                Console.WriteLine(xn[0]);
                return;
            }
            int[] pn = Array.ConvertAll(System.Console.ReadLine().Split(' '), int.Parse);
            int i = 0;
            while (true)
            {
               if(!pn.Contains(xn[0]-i))
                {
                    Console.WriteLine(xn[0] - i);
                    return;
                }
                else if(!pn.Contains(xn[0] + i))
                {
                    Console.WriteLine(xn[0] + i);
                    return;
                }

                ++i;
            }
        }
    }
}


Measured memory_bytes: 27848
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int x1; int y1;
	while(~scanf("%d%d", &x1, &y1)) {
		int x2; int y2;
		scanf("%d%d", &x2, &y2);
		int x3; int y3;
		scanf("%d%d", &x3, &y3);
		double a = hypot(x1 - x2, y1 - y2);
		double b = hypot(x2 - x3, y2 - y3);
		double c = hypot(x3 - x1, y3 - y1);
		double s = (a + b + c) / 2;
		double r = sqrt((s - a) * (s - b) * (s - c) / s);
		double lo = 0, up = r;
		rep(k, 64) {
			double x = (lo + up) / 2;
			if((1 - x / r) * max({ a, b, c }) >= 2 * x)
				lo = x;
			else
				up = x;
		}
		printf("%.10f\n", (lo + up) / 2);
	}
	return 0;
}


Measured memory_bytes: 256
s = input()
t = input()

ans = 100000

n = len(s)
m = len(t)

for i in range(n - m + 1):
    temp = s[i:i + m]
    count = 0
    for a, b in zip(temp, t):
        if a != b:
            count += 1
    ans = min(count, ans)

print(ans)


Measured memory_bytes: 9040
#include<bits/stdc++.h>
#define ll long long
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
using namespace std;
const int maxn = 2e3 + 50;
ll num[maxn];
ll s1[maxn], s2[maxn];
ll x[maxn];
int a[maxn];
int n;
int main()
{
    cin>>n;
    for(int i = 0; i < n; ++i){
         cin>>a[i];
         num[a[i]]++;
         for(int j = 0; j < i; ++j){
            int c = a[i] + a[j];
            x[c]++;
         }
    }
    for(int i = 1; i < maxn; ++i) s1[i] = s1[i-1] + num[i], s2[i] = s2[i-1] + x[i];
    ll ans = 0;
    sort(a, a+n);
    for(int i = 0; i < n; ++i){
        ll t = s2[maxn-1] - s2[a[i]];
        t -= n-1;
        t -= i * (n-i-1);
        t -= (n-i-1)*(n-i-2)/2;
        ans += t;
    }cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int high[3]={0};
	int mount;
	for(int i=1;i<=10;i++){
		cin>>mount;
		if(mount>high[0]){high[2]=high[1];high[1]=high[0];high[0]=mount;}
		else if(mount>high[1]){high[2]=high[1];high[1]=mount;}
		else if(mount>high[2]){high[2]=mount;}
	}
	cout<<high[0]<<endl<<high[1]<<endl<<high[2]<<endl;
}

Measured memory_bytes: 0
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	int n;
	cin >> n;
	ll mx1 = -1e18, mn1 = 1e18, mx2 = -1e18, mn2 = 1e18;
	for (int i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;
		mx1 = max(mx1, x + y);
		mn1 = min(mn1, x + y);
		mx2 = max(mx2, x - y);
		mn2 = min(mn2, x - y);
	}
	cout << max(mx1 - mn1, mx2 - mn2) << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll num = 1, ans = 0;
	ll h;
	cin >> h;
	while(h > 1){
		ans+=num;
		num*=2;	
		h/=2;
	}
	cout << ans + num << '\n';
}


Measured memory_bytes: 256