akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n; n *= 2;
	vi v(n); rep(i, n) cin >> v[i];
	sort(all(v));
	int ans = 0;
	for(int i = n - 1; i > 0; i -= 2){
		ans += v[i - 1];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
  int n;
  cin >> n;
  ll a,b;
  cin >> a >> b;
  ll ans=0;
  vector<ll> d(n+1);
  rep(i,n) cin >> d.at(i+1);
  for (int i=2;i<n+1;i++){
    if ((d.at(i)-d.at(i-1))*a<b) {
      ans+=(d.at(i)-d.at(i-1))*a;
    } 
    else ans+=b;
  }
  cout << ans << endl;
  }

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

vector<int> a;

int partition(int p, int r){
  int x = a[r];
  int i = p - 1;
  int dummy;

  for(int j = p; j < r; j++){

    if(a[j] <= x){
      i++;
      dummy = a[i];
      a[i] = a[j];
      a[j] = dummy;
    }
  }
    
    dummy = a[i+1];
    a[i+1] = a[r];
    a[r] = dummy;
  
  return i+1;
  
}

int main()
{
  int n;
  cin >> n;
  a.resize(n+5);

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

  int q = partition(0, n-1);

  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    
    if(i == q) cout << "[" << a[i] << "]";

    else cout << a[i];

  }

  cout << endl;

  return 0;

}


Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a,b,c,bufa;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		if(a>b){
			bufa = a;
			a = b;
			b = bufa;
		}
		if(b>c){
			bufa = c;
			c = b;
			b = bufa;
		}
		if(a>b){
			bufa = a;
			a = b;
			b = bufa;
		}
		System.out.println(a+" "+b+" "+c);
	}

}

Measured memory_bytes: 26120
import sys
input = sys.stdin.readline

D = int(input())
cost = list(map(int, input().strip().split()))
S = [list(map(int, input().strip().split())) for _ in range(D)]

last_held = [-1 for i in range(26)]
ans = []
for date, daily_scores in enumerate(S):
    minus_score = 0
    for i in range(26):
        minus_score += cost[i] * (date - last_held[i])

    max_score = daily_scores[0] + cost[0] * (date - last_held[0])
    max_index = 0
    for i, daily_score in enumerate(daily_scores):
        tmp = daily_score + cost[i] * (date - last_held[i])
        if max_score < tmp:
            max_index = i
            max_score = tmp
    if max_score <= minus_score:
        tmp = 0
        max_index = 0
        for i in range(26):
           if tmp < cost[i] * (date - last_held[i]):
               tmp = cost[i] * (date - last_held[i])
               max_index = i
    last_held[max_index] = date
    ans.append(max_index+1)
print("\n".join(map(str, ans)))


Measured memory_bytes: 68612
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

const int N = 1001;

int lcs(string x, string y)
{
	vector<vector<int>> c(N, vector<int>(N));

	int m = x.size();
	int n = y.size();

	int maxl = 0;

	x = " " + x;
	y = " " + y;

	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (x.at(i) == y.at(j))
			{
				c.at(i).at(j) = c.at(i - 1).at(j - 1) + 1;
			}
			else
			{
				c.at(i).at(j) = max(c.at(i).at(j - 1), c.at(i - 1).at(j));
			}

			maxl = max(maxl, c.at(i).at(j));
		}
	}

	return maxl;
}

int main()
{
	int n;
	for (cin >> n; n--;)
	{
		string s0, s1;
		cin >> s0 >> s1;

		cout << lcs(s0, s1) << endl;
	}
}


Measured memory_bytes: 6796
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> vec(N, 0);
  for(int i=0; i<N; i++){
    cin>>vec.at(i);
  }
  int ans=0;
  sort(vec.begin(), vec.end());
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      if(vec.at(i)==vec.at(j)){
        continue;
      }
      for(int k=j+1; k<N; k++){
        if(vec.at(j)==vec.at(k)||vec.at(i)==vec.at(k)){
        continue;
        }
        if(vec.at(i)+vec.at(j)>vec.at(k)){
         // cout<<vec.at(i)<<vec.at(j)<<vec.at(k)<<endl;
          ans++;
        }
      }
    }
  }
 cout<<ans<<endl;
}

