akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

char ch[6060];
string str;
int h[6060];

string solve(int l, int r){
	if(str[l] == 'a'){
		vector<int> A, B;
		for(int i = l; i < r; ++i){
			if(str[i] == 'a') A.push_back(i);
			else B.push_back(i);
		}
		int cnt = 0;
		int prv = -1;
		for(int i = 0; i < A.size(); ++i){
			if(A[i] >= prv){
				prv = B[i];
				cnt++;
			}
		}
		string s(cnt * 2, 'a');
		for(int i = 0; i < s.size(); ++i){
			if(i % 2 == 1) s[i] = 'b';
		}
		return s;
/*
		int cnt = 0;
		int num = 0;
		bool pending = false;
		string ans = "";
		for(int i = l; i < r; ++i){
			if(str[i] == 'a'){
				if(num == 0)
			if(!pending){
				pending = true;
			}else{
				if(str[i] == 'b'){
					cnt++;
					pending = false;
				}
			}
		}
		string s(cnt * 2, 'a');
		for(int i = 0; i < s.size(); ++i){
			if(i % 2 == 1) s[i] = 'b';
		}
		return s;*/
	}else{
		int mi = 0;
		for(int i = l + 1; i <= r; ++i){
			mi = min(mi, h[i]);
		}
		string s = "";
		for(int i = l + 1; i <= r; ++i){
			if(h[i] == mi){
				string tmp = str.substr(i, r - i);
				if(s == "" || s < tmp) s = tmp;
			}
		}
		string ans(-mi, 'b');
		return ans + s;
	}
}

string solve(){
	h[0] = 0;
	for(int i = 0; i < str.size(); ++i){
		if(str[i] == 'a') h[i + 1] = h[i] + 1;
		else h[i + 1] = h[i] - 1;
	}
	string ans;
	int prv = str.size();
	for(int i = str.size() - 1; i >= 0; --i){
		if(h[i] == 0){
			string tmp = solve(i, prv);
			prv = i;
			tmp = tmp + ans;
			if(tmp > ans) ans = tmp;
		}
	}
	return ans;
}

int main(){
	int N;
	scanf("%d", &N);
	scanf("%s", ch);
	str = ch;
	string ans = solve();
	printf("%s\n", ans.c_str());
	return 0;
}


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

using namespace std;
#define pii pair <int , int>
#define F first
#define S second

const int N = 1e5 + 5;
int par[N];
long long C, m;

int getpar(int v) {return par[v] = (par[v] == v ? v : getpar(par[v]));}
void Union(int u, int v) {
    u = getpar(u), v = getpar(v);
    if (u == v) return ;
    C--, par[u] = par[v];
    return ;
}

int main(){
    int n, q; cin >> n >> m >> q, C = n;
    vector <pii> vec;
    for (int i = 0; i < n; i++) par[i] = i;
    for (int i = 0; i < q; i++) {
        int u, v, c; cin >> u >> v >> c;
        if (c == 0) Union(u, v);
        else vec.push_back({u, v});
    }
    for (pii p : vec) if (getpar(p.F) == getpar(p.S)) return cout << "No\n", 0;
    if ((m == n - 1 || C == 2) && !vec.empty()) return cout << "No\n", 0;
    if (m > C * (C - 1) / 2 + n - C) return cout << "No\n", 0;
    cout << "Yes\n";

    return 0;
}


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

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

