akhauriyash/Code-Regression huggingface dataset:
A, B, K = map(int, input().split())

l1 = list(range(A,min(B+1,A+K)))
l2_lower = max(A,(B+1) - K)
l2 = list(range(l2_lower, B+1))
for n in sorted(list(set(l1+l2))):
    print(n)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int cnt;
vector<int> a;
void insertionsort(vector<int> &a,int n,int g){
  int v,i,j,k;
  for(i=g;i<n;i++){
    v=a[i];
    j=i-g;
    while(j>=0&&a[j]>v){
      a[j+g]=a[j];
      j=j-g;
      cnt++;
    }
    a[j+g]=v;
  }
  //  cout<<"insert:"<<&a<<endl;
}
vector<int> shellsort(vector<int> &a,int n){
  cnt = 0;
  int m,i;
  vector<int>g;
  for(i=1;i<n+1;i=i*3+1){
    g.push_back(i);
    //cout<<g[i]<<endl;
  }
  m=g.size();
  for(int i=m-1;i>=0;i--){
    insertionsort(a,n,g[i]);
  }
  //cout<<"@"<<m<<endl;
  // cout<<"shell:"<<&a<<endl;
  return g;
}

int main(){
  int m,n,tmp,i;
  vector<int>a;
  vector<int>g;
  cin>>n;
  for(i=0;i<n; i++){
    cin>>tmp;
    a.push_back(tmp);
  }
  //cout<<"main:"<<&a<<endl;
  g=shellsort(a,n);
  m=g.size(); 
  cout<<m<<endl;
  if(m>1){
    for(i=m-1;i>0;i--){
      cout<<g[i]<<" ";
    }
  }
  //cout<<"finished:"<<i<<endl;
  cout<<g[0]<<endl;
  cout<<cnt<<endl;
  for(i=0;i<n;i++)cout<<a[i]<<endl;
 
  return 0;
}