Measured memory_bytes: 3644
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;
ll arr[200005],l[200005],r[200005];

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}
    
void cal(ll n)
{
	ll i;
	for(i=0;i<n;i++)
	{
		l[i]++;
		l[min(n,i+1+v[i])]--;
	}
	for(i=n-1;i>=0;i--)
	{
		r[i]++;
		if(i-1-v[i]>=0)
		r[i-1-v[i]]--;
	}
//	cout << "l,r\n";
//	for(i=0;i<n;i++)
//		cout << l[i] << " ";
//	cout << endl;
//	for(i=0;i<n;i++)
//		cout << r[i] << " ";
//	cout << endl;
	ll cnt=0;
	for(i=0;i<n;i++)
	{
		cnt+=l[i];
		arr[i]=cnt;
	}
	cnt=0;
	for(i=n-1;i>=0;i--)
	{
		cnt+=r[i];
		v[i]=arr[i]+cnt-1;
		l[i]=r[i]=0;
	}
	l[n]=r[n]=0;
}

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

	ll n,i,m,j,k,x,y,a,b,t,w;
	string s;
	
	cin >> n >> k;
	for(i=0;i<n;i++)
	{
		cin >> x;
		v.pb(x);
	}
	bool tr=true;
	while(k && tr)
	{
		cal(n);
		for(i=0;i<n;i++)
			if(v[i]<n)
				break;
		if(i==n)
			tr=false;
		k--;
	}
	for(i=0;i<n;i++)
		cout << v[i] << " ";

	return 0;
}


