akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
typedef long long ll;
const int N = 1e5 + 5;
const int Mod = 1e9 + 7;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}

int n, vis[N], flag, que[N], qn, deg[N], count[N];
int Que[N], Deg[N], Qn, g[N], a[N], cnt, ans;
int tot, first[N], next[N << 1], end[N << 1];
void AddEdge(int x, int y) {
	next[++tot] = first[x], first[x] = tot, end[tot] = y;
	next[++tot] = first[y], first[y] = tot, end[tot] = x;
}
inline bool check(int x) {
	vis[x] = true, que[qn = 1] = x;
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql)
		for (int k = first[u], v; v = end[k], k; k = next[k])
			if (!vis[v]) vis[v] = true, que[++qn] = v;
		
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql) 
		for (int k = first[u], v; v = end[k], k; k = next[k]) deg[v] += (k & 1);
	
	bool flag = true;
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql) flag &= deg[u];
		
	if (flag) {
		++count[qn];
		return true;
	}
	
	//找环
	Qn = 0;
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql)
		if (!(Deg[u] = deg[u])) Que[++Qn] = u;
		else 
			if (deg[u] > 2) return false;
	
	for (int Ql = 1, u; u = Que[Ql], Ql <= Qn; ++Ql)
		for (int k = first[u], v; v = end[k], k; k = next[k])
			if (k & 1) if (!(--Deg[v])) Que[++Qn] = v;
		
	//没有分支
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql)
		if (!Deg[u] && deg[u] > 1) return false;
	
	Qn = 0;
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql) if (!deg[u]) Que[++Qn] = u, g[u] = 0;
	for (int Ql = 1, u; u = Que[Ql], Ql <= Qn; ++Ql) 
		for (int k = first[u], v; v = end[k], k; k = next[k])
			if (k & 1) {
				if (!(--deg[v])) Que[++Qn] = v;
				g[v] = g[u] + 1;
			}
			
	int y = 0;
	for (int ql = 1, u; y = u = que[ql], ql <= qn; ++ql) if (deg[u]) break; 
	
	cnt = 0;
	a[++cnt] = y;
	while (true) {
		int u = a[cnt];
		for (int k = first[u], v; v = end[k], k; k = next[k]) 
			if (k & 1) if (deg[v]) {
				a[++cnt] = v; break;
			}
			
		if (a[cnt] == a[1]) {
			--cnt; break;
		}
	}
	
	int last = 0;
	for (int i = 1; i <= cnt; ++i) if (g[a[i]]) last = i;
	for (int i = 1; i <= cnt; ++i) 
		if (g[a[i]]) {
			int l1 = g[a[i]], l2 = last >= i ? cnt - last + i : i - last;
			if (l1 < l2) ans = ans * 2 % Mod;
			if (l1 > l2) ans = 0;
			last = i;
		}
	
	return true;
}
int main() {
	n = Get();
	for (int i = 1; i <= n; ++i) AddEdge(i, Get()); 
	
	ans = 1, flag = true;
	for (int i = 1; i <= n; ++i) 
		if (!vis[i]) flag &= check(i);
	
	if (!flag) {
		puts("0");
		return 0;
	}
	
	for (int len = 1; len <= n; ++len)
		if (count[len]) {
			g[0] = 1;
			for (int i = 1; i <= count[len]; ++i) {
				g[i] = g[i - 1];
				if (len > 1 && (len & 1)) (g[i] += g[i - 1]) %= Mod;
				if (i > 1) (g[i] += (ll)(i - 1) * len % Mod * g[i - 2] % Mod) %= Mod;
			}
			ans = (ll)ans * g[count[len]] % Mod;
		}
		
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5248
def warshal_floyd(d):
  for k in range(10):
    for i in range(10):
      for j in range(10):
        d[i][j] = min(d[i][j], d[i][k]+d[k][j])
  return d

h, w = map(int, input().split())
d = [[float('inf') for i in range(10)] for j in range(10)]
for i in range(10):
  l = list(map(int, input().split()))
  for j in range(10):
    d[i][j] = l[j]
d = warshal_floyd(d)
#print(d)

ans = 0
for i in range(h):
  l = list(map(int, input().split()))
  for j in range(w):
    if l[j] != -1:
      ans += d[l[j]][1]
print(ans)
    

Measured memory_bytes: 40556
type Op = String
type Formula = (Int,Op,Int)

toFormula :: [String]->Formula
toFormula [x,y,z] = (read x::Int, y ::Op, read z::Int)

prepare :: String->[Formula]
prepare=map toFormula.map words.lines

putMaybe :: Maybe Int->IO ()
putMaybe (Just x) = putStrLn $ show x

calc :: Formula->Maybe Int
calc xs = case xs of
	(x,"+",z)->Just $ x+z
	(x,"-",z)->Just $ x-z
	(x,"*",z)->Just $ x*z
	(x,"/",z)->Just $ x`div`z
	(_,"?",_)->Nothing

main=getContents>>=mapM_ putMaybe.takeWhile (/=Nothing).map calc.prepare

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
const int N = 610, INF = 0x3f3f3f3f;
int p[N],n,cnt,st,en,x[N];
struct edge {
  int la,b,cap;
} con[N * N * 2];
int tot=1,fir[N];
void add(int from,int to,int capc) {
  con[++tot] = (edge) {fir[from],to,capc};
  fir[from] = tot;
  con[++tot] = (edge) {fir[to],from,0};
  fir[to] = tot;
}
int cur[N], dis[N];
int dfs(int pos,int imp) {
  if (pos == en || (!imp)) return imp;
  int expo = 0, tmp;
  for (int &i = cur[pos] ; i ; i = con[i].la) {
    if (dis[con[i].b] == dis[pos] + 1) {
      tmp = dfs(con[i].b,min(imp,con[i].cap));
      con[i].cap -= tmp;
      con[i^1].cap += tmp;
      expo += tmp;
      imp -= tmp;
      if (!imp) break;
    }
  }
  return expo;
}
bool bfs() {
  static queue<int> q;
  while (!q.empty()) q.pop();
  memset(dis,0,sizeof dis);
  for (int i = 1 ; i <= n ; ++ i)
    cur[i] = fir[i];
  dis[st] = 1;
  q.push(st);
  for (int pos ; !q.empty() ; q.pop()) {
    pos = q.front();
    for (int i = fir[pos] ; i ; i = con[i].la) {
      if (con[i].cap && (!dis[con[i].b])) {
	dis[con[i].b] = dis[pos] + 1;
	q.push(con[i].b);
      }
    }
  }
  if (!dis[en]) return 0;
  return 1;
}
const int MAX = 10000010;
int isp[MAX + 10], pri[MAX / 10], pcnt, num[2];
set<int> prime;
void prework() {
  for (int i = 2 ; i <= MAX ; ++ i) {
    if (!isp[i]) pri[++pcnt] = i;
    for (int j = 1 ; j <= pcnt && pri[j] * i <= MAX ; ++ j) {
      isp[pri[j] * i] = 1;
      if (i % pri[j] == 0) break;
    }
  }
  for (int i = 2 ; i <= pcnt ; ++ i)
    prime.insert(pri[i]);
}
int main() {
  prework();
  scanf("%d",&n);
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%d",&x[i]);
    if (x[i] == 1 || x[i] != x[i-1] + 1)
      p[++cnt] = x[i];
    if (i > 1 && x[i] != x[i-1] + 1)
      p[++cnt] = x[i-1] + 1;
  }
  p[++cnt] = x[n] + 1;
  n = cnt;
  st = ++n;
  en = ++n;
  for (int i = 1 ; i <= cnt ; ++ i) {
    ++ num[p[i]&1];
    if (p[i]&1) {
      add(st,i,1);
      for (int j = 1 ; j <= cnt ; ++ j) {
	int d = abs(p[i] - p[j]);
	if (prime.count(d))
	  add(i,j,1);
      }
    } else add(i,en,1);
  }
  int ans = 0;
  while (bfs())
    ans += dfs(st,INF);
  printf("%d\n",ans + 2 * ((num[0] - ans) / 2 + (num[1] - ans) / 2) + ((num[1] - ans)&1) * 3);
  return 0;
}


