akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

class E
{
	static int F()
	{
		return int.Parse(Console.ReadLine());
	}
	static int[] G()
	{
		return Console.ReadLine().Split().Select(int.Parse).ToArray();
	}
	public static void Main()
	{
		Console.WriteLine(G().Sum() % 24);
	}
}


Measured memory_bytes: 13396
N, T = map(int, input().split())
c = [0 for _ in range(N)]
t = [0 for _ in range(N)]
for i in range(N):
  c[i], t[i] = map(int, input().split())
c_min = max(c)
if min(t) > T:
  print("TLE")
  quit()
  
for i in range(N):
  if t[i] <= T:
    if c[i] < c_min:
      c_min = c[i]
print(c_min)

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    
    string S;
    cin >>S;
    ll N = S.size();
    ll cnt = 0, max = 0;
    rep(i,N){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            cnt++;
        }else{
            if(cnt > max){
                max = cnt;
            }
            cnt = 0;
        }
    }
    if(cnt > max){
        max = cnt;
    }
    cout << max << endl;
    
    
    
    return 0;
    

}

Measured memory_bytes: 3480
#include<stdio.h>

int main(void)
{
	int a[2];
	int i, d;
	while(1)
	{
		scanf("%d %d", &a[0], &a[1]);
		if ((a[0] == 0 && a[1] == 0))
		{
			break;
		}
		for (i=0; i<a[0]; i++)
		{
			for (d=0; d<a[1]; d++)
			{
				if (i % 2 == 1)
				{
					if (d % 2 == 1)
					{
						printf("#");
					}
					else
					{
						printf(".");
					}
				}
				else
				{
					if (d % 2 == 1)
					{
						printf(".");
					}
					else
					{
						printf("#");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

int main()
{
  int n, r;
  cin >> n >> r;
  int ans = r;
  if (10 > n) ans += 100 * (10 - n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int count = 0;
		for(int i = 1;i <= n;i++){
			if(!(i == saori.saori_hayami())){
				count++;
			}
		}
		if(count <= 2){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main (int n) 
{
    int N; cin >> N;
  int t=N, c=0;
    while (t>0) 
     c += t%10, t /= 10;
    
  if (N%c == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  queue<pair<int, int>> que;
  queue<pair<pair<int, int>, pair<int, int>>> opr;
  int cnt = 0;
  int crri(0), crrj(0);
  int dir = 1;
  while (true) {
    if (a[crri][crrj] & 1) {
      if (que.empty()) {
        que.push({crri, crrj});
      } else {
        auto prvp = que.front();
        que.pop();
        while (!que.empty()) {
          auto crrp = que.front();
          que.pop();
          opr.push({prvp, crrp});
          cnt++;
          prvp = crrp;
        }
        opr.push({prvp, {crri, crrj}});
        cnt++;
      }
    } else {
      if (!que.empty()) {
        que.push({crri, crrj});
      }
    }
    int tmpi = crri + dir;
    if (tmpi < 0 || h <= tmpi) {
      crrj++;
      dir *= -1;
      if (crrj == w) {
        break;
      }
    } else {
      crri = tmpi;
    }
  }
  cout << cnt << '\n';
  while (!opr.empty()) {
    auto e = opr.front();
    opr.pop();
    int i = e.first.first;
    int j = e.first.second;
    int k = e.second.first;
    int l = e.second.second;
    cout << ++i << ' ' << ++j << ' ' << ++k << ' ' << ++l << '\n';
  }
  return 0;
}

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

int main()
{
    int k,s,a;
    int x,y,z;
    scanf("%d",&k);
    scanf("%d",&s);
    if(k<s) a=k;
    else a=s;
    int cont=0;
    for(x=0;x<=a;x++)
    {
        for(y=0;y<=a;y++)
        {
            if(s-x-y>=0&&s-x-y<=k) cont++;
        }
    }
    printf("%d\n",cont);
    return 0;
}


Measured memory_bytes: 128
n,m=gets.split.map(&:to_i)
s=[1]*n
r=[true]+[false]*~-n
m.times{
	x,y=gets.split.map{|e|e.to_i-1}
	r[y]=true if r[x]
	s[x]-=1
	s[y]+=1
	r[x]=false if s[x]==0
}
p r.count{|e|e}

Measured memory_bytes: 4092
#include<iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

long long n, m;

bool f(long long need) {

    long long nn = n;
    long long mm = m;

    if (nn < need) {
        long long cur = need - nn;
        mm -= 2 * cur;
        nn += cur;
    }

    return (mm >= 2 * need);
}

int main(void) {

    cin >> n >> m;
    long long l = 0;
    long long r = 1e13;

    while (r - l > 1) {
        long long m = (l + r) / 2;

        if (f(m)) {
            l = m;
        } else {
            r = m;
        }
    }

    cout << l << endl;
    return 0;
}

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

int main() {

  int D,n;
  int d;
  cin >> D >> n;
  if(D==0){
    if(n != 100)
      cout << n << endl;
    else
      cout << 101 << endl;
  }
  else {
    if (D==1){
      d=100;
    }
    if(D==2){
      d=10000;
    }
    if(n!=100)
      cout << d*n << endl;
    else
      cout << d*(n+1) << endl;
  }
  return 0;
}



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

using namespace std;

int ans, n, m, h[100000], a[100000], b[100000];
vector< vector<int> > g;

bool ok(int now){
	bool f = true;
	for(int i = 0; i < g[now].size(); ++i){
		if(h[now] <= h[g[now][i]]){
			f = false;
			break;
		}
	}
	return f;
}

int main(){
	cin >> n >> m;
	g.resize(n);
	for(int i = 0; i < n; ++i) cin >> h[i];
	for(int i = 0; i < m; ++i){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	for(int i = 0; i < n; ++i) if(ok(i)) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 9556
//
//  main.cpp
//  atcoderdemo
//
//  Created by apple on 2019/6/29.
//  Copyright © 2019 apple. All rights reserved.
//

#include <iostream>
#include <string.h>
#include <queue>
#define ll long long
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int sum[maxn];
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    ll ans = 0;
    for(int i=2;i<=n-1;i++){
        if(a[i]<a[i-1] && a[i]>a[i+1]) ans++;
        else if(a[i]>a[i-1] && a[i]<a[i+1]) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
#include "stdio.h"
#include <iostream> 

using namespace std;
static int MAX_N = 100;

void trace(int* num, int n) {
	for(int i = 0; i < n - 1; i ++) {
		printf("%d ", num[i]);
	}
	printf("%d\n", num[n - 1]);
}

void insertionSort(int n, int* num) {
	for(int i = 1; i < n; i ++) {
		int key = num[i];
		int j = i - 1;
		while(num[j] > key & j >= 0) {
			num[j + 1] = num[j];
			j --;
		}
		num[j + 1] = key;
		trace(num, n);		
	}
}

int main() {
	int n, num[MAX_N];
	scanf("%d", &n);
	for(int i = 0; i < n; i ++) {
		scanf("%d", &num[i]);
	}
	trace(num, n);
	insertionSort(n, num);
}

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

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

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

  return 0;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node
{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL)
    {
        root = z;
    }
    else
    {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    if (u == NIL)
        return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if (u == NIL)
        return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, i, x;
    string com;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        cin >> com;
        if (com == "insert")
        {
            scanf("%d", &x);
            insert(x);
        }
        else if (com == "print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 26708
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  int ans = 0;
  string s;
  string s1;
  string s2;

  cin >> s;
  N = s.size();
  s1 = s.substr(0, (N-1)/2);
  s2 = s.substr((N+1)/2, (N+3)/2);

  int n1 = s1.size();
  int n2 = s2.size();

  // cout << s << endl;
  // cout << s1 << endl;
  // cout << s2 << endl;

  int nt = N/2;  
  int n12 = n1/2;  
  int n22 = n2/2;  
  for(int i=0; i < nt; i++){
    // cout << s[i] << ", " << s[N-i-1] << endl;
    if(s[i] != s[N-i-1]){
      ans++;
    }
  }  
  for(int i=0; i < n12; i++){
    // cout << s1[i] << ", " << s1[n1-i-1] << endl;
    if(s1[i] != s1[n1-i-1]){
      ans++;
    }
  }
  // cout <<  " --- " << endl;
  for(int i=0; i < n22; i++){
    // cout << s2[i] << ", " << s2[n2-i-1] << endl;
    if(s2[i] != s2[n2-i-1]){
      ans++;
    }
  }

  if(ans > 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
long long a[100005],cnt[100005],s1[100005],s2[100005],s=0,n,m,i,j;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	for (i=1;i<=n;i++){
		cin>>a[i]>>cnt[i];
		cnt[i]+=cnt[i-1];
	}
	for (i=1;i<=n;i++){
		s=max(s,cnt[i]-a[i]);
		s1[i]=cnt[i]-a[i]*2;
	}
	for (i=1;i<=n;i++){
		s=max(s,cnt[n]-cnt[i-1]-m+a[i]);
		s2[i]=cnt[n]-cnt[i-1]-m*2+a[i]*2;
	}
	for (i=1;i<=n;i++) s1[i]=max(s1[i],s1[i-1]);
	for (i=n;i>=1;i--) s2[i]=max(s2[i],s2[i+1]);
	for (i=1;i<=n;i++) s=max(s,cnt[i]-a[i]+s2[i+1]);
	for (i=1;i<=n;i++) s=max(s,cnt[n]-cnt[i-1]-m+a[i]+s1[i-1]);
	cout<<s;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int>ii;
typedef vector<ii>vii;
#define forn(i,n) for(ll i=0;i<n;i++)
#define wez(n) ll (n); cin>>(n);
#define w(t) while(t--)
#define setmax(a,b) (a)=max((a),(b))
#define setmin(a,b) (a)=min((a),(b))
#define pb push_back
#define mp make_pair
#define pie 3.1415926535897;
#define inf 1000000000;
#define outa(a,e) forn(i,e) cout << a[i] << (i==e-1?'\n':' ')
#define oute(n) cout<<n<<"\n"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    vector<int>a;
    a.pb(n);
    bool flag=true;
    ll step=2;
    while(true){
        if(n%2==0){
            n=(n/2);
            forn(i,step-1){
                if(n==a[i]){
                    cout<<step<<endl;
                    flag=false;
                    break;
                }

            }
            a.pb(n);
        }else{
            n=(3*n+1);
            forn(i,step-1){
                if(n==a[i]){
                    cout<<step<<endl;
                    flag=false;
                    break;
                }
            }
            a.pb(n);
        }
        if(!flag)break;
        step++;
    }
    return 0;
}


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

int main(){
    int N,M,X; cin>>N>>M>>X;
    int A[110]={};
    for(int i=1;i<=M;i++) cin >> A[i];
    int B[110]={};
    for(int i=1;i<=M;i++) B[A[i]]++;
    // for(int i=1;i<=10;i++) cout << B[i] << endl;

    // for(int i = 1;i<=M;i++){
    //     if(A[i]) cout << i << endl;
    // }
    // cout << endl << endl;
    int cost1 =0;
    for(int i = X ; i<=N;i++){
        if(B[i]) cost1++;//cout << cost1 << endl;
    }
    int cost2 = 0;
    for(int i = X; i >0; i--){
        if(B[i]) cost2++;
    }
    // cout << cost1 << ' ' << cost2 << endl;
    cout << min(cost1, cost2) << endl; 

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;


int main(){
   IOS;
   int h,w;cin>>h>>w;
   if(h==1||w==1){
      cout<<1;
      return 0;
   }
   if(1LL*h*w&1){
      cout<<1LL*h*w/2+1<<endl;
   }else{
      cout<<1LL*h*w/2<<endl;
   }

     
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int n,sum = 0;
	cin >> n;
	vi p(n);
	repz(i, n) {
		cin >> p[i];
		sum += p[i];
	}

	sort(p.rbegin(), p.rend());
	sum -= p[0] / 2;

	cout << sum << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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 * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    int n; cin >> n;

    map<ll,ll> factor;
    for(ll j = 1; j <= n; j++){
        ll m = j;
        for(ll i = 2; i * i <= m; i++){
            while(m % i == 0){
                ++factor[i];
                m /= i;
            }
        }
        if(m != 1) factor[m]++;
    }

    ll ans = 1;
    for(auto it : factor){
        //cout << it.first << " " << it.second << endl;
        ans *= it.second + 1;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int a[maxn],b[maxn],c1,c2,n;

int main()
{
	n=read(); rep(i,1,n) a[i]=read(),b[i]=a[i];
	sort(b+1,b+n+1);
	rep(i,1,n)
	{
		int x=lower_bound(b+1,b+n+1,a[i])-b;
		if(i%2==1&&(x%2==0)) c1++;
		else if(i%2==0&&(x%2==1)) c2++;
	}
	cout<<max(c1,c2);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n,m,k; cin >> n >> m >> k;
  rep(i, n+1) {
    rep(j, m+1) {
      int res = i * (m - j) + j * (n - i);
      if(res == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
from math import sqrt
q3 = sqrt(3)
fmt = "%.8f %.8f"
def koch(x0, y0, x1, y1, c):
    if c == n:
        return (fmt % (x0, y0),)
    xp = (x0*2 + x1) / 3
    yp = (y0*2 + y1) / 3

    xq = (x0 + x1*2) / 3
    yq = (y0 + y1*2) / 3

    dx = (x1 - x0) / 6
    dy = (y1 - y0) / 6

    xr = xp + (dx - dy * q3)
    yr = yp + (dx * q3 + dy)

    return koch(x0, y0, xp, yp, c+1) + koch(xp, yp, xr, yr, c+1) + koch(xr, yr, xq, yq, c+1) + koch(xq, yq, x1, y1, c+1)
n = int(input())
print(*koch(0, 0, 100, 0, 0)+(fmt % (100, 0),), sep='\n')


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------
const int INF = 1e9+1000;
ll n, a, b;
ll h[111111];

int main() {
   cin >> n >> a >> b;
   rep (i, n) cin >> h[i];

   ll c = a - b;
   ll left = 0, right = INF;
   while (left+1<right) {
      ll mid = (left+right)/2;
      ll t = 0;
      rep (i, n) {
         ll x = max(h[i] - b * mid, 0LL);
         t += (x+c-1) / c;
      }
      if (t <= mid) {
         right = mid;
      } else {
         left = mid;
      }
   }
   cout << right << endl; 

   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>


using namespace std;

struct Node{
  Node *right;
  Node *left;
  Node *parent;
  int key;
};

Node *root ,*NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z = (Node *) malloc(sizeof(Node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;


  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }


}

void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  cout<<" "<<u->key;
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL)return;
  cout<<" "<<u->key;
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  string com;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    cin>>com;
    if ( com=="insert" ){
      cin>>x;
      insert(x);
    } else if ( com == "print" ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}



Measured memory_bytes: 26652
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,ans = 0;
    scanf("%d%d%d",&a,&b,&c);
    if (a > b) swap(a,b);
    if (b > c) swap(b,c);
    if (a > b) swap(a,b);
    while (b+1 <= c) a++,b++,ans++;
    while (a+2 <= b+1) a += 2,ans++;
    if (a == b-1) printf("%d",ans+2);
    else if (a == b+1) printf("%d",ans+1);
    else printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int s;
	cin >> s;

	lint cnt = 1;
	while (s != 4 && s != 2 && s != 1) {
	
		if (s % 2 == 0) s /= 2;
		else s = 3 * s + 1;

		cnt++;
	}

	cout << cnt + 3 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int x, y;
    cin >> x >> y;
    int ans = 0;
    if (x == 1)
        ans += 300000;
    if (x == 2)
        ans += 200000;
    if (x == 3)
        ans += 100000;
    if (y == 1)
        ans += 300000;
    if (y == 2)
        ans += 200000;
    if (y == 3)
        ans += 100000;
    if (x == 1 && y == 1)
        ans += 400000;
    cout << ans << endl;
}

Measured memory_bytes: 256
#ABC7
N = int(input())
#空のリストを作成
d = [] 
#リストdに先頭から入力値を埋めていく
for i in range(N):
	d.append(int(input()))
#dを降順でソート
d.sort(reverse  = True )

counter = 1

for j in range(N-1):
	if d[j] > d[j+1]:
		counter += 1

print(counter)	

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	
	private static class Team implements Comparable<Team>{
		public String name;
		public int win;
		public int lose;
		
		public Team(String name, int win, int lose){
			this.name = name;
			this.win = win;
			this.lose = lose;
		}
		
		@Override
		public String toString(){
			return name;
		}

		@Override
		public int compareTo(Team other) {
			if(this.win > other.win){
				return -1;
			}else if(this.win == other.win){
				if(this.lose < other.lose){
					return -1;
				}else if(this.lose == other.lose){
					return 0;
				}else{
					return 1;
				}
			}else{
				return 1;
			}
		}
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int teams = Integer.parseInt(sc.nextLine());
			
			if(teams == 0){
				break;
			}
			
			ArrayList<Team> list = new ArrayList<Team>(teams);
			
			for(int i = 0; i < teams; i++){
				String[] strs = sc.nextLine().split(" ");
				
				int win = 0,lose = 0;
				for(int j = 1; j < strs.length; j++){
					int tmp = Integer.parseInt(strs[j]);
					
					if(tmp == 0){
						win++;
					}else if(tmp == 1){
						lose++;
					}
				}
				
				list.add(new Team(strs[0],win,lose));
			}
			
			
			Collections.sort(list);
			
			for(Team t : list){
				System.out.println(t);
			}
		}
	}
	
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int n,a,b,time,distance[10][10],min_value,min_index;
	int D[10],P[10],tmp_min,tmp_min_index,tmp_sum,count,max_number;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i = 0; i < 10; i++){
			for(int k = 0; k < 10; k++)distance[i][k] = 2000000000;
		}

		max_number = -1;
		for(int i = 0; i < n; i++){
			scanf("%d %d %d",&a,&b,&time);
			distance[a][b] = time;
			distance[b][a] = time;
			max_number = max(max_number,max(a,b));
		}

		min_value = 2000000000;

		for(int town = 0; town <= max_number; town++){
			for(int i = 0; i <= max_number; i++){
				P[i] = 0;
				D[i] = 2000000000;
			}

			for(int i = 0; i <= max_number; i++){
				if(distance[town][i] >= 0){
					D[i] = distance[town][i];
				}
			}

			count = 1;
			P[town] = 1;
			D[town] = 0;

			while(count <= max_number){
				tmp_min = 2000000000;
				for(int i = 0; i <= max_number; i++){
					if(D[i] >= 0 && P[i] == 0 && D[i] < tmp_min){
						tmp_min = D[i];
						tmp_min_index = i;
					}
				}

				if(tmp_min == 2000000000)break;

				P[tmp_min_index] = 1;
				count++;

				for(int k = 0; k <= max_number; k++){
					if(D[k] > D[tmp_min_index] + distance[tmp_min_index][k]){
						D[k] = D[tmp_min_index] + distance[tmp_min_index][k];
					}
				}
			}

			tmp_sum = 0;

			for(int i = 0; i <= max_number; i++){
				tmp_sum += D[i];
			}

			if(tmp_sum < min_value){
				min_value = tmp_sum;
				min_index = town;
			}else if(tmp_sum == min_value && town < min_index){
				min_index = town;
			}
		}

		printf("%d %d\n",min_index,min_value);

	}

    return 0;
}

Measured memory_bytes: 2588
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int A, B;
    cin >> A >> B;
    cout << max(A - B, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    return 0;
}

Measured memory_bytes: 256
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

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

ll INF=LLONG_MAX;

int const mxn=1e5+5;

vi adj[mxn];
int vis[mxn];

void bfs(int u){
	queue<ii>q;
	q.push({u,-1});
	while(!q.empty()){
		u = q.front().fi;
		int par = q.front().se;
		q.pop();
		if(vis[u])continue;
		vis[u]=par;
		for(int v:adj[u]){
			if(v==par)continue;
			q.push(ii(v,u));
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,m,a,b; cin >> n >> m;
	for(int i=0; i<m; i++){
		cin >> a >> b;
		adj[a].emplace_back(b);
		adj[b].emplace_back(a);
	}
	memset(vis,0,sizeof(vis));
	bfs(1);
	bool all=1;
	for(int i=2; i<=n; i++){
		if(!vis[i])all=0;
	}
	if(!all)cout << "No" << endl;
	else{
		cout << "Yes" << endl;
		for(int i=2; i<=n; i++){
			cout << vis[i] << endl;
		}
	}
}	


Measured memory_bytes: 11816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int dp[100001][10];
int n,m;

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


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
long long min(long long s,long long t){
  if (s>t)return t;
  else return s;
}
int main(void){
  long long x,k,d,limit=1000000000000000;
  scanf("%lld%lld%lld",&x,&k,&d);
  if(x<=0)x*=-1;
  if(x/d<=k){
    if((k-x/d)%2==0)printf("%lld",x%d);
    else printf("%lld",d-x%d);
  }
  else {
    printf("%lld",x-d*k);
  }
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

void chmax(ll& a,ll b){if(a<b) a = b;}

ll dp[4][3010][3010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R,C;
    cin >> R >> C;
    vvec<ll> val(R,vec<ll>(C));
    int K;
    cin >> K;
    for(int i=0;i<K;i++){
        int r,c,v;
        cin >> r >> c >> v;
        r--; c--;
        val[r][c] = v;
    }
    dp[0][0][0] = 0;
    dp[1][0][0] = val[0][0];
    for(int i=0;i<R;i++) for(int j=0;j<C;j++) for(int k=0;k<4;k++){
        if(i+1<R){
            chmax(dp[0][i+1][j],dp[k][i][j]);
            chmax(dp[1][i+1][j],dp[k][i][j]+val[i+1][j]);
        }
        if(j+1<C){
            chmax(dp[k][i][j+1],dp[k][i][j]);
            if(k+1<=3) chmax(dp[k+1][i][j+1],dp[k][i][j]+val[i][j+1]);
        }
    }
    ll ans = 0;
    for(int k=0;k<4;k++) ans = max(ans,dp[k][R-1][C-1]);
    cout << ans << "\n";
}

Measured memory_bytes: 355884
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void) {
	int test = 0;
	int N;
	long long int K;
	int a;
	long long int b[100001];
	int i;
	long long int num_terms;
	char buf[128], *ch;
	FILE *file;

	if(test == 1) {
		file = fopen("input.txt", "r");
	}

	if(test == 1) {
		fgets(buf, sizeof(buf), file);
	} else {
		fgets(buf, sizeof(buf), stdin);
	}
	ch = strtok(buf, " ");
	N = atoi(ch);
	ch = strtok(NULL, " ");
	K = atoll(ch);

	for(i = 0; i < 100001; i += 1) {
		b[i] = 0;
	}

	if(test == 1) {
		for(i = 0; i < N; i += 1) {
			fgets(buf, sizeof(buf), file);
			ch = strtok(buf, " ");
			a = atoi(ch);
			ch = strtok(NULL, " ");
			b[a] += atoi(ch);
		}
	} else {
		for(i = 0; i < N; i += 1) {
			fgets(buf, sizeof(buf), stdin);
			ch = strtok(buf, " ");
			a = atoi(ch);
			ch = strtok(NULL, " ");
			b[a] += atoi(ch);
		}
	}

	num_terms = 0;
	for(i = 0; i < 100001; i += 1) {
		num_terms += b[i];
		if(num_terms >= K) {
			printf("%d\n", i);
			break;
		}
	}

	if(test == 1) {
		fclose(file);
	}
	return 0;
}


Measured memory_bytes: 2884
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int t[n],m;
	for (int i=0;i<n;i++) cin >> t[i];
	cin >> m;
	int p[m],x[m];
	for (int i=0;i<m;i++) cin >> p[i] >> x[i];
	int c=0;
	for (int i=0;i<n;i++) c+=t[i];
	for (int i=0;i<m;i++) {
		cout << c+(x[i]-t[p[i]-1]) << endl;
	} 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
const ll MOD = 1000000007;
ll dp[100005];
int main() {
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a;
		cin >> a;
		dp[a] = -1;
	}
	dp[0] = 1;
	if (dp[1] == 0) dp[1] = 1;
	repl(i, 2, n + 1) {
		if (dp[i] == -1) continue;
		if (dp[i - 1] != -1) dp[i] += dp[i - 1];
		if (dp[i - 2] != -1) dp[i] += dp[i - 2];
		dp[i] %= MOD;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int n,a,b,res1,res2,res3,store[110],res;
signed main(){
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)cin>>store[i];
	sort(store,store+n);
	int cnt=0;
	while(cnt<n&&store[cnt]<=a)cnt++;
	res1=cnt;
	while(cnt<n&&store[cnt]>=a+1&&store[cnt]<=b)cnt++;
	res2=cnt-res1;
	while(cnt<n&&store[cnt]>=b+1)cnt++;
	res3=cnt-(res2+res1);
	res=min(res1,res2);
	res=min(res,res3);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3620
//31
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

typedef complex<double> P;

P p[50];
int n;

double cr(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

bool in(P a,P b,P c,P d){
  bool f[2]={};
  for(int i=0;i<3;i++){
    P pa[]={b,c,d};
    double c=cr(a-pa[i],pa[i+1]-pa[i]);
    if(fabs(c)>1e-9){
      f[c>0]=true;
    }
  }
  return !(f[0]&&f[1]);
}

bool ip(P cp){
  bool f=false;
  for(int px=0;px<n;px++){
    int nx=(px+1)%n;
    f|=cr(p[nx]-cp,p[px]-cp)>1e-9;
  }
  return !f;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      p[i]=P(x,y);
    }
    int i;
    for(i=0;i<n;i++){
      for(int j=0;j<i;j++){
	for(int k=0;k<n;k++){
	  for(int l=0;l<k;l++){
	    if(fabs(cr(p[i]-p[j],p[k]-p[l]))<1e-9)continue;
	    double a=cr(p[k]-p[l],p[i]-p[l]);
	    double b=cr(p[k]-p[l],p[j]-p[l]);
	    P ic=p[i]+(p[j]-p[i])*a/(a-b);
	    int m;
	    for(m=0;m<n;m++){
	      if(!in(ic,p[m],p[(m+1)%n],p[(m+2)%n]))break;
	    }
	    if(m!=n&&ip(ic))goto end;
	  }
	}
      }
    }
  end:
    cout<<(i!=n)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import sys
readline = sys.stdin.buffer.readline
h,w = map(int,readline().split())

if h ==1 or w==1:
    print(1)
    exit()

if h%2==0:
    print((h//2)*w)
else:
    if w%2==0:
        print((h//2)*(w//2)+(h//2+1)*(w//2))
    else:
        print((h//2+1)*(w//2+1)+(h//2)*(w//2))


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define F                 first
#define S                 second
#define C                 continue
#define G                 goto done
#define pb                push_back
#define pf                push_front
#define ppb               pop_back
#define ppf               pop_front
#define sz                size()
#define pi                acos(-1.0)
#define mod               1000000007
#define maxe              *max_element
#define mine              *min_element
#define min3(a,b,c)       min(a,min(b,c))
#define max3(a,b,c)       max(a,max(b,c))
#define min4(a,b,c,d)     min(a,min(b,min(c,d)))
#define max4(a,b,c,d)     max(a,max(b,max(c,d)))
#define mem(a,b)          memset(a,b,sizeof(a))
#define all(a)            (a).begin(),(a).end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          ((a)*((b)/gcd(a,b)))
#define case(a)           cout<<"Case "<<(a)<<": "
#define point(a)          fixed<<setprecision(a)
#define get(a)            for(auto &x:a) cin>>x;
#define print(a)          for(auto x:a) cout<<x<<" "; cout<<endl;
#define uniq(a)           sort(all(a)); (a).erase(unique((a).begin(),(a).end()),(a).end())
#define big(a)            transform((a).begin(),(a).end(),(a).begin(),::toupper)
#define small(a)          transform((a).begin(),(a).end(),(a).begin(),::tolower)
#define ischar(a)         (('a'<=a&&a<='z')('A'<=a&&a<='Z'))
#define isvowel(a)        (a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
#define fast              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tc                int test; cin>>test; while(test--)
using namespace std;
int main()
{
    ll d,t,s; cin>>d>>t>>s;
    float a=d*1.0/t;
    if(s<a) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}




















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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for( int i=0; i<N; i++ ){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Alice = 0, Bob = 0;
  for( int i=0; i<N; i++ ){
    if( (i % 2) == 0 ){
      Alice += a.at(i);
    }
    else{
      Bob += a.at(i);
    }
  }
  
  cout << (Alice - Bob) << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

// long long pow_mod(long long a, long long b){
// 	if(a == 0)
// 		return 0ll;
// 	if(b == 0)
// 		return 1ll;
// 	if(b == 1)
// 		return a%MOD;
// 	long long x = pow_mod(a,b/2);
// 	return ((b%2 == 1) ? (((x*x)%MOD)*a)%MOD : (x*x)%MOD);
// }

// long long pow_int(long long a, long long b){
// 	if(a==0)
// 		return a;
// 	if(b==0)
// 		return 1;
// 	if(b==1)
// 		return a;
// 	long long x = pow_int(a,b/2);
// 	return ((b%2 == 1) ? x*x*a : x*x);
// }

// int pow_int(int a, int b){
// 	if(a==0)
// 		return a;
// 	if(b==0)
// 		return 1;
// 	if(b==1)
// 		return a;
// 	int x = pow_int(a,b/2);
// 	return ((b%2 == 1) ? x*x*a : x*x);
// }


// void print_vec(vector<int>& a){
// 	for(int i=0;i<a.size();i++)
// 		cout << a[i] << (i<n-1 ? " ":"\n");
// }

// void print_vec(vector<long long>& a){
// 	for(int i=0;i<a.size();i++)
// 		cout << a[i] << (i<n-1 ? " ":"\n");
// }

// void solve_kick_start(int test_case){

// }

void dfs(int ind, vector<vector<pair<int,int>>>& tr, vector<bool>& vis, vector<int>& edges){
	if(vis[ind]){
		vis[ind]=false;

		priority_queue<int,vector<int>,greater<int>> pq;
		for(int i=0;i<tr[ind].size();i++){
			if(edges[tr[ind][i].S]!=-1){
				pq.push(edges[tr[ind][i].S]);
			}
		}

		int color = 1;
		for(int i=0;i<tr[ind].size();i++){
			if(edges[tr[ind][i].S]==-1){
				while(!pq.empty() && pq.top() == color){
					color++;
					pq.pop();
				}
				edges[tr[ind][i].S]=color;
				color++;
			}
		}

		for(int i=0;i<tr[ind].size();i++){
			dfs(tr[ind][i].F,tr,vis,edges);
		}
	}
}

void solve(){
	int n;
	cin >> n;
	vector<vector<pair<int,int>>> tr(n);
	vector<int> edges(n-1,-1);

	for(int i=0;i<edges.size();i++){
		int a,b;
		cin >>a>>b;
		a--;
		b--;
		tr[a].pb({b,i});
		tr[b].pb({a,i});
	}

	vector<bool> vis(n,true);
	dfs(0,tr,vis,edges);
	int mx_col = 0;
	for(int i=0;i<edges.size();i++)
		mx_col = max(mx_col,edges[i]);

	cout << mx_col << "\n";
	for(int i=0;i<edges.size();i++){
		cout << edges[i] << "\n";
	}
}	

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);

	// // CodeChef Template
	// int t;       
	// cin >> t;
	// while(t--){
	// 	solve();
	// }

	// Single test case input
	solve();

	// // Kick Start Template	
	// int test_cases;
	// cin >> test_cases;
	// for(int i=1;i<=test_cases;i++){
	// 	solve_kick_start(i);
	// }

	return 0;
}

Measured memory_bytes: 12032
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        long ret = k-a;
        a = Math.max(0,a-k);
        b -= Math.max(0,ret);
        b = Math.max(b,0);
        System.out.println(a + " " + b);
    }
}



Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define lli long long int
#define floop(a,b,c) for(lli a=b;a<c;a++)
#define bloop(a,b,c) for(lli a=b;a>=c;a--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vt vector
#define MAX 1000000007
using namespace std;
lli t,n,m;
lli i,j,k;
long double sum=0;
int main(){
        cin>>n;
        long double a[n+1]; a[0]=1;
        floop(i,1,n+1) cin>>a[i];
        long double prob[n+1][n+1];
        floop(i,0,n+1){
        	floop(j,0,n+1){
        		prob[i][j]=0;
        	}
        }
        prob[0][0]=1;
        floop(i,1,n+1){
        	cout<<fixed<<setprecision(12);
            prob[i][0]=((prob[i-1][0])*(1-a[i]));
        }
        //floop(i,0,n+1) cout<<prob[i][0]<<" ";
        //cout<<endl;
        floop(i,1,n+1){
            floop(j,1,n+1){
            	if(j<=i){
                cout<<fixed;
                cout<<setprecision(12);
                prob[i][j]=((prob[i-1][j])*(1-a[i]))+((prob[i-1][j-1])*(a[i]));
            	}
            }
        }
        floop(i,(n+1)/2,n+1){
        	cout<<fixed<<setprecision(12);
            sum+=prob[n][i];
        }
        cout<<fixed<<setprecision(10)<<sum;
        return 0;
}


Measured memory_bytes: 140928
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
int main()
{
    int x,y;
    cin>>x>>y;
    cout<<x+y/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  cout << (N-K+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf 1000000000000000000

using namespace std;

void run();

signed main(){
    cout<<fixed;
    run();
    return 0;
}

void run(){
    int a,b;
    cin>>a>>b;
    puts(a%2&&b%2?"Yes":"No");
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

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

    mint ans = 1;
    rep(i, N) {
        ans *= i+1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    string s, t; cin >> s >> t;
    int ls = s.length();   
    int lt = t.length();   

    int best = 0;
    rep(i, ls - lt + 1)
    {
        int count = 0;
        rep(j, lt)
        {
            if( s[i + j] == t[j] ) count++;
        }
        best = max(best, count);
    }
    cout << lt - best << endl;
}

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

using namespace std;
typedef unsigned long long ll;
int main() {
	int n ;
	cin>>n;
	vector<int>num(n);
	for(int i = 0 ; i< n ; i++){
		cin>>num[i];
	}
	int sum=0;
	for(int i = 1 ; i< n-1 ; i++){
		if((num[i]>num[i-1]||num[i]>num[i+1])&&(num[i]<num[i-1]||num[i]<num[i+1])){
			sum++;
		}
	}
	cout<<sum;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max({ a + b, a - b, a * b }) << endl;
    return 0;
}

Measured memory_bytes: 256