akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    set<int> st;
    REP(i,n){
        int l,r; cin >> l >> r;
        FOR(j,l,r+1) st.insert(j);
    }
    out(st.size());

    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int n;
ll d;
int main(){
    scanf("%d%lld",&n,&d);
    d = d * d;
    int cnt=0;
    for(int i=1;i<=n;i++){
        ll x,y;scanf("%lld%lld",&x,&y);
        ll v = x*x + y*y;
        if(v<=d) ++cnt;
    }
    printf("%d\n",cnt);
    return 0;
}

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

int main() {
  int n,t;
  while(cin>>n) {
    vector<int> v;
    for(int i=0; i<n; ++i) {
      cin>>t;
      v.push_back(t);
    }
    sort(v.begin(), v.end());
    int pena = 0,sum = 0;
    for(int i=0; i<n; ++i) {
      sum += v[i];
      pena += sum;
    }
    cout<<pena<<endl;
  }
}

Measured memory_bytes: 0
n = int(raw_input())
A = map(int, raw_input().split(" "))

def printElem(B):
    string = ""
    for elem in B:
        string += str(elem) + " "
    print(string[:len(string)-1])

printElem(A)

for i in range(1, n):
    key = A[i]
    j = i - 1

    while j >= 0 and A[j] > key:
        A[j+1] = A[j]
        j -= 1

    A[j+1] = key

    printElem(A)

Measured memory_bytes: 6464
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

cnt = 0

for i in range(n-2):
    c = a[i] - b[i] 
    if c == 0:
        d = a[i+1] - b[i+1]
        if d == 0:
            e = a[i+2] - b[i+2]
            if e == 0:
                cnt += 1

if cnt == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9192
N, M, C = map(int, input().split())

BL = list(map(int, input().split()))

ALL = []
for _ in range(N):
    ALL.append(list(map(int, input().split())))

R = 0
for al in ALL:
    if sum([a * b for (a, b) in zip(al, BL)]) + C > 0:
        R += 1

print(R)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  cin>>X;
  bool prime=true;
  int count=0; //約数の数
  if(X==2){
    cout<<2<<endl;
  }
  else{
  while(prime){
    count=0;
    for(int j=2; j*j<=X; j++){
      if(X%j==0){
        count++;
        break;
      }
    } //j
    if(count==0){
      prime=false;
    }
    X+=1;
  } //while
      cout<<X-1<<endl;
  } //else
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
   for(int i = 0;i < N;i++){
       int L[N];
       int R[N];
       cin >> L[i] >> R[i];
       ans += R[i] - L[i] + 1;
   }

cout << ans <<endl;
}

Measured memory_bytes: 384
n,l=map(int,input().split())
nl=n+l
ls=[]
for i in range(l,nl):
    ls.append(i)
mn=500
for j in ls:
    if abs(j)<abs(mn):
        mn=j
    else:
        continue
ls.remove(mn)
ans=sum(ls)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;


int main(){
    int N,K;
    cin>>N>>K;
    vector<double> n(N+1,0);
   
    for(int i=0;i<N;i++){
        double a=0.0;
        cin>>a;
        n[i+1]=(a+1.0)/2.0;
    }

    for(int i=1;i<=N;i++){
        n[i]+=n[i-1];
    }

    double max=0.0;
    for(int i=0;i<N-K+1;i++){
        if(n[i+K]-n[i]>max){
            max=n[i+K]-n[i];
        }
    }
    
    cout<<fixed << setprecision(15)<<max<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>

using namespace std;

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    
    vector<int> xx(n);
    vector<int> yy(m);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> xx[i];
    }
    for (int i = 0; i < m; ++i)
    {
        cin >> yy[i];
    }
    
    sort(xx.begin(), xx.end());
    sort(yy.begin(), yy.end());
    
    int zmin = xx[n - 1] + 1;
    int zmax = yy[0];
    
    if (x < zmax && y >= zmin && zmin <= zmax)
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
    
    
    return 0;
}

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

const int MAX = 210000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
    COMinit();
    int K, N;
    cin >> K >> N;
    for (int query = 2; query <= K*2; ++query) {
        long long res = 0;
        int Q = query;
        if (query > K + 1) Q = (K+1)*2 - query;
        int q = Q/2;
        for (int i = 0; i <= q; ++i) {
            long long tmp = COM(q, i) * COM(K+N-i*2-1, N-i*2) % MOD;
            if (i & 1) res = (res - tmp + MOD) % MOD;
            else res = (res + tmp) % MOD;
        }
        cout << res << endl;
    }
}


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