Measured memory_bytes: 7060
#include <stdio.h>
int main(){
  int count,i,j,n,y,m,d,M[11]={0,21,20,21,20,21,20,21,20,21,20};
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    count=0;
    scanf("%d%d%d",&y,&m,&d);
     
    while(1){
      if(y%3!=0){
    count++;
    d++;
    if(d==M[m]){
      m++;
      d=1;
    }
    if(m==11){
      m=1;
      y++;
    }
    if(y==1000&&m==1&&d==1){
      break;
    }
      }else{
    count++;
        d++;
        if(m%2==0){
      if(d==M[m]+1){
        m++;
        d=1;
      }
      if(m==11){
        m=1;
        y++;
      }
      if(y==1000&&m==1&&d==1){
        break;
      }
    }else{
      if(d==M[m]){
        m++;
        d=1;
      }
      if(m==11){
        m=1;
        y++;
      }
      if(y==1000&&m==1&&d==1){
        break;
      }
    }
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
bool ok(vector<int>v)
{
	for(int i=1;i<v.size();i++)
	{
		if(v[i]-v[i-1] != v[1]-v[0]) return false;
	}
	return true;
}
int main()
{
	while(1)
	{
		int n;
		int a[105];
		cin >> n; n++;
		if(n == 1) return 0;
		for(int i=0;i<n;i++) cin >> a[i];
		//cout << n << endl;
		for(int res=0;res<n;res++)
		{
			vector<int>vec; vec.clear();
			for(int i=0;i<n;i++) if(res != i) vec.pb(a[i]);
			if(ok(vec))
			{
				cout << a[res] << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
int gcd(Int a, Int b) {
 return b != 0 ? gcd(b, a % b) : a;
}
int lcm(Int a, Int b) {
 return a / gcd(a, b)*b;
}
int main(){
  int a;cin >> a;
  string s;cin >> s;
  cout << (a>=3200?s:"red") << endl;
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; 0 <= i; i--)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A(N); REP(i, N) cin >> A[i]
#define ANS(ans) cout << (ans) << endl
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DEBUGV(V) REP(i, V.size()) cout << V.at(i) << " "; cout << endl 

int
main()
{
  CIN2(N, K);

  int num = 1;
  REP(i, N) 
    if (num * 2 < num + K) num *= 2;
    else num += K;

  ANS(num);

  return 0;
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

void solve(long long N, long long Q, std::vector<long long> t, std::vector<long long> u, std::vector<long long> v) {
  auto dsu = atcoder::dsu(N);
  REP(i, Q) {
    if (t[i] == 0) {
      dsu.merge(u[i], v[i]);
    } else {
      cout << (dsu.same(u[i], v[i]) ? 1 : 0) << endl;
    }
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long Q;
  scanf("%lld", &Q);
  std::vector<long long> t(Q);
  std::vector<long long> u(Q);
  std::vector<long long> v(Q);
  for (int i = 0; i < Q; i++) {
    scanf("%lld", &t[i]);
    scanf("%lld", &u[i]);
    scanf("%lld", &v[i]);
  }
  solve(N, Q, std::move(t), std::move(u), std::move(v));
  return 0;
}


Measured memory_bytes: 8224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    string o,e,ans;
    cin >> o >> e;
    rep(i, o.size()){
        cout << o[i];
        if(i < e.size()) cout << e[i];
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-9
#define MOD 1000000007
#define int long long
using namespace __gnu_pbds;
using namespace std;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ost;
#define INF 10000000000


int32_t main(){
	int n;
	cin >> n;
	vector<int> dp(3,0);
	for(int i = 0; i < n; i++){
		int x[3];
		for(int i = 0; i < 3; i++)
			cin >> x[i];
		vector<int> temp(3,0);
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(k == j)
					continue;
				temp[j] = max(temp[j],dp[k]+x[j]);
			}
		}
		dp = temp;
	}
	cout << max({dp[0],dp[1],dp[2]});
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	ll a1, a2, a3, m1, m2, m3;
	
	while (cin>>a1>>m1>>a2>>m2>>a3>>m3, a1||m1||a2||m2||a3||m3)
	{
		ll x, y, z, a, b, c;
		a = b = c = x = y = z = 1;
		x = (x * a1) % m1;
		y = (y * a2) % m2;
		z = (z * a3) % m3;
		for (;x!=1;a++) x = (x * a1) % m1;
		for (;y!=1;b++) y = (y * a2) % m2;
		for (;z!=1;c++) z = (z * a3) % m3;
		ll ans = lcm(lcm(a, b), c);
		cout << ans << endl;
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

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

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1156
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 205;
const int mo = 998244353;

int n;
struct point{
	int x,y;
}a[N];
LL ans;
LL mi[N];

LL cross(point a,point b,point c){
	return 1ll*(c.x-a.x)*(b.y-a.y)-1ll*(b.x-a.x)*(c.y-a.y);
}

int main(){
	n=get();
	fo(i,1,n){a[i].x=get();a[i].y=get();}
	mi[0]=1;
	fo(i,1,n)mi[i]=mi[i-1]*2%mo;
	ans=(mi[n]+mo-1-n)%mo;
	fo(i,1,n)
		fo(j,i+1,n){
			int cnt=-2;
			int x1=min(a[i].x,a[j].x),x2=max(a[i].x,a[j].x),y1=min(a[i].y,a[j].y),y2=max(a[i].y,a[j].y);
			fo(x,1,n)
			if (cross(a[i],a[j],a[x])==0&&a[x].x>=x1&&a[x].x<=x2&&a[x].y>=y1&&a[x].y<=y2)cnt++;
			ans=(ans+mo-mi[cnt])%mo;
		}
	printf("%lld\n",ans);
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;


void solve(){
	ll n,ans=0;
	cin>>n;
	vll A(n);
	for(int i=0;i<n;i++) cin>>A[i],A[i]--;
	vector<bool> vis(n,false);
	for(int i=0;i<n;i++)
		if(!vis[i]){
			ll x=i,prev;
			while(!vis[x])
				vis[x]=true,prev=x,x=A[x];
			ans+=(A[x]==prev);
		}
	cout<<ans<<"\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	ll t;cin>>t;while(t--)
	solve();

}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n, num = 26;
    vector<int> alphabetList;
    cin >> n;
    while(n/num){
        alphabetList.push_back(n%num);
        if(n%num==0){
            n = n / num - 1;
        }else{
            n /= num;
        }
    }
    if(n!=0){
        alphabetList.push_back(n%num);
    }
    for(int i=alphabetList.size()-1; i>=0; i--){
        cout << (char)(96+(alphabetList[i] == 0 ? 26 : alphabetList[i]));
    }
    return 0;
}

Measured memory_bytes: 3652
MOD = 10**9 + 7
fac = [1 for k in range(200010)]
inv = [1 for k in range(200010)]
finv = [1 for k in range(200010)]
for k in range(2,200010):
    fac[k] = (fac[k-1]*k)%MOD
    inv[k] = (MOD - inv[MOD%k] * (MOD // k))%MOD
    finv[k] = (finv[k - 1] * inv[k]) % MOD;
def nCr(n,r):
    return (fac[n]*finv[r]*finv[n-r])%MOD

N, K = map(int,input().split())
A = sorted(list(map(int,input().split())))
m = 0
for k in range(N-K+1):
    m += A[k]*nCr(N-k-1,K-1)
    m %= MOD
A = A[::-1]
M = 0
for k in range(N-K+1):
    M += A[k]*nCr(N-k-1,K-1)
    M %= MOD
print(M-m if M>=m else M-m+MOD)


Measured memory_bytes: 43728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> v(n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j += i) {
			v[j]++;
		}
	}
	ll ans = 0;
	for (int i = i; i <= n; i++) {
		ans += (ll) i * v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 42304
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

int a[3000];
int32_t main()
{
    int n=in();
    for(int i=1;i<=n;i++) a[i]=in();
    sort(a+1,a+n+1);
    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            ans+=(upper_bound(a+j+1,a+n+1,a[i]+a[j]-1)-a)-j-1;
        }
    }
    pf1ll(ans);
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void input(vector<int> &);
int main() {
	int n, m;
	vector<int> table;
	int point[] = { 0,2 };
	int move[] = { 2,0,0 };
	while (cin >> n >> m&&n != 0) {
		table.resize(n + 1);
		input(table);
		int ans = (1 << 31) - 1;
		int df = 1;
		for (int i = 1; i < n; ++i) {
			df *= 3;
		}
		for (int i = 0; i < 2; ++i) {
			int stock = df;
			int place = point[i];
			int dnum = 0;
			for (int j = 1; j <= n; ++j) {
				if (abs(table[j]- place)==1) {
					dnum += stock;
					place = move[place];
				}
				else if (abs(table[j] - place)==2) {
					dnum += stock * 2;
				}
				stock /= 3;
			}
			ans = min(ans, dnum);
		}
		cout << (ans <= m ? ans : -1) << endl;
	}
	return 0;
}

void input(vector<int > &table) {
	for (int i = 0; i < 3; ++i) {
		int time;
		cin >> time;
		for (int j = 0; j < time; ++j) {
			int num;
			cin >> num;
			table[num] = i;
		}
	}
}

Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N), left(N - 1), right(N - 1), total(N);
    for (auto &i: A) cin >> i;
    left[0] = A[0];
    right[N - 2] = A[N - 1];
    int N2 = N - 2;
    for (int i = 1; i <= N2; i++)
    {
        left[i] = gcd(left[i - 1], A[i]);
        right[N2 - i] = gcd(right[N2 - i + 1], A[N2 - i + 1]);
    }
    total[0] = right[0];
    total[N - 1] = left[N2];
    for (int i = 1; i <= N2; i++) total[i] = gcd(left[i - 1], right[i]);
    for (auto i: left) cerr << i << " ";
    cerr << endl;
    for (auto i: right) cerr << i << " ";
    cerr << endl;
    for (auto i: total) cerr << i << " ";
    cerr << endl;
    int ans = 0;
    for (auto i: total) ans = max(ans, i);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
 #ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("outt.txt", "w", stdout);

#endif
  
   long long mod = 1000000007;


   int a,b,c;
   cin>>a>>b>>c;
   int sum= a+b+c;

   cout<<(sum>=22?"bust":"win");





return 0;
}

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

#define out(v) cout<<v<<"\n"
#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  long long Z, W; cin >> Z >> W;

  long long A[N];
  rep(i, N) cin >> A[i];

  if (N == 1)
    out(abs(A[0] - W));
  else
    out(max(abs(A[N-1] - W), abs(A[N-1] - A[N-2])));

  return 0;
}


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

using namespace std;

int N, a[100009];
long long s;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=0; i<N; i++)
    scanf ("%d", &a[i]), s += a[i];
long long u = 1LL * N * (N + 1) / 2;
if (s % u != 0 || s / u > 1e9)
{
    printf ("NO\n");
    return 0;
}
int steps = s / u;
for (int i=0; i<N; i++)
{
    int curr = a[(i + 1) % N] - a[i] - steps;
    if (curr % N != 0 || curr > 0)
    {
        printf ("NO\n");
        return 0;
    }
}
printf ("YES\n");
return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
int k,s,ans=0;
cin>>k>>s;
for (int i = 0; i <= k; i++)
{
    for (int j = 0; j <= k; j++)
    {
        if (k>=s-i-j&&s-i-j>=0)
        {
            ans++;
        }
        
     
    }
    
}
 cout<<ans<<endl;  
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, a[100005];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int now = 1, cnt = 0, ans1 = 0, ans2 = 0;
	for (int i = 0; i < n; i++, now *= -1) {
		cnt += a[i];
		if (now == 1 && cnt < 1) {
			ans1 += 1 - cnt;
			cnt = 1;
		}
		if (now == -1 && cnt > -1) {
			ans1 += cnt + 1;
			cnt = -1;
		}
	}
	now = -1, cnt = 0;
	for (int i = 0; i < n; i++, now *= -1) {
		cnt += a[i];
		if (now == -1 && cnt > -1) {
			ans2 += cnt + 1;
			cnt = -1;
		}
		if (now == 1 && cnt < 1) {
			ans2 += 1 - cnt;
			cnt = 1;
		}
	}
	cout << min(ans1, ans2) << endl;
	endre;
}


Measured memory_bytes: 1024
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut ab: Vec<(i32, i32)> = (0..n).map(|_| (read(), read())).collect();

    ab.sort_by_key(|k| k.1);

    let mut sum = 0;
    let mut flag = true;

    for (a, b) in ab {
        sum += a;
        if sum > b {
            flag = false;
            break;
        }
    }

    let ans = if flag { "Yes" } else { "No" };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int p = sc.nextInt();
		
		int all = 3 * a + p;
		boolean odd = true;
		
		odd = (all % 2 == 1);
		
		if(odd) {
			System.out.println((all-1)/2);
		}
		else {
			System.out.println(all/2);
		}

	}

}


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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}


int main(){

  int x,n;
  scanf("%d%d",&x,&n);

  if(n == 0){
    printf("%d",x);
    return 0;
  }

  int p[n];
  for(int i = 0; i < n; ++i){
    scanf("%d",p+i);
  }

  int flag;
  int tmp = 200;
  int ans = 200;
  for(int i = -100; i <= 101; ++i){
    flag = 0;
    if(i >= 0){
      for(int j = 0; j < n; ++j){
        if( i == p[j] ) flag = 1;
      }
    }

    if(flag == 0){
      if(tmp > abs(x-i)){
        tmp = min(tmp,abs(x-i));
        ans = i;
      }else if(tmp == abs(x-i)){
        if(ans > i) ans = i;
      }
    }
  }


  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif


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

  int counter[10][10];
  rep(i, 10) rep(j, 10) counter[i][j] = 0;
  fromto(i, 1, N) {
    int head = i, tail = i%10;
    while (head >= 10) head /= 10;
    ++counter[head][tail];
  }
  int ans = 0;
  fromto(i, 1, 9) {
    fromto(j, 1, 9) {
      ans += counter[i][j] * counter[j][i];
     }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int N; cin >> N;
	vector<vector<int> > F(N, vector<int> (10));
	REP(i, N) REP(j, 10) cin >> F[i][j];
	vector<vector<int> > P(N, vector<int> (11));
	REP(i, N) REP(j, 11) cin >> P[i][j];

	ll res = -1e18;
	for (int bit = 1; bit < 1 << 10; bit++) {
		ll sum = 0;
		REP(i, N) {
			int cnt = 0;
			REP(j, 10) {
				if (((bit >> j) & 1) && F[i][j])
					cnt++;
			}
			sum += P[i][cnt];
		}
		res = max(res, sum);
	}

	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    string s;
    while(cin >> s, s[0] != '#'){
        reverse(s.begin(), s.end());
        int a = 0;
        int c = 0;
        for(int i = 0; i < s.size();){
            if(s[i] == 'h'){
                i += 5;
                if(c == 0){
                } else {
                    a -= (90 << (20-c));
                }
            } else if(s[i] == 't') {
                i += 4;
                a += (90 << (20-c));
            } else assert(false);
            c++;
        }
        int d = 1 << 20;
        int g = __gcd(a,d);
        cout << a/g;
        if(d/g != 1) cout << "/" << d/g;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
import sys

f = sys.stdin
m1, d1 = map(int, f.readline().split(' '))
m2, d2 = map(int, f.readline().split(' '))

result = 0

if m2 - m1 == 1:
    result = 1
if m1 == 12 and m2 == 1:
    result = 1

print(result)

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

int main(){
	ll n,p ;
	cin >> n >> p ;
	if(p==1){
		cout << 1 << endl ;
		return 0 ;
	}
	vector<ll> div,cnt ;
	for(ll i=2;i*i<=p;i++){
		if(p%i==0){
			ll sub = 0 ;
			while(p%i==0){
				sub++ ;
				p /= i ;
			}
			div.push_back(i) ;
			cnt.push_back(sub) ;
		}
	}
	if(p!=1){
		div.push_back(p) ;
		cnt.push_back(1) ;
	}
	ll ans = 1 ;
	for(int i=0;i<div.size();i++){
		for(int j=0;j<cnt.at(i)/n;j++){
			ans *= div.at(i) ;
		}
	}
	cout << ans << endl ;
}


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



int main() {
    int n;
    cin >> n;
    
    n %= 1000;
    
    if(n == 0)
        cout << 0 << endl;
    else
        cout << 1000-n << endl;
    
    return 0;
}




Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#include <functional>
#include <sstream>

using namespace std;

int main()
{
    int N,M;
    int x,y;
    vector<pair<int,int>> v;
    
    cin >> N >> M;
    for (int i = 0;i < M;i++){
        cin >> x >> y;
        x--;
        y--;
        v.push_back(make_pair(y,x));
    }
    sort(v.begin(),v.end());
    
    int res = 1;
    int sta = v[0].first;
    
    for (int i = 1;i < v.size();i++){
        if (v[i].second >= sta){
            res++;
            sta = v[i].first;
        }
    }
    
    cout << res << endl;
}


Measured memory_bytes: 4300
#include<stdio.h>

static const int N = 100;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  trace(A, n);


  for(i=2;i<=n;i++){
    key=A[i];
    j=i-1;
    while(j>0 && A[j]>key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
    trace(A,n);
  }


  return 0;
}

Measured memory_bytes: 604
import numpy as np
ND =  list(map(int,input().split()))
Lis = []
for i in range(ND[0]):
    a =list(map(int,input().split()))
    Lis.append(a)
Lisnp = np.array(Lis)
Count = 0
for k in range(ND[0]):
    for g in range(k):
        u = Lisnp[k] - Lisnp[g]
        norm = np.linalg.norm(u)
        if norm.is_integer():
            Count += 1
print(Count)

Measured memory_bytes: 12508
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        String s = sc.next();
        if (s.charAt(s.length()-1) == 's') {
            System.out.println(s + "es");
        } else {
            System.out.println(s + "s");
        }
    }


}



Measured memory_bytes: 38628
#include<stdio.h>
int main(){
    int x1,x2,x3,x4,x5;
    
    scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
    
    if(x1 == 0) printf("1\n");
    else if(x2 == 0) printf("2\n");
    else if(x3 == 0) printf("3\n");
    else if(x4 == 0) printf("4\n");
    else printf("5\n");
    return 0;
}


Measured memory_bytes: 1648
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int num = Integer.valueOf(br.readLine());

        String[] preValues = br.readLine().split(" " , num);
        long[] values = new long[num];

        for(int i = 0; i < num; i++){
            values[i] = Integer.parseInt(preValues[i]);
        }

        System.out.print(getMin(values) + " ");
        System.out.print(getMax(values) + " ");
        System.out.println(sum(values));

    }

    private static long getMin(long[] data){
        long min = data[0];

        for(int i = 1; i < data.length; i++){
            if(min > data[i]) min = data[i];
        }

        return min;
    }

    private static long getMax(long[] data){
        long max = data[0];

        for(int i = 1; i < data.length; i++){
            if(max < data[i]) max = data[i];
        }

        return max;
    }

    private static long sum(long[] data){
        long sum = 0;

        for(int i = 0; i < data.length; i++){
            sum += data[i];
        }

        return sum;
    }

}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;

string s;
lli cnt[e5];

int main(){
  cin >> s;
  for(lli i = 0;i < s.size();i++){
    cnt[s[i]]++;
  }
  for(lli i = 'a';i <= 'z';i++){
    if(cnt[i] == 0){
      cout << s << ((char)i) << endl;
      cerr << 'a' << endl;
      return 0;
    }
  }
  for(lli i = s.size()-1;i >= 0;i--){
    cnt[s[i]]--;
    for(lli j = s[i]+1;j <= 'z';j++){
      if(cnt[j] == 0){
        s[i] = j;
        for(lli k = 0;k <= i;k++){
          cout << s[k];
        }
        cout << endl;
        cerr << 'b' << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Ma = sc.nextInt();
		int Mb = sc.nextInt();
		
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N];
		
		for(int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		int L = N*10+1;
		int[][] dp = new int[L][L];
		for(int i=0; i<L; i++)
			Arrays.fill(dp[i], Integer.MAX_VALUE);
		dp[0][0] = 0;
		
		for(int i=0; i<N; i++) {
			for(int j=L-1; j>=0; j--) {
				for(int k=L-1; k>=0; k--) {
					if(dp[j][k]<Integer.MAX_VALUE) {
						dp[j+a[i]][k+b[i]] = Math.min(dp[j+a[i]][k+b[i]], dp[j][k]+c[i]);
					}
				}
			}
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i=1; i*Ma<L && i*Mb<L; i++) {
			if(dp[i*Ma][i*Mb]<Integer.MAX_VALUE) {
				ans = Math.min(ans, dp[i*Ma][i*Mb]);
			}
		}
		
		System.out.println(ans < Integer.MAX_VALUE ? ans : -1);
		sc.close();
	}
}

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

int main(){
    int N;
    map<string,int> a;
    cin >> N;
    vector<int> S(N);
    for(int i = 0;i < N;i++){
        string input;
        cin >> input;
        if( a.count(input)){
            a.at(input)++;
        }else{
            a[input] = 1;
        }
    }
    int cnt = a.size();
  
    cout << cnt << endl;
}

Measured memory_bytes: 19568
#include<iostream>
#include<fstream>

bool isPrime(int n){
	if (n <= 1)return false;
	if (n == 2)return 3;
	if (n % 2 == 0)return false;

	for (int i = 3; i * i <= n; i++)
		if (n % i == 0)return false;

	return true;
}


int main(){
	using namespace std;

	//ifstream fin;
	//fin.open("input.txt");

	int a, d, n;
	int count;
	bool isFinished;

	a = d = n= 0;
	while (true){

		isFinished = false;
		count = 0;

		cin >> a >> d >> n;

		if (n == 0)break;

		while (!isFinished){
			if (isPrime(a)){
				count++;
			}
			if (count == n){
				cout << a << endl; 
				isFinished = true;
			}
			a += d;
		}

	}


	return 0;
}

Measured memory_bytes: 1160
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }
ll power(ll n , ll k) { if(k == 0) return 1 ; if(k&1) return n*sqr(power(n,k/2)) ; else return sqr(power(n,k/2)); }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

int main() {ikarus_101

    ll n,m,i,j,k,x;

    cin>>n;
    mll a;
    for(k=2;k<=n;++k)
    {
        ll cnt = 0;
        ll num = k;
        while(num%2 == 0) {
            ++cnt;
            num/=2;
        }
        if(cnt) a[2] += cnt;
        for(i=3;sqr(i)<=num;i+=2) {
            if(num % i == 0) {
                cnt = 0;
                while(num%i == 0) {
                    ++cnt;
                    num/=i;
                }
                a[i] += cnt;

            }
        }
        if(num > 1) a[num]++;
    }

    ll tot = 1;
    for(auto t:a)
    {
        tot *= (t.S+1);
        tot %= M;
    }
    cout << tot << endl;






















    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

#define MAX_V 100010

// 
vector<pair<ll, ll>> G[MAX_V];
vector<int> color(MAX_V, 0);

void dfs(int from, int root) {
	rep(i, (int)G[from].size()) {
		int to = G[from][i].first;
		if (to == root) continue;
		if (G[from][i].second % 2 == 0) {
			color[to] = color[from];
		}
		else {
			color[to] = 1 - color[from];
		}
		dfs(to, from);
	}
}

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

	int n;
	cin >> n;
	vector<int> u(n - 1), v(n - 1);
	vector<ll> w(n - 1);
	rep(i, n - 1) {
		cin >> u[i] >> v[i] >> w[i];
		G[u[i] - 1].push_back({ v[i] - 1,w[i] });
		G[v[i] - 1].push_back({ u[i] - 1, w[i] });
	}

	// 一つ決めてそれからたどる
	color[0] = 0;
	dfs(0, -1);

	rep(i, n) {
		cout << color[i] << endl;
	}

	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,hoge,ans[100000];
vector<pair<int,int>> v[100000];
map<int,bool> m[100000];
priority_queue<int, vector<int>, greater<int>> pq[100000];

signed main() {
    cin >> n;
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        --a, --b;
        v[a].pb(mp(b,i));
        v[b].pb(mp(a,i));
    }
    rep(i,n) {
        int tmp = 1;
        for(auto j : v[i]) {
            if (!ans[j.se]) {
                while(!pq[i].empty() && pq[i].top() == tmp) {tmp++;pq[i].pop();}
                ans[j.se] = tmp;
                pq[j.fi].push(tmp);
                tmp++;
            }
        }
        hoge = max(hoge, (int)v[i].size());
    }
    cout << hoge << endl;
    rep(i,n-1) cout << ans[i] << endl;
}





Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (int r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
vector<ll>dp(10005, -1), A(1002), B(1002);
ll h, n;
ll rec(int p){
	if(p<=0){
		return 0;
	}
	if(dp[p]>=0){
		return dp[p];
	}
	ll ans=LLONG_MAX;
	rep(i,0, n){
		ans=min(ans, B[i]+rec(p-A[i]));
	}
	return dp[p]=ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	cin>>h>>n;
	rep(i,0,n)cin>>A[i]>>B[i];
	cout<<rec(h)<<"\n";
}



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

int main(void){
    int h, w, diag;
    int bh, bw;
    while(cin >> h >> w && h) {
        int mind = numeric_limits<int>::max();
        int bh = numeric_limits<int>::max();
        diag = h*h + w*w;
        for(int i=1; i<151; ++i) {
            for(int j=i+1; j<151; ++j) {
                int t = i*i+j*j;
                if(t > diag || (t==diag && i>h)) {
                    if(t < mind || (t==mind && i<bh)) {
                        mind = t;
                        bh = i;
                        bw = j;
                    }
                    break;
                }
            }
        }
        cout << bh << " " << bw << endl;
    }
}

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

int main() {
    ll n,ans,d;
    cin >> n;
    ll ar[n];
    for(ll i=0;i<n;i++)
        cin >> ar[i];
    sort(ar,ar+n, greater<ll>());
    ans = ar[0];
    d = n-2;
    for(int i=1;i<n;i++)
    {
        if(d==0)
            break;
        else if(d==1)
        {
            ans += ar[i];
            break;
        }
        else
        {
            ans += 2*ar[i];
            d -=2;
        }
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 5144
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> a, long long q, std::vector<long long> b, std::vector<long long> c){
    map<i64,i64> v;
    for(int i = 0; i < n; ++i)
        ++v[a[i]];
    i64 sum = accumulate(a.begin(), a.end(), 0LL);
    for(int i = 0; i < q; ++i){
        i64 cnt = v[b[i]];
        v[c[i]] += cnt;
        v[b[i]] = 0;
        sum -= cnt * b[i];
        sum += cnt * c[i];
        cout << sum << endl;
    }
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> B(Q);
    std::vector<long long> C(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), Q, std::move(B), std::move(C));
    return 0;
}


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

int main() {
	int n, a, ans = 0, pans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		if (a)
			pans++;
		else {
			ans = max(ans, pans);
			pans = 0;
		}
	}
	cout << max(ans, pans) + 1 << endl;
}


Measured memory_bytes: 3104
#include<cstdio>
#include<cstring>
#define mem(a,p) memset(a,p,sizeof(a))
const int N=2e5+10,M=1<<26;
char ch[N];
int f[N],len,g[M];
int ss[N];
int min(int x,int y){return x>y?y:x;}
int main(){
	mem(g,127);
	scanf("%s",ch+1);
	len=strlen(ch+1);
	for(int i=1;i<=len;i++)ss[i]=ss[i-1]^(1<<(ch[i]-'a'));
	g[0]=0;
	for(int i=1;i<=len;i++){
		f[i]=g[ss[i]]+1;
		for(int j=0;j<=25;j++)
			f[i]=min(f[i],g[ss[i]^(1<<j)]+1);
		g[ss[i]]=min(f[i],g[ss[i]]);
	}
	printf("%d",f[len]);
	return 0;
}

Measured memory_bytes: 264064
#include<stdio.h>

int main(){
    int m1[10] ={1,2,3,4,5,6,7,8,9};
    int m2[10] ={1,2,3,4,5,6,7,8,9};
    int i,j;
    i=j=0;
    while(1){
      printf("%dx%d=%d\n",m1[i],m2[j],m1[i]*m2[j]);
      j++;
      if(j==9){
	i++;
	if(i==9)
	    break;
	j=0;
      }
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int a[n], sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);
	if (a[0] >= 0) {
		cout << sum - a[0] * 2 << endl;
		rep(i, n - 2) {
			cout << a[0] << " " << a[i + 1] << endl;
			a[0] -= a[i + 1];
		}
		cout << a[n - 1] << " " << a[0] << endl;
	} else if (a[n - 1] <= 0) {
		reverse(a, a + n);
		cout << -sum + a[0] * 2 << endl;
		rep(i, n - 1) {
			cout << a[0] << " " << a[i + 1] << endl;
			a[0] -= a[i + 1];
		}
	} else {
		sum = 0;
		rep(i, n) sum += abs(a[i]);
		cout << sum << endl;
		int p = upper_bound(a, a + n, 0) - a;
		for (int i = 1; i < p; i++) {
			cout << a[p] << " " << a[i] << endl;
			a[p] -= a[i];
		}
		for (int i = p; i < n - 1; i++) {
			cout << a[0] << " " << a[i] << endl;
			a[0] -= a[i];
		}
		cout << a[n - 1] << " " << a[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#define F first
#define S second

using namespace std;

typedef long long ll;

const ll M = 4e18;

struct st
{
    ll s, e, i;
};

bool operator <(st p, st q)
{
    return p.i > q.i;
}

bool cmp(st p, st q)
{
    return p.s < q.s;
}

ll n, Q;
st a[200005];
priority_queue<st> pq;

int main()
{
    scanf("%lld%lld", &n, &Q);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld%lld", &a[i].s, &a[i].e, &a[i].i);
        a[i].s -= a[i].i;
        a[i].e -= a[i].i;
    }
    sort(a, a + n, cmp);
    ll j = 0;
    pq.push({0, M, M});
    for(ll i = 0; i < Q; i++)
    {
        ll t;
        scanf("%lld", &t);
        for(; j < n && a[j].s <= t; j++)
        {
            pq.push(a[j]);
        }
        while(pq.top().e <= t) pq.pop();
        if(pq.top().i != M) printf("%lld\n", pq.top().i);
        else printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 11248
#include<stdio.h>
int main()
{
    int A,B,C;
    int temp;
  
    // 整数の入力
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
  
    // 比較
    if(A==B)
      temp=C;
    else if(B==C)
      temp=A;
    else
      temp=B;
  
    // 出力
    printf("%d\n", temp);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();

			int n = arr[0];
			int k = arr[1];

			List<long> list = Console.ReadLine().Trim().Split(' ').Select(hogehoge => long.Parse(hogehoge)).ToArray<long>().ToList<long>();

			list.Sort();

			long sum = 0;

			for (int i = 0; i < n - k; i++)
			{
				sum += list[i];
			}


			Console.WriteLine(sum);
		}

	}

}


Measured memory_bytes: 43008