akhauriyash/Code-Regression huggingface dataset:
#りゅうせいの解答3
N = int(input())
task_list = [list(map(int, input().split())) for i in range(N)]

task_list.sort(key=lambda task_list: task_list[1])
time = 0
flag = True

j = 0
while(j < N):
    x = task_list[j]
    time += x[0]
    if time > x[1]:
        flag = False
        break
    j += 1

if flag:
    print("Yes")

else:
    print("No")




#りゅうせいの解答2 正解
# N = int(input())
# task_list = [list(map(int, input().split())) for i in range(N)]
#
# task_list.sort(key=lambda task_list: task_list[1])
# time = 0
# flag = True
#
# for i in range(N):
#     x = task_list[i]
#     time += x[0]
#     if time > x[1]:
#         flag = False
#         break
#
# if flag:
#     print("Yes")
#
# else:
#     print("No")




#りゅうせいの解答1　実行時エラー(exit(1)が原因）、実行時間超過
# N = int(input())
# task_list = [list(map(int,input().split())) for i in range(N)]
#
# task_list.sort(key= lambda task_list: task_list[1])
# time = 0
#
# while(len(task_list)):
#     x = task_list.pop(0)
#     time += x[0]
#     if time > x[1]:
#         print("No")
#         exit(1)
#
#     else:
#         continue
#
# print("Yes")

Measured memory_bytes: 53724
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	rep3(b,k+1,n){
		int p = n/b;
		int r = n%b;
		// a = 0 to N に対して a%b は (0 to b-1) * p + (0 to r) だけ動く
		ans += p * max(0, b-k) + max(0, r-k+1);
		if(k==0) ans--;
		//cout << b << ": " << ans << endl;
	}
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (r<=x&&x<=W-r&&r<=y&&y<=H-r) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

string S;

int main() {
    cin >> S;

    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '?') cout << 'D';
        else cout << S[i];
    }
    cout << endl;
    
    return 0; 
}

Measured memory_bytes: 3728
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;

char s[4444], t[4444];
int sl, tl;
int nxs[4444][2], nxt[4444][2];
int dp[4444][4444];
int nx[4444][4444];

int solve(int a, int b, int c=0) {
  a = min(a, sl);
  b = min(b, tl);
  // printf("%d %d %d\n", a, b, c);
  if (a >= sl - 1 && b >= tl - 1) return 0;
  if (dp[a][b] >= 0) return dp[a][b];
  int p = solve(nxs[a][0], nxt[b][0], 0) + 1;
  int q = solve(nxs[a][1], nxt[b][1], 1) + 1;
  if (p == q || p < q) nx[a][b] = 0;
  else nx[a][b] = 1;
  int res = min(p, q);
  return dp[a][b] = res;
}

void gen(char *s, int l, int nx[4444][2]) {
  for (int i = 0; i < l; i++) {
    for (int j = 0; j < 2; j++) {
      int k = i;
      if (s[k] == j + '0') nx[i][j] = k + 1;
      else {
        k += 1;
        while (s[k] && s[k] != j + '0') {
          ++k;
        }
        nx[i][j] = min(l, k + 1);
      }
    }
  }
  nx[l][0] = nx[l][1] = l;
}

int main(void) {
  scanf("%s%s", s, t);
  strcat(s, "10");
  strcat(t, "10");
  sl = strlen(s);
  tl = strlen(t);
  memset(dp, -1, sizeof(dp));
  memset(nx, -1, sizeof(nx));
  gen(s, sl, nxs);
  gen(t, tl, nxt);
  // printf("%d %d\n", nxs[0][0], nxt[0][0]);
  // printf("%d %d\n", nxs[0][1], nxt[0][1]);
  int res = solve(0, 0);
  int a = 0, b = 0;
  while(nx[a][b] >= 0) {
    int t = nx[a][b];
    printf("%d", t);
    a = nxs[a][t];
    b = nxt[b][t];
  }
  puts("");
  // printf("%d\n", res);
  return 0;
}



Measured memory_bytes: 157148
N = int(input())
a = list(map(int,input().split()))
a = [None] + a

b = [None for _ in range(N+1)]

