akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Data.List

count :: (Int, Int, Int) -> [(Int, Int, Int, Int)] -> Int
count t ts = foldl (+) 0 $ map (\(_, _, _, v) -> v) $ filter (\(b, f, r, _) -> t == (b, f, r)) ts

solve :: [(Int, Int, Int, Int)] -> String
solve ts = intercalate separator $ map house [1 .. 4]
    where
        house b   = unlines $ map (line b) [1, 2, 3]
        line b f  = " " ++ (unwords $ map show $ map (\r -> count (b, f, r) ts) [1 .. 10])
        separator = replicate 20 '#' ++ "\n"

main :: IO ()
main = do
    n     <- readLn
    lines <- replicateM n getLine
    putStr $ solve $ map ((\[b, f, r, v] -> (b, f, r, v)) . map read . words) lines

Measured memory_bytes: 4212
#include<iostream>
using namespace std;
int main()
{
	long long int a, b, c, k;
	while(cin >> a >> b >> c >> k)
	{
		if(a >= k) cout << k << endl;
		else
		{
			if(b >= k - a) cout << a << endl;
			else cout << a - (k - a - b) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3600
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  # 隣り合う組の数はm-1個
  # d=0のとき、p=n/n^2=1/n
  # それ以外のときはp=2(n-d)/n^2
  # p*(m-1)が解

  n,m,d=LI()
  if d==0:
    p=1/n
  else:
    p=2*(n-d)/(n*n)

  return p*(m-1)

# main()
print(main())


Measured memory_bytes: 5332
#coding: utf-8
n = int(input())
a = []
b = list(map(int, input().split()))
flag = True
for _ in range(n):
    add = 0
    for j in range(1, len(b)+1):
        if j == b[j-1]:
            add = max(add, j)
    if add == 0:
        flag = False
        break
    a.append(add)
    del b[add-1]
if flag:
    for i in range(len(a)):
        print(a[-i-1])
else:
    print(-1)

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */
int main(){
    int N,M;
    cin >> N >> M;
    int L = -1e6;
    int R = 1e6;
    REP(i,M){
        int l,r;
        cin >> l >> r;
        if ((r < L) or (R < l)){
        	L = 0;
        	R = -1;
        	break;
        }else if ((r <= R) and (L <= l)){
        	L = l;
        	R = r;
        }else if ((R <= r) and (l <= L)){
        	continue;
        }else{
        	L = max(L,l);
        	R = min(R,r);
        }
    }

    cout << R - L + 1 << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,n;
	cin>>n;
	for (int i = 0; i < n; i++)
	{
		cin>>a>>b>>c;
		if (a*a == b * b + c * c)
		{
			cout<<"YES"<<endl;
		}
		else if (b*b == c * c + a * a)
		{
			cout<<"YES"<<endl;
		}
		else if (c*c == a * a + b * b)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}
	return false;
}


Measured memory_bytes: 2992
# -*- coding:utf-8 -*-
import sys
from collections import OrderedDict


def cleate_node_dict(children):
    node_dict = OrderedDict()
    for val in children:
        node_dict[val] = OrderedDict()
    return node_dict


def cleate_tree(nodes):
    tree = nodes.copy()
    for node, children in nodes.items():
        for key in children.keys():
            children[key] = nodes[key]
            del tree[key]

    return tree


def rec(current, acc, parent=-1, depth=0):
    if current == {}:
        return
    for node, children in current.items():
        cld_lst = list(children.keys())
        acc[node] = "node {0}: parent = {1}, depth = {2}, {3}, {4}".format(
                node, parent, depth, node_type(parent, children), cld_lst)
        rec(children, acc, node, depth+1)


def node_type(parent, children):
    if parent == -1:
        return "root"
    elif children != {}:
        return "internal node"
    else:
        return "leaf"


if __name__ == "__main__":
    n = int(input())
    lst = [[int(n) for n in val.split()] for val in sys.stdin.readlines()]
    nodes = {val[0]: cleate_node_dict(val[2:]) for val in lst}
    tree = cleate_tree(nodes)
    node_info = {}
    rec(tree, node_info)
    for key, val in sorted(node_info.items()):
        print(val)

Measured memory_bytes: 254592
// --------------
// Tejas Pandey  |
// 28 - 03 - 20  |
// Atcoder BC 160|
// --------------

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

#define mod 998244353
#define vi vector<int>
typedef long long int ll;

int main (void)
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll k,n;
  cin >> k >> n;
  ll a[n];
  for(int i = 0;i < n;i++) cin >> a[i];
  ll ans = k - (a[0] + (k - a[n - 1]));
  for(int i = 0;i < n - 1;i++)
	ans = min(ans,k - (a[i + 1] - a[i]));
  cout << ans;
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par;
    UnionFindTree(int n){
        par.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
};

class comp{
public:
    bool operator()(const tuple<int,int,int>&a,const tuple<int,int,int>&b){
        if(get<1>(a)*get<0>(b)!=get<1>(b)*get<0>(a))return get<1>(a)*get<0>(b)<get<1>(b)*get<0>(a);
        return get<2>(a)<get<2>(b);
    }
};

int N;
int P[222222];
int A[222222],B[222222];

signed main(){
    cin>>N;
    for(int i=1;i<N;i++){
        cin>>P[i];P[i]--;
    }
    rep(i,N){
        int a;cin>>a;
        if(a==0)A[i]++;
        else B[i]++;
    }

    int ans=0;

    set<tuple<int,int,int>,comp>st;
    UnionFindTree uf(N);
    for(int i=1;i<N;i++){
        st.insert(make_tuple(A[i],B[i],i));
    }

    rep(_,N-1){
        int v=get<2>(*st.begin());
        st.erase(st.begin());
        int p=uf.find(P[v]);
        if(p!=0){
            st.erase(make_tuple(A[p],B[p],p));
        }
        ans+=B[p]*A[v];
        A[p]+=A[v];
        B[p]+=B[v];
        uf.unite(p,v);
        if(p!=0)st.insert(make_tuple(A[p],B[p],p));
    }

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


Measured memory_bytes: 19200
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  int N, H, W;
  cin >> N >> H >> W;

  int ans = (N-H+1)*(N-W+1);
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string S;
char Q;
long bcnt=0,wcnt=0;
long c1=0,c2=0,c3=0,c4=0;
int ans=0;
int i;
void cnt(void){
  bcnt=0;
  wcnt=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='B') bcnt++;
    else wcnt++;
  }
}

int main(){
  cin >> S;
  /*cnt();
  //cout << S.size();
  //cout << bcnt << wcnt << endl;
  /*if(wcnt==S.size() || bcnt==S.size()){
  cout << "0" << endl;
  return 0;
}
while(wcnt==S.size() || bcnt==S.size()){
  if(S[0]=='B'){
    i=1;
    while(S[i]=='B'){
      c1++;
      i++;
    }
  }
  if(S[0]=='W'){
    i=1;
    while(S[i]=='W'){
      c1++;
      i++;
    }
  }
  if(S[S.size()-1]=='B'){
    i=S.size()-2;
    while(S[i]=='B'){
      c2++;
      i--;
    }
  }
  if(S[S.size()-1]=='W'){
    i=S.size()-2;
    while(S[i]=='W'){
      c2++;
      i--;
    }
  }
  if(c1>=c2){//注意
    if(S[0]=='B'){
      for(int i=0;i<c1;i++){
        S[i]='W';
      }
      S='W'+S;
    }
    if(S[0]=='W'){
      for(int i=0;i<c1;i++){
        S[i]='B';
      }
      S='B'+S;
    }
  }
    else{//注意
      if(S[S.size()-1]=='B'){
        for(int i=S.size()-1;i>S.size()-c2;i--){
          S[i]='W';
        }
        S=S+'W';
      }
      if(S[S.size()-1]=='W'){
        for(int i=S.size()-1;i>S.size()-c2;i--){
          S[i]='B';
        }
        S=S+'B';
      }
    }
cnt();
ans++;
}*/

  Q=S[0];
for(int i=0;i<S.size();i++){
  if(S[i]==Q);
  else{
    if(Q=='B') Q='W';
    else Q='B';
    ans++;
  }
}
cout << ans << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define f(i,a,b) for(i=a;i<=b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ll long long
#define mod (1000*1000*1000+7)
#define scan1(x) scanf("%lld",&x)
#define scan2(x,y) scanf("%lld %lld",&x,&y)
#define scan3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define print(x) printf("%lld\n",x)
#define ff first
#define ss second
using namespace std;
ll spf[10000001];

ll calc(ll n){
    if(spf[n]==n)
    return 2;
    ll ans=1;
    while(n!=1){
        ll cnt=0;
        ll fact=spf[n];
        while(spf[n]==fact)
        n/=spf[n],cnt++;
        cnt++;
        ans*=cnt;
    }
    
    return ans;
}

int main(){
    ll n,i,j;
    scan1(n);
    
    if(n==1){
        cout<<1<<"\n";
        return 0;
    }
    f(i,1,n)
    spf[i]=i;
    
    for(i=2;i*i<=n;i++)
    if(spf[i]==i)
    for(j=i*i;j<=n;j+=i)
    if(spf[j]==j)
    spf[j]=i;
    
    ll ans=1;
    for(i=2;i<=n;i++)
    ans+=i*calc(i);
    
    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 81736
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s, t;
    cin >> s >> t;
    s += s;
    int n = s.length(), m = 26;
    VVL next(n, VL(m, -1));
    VL pos(m, -1);
    FORR(i,n-1,0){
        REP(j,m) next[i][j] = pos[j];
        pos[s[i] - 'a'] = i;
    }
    if (pos[t[0] - 'a'] == -1){
        cout << -1 << endl;
        return 0;
    }
    ll p = pos[t[0] - 'a'], ans = p;
    FOR(i,1,t.length()-1){
        ll q = next[p][t[i] - 'a'];
        if (q == -1){
            cout << -1 << endl;
            return 0;
        }
        ans += q - p;
        p = q;
        if (p >= n / 2) p -= n / 2;
    }
    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 49024
#include<iostream>

int main(){
	int q,year[100][3];
	std::cin>>q;
	for(int i=0;i<q;i++){
		for(int j=0;j<3;j++){
			std::cin>>year[i][j];
		}
	}
	for(int i=0;i<q;i++){
		int count=0;
		while(year[i][0]>=1&&year[i][1]>=1&&year[i][2]>=1){
			year[i][0]--,year[i][1]--,year[i][2]--;
			count++;
		}while(year[i][0]>=2&&year[i][1]>=1){
			year[i][0]-=2,year[i][1]--;
			count++;
		}while(year[i][0]>=3){
			year[i][0]-=3;
			count++;
		}
		std::cout<<count<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Char
import Data.Complex
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Maybe
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [n,m,k] <- r'
    as <- r n
    bs <- r m
    let aScan = U.takeWhile (<= k) $ U.scanl (+) 0 as
    let bScan = U.scanl1 (+) bs

    bScanMut <- U.thaw bScan

    res <- U.imapM (\i a -> solve i a bScanMut k) aScan

    print $ U.maximum res

solve :: Int -> Int -> UM.IOVector Int -> Int -> IO Int
solve numA tforA bScan k = let tforB = k - tforA
    in  if tforB < 0 then return 0
            else do
                numB <- binarySearchR bScan tforB
                return $ numA + numB


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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

vector<Pii> data;
int N, K;

signed main() {
  cin >> N >> K;
  Rep(i, N) {
    int a, b; cin >> a >> b;
    data.pb(Pii(b, a));
  }

  sort(All(data), greater<Pii>());

  int ans = 0;
  Rep(j, 32) {
    int ans2 = 0;
    int sum = 0;
    Rep(i, (int)data.size()) {
      int b = data[i].fr, a = data[i].sc;
      if ( !(a & (1 << j)) && (sum | a) <= K ) {
	ans2 += b;
	sum |= a;
      } 
    }
    ans = max(ans, ans2);
  }

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


Measured memory_bytes: 2420
class RollingHash:
    def __init__(self,S,base,M):
        self.N=len(S)
        self.M=M
        self.H=[0]*(self.N+1)
        self.B=[0]*(self.N+1)
        self.B[0]=1
        for i in range(self.N):
            self.B[i+1]=self.B[i]*base%M
            self.H[i+1]=(self.H[i]*base+(ord(S[i])-96))%M
    def get(self,l,r):
        return (self.H[r]-self.H[l]*self.B[r-l]+self.M)%self.M
    def getall(self,L):
        arr=[]
        for i in range(L,self.N+1):
            arr.append(self.get(i-L,i))
        return arr

def Hash(S,base,M):
    H=0
    for c in S:
        H=(H*base+ord(c)-96)%M
    return H
    
def isbad(L):
    arr=RH.getall(L)
    s=set()
    for i in range(L,N-L+1):
        s.add(arr[i-L])
        if arr[i] in s:
            return False
    return True
    
import random
N=int(input())
S=input()
MOD=2**61-1
base=random.randrange(100,MOD)
RH=RollingHash(S,base,MOD)
l,r=-1,N+1
while(r-l>1):
    mid=(l+r)//2
    if isbad(mid):
        r=mid
    else:
        l=mid
print(l)

Measured memory_bytes: 84904
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	string s;
	cin>>n>>s;
	
	auto r = count(ALL(s), 'R');
	auto ans = min(r,n-r);
	
	ans = min(ans, count(begin(s),begin(s)+r,'W'));
	ans = min(ans, count(begin(s)+r,end(s),'R'));
	
	cout<<ans<<endl;
	
	
	
	
	return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j,k;


int main(){
   char a,b;
   cin>>a>>b;
   if(a==b)cout<<'H'<<endl;
   else cout<<'D'<<endl;

   
}

Measured memory_bytes: 256
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2019/09/15.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef LONG_MAX
#undef LONG_MIN

#define LONG_MAX	9223372036854775807
#define LONG_MIN	(-LONG_MAX  -1)

#define ll long long

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	
	
	
	string s;
	cin >> s;


	string next;
	if ( s == "Sunny") {
		next = "Cloudy";
	}
	else if ( s == "Cloudy") {
		next = "Rainy";
	}
	else {
		next = "Sunny";
	}
	
	cout << next << endl;
	return 0;
}


Measured memory_bytes: 256
import collections

n,m = map(int,input().split())
g = [[] for i in range(n+1)]
for i in range(m):
  a,b = map(int,input().split())
  g[a].append(b)
  g[b].append(a)
q = collections.deque()
q.append(1)
check = [0]*(n+1)
check[1] = 1
ans = [0]*(n+1)
while len(q)!=0:
  v = q.popleft()
  for j in g[v]:
    if check[j] == 0:
      check[j] = 1
      ans[j] = v
      q.append(j)
print('Yes')
for k in range(2,n+1):
  print(ans[k])

Measured memory_bytes: 34852
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int n, p, sum = 0, maxi = -1;
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &p);
		sum += p;
		maxi = max(maxi, p);
	}
	sum -= (maxi / 2);
	printf("%d\n", sum);
	return 0;
}

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

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	int count = 1;
	int ans = 0;
	while(count < b) {
		count += a - 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
import Data.List

solve :: String -> String -> [Int]
solve _ [] = []
solve a b = result : solve (a ++ [head b]) (tail b)
  where sa = nub $ sort a
        sb = nub $ sort b
        result = length $ filter (==True) [x == y | x <- sa, y <- sb]

main :: IO ()
main = do
  getLine
  s <- getLine
  print . maximum $ solve "" s

Measured memory_bytes: 1020
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	h, _ := strconv.Atoi(stringLineScan())
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(stringLineScan())
		b[i], _ = strconv.Atoi(stringLineScan())
	}
	ma := max(a)
	fb := filter(b, ma)
	sort.Ints(fb)
	c := 0
	for i := len(fb) - 1; i >= 0; i-- {
		h -= fb[i]
		c++
		if h <= 0 {
			h = 0
			break
		}
	}
	if h%ma == 0 {
		c += h / ma
	} else {
		c += h/ma + 1
	}
	fmt.Println(c)
}
func max(x []int) int {
	y := x[0]
	for _, i := range x {
		if y < i {
			y = i
		}
	}
	return y
}
func filter(x []int, th int) []int {
	y := make([]int, 0)
	for _, i := range x {
		if i > th {
			y = append(y, i)
		}
	}
	return y
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define maxn 100000
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

lli power(lli x, lli y, lli p)
{   lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {   if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int main()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    double i, j, x, k, n, y,  p, q, l, t, z, m, w, r, d;
    cin >> n >> d;
    r = 0;
    for (i = 0; i < n; i++) {
        cin >> x >> y;
        w = sqrt((x * x) + (y * y));
        if (w <= d) {
            r++;
        }
    }
    cout << r;
}

Measured memory_bytes: 3736
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll H, N;

    cin >> H >> N;

    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        H -= A[i];
    }

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

    return 0;
    
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 2000000000
using namespace std;
inline int read()
{
    char c=getchar(); int num=0,f=1;
    while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
    while (c<='9'&&c>='0') { num=num*10+c-'0'; c=getchar(); }
    return num*f;
}
int n,dp[2005][2005],w[2005][2005],b[2005][2005];
char s[4005][5];
int bitw[2005],bitb[2005];
inline int lowbit(int x) { return x&-x; }
inline void add(int *f,int x)
{
    for (;x<=n;x+=lowbit(x)) f[x]++;
}
inline int query(int *f,int x)
{
    int r=0; for (;x;x-=lowbit(x)) r+=f[x]; return r;
}
int main()
{
    n=read();
    for (int i=1;i<=n*2;i++)
    {
        scanf("%s",s[i]); int x=read();
        if (s[i][0]=='W')
        {
            for (int j=0;j<=n;j++)
             w[x-1][j]=(i-1)-query(bitw,x-1)-query(bitb,j);
            add(bitw,x);
        }
        else
        {
            for (int j=0;j<=n;j++)
             b[j][x-1]=(i-1)-query(bitw,j)-query(bitb,x-1);
            add(bitb,x);
        }
    }
    for (int i=0;i<=n;i++)
     for (int j=0;j<=n;j++)
     {
         if (!i&&!j) continue;
         dp[i][j]=inf;
         if (i) dp[i][j]=min(dp[i][j],dp[i-1][j]+w[i-1][j]);
         if (j) dp[i][j]=min(dp[i][j],dp[i][j-1]+b[i][j-1]);
     }
    printf("%d",dp[n][n]);
    return 0;
}


Measured memory_bytes: 47360
#include <stdio.h>

int main(void)
{
	int a, b, c, i, N;
	scanf("%d", &N);
	for (i = 0; i < N; i++)
	{
		scanf("%d %d %d", &a, &b, &c);
		if (a <= b && b <= c || b <= a && a <= c)
		{
			if (a*a + b*b == c*c)
				printf("YES");
			else
				printf("NO");
		} else if (a <= c && c <= b || c <= a && a <= b)
		{
			if (a*a + c*c == b*b)
				printf("YES");
			else
				printf("NO");
		} else if (b <= c &&  c<=a || c <= b && b <= a)
		{
			if (b*b + c*c == a*a)
				printf("YES");
			else
				printf("NO");
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 584
import math
a,b,C=map(float,input().split())
sinC=math.sin(math.radians(C))
cosC=math.cos(math.radians(C))
S=1/2*a*b*sinC
print(f'{S}')
c=math.sqrt(a*a+b*b-2*a*b*cosC)
print(f'{a+b+c}')
h=(2*S)/a
print(f'{h}')


Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

const int e = 2e6 + 69;
const ll mod = 1e9 + 7;

ll a[e];

int main()
{
    string s;
    cin >> s;
    int cur = (s[0]-'0')*10 + s[1]-'0';
    int cur1 = (s[2]-'0')*10 + s[3]-'0';
    bool chk1 = false, chk2 = false;
    if(cur >= 1 && cur <= 12) chk1 = true;
    if(cur1 >= 1 && cur1 <= 12) chk2 = true;
    if(chk1 && chk2){
        cout << "AMBIGUOUS";
        return 0;
    }
    if(chk2){
        cout << "YYMM";
        return 0;
    }
    if(chk1){
        cout << "MMYY";
    return 0;
    }
    cout << "NA";
}


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

using namespace std;
#define MOD 1e9
typedef long long ll;

int pos;

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

  for(int i = 0, x; i < 5; ++i){
    cin>>x;
    if(x == 0) pos = i + 1;
  }
  cout<<pos<<"\n";
}


Measured memory_bytes: 3648
import math

a,b,x = map(int,input().split())

if a*b/2*a <x:
  l = 2*b-(2*x)/(a**2)
  d = math.degrees(math.atan(l/a))
else:
  l = 2*x/(a*b)
  d = math.degrees(math.atan(b/l))
print(d)

Measured memory_bytes: 38256
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector<lld> v(100001,0);
lld n,d;
vector<vector<vector<lld> > > dp(10001,vector<vector<lld> >(100,vector<lld>(2,-1)));
lld cou(lld sz,lld sum,lld edge)
{
    if(dp[sz][sum][edge]!=-1)
        return dp[sz][sum][edge];
    if(sz==0)
        return (sum==0);
    lld lim=9,ans=0,nedge;
    if(edge==1)
        lim = v[n-sz];
    for(lld i=0;i<=lim;i++)
    {
        nedge=0;
        if((i==lim)&&(edge==1))
            nedge=1;
        ans=(ans+cou(sz-1,(sum+i)%d,nedge))%mod;
    }
    return dp[sz][sum][edge]=ans;
}
int main()
{
      ios;
      string k;
      cin>>k;
      cin>>d;
      n=k.size();
      rep(i,0,n-1)
      {
          v[i]=(k[i]-'0');
      }
      lld ans = cou(n,0,1);
      cout<<(dp[n][0][1]-1+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 57088
### main

m = gets.to_i

m.times do
  cars = gets.strip
  #p cars

  finals = {}
  ncars = cars.length

  for k in (1...ncars)
    cars0 = cars[0, k]
    cars1 = cars[k, ncars - k]
    #p [cars0, cars1]

    rcars0 = cars0.reverse
    rcars1 = cars1.reverse

    finals[ cars0 +  cars1] = 1
    finals[rcars0 +  cars1] = 1
    finals[ cars0 + rcars1] = 1
    finals[rcars0 + rcars1] = 1
    finals[ cars1 +  cars0] = 1
    finals[rcars1 +  cars0] = 1
    finals[ cars1 + rcars0] = 1
    finals[rcars1 + rcars0] = 1
  end

  puts finals.keys.length
end

Measured memory_bytes: 6520
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = S / 3600;
		int m = (S - h * 3600) / 60;
		int s = S - 3600 * h - 60 * m;
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26028
#include<bits/stdc++.h>
using namespace std;
int a[20000];
int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int  i=0;i<n;i++)
    {
        int s=0;

          while(a[i]%2==0)
          {
              a[i]=a[i]/2;
              s++;
          }

        sum=sum+s;
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n,m;
	cin>>n>>m;
	vvint vv(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		vv[a].PB(b);
		vv[b].PB(a);
	}
	rep(i,n){
		cout<<vv[i].size()<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

int ans,h[100002],n,m,x,y,l;
vector <int> ar[100002];
bool ok;

int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>h[i];
	for (int i=0;i<m;i++){
		cin>>x>>y;
		ar[x].push_back(y);
		ar[y].push_back(x);
	}
	for (int i=1;i<=n;i++){
		l=ar[i].size();
		ok=true;
		for (int j=0;j<l;j++){
			if (h[i]<=h[ar[i][j]]) ok=false;
			//cout<<i<<" "<<h[i]<<" "<<h[ar[i][j]]<<"\n";
		}
		if (ok==true) ans++;
		//cout<<h[i]<<" "<<h[ar[i][j]]<<"\n";
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 9148
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

//ABのけた数を求める
ll dig(ll A){
  for(ll i=1;1;i++){
    if(!A)
      return i-1;
    else
      A/=10;
  }
}

int main(){
  ll N;
  cin>>N;
  vector<ll> tes,ket;
  //約数を求める
  for(ll i=1;i*i<=N;i++){
    if(N%i==0){
      tes.push_back(i);
    }
  }
  ll mini=INF;
  for(auto it=tes.begin();it!=tes.end();it++){
    //全ての約数についてFを求める
    mini=min(mini,max(dig(*it),dig(N/(*it))));
  }
  cout<<mini<<endl;
  return 0; 
}

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

int main(){
    int n;
    scanf("%d",&n);
    int h[n];
    for(int i=0;i<n;i++) scanf("%d",&h[i]);
    int ans=0;
    int max=0;
    for(int i=0;i<n-1;i++){
        if(h[i+1]<=h[i]) ans++;
        else ans=0;
        if(ans>max) max=ans;
    }
    printf("%d\n",max);
}

Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def main():
    n,k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    r = 0
    for c in a:
        if c > 0:
            r += c
    ps = 0
    ms = 0
    for c in a[:k]:
        if c > 0:
            ps += c
        else:
            ms -= c
    mi = min(ps,ms)
    for i in range(k,n):
        kc = a[i-k]
        if kc > 0:
            ps -= kc
        else:
            ms += kc
        c = a[i]
        if c > 0:
            ps += c
        else:
            ms -= c
        mi = min(mi,ps,ms)
    return r-mi


print(main())


Measured memory_bytes: 17224
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

  /*
    11???((?£n=1^11 Pn??Qn)???11??§???????????????)
    ???????????? ((?£n=1^11 Pn??Qn)???11??§???????????????)???1 ?????´?????? 0 ??¨?????????
    ????????§??? Qn (n=1,2,???,11) ????¬???????????????????????????????

    1???n???6 ?????¨??? n+1
    7???n???11 ?????¨??? n???5
  */

int main() {

  string s; cin >> s;

  char c = s.back();
  s = s.substr(0, 11); reverse(all(s)); s.push_back(c);

  if(s.back() == '?') {

    int sum = 0;

    REP(i, 1, 12) {
      sum += (s[i-1] - '0') * ((1 <= i && i <= 6) ? (i + 1) : (i - 5));
    }
    int P0 = ((sum % 11) <= 1) ? 0 : 11 - (sum % 11);
    cout << P0 << endl;

  }
  else {
    set<int> answers;
    rep(place, 10) {
      int sum = 0;
      REP(i, 1, 12) {
        if(s[i-1] == '?') {
          sum += place * ((1 <= i && i <= 6) ? (i + 1) : (i - 5));
        }
        else {
          sum += (s[i-1] - '0') * ((1 <= i && i <= 6) ? (i + 1) : (i - 5));
        }
      }
      int P0 = ((sum % 11) <= 1) ? 0 : 11 - (sum % 11);
      if(P0 == s.back()-'0') {
        answers.insert(place);
      }
    }

    if(answers.size() == 1) {
      cout << *answers.begin() << endl;
    }
    else if(answers.size() >= 2) {
      cout << "MULTIPLE\n";
    }
    else { assert(0); }

  }

  return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io  ios_base::sync_with_stdio(false), cin.tie(NULL),cout.tie(NULL)
int mod=1e9+7;const int N=55;
int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	return (a+b)%m;}
int sub(int a,int b,int m=mod){	return (a-b+m)%m;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
bool chk(int x,int y,int n,int m)
{
    return x>=0 && x<n && y>=0 && y<m;
}
int32_t main()
{
    int n,k;
    cin>>n>>k;
    int arr[n+1];
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    map<int,bool> vis;
    int p=1;
    while(1)
    {
        if(vis[p]==true)
            break;
        vis[p]=true;
        p=arr[p];
    }
    int st=p;
    vector<int> brr,crr;
    p=1;
    while(p!=st)
    {
        brr.push_back(p);
        p=arr[p];
    }
    crr.push_back(st);
    p=arr[st];
    while(p!=st)
    {
        crr.push_back(p);
        p=arr[p];
    }
    if(k<brr.size())
        cout<<brr[k];
    else
    {
        k-=brr.size();
        int sz=crr.size();
        k%=sz;
        cout<<crr[k];
    }
}


Measured memory_bytes: 19248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool mycomp(ll a,ll b)
{
    return (a>b);
}
int main() 
{
    ll n;
    cin>>n;
    vector<ll> v(n,0);
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end(),mycomp);
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        if(i&1)
        {
            ans-=v[i];
        }
        else
        {
            ans+=v[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll n;
        cin >> n;
        vll a(n);
        rep(i, 0, n) cin >> a[i];
        deque<ll> b;
        if (n % 2 == 0) {
                rep(i, 0, n) {
                        b.push_back(a[i]);
                        ++i;
                        b.push_front(a[i]);
                }
        } else {
                rep(i, 0, n-1) {
                        b.push_front(a[i]);
                        ++i;
                        b.push_back(a[i]);                       
                }
                b.push_front(a[n-1]); 
        }

        rep(i, 0, len(b)) {
                cout << b[i] << ' ';
        }
        cout << endl;
}

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

int main() {
  int N;
  cin >> N;
  int count=0;
  for (int i = 0; i < N; i++) {
    int l,r;
    cin >> l >> r;
    count += r-l+1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

n=int(input())

#n番目の頂点が「どの頂点と、何本目の辺つながっているか」をsetの配列で持つ
g = [[] for _ in range(n)]
#i本目の辺(n頂点なのでn-1本ある)が何色か（つまり出力する答え）の配列
ans = [0]*(n-1)

def dfs(target,parent_color,parent):
    next_color = 1

    for a,b in g[target]:
        if target == parent:
            continue
        if next_color == parent_color:
            next_color += 1
        if ans[b] != 0:
            continue
        
        ans[b] = next_color
        next_color += 1
        dfs(a,ans[b],target)
    
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append((b,i))
    g[b].append((a,i))

#print(g)
dfs(0,-1,-1)

print(max(ans))
for a in ans:
    print(a)


Measured memory_bytes: 74688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{
    int n,m; cin >> n >> m;
    vector<ll> dp(n+1,0);
    vector<bool> is_safe(n+1,true);

    for(int i=0;i<m;i++){
        int a; cin >> a;
        is_safe[a] = false;
    } 

    dp[0]=1;
    if(is_safe[1])dp[1]=1;

    for(int i=2;i<n+1;i++){
        if(is_safe[i-2])dp[i] += dp[i-2];
        if(is_safe[i-1])dp[i] += dp[i-1];
        dp[i] %= MOD;
    }
    cout << dp[n] << endl;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    double R;
    cin >> R;
    
    cout << 2 * R * acos(-1) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3804
function Main(input) {
  input = parseInt(input);
  var output = 0;
  for(var i = 1; i <= input; i++){
    if(i.toString().length % 2 == 1){
       output++;
       }
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 10944
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    ll N,M,sum=0;
    cin >> N;

    for (int i = 1; i <= N; i++) {
        if(i%3!=0 & i%5!=0) sum+=i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3620
n, p = map(int, input().split())
 
s = list(input())
ans = 0
if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
else:
    d = [0] * (n + 1)
    ten = 1
    for i in range(n - 1, -1, -1):
        a = int(s[i]) * ten % p
        ten *= 10
        ten %= p
        d[i - 1] = (d[i] + a) % p
    cnt = [0] * p
    for i in range(n, -1, -1):
        cnt[d[i]] += 1
    for  i in cnt:
        ans+=i*(i-1)/2

print(int(ans))

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

using namespace std;

int main() {
    int r, d, x, y;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; ++i) {
        y = (r * x) - d;
        cout << y << endl;
        x = y;

    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define debug2(x,y) cout<<"("<<#x<<","<<#y<<") = ("<<(x)<<","<<(y)<<")\n"
using vi = vector<int>;
using vvi = vector<vi>;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define rep(i, n) for(int i=0; i<(int)n; i++)

namespace /*DAG.cpp*/{
  int N,M; //頂点と辺の数
  vector<vector<int>> G; //グラフ
  vector<int> h; //入次数 : topoBFS
  vector<int> l_depth; //最大経路長 //recDFSでは探索済みかどうかも示す
  vector<int> s_depth; //最短経路長
  vector<int> ans; //答えを格納(recDFSではreverse必要)

  void input(){
    cin>>N>>M;
    G.resize(N);
    h.resize(N, 0);
    int f,t;
    for(int i=0; i<M; i++){
      cin>>f>>t;
      f--;t--;
      G[f].push_back(t); //recDFSとtopoBFS両方に必要
      h[t]++; //topoBFSにのみ必要
    }
  }

  void topoBFS(){
    l_depth.resize(N, -1);
    s_depth.resize(N, N);
    
    queue<int> unchecked;
    for(int i=0; i<N; i++){
      if(h[i]==0){
        unchecked.push(i);
        l_depth[i] = 0;
        s_depth[i] = 0;
      }
    }
    while(!unchecked.empty()){
      int current = unchecked.front();
      unchecked.pop();
      ans.push_back(current+1);
      for(int next: G[current]){
        h[next]--;

        l_depth[next] = max(l_depth[next], l_depth[current]+1); //最長経路長
        s_depth[next] = min(s_depth[next], s_depth[current]+1); //最短経路長

        if(h[next]==0){
          unchecked.push(next);
        }
      }
    }
  }

  void recDFS(int look){
    if(l_depth[look]!=-1) return;
    if(G[look].size()){
      for(int next: G[look]){
        recDFS(next);
        l_depth[look] = max(l_depth[next]+1, l_depth[look]);
        s_depth[look] = min(s_depth[next]+1, s_depth[look]);
      }
    }else{
      l_depth[look] = 0;
      s_depth[look] = 0;
    }
    ans.push_back(look+1);
  }
}


int main(){
  int n;
  cin>>n;
  vvi IDs(n, vi(n, -1));
  N = n*(n-1)/2;
  G.resize(N);
  h.resize(N, 0);

  int id = 0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      IDs[i][j] = id;
      IDs[j][i] = id;
      id++;
    }
  }
  /*
  rep(i,n){
    rep(j,n){
      cout<<IDs[i][j]<<",";
    }
    cout<<endl;
  }
  debug(G.size());
  //*/
  int t, bufid, vsid;
  for(int i=0; i<n; i++){
    cin>>t;t--;
    bufid = IDs[i][t];
    for(int j=1; j<n-1; j++){
      cin>>t;t--;
      vsid = IDs[i][t];

      G[bufid].push_back(vsid);
      h[vsid]++;

      bufid = vsid;
    }
  }

  /*
  for(int i=0; i<N; i++){
    debug2(i, h[i]);
  }
  */

  topoBFS();
  /*
  for(int x: ans){
    cout<<x<<",";
  }cout<<" -> ";
  */
  bool isDAG = ans.size()==N;
  //cout<<(isDAG? "閉路なし": "閉路あり")<<endl;
  if(isDAG){
    int l_max = *max_element(l_depth.begin(), l_depth.end());
    cout<<l_max+1<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 39544
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll a, b, k;
  cin >> a >> b >> k;
  if(a-k<0){
    cout << "0" << " " << max(ll(0),b-(k-a)) << endl;
  }
  else cout << a-k << " " << b << endl;
  return 0;
}

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

int gra[101][101];
int n, a, b, c;

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


Measured memory_bytes: 3116