Measured memory_bytes: 9548
#include<iostream>
using namespace std;
int main(){
	int n,x,l[100],i,j,b=0;
	cin>>n>>x;
	for(i=0;i<n;i++)cin>>l[i];
	for(i=0;i<n;i++){
		b+=l[i];
		if(x<b)break;
	}
	cout<<i+1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> void chmax(Type_a &a,const Type_b &b){if(a<b)a=b;}
template<class Type_a,class Type_b> void chmin(Type_a &a,const Type_b &b){if(a>b)a=b;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int h,w;
	cin>>h>>w;
	
	int c[10][10];
	REP(i,10)REP(j,10) cin>>c[i][j];
	
	vvi a(h,vi(w));
	REP(i,h)REP(j,w) cin>>a[i][j];
	
	REP(k,10)REP(i,10)REP(j,10){
		chmin(c[i][j],c[i][k]+c[k][j]);
	}
	
	int ans=0;
	REP(i,h)REP(j,w){
		if(a[i][j]==-1) continue;
		ans+=c[a[i][j]][1];
	}
	
	cout<<ans<<endl;
}

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

int main(){
  
  vector<char> ans(500010, 'Z');
  //最後に出力する配列（出力しない部分は適当な文字で埋める）
  
  int start = 200000;
  //ans[start]からSを入れていく
  string S;
  cin >> S;
  int cnt = 0;
  for( int i = start; i < start + S.size(); i++ ){
    ans.at(i) = S.at(cnt);
    cnt++;
  }
  
  int Q;
  cin >> Q;
  
  int prev = 199999;
  int next = start + S.size();
  
  bool fg = 1;
  //1のとき通常、0のとき反転
  for( int i = 0; i < Q; ++i ){
    int T;
    cin >> T;
    if( T == 1 ){
      if( fg ) fg = 0;
      else fg = 1;
    }
    
    else if( T == 2 ){
      int F;
      cin >> F;
      char C;
      cin >> C;
      if( F == 1 ){ 
        if( fg ){
          ans.at(prev) = C;
          prev--;
        }
        else{
          ans.at(next) = C;
          next++;
        }
      }else if( F == 2 ){ 
        if( fg ){
          ans.at(next) = C;
          next++;
        }else{
          ans.at(prev) = C;
          prev--;
        }
      }
    }
  }
  
  //出力
  if( fg ){
    for( int i = 0; i < ans.size(); i++ ){
      if( ans.at(i) == 'Z' ) continue; //空白の時は出力しない
      cout << ans.at(i);
    }
    cout << endl;
  }
  else{
    for( int i = ans.size()-1; i >= 0; i-- ){
      if( ans.at(i) == 'Z' ) continue;
      cout << ans.at(i);
    }
    cout << endl;
  }
  
}


Measured memory_bytes: 1280
package main

import (
  "fmt"
  "math"
)


func foo(n, a int) int {
  if a >= n {
    return 1
  } else {
    v := float64(n) / float64(a)
    return int(math.Ceil(v))
  }
}

func main() {
  var n, a int
  fmt.Scan(&n)
  fmt.Scan(&a)
  fmt.Println(foo(n, a))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  vec A(N);
  rep(i,N){
    cin >> A.at(i);
  }
  sort(all(A));
  reverse(all(A));
  ll ans=0;
  rep(i,N-1){
    ans+=A.at((i+1)/2);
  }
  cout << ans << endl;
}
          
          
        
  

Measured memory_bytes: 4784
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

const int N = 1000001;
int eulerPhi(int n) {
  static int lookup = 0, p[N], f[N];
  if (!lookup) {
    REP(i,N) p[i] = 1, f[i] = i;
    for (int i = 2; i < N; ++i) {
      if (p[i]) {
        f[i] -= f[i] / i;
        for (int j = i+i; j < N; j+=i)
          p[j] = 0, f[j] -= f[j] / i;
      }
    }
    lookup = 1;
  }
  return f[n];
}

int main() {
  int t;
  cin >> t;
  long long table[1000001];
  table[0] = 0;
  REP(i, 1000000) {
    table[i+1] = table[i] + eulerPhi(i+1);
  }
  while(t--) {
    int n;
    cin >> n;
    cout << table[n]+1 << endl;
  }
}

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

template <class T>
inline void read(T &res)
{
	res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	if (bo) res = ~res + 1;
}

template <class T>
inline T Min(const T &a, const T &b) {return a < b ? a : b;}

template <class T>
inline T Max(const T &a, const T &b) {return a > b ? a : b;}

typedef long double ld;

const int N = 8, M = 305, T = 34;

int n, C, l[N], p[N], f[M][M][T];
ld ans;

int main()
{
	read(n); read(C);
	for (int i = 1; i <= n; i++) read(l[i]), p[i] = i;
	std::sort(l + 1, l + n + 1);
	do
	{
		memset(f, 0, sizeof(f));
		f[0][l[n] * n][0] = 1;
		for (int i = 1; i < n * C; i++)
			for (int j = i; j <= n * C; j++)
				for (int S = 0; S < (1 << n - 1); S++)
				{
					f[i][j][S] += f[i - 1][j][S];
					int x = i % n; if (!x || ((S >> x - 1) & 1)) continue;
					f[i][Min(n * C, Max(j, i + l[p[x]] * n))]
						[S | (1 << x - 1)] += f[i - 1][j][S];
				}
		ans += f[n * C - 1][n * C][(1 << n - 1) - 1];
	} while (std::next_permutation(p + 1, p + n));
	for (int i = 1; i < n; i++) ans /= i * C;
	return printf("%.16Lf\n", ans), 0;
}

Measured memory_bytes: 12544
// abc123_b
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
	vector<int> A(5);
	for (int i = 0; i < 5; i++) {
		cin >> A[i];
	}
	vector<int> P = { 0,1,2,3,4 };
	int final_answer = 9999;
	do {
		int ans = 0;
		for (int i = 0; i < 5; i++) {
			while (ans % 10 != 0) {
				ans += 1;
			}
			ans += A[P[i]];
		}
		final_answer = min(final_answer, ans);
	} while (next_permutation(P.begin(), P.end()));
	cout << final_answer << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Not so Diverse
            var line = ReadLine();
            int N = line[0];
            int K = line[1];
            var A = ReadLine();

            var balls = new Dictionary<int, int>();

            foreach(var Ai in A)
            {
                if (!balls.ContainsKey(Ai))
                {
                    balls.Add(Ai, 1);
                }
                else
                {
                    balls[Ai]++;
                }
            }

            var query = balls.OrderByDescending(x => x.Value).Skip(K);

            Console.WriteLine(query.Sum(x => x.Value));
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 42576
#include<cstdio>
#include<cstring>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<int,int>P;
vector<int>R[105];

int f(int s,int t,int v)
{
	int flg[105][105],r=-1;
	memset(flg,0x7f,sizeof(flg));
	priority_queue<P>Q;
	Q.push(P(1,s));
	flg[s][s]=0;
	for(;!Q.empty();)
	{
		P now=Q.top();Q.pop();
		if(now.second==t)
		{
			if(r==-1)r=now.first;
			else r=min(r,now.first);
			continue;
		}
		now.first++;
		if(now.first>v)continue;
		int n=now.second;
		for(int i=0;i<R[n].size();i++)
		{
			if(flg[s][R[n][i]]>now.first)
			{
				flg[s][R[n][i]]=now.first;
				Q.push(P(now.first,R[n][i]));
			}
		}
	}
	return r;
}

int main()
{
	int N,M,s,t,v,r;
	scanf("%d",&N);
	for(;N--;)
	{
		scanf("%d%d",&s,&t);
		for(;t--;)
		{
			scanf("%d",&v);
			R[s].push_back(v);
		}
	}
	scanf("%d",&M);
	for(;M--;)
	{
		scanf("%d%d%d",&s,&t,&v);
		r=f(s,t,v);
		if(r!=-1)printf("%d\n",r);
		else puts("NA");
	}
}

Measured memory_bytes: 1116
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
import math

#def main(N):
def main():
    N = int(input())
    # Nが1のときは答えは0
    if N == 1:
        return 0
    else:
        N_remein = N
        # Nを素因数分解する。
        p_list = []
        p_factor_list = []
        #p = 2
        #while N_remein >= 2:
        for p in range(2, math.ceil(math.sqrt(N))+1):
            if N_remein%p == 0:
                counter = 0
                #p_pow_counter = 1
                while True:
                    #p_pow_counter *= p
                    if N_remein%p == 0:
                        N_remein = N_remein//p
                        counter+=1
                    else:
                        p_list.append(p)
                        p_factor_list.append(counter)
                        break
        if N_remein != 1:
            p_list.append(N_remein)
            p_factor_list.append(1)
        #print(p_list)
        #print(p_factor_list)
        # Nが素数の場合は、答えは1。
        if not p_factor_list:
            return 1
        else:
            answer = 0
            # 各素因数の指数に対して、、
            # 1,2,3,...と正整数を順番に引いていき、
            # 引けた回数を合計する。
            for factor in p_factor_list:
                counter = 1
                while (counter*(counter+1))//2 <= factor:
                    counter += 1
                answer += (counter-1) 
            #return answer, p_list, p_factor_list
            return answer

if __name__ == "__main__":
    print(main())
    #for i in range(1, 100):
    #    print(i, main(i))



Measured memory_bytes: 9240
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N) {
  cout << (N-1)/2 << endl;
}