for i in range(N//2+1,N+1):
    b[i] = a[i]

possible = True
for i in reversed(range(1,N//2+1)):
    s = 0
    for j in range(2,int(N/i)+1):
        s = (s+b[i*j]) % 2
    if b[i] == None:
        b[i] = (a[i] + s) % 2
    elif b[i] != (a[i] + s) % 2:
        possible = False
        break

if possible:
    Ans = []
    for i in range(1,N+1):
        if b[i] == 1:
            Ans.append(str(i))
    print(len(Ans))
    ans = " ".join(Ans)
    if ans != "":
        print(ans)
else:
    print(-1)


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

class Graph
{
  public:
    Graph(int n);

    void Show() const;

  private:
    vector<vector<int>> m_graph;
};

Graph::Graph(int n) :
  m_graph(n, vector<int>(n, 0))
{
  for (int i = 0; i < n; ++i)
  {
    int u, k;
    cin >> u >> k;
    vector<int> list(k);
    for (int j = 0; j < k; ++j)
    {
      cin >> list[j];
    }

    for (auto v : list)
    {
      m_graph[u-1][v-1] = 1;
    }
  }
}

void Graph::Show() const
{
  for (auto a: m_graph)
  {
    for (int i = 0, size = a.size(); i < size; ++i)
    {
      cout << a[i];
      if (i != size - 1)
      {
        cout << " ";
      }
    }
    cout << endl;
  }
}

int main(void)
{
  int n;
  cin >> n;

  Graph graph(n);
  graph.Show();
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int fr[1000006];
int main()
{
int n=D(),k=D();
for(int i=0;i<n;++i){
    int a=D();
   fr[a]++;
}
vector<int>v;
for(int i=1;i<=n;++i)
{
    if(fr[i]!=0)
    v.push_back(fr[i]);
}
sort(v.rbegin(),v.rend());
int c=0;
for(int i=k;i<v.size();++i)
 c+=v[i];
cout<<c<<endl;
}



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

int main(){
    int n,m; cin>>n>>m;
    cout<<n*m<<endl;
}


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

int main(){

    int k,s;
    cin >> k >> s;
    int cnt = 0;
    for (int x = 0; x <= k; x++) {
      for (int y = x; y <= k; y++) {
        for (int z = y; z <= k; z++) {
          if (x+y+z==s) {
            int t;
            if (x==y&y==z) {
              t = 1;
            } else if (x==y||y==z) {
              t = 3;
            } else {
              t = 6;
            }
            cnt+=t;
          }
        }
      }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
ll X,Y,Res;
int main()
{
    
    cin>>X>>Y;
    if (X==1) Res+=300000;
    if (X==2) Res+=200000;
    if (X==3) Res+=100000;
    if (Y==1) Res+=300000;
    if (Y==2) Res+=200000;
    if (Y==3) Res+=100000;
    if (X*Y==1) Res+=400000;
    cout<<Res;
}


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

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String[] whStr = reader.readLine().split(" ");
    int w = Integer.parseInt(whStr[0]);
    int h = Integer.parseInt(whStr[1]);
    
    System.out.println((w * h) + " " + (w * 2 + h * 2));
  }

}

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

int main(){
	int n,max=0,result_num,sec_max=0,two;
	cin >> n;
  	int* a;
  a = new int[n];
  
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
   for(int i=0;i<n;i++){
     if(sec_max<a[i]){
       sec_max = a[i];
     }
        if(max == a[i]){
       		two = 1;
     	}
    	else if(max < a[i]){
      		sec_max = max;
   			max = a[i];
            two = 0;
  		}
     
   }
  
  if(two != 1){
  		for(int i=0;i<n;i++){
    		if(a[i] != max){
   				cout << max << endl;
   			 }
   			 else{
     			 cout << sec_max << endl;
    		}
  		}
  }
  else{
  	for(int i=0;i<n;i++){
     	 cout << max << endl;
  	}
  }
  
  delete a;
  
  return 0;
}

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

using namespace std ; 

int main ( ) 
{ bool flag = true ; 
	string x , y; 
	cin >> x >> y ; 

	if  (x.size() > y.size())

	{
		cout << "GREATER" ; 
	}
	else 
	if (x.size()==y.size() ) 
	{
		for (int i =0;i<x.size();i++)
		{
			if (x[i]>y[i])
			{
				cout << "GREATER" ;
				flag = false ; 
				break ;
			}
			else if (x[i] <y[i])
			{
				cout <<"LESS" ;
				flag = false ; 

				break ;
			}
		}
		if (flag == true ) 
		{
						cout << "EQUAL " ; 

		}
	}
	else 
	if (x.size()<y.size() ) 
	cout << "LESS" ;

		return 0 ; 
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
//
#include <bits/stdc++.h>
//
using namespace std;
//
#define krep(i,k,n)      for(int i=k;i<n;++i)
#define rep(i,n)         for(int i=0;i<n;++i)
#define toupp(s)         transform(s.begin(),s.end(),s.begin(),::toupper) // string
#define tolow(s)         transform(s.begin(),s.end(),s.begin(),::tolower) // string
#define pb(v)            push_back(v)
#define all(v)           v.begin(),v.end()
#define mp               make_pair
#define __sort(v)        sort(v.begin(),v.end()) // vector
#define __stable_sort(v) stable_sort(v.begin(),v.end()) // vector
#define __exists(c,v)    (find(all(c), (v)) != (c).end()) // vector
#define __unique(v)      __sort(v);v.erase(unique(v.begin(),v.end()),v.end()) // vector
#define __swap(a, b, tmp)  tmp=a;a=b;b=tmp;
#define __memset(a)      memset(a,0,sizeof(a));
//
#define dumpVar(v)       cerr<<setw(30)<<#v" = ["<<v<<"]"<<endl
#define dumpArr(v, n)    for(int i=0;i<n;++i){cerr<<v[i]<<", ";} cerr<<endl
#define dumpPair(p)      cerr<<"<"<<p.first<<", "<<p.second<<">"<<endl
//
typedef long long              ll;
typedef vector<string>         vs;
typedef vector<double>         vd;
typedef vector<int>            vi;
typedef pair<int, int>         pii;
typedef pair<double, double>   pdd;
//
int main ()
{
	ios::sync_with_stdio ( false );
	//
	/* code start */
	int n,ans;
	cin >> n;


	ans = 0;
	for(int i = n; i > 0; i-- )ans+= i;
	cout << ans << endl;

	
	
	/* code end   */
	//
	return 0;
}


/* === 2 dimention arr sort === 

struct data{
	int val1;
	int val2;
};

// functions for sort judge 
bool comp1(data x, data y){
	return x.day > y.day ? true : false;
}
bool comp2(data x, data y){
	return x.rew > y.rew ? true : false;
}

// How to use in main function
	vector<data> arr; // �錾
	arr.push_back({_data1,_data2}); // �v�f�̒ǉ�
	sort(arr.begin(), arr.end(),comp1); // comp1�̏����ɏ]���ă\�[�g
*/

// === GCD function ===
/* how to write
__gcd(a,b);
*/


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

using namespace std;

const int MAX_N = 101;
const int MAX_K = 100001;
const int MOD = 1000000007;

int N, K, cum, a[MAX_N], dp[MAX_N][MAX_K];

int add(int a, int b) {
  return (a + b) % MOD;
}
int sub(int a, int b) {
  return (a - b + MOD) % MOD;
}

int main() {
  scanf("%d %d", &N, &K);
  for(int i = 0; i < N; ++i) scanf("%d", &a[i]);

  cum = a[0];
  for(int c = 0; c <= min(cum, K); ++c) dp[0][c] = 1;
  for(int i = 1; i < N; ++i) {
    int r = 0;
    cum += a[i];
    for(int c = 0; c <= min(cum, K); ++c) {
      r = add(r, dp[i - 1][c]);
      if(c > a[i]) r = sub(r, dp[i - 1][c - a[i] - 1]);
      dp[i][c] = r;
    }
  }
  
  printf("%d\n", dp[N - 1][K]);
  return 0;
}

Measured memory_bytes: 42788
N,K=[int(x) for  x in input().split()]
S=input()

out=''
for n in range(N):
    if n+1 == K:
        if S[n]=='A':
            out=out+'a'
        elif S[n]=='B':
            out+='b'
        elif S[n]=='C':
            out+='c'
    else:
        out+=S[n]
print(out)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,n) for(int j=0;j<n;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<string> ve;
typedef vector<pair<int, int> > vepa;
typedef set<string>se;
typedef map<string,int> mpp;
const ll N=1024,OO=1e14,MOD=1e9+7;
const int di[]={1,-1,0,0};
const int dj[]={0,0,1,-1};
ll TC,n,m,k,a,b,cnt,sum,mx,mn,arr[N];
bool f,vis[N];
int main(){
   IOS;
    string s;
    cin>>s;
    rep(i,len(s))
     {
         sum+=( s[i]-'0' );
     }
     if(sum%9==0)cout<<"Yes";
     else cout<<"No";
go;
}


Measured memory_bytes: 3784
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;
	long A, B; cin >> A >> B;

	res = B / 2;
	if (A >= 13) res = B;
	if (A <= 5) res = 0;

	cout << res << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 1; i < s.length(); i++)
		if (s[i - 1] == 'A'&&s[i] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,j,i,k,m1,y1,m2,y2;
    cin>>n>>k;
    long double t,arr[n],temp,sarr[n]={0},max=0;;
    for(i=0;i<n;i++)
    {
    cin>>t;
    temp=double((t+1)/2);
    arr[i]=temp;
    
 
    if(i==0)
    sarr[i]=arr[i];
    else
    sarr[i]=sarr[i-1]+arr[i];
    
    
    }
    max=sarr[k-1];
    for(j=k;j<n;j++)
    {
        temp=sarr[j]-sarr[j-k];

        if(temp>max)
        max=temp;
    }
    cout<<fixed<<setprecision(12)<<max;


    return 0;
    
}
    


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

int n;
vector<int> A(100);

bool solve(int i, int m) {
  if (m == 0) {
    return true;
  }
  if (i >= n) {
    return false;
  }
  bool res = solve(i + 1, m) || solve(i + 1, m - A.at(i));
  return res;
}

int main() {
  cin >> n;
  rep(i, n) cin >> A.at(i);

  int q;
  cin >> q;
  vector<int> m(q);
  rep(i, q) cin >> m.at(i);

  rep(i, q) {
    bool canMake = solve(0, m.at(i));
    if (canMake) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3092
n=int(input())
l=list(map(int,input().split()))
l.sort()
#print(l)
from bisect import bisect_left as bl
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        ans+=bl(l,l[j]+l[i])-j-1
print(ans)


Measured memory_bytes: 45040
from math import ceil
n=int(input())
s=input()
lst=list(s)
i=0
j=n-1
c=0
while i<=j:
    if lst[j]=='R' and lst[i]=='W':
        temp=lst[j]
        lst[j]=lst[i]
        lst[i]=temp
        j-=1
        i+=1
        c+=1
        #print('1')
    elif lst[j]=='R' and lst[i]=='R':
        i+=1
        #print('2')
    elif lst[j]=='W' and lst[i]=='W':
        j-=1
        #print('3')
    elif lst[j]=='W' and lst[i]=='R':
        i+=1
        j-=1
        #print('4')
print(c)

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

int main(){
  ll n; cin >> n;
  
  cout << n*(n-1)/2 << endl;
}



Measured memory_bytes: 256
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components


class People:
    def __init__(self):
        self.frends = 0
        self.blocks = 0


n, m, k = [int(i) for i in input().split()]

data=[1]*m
row=[]
col=[]
peoples = [People() for i in range(n + 1)]
for i in range(m):
    one, two = [int(j) for j in input().split()]
    new_one=min(one,two)
    new_two=max(one,two)
    row.append(one)
    col.append(two)
    peoples[one].frends+=1
    peoples[two].frends+=1

frends = csr_matrix((data, (row, col)), shape=(n+1, n+1))


num, labels = connected_components(frends)
labels=list(labels)

for i in range(k):
    one, two = [int(j) for j in input().split()]
    if labels[one] == labels[two]:
        peoples[one].blocks+=1
        peoples[two].blocks+=1

renketu_num = [0]*num
for i in labels:
    renketu_num[i]+=1


def get_renketu_num(i):
    return renketu_num[labels[i]] - 1


def get_friend_num(i):
    return peoples[i].frends


def get_block_num(i):
    return peoples[i].blocks


for i in range(1, n + 1):
    print(get_renketu_num(i) - get_friend_num(i) - get_block_num(i))


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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

int main(){
    init();
    int n;  cin >> n;
    int arr[n];
    for(int i = 0;i < n;i++){
        cin >> arr[i];
    }

    multiset<int> s;
    s.insert(arr[0]);
    for(int i= 1;i < n;i++){
        auto it = s.lower_bound(arr[i]);
        if(it == s.begin())
            s.insert(arr[i]);
        else{
            it--;
            s.erase(it);
            s.insert(arr[i]);

        }
    }

    cout << s.size();
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char s[3000],t[3000];
    Scs(s);
    Scs(t);

    int n = strlen(s);
    int m = strlen(t);

    static int dp[3003][3003] = {};
    // dp[si][ti] -> s(si)とt(ti)までのLCS(LongestCommonSubsequence)の長さ
    // 配るDP

    // string ans = "";

    Rep(si,n){
        Rep(ti,m){
            if( s[si] == t[ti] ){
                dp[si+1][ti+1] = dp[si][ti] + 1;
            }else{
                dp[si+1][ti+1] = max(dp[si+1][ti] , dp[si][ti+1] );
            }
        }
    }
    /*Rep(si,n+1){
        Rep(ti,m+1){
            printf ("%d ", dp[si][ti] );
        }
        printf ("\n");
    }*/
    string ans = "";
    int sd = n;
    int td = m;
    // dpから文字列を復元する
    // 右下から探し、値が変わる直前まで左上に向かう
    // 値が変わったら文字を頭から入れサーチを続ける
    while( sd>0 && td>0 ){
        if( dp[sd][td] == dp[sd-1][td] ){
            sd--;
        }else if( dp[sd][td] == dp[sd][td-1] ){
            td--;
        }else{
            sd--; td--;
            ans = s[sd] + ans;
        }
    }

    cout << ans << endl;




    return 0;
}



Measured memory_bytes: 35456
/* Author - xorier4104 */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define MOD 			(int) 1e9+7
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define mem(a,b)        memset(a,(b),sizeof(a))
#define max(a,b)        ((a)>(b) ? (a):(b))
#define min(a,b)        ((a)<(b) ? (a):(b))
#define abs(a)          ((a)>0 ? (a):(-(a)))
#define sq(a) 			((a)*(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)

int main(){ FastIO;

	int n;

		cin>>n;
		double answer=2*n*pi;

		cout<<setprecision(20)<<answer<<endl;

return 0;	
}

Measured memory_bytes: 3796
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define Rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0) cout << "Alice" << endl;
	else cout << "Borys" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int high = 0;
		int sum = 0;

		for (int i = 0; i < N; i++) {
			int temp = sc.nextInt();
			sum += temp;
			if(temp > high) {
				high = temp;
			}
		}

		System.out.println(sum - (high / 2));

	}
}

Measured memory_bytes: 20820
#include <iostream>
#include <string>
int main()
{
	int H, W, K;
	std::cin >> H >> W >> K;
	bool* mtx = new bool[H*W];
	for (int row = 0; row < H; ++row) {
		std::string s;
		std::cin >> s;
		for (int col = 0; col < W; ++col) {
			mtx[row*W + col] = (s[col] == '#');
		}
	}
	const int count = 1 << (H + W);
	int answer = 0;
	for (int i = 0; i < count; ++i)
	{
		int black = 0;
		for (int row = 0; row < H; ++row) {
			for (int col = 0; col < W; ++col) {
				if (mtx[row*W + col]) {
					if ((i&(1 << row)) == 0)
					{
						if ((i&(1 << (H + col))) == 0)
						{
							++black;
						}
					}
				}
			}
		}
		if (black == K)
		{
			++answer;
		}
	}
	std::cout << answer << std::endl;
	delete[] mtx;
	return 0;
}

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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define pii pair < int , int >
#define pll pair < long long, long long >

const int N = 200005;


int main()
{
    #ifdef Estb_probitie
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int n, w;
    cin >> n >> w;

    ll dp[2][100005] = {};

    fill(dp[0],dp[0] + 100002, -1e18);
    fill(dp[1],dp[1] + 100002, -1e18);

    ll ma = -1;
    bool now = 0;
    dp[0][0] = dp[1][0] = 0;


    for (int i = 0; i < n; ++i)
    {
        int we, us;
        cin >> we >> us;
        for (int j = 0; j <= w - we; ++j)
            dp[!now][j + we] = max(dp[!now][j + we], dp[now][j] + us);

        for (int j = 0; j <= w; ++j)
            dp[now][j] = dp[!now][j] = max(dp[now][j], dp[!now][j]);
        now = !now;
    }

    for (int i = 0; i <= w; ++i)
          ma = max(ma, dp[now][i]);

    cout << ma;

}



Measured memory_bytes: 1792
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

string result_patterns[] = {"EQUAL", "GREATER", "LESS"};
int main() {
  vector<string> Numbers(2);
  cin >> Numbers[0];
  cin >> Numbers[1];

  int ans = 0;
  if (Numbers[0].size() > Numbers[1].size()) {
    ans = 1;
  } else if (Numbers[0].size() < Numbers[1].size()) {
    ans = 2;
  } else if (Numbers[0] == Numbers[1]) {
    ans = 0;
  } else {
    for (int i = 0; i < Numbers[0].size(); i++) {
      if (Numbers[0][i] > Numbers[1][i]) {
        ans = 1;
        break;
      } else if (Numbers[0][i] < Numbers[1][i]) {
        ans = 2;
        break;
      }
    }
  }

  cout << result_patterns[ans] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    string ans;
    int i = 0, j = 0;
    while(i + j < 2 * N){
        if(i == j) {
            ans += S[i];
            i++;
        }
        else{
            ans += T[j];
            j++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = 3.141593;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	ll a,b,n;cin>>a>>b>>n;
    cout << max(((a*n)/b-a*(n/b)), ((a*((n/b)*b-1))/b-a*((((n/b)*b-1))/b))) << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int N, W; cin >> N >> W;
    int v[110], w[110];
    rep(i,0,N) cin >> v[i] >> w[i];

    // i ???????????§????????£????????? j ????????????????????????????°????
    int dp[110][10010] = {};
    repq(i,0,N) rep(j,0,10010) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,0,N) {
        rep(j,0,10010) {
            if(j - v[i] >= 0 && dp[i][j-v[i]] + w[i] <= W)
                dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    int ans = 0;
    rep(j,0,10010) if(dp[N][j] < INF) ans = j;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11700
#include <iostream>
#include <vector>

using namespace std;
const int INF = 1001001001;

void djkstra(const vector< vector< int > >& edges, vector< int >& d, int root)
{
    int n = d.size(), node, min_dist;
    d[root] = 0;
    vector<int> color(n, 0);

    while(true)
    {
        min_dist = INF;
        for(int i=0;i<n;++i)
        {
            if(color[i] == 0 && d[i] < min_dist)
            {
                node = i;
                min_dist = d[i];
            }
        }
        if(min_dist == INF) break;
        color[node] = 1;
        for(int i=0;i<n;++i)
        {
            d[i] = min(d[i], edges[node][i] + d[node]);
        }
    }
}

int main()
{
    int n, k, u, v, c;
    cin >> n;
    vector< vector< int > > edges(n, vector<int>(n, INF));
    vector<int> d(n, INF);
    for(int i=0;i<n;++i)
    {
        cin >> u >> k;
        for(int j=0;j<k;++j)
        {
            cin >> v >> c;
            edges[u][v] = c;
        }
    }

    djkstra(edges, d, 0);
    for(int i=0;i<d.size();++i)
    {
        cout << i << " " << d[i] << endl;
    }
}


Measured memory_bytes: 3148
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(a==0)return 0; if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
//ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}
ll modncr(ll n, ll r){return modmul(modfact(n), modinv(modmul(modfact(n-r), modfact(r))));}

int main() {

    ll x, y; 
    cin >> x >> y;
    ll ans, n, m;
    if ((x + y) % 3 == 0 && 2 * y - x >= 0 && 2 * x - y >= 0) {
        n = (2 * y - x) / 3;
        m = (2 * x - y) / 3;
        ans = modncr(m+n, m);
    }
    else ans = 0;
    out(ans);

    return 0;
}






Measured memory_bytes: 504
/*
Date:
Author:
Descipction
*/
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
struct store
{
	long long int price;
	long long int num;
};
bool compare(store a,store b)
{
	return a.price<b.price;
};

int main()
{
	long long int n,m,i=0,j,sum=0/*算累積錢*/,need/*差幾罐*/;
	cin>>n>>m;
	need=m;
	store data[n];
	for(;i<n;i++)
	{
		cin>>data[i].price>>data[i].num;
	}
	sort(data,data+n,compare);
	i=0;
	while(need>0)
	{
		if(data[i].num<=need)
		{
			sum+=data[i].num*data[i].price;
			need-=data[i].num;
		}
		else
		{
			sum+=need*data[i].price;
			need=0;
		}
		i++;
	}
	cout<<sum<<endl;
	return 0;
}



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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rall(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define sz(a) int((a).size())
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}

int n;
ll a[100005];
void solve() {
    cin >> n;

    rep(i, n)
        cin >> a[i];

    ll ans = 0;
    for (int c = 1; c < n; ++c) {
        ll res = 0;
        vector<bool> used(n, false);
        for (int x = 0; x * c < n; ++x) {
            auto aa = n - 1 - x * c;
            auto b = aa - c;
            if (b <= 0 || x * c == n - 1 - x * c || used[x * c] || used[n - 1 - x * c])
                break;

            res += a[x * c] + a[n - 1 - x * c];
            used[x * c] = used[n - 1 - x * c] = true;
            ans = max(ans, res);

        }
    }

    cout << ans << endl;

    return;
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    return 0;
}


Measured memory_bytes: 1152
import java.util.ArrayDeque;
import java.util.Scanner;


public class Main {
	
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] begin = new int[n];
		int[] end = new int[n];
		for (int i=0;i<n;i++) {
			begin[i]=sc.nextInt();
		}
		for (int i=0;i<n;i++) {
			end[i]=sc.nextInt();
		}
		
		long count = 0;
		
		ArrayDeque<Integer> check = new ArrayDeque<>();
		
		for (int i=0;i<n;i++) {
			check.offer(i);
		}
		while (!check.isEmpty()) {
			int i = check.poll();
			int times = process(end, begin, i);
			if (times>0) {
				count += times;
				check.offer(i==0 ? n-1 : i-1);
				check.offer(i==n-1 ? 0 : i+1);
			}
		}
		
		boolean same = true;
		for (int i=0;i<n;i++) {
			if (begin[i]!=end[i]) {
				same=false;
				break;
			}
		}
		if (same) {
			System.out.println(count);
		} else {
			System.out.println(-1);
		}
	}
	
	static int process(int[] end, int[] begin, int i) {
		int left = (i==0 ? end[end.length-1] : end[i-1]);
		int right = (i==end.length-1 ? end[0] : end[i+1]);

		if (end[i]>left+right && end[i]>begin[i]) {
			int ret = (end[i]-begin[i])/(left+right);
			end[i]-=((left+right)*ret);
			return ret;
		} else {
			return 0;
		}
	}
}

Measured memory_bytes: 133520
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut mi = n + 1;
    let mut cur = 0;
    for i in 0..n {
        if mi >= p[i] {
            cur += 1;
        }
        mi = min(mi, p[i]);
    }
    puts!("{}\n", cur);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    string S;
    int topping = 0;
    cin >> S;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'o') topping++;
    }
    cout << 700 + 100 * topping << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

//cの高さkの木のサイズ
long count(long[][] g, bool[] used, long c, long k) {
    if(used[c]) {
        return 0;
    }
    used[c] = true;
    if(k <= 0) {
        return 0;
    }
    long ans = 1;
    foreach(v; g[c]) {
        ans += count(g, used, v, k-1);
    }
    return ans;
}

void main(){
    long n, k;
    readlnTo(n, k);

    auto g = new long[][](n);
    foreach(i; iota(n-1)) {
        long a, b;
        readlnTo(a, b);
        a--;
        b--;
        g[a] ~= b;
        g[b] ~= a;
    }
    long ans = n;
    foreach(i; iota(n)) {
        auto m = k/2;
        long s = 1;
        foreach(vi; g[i]) {
            auto used = new bool[](n);
            used[i] = true;
            s += count(g, used, vi, m);
        }
        if(k%2 == 1) {
            long t = 0;
            foreach(vi; g[i]) {
                auto used = new bool[][](2,n);
                used[0][i] = true;
                used[1][i] = true;
                t = max(t, count(g, used[0], vi, m+1) - count(g, used[1], vi, m));
            }
            s += t;
        }
        ans = min(ans, n-s);
    }
    writeln(ans);
}



Measured memory_bytes: 1404
import sys

pre_strk = 1
now_strk = 1
ans = 1
n = int(input())
d_list = list(map(int,input().split()))
# print(d_list)
if d_list[0] != 0:
    print(0)
    sys.exit()

d_list.sort()
if d_list[1] == 0:
    print(0)
    sys.exit()

for i in range(1,n):
    if d_list[i] == d_list[i-1]:
        now_strk += 1

    elif d_list[i] > d_list[i-1] + 1:
        print(0)
        sys.exit()

    elif d_list[i] != d_list[i-1] and d_list[i-1] != 1:
        for j in range(now_strk):
            ans *= pre_strk
        pre_strk = now_strk
        now_strk = 1
        # print(ans)
        ans = ans % 998244353

    else:
        pre_strk = now_strk
        now_strk = 1
for i in range(now_strk):
    ans *= pre_strk
print(ans%998244353)



Measured memory_bytes: 14396
#include<bits/stdc++.h>
#define D(x) cerr<<#x<<'='<<x<<'\n';
using namespace std;
typedef long long ll;
int main()
{
	int n,r;
	scanf("%d%d",&n,&r);
	printf("%d",n>=10?r:r+(10-n)*100);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  int ans = 0, tmp = 0;
  bool flag = false;
  REP(i, N){
    if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
      tmp++;
    }else if(tmp != 0){
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans << endl;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
 
A = a[0]
B = a[1]
C = a[2]
D = a[3]
 
while A>0 and C>0:
  C = C - B
  if C <= 0:
    print("Yes")
    break
  A = A - D
  if A <= 0:
    print("No")
    break

Measured memory_bytes: 9124
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]

flg = False
count = 0
for i in range(n):
  if d[i][0] == d[i][1]:
    flg = True
  else:
    flg = False
    count = 0
    
  if flg:
    count += 1
  if count >= 3:
    print('Yes')
    exit(0)
print('No')

Measured memory_bytes: 9208
N = int(input())
V_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

sum = 0
for i in range(N):
    if V_list[i] >= C_list[i]:
        sum += V_list[i] - C_list[i]
    else:
        pass

print(sum)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    int h, a;
    cin >> h >> a;
    int count = 0;
    while(true){
        count++;
        h -= a;
        if(h <= 0) {
            cout << count;
            break;
        }

    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};
string alphabet = "abcdefghijklmnopqrstuvwxyz";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        print((n - 30)/ 2);
    }
}



Measured memory_bytes: 3220
#include <iostream>
using namespace std;
 
int main()
{
    while(true){
        int H;
        cin >> H;
 
        if(H==0)
            break;
 
        int S[10][5];
        for(int y=0; y<H; y++){
            for(int x=0; x<5; x++){
                cin >> S[y][x];
            }
        }
 
        int sco = 0;
 
        while(true){
            bool flg = false;
 
            for(int y=0; y<H; y++){
                int m = S[y][2];
                if(m==0)
                    continue;
 
                if(S[y][0]==m && S[y][1]==m){
                    sco += m*3;  S[y][0] = S[y][1] = S[y][2] = 0;  flg = true;
                    if(S[y][3]==m){
                        sco += m;  S[y][3] = 0;
                        if(S[y][4]==m){
                            sco += m;  S[y][4] = 0;
                        }
                    }
                }
                else if(S[y][1]==m && S[y][3]==m){
                    sco += m*3;  S[y][1] = S[y][2] = S[y][3] = 0;  flg = true;
                    if(S[y][4]==m){
                        sco += m;  S[y][4] = 0;
                    }
                }
                else if(S[y][3]==m && S[y][4]==m){
                    sco += m*3;  S[y][2] = S[y][3] = S[y][4] = 0;  flg = true;
                }
            }
 
            if(!flg)
                break;
 
            for(int x=0; x<5; x++){
                for(int y=H-1; y>=0; y--){
                    if(S[y][x]!=0)
                        continue;
 
                    for(int y2=y-1; y2>=0; y2--){
                        if(S[y2][x]!=0){
                            S[y][x] = S[y2][x];
                            S[y2][x] = 0;
                            break;
                        }
                    }
                }
            }
        }
 
        cout << sco << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3068