Measured memory_bytes: 76544
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n;
  cin>>n;
  vector<ll> x(n),y(n);
  int f[2]={};
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    f[(x[i]+y[i])%2]=1;
  }
  if(f[0]&&f[1]){
    cout<<"-1"<<endl;
    return 0;
  }

  cout<<34<<endl;
  ll d[35];
  d[0]=1;
  for(int i=0;i<34;i++){
    if(i)cout<<" ";
    if(f[0]&&i==33)d[i]--;
    cout<<d[i];
    d[i+1]=d[i]*2;
  }
  cout<<endl;

  for(int i=0;i<n;i++){
    ll u=x[i]+y[i];
    ll v=x[i]-y[i];
    //    cout<<u<<" "<<v<<endl;
    int us[34],vs[34];
    if(u>0){
	 fill_n(us,34,0);
	 us[33]=1;
    }else{
	 fill_n(us,34,1);
	 us[33]=0; 
    }

    if(v>0){
	 fill_n(vs,34,0);
	 vs[33]=1;
    }else{
	 fill_n(vs,34,1);
	 vs[33]=0; 
    }
    u=abs(u);
    v=abs(v);
    u/=2;
    v/=2;
    
    int cnt=0;
    while(u||v){
	 if(u%2)us[cnt]=(us[cnt]+1)%2;
	 if(v%2)vs[cnt]=(vs[cnt]+1)%2;
	 u/=2;
	 v/=2;
	 cnt++;
    }
    
    for(int i=0;i<34;i++){
	 //	 cout<<us[i]<<" "<<vs[i];
	 if(us[i]==0&&vs[i]==0)cout<<"L";
	 if(us[i]==1&&vs[i]==1)cout<<"R";
	 if(us[i]==0&&vs[i]==1)cout<<"D";
	 if(us[i]==1&&vs[i]==0)cout<<"U";
	 //	 cout<<endl;
    }
    cout<<endl;
    
  }
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  function<void(string, int)> dfs = [&](string s, int m) {
    if ((int)s.size() == N) {
      cout << s << '\n';
      return;
    }
    for (int i = 0; i < m + 1; i++) {
      dfs(s + (char)('a' + i), i == m ? m + 1 : m);
    }
  };
  dfs("", 0);
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int conv(int a, int l){
    VI p;
    REP(i,l){
        p.push_back(a % 10);
        a /= 10;
    }
    sort(p.begin(),p.end());
    int mi = 0, ma = 0;
    REP(i,l){
        mi *= 10;
        ma *= 10;
        mi += p[i];
        ma += p[l-1-i];
    }
    return ma - mi;
}