int main() {
  int N;
  cin >> N;
  vector<int> hs(N + 2, 0);
  int maxH = 0;
  for(int i = 1; i <= N; ++i) {
    cin >> hs[i];
    chmax(maxH, hs[i]);
  }

  int ans = 0;
  for(int h = 1; h <= maxH; ++h) {
    for(int x = 1; x <= N + 1; ++x) {
      if(hs[x - 1] >= h && h > hs[x]) {
        // cout << h << " : " << x - 1 << " - " << x << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var a,b,c,d,e int
  fmt.Scanf("%d%d%d%d%d", &a, &b, &c, &d, &e )

	if a==0 { fmt.Printf("%d", 1) }
	if b==0 { fmt.Printf("%d", 2) }
	if c==0 { fmt.Printf("%d", 3) }
	if d==0 { fmt.Printf("%d", 4) }
	if e==0 { fmt.Printf("%d", 5) }


}

Measured memory_bytes: 1816
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,U,V,ans=0;
  cin>>N>>U>>V;
  bool CAN[N];
  REP(i,N) CAN[i]=false;
  Graph G(N);
  REP(i,N-1){
    ll A,B;
    cin>>A>>B;
    A--,B--;
    G[A].PB(B);
    G[B].PB(A);
  }
  
  ll DU[N],DV[N];
  REP(i,N){
    DU[i]=INF;
    DV[i]=INF;
  }
  DU[U-1]=0;
  DV[V-1]=0;
  
  queue<ll> Q;
  Q.push(U-1);
  CAN[U-1]=true;
  while(!Q.empty()){
    ll i=Q.front();
    Q.pop();
    FORE(j,G[i]){
      if(CAN[j]) continue;
      CAN[j]=true;
      chmin(DU[j],DU[i]+1);
      Q.push(j);
    }
  }
  
  REP(i,N) CAN[i]=false;
  queue<ll> QQ;
  QQ.push(V-1);
  CAN[V-1]=true;
  while(!QQ.empty()){
    ll i=QQ.front();
    QQ.pop();
    FORE(j,G[i]){
      if(CAN[j]) continue;
      CAN[j]=true;
      chmin(DV[j],DV[i]+1);
      QQ.push(j);
    }
  }
  
  REP(i,N){
    if(DU[i]<DV[i]) chmax(ans,DV[i]);
  }
  co(ans-1);
  return 0;
}

Measured memory_bytes: 10628
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

A, B = map(int, input().split())

def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    return gcd(b, a % b)


# https://en.wikipedia.org/wiki/Trial_division
def f(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1: a.append(n)
    # Only odd number is possible
    return a


c = gcd(A, B)

print(len(set(f(c))) + 1)


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

int main()
{
	deque<int> DR;
	deque<int> DV;
	deque<int> DC;

	int x, y, MR, MV, MC;
	cin >> x >> y >> MR >> MV >> MC;

	for (int i = 0; i < MR; i++)
	{
		int x; cin >> x;
		DR.push_back(x);
	}
	sort(DR.begin(), DR.end());

	for (int i = 0; i < MV; i++)
	{
		int x; cin >> x;
		DV.push_back(x);
	}
	sort(DV.begin(), DV.end());

	for (int i = 0; i < MC; i++)
	{
		int x; cin >> x;
		DC.push_back(x);
	}
	sort(DC.begin(), DC.end());
	reverse(DC.begin(), DC.end());

	while (DR.size() > x) { DR.pop_front(); }
	while (DV.size() > y) { DV.pop_front(); }

	while (DC.size())
	{
		int variable = DC.front();
		int minimo = min(DR.front(), DV.front());

		if (variable <= minimo) { break; }
		if (DR.front() < DV.front())
		{
			DR.pop_front();
			DR.push_back(variable);
		}
		else
		{
			DV.pop_front();
			DV.push_back(variable);
		}

		DC.pop_front();
	}

	long long resultado = 0;

	for (int i = 0; i < DR.size(); i++)
	{
		resultado += DR[i];
	}

	for (int i = 0; i < DV.size(); i++)
	{
		resultado += DV[i];
	}

	cout << resultado;
	return 0;
}

Measured memory_bytes: 1536
h = {}
('a'..'z').zip(1..26) do |k, v|
  h[k] = v
end

s = gets.chomp.split("")

if s.length < 26
  cand = ('a'..'z').select{|x| !s.include?(x)}
  puts s.join("") + cand[0]
else
  left = 0
  25.downto(1) do |i|
    if h[s[i]] > h[s[i - 1]]
      left = i
      break
    end
  end
  if left == 0
    puts -1
  else
    cand = s[left..25].select{|x| h[x] > h[s[left - 1]]}.sort
    if left == 1
      puts cand[0]
    else
      puts s[0..(left - 2)].join("") + cand[0]
    end
  end
end

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<bool> vb;

const int MAXN = 1e5;

int num[MAXN], cost[MAXN]={0};

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

    int n; cin >> n;
    for(int i=0; i<n; i++)
        cin >> num[i];

    cost[1] = abs(num[1]-num[0]);
    for(int i=2; i<n; i++){
        cost[i] = min(cost[i-1]+abs(num[i]-num[i-1]),
                    cost[i-2]+abs(num[i]-num[i-2]));
    }

    cout << cost[n-1] << '\n';

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
  ll m; cin>>m;
  vl v(n),w(n);
  rep(i,0,n)cin>>w[i]>>v[i];
  ll dp[n+10][m+100];
  rep(i,0,n){
  	rep(j,0,m+10){
      dp[i+1][j]=dp[i][j];
      if(j-w[i]>=0)chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout<<dp[n][m]<<endl;
  
  
	return 0;
}


Measured memory_bytes: 81812
#n=int(input())
#L=list(map(int,input().split()))
k,x=map(int,input().split())
#A=[[0 for i in range()] for j in range()]
sita=max(-1000000,x-k+1)
ue=min(1000000,x+k-1)
l=[]

for i in range(sita,ue+1):
  l.append(i)
print(*l)

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=500010, inf=1e9;
struct poi{int w, pos, ty;}q[maxn];
int n, cnt;
int a[maxn], b[maxn];
bool va[maxn], vb[maxn];

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;
}

bool operator < (poi a, poi b) {return a.w<b.w;}

int main()
{
	read(n); ll suma=0, sumb=0;
	for(int i=1;i<=n;i++)
	{
		read(a[i]); read(b[i]);
		suma+=a[i]; sumb+=b[i];
		q[++cnt]=(poi){a[i], i, 0};
		q[++cnt]=(poi){b[i], i, 1};
	}
	sort(q+1, q+1+cnt); ll ans=0;
	ll flaga=0, flagb=0;
	for(int i=1;i<=n;i++)
	{
		if(q[i].ty) vb[q[i].pos]=1, flaga=1;
		else va[q[i].pos]=1, flagb=1;
		ans+=q[i].w;
	}
	if(!flaga || !flagb) return printf("%lld\n", ans), 0;
	bool flag=0;
	for(int i=1;i<=n;i++) flag|=(va[i] && vb[i]);
	if(flag) return printf("%lld\n", ans), 0;
	if(q[n+1].pos!=q[n].pos) ans+=q[n+1].w-q[n].w;
	else ans=min(ans+q[n+1].w-q[n-1].w, ans+q[n+2].w-q[n].w);
	printf("%lld\n", ans);
}

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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int n, m;
const int MAXN = 210000;

pair<int, int> rmq[MAXN * 4];
int a[MAXN];
int cc[MAXN];
int dd[MAXN * 4];

void build(int v, int tl, int tr) {
    rmq[v] = make_pair(0, tr - tl);
    if (tl + 1 == tr)
        return;
    int m = (tl + tr) >> 1;
    build(v * 2 + 1, tl, m);
    build(v * 2 + 2, m, tr);
}

pair<int, int> merge(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return make_pair(a.first, a.second + b.second);
    }
    else {
        return min(a, b);
    }
}

void add(int v, int tl, int tr, int l, int r, int d) {
    if (r <= tl || tr <= l)
        return;
    if (l <= tl && tr <= r) {
        dd[v] += d;
        rmq[v].first += d;
        return;
    }
    int m = (tl + tr) >> 1;
    add(v * 2 + 1, tl, m, l, r, d);
    add(v * 2 + 2, m, tr, l, r, d);
    rmq[v] = merge(rmq[v * 2 + 1], rmq[v * 2 + 2]);
    rmq[v].first += dd[v];
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        ++cc[a[i]];
    }
    build(0, 1, n + 1);
    for (int i = 1; i <= n; ++i) {
        if (cc[i])
            add(0, 1, n + 1, i - cc[i] + 1, i + 1, 1);
    }
    for (int i = 0; i < m; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        --x;
        add(0, 1, n + 1, a[x] - cc[a[x]] + 1, a[x] - cc[a[x]] + 2, -1);
        --cc[a[x]];
        a[x] = y;
        ++cc[a[x]];
        add(0, 1, n + 1, a[x] - cc[a[x]] + 1, a[x] - cc[a[x]] + 2, 1);
        if (rmq[0].first == 0)
            printf("%d\n", rmq[0].second);
        else
            printf("0\n");
    }
    return 0;
}




Measured memory_bytes: 11520
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int a, b;

    cin >> a >> b;

    int res = max(a, b);
    if (a > b)
        a--;
    else
        b--;
    res += max(a, b);

    cout << res << endl;

    return 0;
}

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