int main() {
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


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

signed main(){
#ifdef _DEBUG
	freopen("_in" , "r", stdin );
	//freopen("_out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int a, b; cin >> a >> b;
	if (a >= 1 && a <= 9 && b >= 1 && b <= 9) cout << a * b << '\n';
	else cout << -1 << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100010];
int main() {
	ll n,k,q;
	cin>>n>>k>>q;
	for(int i=0;i<q;i++){
		ll x;
		cin>>x;
		x--;
		a[x]++;
	}
	for(ll i=0;i<n;i++){
		a[i]+=k-q;
		if(a[i]>0){
			cout << "Yes";
		}
		else{
			cout << "No";
		}
		cout << endl;
	}
	// your code goes hereSunny)、くもり(Cloudy)、雨(Rainy)、
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;
 
#define forl(i,a,b) for (int i = a; i <= b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    vector <ull> a(n);
    ull pr = 1; bool iso = false;
    forl(i,0,n-1) {
        cin>>a[i];
        pr*=(ull)a[i];
        if(a[i]==0) iso = true;
    }
    if((pr>(ull)(pow(10,18)) || pr==0) && !iso) {
        cout<<-1<<"\n"; return 0;
    }
    cout<<pr<<"\n";
    return 0;    
}

Measured memory_bytes: 3988
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var H = myconv(input[0],4)[0];
  var W = myconv(input[0],4)[1];
  var N = myconv(input[1],1);
  var list = myconv(input[2],4);
  
  var output = new Array(H);
  for(var i = 0; i < H; i++){
    output[i] = new Array(W);
  }
  
  var getNo = 1;
  for(var i = 0; i < H; i++){
    if(i % 2 == 0){
    for(var j = 0; j < W; j++){
      if(list[getNo-1] == 0){
        getNo++;
      }
      list[getNo-1]--;
      output[i][j] = getNo;
    }
  	}else{
    for(var j = W-1; j >= 0; j--){
      if(list[getNo-1] == 0){
        getNo++;
      }
      list[getNo-1]--;
      output[i][j] = getNo;
    }  
    }
  }
  for(var i = 0; i < H; i++){
    output[i] = output[i].join(" ");
  }
  myout(output.join("\n"));
}