int main() {
    int a, l;
    while (cin >> a >> l && l){
        map<int, int> mp;
        mp[a] = 1;
        REP(i,20){
            a = conv(a, l);
            if (mp[a] > 0){
                printf("%d %d %d\n", mp[a]-1, a, i+2-mp[a]);
                break;
            }
            mp[a] = i+2;
        }
    }
    return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
int main(void)
{
  int a,b,i=0,sum=0;
  
  scanf("%d %d",&a,&b);
  
  for(i=1;i<=2;i++){
  if(a>=b){
    sum=sum+a;
    a--;
  }
  else{
    sum=sum+b;
    b--;
  }
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N,ans=0;
    string S;
    cin>>N>>S;
    REP(i,N-2){
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<memory.h>
using namespace std;
int main()
{
	int L[100001], R[100001];
	int N, M;
	while (cin >> N >> M)
	{
		int Lt, Rt;
		memset(L, 0, sizeof(L));	memset(R, 0, sizeof(R));
		for (int i = 1; i <= M; i++)
		{
			cin >> Lt >> Rt;
			L[Lt]++;
			R[Rt]++;
		}
		int it = 0,cnt=0;
		for (int i = 1; i <= N; i++)
		{
			it += L[i];
			cnt += (it == M);
			it -= R[i];
		}
		cout << cnt<<'\n';
	}
}




Measured memory_bytes: 1024
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define MAX 100009
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int fac[MAX], inv[MAX], finv[MAX], p2[MAX],p3[MAX];

void pre(){
        p2[0]=1,p3[0]=1;
        for(int i=1;i<MAX;i++){
                p2[i] = p2[i-1]*2%mod;
                p3[i] = p3[i-1]*3%mod;
        }
	inv[1]=1;
	for (int i = 2; i <MAX ; i++)
	{
		inv[i]=inv[mod%i]*(mod-mod/i)%mod;
	}
	fac[0]=finv[0]=1;
	for (int i = 1; i < MAX; ++i)
	{
		fac[i]=fac[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ncr(int n, int r){
	if(r<0||r>n)return 0;
	return fac[n]*finv[r]%mod*finv[n-r]%mod;
}
int modpow(int x, int n, int m) {
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}
string s;
int ans = 0;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

        pre();
        cin >> s;
        int cnt = 0;
        reverse(all(s));
        int n = s.size();
        for(int i=0;i<n;i++){
                if( s[i]=='1' )cnt++;
        }
        ans = p2[cnt];
        int c1 = 0;
        for(int i=0;i<n;i++){
                if(s[i]=='1'){
                   c1++;
                   int cur = p2[cnt-c1]*( p3[i] )%mod%mod%mod;
                   //cur = (cur - 1 + mod)%mod;
                   //cout << cur << endl;
                   ans = (ans+cur)%mod;
                }
        }
        cout << ans << endl;


return 0;
}
///....


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    vi p(n);
    VIN(p);
    sort(ALL(p));
    ll ans = accumulate(p.begin(), p.begin()+k, 0LL);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int turn = 1;
  while(a > 0 && c > 0){
    if(turn % 2 == 1){
      c -= b;
    }
    else{
      a -= d;
    }
    turn++;
  }
  if(a > 0){
    cout << "Yes" << endl; 
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
def select(list_, selected_set):
    while True:
        s = list_.pop()
        if not s[0] in selected_set:
            return s


n = int(input())
ab = []

for i in range(n):
    ai, bi = map(int, input().split())
    ab.append((i, ai, bi))

flag = True
list_a = sorted(ab, key=lambda x: (x[1] + x[2]))
list_b = sorted(ab, key=lambda x: (x[2] + x[1]))
a = 0
b = 0
selected = set()
for _ in range(n):
    s = None
    if flag:
        s = select(list_a, selected)
        a += s[1]
    else:
        s = select(list_b, selected)
        b += s[2]
    selected.add(s[0])

    flag = not(flag)

print(a - b)


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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int a=1;a<N;a++){
    for(int b=1;b<N;b++){
      if(a*b>=N){
        break;
      }
      ans++;
    }
  }
  printl(ans);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[200000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int t;
    cin >> n >> t;
    ll sol = 0;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    for (int i = 1; i < n; ++i)
        sol += min(a[i] - a[i - 1], t);
    cout << sol + t;
}


Measured memory_bytes: 1024
n = int(input())
s = input()
ans = 0
for i in range(1, n):
    tmp = 0
    dic = {}
    sl = list(set(s[:i]))
    sr = list(set(s[i:]))
    # print(sl, sr)

    for c in sl:
        if c not in dic:
            dic[c] = 0

    for c in sr:
        if c in dic:
            tmp += 1
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    long long y = 0;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        y ^= a[i];
    }
    for(int i=0; i<n; ++i)
        a[i] &= ~y;

    long long x = 0;
    for(int i=62; i>=0; --i){
        long long tmp = 0;
        for(int j=0; j<n; ++j){
            if(a[j] & (1LL << i)){
                tmp = a[j];
                break;
            }
        }

        if(!(x & (1LL << i)))
            x ^= tmp;
        for(int j=0; j<n; ++j){
            if(a[j] & (1LL << i))
                a[j] ^= tmp;
        }
    }

    y ^= x;
    long long ans = x + y;
    cout << ans << endl;

    return 0;
}


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

int main(){
    int n, m, i, a, b;
    cin >> n >> m;
    int c[n+1] = {};
    for(i=0; i<m; i++){
        cin >> a >> b;
        c[a]++;
        c[b]++;
    }
    for(i=1; i<=n; i++){
        cout << c[i] << '\n';
    }
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long UL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)

int main()
{
    int N, T;
    LL ans = 0;
    cin >> N >> T;
    vector<int> t(N);
    REP(i, N)
    {
        cin >> t[i];
    }

    REP(i, N)
    {
        if (i + 1 < N)
        {
            if (t[i + 1] - t[i] >= T) ans += T;
            else ans += t[i + 1] - t[i];
        }
        else
        {
            ans += T;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3 + 7;
const int MOD = 1e9 + 7;

int cnt[N];

int main()
{
	int n;
	cin >> n;
	
	for (int i=1; i<=n; i++)
	{
		int x = i;
		for (int i=2; i<=x; i++)
			while (x % i == 0)
				cnt[i]++, x /= i;
	}
	ll res = 1;
	for (int i=1; i<=n; i++)
		res = 1LL * res * (cnt[i] + 1) % MOD;
	cout << res << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef pair<ll,pi> pii;
typedef vector<pi> vpi;
typedef set<ll> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e18;
ll MOD = 1e9+7;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()

int L,N;
vi direct;

int main(){
  cin>>L;
  for (int i=1;i<=20;++i){
    if (!L)break;
    ++N;
    if (L % 2 == 1){
      --L;
      direct.pb(i);
    }
    L /= 2;
  }
  direct.pop_back();
  cout<<N<<' '<<SZ(direct)+2*(N-1)<<'\n';
  for (int i=1;i<N;++i){
    cout<<i<<' '<<i+1<<" 0\n";
    cout<<i<<' '<<i+1<<' '<<(1<<(i-1))<<'\n';
  }
  reverse(ALL(direct));
  int T = (1<<(N-1));
  for (auto i : direct){
    cout<<i<<' '<<N<<' '<<T<<'\n';
    T += (1<<(i-1));
  }
}

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

int main(void){
    int w, h, n;
    cin >> w >> h >> n;

    int p = 0;
    int q = w;
    int r = 0;
    int s = h;

    for(int i = 0; i < n; i++){
        int x, y, a;
        cin >> x >> y >> a;

        if(a == 1 && p < x){
            p = x;
        }
        if(a == 2 && x < q){
            q = x;
        }
        if(a == 3 && r < y){
            r = y;
        }
        if(a == 4 && y < s){
            s = y;
        }
    }

    if(p >= q || r >= s){
        cout << 0 << endl;
    }
    else{
        int ans = (q - p) * (s - r);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
     
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
     
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll, ll>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main () {
  int n, y;
  cin >> n >> y;
  int i, j;
  for (i = 0; i <= n; i++) {
    for (j = 0; i + j <= n; j++) {
      int k = n - i - j;
      if (i * 10000 + j * 5000 + k * 1000 == y) {
	cout << i << " " << j << " " << k << endl;
	return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, M, a, b;
    cin >> N >> M;
    int cnt[51] = {};
    REP(i, M) {
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    FOR(i, 1, N + 1, 1) {
        cout << cnt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        var s = sc.Next().ToCharArray();
        Array.Sort(s);
        if (new string(s) == "abc")
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13396
/*
    Created by Tejas Chaudhari
    link:
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef double lf;
typedef bool bl;
typedef vector<ll> vl;
typedef vector<lf> vd;
typedef vector<bl> vb;
typedef string st;
typedef pair<ll,ll> pll;

#define INF (LONG_LONG_MAX / 4)
#define SORT(x) sort(x.begin(), x.end())
#define Mod % 1000000007

void re_curse() {
    ll a, b, k;
    cin>>a>>b>>k;
    if (k <= a) {
        cout<<a-k<<" "<<b<<endl;
    } else if (k <= b+a) {
        cout<<"0 "<<b+a - k<<endl;
    } else {
        cout<<"0 0"<<endl;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    for (int i = 1; i <= t; ++i) {
        re_curse();
    }
    return 0;
}


Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();

		int sum = A + B;
		int diff = A - B;
		int prod = A * B;
		int max = sum;

		//和と差の比較
		if(max < diff) {
			max = diff;
		}

		//和と差のうち大きい数と積の比較
		if(max < prod) {
			max = prod;
		}

		System.out.println(max);
	}
}

Measured memory_bytes: 23764
N = int(input())
p = [int(i) for i in input().split()]

ans = 0

for i in range(N):
    if p[i] == i + 1:
        if i == 0:
            p[0] = p[1]
            p[1] = 1
            ans += 1
        elif i == N - 1:
            p[i], p[i-1] = p[i-1], p[i]
            ans += 1
        else:
            if p[i+1] == i + 2:
                p[i], p[i+1] = p[i+1], p[i]
            else:
                p[i], p[i-1] = p[i-1], p[i] 
            ans += 1


print(ans)                

Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0, ans = -1;
	for (int i = 0; i < n; i++) {
		string cmp1 = s.substr(0, i), cmp2 = s.substr(i, n - i);
		cnt = 0;
		for (int j = 0; j < 26; j++) {
			char Cmp = 'a' + j;
			if (cmp1.find(Cmp) != string::npos && cmp2.find(Cmp) != string::npos) {
				cnt++;
			}
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

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

#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;

    std::vector<int> points(N);

    REP(i, Q) {
        int a;
        cin >> a;
        points[a - 1]++;
    }

    int p = Q - K;
    REP(i, N) {
        if (points[i] > p) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}


/*
 * Local Variables:
 * compile-command: "CXXFLAGS='-std=c++14' make main"
 * End:
 */


Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

class Input
{
  public:
    int height;
    int width;
    Input(int a,int b);
};

Input::Input(int a, int b)
{
  height = a;
  width = b;
}

int main(int argc, char* argv[])
{
    int height,width;
    vector<Input> inputs;
    while(1)
    {
        cin >> height >> width;
        if(height==0 and width==0) break;
        inputs.push_back(Input(height,width));
    }
    for(auto input: inputs)
    {
        for(int i=0;i<input.height;i++)
        {
            if(i==0 or i==input.height - 1)
            {
                for(int j=0; j<input.width;j++)
                {
                    cout << '#';
                }
                cout << endl;
            }
            else
            {
                for(int j=0; j<input.width;j++)
                {
                    if(j==0 or j==input.width-1)
                    {
                        cout << '#';
                    }
                    else
                    {
                        cout << '.';
                    }
                }
                cout << endl;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

const int INF = 1e8;

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

	ll n = s.size();
	string a = s;
	string b = s;

	rep(i,n) {
		if (i % 2 == 0) {
			a[i] = '0';
			b[i] = '1';
		}
		else {
			a[i] = '1';
			b[i] = '0';
		}
	}
	int m = 0;
	int p = 0;
	int ans = 0;
	rep(i, n) {
		if (a[i] != s[i]) {
			m++;
		}
		if (b[i] != s[i]) {
			p++;
		}
	}
	ans = min(m, p);
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(a);in(b);
	if(a>9||b>9)printf("-1\n");
	else printf("%d\n",a*b);
	return 0;
}


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

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll solve(int n, int k) {
    priority_queue<pair<int,ll>> pq;
    pq.push(make_pair(0, -1LL));
    while (!pq.empty()) {
        auto a = pq.top(); pq.pop();
        if (a.first == n) return -a.second;
        pq.push(make_pair(a.first+1, a.second*2));
        pq.push(make_pair(a.first+1, a.second-k));
    }
}

int main() {
    int n; int k;
    cin >> n;
    cin >> k;
    cout << solve(n, k) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		long ans = 0;
		for (int i = 1; i <= N; i++) {
			long tot = N / i;
			ans += tot * (tot + 1) / 2 * i;
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 32784
#include <iostream>

int main() {
    long W, H, x, y;
    std::cin >> W >> H >> x >> y;

    char flag = '0';
    if (W == x * 2 && H == y * 2) {
        flag = '1';
    }

    std::cout << (W * H) / 2.0 << " " << flag << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c - '0';}


// TODO: write
int main() {
  #define int ll 
  int n,W;cin>>W>>n;
  vector<int> w(n),v(n);rep(i,n)cin>>w[i]>>v[i];
  vector<vector<int>> dp(n+10,vector<int>(W+10,INF));
  dp[0][0] = 0;
  rep(i,n){
    rep(j,W+1){
      chmin(dp[i+1][j],dp[i][j]);
      chmin(dp[i+1][j],dp[i+1][max(j-w[i],0ll)] + v[i]);
    }
  }
  print(dp[n][W]);
  return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int D;

vector<i64> P;
vector<i64> C;

i64 G;

int main(){
  cin >> D >> G;
  P.resize(D + 1);
  C.resize(D + 1);

  rep(i,1,D){
    cin >> P[i] >> C[i];
  }

  vector<int> idx;
  rep(i,1,D) idx.push_back(i);

  i64 ans = 1e18;

  do{
    i64 now = 0;
    i64 res = 0;
    for(int i : idx){
      int need = min(P[i],(G - now + i * 100 - 1) / (i * 100));
      res += need;
      now += need * i * 100 + C[i];
      if(now >= G) break;
    }
    ans = min(ans , res);
  }while(next_permutation(idx.begin(),idx.end()));

  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
int main()
{
    ll n, t, x, i, j ;
    cin >> n ;
    ll a[n];
    ll mini, maxi=0;
    for(i=0; i<n; i++)
        cin >> a[i];
    mini=a[0];
    for(i=0; i<n; i++)
    {
        if(mini>=a[i])
        {
            maxi+=(mini-a[i]);
        }
        else
            mini=a[i];
    }
    cout << maxi ;
    return 0;
}


Measured memory_bytes: 5196
#include <stdio.h>

int main(){

  int i, n, min, max;
  int a[10000];
  long long sum = 0;

  scanf("%d", &n);
  
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  min = a[0];
  max = a[0];
  sum += a[0];
  
  for(i = 1; i < n; i++){
    if(a[i] < min)
      min = a[i];
    if(a[i] > max)
      max = a[i];
    sum += a[i];
  }

  printf("%d %d %lld\n", min, max, sum);

  return 0;
}

Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vec b(101);
    rep(i,101){
        rep(j,n){
            b[i]+=(a[j]-i)*(a[j]-i);
        }
    }
    sort(all(b));
    cout<<b[0]<<endl;
    
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    string ans = "NO";
    for(int i=1;i<=b;i++){
        if((i*a)%b==c){
            ans ="YES";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
string S;
int dp[100010][13];

int calc(int x, int num) {
    if(x >= S.length()){
        if(num == 5) return dp[x][num] = 1;
         return dp[x][num] = 0;
    } 
    else if(dp[x][num] != -1) return dp[x][num];
    int k = S[x] - '0';
    if(S[x] != '?')  return dp[x][num] = calc(x + 1, ((num * 10) + k)% 13);
    int ret = 0;
    rep(i, 10) ret = (ret + calc(x + 1, (num * 10 + i) % 13)) % mod;
    return dp[x][num] = ret;
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    rep(i, 100010) rep(j, 13) dp[i][j] = -1;
    cout << calc(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 18512
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18+5
#define mod 1000000007
#define MAXN 100005
#define ll long long
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define tc(t) int t;cin>>t;while(t--)
#define copy copy_n
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define frr(i,a,b) for(long long i=a;i>=b;i--)
#define frn(i,a,b,n) for(long long i=a;i<=b;i=i+n)
#define gcd(x,y) __gcd(x,y)
#define ld long double
#define um unordered_map
#define mkp make_pair
#define b_s binary_search
#define nob __builtin_popcount
#define des greater<ll>()
#define fi first
#define se second
ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
void input(ll a[], ll sz) {fr(i, 0, sz) cin >> a[i];}
void print(ll a[], ll sz) {fr(i, 0, sz) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll maxr(ll a[], ll sz) {ll ma; fr(i, 0, sz) {if (i == 0) ma = a[i]; else if (a[i] > ma) ma = a[i];} return ma;}
ll minr(ll a[], ll sz) {ll mi; fr(i, 0, sz) {if (i == 0) mi = a[i]; else if (a[i] < mi) mi = a[i];} return mi;}
ll isprm(ll n) {
    if (n <= 1)  return 0;
    if (n <= 3)  return 1;
    if (n % 2 == 0 || n % 3 == 0) return 0;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return 0;
    return 1;
}
/*ll spf[MAXN];
void sieve()
{
    spf[1]=1;
    for (ll i=2; i<MAXN; i++)
        spf[i] = i;
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for(ll i=3;i*i<MAXN;i+=2)
    {
        if (spf[i]==i)
        {
            for (int j=i*i;j<MAXN;j+=i)
                if (spf[j]==j)
                    spf[j]=i;
        }
    }
}*/
ll power(ll x, ll y, ll p = mod)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
//a+b=xor(a,b)+2*(a&b)//
struct comp
{
    bool operator()(const pair<ll, ll> &a,
                    const pair<ll, ll> &b)const
    {
        if (a.fi == b.fi)
        {
            return (a.se > b.se); //second elem in descending
        }
        return (a.first < b.first);//first elem in ascending
    }
};




int main()
{
    fio;
    ll n;
    cin>>n;
    if(n==1)
    {
        cout<<"0\n";
        return 0;
    }
    ll ans=1;
    ans%=mod;
    ll p=power(10,n);
    p%=mod;
    ans=mul(ans,p);
    ll h=power(8,n);
    ans-=h;
    ans+=mod;
    ans%=mod;
    ll g=power(9,n)-h;
    g+=mod;g%=mod;
    g=mul(g,2);
    ans-=g;
    ans+=mod;
    ans%=mod;
    cout<<ans%mod<<"\n";
    return 0;
}


Measured memory_bytes: 3636
while True:
	n = input()
	if n == 0:
		break
	
	array = map(int,raw_input().split())
	aray = []
	count = 0
	while array != aray:
		aray = array
		agency = []
		for i in xrange(n):
			agency.append(array.count(array[i]))
		array = agency
		count += 1
		
	print count - 1
	
	string = ""
	for var in array:
		string += str(var) + " "
		
	print string[:len(string) - 1]

Measured memory_bytes: 6272
[n,k]=input().split()
[r,s,p]=input().split()
t=input()
n=int(n)
k=int(k)
r=int(r)
s=int(s)
p=int(p)
r_miss=0
s_miss=0
p_miss=0
wl='w'
for i in range(1,k):
    wl=wl+'w'

for i in range(k,n):
    if t[i]==t[i-k] and wl[i-k]=='w':
        wl=wl+'l'
        if t[i]=='r':
            r_miss=r_miss+1
        elif t[i]=='s':
            s_miss=s_miss+1
        elif t[i]=='p':
            p_miss=p_miss+1
    else:
        wl=wl+'w'
            
score=(t.count('r')-r_miss)*p+(t.count('s')-s_miss)*r+(t.count('p')-p_miss)*s
print(score)

Measured memory_bytes: 3444
s=gets.chomp
gets
while gets
c,a,b,p=$_.split
a=a.to_i;b=b.to_i-a+1
case c[2]
when ?i
puts s[a,b]
when ?v
s[a,b]=s[a,b].reverse
else
s[a,b]=p
end
end


Measured memory_bytes: 6916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 7;
const double pi = acos(-1);
const int mod = 100007;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;

int main(){
	ll a,b,n;
	cin >> a >> b >> n;
	ll maxx = 0;
	maxx = max((a*(min(b-1,n)))/b,maxx);
	cout << maxx << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  int debt = 100000, n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    debt *= 1.05;
    debt = (int)ceil(debt/1000.0)*1000;
  }
  cout << debt << endl;
}

Measured memory_bytes: 1164
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
    int n,i,j,k,l,b,f,r,v;
    int member[4][3][10]={
        {
            {0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0}
        },{
            {0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0}
        },{
            {0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0}
        },{
            {0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0}
        }
    };
    cin >> n;
    for(i=0;i<n;i++){
        cin >>b>>f>>r>>v;
        member[b-1][f-1][r-1] +=v;
    }
    for(j=0;j<4;j++){
        for(k=0;k<3;k++){
            for(l=0;l<10;l++){
                printf(" %d",member[j][k][l]);
            }
            printf("\n");
        }
        if(j==3){
            break;
        }
        else{
            printf("####################\n");
        }
    }
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a == 1 && b == 2)
  cout << 3;
  if(a == 1 && b == 3)
  cout << 2;
  if(a == 2 && b == 1)
  cout << 3;
  if(a == 2 && b == 3)
  cout << 1;
  if(a == 3 && b == 2)
  cout << 1;
  if(a == 3 && b == 1)
  cout << 2;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

vector<pair<ll, ll>> prime_factorize(ll n)
{
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) {
            continue;
        }
        int num = 0;
        while (n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N, P;
    cin >> N >> P;
    auto fac = prime_factorize(P);
    ll res = 1;
    for (auto p : fac) {
        for (int j = 0; j < p.second / N; ++j) {
            res *= p.first;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  string N;
  cin >> N;
  for (ll i = 0; i < 3; ++i) {
    if (N[i] == '7') {
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
}


Measured memory_bytes: 3624