int main(){
    int N;
    cin >> N;
    N = N % 10;

    if(N == 3) cout << "bon" << endl;
    else if(N == 0 || N == 1 || N == 6 || N == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3588
m, n = map(int, input().split())
while True:
  if m < n:
    m, n = n, m
  if m%n:
    m, n = n, m%n
  else:
    break

divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
divisors.sort()
ans = [1]
notans = [False]*len(divisors)
for j in range(len(divisors)):
    if divisors[j] == 1 or notans[j] == True:
        continue
    ans.append(divisors[j])
    for i in range(j+1, len(divisors)):
        if divisors[i]%divisors[j] == 0:
            notans[i] = True

print(len(ans))

Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    int n, m; cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse,sse2")
#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;

template<class T>
using ordered_set = tree <T, null_type ,  less<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree <T, null_type ,  less_equal<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;

#define all(x) x.begin(), x.end()
#define all_r(x) x.rbegin(), x.rend()
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, n) for(int i = n; i >= 0; --i)
#define f first
#define s second

const int MAXN = 5e5 + 1, MOD = 1e9 + 7;
ll f[MAXN], invf[MAXN];

ll expmod(int n, int p) {
	if(p == 0) return 1;
	ll x = expmod(n, p >> 1);
	x = x * x % MOD;
	return p & 1 ? x * n % MOD : x;	
}
ll P(int n, int k) {
	return f[n] * expmod(f[n - k], MOD - 2) % MOD;
}
ll C(int n, int k) {
	return f[n] * expmod(f[k] * f[n - k] % MOD, MOD - 2) % MOD;
}
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	f[0] = invf[0] = 1;
	for(int i = 1; i < MAXN; ++i)
		f[i] = i * f[i - 1] % MOD;
	ll y = P(m, n) * P(m, n) % MOD;
	for(int i = 1; i <= n; ++i) {
		if(i & 1) {
			ll z = P(m - i, n - i);
			ll w = C(n, i);
			ll x = P(m, i);
			z = z * z % MOD;
			y -= z * x % MOD * w % MOD;
		}
		else {
			ll z = P(m - i, n - i);
			ll w = C(n, i);
			ll x = P(m, i);
			z = z * z % MOD;
			y += z * x % MOD * w % MOD;
		}
	} 
	y %= MOD;
	if(y < 0) y += MOD;
	cout << y << '\n';
 	return 0;
}