int main(){
    int N, K, H[100000];
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> H[i];
    sort(H, H+N);
    
    int ans = 2e9;
    for(int i=0; i<=N-K; i++) ans = min(ans, H[i+K-1] - H[i]);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int power(int x)
{
    int s=1;
    for(int i=0;i<3;i++)
        s*=x;

    return s;
}

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



    int n;cin >> n;
    if(n == 1)return cout << 1,0;
    else cout << power(n);







    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int insertionSort(int *A, int n, int g);
void shellSort(int *A, int n);

int main()
{
    int i,n;
    scanf("%d%*c",&n);
    int *A;
    A = malloc(n*sizeof(int));
    for (i=0;i<n;i++)
    {
        scanf("%d%*c",&A[i]);
    }
    shellSort(A,n);
    for (i=0;i<n;i++)
    {
        printf("%d\n",A[i]);
    }


    return 0;
}

int insertionSort(int *A, int n, int g)
{
    int i,j,tmp,cnt=0;
    for(i=g;i<n;i++)
    {
        tmp = A[i];
        j = i-g;
        while (j>=0 && A[j]>tmp)
        {
            A[j+g] = A[j];
            j = j-g;
            cnt++;
        }
        A[j+g] = tmp;
    }
    return cnt;
}

void shellSort(int *A,int n)
{
    int ans[102] = {1};
    int i,j,m=1,cnt=0;
    int h=1;
    for (i=0;i<((int)(n*0.333333)+1);i++)
    {
        h = 3*h+1; // h=1,4,13,40,121,364...
        if (h<=n && m<100)
        {
            ans[m] = h;
            m+=1;
        }
        else break;
    }
    printf("%d\n",m);
    int *G;
    G = malloc((m)*sizeof(int));
    for (i=0;i<m;i++)
    {
        G[i] = ans[m-1-i];
        printf("%d",G[i]);
        if (i<m-1) printf(" ");
    }
    printf("\n");
    for (i=0;i<m;i++)
    {
        cnt += insertionSort(A,n,G[i]);
    }
    printf("%d\n",cnt);
    free(G);
    return; //G 넣은뒤 m,cnt넣어놓기.
}


Measured memory_bytes: 5624
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

string getLine(char c, int length){
    stringstream ss;
    FOR(i, 0, length){
        ss << c;
    }
    return ss.str();
}

vector<string> grid(100);

// 横に3つとびでドットを塗る
int paintDot(char color, int rowIndex, int maxInkNuM){
    int offset = 0;
    if(rowIndex % 2 == 1){
        offset = 2;
    }

    int i = 0;
    int paintNum = 0;
    while(i < 100 && maxInkNuM - paintNum > 0){
        grid[rowIndex][i+offset] = color;
        i+=4;
        paintNum++;
    }
    return paintNum;
}

void printGrid(){
    FOR(i, 0, 100){
        p(grid[i]);
    }
}

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

    // input
    int A, B;
    cin >> A >> B;
    
    FOR(i, 0, 50){
        grid[i] = getLine('#', 100);
    }
    FOR(i, 50, 100){
        grid[i] = getLine('.', 100);
    }

    // paint by white
    int drawNum = A-1;
    int rowIndex = 0;
    while(drawNum>0){
        int drawnNum = paintDot('.', rowIndex, drawNum);
        drawNum -= drawnNum;
        rowIndex++;
    }

    // black
    drawNum = B-1;
    rowIndex = 51;
    while(drawNum>0){
        int drawnNum = paintDot('#', rowIndex, drawNum);
        drawNum -= drawnNum;
        rowIndex++;
    }

    p("100 100");
    printGrid();
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits>

using namespace std;

int64_t score[100'001];
int64_t rScore[100'001];
int64_t mScore[100'001];
int64_t rmScore[100'001];
int64_t mCost[100'001];
int64_t rmCost[100'001];
int64_t x[100'000];
int64_t v[100'000];

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

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> v[i];
    }

    score[0] = rScore[0] = 0;
    for (int i = 1; i <= N; i++)
    {
        score[i] = score[i - 1] + v[i - 1];
        rScore[i] = rScore[i - 1] + v[N - i];
    }

    for (int i = 1; i <= N; i++)
    {
        score[i] -= x[i - 1];
        rScore[i] -= C - x[N - i];
    }

    mScore[0] = rmScore[0] = 0;
    mCost[0] = rmCost[0] = 0;
    for (int i = 1; i <= N; i++)
    {
        if (mScore[i - 1] < score[i])
        {
            mScore[i] = score[i];
            mCost[i] = x[i - 1];
        }
        else
        {
            mScore[i] = mScore[i - 1];
            mCost[i] = mCost[i - 1];
        }

        if (rmScore[i - 1] < rScore[i])
        {
            rmScore[i] = rScore[i];
            rmCost[i] = C - x[N - i];
        }
        else
        {
            rmScore[i] = rmScore[i - 1];
            rmCost[i] = rmCost[i - 1];
        }
    }

    int64_t result = numeric_limits<int64_t>::min();
    for (int i = 0; i <= N; i++)
    {
        int64_t a = mScore[i] + rmScore[N - i];
        int64_t b = min(mCost[i], rmCost[N - i]);
        result = max(result, a - b);
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int main(){
    int A,B,ans=0;
    cin >> A >> B;
    ans += max(A,B);
    if(A>B){
        A--;
    }else{
        B--;
    }
    ans += max(A,B);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>   
using namespace std;
 
int main(){
	double a,b,c,d,e,f,aa,bb,cc,i = 0,x,y;
	while(cin >> a >> b >> c >> d >> e >> f){
	aa = a;
	bb = b;
	cc = c;
	a = a * d;
	b = b * d;
	c = c * d;

	d = d * aa;
	e = e * aa;
	f = f * aa;

	y = (c - f) / (b - e);
	x = cc - (bb * y);
	x = x / aa;
    cout << fixed << setprecision(3) << x << " " << fixed << setprecision(3) << y << endl;
	}
}

Measured memory_bytes: 1280
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N;
    cin >> N;

    map<string, int> m;

    rep(i, N)
    {
        string s;
        cin >> s;

        m[s]++;
    }

    cout << "AC" << " x " << m["AC"] << endl;
    cout << "WA" << " x " << m["WA"] << endl;
    cout << "TLE" << " x " << m["TLE"] << endl;
    cout << "RE" << " x " << m["RE"] << endl;

    return 0;
}

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

const  int INF = 100100100;

int a[12][12];
int main(){
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i,n){
		cin >> c[i];
		rep(j,m) cin >> a[i][j];
	}
	int ans = INF;
	rep(s,1<<n){
		int cost = 0;
		vector<int> d(m);
		rep(i,n){
			if(s>>i&1){
				cost += c[i];
				rep(j,m) d[j] += a[i][j];
			} 
		}
		bool ok = true;
		rep(j,m) if(d[j] < x) ok = false;
		if(ok) ans = min(ans,cost);
	}
	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 2005;
void solve(){
	int n;
	cin>>n;
	if(n>=30){
		cout<<"Yes\n";
	}
	else
		cout<<"No\n";

}

int main() {	
	IOS
	ll T;
	// cin>>T;
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		solve();
		// i++;
	}
	return 0;
	
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define M 2001

long long L[M];
long long n;

using namespace std;

int main()
{
	long long tot = 0;

	cin >> n;

	for (long long i = 1; i <= n; i++)
		cin >> L[i];

	sort(L + 1, L + n + 1);

	for (long long i = 1; i <= n - 2; i++)
		for (long long j = i + 1; j <= n - 1; j++)
		{
			long long tmp = L[i] + L[j] - 1;
			long long pos = upper_bound(L + j + 1, L + n + 1, tmp) - L;
			pos -= 1;
			tot += pos - j;
		}

	cout << tot << endl;

	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int tab[210];
	bool ada=false;
	for (int i=1;i<=n;i++)
	 {
	 	cin>>tab[i];
	 	if (tab[i]%2==1)
	 	 ada=true;
	 }
	int ans=0;
	while (1)
	{
		ada=false;
		for (int i=1;i<=n;i++)
		 if (tab[i]%2==1)
		  {
		  	ada=true;
		  	break;
		  }
		if (ada) break;
		++ans;
		for (int i=1;i<=n;i++)
		 tab[i]/=2;	
	}
	cout<<ans<<"\n";
}

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

using namespace std;

int main() {
    int n; cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    long long res = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) res += a[i] * a[j];
    }
    cout << res;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> div(n+1);
  int ans = 0;
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      if (i % j == 0) div[i]++;
    }
  }
  for(int i=1; i<=n; i++) {
    if (div[i] == 8 && i % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		SortedShops ss = new SortedShops(a, b);
		System.out.println(ss.getTotalPrice(m));
	}
	
}

class SortedShops {
	Shop[] shops;
	public SortedShops(int[] a, int[] b) {
		int n = a.length;
		shops = new Shop[n];
		for (int i = 0; i < n; i++) {
			shops[i] = new Shop(a[i], b[i]);
		}
		Arrays.sort(shops, (p, q) -> p.price - q.price);
		for (Shop s : shops) {
			//			System.out.println(s.price + " " + s.number);
		}
	}
	long getTotalPrice(int m) {
		long totalPrice = 0;
		int num = m;
		for (Shop s : shops) {
			int buy = Math.min(num, s.number);
			num -= buy;
			totalPrice += (long)buy * s.price;
			//			System.out.println(buy + " " + totalPrice);
			if (num == 0) {
				break;
			}
		}
		return totalPrice;
	}
}

class Shop {
	int price;
	int number;
	public Shop(int a, int b) {
		price = a;
		number = b;
	}
}


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

using namespace std;

typedef long long ll;

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

    float ans;
    for (int i = 0; i < n; i++) {
        float x;
        string u;
        cin >> x >> u;
        if (u == "BTC") {
            x *= 380000;
        }
        ans += x;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();
        if(m1 == m2){
            System.out.println(0);
        }else{
            System.out.println(1);
        }

    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}



Measured memory_bytes: 23124
#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  long h[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &h[i]);
  }

  long count = 0;
  long max = 0;
  for (long i = 1; i < n; i++) {
    if (h[i] <= h[i-1]) {
      count++;
    } else {
      if (count > max) {
        max = count;
      }
      count = 0;
    }
  }
  if (count > max) {
    max = count;
  }

  printf("%ld\n", max);

  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

// UnionFind tree(n);  と宣言

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        siz.assign(sz_, 1LL);  // assign: 再代入
        par.resize(sz_);  // resize: 再確保
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

ll ans[100010];

int main () {

    ll n,m;cin>>n>>m;

    ll a[100010],b[100010];

    rep(i,m) {
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
    }

    ans[m-1]=(n*(n-1))/2;

    UnionFind tree(n);

    for (ll i = m-1; i >= 1; --i) {
        ll node1, node2;
        node1 = a[i], node2 = b[i];
        if (tree.issame(node1, node2)) {
            ans[i-1] = ans[i];
        } else {
            // 根が異なるとき，それぞれのサイズの積（頂点の組み合わせ）を引く．
            ans[i-1] = ans[i] - (tree.size(node1) * tree.size(node2));
            tree.merge(node1, node2);
        }
    }

    rep(i,m) {
        cout<<ans[i]<<endl;
    }



}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=3e3+5;
ll inf=1e15;

ll dp[sz][sz][2],ar[sz];


ll f(int st,int en,int t)
{
    if(st==en)
    {
        if(t)
            return 0;
        else
            return ar[st];
    }
    ll &res=dp[st][en][t];
    if(res!=-1)
        return res;
    if(t)
    {
        res=min(f(st+1,en,t^1),f(st,en-1,t^1));
    }
    else
    {
        res=max(ar[st]+f(st+1,en,t^1),ar[en]+f(st,en-1,t^1));
    }

    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n;

        ll sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>ar[i];
            sum+=ar[i];
        }
        memset(dp,-1,sizeof(dp));

        ll y=sum-f(0,n-1,0);
        cout<<f(0,n-1,0)-y<<endl;

        
    }

    return 0;
}

Measured memory_bytes: 144856
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int n,x,t;
  cin >> n >> x >> t;
  cout << (n + x - 1)/x * t << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B;
  int amount=0;
  cin>>A>>B;
  if(A>= 13)
    cout<<B;
  else
    if(A>=6 && A<=12)
      cout<<B/2;
  else
    if(A>=0 && A<=5)
      cout<<"0";
  else 
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

struct segtree
{
	static const int SIZE = 1 << 19;
	int data[2 * SIZE];

	segtree() {
		fill(data, data + 2 * SIZE, 0);
	}
	void clear() {
		fill(data, data + 2 * SIZE, 0);
	}
	void incl(int p) {
		p += SIZE;
		while (p) {
			data[p] += 1;
			p >>= 1;
		}
	}
	int query(int L, int R) {
		L += SIZE;
		R += SIZE;
		int ret = 0;
		while (L < R) {
			if (L & 1) ret += data[L++];
			if (R & 1) ret += data[--R];
			L >>= 1; R >>= 1;
		}
		return ret;
	}
};

int N;
int P[303030];

int odds[303030], evens[303030];

void add_range(int *a, int lo, int hi)
{
	if (lo == hi) return;
	if (lo > hi) swap(lo, hi);
	a[lo] += 1;
	a[hi + 1] -= 1;
}

segtree seg;

bool check(int x)
{
	seg.clear();
	i64 inv = 0, mv = 0;
	for (int i = 0; i < N; ++i) if (i % 2 == x) {
		inv += seg.query(P[i] + 1, N);
		seg.incl(P[i]);
		mv += abs(i - P[i]) / 2;
	}
	return inv * 2 == mv;
}

i64 inv()
{
	i64 ret = 0;
	for (int i = 0; i < N; ++i) {
		ret += seg.query(P[i] + 1, N);
		seg.incl(P[i]);
	}
	return ret;
}

int main()
{
	i64 v, mov;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", P + i);
		--P[i];
	}
	for (int i = 0; i < N; ++i) {
		if (i % 2 != P[i] % 2) goto fail;
		if (i % 2 == 0) {
			add_range(evens, i, P[i]);
		} else {
			add_range(odds, i, P[i]);
		}
	}
	for (int i = 1; i < N; ++i) {
		odds[i] += odds[i - 1];
		evens[i] += evens[i - 1];
	}
	for (int i = 0; i < N; ++i) {
		if (odds[i] > 0 && evens[i] > 0) goto fail;
	}

	if (!check(0) || !check(1)) goto fail;

	puts("Yes");
	return 0;
fail:
	puts("No");
	return 0;
}


Measured memory_bytes: 7936
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    vector<ll> a(n+1),b(n);
    for(int i = 0; i < n+1; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }

    ll ans = 0;

    for(int i = 0; i < n; i++){
        if(a[i] > b[i]){
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }else{
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }
        if(a[i+1] > b[i]){
            ans += b[i];
            a[i+1] -= b[i];
            b[i] = 0;
        }else{
            ans += a[i+1];
            b[i] -= a[i+1];
            a[i+1] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main() {
	int a;
	cin>>a;
	if(a<1200)cout<<"ABC"<<endl;
	else if(a<2800) cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;
    return 0;
}


Measured memory_bytes: 768
def solve(h, w, A, B):
    center = 80 * (h + w - 1)
    C = [[abs(A[r][c] - B[r][c]) for c in range(w)] for r in range(h)]
    dp = [[0] * w for r in range(h)]
    dp[0][0] = (1 << (center + C[0][0])) | (1 << (center - C[0][0]))
    for r in range(h):
        for c in range(w):
            if r > 0:
                dp[r][c] |= (dp[r-1][c] << C[r][c]) | (dp[r-1][c] >> C[r][c])
            if c > 0:
                dp[r][c] |= (dp[r][c-1] << C[r][c]) | (dp[r][c-1] >> C[r][c])
    mask = bin(dp[-1][-1] >> center)
    return mask[::-1].find("1")
h, w = map(int, input().split())
A = [list(map(int, input().split())) for i in range(h)]
B = [list(map(int, input().split())) for i in range(h)]
print(solve(h, w, A, B))

Measured memory_bytes: 20212
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	
	int N, A, B;
	cin >> N >>A>>B;
	
	cout <<std::min(N*A, B)<<endl;
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
k=int(input())
list=[0, 1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772,10813692]
print(list[k])


Measured memory_bytes: 9368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
#define ERASE(a)  (a).erase(unique((a).begin(), (a).end()), (a).end()); // sortしてから
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    string s, t; cin >> s >> t;
    int ans = 0;
    rep(i, s.size())
    {
        if (s[i] != t[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3912
N, K, S = map(int, input().split())

array = []
if N >= K :
  if (N-K) >= S:
    array.extend([S] * K)
    array.extend([S+1] * (N-K))
  else:
    array.extend([S] * K)
    array.extend([1] * (N-K))

array_str = " ".join(map(str, array))
print(array_str)

Measured memory_bytes: 12004
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define Reza ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define         ll          long long
#define         yes         cout<<"YES"<<endl
#define         no          cout<<"NO"<<endl
#define         ff          first
#define         sc          secound
#define         MAX         10000



int main()
{
    Reza;
    string s,s2,s3,s4,s5;
      ll q,n,a,b,c,d,x,y,o,cnt=0,cnt2=1,sum=0,mm=0,mx=0;
   cin>>n;
   for(ll i=1;i<=n;i++){
      if(i%3==0 || i%5==0) continue;
      else sum+=i;
   }
   cout<<sum<<endl;

    return 0;

}






Measured memory_bytes: 3612
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1
#define INF (1<<21)
int n;
int d[N],pi[N],color[N],G[N][N];
int prim(void){
  int mincost,u,v,i,weight=0;
  for(u=0;u<n;u++){
    d[u]=INF;
    pi[u]=NIL;
    color[u]=WHITE;
  }
  d[0]=WHITE;
  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INF) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(G[u][v]!=NIL){
	if(color[v]!=BLACK && G[u][v]<d[v]){
	  pi[v]=u;
	  d[v]=G[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++) weight+=d[i];
  return weight;
}
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) {
      scanf("%d",&G[i][j]);
    }
  }
  printf("%d\n",prim());
  return 0;
}

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

int  main()
{
	ll a, v; cin >> a >> v;
	ll b, w; cin >> b >> w;
	ll t; cin >> t;

	if (v <= w)
	{
		cout << "NO" << endl;
		return 0;
	}
	else
	{
		ll s = v - w;
		if (s*t >= llabs(a-b))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return (0);
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
 
int arr[105];
 
int main()
{
	int x,n;
	cin>>x>>n;
	int p[n];
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
		arr[p[i]]=1;
	}
	int ans=INT_MAX,res=0;
	for(int i=0;i<105;i++)
	{
		if(arr[i]==0 && abs(x-i)<ans)
		{
			ans=abs(x-i);
			res=i;
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll L, R;
  cin >> L >> R;
  if (R - L >= 2019) {
    cout << 0 << endl;
    return 0;
  }
  int l = L % 2019, r = R % 2019;
  if (l >= r) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 2019;
  for (int i = l; i <= r; ++i) {
    for (int j = i+1; j <= r; ++j) {
      int temp = (i * j) % 2019;
      ans = min(ans, temp);
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

std::string ab("AB");

int main(int argc, char** argv) {
    int64_t n, k;
    cin >> n >> k;
    std::string str;
    cin >> str;

    str[k-1] = str[k-1] - ('A' - 'a');

    cout << str << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int head[N],ver[N*2],nxt[N*2],tot;
int n,k;
int dp[N];
int g[N];
void add(int x,int y)
{
	ver[++tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}
void dfs(int rt,int fa,int dep)
{
	for(int i=head[rt]; i; i=nxt[i])
	{
		int y=ver[i];
		if(y!=fa)
		{
			dfs(y,rt,dep+1);
			g[rt]+=g[y]+1;
			dp[rt]+=dp[y];
		}
	}
	if(dep>k/2)
		dp[rt]=g[rt];
}
int main()
{
	scanf("%d%d",&n,&k);
	int x,y;
	for(int i=1; i<n; i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	int ans=1e9;
	if(k%2==0)
	{
		for(int i=1; i<=n; i++)
		{
			memset(dp,0,sizeof(dp));
			memset(g,0,sizeof(g));
			dfs(i,i,1);
			ans=min(ans,dp[i]);
			//cout<<dp[i]<<endl;
		}
	}
	else
	{
		for(int x=1;x<=n;x++)
		{
			for(int i=head[x];i;i=nxt[i])
			{
				memset(dp,0,sizeof(dp));
				memset(g,0,sizeof(g));
				int y=ver[i];
				dfs(x,y,1);
				dfs(y,x,1);
				ans=min(ans,dp[x]+dp[y]);
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int k = sc.nextInt();
		long sum = 0;
		for(int i = 1; i <= k; i++ ) {
			for(int j = 1; j <= k; j++) {
				for(int m = 1; m <= k; m++) {
					long num = gcd(i, j);
					long num2 = gcd(num, m);
					sum += num2;
				}
			}
		}
		out.println(sum);
		
		out.close();
	}
	  private static long gcd(long m, long n) {
		    if(m < n) return gcd(n, m);
		    if(n == 0) return m;
		    return gcd(n, m % n);
		}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


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

using namespace std;

int main()
{
    long  int a,b,c,d;cin>>a>>b>>c>>d;
    vector <long int> out;
    out.push_back(a*c);
    out.push_back(a*d);
    out.push_back(b*c);
    out.push_back(b*d);
    long int output;
    output = *max_element(out.begin(),out.end());
    cout << output << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
int INF=1000000000;
int cnt=0;
void merge(int A[],int left,int mid,int right){
  int n1,n2;
  n1=mid-left;
  n2=right-mid;
  int L[n1+1];
  int R[n2+1];
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=R[n2]=INF;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      cnt++;
    }else{
      A[k]=R[j];
      j++;
      cnt++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int n;
  std::cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    std::cin>>A[i];
  }
  int left=0;
  int right=n;
  mergeSort(A,left,right);
  for(int i=0;i<n-1;i++){
    std::cout<<A[i]<<" ";
  }
  std::cout<<A[n-1]<<"\n";
  std::cout<<cnt<<"\n";
}



Measured memory_bytes: 6952
a1 = input()
pp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ppp= ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
n = len(pp)
if a1 in pp:
  print('a')
else:
  print('A')

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }

int sum[501][501] = {0};
int p, q;

int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    int L, R;

    for(int i = 1; i <= M; i++){
        cin >> L >> R;
        ++sum[L][R];
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            sum[i][j] += sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
        }
    }

    int ans = 0;
    for(int i = 1; i <= Q; i++){
        cin >> p >> q;
        ans = sum[q][q] - sum[q][p - 1] - sum[p- 1][q] + sum[p - 1][p - 1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int N, K;
vector<pair<int, int>> s;
vector<int> score;
vector<int> score_new;
int neta_cnt, neta_prev, cnt_now, rem_susi;
long long ans;

bool compare_by_sec(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

void delete_susi(int id) {
  s[id].first = INF;
  s[id].second = INF;
}

void reduce_susi() {
  int i = 0;
  while (neta_cnt > K) {
    ans -= (long long)score[i];
    score[i] = INF;
    neta_cnt--;
    i++;
  }

  sort(all(score));
  for (int j = 0; j < neta_cnt; j++) {
    score_new.push_back(score[j]);
  }
}

void add_susi() {
  rep(i, neta_cnt) score_new.push_back(score[i]);
  rep(i, K-neta_cnt) {
    ans += (long long)-s[i].second;
    delete_susi(i);
    rem_susi--;
  } 
}

int main() {
  cin >> N >> K;
  rep(i, N) {
    int t, d;
    cin >> t >> d;
    s.push_back(make_pair(t, -d));
  }

  sort(all(s));

  neta_cnt = 1;
  neta_prev = s[0].first;
  ans = (long long)-s[0].second;
  score.push_back(-s[0].second);
  delete_susi(0);
  for (int i = 1; i < N; i++) {
    if (s[i].first != neta_prev) {
      neta_cnt++;
      neta_prev = s[i].first;
      ans += (long long)-s[i].second;
      score.push_back(-s[i].second);
      delete_susi(i);
    }
  }

  rem_susi = N - neta_cnt;
  sort(all(s), compare_by_sec);
  sort(all(score));


  if (neta_cnt > K) {
    reduce_susi();
  } else if (neta_cnt <= K) {
    add_susi();
  }


  sort(all(s), compare_by_sec);

  ans += (long long)neta_cnt * neta_cnt;

  rep(i, neta_cnt) {
    if (rem_susi <= 0) break;
    long long minus = (long long)(neta_cnt-i) * 2 - 1 + score_new[i];
    long long plus = (long long)-s[i].second;

    if (minus >= plus) {
      break;
    } else {
      ans = ans - minus + plus;
    }

    rem_susi--;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1908