Main(myin());


Measured memory_bytes: 8140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

ll max(ll a, ll b){
    if (a > b) return a;
    else return b;
}

int num_divisor(int num){
    int res = 0;
    for(int i = 1; i * i <= num; i++){
        if (num % i == 0){
            res++;
            if(i * i != num) res++;
        }
    }
    return res;
}

ll solve(ll N, ll M){
    ll ans = 1;
    for(int i = 1; i * i <= M; i++){
        if (M % i != 0) continue;
        if (M / i >= N) ans = max(ans, i);
        if (i >= N)     ans = max(ans, M / i);
    }
    return ans;
}

int main(void){
    int N; cin >> N;
    
    map<int, int> kuku;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            kuku[i * j]++;
        }
    }
    if (kuku[N] != 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

ans=0
for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        ans+=i

print(ans)


Measured memory_bytes: 27120
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vector<int> x(N),y(M);
  int xmax= -1000;
  int xmin= 1000;
  int ymax= -1000;
  int ymin= 1000;
  for(int i=0;i<N;i++){
    cin>>x.at(i);
    xmax=max(xmax,x.at(i));
    xmin=min(xmin,x.at(i));
  }
  for(int i=0;i<M;i++){
    cin>>y.at(i);
    ymax=max(ymax,y.at(i));
    ymin=min(ymin,y.at(i));
  }
  if(max(X,xmax)<min(Y,ymin)||min(X,xmin)>max(Y,ymax)) cout<<"No War"<<endl;
  else cout<<"War"<<endl;
}


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

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

    int H, W, h, w;
    cin >> H >> W >> h >> w;
    
    int ans = H * W - h * W - w * H + h * w;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
    int W, H;
    
    while(true) {
        cin >> H >> W;
        if(H == 0 && W == 0)   break;
        for(int h = 0; h < H; ++h) {
            for(int w = 0; w < W; ++w) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m; cin >> n >> m;
	ll h[n]; zep(i, 0, n)cin >> h[i];
	vector<bool> ok(n, 1); 
	
	zep(i, 0, m){
		ll a, b; cin >> a >> b;
		a--; b--;
		
		if(h[a] <= h[b])ok[a] = false;
		if(h[b] <= h[a])ok[b] = false;
	}
	
	ll ans = 0;
	zep(i, 0, n)if(ok[i])ans++;
	print(ans)
	return 0;
}

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

int main() {
	int ans = 0;
	string s;
	cin >> s;
	s.pop_back();
	while (s.size() >= 2) {
		int j = 0;
		while (s.size() >= 2) {
			if (s.size() % 2 == 1) break;
			if (s[j] != s[s.size() / 2 + j]) {
				break;
			}
			j++;
		}
		if (j == s.size() / 2) ans = max(ans, (int)s.size());
		s.pop_back();
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll x,cnt=0,y=100;
    cin>>x;
    while(y<x){
    	y= y+y/100;
    	cnt ++;
    }
    cout<<cnt;
 	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int main() {
    int ans = 1000000000;

    vector<int> a(5);
    rep(i, 0, 5) cin >> a[i];

    vector<int> v(5);
    rep(i, 0, 5) v[i] = i;

    do {
        int time = 0;
        for(auto x : v) {
            if (time % 10 == 0) time += a[x];
            else {
                time += 10 - time % 10 + a[x];
            }
        }
        ans = min(ans, time);
    } while( next_permutation(v.begin(), v.end()) );
    cout << ans << endl;
}

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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;


void solve(){
   ll n;
   cin >> n;
   ll cnt=0;
   ll ans=0;
   vector<int> v(10);
   for(int i=0;i<10;i++){
     if(i)v[i]=i+1 + v[i-1];
   }
   for(ll i=2;i*i<=n;i++){
     ll cnt=0;
        while(n%i==0){
         n/=i;
         cnt++;
       }
      if(cnt){
        int j = 1;
        while(cnt>0){
           cnt-=(j);
           if(cnt>=0)ans++;
           j++;
        }
      }
   }
   if(n>1){
      ans++;
   }
cout << ans;
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	double l;
	cin>>l;
	cout<<setprecision(16)<<l/3*l/3*l/3<<endl;
}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

ll n, a, b;

bool read() {
    if (!(cin >> n >> a >> b))
        return false;

    return true;
}

void solve() {
    ll x = max(0ll, a + b - n);
    ll y = min(a, b);
    cout << y << ' ' << x << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 256
def main():
    n = int(input())
    H = []
    ans = 0
    X = []
    Y = []
    a = 0
    tmpx = 0
    tmpy = 0
    for _ in range(n):
        x,y,h = map(int,input().split())
        X.append(x)
        Y.append(y)
        H.append(h)
        if h != 0:
            tmpx = x
            tmpy = y
            tmph = h

    for x in range(101):
        for y in range(101):
            flg = True
            h = tmph + abs(x-tmpx) + abs(tmpy-y)
            for i in range(n):
                hh = max(h - abs(x-X[i]) - abs(y - Y[i]), 0)
                if hh != H[i]:
                    flg = False
                    break
            if flg:
                print(x,y,h)
                return
if __name__ == '__main__':
    main()


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

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

	int N;cin>>N;
	string s;cin>>s;
	int size=s.length();
	string ans="";
	for(int i=0;i<size;++i){
		char c=s[i]+N;
		if(c-'A'>=26){
		  	int shift = c-'Z';
		  	c='A'+shift-1;
		}
		ans.push_back(c);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	vector<int> B(n);
	set<pair<int, int>> st;
	for (int i = 0; i < n; i++) {
		cin >> B[i];
		st.insert({B[i], i});
	}
	ll ans = 0;
	while(!st.empty()) {
		auto it = prev(st.end());
		if (A[it->ss] == B[it->ss]) {
			st.erase(it);
		}
		else {
			int i = it->ss;
			int val = B[i] - (B[(i + 1) % n] + B[(i - 1 + n) % n]);
			if (val < A[i]) {
				cout << -1;
				return 0;
			}
			else {
				int mx = max(B[(i + 1) % n], B[(i - 1 + n) % n]);
				int sum = (B[(i + 1) % n] + B[(i - 1 + n) % n]);
				ans += max(1, ((B[i] - max(A[i], mx)) / sum));
				B[i] -= max(sum, ((B[i] - max(A[i], mx)) / sum) * sum);
				st.insert({B[i], i});
				st.erase(it);
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX 10000005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
vector<int> primes;
ll sumprime[MAX];
bool is_prime[MAX];
void sieve(){
    is_prime[0]=is_prime[1]=true;
    for(int i=4;i<MAX;i+=2){
        is_prime[i]=true;
    }
    for(int i=3;i*i<MAX;i+=2){
        if(!is_prime[i]){
            for(int j=i*i;j<MAX;j+=i){
                is_prime[j]=true;
            }
        }
    }
    for(int i=0;i<MAX;i++){
        if(!is_prime[i]){
            sumprime[i]=sumprime[i-1]+i;
        }else{
            sumprime[i]=sumprime[i-1];
        }
    }
}
*/
int weight[100],value[100];

int dp[100][100001];

using namespace std;
int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    //cin>>t;
    for(int tc=1;tc<=t;tc++){
        int n,w;
        cin>>n>>w;
        for(int i=0;i<n;i++){
            cin>>weight[i]>>value[i];
        }
        dp[0][0]=0;
        dp[0][weight[0]]=value[0];
        for(int i=1;i<n;i++){
            dp[i][0]=0;
            for(int j=1;j<=w;j++){
                dp[i][j]=dp[i-1][j];
                if(j>=weight[i]){
                    dp[i][j]=max(dp[i][j],value[i]+dp[i-1][j-weight[i]]);
                }
            }
        }
        int ans=INT_MIN;
        for(int i=0;i<=w;i++){
            ans=max(ans,dp[n-1][i]);
        }
        cout<<ans<<'\n';

    }
    
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 80940
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,m,a[1000];
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        for(int j=0;j<n-1;j++){
            if((a[j]%i)>(a[j+1]%i)){
                swap(a[j],a[j+1]);
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define lambda(res, ...) (function<res(__VA_ARGS__)>)[&](__VA_ARGS__)->res
#define method(name, res, ...)                                                 \
  function<res(__VA_ARGS__)> name = lambda(res, __VA_ARGS__)
#define foreach(i,n) for(auto&i:(n))

using namespace std;

int main(){
  string str;
  cin >> str;
  map<char,int> m;
  int n = 0;
  foreach(i,str){
    if('a'<=i and i <= 'z')++n;
  }

  for(int i=0;i<n;++i){
    char ch;
    int num;
    cin >> ch >> num;
    m[ch] = num;
  }

  method(func,int,string str){
    if(str.size()==1){
      return m[str[0]];
    }
    int pos;
    int nest = 0;
    for(int i=0;i<str.size();++i){
      if(str[i]=='[')++nest;
      if(str[i]==']')--nest;
      if(nest==1 and str[i]=='-'){
        pos = i;
        break;
      }
    }
    int a = func(str.substr(1,pos-1));
    int b = func(str.substr(pos+1, str.size()-pos-2));
    if(min(a,b) or max(a,b)==0){
      cout << "No" << endl;
      exit(0);
    }
    return max(a,b) - 1;
  };

  cout << (func(str)?"No":"Yes") << endl;
  return 0;
}



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

int main(){
  constexpr char sheep= 'S';
  constexpr char wolf = 'W';
  const vector<pair<char, char>> search= {make_pair(sheep, sheep)
                                         ,make_pair(sheep, wolf )
                                         ,make_pair(wolf , sheep)
                                         ,make_pair(wolf , wolf ) };
  int N;
  string S;
  cin >> N >> S;

  auto guess= [&](const string &cand, int pivot){
    int opponent= (pivot==0) ? 1
                             : pivot- 1;
    char flip= cand.at(opponent) ^ sheep ^ wolf;
    char ret= (cand.at(pivot)==sheep) ? (S.at(pivot)=='o') ? cand.at(opponent)
                                                           : flip
                                      : (S.at(pivot)=='o') ? flip
                                                           : cand.at(opponent);
    return ret;
  };

  string ans= "-1";
  for(auto [a0,a1]:search){
    string cand= string(N, 'X');
    cand.at(0)= a0;
    cand.at(1)= a1;
    char guess_back= guess(cand, 0);
    for(int pivot=1; pivot+1 < N; pivot++){
      cand.at(pivot+1)= guess(cand, pivot);
    }
    char guess_head= guess(cand, N-1);

    if(guess_back==cand.back() && guess_head==cand.at(0)){
      ans= cand;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;

int main(){
    int n;  cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    map<ll, int> mp;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(mp.find(a[i]) == mp.end()){
            mp[a[i]] = 1;
        }
        else{
            mp[a[i]]++;
        }
    }

    sort(a.begin(), a.end());

    int res = 0;
    for(int i = n-1; i >= 0; i--){
        ll x = 1;
        if(mp[a[i]] == 0)   continue;

        while(x <= a[i]){
            x *= 2;
        }
        b[i] = x - a[i];
        if(b[i] == a[i]){
            if(mp[a[i]] >= 2){
                mp[a[i]] -= 2;
                res++;
            }
        }
        else{
            if(mp[b[i]] >= 1){
                res++;
                mp[a[i]]--;
                mp[b[i]]--;
            }
        }
    }

    cout << res << endl;



    return 0;
}


Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
    lint n, k;
    cin >> n >> k;

    vector<lint> h(n);
    for(auto& e : h)  cin >> e;

    lint ans = 0;
    for(auto& e : h) {
        if(e >= k)  ans++;
    }

    cout << ans << endl;
}

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

int main() {
    int R;
    cin >> R;
    if (R < 1200) cout << "ABC" << endl;
    else if (R <2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdio>
#include<sstream>
#include<vector>
#include<algorithm>

using namespace std;
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define pii pair<int,int>
#define INF 1e13
#define ll long long
const ll mod = 2333;
const int N = 1e5 + 10;
const int M = 2e6 + 1005;
using namespace std;
map<pii,int> hap;
struct Edge
{
    int next;
    int to;
}edge[N*2];
int deg[N];
int head[N],tot;
inline void add(int from,int to){
    edge[++tot].next= head[from];
    edge[tot].to = to;
    head[from] = tot;
    deg[to] ++;
}
inline void init(){
    mmt(head,-1);
    tot = 0;
}
void dfs(int root,int fa,int color,int color_num){
    for(int i = head[root];~i;i = edge[i].next){
        int y = edge[i].to;
        if(y != fa){
           // cout<<"y: "<<y<< " "<<" c  "<<color<<endl;
            hap[{root,y}] = hap[{y,root}] = color;
            color = (++color)%color_num;
            dfs(y,root,color,color_num);
        }
    }
   // cout<<"UES"<<endl;
}
pii res[N];
int main()
{
    init();
    int n;
    read(n);

    int u,v;
    for(int i = 1;i <= n - 1;++i){
        Read(u,v);//重边？
        add(u,v);
        add(v,u);
        res[i].first = u;res[i].second = v;
    }
    int root;
    int MAX = -1;
    for(int i = 1;i <= n;++i){
        if(MAX < deg[i]){
           MAX = deg[i];
           root = i;
        }
    }
    cout<<MAX<<endl;
    //cout<<root;
   // return 0;
    dfs(root,-1,0,MAX);
    for(int i = 1;i <= n - 1;++i){
        cout<<hap[res[i]] +1<<endl;
    }
}


Measured memory_bytes: 18816
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)44e15;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	llint n,gen=0,i;cin>>n;
	vector<llint>a(n);for(i=0;i<n;i++){cin>>a[i];}
	vector<llint>b(n);for(i=0;i<n;i++){cin>>b[i];}
	for(i=0;i<n;i++){
		if(b[i]>a[i]){gen+=(b[i]-a[i])/2;}
		else{gen+=b[i]-a[i];}
	}
	if(gen<0){cout<<"No"<<endl;RE;}
	cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using IP = pair<int, int>;


#define INF 999999999
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

int main() {
	
	int cnt = 0;
	int l = 0, r;
	string s;
	cin >> s;

	r = s.length() -1;
	while(l<r){
		if (s[l] == s[r]) {
			l++;
			r--;
		}
		else if (s[l] == 'x') {
			cnt++;
			l++;
		}
		else if (s[r] == 'x') {
			cnt++;
			r--;
		}
		else{
			cout << "-1" << Endl;
			return 0;
		}
	}

	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long N, W;
vector<long long> Weights, Values;

void read() {
  cin >> N >> W;
  int w, v;
  for (int i = 0; i < N; i++) {
    cin >> w >> v;
    Weights.push_back(w);
    Values.push_back(v);
  }
}

int main() {
  read();

  vector<vector<long long>> DP;
  vector<long long> row;
  for (long long w = 0; w <= W; w++) row.push_back(0);
  DP.push_back(row);
  for (int i = 0; i < N; i++) {
    vector<long long> row;
    // copy the prev vector
    for (long long w = 0; w <= W; w++) row.push_back(DP.at(i).at(w));
    // overwrite the vector if we have a better option
    for (long long w = W; w >= 0; w--) {
      long long new_w = w + Weights.at(i);
      if (new_w <= W) {
        row.at(new_w) = max(row.at(new_w), row.at(w) + Values.at(i));
      }
    }
    DP.push_back(row);
  }

  cout << DP.back().back() << endl;
}


Measured memory_bytes: 81000
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    set<int> st;
    for(int i = 1;i <= n;i++){
        if(i*(i+1)/2>= n){
            for(int j = 1;j <= i;j++)st.insert(j);
            break;
        }
    }
    int tmp = *st.rbegin();

    st.erase(tmp*(tmp+1)/2 - n);
    for(auto p:st)cout <<p << " ";
    return 0;
}

Measured memory_bytes: 3812