Measured memory_bytes: 7540
#include <iostream>
using namespace std;
int main()
{
    int n,a;
    cin >> n;
    int num[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a;
        num[a -1] = i + 1;
    }
    for(int i = 0;i < n;i++)
    {
        cout << num[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

#define pi 3.1415926535897932

int main()
{
	double n;
	cin >> n;
	cout << 2*n*pi << endl;





}


Measured memory_bytes: 3784
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string S;
    ll N, i, al[30], ans=1;

    cin >> N >> S;

    for(i=0; i<26; i++){
        al[i] = 0;
    }

    for(i=0; i<N; i++){
        al[S[i]-'a']++;
    }

    for(i=0; i<26; i++){
        ans *= (al[i]+1);

        ans = ans % div1;
    }

    ans--;

    ans = ans % div1;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll N, M; cin >> N >> M;
	char s[51][51] = {};
	char t[51][51] = {};

	rep(i, 0, N) {
		rep(j, 0, N) {
			cin >> s[i][j];
		}
	}
	rep(i, 0, M) {
		rep(j, 0, M) {
			cin >> t[i][j];
		}
	}

	rep(i, 0, N) {
		rep(j, 0, N) {
			bool valid = true;
			rep(k, 0, M) {
				rep(l, 0, M) {
					if (i + k <= N && j + l <= N) {
						valid &= s[i + k][j + l] == t[k][l];
					}
					else {
						valid = false;
					}
				}
			}
			if (valid) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main(void){
	int n;
	cin >> n;
	vector<int> w(n);
	int sum = 0;
	for(auto &x : w){
		cin >> x;
		sum += x;
	}
	int ans = INT_MAX;
	int now = 0;
	for(int i = 0; i < n; ++i){
		now += w[i];
		ans = min(abs(sum-now*2), ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i=n-1 ; i > =0; i--)
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
typedef long long int ll;
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};
void solve(){

	int q,k;
	cin>>q>>k;
	std::vector<int> v(q+1);
	for(int i=1;i<=q;i++)
		cin>>v[i];
		
	int mx=INT_MAX,t1=INT_MAX,t2=INT_MAX;
	for(int i=1;i+k-1<=q;i++)
	{
		 if(v[1]<0)
			{
				t1=abs(v[i]);
				if(v[i+k-1]>0)
					t1+=v[i+k-1]*2,t2=abs(v[i])*2+v[i+k-1];
				
			}
			else
			{
				t1=abs(v[i+k-1]);
			}
			mx=min({t1,t2,mx});
	}
	cout<<mx;
}
int main(){
	
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	solve();
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int n, m;
int x[100010];
int d[100010];

int main() {
    cin >> n >> m;
    rep(i, m) cin >> x[i];
    sort(x, x + m);
    int ans = 0;
    rep(i, m -1){
        d[i] = x[i+1] - x[i];
        ans += d[i];
    }
    sort(d, d+m, greater<int>());
    rep(i, n-1){
        ans -= d[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
n,m = map(int, input().split())
h_li = list(map(int, input().split()))
ans = [0]*n
goods = list()
bads = list()

for i in range(m):
  a, b = map(int, input().split())
  good = max(h_li[a-1], h_li[b-1])
  bad = min(h_li[a-1], h_li[b-1])
  if h_li[a-1] == h_li[b-1]:
    bads.append(a-1)
    bads.append(b-1)
    continue
  if good == h_li[a-1]:
    good_i = a-1
    bad_i = b-1
  else:
    good_i = b-1
    bad_i = a-1
  goods.append(good_i)
  bads.append(bad_i)

  
all_s = set(goods + bads)
goods = set(goods)
bads = set(bads)

no_paths = n - len(all_s)
bests = [ten for ten in goods if ten not in bads]

print(len(bests) + no_paths)


Measured memory_bytes: 31160
S=input()
if S[0]==S[1]:
    if S[1]!=S[2] and S[2]==S[3]:
        print('Yes')
    else:
        print('No')
else:
    if S.count(S[0])==2 and S.count(S[1])==2:
        print('Yes')
    else:
        print('No')

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

set<char> ACGT{'A', 'C', 'G', 'T'};

int main() {
  string S; cin >> S;
  int ans{};
  size_t i{};
  while (i < S.size()) {
    while (i < S.size() && ACGT.find(S[i]) == ACGT.end()) {
      ++i;
    }
    int len{};
    while (i < S.size() && ACGT.find(S[i++]) != ACGT.end()) {
      ++len;
    }
    ans = max(ans, len);
  }

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


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define NOT 0
struct Point{
  double a;
  double b;
};

void Koch(int x, struct Point a, struct Point b){


  struct Point s, t, u;







  if(x == 0) return;

  double radian = M_PI * 60.0 / 180.0;

  s.a = (2.0 * a.a + 1.0 * b.a) / 3.0;
  s.b = (2.0 * a.b + 1.0 * b.b) / 3.0;
  t.a = (1.0 * a.a + 2.0 * b.a) / 3.0;
  t.b = (1.0 * a.b + 2.0 * b.b) / 3.0;
  u.a = (t.a - s.a) * cos(radian) - (t.b - s.b) * sin(radian) + s.a;
  u.b = (t.a - s.a) * sin(radian) + (t.b - s.b) * cos(radian) + s.b;

  Koch(x - 1, a, s);

  printf("%.8f %.8f\n",s.a,s.b);


  Koch(x - 1, s, u);
  printf("%.8f %.8f\n",u.a,u.b);
  Koch(x - 1, u, t);
  printf("%.8f %.8f\n",t.a,t.b);
  Koch(x - 1, t, b);
}


int main(){
  int n;
  struct Point s, t;

  scanf("%d",&n);

  s.a = 0;
  s.b = 0;
  t.a = 100;
  t.b = 0;

  printf("%.8f %.8f\n",s.a,s.b);



  Koch(n, s, t);



  printf("%.8f %.8f\n",t.a,t.b);

  return NOT;
}



Measured memory_bytes: 2136
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
using namespace atcoder;

void solve(){
	int n,m;
	cin>>n>>m;
	scc_graph scc(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		scc.add_edge(a,b);
	}
	auto v=scc.scc();
	cout<<v.size()<<"\n";
	rep(i,v.size()){
		cout<<v[i].size();
		for(auto e:v[i]){
			cout<<" "<<e;
		}
		cout<<"\n";
	}
}


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


Measured memory_bytes: 40072
#include<iostream>
#include<cmath>
#define INF 1000000001
using namespace std;

int C = 0;
int merge(int A[], int left, int mid, int right) {

    int n1, n2, i, j, k;
    n1 = mid - left;
    n2 = right - mid;
    int L[n1+1], R[n2+1];
    
    for (i = 0; i < n1; i++) {
	L[i] = A[left+i];
    }
    for (i = 0; i < n2; i++) {
	R[i] = A[mid+i];
    }
    L[n1] = INF;
    R[n2] = INF;
    i = 0;
    j = 0;
    for (k = left; k < right; k++) {
	if (L[i] <= R[j]) {
	    A[k] = L[i];
	    i++;
	    C++;
	}
	else {
	    A[k] = R[j];
	    j++;
	    C++;
	}
    }
    return C;
}

int mergeSort(int A[], int left, int right) {
    if (left+1 < right) {
	int mid = (left + right ) / 2;
	mergeSort(A, left, mid);
	mergeSort(A, mid, right);
	return merge(A, left, mid, right);
    }
}

int main() {
    int n, i, left, right, res;
    cin >> n;
    int A[n];
    
    for (i = 0; i < n; i++) {
	cin >> A[i];
    }
    left = 0;
    right = n;
    res = mergeSort(A, left, right);
    
    for (i = 0; i < n; i++) {
	if (i != n-1) cout << A[i] << " ";
	else cout << A[i];
    }
    cout << endl;
    cout << res << endl;
}

Measured memory_bytes: 5060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

class unionfind {
	vector<int> par;
	vector<int> sz;
public:
	unionfind(int n) {
		par = vector<int>(n);
		for (int i = 0; i < n; i++) par[i] = i;
		sz = vector<int>(n, 1);
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	int si(int x) { return sz[find(x)]; }
	bool same(int x, int y) { return find(x) == find(y); }
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (sz[x] < sz[y]) {
			par[x] = y;
			sz[y] += sz[x];
		}
		else {
			par[y] = x;
			sz[x] += sz[y];
		}
	}
};

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

	int a, b;
	cin >> a >> b;
	if (a <= b) {
		cout << "Impossible" << endl;
		return 0;
	}
	int n = a + b;
	unionfind uni(n);
	vector<int> vec(n);
	rep(i, n) vec[i] = i;
	while (vec.size() > 1) {
		vector<int> nxt;
		int vs = vec.size();
		for (int i = 0; i < vs - 1; i += 2) {
			int x = vec[i]; int y = vec[i + 1];
			char c, d;
			cout << "? " << x << ' ' << y << endl;
			cin >> c;
			cout << "? " << y << ' ' << x << endl;
			cin >> d;
			if (c == 'Y' && d == 'Y') {
				uni.unite(x, y);
				nxt.pb(x);
			}
		}
		if (vs % 2 == 1 && nxt.size() % 2 == 0) nxt.pb(vec.back());
		vec = nxt;
	}
	int honest = vec[0];
	vector<int> ans(n, -1);
	rep(i, n) {
		int v = uni.find(i);
		if (ans[v] == -1) {
			cout << "? " << honest << ' ' << v << endl;
			char c;
			cin >> c;
			if (c == 'Y') ans[v] = 1;
			else ans[v] = 0;
		}
	}
	rep(i, n) {
		ans[i] = ans[uni.find(i)];
	}
	cout << "! ";
	rep(i, n) cout << ans[i];
	cout << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fs first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  string s; std::cin >> s;
  int nr = 0, nl = 0;
  rep(i, n) {
    if (s[i] == '(') nr++; 
    else {
      if (nr == 0) nl++;
      else nr--;
    }
  }
  rep(i, nl) std::cout << '(';
  std::cout << s;
  rep(i, nr) std::cout << ')';
  std::cout << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
  int number_n, str_length, i, j;
  scanf("%d %d", &number_n, &str_length);
  char temp[str_length+1];
  char str[number_n+1][str_length+1];
  for(i = 0; i < number_n; i++) {
    scanf("%s", str[i]);
  }
  for(i = 0; i < number_n - 1; i++) {
    for(j = number_n - 1; j > i; j--) {
      if(strcmp(str[j], str[j-1]) < 0) {
        strcpy(temp, str[j]);
        strcpy(str[j], str[j-1]);
        strcpy(str[j-1], temp);
      }
    }
  }
  for(i = 0; i < number_n; i++) {
    printf("%s", str[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
N,K = map(int,input().split())
P = [float('inf')]+list(map(int,input().split()))+[float('inf')]

A = [0]*N
B = [0]*(N+2)
hoge = 1
for i in range(1,N):
    if P[i] < P[i+1]:
        hoge += 1
    else:
        hoge = 1
    if hoge >= K:
        B[i-K+2] = 1
    
for i in range(1,N+1):
    A[P[i]] = i
minL,minR,maxL,maxR = [i-1 for i in range(N+2)],[i+1 for i in range(N+2)],[i-1 for i in range(N+2)],[i+1 for i in range(N+2)]
for i in range(N):
    m = A[i]
    x,y = maxL[m],maxR[m]
    maxL[y] = x
    maxR[x] = y
P[0],P[-1] = -1,-1

for i in range(N-1,-1,-1):
    m = A[i]
    x,y = minL[m],minR[m]
    minL[y] = x
    minR[x] = y
ans = 1
for i in range(1,N-K+1):
    # print(i)
    L,R = i,i+K
    # print(i,P[L],P[R],minR[L],maxL[R],B[i+1])
    if B[i+1] == 0 and (minR[L] <= R or maxL[R] >= L):
        # print(i)
        ans += 1
# print(minR[1:-1])
# print(maxL[1:-1])
if sum(B) and B[1] == 0:
    ans += 1
# print(B)
print(ans)

Measured memory_bytes: 117872
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int a, b;
    cin >> a >> b;
    
    if(a <= 0 && b >= 0) {
        output("Zero", 0);
        return 0;
    }
    if(a > 0){
        output("Positive", 0);
    }
    if(b < 0){
        if((b - a + 1) % 2 == 0){
            output("Positive", 0);
        }
        else{
            output("Negative", 0);
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Run(args));
        }


        private static int Run(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            var ret = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i].Equals(T[i])) {
                    ret++;
                }
            }

            return ret;
        }
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		WriteLine(I[0] % I[1] == 0 ? 0 : 1);
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+')ans++;
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,sum=0;
    c_p_c();
  	cin>>n>>m;
  	vl a[n+1];
  	int a1,b1;
  	for (int i = 0; i < m; ++i)
  	{
  		/* code */
  		cin>>a1>>b1;
  		a[a1].pb(b1);
  		a[b1].pb(a1);
  	}

  	for (int i = 1; i < n+1; ++i)
  	{
  		/* code */
  		cout<<a[i].size()<<endl;
  	}


  	
 	return 0;

   }

Measured memory_bytes: 3624
def cost(N, K, X, Y):
    cost = 0
    for i in range(1,N+1):
        if i <= K:
            cost += X
        else:
            cost += Y
    return cost

N = int(input())
K = int(input())
X = int(input())
Y = int(input())

print(cost(N, K, X, Y))


Measured memory_bytes: 2940
//tenka1_a.cpp
//Sat Oct 20 23:07:56 2018

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

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

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

	cout << count << endl;
}

Measured memory_bytes: 256
SENTINEL = 10**9 + 1


def merge_sort(alist):
    """Sort alist using mergesort.
    Returns a tuple of the number of comparisons and sorted list.

    >>> merge_sort([8, 5, 9, 2, 6, 3, 7, 1, 10, 4])
    (34, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
    """
    def _sort(left, right):
        count = 0
        if left + 1 < right:
            mid = (left + right) // 2
            count += _sort(left, mid)
            count += _sort(mid, right)
            count += merge(left, mid, right)

        return count

    def merge(left, mid, right):
        count = 0
        ll = alist[left:mid] + [SENTINEL]
        rl = alist[mid:right] + [SENTINEL]

        i = j = 0
        for k in range(left, right):
            count += 1
            if ll[i] <= rl[j]:
                alist[k] = ll[i]
                i += 1
            else:
                alist[k] = rl[j]
                j += 1

        return count

    comp = _sort(0, len(alist))
    return (comp, alist)


def min_cost(li1, li2):
    """calculate minimum cost to transform li1 into li2.

    >>> min_cost([1, 5, 3, 4, 2], [1, 2, 3, 4, 5])
    7
    >>> min_cost([4, 3, 2, 1], [1, 2, 3, 4])
    10
    """
    def find_moves(i, j):
        start = i
        elems = [i]
        mincost = li1[i]
        minidx = 0

        while j != start:
            if mincost > li1[j]:
                mincost = li1[j]
                minidx = len(elems)
            elems.append(j)
            j = li2.index(li1[j])

        elems = elems[minidx+1:] + elems[:minidx+1]
        if 2 * (mincost + li1[mini]) < (len(elems) - 1) * (mincost - li1[mini]):
            elems.append(mini)
            elems.insert(0, mini)

        q = elems.pop()
        p = elems.pop()
        yield (p, q)
        while len(elems) > 0:
            q = p
            p = elems.pop()
            yield (p, q)


    def move(i, j):
        cost = 0
        for p, q in find_moves(i, j):
            li1[p], li1[q] = li1[q], li1[p]
            cost += li1[p] + li1[q]

        return cost

    assert len(li1) == len(li2)
    size = len(li1)
    totalcost = 0

    for i in reversed(range(size)):
        if li1[i] != li2[i]:
            mini = li1.index(li2[0])
            totalcost += move(li1.index(li2[i]), i)

    return totalcost


def run():
    _ = int(input())  # flake8: noqa
    li = [int(i) for i in input().split()]
    sli = li[:]
    (_, sli) = merge_sort(sli)

    print(min_cost(li, sli))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5648
import sys

n, y = map(int, input().split())
for i in range(n+1):
  for j in range(min(n-i+1, 9)):
    k = n - i - j
    money = 10000 * i + 5000 * j + 1000 * k
    if y == money:
      print("{} {} {}".format(i, j, k))
      sys.exit()
print(-1, -1, -1)

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

int main() { 
    map<int, int> mp;
    int n, a;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> a;
        if(mp[a] != 0) {
            cout << "NO" << '\n';
            return 0;
        } else {
            mp[a]++;
        }
    }
    cout << "YES" << '\n';

    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
//#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return abs(gcd(b,a%b));
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[b];
    uni[b]=a;
    return true;
}
int ord(int n){
    int ans=0;
    while(n%2==0){
        ans++;
        n/=2;
    }
    return ans;
}

signed main(void){
    int n,m;cin>>n>>m;
    int V[n];
    rep(i,n){
        int a;cin>>a;
        V[i]=a/2;
    }
    int lcm=1;
    
    rep(i,n-1){
        if(ord(V[i])!=ord(V[i+1])){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        lcm=lcm/gcd(lcm,V[i])*V[i];
        if(lcm>m){
            cout<<0<<endl;
            return 0;
        }
    }
    

   // cout<<lcm<<endl;
    //1~mでlcmの奇数倍のものを数える    
    cout<<(m+lcm)/(2*lcm)<<endl;
    
}
        


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

int main()
{
  int64_t N, M, sum;
  cin >> N >> M;
  vector<int64_t> A(N);
  for (int i = 0; i < M; i++)
  {
    cin >> A.at(i);
  }
  sum = accumulate(A.begin(), A.end(), 0);
  if (sum > N)
    cout << -1 << endl;
  else
    cout << N - sum << endl;
}

Measured memory_bytes: 11104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 998244353;
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= 50000; i++)
    {
        int ans = i * 1.08;
        if(ans == n)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[3005][3005];
ll f(ll ar[],int i,int j){
    if(i>j){
        return 0;
    }
    //Recursive Case
    if(dp[i][j]!=-1){
        return dp[i][j];
    }

    ll ans1 = ar[i]  + min(f(ar,i+2,j),f(ar,i+1,j-1));
    ll ans2 = ar[j]  + min(f(ar,i,j-2),f(ar,i+1,j-1));
    dp[i][j] = max(ans1,ans2);
    return dp[i][j];
}

int main(){
    int n;
    cin>>n;
    ll ar[n];
    memset(dp,-1,sizeof(dp));
    ll s=0;
    for(int i=0;i<n;i++){
        cin>>ar[i];
        s += ar[i];
    }
    ll x = f(ar,0,n-1);
    /*for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    ll y = s-x;
    cout<<x-y;
}


Measured memory_bytes: 74236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1==s2.substr(0,s2.size()-1) && s1.size()==s2.size()-1)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 3604
from collections import defaultdict
def inpl(): return [int(i) for i in input().split()]

path = defaultdict(lambda: [])
N = int(input())
for _ in range(N-1):
    a, b, c = inpl()
    path[a].append((b,c))
    path[b].append((a,c))

ctr = 1
Q, K = inpl()
now = {K}
dist = [0 for _ in range(N+1)]
while True:
    for na in now.copy():
        na = now.pop()
        for nb, nc in path[na]:
            dist[nb] = dist[na] + nc
            path[nb].remove((na,nc))
            now.add(nb)
            ctr += 1
    if ctr >=  N:
        break
for i in range(Q):
    x, y = inpl()
    print(dist[x]+dist[y])

Measured memory_bytes: 52372
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N;
		N=scan.nextInt();
		int kisu;
		kisu=N/2;
		if(N%2==1)kisu++;
		double A;
		A=(double)kisu/(double)N;
		System.out.print(A);
		
		
	}
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	vector<vector<char>> a(2, vector<char>(3));
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (a[i][j] != a[1 - i][2 - j]) {
				cout << "NO\n";
				return 0;
			}
		}
	}
	cout << "YES\n";
 	return 0;
}


Measured memory_bytes: 256